diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/dlg/REUSE.toml b/qt/6.8.1/msvc2022_64/include/QtFreetype/dlg/REUSE.toml new file mode 100644 index 0000000000000000000000000000000000000000..81d6a6b1aa1a0a4121992724b238cf7c6a5de082 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/dlg/REUSE.toml @@ -0,0 +1,7 @@ +version = 1 + +[[annotations]] +path = "*" +precedence = "closest" +SPDX-FileCopyrightText = "Copyright (c) 2019 nyorain" +SPDX-License-Identifier = "BSL-1.0" diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/dlg/dlg.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/dlg/dlg.h new file mode 100644 index 0000000000000000000000000000000000000000..df37a85d97715dcea5f1912861cecd95b898ffcc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/dlg/dlg.h @@ -0,0 +1,290 @@ +// Copyright (c) 2019 nyorain +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt + +#ifndef INC_DLG_DLG_H_ +#define INC_DLG_DLG_H_ + +#include +#include +#include +#include +#include + +// Hosted at https://github.com/nyorain/dlg. +// There are examples and documentation. +// Issue reports and contributions appreciated. + +// - CONFIG - +// Define this macro to make all dlg macros have no effect at all +// #define DLG_DISABLE + +// the log/assertion levels below which logs/assertions are ignored +// defaulted depending on the NDEBUG macro +#ifndef DLG_LOG_LEVEL + #ifdef NDEBUG + #define DLG_LOG_LEVEL dlg_level_warn + #else + #define DLG_LOG_LEVEL dlg_level_trace + #endif +#endif + +#ifndef DLG_ASSERT_LEVEL + #ifdef NDEBUG + #define DLG_ASSERT_LEVEL dlg_level_warn + #else + #define DLG_ASSERT_LEVEL dlg_level_trace + #endif +#endif + +// the assert level of dlg_assert +#ifndef DLG_DEFAULT_ASSERT + #define DLG_DEFAULT_ASSERT dlg_level_error +#endif + +// evaluated to the 'file' member in dlg_origin +#ifndef DLG_FILE + #define DLG_FILE dlg__strip_root_path(__FILE__, DLG_BASE_PATH) + + // the base path stripped from __FILE__. If you don't override DLG_FILE set this to + // the project root to make 'main.c' from '/some/bullshit/main.c' + #ifndef DLG_BASE_PATH + #define DLG_BASE_PATH "" + #endif +#endif + +// Default tags applied to all logs/assertions (in the defining file). +// Must be in format ```#define DLG_DEFAULT_TAGS "tag1", "tag2"``` +// or just nothing (as defaulted here) +#ifndef DLG_DEFAULT_TAGS + #define DLG_DEFAULT_TAGS_TERM NULL +#else + #define DLG_DEFAULT_TAGS_TERM DLG_DEFAULT_TAGS, NULL +#endif + +// The function used for formatting. Can have any signature, but must be callable with +// the arguments the log/assertions macros are called with. Must return a const char* +// that will not be freed by dlg, the formatting function must keep track of it. +// The formatting function might use dlg_thread_buffer or a custom owned buffer. +// The returned const char* has to be valid until the dlg log/assertion ends. +// Usually a c function with ... (i.e. using va_list) or a variadic c++ template do +// allow formatting. +#ifndef DLG_FMT_FUNC + #define DLG_FMT_FUNC dlg__printf_format +#endif + +// Only overwrite (i.e. predefine) this if you know what you are doing. +// On windows this is used to add the dllimport specified. +// If you are using the static version of dlg (on windows) define +// DLG_STATIC before including dlg.h +#ifndef DLG_API + #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(DLG_STATIC) + #define DLG_API __declspec(dllimport) + #else + #define DLG_API + #endif +#endif + +// This macro is used when an assertion fails. It gets the source expression +// and can return an alternative (that must stay alive). +// Mainly useful to execute something on failed assertion. +#ifndef DLG_FAILED_ASSERTION_TEXT + #define DLG_FAILED_ASSERTION_TEXT(x) x +#endif + +// - utility - +// two methods needed since cplusplus does not support compound literals +// and c does not support uniform initialization/initializer lists +#ifdef __cplusplus + #include + #define DLG_CREATE_TAGS(...) std::initializer_list \ + {DLG_DEFAULT_TAGS_TERM, __VA_ARGS__, NULL}.begin() +#else + #define DLG_CREATE_TAGS(...) (const char* const[]) {DLG_DEFAULT_TAGS_TERM, __VA_ARGS__, NULL} +#endif + +#ifdef __GNUC__ + #define DLG_PRINTF_ATTRIB(a, b) __attribute__ ((format (printf, a, b))) +#else + #define DLG_PRINTF_ATTRIB(a, b) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +// Represents the importance of a log/assertion call. +enum dlg_level { + dlg_level_trace = 0, // temporary used debug, e.g. to check if control reaches function + dlg_level_debug, // general debugging, prints e.g. all major events + dlg_level_info, // general useful information + dlg_level_warn, // warning, something went wrong but might have no (really bad) side effect + dlg_level_error, // something really went wrong; expect serious issues + dlg_level_fatal // critical error; application is likely to crash/exit +}; + +// Holds various information associated with a log/assertion call. +// Forwarded to the output handler. +struct dlg_origin { + const char* file; + unsigned int line; + const char* func; + enum dlg_level level; + const char** tags; // null-terminated + const char* expr; // assertion expression, otherwise null +}; + +// Type of the output handler, see dlg_set_handler. +typedef void(*dlg_handler)(const struct dlg_origin* origin, const char* string, void* data); + +#ifndef DLG_DISABLE + // Tagged/Untagged logging with variable level + // Tags must always be in the format `("tag1", "tag2")` (including brackets) + // Example usages: + // dlg_log(dlg_level_warning, "test 1") + // dlg_logt(("tag1, "tag2"), dlg_level_debug, "test %d", 2) + #define dlg_log(level, ...) if(level >= DLG_LOG_LEVEL) \ + dlg__do_log(level, DLG_CREATE_TAGS(NULL), DLG_FILE, __LINE__, __func__, \ + DLG_FMT_FUNC(__VA_ARGS__), NULL) + #define dlg_logt(level, tags, ...) if(level >= DLG_LOG_LEVEL) \ + dlg__do_log(level, DLG_CREATE_TAGS tags, DLG_FILE, __LINE__, __func__, \ + DLG_FMT_FUNC(__VA_ARGS__), NULL) + + // Dynamic level assert macros in various versions for additional arguments + // Example usages: + // dlg_assertl(dlg_level_warning, data != nullptr); + // dlg_assertlt(("tag1, "tag2"), dlg_level_trace, data != nullptr); + // dlg_asserttlm(("tag1), dlg_level_warning, data != nullptr, "Data must not be null"); + // dlg_assertlm(dlg_level_error, data != nullptr, "Data must not be null"); + #define dlg_assertl(level, expr) if(level >= DLG_ASSERT_LEVEL && !(expr)) \ + dlg__do_log(level, DLG_CREATE_TAGS(NULL), DLG_FILE, __LINE__, __func__, NULL, \ + DLG_FAILED_ASSERTION_TEXT(#expr)) + #define dlg_assertlt(level, tags, expr) if(level >= DLG_ASSERT_LEVEL && !(expr)) \ + dlg__do_log(level, DLG_CREATE_TAGS tags, DLG_FILE, __LINE__, __func__, NULL, \ + DLG_FAILED_ASSERTION_TEXT(#expr)) + #define dlg_assertlm(level, expr, ...) if(level >= DLG_ASSERT_LEVEL && !(expr)) \ + dlg__do_log(level, DLG_CREATE_TAGS(NULL), DLG_FILE, __LINE__, __func__, \ + DLG_FMT_FUNC(__VA_ARGS__), DLG_FAILED_ASSERTION_TEXT(#expr)) + #define dlg_assertltm(level, tags, expr, ...) if(level >= DLG_ASSERT_LEVEL && !(expr)) \ + dlg__do_log(level, DLG_CREATE_TAGS tags, DLG_FILE, __LINE__, \ + __func__, DLG_FMT_FUNC(__VA_ARGS__), DLG_FAILED_ASSERTION_TEXT(#expr)) + + #define dlg__assert_or(level, tags, expr, code, msg) if(!(expr)) {\ + if(level >= DLG_ASSERT_LEVEL) \ + dlg__do_log(level, tags, DLG_FILE, __LINE__, __func__, msg, \ + DLG_FAILED_ASSERTION_TEXT(#expr)); \ + code; \ + } (void) NULL + + // - Private interface: not part of the abi/api but needed in macros - + // Formats the given format string and arguments as printf would, uses the thread buffer. + DLG_API const char* dlg__printf_format(const char* format, ...) DLG_PRINTF_ATTRIB(1, 2); + DLG_API void dlg__do_log(enum dlg_level lvl, const char* const*, const char*, int, + const char*, const char*, const char*); + DLG_API const char* dlg__strip_root_path(const char* file, const char* base); + +#else // DLG_DISABLE + + #define dlg_log(level, ...) + #define dlg_logt(level, tags, ...) + + #define dlg_assertl(level, expr) // assert without tags/message + #define dlg_assertlt(level, tags, expr) // assert with tags + #define dlg_assertlm(level, expr, ...) // assert with message + #define dlg_assertltm(level, tags, expr, ...) // assert with tags & message + + #define dlg__assert_or(level, tags, expr, code, msg) if(!(expr)) { code; } (void) NULL +#endif // DLG_DISABLE + +// The API below is independent from DLG_DISABLE + +// Sets the handler that is responsible for formatting and outputting log calls. +// This function is not thread safe and the handler is set globally. +// The handler itself must not change dlg tags or call a dlg macro (if it +// does so, the provided string or tags array in 'origin' might get invalid). +// The handler can also be used for various other things such as dealing +// with failed assertions or filtering calls based on the passed tags. +// The default handler is dlg_default_output (see its doc for more info). +// If using c++ make sure the registered handler cannot throw e.g. by +// wrapping everything into a try-catch blog. +DLG_API void dlg_set_handler(dlg_handler handler, void* data); + +// The default output handler. +// Only use this to reset the output handler, prefer to use +// dlg_generic_output (from output.h) which this function simply calls. +// It also flushes the stream used and correctly outputs even from multiple threads. +DLG_API void dlg_default_output(const struct dlg_origin*, const char* string, void*); + +// Returns the currently active dlg handler and sets `data` to +// its user data pointer. `data` must not be NULL. +// Useful to create handler chains. +// This function is not threadsafe, i.e. retrieving the handler while +// changing it from another thread is unsafe. +// See `dlg_set_handler`. +DLG_API dlg_handler dlg_get_handler(void** data); + +// Adds the given tag associated with the given function to the thread specific list. +// If func is not NULL the tag will only applied to calls from the same function. +// Remove the tag again calling dlg_remove_tag (with exactly the same pointers!). +// Does not check if the tag is already present. +DLG_API void dlg_add_tag(const char* tag, const char* func); + +// Removes a tag added with dlg_add_tag (has no effect for tags no present). +// The pointers must be exactly the same pointers that were supplied to dlg_add_tag, +// this function will not check using strcmp. When the same tag/func combination +// is added multiple times, this function remove exactly one candidate, it is +// undefined which. Returns whether a tag was found (and removed). +DLG_API bool dlg_remove_tag(const char* tag, const char* func); + +// Returns the thread-specific buffer and its size for dlg. +// The buffer should only be used by formatting functions. +// The buffer can be reallocated and the size changed, just make sure +// to update both values correctly. +DLG_API char** dlg_thread_buffer(size_t** size); + +// Untagged leveled logging +#define dlg_trace(...) dlg_log(dlg_level_trace, __VA_ARGS__) +#define dlg_debug(...) dlg_log(dlg_level_debug, __VA_ARGS__) +#define dlg_info(...) dlg_log(dlg_level_info, __VA_ARGS__) +#define dlg_warn(...) dlg_log(dlg_level_warn, __VA_ARGS__) +#define dlg_error(...) dlg_log(dlg_level_error, __VA_ARGS__) +#define dlg_fatal(...) dlg_log(dlg_level_fatal, __VA_ARGS__) + +// Tagged leveled logging +#define dlg_tracet(tags, ...) dlg_logt(dlg_level_trace, tags, __VA_ARGS__) +#define dlg_debugt(tags, ...) dlg_logt(dlg_level_debug, tags, __VA_ARGS__) +#define dlg_infot(tags, ...) dlg_logt(dlg_level_info, tags, __VA_ARGS__) +#define dlg_warnt(tags, ...) dlg_logt(dlg_level_warn, tags, __VA_ARGS__) +#define dlg_errort(tags, ...) dlg_logt(dlg_level_error, tags, __VA_ARGS__) +#define dlg_fatalt(tags, ...) dlg_logt(dlg_level_fatal, tags, __VA_ARGS__) + +// Assert macros useing DLG_DEFAULT_ASSERT as level +#define dlg_assert(expr) dlg_assertl(DLG_DEFAULT_ASSERT, expr) +#define dlg_assertt(tags, expr) dlg_assertlt(DLG_DEFAULT_ASSERT, tags, expr) +#define dlg_assertm(expr, ...) dlg_assertlm(DLG_DEFAULT_ASSERT, expr, __VA_ARGS__) +#define dlg_asserttm(tags, expr, ...) dlg_assertltm(DLG_DEFAULT_ASSERT, tags, expr, __VA_ARGS__) + +// If (expr) does not evaluate to true, always executes 'code' (no matter what +// DLG_ASSERT_LEVEL is or if dlg is disabled or not). +// When dlg is enabled and the level is greater or equal to DLG_ASSERT_LEVEL, +// logs the failed assertion. +// Example usages: +// dlg_assertl_or(dlg_level_warn, data != nullptr, return); +// dlg_assertlm_or(dlg_level_fatal, data != nullptr, return, "Data must not be null"); +// dlg_assert_or(data != nullptr, logError(); return false); +#define dlg_assertltm_or(level, tags, expr, code, ...) dlg__assert_or(level, \ + DLG_CREATE_TAGS tags, expr, code, DLG_FMT_FUNC(__VA_ARGS__)) +#define dlg_assertlm_or(level, expr, code, ...) dlg__assert_or(level, \ + DLG_CREATE_TAGS(NULL), expr, code, DLG_FMT_FUNC(__VA_ARGS__)) +#define dlg_assertl_or(level, expr, code) dlg__assert_or(level, \ + DLG_CREATE_TAGS(NULL), expr, code, NULL) + +#define dlg_assert_or(expr, code) dlg_assertl_or(DLG_DEFAULT_ASSERT, expr, code) +#define dlg_assertm_or(expr, code, ...) dlg_assertlm_or(DLG_DEFAULT_ASSERT, expr, code, __VA_ARGS__) + +#ifdef __cplusplus +} +#endif + +#endif // header guard diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/dlg/output.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/dlg/output.h new file mode 100644 index 0000000000000000000000000000000000000000..bc7f1190297f94a5d01d637ebdfc5143c9ceb267 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/dlg/output.h @@ -0,0 +1,172 @@ +// Copyright (c) 2019 nyorain +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt + +#ifndef INC_DLG_OUTPUT_H_ +#define INC_DLG_OUTPUT_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// Text style +enum dlg_text_style { + dlg_text_style_reset = 0, + dlg_text_style_bold = 1, + dlg_text_style_dim = 2, + dlg_text_style_italic = 3, + dlg_text_style_underline = 4, + dlg_text_style_blink = 5, + dlg_text_style_rblink = 6, + dlg_text_style_reversed = 7, + dlg_text_style_conceal = 8, + dlg_text_style_crossed = 9, + dlg_text_style_none, +}; + +// Text color +enum dlg_color { + dlg_color_black = 0, + dlg_color_red, + dlg_color_green, + dlg_color_yellow, + dlg_color_blue, + dlg_color_magenta, + dlg_color_cyan, + dlg_color_gray, + dlg_color_reset = 9, + + dlg_color_black2 = 60, + dlg_color_red2, + dlg_color_green2, + dlg_color_yellow2, + dlg_color_blue2, + dlg_color_magenta2, + dlg_color_cyan2, + dlg_color_gray2, + + dlg_color_none = 69, +}; + +struct dlg_style { + enum dlg_text_style style; + enum dlg_color fg; + enum dlg_color bg; +}; + +// Like fprintf but fixes utf-8 output to console on windows. +// On non-windows sytems just uses the corresponding standard library +// functions. On windows, if dlg was compiled with the win_console option, +// will first try to output it in a way that allows the default console +// to display utf-8. If that fails, will fall back to the standard +// library functions. +DLG_API int dlg_fprintf(FILE* stream, const char* format, ...) DLG_PRINTF_ATTRIB(2, 3); +DLG_API int dlg_vfprintf(FILE* stream, const char* format, va_list list); + +// Like dlg_printf, but also applies the given style to this output. +// The style will always be applied (using escape sequences), independent of the given stream. +// On windows escape sequences don't work out of the box, see dlg_win_init_ansi(). +DLG_API int dlg_styled_fprintf(FILE* stream, struct dlg_style style, + const char* format, ...) DLG_PRINTF_ATTRIB(3, 4); + +// Features to output from the generic output handler. +// Some features might have only an effect in the specializations. +enum dlg_output_feature { + dlg_output_tags = 1, // output tags list + dlg_output_time = 2, // output time of log call (hour:minute:second) + dlg_output_style = 4, // whether to use the supplied styles + dlg_output_func = 8, // output function + dlg_output_file_line = 16, // output file:line, + dlg_output_newline = 32, // output a newline at the end + dlg_output_threadsafe = 64, // locks stream before printing + dlg_output_time_msecs = 128 // output micro seconds (ms on windows) +}; + +// The default level-dependent output styles. The array values represent the styles +// to be used for the associated level (i.e. [0] for trace level). +DLG_API extern const struct dlg_style dlg_default_output_styles[6]; + +// Generic output function. Used by the default output handler and might be useful +// for custom output handlers (that don't want to manually format the output). +// Will call the given output func with the given data (and format + args to print) +// for everything it has to print in printf format. +// See also the *_stream and *_buf specializations for common usage. +// The given output function must not be NULL. +typedef void(*dlg_generic_output_handler)(void* data, const char* format, ...); +DLG_API void dlg_generic_output(dlg_generic_output_handler output, void* data, + unsigned int features, const struct dlg_origin* origin, const char* string, + const struct dlg_style styles[6]); + +// Generic output function, using a format string instead of feature flags. +// Use following conversion characters: +// %h - output the time in H:M:S format +// %m - output the time in milliseconds +// %t - output the full list of tags, comma separated +// %f - output the function name noted in the origin +// %o - output the file:line of the origin +// %s - print the appropriate style escape sequence. +// %r - print the escape sequence to reset the style. +// %c - The content of the log/assert +// %% - print the '%' character +// Only the above specified conversion characters are valid, the rest are +// written as it is. +DLG_API void dlg_generic_outputf(dlg_generic_output_handler output, void* data, + const char* format_string, const struct dlg_origin* origin, + const char* string, const struct dlg_style styles[6]); + +// Generic output function. Used by the default output handler and might be useful +// for custom output handlers (that don't want to manually format the output). +// If stream is NULL uses stdout. +// Automatically uses dlg_fprintf to assure correct utf-8 even on windows consoles. +// Locks the stream (i.e. assures threadsafe access) when the associated feature +// is passed (note that stdout/stderr might still mix from multiple threads). +DLG_API void dlg_generic_output_stream(FILE* stream, unsigned int features, + const struct dlg_origin* origin, const char* string, + const struct dlg_style styles[6]); +DLG_API void dlg_generic_outputf_stream(FILE* stream, const char* format_string, + const struct dlg_origin* origin, const char* string, + const struct dlg_style styles[6], bool lock_stream); + +// Generic output function (see dlg_generic_output) that uses a buffer instead of +// a stream. buf must at least point to *size bytes. Will set *size to the number +// of bytes written (capped to the given size), if buf == NULL will set *size +// to the needed size. The size parameter must not be NULL. +DLG_API void dlg_generic_output_buf(char* buf, size_t* size, unsigned int features, + const struct dlg_origin* origin, const char* string, + const struct dlg_style styles[6]); +DLG_API void dlg_generic_outputf_buf(char* buf, size_t* size, const char* format_string, + const struct dlg_origin* origin, const char* string, + const struct dlg_style styles[6]); + +// Returns if the given stream is a tty. Useful for custom output handlers +// e.g. to determine whether to use color. +// NOTE: Due to windows limitations currently returns false for wsl ttys. +DLG_API bool dlg_is_tty(FILE* stream); + +// Returns the null-terminated escape sequence for the given style into buf. +// Undefined behvaiour if any member of style has a value outside its enum range (will +// probably result in a buffer overflow or garbage being printed). +// If all member of style are 'none' will simply nullterminate the first buf char. +DLG_API void dlg_escape_sequence(struct dlg_style style, char buf[12]); + +// The reset style escape sequence. +DLG_API extern const char* const dlg_reset_sequence; + +// Just returns true without other effect on non-windows systems or if dlg +// was compiled without the win_console option. +// On windows tries to set the console mode to ansi to make escape sequences work. +// This works only on newer windows 10 versions. Returns false on error. +// Only the first call to it will have an effect, following calls just return the result. +// The function is threadsafe. Automatically called by the default output handler. +// This will only be able to set the mode for the stdout and stderr consoles, so +// other streams to consoles will still not work. +DLG_API bool dlg_win_init_ansi(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // header guard diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/REUSE.toml b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/REUSE.toml new file mode 100644 index 0000000000000000000000000000000000000000..5e93797237b3c55591fbe97f2e0b5ab03026dca9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/REUSE.toml @@ -0,0 +1,123 @@ +version = 1 + +[[annotations]] +path = "ftbzip2.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2010-2023 by Joel Klinghed." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftmac.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 1996-2023 by Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftgxval.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2004-2023 by Masatake YAMATO, Redhat K.K, David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "otsvg.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2022-2023 by David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftcid.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2007-2023 by Dereg Clegg and Michael Toftdal." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = ["freetype.h", "ftbbox.h", "ftcache.h", "fterrors.h", "ftglyph.h", + "ftimage.h", "ftlist.h", "ftmac.h", "ftmm.h", "ftmodapi.h", "ftoutln.h", + "ftrender.h", "ftsizes.h", "ftsnames.h", "ftsystem.h", "fttypes.h", + "t1tables.h", "ttnameid.h", "tttables.h", "tttags.h","ftchapters.h"] +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 1996-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftsynth.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2000-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = ["ftmoderr.h", "fttrigon.h"] +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2001-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = ["ftbdf.h", "fterrdef.h", "ftfntfmt.h", "ftgzip.h", "ftincrem.h", "ftpfr.h", "ftstroke.h"] +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2002-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftwinfnt.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2003-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = ["ftbitmap.h", "ftlzw.h", "ftotval.h"] +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2004-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftlcdfil.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2006-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftgasp.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2007-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftadvanc.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2008-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = ["ftdriver.h", "ftparams.h"] +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2017-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftcolor.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2018-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftlogging.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2020-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/REUSE.toml b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/REUSE.toml new file mode 100644 index 0000000000000000000000000000000000000000..f51f6cc28dcecad4d1b5adcb3b0cc428e0131d76 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/REUSE.toml @@ -0,0 +1,28 @@ +version = 1 + +[[annotations]] +path = "ftmodule.h" +precedence = "override" +SPDX-FileCopyrightText = "None" +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = ["mac-support.h", "integer-types.h", "ftoption.h", "ftheader.h", "ftconfig.h"] +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 1996-2023 by Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "ftstdlib.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2002-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" + +[[annotations]] +path = "public-macros.h" +comment = "Copyright continuation line ignored by reuse for lack of word Copyright at start." +precedence = "override" +SPDX-FileCopyrightText = "Copyright (C) 2020-2023 by David Turner, Robert Wilhelm, and Werner Lemberg." +SPDX-License-Identifier = "FTL OR GPL-2.0-only" diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftconfig.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftconfig.h new file mode 100644 index 0000000000000000000000000000000000000000..0830d3f2eb1617f0545d208220590fea20029eb9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftconfig.h @@ -0,0 +1,51 @@ +/**************************************************************************** + * + * ftconfig.h + * + * ANSI-specific configuration file (specification only). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This header file contains a number of macro definitions that are used by + * the rest of the engine. Most of the macros here are automatically + * determined at compile time, and you should not need to change it to port + * FreeType, except to compile the library with a non-ANSI compiler. + * + * Note however that if some specific modifications are needed, we advise + * you to place a modified copy in your build directory. + * + * The build directory is usually `builds/`, and contains + * system-specific files that are always included first when building the + * library. + * + * This ANSI version should stay in `include/config/`. + * + */ + +#ifndef FTCONFIG_H_ +#define FTCONFIG_H_ + +#include +#include FT_CONFIG_OPTIONS_H +#include FT_CONFIG_STANDARD_LIBRARY_H + +#include +#include +#include + +#endif /* FTCONFIG_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftheader.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftheader.h new file mode 100644 index 0000000000000000000000000000000000000000..f491d232bf7d62a4d4a0bbedacf2f851f9fe8afb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftheader.h @@ -0,0 +1,836 @@ +/**************************************************************************** + * + * ftheader.h + * + * Build macros of the FreeType 2 library. + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +#ifndef FTHEADER_H_ +#define FTHEADER_H_ + + + /*@***********************************************************************/ + /* */ + /* */ + /* FT_BEGIN_HEADER */ + /* */ + /* */ + /* This macro is used in association with @FT_END_HEADER in header */ + /* files to ensure that the declarations within are properly */ + /* encapsulated in an `extern "C" { .. }` block when included from a */ + /* C++ compiler. */ + /* */ +#ifndef FT_BEGIN_HEADER +# ifdef __cplusplus +# define FT_BEGIN_HEADER extern "C" { +# else +# define FT_BEGIN_HEADER /* nothing */ +# endif +#endif + + + /*@***********************************************************************/ + /* */ + /* */ + /* FT_END_HEADER */ + /* */ + /* */ + /* This macro is used in association with @FT_BEGIN_HEADER in header */ + /* files to ensure that the declarations within are properly */ + /* encapsulated in an `extern "C" { .. }` block when included from a */ + /* C++ compiler. */ + /* */ +#ifndef FT_END_HEADER +# ifdef __cplusplus +# define FT_END_HEADER } +# else +# define FT_END_HEADER /* nothing */ +# endif +#endif + + + /************************************************************************** + * + * Aliases for the FreeType 2 public and configuration files. + * + */ + + /************************************************************************** + * + * @section: + * header_file_macros + * + * @title: + * Header File Macros + * + * @abstract: + * Macro definitions used to `#include` specific header files. + * + * @description: + * In addition to the normal scheme of including header files like + * + * ``` + * #include + * #include + * #include + * ``` + * + * it is possible to used named macros instead. They can be used + * directly in `#include` statements as in + * + * ``` + * #include FT_FREETYPE_H + * #include FT_MULTIPLE_MASTERS_H + * #include FT_GLYPH_H + * ``` + * + * These macros were introduced to overcome the infamous 8.3~naming rule + * required by DOS (and `FT_MULTIPLE_MASTERS_H` is a lot more meaningful + * than `ftmm.h`). + * + */ + + + /* configuration files */ + + /************************************************************************** + * + * @macro: + * FT_CONFIG_CONFIG_H + * + * @description: + * A macro used in `#include` statements to name the file containing + * FreeType~2 configuration data. + * + */ +#ifndef FT_CONFIG_CONFIG_H +#define FT_CONFIG_CONFIG_H +#endif + + + /************************************************************************** + * + * @macro: + * FT_CONFIG_STANDARD_LIBRARY_H + * + * @description: + * A macro used in `#include` statements to name the file containing + * FreeType~2 interface to the standard C library functions. + * + */ +#ifndef FT_CONFIG_STANDARD_LIBRARY_H +#define FT_CONFIG_STANDARD_LIBRARY_H +#endif + + + /************************************************************************** + * + * @macro: + * FT_CONFIG_OPTIONS_H + * + * @description: + * A macro used in `#include` statements to name the file containing + * FreeType~2 project-specific configuration options. + * + */ +#ifndef FT_CONFIG_OPTIONS_H +#define FT_CONFIG_OPTIONS_H +#endif + + + /************************************************************************** + * + * @macro: + * FT_CONFIG_MODULES_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * list of FreeType~2 modules that are statically linked to new library + * instances in @FT_Init_FreeType. + * + */ +#ifndef FT_CONFIG_MODULES_H +#define FT_CONFIG_MODULES_H +#endif + + /* */ + + /* public headers */ + + /************************************************************************** + * + * @macro: + * FT_FREETYPE_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * base FreeType~2 API. + * + */ +#define FT_FREETYPE_H + + + /************************************************************************** + * + * @macro: + * FT_ERRORS_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * list of FreeType~2 error codes (and messages). + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_ERRORS_H + + + /************************************************************************** + * + * @macro: + * FT_MODULE_ERRORS_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * list of FreeType~2 module error offsets (and messages). + * + */ +#define FT_MODULE_ERRORS_H + + + /************************************************************************** + * + * @macro: + * FT_SYSTEM_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 interface to low-level operations (i.e., memory management + * and stream i/o). + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_SYSTEM_H + + + /************************************************************************** + * + * @macro: + * FT_IMAGE_H + * + * @description: + * A macro used in `#include` statements to name the file containing type + * definitions related to glyph images (i.e., bitmaps, outlines, + * scan-converter parameters). + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_IMAGE_H + + + /************************************************************************** + * + * @macro: + * FT_TYPES_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * basic data types defined by FreeType~2. + * + * It is included by @FT_FREETYPE_H. + * + */ +#define FT_TYPES_H + + + /************************************************************************** + * + * @macro: + * FT_LIST_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * list management API of FreeType~2. + * + * (Most applications will never need to include this file.) + * + */ +#define FT_LIST_H + + + /************************************************************************** + * + * @macro: + * FT_OUTLINE_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * scalable outline management API of FreeType~2. + * + */ +#define FT_OUTLINE_H + + + /************************************************************************** + * + * @macro: + * FT_SIZES_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * API which manages multiple @FT_Size objects per face. + * + */ +#define FT_SIZES_H + + + /************************************************************************** + * + * @macro: + * FT_MODULE_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * module management API of FreeType~2. + * + */ +#define FT_MODULE_H + + + /************************************************************************** + * + * @macro: + * FT_RENDER_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * renderer module management API of FreeType~2. + * + */ +#define FT_RENDER_H + + + /************************************************************************** + * + * @macro: + * FT_DRIVER_H + * + * @description: + * A macro used in `#include` statements to name the file containing + * structures and macros related to the driver modules. + * + */ +#define FT_DRIVER_H + + + /************************************************************************** + * + * @macro: + * FT_AUTOHINTER_H + * + * @description: + * A macro used in `#include` statements to name the file containing + * structures and macros related to the auto-hinting module. + * + * Deprecated since version~2.9; use @FT_DRIVER_H instead. + * + */ +#define FT_AUTOHINTER_H FT_DRIVER_H + + + /************************************************************************** + * + * @macro: + * FT_CFF_DRIVER_H + * + * @description: + * A macro used in `#include` statements to name the file containing + * structures and macros related to the CFF driver module. + * + * Deprecated since version~2.9; use @FT_DRIVER_H instead. + * + */ +#define FT_CFF_DRIVER_H FT_DRIVER_H + + + /************************************************************************** + * + * @macro: + * FT_TRUETYPE_DRIVER_H + * + * @description: + * A macro used in `#include` statements to name the file containing + * structures and macros related to the TrueType driver module. + * + * Deprecated since version~2.9; use @FT_DRIVER_H instead. + * + */ +#define FT_TRUETYPE_DRIVER_H FT_DRIVER_H + + + /************************************************************************** + * + * @macro: + * FT_PCF_DRIVER_H + * + * @description: + * A macro used in `#include` statements to name the file containing + * structures and macros related to the PCF driver module. + * + * Deprecated since version~2.9; use @FT_DRIVER_H instead. + * + */ +#define FT_PCF_DRIVER_H FT_DRIVER_H + + + /************************************************************************** + * + * @macro: + * FT_TYPE1_TABLES_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * types and API specific to the Type~1 format. + * + */ +#define FT_TYPE1_TABLES_H + + + /************************************************************************** + * + * @macro: + * FT_TRUETYPE_IDS_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * enumeration values which identify name strings, languages, encodings, + * etc. This file really contains a _large_ set of constant macro + * definitions, taken from the TrueType and OpenType specifications. + * + */ +#define FT_TRUETYPE_IDS_H + + + /************************************************************************** + * + * @macro: + * FT_TRUETYPE_TABLES_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * types and API specific to the TrueType (as well as OpenType) format. + * + */ +#define FT_TRUETYPE_TABLES_H + + + /************************************************************************** + * + * @macro: + * FT_TRUETYPE_TAGS_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * definitions of TrueType four-byte 'tags' which identify blocks in + * SFNT-based font formats (i.e., TrueType and OpenType). + * + */ +#define FT_TRUETYPE_TAGS_H + + + /************************************************************************** + * + * @macro: + * FT_BDF_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * definitions of an API which accesses BDF-specific strings from a face. + * + */ +#define FT_BDF_H + + + /************************************************************************** + * + * @macro: + * FT_CID_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * definitions of an API which access CID font information from a face. + * + */ +#define FT_CID_H + + + /************************************************************************** + * + * @macro: + * FT_GZIP_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * definitions of an API which supports gzip-compressed files. + * + */ +#define FT_GZIP_H + + + /************************************************************************** + * + * @macro: + * FT_LZW_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * definitions of an API which supports LZW-compressed files. + * + */ +#define FT_LZW_H + + + /************************************************************************** + * + * @macro: + * FT_BZIP2_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * definitions of an API which supports bzip2-compressed files. + * + */ +#define FT_BZIP2_H + + + /************************************************************************** + * + * @macro: + * FT_WINFONTS_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * definitions of an API which supports Windows FNT files. + * + */ +#define FT_WINFONTS_H + + + /************************************************************************** + * + * @macro: + * FT_GLYPH_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * API of the optional glyph management component. + * + */ +#define FT_GLYPH_H + + + /************************************************************************** + * + * @macro: + * FT_BITMAP_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * API of the optional bitmap conversion component. + * + */ +#define FT_BITMAP_H + + + /************************************************************************** + * + * @macro: + * FT_BBOX_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * API of the optional exact bounding box computation routines. + * + */ +#define FT_BBOX_H + + + /************************************************************************** + * + * @macro: + * FT_CACHE_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * API of the optional FreeType~2 cache sub-system. + * + */ +#define FT_CACHE_H + + + /************************************************************************** + * + * @macro: + * FT_MAC_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * Macintosh-specific FreeType~2 API. The latter is used to access fonts + * embedded in resource forks. + * + * This header file must be explicitly included by client applications + * compiled on the Mac (note that the base API still works though). + * + */ +#define FT_MAC_H + + + /************************************************************************** + * + * @macro: + * FT_MULTIPLE_MASTERS_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * optional multiple-masters management API of FreeType~2. + * + */ +#define FT_MULTIPLE_MASTERS_H + + + /************************************************************************** + * + * @macro: + * FT_SFNT_NAMES_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * optional FreeType~2 API which accesses embedded 'name' strings in + * SFNT-based font formats (i.e., TrueType and OpenType). + * + */ +#define FT_SFNT_NAMES_H + + + /************************************************************************** + * + * @macro: + * FT_OPENTYPE_VALIDATE_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * optional FreeType~2 API which validates OpenType tables ('BASE', + * 'GDEF', 'GPOS', 'GSUB', 'JSTF'). + * + */ +#define FT_OPENTYPE_VALIDATE_H + + + /************************************************************************** + * + * @macro: + * FT_GX_VALIDATE_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * optional FreeType~2 API which validates TrueTypeGX/AAT tables ('feat', + * 'mort', 'morx', 'bsln', 'just', 'kern', 'opbd', 'trak', 'prop'). + * + */ +#define FT_GX_VALIDATE_H + + + /************************************************************************** + * + * @macro: + * FT_PFR_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which accesses PFR-specific data. + * + */ +#define FT_PFR_H + + + /************************************************************************** + * + * @macro: + * FT_STROKER_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which provides functions to stroke outline paths. + */ +#define FT_STROKER_H + + + /************************************************************************** + * + * @macro: + * FT_SYNTHESIS_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which performs artificial obliquing and emboldening. + */ +#define FT_SYNTHESIS_H + + + /************************************************************************** + * + * @macro: + * FT_FONT_FORMATS_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which provides functions specific to font formats. + */ +#define FT_FONT_FORMATS_H + + /* deprecated */ +#define FT_XFREE86_H FT_FONT_FORMATS_H + + + /************************************************************************** + * + * @macro: + * FT_TRIGONOMETRY_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which performs trigonometric computations (e.g., + * cosines and arc tangents). + */ +#define FT_TRIGONOMETRY_H + + + /************************************************************************** + * + * @macro: + * FT_LCD_FILTER_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which performs color filtering for subpixel rendering. + */ +#define FT_LCD_FILTER_H + + + /************************************************************************** + * + * @macro: + * FT_INCREMENTAL_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which performs incremental glyph loading. + */ +#define FT_INCREMENTAL_H + + + /************************************************************************** + * + * @macro: + * FT_GASP_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which returns entries from the TrueType GASP table. + */ +#define FT_GASP_H + + + /************************************************************************** + * + * @macro: + * FT_ADVANCES_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which returns individual and ranged glyph advances. + */ +#define FT_ADVANCES_H + + + /************************************************************************** + * + * @macro: + * FT_COLOR_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which handles the OpenType 'CPAL' table. + */ +#define FT_COLOR_H + + + /************************************************************************** + * + * @macro: + * FT_OTSVG_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which handles the OpenType 'SVG~' glyphs. + */ +#define FT_OTSVG_H + + + /* */ + + /* These header files don't need to be included by the user. */ +#define FT_ERROR_DEFINITIONS_H +#define FT_PARAMETER_TAGS_H + + /* Deprecated macros. */ +#define FT_UNPATENTED_HINTING_H +#define FT_TRUETYPE_UNPATENTED_H + + /* `FT_CACHE_H` is the only header file needed for the cache subsystem. */ +#define FT_CACHE_IMAGE_H FT_CACHE_H +#define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H +#define FT_CACHE_CHARMAP_H FT_CACHE_H + + /* The internals of the cache sub-system are no longer exposed. We */ + /* default to `FT_CACHE_H` at the moment just in case, but we know */ + /* of no rogue client that uses them. */ + /* */ +#define FT_CACHE_MANAGER_H FT_CACHE_H +#define FT_CACHE_INTERNAL_MRU_H FT_CACHE_H +#define FT_CACHE_INTERNAL_MANAGER_H FT_CACHE_H +#define FT_CACHE_INTERNAL_CACHE_H FT_CACHE_H +#define FT_CACHE_INTERNAL_GLYPH_H FT_CACHE_H +#define FT_CACHE_INTERNAL_IMAGE_H FT_CACHE_H +#define FT_CACHE_INTERNAL_SBITS_H FT_CACHE_H + +/* TODO(david): Move this section below to a different header */ +#ifdef FT2_BUILD_LIBRARY +#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ + + /* We disable the warning `conditional expression is constant' here */ + /* in order to compile cleanly with the maximum level of warnings. */ + /* In particular, the warning complains about stuff like `while(0)' */ + /* which is very useful in macro definitions. There is no benefit */ + /* in having it enabled. */ +#pragma warning( disable : 4127 ) + +#endif /* _MSC_VER */ +#endif /* FT2_BUILD_LIBRARY */ + +#endif /* FTHEADER_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftmodule.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftmodule.h new file mode 100644 index 0000000000000000000000000000000000000000..2ef7a73238cd763bb3b60e32a9b3580dc5adc4cc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftmodule.h @@ -0,0 +1,33 @@ +/* + * This file registers the FreeType modules compiled into the library. + * + * If you use GNU make, this file IS NOT USED! Instead, it is created in + * the objects directory (normally `/objs/`) based on information + * from `/modules.cfg`. + * + * Please read `docs/INSTALL.ANY` and `docs/CUSTOMIZE` how to compile + * FreeType without GNU make. + * + */ + +FT_USE_MODULE( FT_Module_Class, autofit_module_class ) +FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class ) +FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) +FT_USE_MODULE( FT_Module_Class, psaux_module_class ) +FT_USE_MODULE( FT_Module_Class, psnames_module_class ) +FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) +FT_USE_MODULE( FT_Module_Class, sfnt_module_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_sdf_renderer_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_bitmap_sdf_renderer_class ) +FT_USE_MODULE( FT_Renderer_Class, ft_svg_renderer_class ) + +/* EOF */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftoption.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftoption.h new file mode 100644 index 0000000000000000000000000000000000000000..40de1900f757242c12a7e624cb3ff648c5c1f76e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftoption.h @@ -0,0 +1,1030 @@ +/**************************************************************************** + * + * ftoption.h + * + * User-selectable configuration macros (specification only). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTOPTION_H_ +#define FTOPTION_H_ + + +#include + + +FT_BEGIN_HEADER + + /************************************************************************** + * + * USER-SELECTABLE CONFIGURATION MACROS + * + * This file contains the default configuration macro definitions for a + * standard build of the FreeType library. There are three ways to use + * this file to build project-specific versions of the library: + * + * - You can modify this file by hand, but this is not recommended in + * cases where you would like to build several versions of the library + * from a single source directory. + * + * - You can put a copy of this file in your build directory, more + * precisely in `$BUILD/freetype/config/ftoption.h`, where `$BUILD` is + * the name of a directory that is included _before_ the FreeType include + * path during compilation. + * + * The default FreeType Makefiles use the build directory + * `builds/` by default, but you can easily change that for your + * own projects. + * + * - Copy the file to `$BUILD/ft2build.h` and modify it + * slightly to pre-define the macro `FT_CONFIG_OPTIONS_H` used to locate + * this file during the build. For example, + * + * ``` + * #define FT_CONFIG_OPTIONS_H + * #include + * ``` + * + * will use `$BUILD/myftoptions.h` instead of this file for macro + * definitions. + * + * Note also that you can similarly pre-define the macro + * `FT_CONFIG_MODULES_H` used to locate the file listing of the modules + * that are statically linked to the library at compile time. By + * default, this file is ``. + * + * We highly recommend using the third method whenever possible. + * + */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*#************************************************************************ + * + * If you enable this configuration option, FreeType recognizes an + * environment variable called `FREETYPE_PROPERTIES`, which can be used to + * control the various font drivers and modules. The controllable + * properties are listed in the section @properties. + * + * You have to undefine this configuration option on platforms that lack + * the concept of environment variables (and thus don't have the `getenv` + * function), for example Windows CE. + * + * `FREETYPE_PROPERTIES` has the following syntax form (broken here into + * multiple lines for better readability). + * + * ``` + * + * ':' + * '=' + * + * ':' + * '=' + * ... + * ``` + * + * Example: + * + * ``` + * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ + * cff:no-stem-darkening=1 + * ``` + * + */ +#define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + + + /************************************************************************** + * + * Uncomment the line below if you want to activate LCD rendering + * technology similar to ClearType in this build of the library. This + * technology triples the resolution in the direction color subpixels. To + * mitigate color fringes inherent to this technology, you also need to + * explicitly set up LCD filtering. + * + * When this macro is not defined, FreeType offers alternative LCD + * rendering technology that produces excellent output. + */ +/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ + + + /************************************************************************** + * + * Many compilers provide a non-ANSI 64-bit data type that can be used by + * FreeType to speed up some computations. However, this will create some + * problems when compiling the library in strict ANSI mode. + * + * For this reason, the use of 64-bit integers is normally disabled when + * the `__STDC__` macro is defined. You can however disable this by + * defining the macro `FT_CONFIG_OPTION_FORCE_INT64` here. + * + * For most compilers, this will only create compilation warnings when + * building the library. + * + * ObNote: The compiler-specific 64-bit integers are detected in the + * file `ftconfig.h` either statically or through the `configure` + * script on supported platforms. + */ +#undef FT_CONFIG_OPTION_FORCE_INT64 + + + /************************************************************************** + * + * If this macro is defined, do not try to use an assembler version of + * performance-critical functions (e.g., @FT_MulFix). You should only do + * that to verify that the assembler function works properly, or to execute + * benchmark tests of the various implementations. + */ +/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */ + + + /************************************************************************** + * + * If this macro is defined, try to use an inlined assembler version of the + * @FT_MulFix function, which is a 'hotspot' when loading and hinting + * glyphs, and which should be executed as fast as possible. + * + * Note that if your compiler or CPU is not supported, this will default to + * the standard and portable implementation found in `ftcalc.c`. + */ +#define FT_CONFIG_OPTION_INLINE_MULFIX + + + /************************************************************************** + * + * LZW-compressed file support. + * + * FreeType now handles font files that have been compressed with the + * `compress` program. This is mostly used to parse many of the PCF + * files that come with various X11 distributions. The implementation + * uses NetBSD's `zopen` to partially uncompress the file on the fly (see + * `src/lzw/ftgzip.c`). + * + * Define this macro if you want to enable this 'feature'. + */ +#define FT_CONFIG_OPTION_USE_LZW + + + /************************************************************************** + * + * Gzip-compressed file support. + * + * FreeType now handles font files that have been compressed with the + * `gzip` program. This is mostly used to parse many of the PCF files + * that come with XFree86. The implementation uses 'zlib' to partially + * uncompress the file on the fly (see `src/gzip/ftgzip.c`). + * + * Define this macro if you want to enable this 'feature'. See also the + * macro `FT_CONFIG_OPTION_SYSTEM_ZLIB` below. + */ +#define FT_CONFIG_OPTION_USE_ZLIB + + + /************************************************************************** + * + * ZLib library selection + * + * This macro is only used when `FT_CONFIG_OPTION_USE_ZLIB` is defined. + * It allows FreeType's 'ftgzip' component to link to the system's + * installation of the ZLib library. This is useful on systems like + * Unix or VMS where it generally is already available. + * + * If you let it undefined, the component will use its own copy of the + * zlib sources instead. These have been modified to be included + * directly within the component and **not** export external function + * names. This allows you to link any program with FreeType _and_ ZLib + * without linking conflicts. + * + * Do not `#undef` this macro here since the build system might define + * it for certain configurations only. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + * + * If you use the GNU make build system directly (that is, without the + * `configure` script) and you define this macro, you also have to pass + * `SYSTEM_ZLIB=yes` as an argument to make. + */ +/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */ + + + /************************************************************************** + * + * Bzip2-compressed file support. + * + * FreeType now handles font files that have been compressed with the + * `bzip2` program. This is mostly used to parse many of the PCF files + * that come with XFree86. The implementation uses `libbz2` to partially + * uncompress the file on the fly (see `src/bzip2/ftbzip2.c`). Contrary + * to gzip, bzip2 currently is not included and need to use the system + * available bzip2 implementation. + * + * Define this macro if you want to enable this 'feature'. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ +/* #define FT_CONFIG_OPTION_USE_BZIP2 */ + + + /************************************************************************** + * + * Define to disable the use of file stream functions and types, `FILE`, + * `fopen`, etc. Enables the use of smaller system libraries on embedded + * systems that have multiple system libraries, some with or without file + * stream support, in the cases where file stream support is not necessary + * such as memory loading of font files. + */ +/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */ + + + /************************************************************************** + * + * PNG bitmap support. + * + * FreeType now handles loading color bitmap glyphs in the PNG format. + * This requires help from the external libpng library. Uncompressed + * color bitmaps do not need any external libraries and will be supported + * regardless of this configuration. + * + * Define this macro if you want to enable this 'feature'. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ +/* #define FT_CONFIG_OPTION_USE_PNG */ + + + /************************************************************************** + * + * HarfBuzz support. + * + * FreeType uses the HarfBuzz library to improve auto-hinting of OpenType + * fonts. If available, many glyphs not directly addressable by a font's + * character map will be hinted also. + * + * Define this macro if you want to enable this 'feature'. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ +/* #define FT_CONFIG_OPTION_USE_HARFBUZZ */ + + + /************************************************************************** + * + * Brotli support. + * + * FreeType uses the Brotli library to provide support for decompressing + * WOFF2 streams. + * + * Define this macro if you want to enable this 'feature'. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ +/* #define FT_CONFIG_OPTION_USE_BROTLI */ + + + /************************************************************************** + * + * Glyph Postscript Names handling + * + * By default, FreeType 2 is compiled with the 'psnames' module. This + * module is in charge of converting a glyph name string into a Unicode + * value, or return a Macintosh standard glyph name for the use with the + * TrueType 'post' table. + * + * Undefine this macro if you do not want 'psnames' compiled in your + * build of FreeType. This has the following effects: + * + * - The TrueType driver will provide its own set of glyph names, if you + * build it to support postscript names in the TrueType 'post' table, + * but will not synthesize a missing Unicode charmap. + * + * - The Type~1 driver will not be able to synthesize a Unicode charmap + * out of the glyphs found in the fonts. + * + * You would normally undefine this configuration macro when building a + * version of FreeType that doesn't contain a Type~1 or CFF driver. + */ +#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES + + + /************************************************************************** + * + * Postscript Names to Unicode Values support + * + * By default, FreeType~2 is built with the 'psnames' module compiled in. + * Among other things, the module is used to convert a glyph name into a + * Unicode value. This is especially useful in order to synthesize on + * the fly a Unicode charmap from the CFF/Type~1 driver through a big + * table named the 'Adobe Glyph List' (AGL). + * + * Undefine this macro if you do not want the Adobe Glyph List compiled + * in your 'psnames' module. The Type~1 driver will not be able to + * synthesize a Unicode charmap out of the glyphs found in the fonts. + */ +#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST + + + /************************************************************************** + * + * Support for Mac fonts + * + * Define this macro if you want support for outline fonts in Mac format + * (mac dfont, mac resource, macbinary containing a mac resource) on + * non-Mac platforms. + * + * Note that the 'FOND' resource isn't checked. + */ +#define FT_CONFIG_OPTION_MAC_FONTS + + + /************************************************************************** + * + * Guessing methods to access embedded resource forks + * + * Enable extra Mac fonts support on non-Mac platforms (e.g., GNU/Linux). + * + * Resource forks which include fonts data are stored sometimes in + * locations which users or developers don't expected. In some cases, + * resource forks start with some offset from the head of a file. In + * other cases, the actual resource fork is stored in file different from + * what the user specifies. If this option is activated, FreeType tries + * to guess whether such offsets or different file names must be used. + * + * Note that normal, direct access of resource forks is controlled via + * the `FT_CONFIG_OPTION_MAC_FONTS` option. + */ +#ifdef FT_CONFIG_OPTION_MAC_FONTS +#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK +#endif + + + /************************************************************************** + * + * Allow the use of `FT_Incremental_Interface` to load typefaces that + * contain no glyph data, but supply it via a callback function. This is + * required by clients supporting document formats which supply font data + * incrementally as the document is parsed, such as the Ghostscript + * interpreter for the PostScript language. + */ +#define FT_CONFIG_OPTION_INCREMENTAL + + + /************************************************************************** + * + * The size in bytes of the render pool used by the scan-line converter to + * do all of its work. + */ +#define FT_RENDER_POOL_SIZE 16384L + + + /************************************************************************** + * + * FT_MAX_MODULES + * + * The maximum number of modules that can be registered in a single + * FreeType library object. 32~is the default. + */ +#define FT_MAX_MODULES 32 + + + /************************************************************************** + * + * Debug level + * + * FreeType can be compiled in debug or trace mode. In debug mode, + * errors are reported through the 'ftdebug' component. In trace mode, + * additional messages are sent to the standard output during execution. + * + * Define `FT_DEBUG_LEVEL_ERROR` to build the library in debug mode. + * Define `FT_DEBUG_LEVEL_TRACE` to build it in trace mode. + * + * Don't define any of these macros to compile in 'release' mode! + * + * Do not `#undef` these macros here since the build system might define + * them for certain configurations only. + */ +/* #define FT_DEBUG_LEVEL_ERROR */ +/* #define FT_DEBUG_LEVEL_TRACE */ + + + /************************************************************************** + * + * Logging + * + * Compiling FreeType in debug or trace mode makes FreeType write error + * and trace log messages to `stderr`. Enabling this macro + * automatically forces the `FT_DEBUG_LEVEL_ERROR` and + * `FT_DEBUG_LEVEL_TRACE` macros and allows FreeType to write error and + * trace log messages to a file instead of `stderr`. For writing logs + * to a file, FreeType uses an the external `dlg` library (the source + * code is in `src/dlg`). + * + * This option needs a C99 compiler. + */ +/* #define FT_DEBUG_LOGGING */ + + + /************************************************************************** + * + * Autofitter debugging + * + * If `FT_DEBUG_AUTOFIT` is defined, FreeType provides some means to + * control the autofitter behaviour for debugging purposes with global + * boolean variables (consequently, you should **never** enable this + * while compiling in 'release' mode): + * + * ``` + * af_debug_disable_horz_hints_ + * af_debug_disable_vert_hints_ + * af_debug_disable_blue_hints_ + * ``` + * + * Additionally, the following functions provide dumps of various + * internal autofit structures to stdout (using `printf`): + * + * ``` + * af_glyph_hints_dump_points + * af_glyph_hints_dump_segments + * af_glyph_hints_dump_edges + * af_glyph_hints_get_num_segments + * af_glyph_hints_get_segment_offset + * ``` + * + * As an argument, they use another global variable: + * + * ``` + * af_debug_hints_ + * ``` + * + * Please have a look at the `ftgrid` demo program to see how those + * variables and macros should be used. + * + * Do not `#undef` these macros here since the build system might define + * them for certain configurations only. + */ +/* #define FT_DEBUG_AUTOFIT */ + + + /************************************************************************** + * + * Memory Debugging + * + * FreeType now comes with an integrated memory debugger that is capable + * of detecting simple errors like memory leaks or double deletes. To + * compile it within your build of the library, you should define + * `FT_DEBUG_MEMORY` here. + * + * Note that the memory debugger is only activated at runtime when when + * the _environment_ variable `FT2_DEBUG_MEMORY` is defined also! + * + * Do not `#undef` this macro here since the build system might define it + * for certain configurations only. + */ +/* #define FT_DEBUG_MEMORY */ + + + /************************************************************************** + * + * Module errors + * + * If this macro is set (which is _not_ the default), the higher byte of + * an error code gives the module in which the error has occurred, while + * the lower byte is the real error code. + * + * Setting this macro makes sense for debugging purposes only, since it + * would break source compatibility of certain programs that use + * FreeType~2. + * + * More details can be found in the files `ftmoderr.h` and `fterrors.h`. + */ +#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS + + + /************************************************************************** + * + * OpenType SVG Glyph Support + * + * Setting this macro enables support for OpenType SVG glyphs. By + * default, FreeType can only fetch SVG documents. However, it can also + * render them if external rendering hook functions are plugged in at + * runtime. + * + * More details on the hooks can be found in file `otsvg.h`. + */ +#define FT_CONFIG_OPTION_SVG + + + /************************************************************************** + * + * Error Strings + * + * If this macro is set, `FT_Error_String` will return meaningful + * descriptions. This is not enabled by default to reduce the overall + * size of FreeType. + * + * More details can be found in the file `fterrors.h`. + */ +/* #define FT_CONFIG_OPTION_ERROR_STRINGS */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** S F N T D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_EMBEDDED_BITMAPS` if you want to support + * embedded bitmaps in all formats using the 'sfnt' module (namely + * TrueType~& OpenType). + */ +#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_COLOR_LAYERS` if you want to support colored + * outlines (from the 'COLR'/'CPAL' tables) in all formats using the 'sfnt' + * module (namely TrueType~& OpenType). + */ +#define TT_CONFIG_OPTION_COLOR_LAYERS + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_POSTSCRIPT_NAMES` if you want to be able to + * load and enumerate Postscript names of glyphs in a TrueType or OpenType + * file. + * + * Note that if you do not compile the 'psnames' module by undefining the + * above `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` macro, the 'sfnt' module will + * contain additional code to read the PostScript name table from a font. + * + * (By default, the module uses 'psnames' to extract glyph names.) + */ +#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_SFNT_NAMES` if your applications need to access + * the internal name table in a SFNT-based format like TrueType or + * OpenType. The name table contains various strings used to describe the + * font, like family name, copyright, version, etc. It does not contain + * any glyph name though. + * + * Accessing SFNT names is done through the functions declared in + * `ftsnames.h`. + */ +#define TT_CONFIG_OPTION_SFNT_NAMES + + + /************************************************************************** + * + * TrueType CMap support + * + * Here you can fine-tune which TrueType CMap table format shall be + * supported. + */ +#define TT_CONFIG_CMAP_FORMAT_0 +#define TT_CONFIG_CMAP_FORMAT_2 +#define TT_CONFIG_CMAP_FORMAT_4 +#define TT_CONFIG_CMAP_FORMAT_6 +#define TT_CONFIG_CMAP_FORMAT_8 +#define TT_CONFIG_CMAP_FORMAT_10 +#define TT_CONFIG_CMAP_FORMAT_12 +#define TT_CONFIG_CMAP_FORMAT_13 +#define TT_CONFIG_CMAP_FORMAT_14 + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_BYTECODE_INTERPRETER` if you want to compile a + * bytecode interpreter in the TrueType driver. + * + * By undefining this, you will only compile the code necessary to load + * TrueType glyphs without hinting. + * + * Do not `#undef` this macro here, since the build system might define it + * for certain configurations only. + */ +#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_SUBPIXEL_HINTING` if you want to compile + * subpixel hinting support into the TrueType driver. This modifies the + * TrueType hinting mechanism when anything but `FT_RENDER_MODE_MONO` is + * requested. + * + * In particular, it modifies the bytecode interpreter to interpret (or + * not) instructions in a certain way so that all TrueType fonts look like + * they do in a Windows ClearType (DirectWrite) environment. See [1] for a + * technical overview on what this means. See `ttinterp.h` for more + * details on this option. + * + * The new default mode focuses on applying a minimal set of rules to all + * fonts indiscriminately so that modern and web fonts render well while + * legacy fonts render okay. The corresponding interpreter version is v40. + * The so-called Infinality mode (v38) is no longer available in FreeType. + * + * By undefining these, you get rendering behavior like on Windows without + * ClearType, i.e., Windows XP without ClearType enabled and Win9x + * (interpreter version v35). Or not, depending on how much hinting blood + * and testing tears the font designer put into a given font. If you + * define one or both subpixel hinting options, you can switch between + * between v35 and the ones you define (using `FT_Property_Set`). + * + * This option requires `TT_CONFIG_OPTION_BYTECODE_INTERPRETER` to be + * defined. + * + * [1] + * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx + */ +#define TT_CONFIG_OPTION_SUBPIXEL_HINTING + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED` to compile the + * TrueType glyph loader to use Apple's definition of how to handle + * component offsets in composite glyphs. + * + * Apple and MS disagree on the default behavior of component offsets in + * composites. Apple says that they should be scaled by the scaling + * factors in the transformation matrix (roughly, it's more complex) while + * MS says they should not. OpenType defines two bits in the composite + * flags array which can be used to disambiguate, but old fonts will not + * have them. + * + * https://www.microsoft.com/typography/otspec/glyf.htm + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html + */ +#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_GX_VAR_SUPPORT` if you want to include support + * for Apple's distortable font technology ('fvar', 'gvar', 'cvar', and + * 'avar' tables). Tagged 'Font Variations', this is now part of OpenType + * also. This has many similarities to Type~1 Multiple Masters support. + */ +#define TT_CONFIG_OPTION_GX_VAR_SUPPORT + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_NO_BORING_EXPANSION` if you want to exclude + * support for 'boring' OpenType specification expansions. + * + * https://github.com/harfbuzz/boring-expansion-spec + * + * Right now, the following features are covered: + * + * - 'avar' version 2.0 + * + * Most likely, this is a temporary configuration option to be removed in + * the near future, since it is assumed that eventually those features are + * added to the OpenType standard. + */ +/* #define TT_CONFIG_OPTION_NO_BORING_EXPANSION */ + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_BDF` if you want to include support for an + * embedded 'BDF~' table within SFNT-based bitmap formats. + */ +#define TT_CONFIG_OPTION_BDF + + + /************************************************************************** + * + * Option `TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES` controls the maximum + * number of bytecode instructions executed for a single run of the + * bytecode interpreter, needed to prevent infinite loops. You don't want + * to change this except for very special situations (e.g., making a + * library fuzzer spend less time to handle broken fonts). + * + * It is not expected that this value is ever modified by a configuring + * script; instead, it gets surrounded with `#ifndef ... #endif` so that + * the value can be set as a preprocessor option on the compiler's command + * line. + */ +#ifndef TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES +#define TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES 1000000L +#endif + + + /************************************************************************** + * + * Option `TT_CONFIG_OPTION_GPOS_KERNING` enables a basic GPOS kerning + * implementation (for TrueType fonts only). With this defined, FreeType + * is able to get kerning pair data from the GPOS 'kern' feature as well as + * legacy 'kern' tables; without this defined, FreeType will only be able + * to use legacy 'kern' tables. + * + * Note that FreeType does not support more advanced GPOS layout features; + * even the 'kern' feature implemented here doesn't handle more + * sophisticated kerning variants. Use a higher-level library like + * HarfBuzz instead for that. + */ +/* #define TT_CONFIG_OPTION_GPOS_KERNING */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * `T1_MAX_DICT_DEPTH` is the maximum depth of nest dictionaries and arrays + * in the Type~1 stream (see `t1load.c`). A minimum of~4 is required. + */ +#define T1_MAX_DICT_DEPTH 5 + + + /************************************************************************** + * + * `T1_MAX_SUBRS_CALLS` details the maximum number of nested sub-routine + * calls during glyph loading. + */ +#define T1_MAX_SUBRS_CALLS 16 + + + /************************************************************************** + * + * `T1_MAX_CHARSTRING_OPERANDS` is the charstring stack's capacity. A + * minimum of~16 is required. + * + * The Chinese font 'MingTiEG-Medium' (covering the CNS 11643 character + * set) needs 256. + */ +#define T1_MAX_CHARSTRINGS_OPERANDS 256 + + + /************************************************************************** + * + * Define this configuration macro if you want to prevent the compilation + * of the 't1afm' module, which is in charge of reading Type~1 AFM files + * into an existing face. Note that if set, the Type~1 driver will be + * unable to produce kerning distances. + */ +#undef T1_CONFIG_OPTION_NO_AFM + + + /************************************************************************** + * + * Define this configuration macro if you want to prevent the compilation + * of the Multiple Masters font support in the Type~1 driver. + */ +#undef T1_CONFIG_OPTION_NO_MM_SUPPORT + + + /************************************************************************** + * + * `T1_CONFIG_OPTION_OLD_ENGINE` controls whether the pre-Adobe Type~1 + * engine gets compiled into FreeType. If defined, it is possible to + * switch between the two engines using the `hinting-engine` property of + * the 'type1' driver module. + */ +/* #define T1_CONFIG_OPTION_OLD_ENGINE */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** C F F D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * Using `CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4}` it is + * possible to set up the default values of the four control points that + * define the stem darkening behaviour of the (new) CFF engine. For more + * details please read the documentation of the `darkening-parameters` + * property (file `ftdriver.h`), which allows the control at run-time. + * + * Do **not** undefine these macros! + */ +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 1000 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 275 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 1667 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 275 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 2333 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0 + + + /************************************************************************** + * + * `CFF_CONFIG_OPTION_OLD_ENGINE` controls whether the pre-Adobe CFF engine + * gets compiled into FreeType. If defined, it is possible to switch + * between the two engines using the `hinting-engine` property of the 'cff' + * driver module. + */ +/* #define CFF_CONFIG_OPTION_OLD_ENGINE */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** P C F D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * There are many PCF fonts just called 'Fixed' which look completely + * different, and which have nothing to do with each other. When selecting + * 'Fixed' in KDE or Gnome one gets results that appear rather random, the + * style changes often if one changes the size and one cannot select some + * fonts at all. This option makes the 'pcf' module prepend the foundry + * name (plus a space) to the family name. + * + * We also check whether we have 'wide' characters; all put together, we + * get family names like 'Sony Fixed' or 'Misc Fixed Wide'. + * + * If this option is activated, it can be controlled with the + * `no-long-family-names` property of the 'pcf' driver module. + */ +/* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * Compile 'autofit' module with CJK (Chinese, Japanese, Korean) script + * support. + */ +#define AF_CONFIG_OPTION_CJK + + + /************************************************************************** + * + * Compile 'autofit' module with fallback Indic script support, covering + * some scripts that the 'latin' submodule of the 'autofit' module doesn't + * (yet) handle. Currently, this needs option `AF_CONFIG_OPTION_CJK`. + */ +#ifdef AF_CONFIG_OPTION_CJK +#define AF_CONFIG_OPTION_INDIC +#endif + + + /************************************************************************** + * + * Use TrueType-like size metrics for 'light' auto-hinting. + * + * It is strongly recommended to avoid this option, which exists only to + * help some legacy applications retain its appearance and behaviour with + * respect to auto-hinted TrueType fonts. + * + * The very reason this option exists at all are GNU/Linux distributions + * like Fedora that did not un-patch the following change (which was + * present in FreeType between versions 2.4.6 and 2.7.1, inclusive). + * + * ``` + * 2011-07-16 Steven Chu + * + * [truetype] Fix metrics on size request for scalable fonts. + * ``` + * + * This problematic commit is now reverted (more or less). + */ +/* #define AF_CONFIG_OPTION_TT_SIZE_METRICS */ + + /* */ + + + /* + * This macro is obsolete. Support has been removed in FreeType version + * 2.5. + */ +/* #define FT_CONFIG_OPTION_OLD_INTERNALS */ + + + /* + * The next two macros are defined if native TrueType hinting is + * requested by the definitions above. Don't change this. + */ +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#define TT_USE_BYTECODE_INTERPRETER +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING +#define TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL +#endif +#endif + + + /* + * The TT_SUPPORT_COLRV1 macro is defined to indicate to clients that this + * version of FreeType has support for 'COLR' v1 API. This definition is + * useful to FreeType clients that want to build in support for 'COLR' v1 + * depending on a tip-of-tree checkout before it is officially released in + * FreeType, and while the feature cannot yet be tested against using + * version macros. Don't change this macro. This may be removed once the + * feature is in a FreeType release version and version macros can be used + * to test for availability. + */ +#ifdef TT_CONFIG_OPTION_COLOR_LAYERS +#define TT_SUPPORT_COLRV1 +#endif + + + /* + * Check CFF darkening parameters. The checks are the same as in function + * `cff_property_set` in file `cffdrivr.c`. + */ +#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500 +#error "Invalid CFF darkening parameters!" +#endif + + +FT_END_HEADER + +#endif /* FTOPTION_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftstdlib.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftstdlib.h new file mode 100644 index 0000000000000000000000000000000000000000..daa5be76c5901ec4f82acf41554d4a38d72b848d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/ftstdlib.h @@ -0,0 +1,185 @@ +/**************************************************************************** + * + * ftstdlib.h + * + * ANSI-specific library and header configuration file (specification + * only). + * + * Copyright (C) 2002-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to group all `#includes` to the ANSI~C library that + * FreeType normally requires. It also defines macros to rename the + * standard functions within the FreeType source code. + * + * Load a file which defines `FTSTDLIB_H_` before this one to override it. + * + */ + + +#ifndef FTSTDLIB_H_ +#define FTSTDLIB_H_ + + +#include + +#define ft_ptrdiff_t ptrdiff_t + + + /************************************************************************** + * + * integer limits + * + * `UINT_MAX` and `ULONG_MAX` are used to automatically compute the size of + * `int` and `long` in bytes at compile-time. So far, this works for all + * platforms the library has been tested on. We also check `ULLONG_MAX` + * to see whether we can use 64-bit `long long` later on. + * + * Note that on the extremely rare platforms that do not provide integer + * types that are _exactly_ 16 and 32~bits wide (e.g., some old Crays where + * `int` is 36~bits), we do not make any guarantee about the correct + * behaviour of FreeType~2 with all fonts. + * + * In these cases, `ftconfig.h` will refuse to compile anyway with a + * message like 'couldn't find 32-bit type' or something similar. + * + */ + + +#include + +#define FT_CHAR_BIT CHAR_BIT +#define FT_USHORT_MAX USHRT_MAX +#define FT_INT_MAX INT_MAX +#define FT_INT_MIN INT_MIN +#define FT_UINT_MAX UINT_MAX +#define FT_LONG_MIN LONG_MIN +#define FT_LONG_MAX LONG_MAX +#define FT_ULONG_MAX ULONG_MAX +#ifdef LLONG_MAX +#define FT_LLONG_MAX LLONG_MAX +#endif +#ifdef LLONG_MIN +#define FT_LLONG_MIN LLONG_MIN +#endif +#ifdef ULLONG_MAX +#define FT_ULLONG_MAX ULLONG_MAX +#endif + + + /************************************************************************** + * + * character and string processing + * + */ + + +#include + +#define ft_memchr memchr +#define ft_memcmp memcmp +#define ft_memcpy memcpy +#define ft_memmove memmove +#define ft_memset memset +#define ft_strcat strcat +#define ft_strcmp strcmp +#define ft_strcpy strcpy +#define ft_strlen strlen +#define ft_strncmp strncmp +#define ft_strncpy strncpy +#define ft_strrchr strrchr +#define ft_strstr strstr + + + /************************************************************************** + * + * file handling + * + */ + + +#include + +#define FT_FILE FILE +#define ft_fclose fclose +#define ft_fopen fopen +#define ft_fread fread +#define ft_fseek fseek +#define ft_ftell ftell +#define ft_snprintf snprintf + + + /************************************************************************** + * + * sorting + * + */ + + +#include + +#define ft_qsort qsort + + + /************************************************************************** + * + * memory allocation + * + */ + + +#define ft_scalloc calloc +#define ft_sfree free +#define ft_smalloc malloc +#define ft_srealloc realloc + + + /************************************************************************** + * + * miscellaneous + * + */ + + +#define ft_strtol strtol +#define ft_getenv getenv + + + /************************************************************************** + * + * execution control + * + */ + + +#include + +#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ + /* `jmp_buf` is defined as a macro */ + /* on certain platforms */ + +#define ft_longjmp longjmp +#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */ + + + /* The following is only used for debugging purposes, i.e., if */ + /* `FT_DEBUG_LEVEL_ERROR` or `FT_DEBUG_LEVEL_TRACE` are defined. */ + +#include + + +#endif /* FTSTDLIB_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/integer-types.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/integer-types.h new file mode 100644 index 0000000000000000000000000000000000000000..3857fc2828393293fc2801f0afd429cb1d1caaa6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/integer-types.h @@ -0,0 +1,250 @@ +/**************************************************************************** + * + * config/integer-types.h + * + * FreeType integer types definitions. + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ +#ifndef FREETYPE_CONFIG_INTEGER_TYPES_H_ +#define FREETYPE_CONFIG_INTEGER_TYPES_H_ + + /* There are systems (like the Texas Instruments 'C54x) where a `char` */ + /* has 16~bits. ANSI~C says that `sizeof(char)` is always~1. Since an */ + /* `int` has 16~bits also for this system, `sizeof(int)` gives~1 which */ + /* is probably unexpected. */ + /* */ + /* `CHAR_BIT` (defined in `limits.h`) gives the number of bits in a */ + /* `char` type. */ + +#ifndef FT_CHAR_BIT +#define FT_CHAR_BIT CHAR_BIT +#endif + +#ifndef FT_SIZEOF_INT + + /* The size of an `int` type. */ +#if FT_UINT_MAX == 0xFFFFUL +#define FT_SIZEOF_INT ( 16 / FT_CHAR_BIT ) +#elif FT_UINT_MAX == 0xFFFFFFFFUL +#define FT_SIZEOF_INT ( 32 / FT_CHAR_BIT ) +#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL +#define FT_SIZEOF_INT ( 64 / FT_CHAR_BIT ) +#else +#error "Unsupported size of `int' type!" +#endif + +#endif /* !defined(FT_SIZEOF_INT) */ + +#ifndef FT_SIZEOF_LONG + + /* The size of a `long` type. A five-byte `long` (as used e.g. on the */ + /* DM642) is recognized but avoided. */ +#if FT_ULONG_MAX == 0xFFFFFFFFUL +#define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT ) +#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL +#define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT ) +#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL +#define FT_SIZEOF_LONG ( 64 / FT_CHAR_BIT ) +#else +#error "Unsupported size of `long' type!" +#endif + +#endif /* !defined(FT_SIZEOF_LONG) */ + +#ifndef FT_SIZEOF_LONG_LONG + + /* The size of a `long long` type if available */ +#if defined( FT_ULLONG_MAX ) && FT_ULLONG_MAX >= 0xFFFFFFFFFFFFFFFFULL +#define FT_SIZEOF_LONG_LONG ( 64 / FT_CHAR_BIT ) +#else +#define FT_SIZEOF_LONG_LONG 0 +#endif + +#endif /* !defined(FT_SIZEOF_LONG_LONG) */ + + + /************************************************************************** + * + * @section: + * basic_types + * + */ + + + /************************************************************************** + * + * @type: + * FT_Int16 + * + * @description: + * A typedef for a 16bit signed integer type. + */ + typedef signed short FT_Int16; + + + /************************************************************************** + * + * @type: + * FT_UInt16 + * + * @description: + * A typedef for a 16bit unsigned integer type. + */ + typedef unsigned short FT_UInt16; + + /* */ + + + /* this #if 0 ... #endif clause is for documentation purposes */ +#if 0 + + /************************************************************************** + * + * @type: + * FT_Int32 + * + * @description: + * A typedef for a 32bit signed integer type. The size depends on the + * configuration. + */ + typedef signed XXX FT_Int32; + + + /************************************************************************** + * + * @type: + * FT_UInt32 + * + * A typedef for a 32bit unsigned integer type. The size depends on the + * configuration. + */ + typedef unsigned XXX FT_UInt32; + + + /************************************************************************** + * + * @type: + * FT_Int64 + * + * A typedef for a 64bit signed integer type. The size depends on the + * configuration. Only defined if there is real 64bit support; + * otherwise, it gets emulated with a structure (if necessary). + */ + typedef signed XXX FT_Int64; + + + /************************************************************************** + * + * @type: + * FT_UInt64 + * + * A typedef for a 64bit unsigned integer type. The size depends on the + * configuration. Only defined if there is real 64bit support; + * otherwise, it gets emulated with a structure (if necessary). + */ + typedef unsigned XXX FT_UInt64; + + /* */ + +#endif + +#if FT_SIZEOF_INT == ( 32 / FT_CHAR_BIT ) + + typedef signed int FT_Int32; + typedef unsigned int FT_UInt32; + +#elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT ) + + typedef signed long FT_Int32; + typedef unsigned long FT_UInt32; + +#else +#error "no 32bit type found -- please check your configuration files" +#endif + + + /* look up an integer type that is at least 32~bits */ +#if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT ) + + typedef int FT_Fast; + typedef unsigned int FT_UFast; + +#elif FT_SIZEOF_LONG >= ( 32 / FT_CHAR_BIT ) + + typedef long FT_Fast; + typedef unsigned long FT_UFast; + +#endif + + + /* determine whether we have a 64-bit integer type */ +#if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT ) + +#define FT_INT64 long +#define FT_UINT64 unsigned long + +#elif FT_SIZEOF_LONG_LONG >= ( 64 / FT_CHAR_BIT ) + +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + + /************************************************************************** + * + * A 64-bit data type may create compilation problems if you compile in + * strict ANSI mode. To avoid them, we disable other 64-bit data types if + * `__STDC__` is defined. You can however ignore this rule by defining the + * `FT_CONFIG_OPTION_FORCE_INT64` configuration macro. + */ +#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 ) + +#if defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ + + /* this compiler provides the `__int64` type */ +#define FT_INT64 __int64 +#define FT_UINT64 unsigned __int64 + +#elif defined( __BORLANDC__ ) /* Borland C++ */ + + /* XXXX: We should probably check the value of `__BORLANDC__` in order */ + /* to test the compiler version. */ + + /* this compiler provides the `__int64` type */ +#define FT_INT64 __int64 +#define FT_UINT64 unsigned __int64 + +#elif defined( __WATCOMC__ ) && __WATCOMC__ >= 1100 /* Watcom C++ */ + +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */ + +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#elif defined( __GNUC__ ) + + /* GCC provides the `long long` type */ +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#endif /* !__STDC__ */ + +#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */ + +#ifdef FT_INT64 + typedef FT_INT64 FT_Int64; + typedef FT_UINT64 FT_UInt64; +#endif + + +#endif /* FREETYPE_CONFIG_INTEGER_TYPES_H_ */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/mac-support.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/mac-support.h new file mode 100644 index 0000000000000000000000000000000000000000..490a9d32b21667e52c24d96b808009aeb33a8396 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/mac-support.h @@ -0,0 +1,49 @@ +/**************************************************************************** + * + * config/mac-support.h + * + * Mac/OS X support configuration header. + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ +#ifndef FREETYPE_CONFIG_MAC_SUPPORT_H_ +#define FREETYPE_CONFIG_MAC_SUPPORT_H_ + + /************************************************************************** + * + * Mac support + * + * This is the only necessary change, so it is defined here instead + * providing a new configuration file. + */ +#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) ) + /* No Carbon frameworks for 64bit 10.4.x. */ + /* `AvailabilityMacros.h` is available since Mac OS X 10.2, */ + /* so guess the system version by maximum errno before inclusion. */ +#include +#ifdef ECANCELED /* defined since 10.2 */ +#include "AvailabilityMacros.h" +#endif +#if defined( __LP64__ ) && \ + ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 ) +#undef FT_MACINTOSH +#endif + +#elif defined( __SC__ ) || defined( __MRC__ ) + /* Classic MacOS compilers */ +#include "ConditionalMacros.h" +#if TARGET_OS_MAC +#define FT_MACINTOSH 1 +#endif + +#endif /* Mac support */ + +#endif /* FREETYPE_CONFIG_MAC_SUPPORT_H_ */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/public-macros.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/public-macros.h new file mode 100644 index 0000000000000000000000000000000000000000..f1def351a3334a622fd3538067536addac13fa60 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/config/public-macros.h @@ -0,0 +1,138 @@ +/**************************************************************************** + * + * config/public-macros.h + * + * Define a set of compiler macros used in public FreeType headers. + * + * Copyright (C) 2020-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /* + * The definitions in this file are used by the public FreeType headers + * and thus should be considered part of the public API. + * + * Other compiler-specific macro definitions that are not exposed by the + * FreeType API should go into + * `include/freetype/internal/compiler-macros.h` instead. + */ +#ifndef FREETYPE_CONFIG_PUBLIC_MACROS_H_ +#define FREETYPE_CONFIG_PUBLIC_MACROS_H_ + + /* + * `FT_BEGIN_HEADER` and `FT_END_HEADER` might have already been defined + * by `freetype/config/ftheader.h`, but we don't want to include this + * header here, so redefine the macros here only when needed. Their + * definition is very stable, so keeping them in sync with the ones in the + * header should not be a maintenance issue. + */ +#ifndef FT_BEGIN_HEADER +#ifdef __cplusplus +#define FT_BEGIN_HEADER extern "C" { +#else +#define FT_BEGIN_HEADER /* empty */ +#endif +#endif /* FT_BEGIN_HEADER */ + +#ifndef FT_END_HEADER +#ifdef __cplusplus +#define FT_END_HEADER } +#else +#define FT_END_HEADER /* empty */ +#endif +#endif /* FT_END_HEADER */ + + +FT_BEGIN_HEADER + + /* + * Mark a function declaration as public. This ensures it will be + * properly exported to client code. Place this before a function + * declaration. + * + * NOTE: This macro should be considered an internal implementation + * detail, and not part of the FreeType API. It is only defined here + * because it is needed by `FT_EXPORT`. + */ + + /* Visual C, mingw */ +#if defined( _WIN32 ) + +#if defined( FT2_BUILD_LIBRARY ) && defined( DLL_EXPORT ) +#define FT_PUBLIC_FUNCTION_ATTRIBUTE __declspec( dllexport ) +#elif defined( DLL_IMPORT ) +#define FT_PUBLIC_FUNCTION_ATTRIBUTE __declspec( dllimport ) +#endif + + /* gcc, clang */ +#elif ( defined( __GNUC__ ) && __GNUC__ >= 4 ) || defined( __clang__ ) +#define FT_PUBLIC_FUNCTION_ATTRIBUTE \ + __attribute__(( visibility( "default" ) )) + + /* Sun */ +#elif defined( __SUNPRO_C ) && __SUNPRO_C >= 0x550 +#define FT_PUBLIC_FUNCTION_ATTRIBUTE __global +#endif + + +#ifndef FT_PUBLIC_FUNCTION_ATTRIBUTE +#define FT_PUBLIC_FUNCTION_ATTRIBUTE /* empty */ +#endif + + + /* + * Define a public FreeType API function. This ensures it is properly + * exported or imported at build time. The macro parameter is the + * function's return type as in: + * + * FT_EXPORT( FT_Bool ) + * FT_Object_Method( FT_Object obj, + * ... ); + * + * NOTE: This requires that all `FT_EXPORT` uses are inside + * `FT_BEGIN_HEADER ... FT_END_HEADER` blocks. This guarantees that the + * functions are exported with C linkage, even when the header is included + * by a C++ source file. + */ +#define FT_EXPORT( x ) FT_PUBLIC_FUNCTION_ATTRIBUTE extern x + + + /* + * `FT_UNUSED` indicates that a given parameter is not used -- this is + * only used to get rid of unpleasant compiler warnings. + * + * Technically, this was not meant to be part of the public API, but some + * third-party code depends on it. + */ +#ifndef FT_UNUSED +#define FT_UNUSED( arg ) ( (arg) = (arg) ) +#endif + + + /* + * Support for casts in both C and C++. + */ +#ifdef __cplusplus +#define FT_STATIC_CAST( type, var ) static_cast(var) +#define FT_REINTERPRET_CAST( type, var ) reinterpret_cast(var) + +#define FT_STATIC_BYTE_CAST( type, var ) \ + static_cast( static_cast( var ) ) +#else +#define FT_STATIC_CAST( type, var ) (type)(var) +#define FT_REINTERPRET_CAST( type, var ) (type)(var) + +#define FT_STATIC_BYTE_CAST( type, var ) (type)(unsigned char)(var) +#endif + + +FT_END_HEADER + +#endif /* FREETYPE_CONFIG_PUBLIC_MACROS_H_ */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/freetype.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/freetype.h new file mode 100644 index 0000000000000000000000000000000000000000..620b3d6d8aa00959a168cc03c992c5a231b4f677 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/freetype.h @@ -0,0 +1,5289 @@ +/**************************************************************************** + * + * freetype.h + * + * FreeType high-level API and common types (specification only). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FREETYPE_H_ +#define FREETYPE_H_ + + +#include +#include FT_CONFIG_CONFIG_H +#include +#include + + +FT_BEGIN_HEADER + + + + /************************************************************************** + * + * @section: + * preamble + * + * @title: + * Preamble + * + * @abstract: + * What FreeType is and isn't + * + * @description: + * FreeType is a library that provides access to glyphs in font files. It + * scales the glyph images and their metrics to a requested size, and it + * rasterizes the glyph images to produce pixel or subpixel alpha coverage + * bitmaps. + * + * Note that FreeType is _not_ a text layout engine. You have to use + * higher-level libraries like HarfBuzz, Pango, or ICU for that. + * + * Note also that FreeType does _not_ perform alpha blending or + * compositing the resulting bitmaps or pixmaps by itself. Use your + * favourite graphics library (for example, Cairo or Skia) to further + * process FreeType's output. + * + */ + + + /************************************************************************** + * + * @section: + * header_inclusion + * + * @title: + * FreeType's header inclusion scheme + * + * @abstract: + * How client applications should include FreeType header files. + * + * @description: + * To be as flexible as possible (and for historical reasons), you must + * load file `ft2build.h` first before other header files, for example + * + * ``` + * #include + * + * #include + * #include + * ``` + */ + + + /************************************************************************** + * + * @section: + * user_allocation + * + * @title: + * User allocation + * + * @abstract: + * How client applications should allocate FreeType data structures. + * + * @description: + * FreeType assumes that structures allocated by the user and passed as + * arguments are zeroed out except for the actual data. In other words, + * it is recommended to use `calloc` (or variants of it) instead of + * `malloc` for allocation. + * + */ + + + /************************************************************************** + * + * @section: + * font_testing_macros + * + * @title: + * Font Testing Macros + * + * @abstract: + * Macros to test various properties of fonts. + * + * @description: + * Macros to test the most important font properties. + * + * It is recommended to use these high-level macros instead of directly + * testing the corresponding flags, which are scattered over various + * structures. + * + * @order: + * FT_HAS_HORIZONTAL + * FT_HAS_VERTICAL + * FT_HAS_KERNING + * FT_HAS_FIXED_SIZES + * FT_HAS_GLYPH_NAMES + * FT_HAS_COLOR + * FT_HAS_MULTIPLE_MASTERS + * FT_HAS_SVG + * FT_HAS_SBIX + * FT_HAS_SBIX_OVERLAY + * + * FT_IS_SFNT + * FT_IS_SCALABLE + * FT_IS_FIXED_WIDTH + * FT_IS_CID_KEYED + * FT_IS_TRICKY + * FT_IS_NAMED_INSTANCE + * FT_IS_VARIATION + * + */ + + + /************************************************************************** + * + * @section: + * library_setup + * + * @title: + * Library Setup + * + * @abstract: + * Functions to start and end the usage of the FreeType library. + * + * @description: + * Functions to start and end the usage of the FreeType library. + * + * Note that @FT_Library_Version and @FREETYPE_XXX are of limited use + * because even a new release of FreeType with only documentation + * changes increases the version number. + * + * @order: + * FT_Library + * FT_Init_FreeType + * FT_Done_FreeType + * + * FT_Library_Version + * FREETYPE_XXX + * + */ + + + /************************************************************************** + * + * @section: + * face_creation + * + * @title: + * Face Creation + * + * @abstract: + * Functions to manage fonts. + * + * @description: + * The functions and structures collected in this section operate on + * fonts globally. + * + * @order: + * FT_Face + * FT_FaceRec + * FT_FACE_FLAG_XXX + * FT_STYLE_FLAG_XXX + * + * FT_New_Face + * FT_Done_Face + * FT_Reference_Face + * FT_New_Memory_Face + * FT_Face_Properties + * FT_Open_Face + * FT_Open_Args + * FT_OPEN_XXX + * FT_Parameter + * FT_Attach_File + * FT_Attach_Stream + * + */ + + + /************************************************************************** + * + * @section: + * sizing_and_scaling + * + * @title: + * Sizing and Scaling + * + * @abstract: + * Functions to manage font sizes. + * + * @description: + * The functions and structures collected in this section are related to + * selecting and manipulating the size of a font globally. + * + * @order: + * FT_Size + * FT_SizeRec + * FT_Size_Metrics + * + * FT_Bitmap_Size + * + * FT_Set_Char_Size + * FT_Set_Pixel_Sizes + * FT_Request_Size + * FT_Select_Size + * FT_Size_Request_Type + * FT_Size_RequestRec + * FT_Size_Request + * + * FT_Set_Transform + * FT_Get_Transform + * + */ + + + /************************************************************************** + * + * @section: + * glyph_retrieval + * + * @title: + * Glyph Retrieval + * + * @abstract: + * Functions to manage glyphs. + * + * @description: + * The functions and structures collected in this section operate on + * single glyphs, of which @FT_Load_Glyph is most important. + * + * @order: + * FT_GlyphSlot + * FT_GlyphSlotRec + * FT_Glyph_Metrics + * + * FT_Load_Glyph + * FT_LOAD_XXX + * FT_LOAD_TARGET_MODE + * FT_LOAD_TARGET_XXX + * + * FT_Render_Glyph + * FT_Render_Mode + * FT_Get_Kerning + * FT_Kerning_Mode + * FT_Get_Track_Kerning + * + */ + + + /************************************************************************** + * + * @section: + * character_mapping + * + * @title: + * Character Mapping + * + * @abstract: + * Functions to manage character-to-glyph maps. + * + * @description: + * This section holds functions and structures that are related to + * mapping character input codes to glyph indices. + * + * Note that for many scripts the simplistic approach used by FreeType + * of mapping a single character to a single glyph is not valid or + * possible! In general, a higher-level library like HarfBuzz or ICU + * should be used for handling text strings. + * + * @order: + * FT_CharMap + * FT_CharMapRec + * FT_Encoding + * FT_ENC_TAG + * + * FT_Select_Charmap + * FT_Set_Charmap + * FT_Get_Charmap_Index + * + * FT_Get_Char_Index + * FT_Get_First_Char + * FT_Get_Next_Char + * FT_Load_Char + * + */ + + + /************************************************************************** + * + * @section: + * information_retrieval + * + * @title: + * Information Retrieval + * + * @abstract: + * Functions to retrieve font and glyph information. + * + * @description: + * Functions to retrieve font and glyph information. Only some very + * basic data is covered; see also the chapter on the format-specific + * API for more. + * + * + * @order: + * FT_Get_Name_Index + * FT_Get_Glyph_Name + * FT_Get_Postscript_Name + * FT_Get_FSType_Flags + * FT_FSTYPE_XXX + * FT_Get_SubGlyph_Info + * FT_SUBGLYPH_FLAG_XXX + * + */ + + + /************************************************************************** + * + * @section: + * other_api_data + * + * @title: + * Other API Data + * + * @abstract: + * Other structures, enumerations, and macros. + * + * @description: + * Other structures, enumerations, and macros. Deprecated functions are + * also listed here. + * + * @order: + * FT_Face_Internal + * FT_Size_Internal + * FT_Slot_Internal + * + * FT_SubGlyph + * + * FT_HAS_FAST_GLYPHS + * FT_Face_CheckTrueTypePatents + * FT_Face_SetUnpatentedHinting + * + */ + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* B A S I C T Y P E S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * @section: + * glyph_retrieval + * + */ + + /************************************************************************** + * + * @struct: + * FT_Glyph_Metrics + * + * @description: + * A structure to model the metrics of a single glyph. The values are + * expressed in 26.6 fractional pixel format; if the flag + * @FT_LOAD_NO_SCALE has been used while loading the glyph, values are + * expressed in font units instead. + * + * @fields: + * width :: + * The glyph's width. + * + * height :: + * The glyph's height. + * + * horiBearingX :: + * Left side bearing for horizontal layout. + * + * horiBearingY :: + * Top side bearing for horizontal layout. + * + * horiAdvance :: + * Advance width for horizontal layout. + * + * vertBearingX :: + * Left side bearing for vertical layout. + * + * vertBearingY :: + * Top side bearing for vertical layout. Larger positive values mean + * further below the vertical glyph origin. + * + * vertAdvance :: + * Advance height for vertical layout. Positive values mean the glyph + * has a positive advance downward. + * + * @note: + * If not disabled with @FT_LOAD_NO_HINTING, the values represent + * dimensions of the hinted glyph (in case hinting is applicable). + * + * Stroking a glyph with an outside border does not increase + * `horiAdvance` or `vertAdvance`; you have to manually adjust these + * values to account for the added width and height. + * + * FreeType doesn't use the 'VORG' table data for CFF fonts because it + * doesn't have an interface to quickly retrieve the glyph height. The + * y~coordinate of the vertical origin can be simply computed as + * `vertBearingY + height` after loading a glyph. + */ + typedef struct FT_Glyph_Metrics_ + { + FT_Pos width; + FT_Pos height; + + FT_Pos horiBearingX; + FT_Pos horiBearingY; + FT_Pos horiAdvance; + + FT_Pos vertBearingX; + FT_Pos vertBearingY; + FT_Pos vertAdvance; + + } FT_Glyph_Metrics; + + + /************************************************************************** + * + * @section: + * sizing_and_scaling + * + */ + + /************************************************************************** + * + * @struct: + * FT_Bitmap_Size + * + * @description: + * This structure models the metrics of a bitmap strike (i.e., a set of + * glyphs for a given point size and resolution) in a bitmap font. It is + * used for the `available_sizes` field of @FT_Face. + * + * @fields: + * height :: + * The vertical distance, in pixels, between two consecutive baselines. + * It is always positive. + * + * width :: + * The average width, in pixels, of all glyphs in the strike. + * + * size :: + * The nominal size of the strike in 26.6 fractional points. This + * field is not very useful. + * + * x_ppem :: + * The horizontal ppem (nominal width) in 26.6 fractional pixels. + * + * y_ppem :: + * The vertical ppem (nominal height) in 26.6 fractional pixels. + * + * @note: + * Windows FNT: + * The nominal size given in a FNT font is not reliable. If the driver + * finds it incorrect, it sets `size` to some calculated values, and + * `x_ppem` and `y_ppem` to the pixel width and height given in the + * font, respectively. + * + * TrueType embedded bitmaps: + * `size`, `width`, and `height` values are not contained in the bitmap + * strike itself. They are computed from the global font parameters. + */ + typedef struct FT_Bitmap_Size_ + { + FT_Short height; + FT_Short width; + + FT_Pos size; + + FT_Pos x_ppem; + FT_Pos y_ppem; + + } FT_Bitmap_Size; + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* O B J E C T C L A S S E S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + /************************************************************************** + * + * @section: + * library_setup + * + */ + + /************************************************************************** + * + * @type: + * FT_Library + * + * @description: + * A handle to a FreeType library instance. Each 'library' is completely + * independent from the others; it is the 'root' of a set of objects like + * fonts, faces, sizes, etc. + * + * It also embeds a memory manager (see @FT_Memory), as well as a + * scan-line converter object (see @FT_Raster). + * + * [Since 2.5.6] In multi-threaded applications it is easiest to use one + * `FT_Library` object per thread. In case this is too cumbersome, a + * single `FT_Library` object across threads is possible also, as long as + * a mutex lock is used around @FT_New_Face and @FT_Done_Face. + * + * @note: + * Library objects are normally created by @FT_Init_FreeType, and + * destroyed with @FT_Done_FreeType. If you need reference-counting + * (cf. @FT_Reference_Library), use @FT_New_Library and @FT_Done_Library. + */ + typedef struct FT_LibraryRec_ *FT_Library; + + + /************************************************************************** + * + * @section: + * module_management + * + */ + + /************************************************************************** + * + * @type: + * FT_Module + * + * @description: + * A handle to a given FreeType module object. A module can be a font + * driver, a renderer, or anything else that provides services to the + * former. + */ + typedef struct FT_ModuleRec_* FT_Module; + + + /************************************************************************** + * + * @type: + * FT_Driver + * + * @description: + * A handle to a given FreeType font driver object. A font driver is a + * module capable of creating faces from font files. + */ + typedef struct FT_DriverRec_* FT_Driver; + + + /************************************************************************** + * + * @type: + * FT_Renderer + * + * @description: + * A handle to a given FreeType renderer. A renderer is a module in + * charge of converting a glyph's outline image to a bitmap. It supports + * a single glyph image format, and one or more target surface depths. + */ + typedef struct FT_RendererRec_* FT_Renderer; + + + /************************************************************************** + * + * @section: + * face_creation + * + */ + + /************************************************************************** + * + * @type: + * FT_Face + * + * @description: + * A handle to a typographic face object. A face object models a given + * typeface, in a given style. + * + * @note: + * A face object also owns a single @FT_GlyphSlot object, as well as one + * or more @FT_Size objects. + * + * Use @FT_New_Face or @FT_Open_Face to create a new face object from a + * given filepath or a custom input stream. + * + * Use @FT_Done_Face to destroy it (along with its slot and sizes). + * + * An `FT_Face` object can only be safely used from one thread at a time. + * Similarly, creation and destruction of `FT_Face` with the same + * @FT_Library object can only be done from one thread at a time. On the + * other hand, functions like @FT_Load_Glyph and its siblings are + * thread-safe and do not need the lock to be held as long as the same + * `FT_Face` object is not used from multiple threads at the same time. + * + * @also: + * See @FT_FaceRec for the publicly accessible fields of a given face + * object. + */ + typedef struct FT_FaceRec_* FT_Face; + + + /************************************************************************** + * + * @section: + * sizing_and_scaling + * + */ + + /************************************************************************** + * + * @type: + * FT_Size + * + * @description: + * A handle to an object that models a face scaled to a given character + * size. + * + * @note: + * An @FT_Face has one _active_ `FT_Size` object that is used by + * functions like @FT_Load_Glyph to determine the scaling transformation + * that in turn is used to load and hint glyphs and metrics. + * + * A newly created `FT_Size` object contains only meaningless zero values. + * You must use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, @FT_Request_Size + * or even @FT_Select_Size to change the content (i.e., the scaling + * values) of the active `FT_Size`. Otherwise, the scaling and hinting + * will not be performed. + * + * You can use @FT_New_Size to create additional size objects for a given + * @FT_Face, but they won't be used by other functions until you activate + * it through @FT_Activate_Size. Only one size can be activated at any + * given time per face. + * + * @also: + * See @FT_SizeRec for the publicly accessible fields of a given size + * object. + */ + typedef struct FT_SizeRec_* FT_Size; + + + /************************************************************************** + * + * @section: + * glyph_retrieval + * + */ + + /************************************************************************** + * + * @type: + * FT_GlyphSlot + * + * @description: + * A handle to a given 'glyph slot'. A slot is a container that can hold + * any of the glyphs contained in its parent face. + * + * In other words, each time you call @FT_Load_Glyph or @FT_Load_Char, + * the slot's content is erased by the new glyph data, i.e., the glyph's + * metrics, its image (bitmap or outline), and other control information. + * + * @also: + * See @FT_GlyphSlotRec for the publicly accessible glyph fields. + */ + typedef struct FT_GlyphSlotRec_* FT_GlyphSlot; + + + /************************************************************************** + * + * @section: + * character_mapping + * + */ + + /************************************************************************** + * + * @type: + * FT_CharMap + * + * @description: + * A handle to a character map (usually abbreviated to 'charmap'). A + * charmap is used to translate character codes in a given encoding into + * glyph indexes for its parent's face. Some font formats may provide + * several charmaps per font. + * + * Each face object owns zero or more charmaps, but only one of them can + * be 'active', providing the data used by @FT_Get_Char_Index or + * @FT_Load_Char. + * + * The list of available charmaps in a face is available through the + * `face->num_charmaps` and `face->charmaps` fields of @FT_FaceRec. + * + * The currently active charmap is available as `face->charmap`. You + * should call @FT_Set_Charmap to change it. + * + * @note: + * When a new face is created (either through @FT_New_Face or + * @FT_Open_Face), the library looks for a Unicode charmap within the + * list and automatically activates it. If there is no Unicode charmap, + * FreeType doesn't set an 'active' charmap. + * + * @also: + * See @FT_CharMapRec for the publicly accessible fields of a given + * character map. + */ + typedef struct FT_CharMapRec_* FT_CharMap; + + + /************************************************************************** + * + * @macro: + * FT_ENC_TAG + * + * @description: + * This macro converts four-letter tags into an unsigned long. It is + * used to define 'encoding' identifiers (see @FT_Encoding). + * + * @note: + * Since many 16-bit compilers don't like 32-bit enumerations, you should + * redefine this macro in case of problems to something like this: + * + * ``` + * #define FT_ENC_TAG( value, a, b, c, d ) value + * ``` + * + * to get a simple enumeration without assigning special numbers. + */ + +#ifndef FT_ENC_TAG + +#define FT_ENC_TAG( value, a, b, c, d ) \ + value = ( ( FT_STATIC_BYTE_CAST( FT_UInt32, a ) << 24 ) | \ + ( FT_STATIC_BYTE_CAST( FT_UInt32, b ) << 16 ) | \ + ( FT_STATIC_BYTE_CAST( FT_UInt32, c ) << 8 ) | \ + FT_STATIC_BYTE_CAST( FT_UInt32, d ) ) + +#endif /* FT_ENC_TAG */ + + + /************************************************************************** + * + * @enum: + * FT_Encoding + * + * @description: + * An enumeration to specify character sets supported by charmaps. Used + * in the @FT_Select_Charmap API function. + * + * @note: + * Despite the name, this enumeration lists specific character + * repertoires (i.e., charsets), and not text encoding methods (e.g., + * UTF-8, UTF-16, etc.). + * + * Other encodings might be defined in the future. + * + * @values: + * FT_ENCODING_NONE :: + * The encoding value~0 is reserved for all formats except BDF, PCF, + * and Windows FNT; see below for more information. + * + * FT_ENCODING_UNICODE :: + * The Unicode character set. This value covers all versions of the + * Unicode repertoire, including ASCII and Latin-1. Most fonts include + * a Unicode charmap, but not all of them. + * + * For example, if you want to access Unicode value U+1F028 (and the + * font contains it), use value 0x1F028 as the input value for + * @FT_Get_Char_Index. + * + * FT_ENCODING_MS_SYMBOL :: + * Microsoft Symbol encoding, used to encode mathematical symbols and + * wingdings. For more information, see + * 'https://www.microsoft.com/typography/otspec/recom.htm#non-standard-symbol-fonts', + * 'http://www.kostis.net/charsets/symbol.htm', and + * 'http://www.kostis.net/charsets/wingding.htm'. + * + * This encoding uses character codes from the PUA (Private Unicode + * Area) in the range U+F020-U+F0FF. + * + * FT_ENCODING_SJIS :: + * Shift JIS encoding for Japanese. More info at + * 'https://en.wikipedia.org/wiki/Shift_JIS'. See note on multi-byte + * encodings below. + * + * FT_ENCODING_PRC :: + * Corresponds to encoding systems mainly for Simplified Chinese as + * used in People's Republic of China (PRC). The encoding layout is + * based on GB~2312 and its supersets GBK and GB~18030. + * + * FT_ENCODING_BIG5 :: + * Corresponds to an encoding system for Traditional Chinese as used in + * Taiwan and Hong Kong. + * + * FT_ENCODING_WANSUNG :: + * Corresponds to the Korean encoding system known as Extended Wansung + * (MS Windows code page 949). For more information see + * 'https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. + * + * FT_ENCODING_JOHAB :: + * The Korean standard character set (KS~C 5601-1992), which + * corresponds to MS Windows code page 1361. This character set + * includes all possible Hangul character combinations. + * + * FT_ENCODING_ADOBE_LATIN_1 :: + * Corresponds to a Latin-1 encoding as defined in a Type~1 PostScript + * font. It is limited to 256 character codes. + * + * FT_ENCODING_ADOBE_STANDARD :: + * Adobe Standard encoding, as found in Type~1, CFF, and OpenType/CFF + * fonts. It is limited to 256 character codes. + * + * FT_ENCODING_ADOBE_EXPERT :: + * Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF + * fonts. It is limited to 256 character codes. + * + * FT_ENCODING_ADOBE_CUSTOM :: + * Corresponds to a custom encoding, as found in Type~1, CFF, and + * OpenType/CFF fonts. It is limited to 256 character codes. + * + * FT_ENCODING_APPLE_ROMAN :: + * Apple roman encoding. Many TrueType and OpenType fonts contain a + * charmap for this 8-bit encoding, since older versions of Mac OS are + * able to use it. + * + * FT_ENCODING_OLD_LATIN_2 :: + * This value is deprecated and was neither used nor reported by + * FreeType. Don't use or test for it. + * + * FT_ENCODING_MS_SJIS :: + * Same as FT_ENCODING_SJIS. Deprecated. + * + * FT_ENCODING_MS_GB2312 :: + * Same as FT_ENCODING_PRC. Deprecated. + * + * FT_ENCODING_MS_BIG5 :: + * Same as FT_ENCODING_BIG5. Deprecated. + * + * FT_ENCODING_MS_WANSUNG :: + * Same as FT_ENCODING_WANSUNG. Deprecated. + * + * FT_ENCODING_MS_JOHAB :: + * Same as FT_ENCODING_JOHAB. Deprecated. + * + * @note: + * When loading a font, FreeType makes a Unicode charmap active if + * possible (either if the font provides such a charmap, or if FreeType + * can synthesize one from PostScript glyph name dictionaries; in either + * case, the charmap is tagged with `FT_ENCODING_UNICODE`). If such a + * charmap is synthesized, it is placed at the first position of the + * charmap array. + * + * All other encodings are considered legacy and tagged only if + * explicitly defined in the font file. Otherwise, `FT_ENCODING_NONE` is + * used. + * + * `FT_ENCODING_NONE` is set by the BDF and PCF drivers if the charmap is + * neither Unicode nor ISO-8859-1 (otherwise it is set to + * `FT_ENCODING_UNICODE`). Use @FT_Get_BDF_Charset_ID to find out which + * encoding is really present. If, for example, the `cs_registry` field + * is 'KOI8' and the `cs_encoding` field is 'R', the font is encoded in + * KOI8-R. + * + * `FT_ENCODING_NONE` is always set (with a single exception) by the + * winfonts driver. Use @FT_Get_WinFNT_Header and examine the `charset` + * field of the @FT_WinFNT_HeaderRec structure to find out which encoding + * is really present. For example, @FT_WinFNT_ID_CP1251 (204) means + * Windows code page 1251 (for Russian). + * + * `FT_ENCODING_NONE` is set if `platform_id` is @TT_PLATFORM_MACINTOSH + * and `encoding_id` is not `TT_MAC_ID_ROMAN` (otherwise it is set to + * `FT_ENCODING_APPLE_ROMAN`). + * + * If `platform_id` is @TT_PLATFORM_MACINTOSH, use the function + * @FT_Get_CMap_Language_ID to query the Mac language ID that may be + * needed to be able to distinguish Apple encoding variants. See + * + * https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt + * + * to get an idea how to do that. Basically, if the language ID is~0, + * don't use it, otherwise subtract 1 from the language ID. Then examine + * `encoding_id`. If, for example, `encoding_id` is `TT_MAC_ID_ROMAN` + * and the language ID (minus~1) is `TT_MAC_LANGID_GREEK`, it is the + * Greek encoding, not Roman. `TT_MAC_ID_ARABIC` with + * `TT_MAC_LANGID_FARSI` means the Farsi variant of the Arabic encoding. + */ + typedef enum FT_Encoding_ + { + FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), + + FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ), + FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ), + + FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ), + FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ), + FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ), + FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ), + FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ), + + /* for backward compatibility */ + FT_ENCODING_GB2312 = FT_ENCODING_PRC, + FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS, + FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC, + FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5, + FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG, + FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB, + + FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ), + + FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ), + + FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' ) + + } FT_Encoding; + + + /* these constants are deprecated; use the corresponding `FT_Encoding` */ + /* values instead */ +#define ft_encoding_none FT_ENCODING_NONE +#define ft_encoding_unicode FT_ENCODING_UNICODE +#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL +#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1 +#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2 +#define ft_encoding_sjis FT_ENCODING_SJIS +#define ft_encoding_gb2312 FT_ENCODING_PRC +#define ft_encoding_big5 FT_ENCODING_BIG5 +#define ft_encoding_wansung FT_ENCODING_WANSUNG +#define ft_encoding_johab FT_ENCODING_JOHAB + +#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD +#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT +#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM +#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN + + + /************************************************************************** + * + * @struct: + * FT_CharMapRec + * + * @description: + * The base charmap structure. + * + * @fields: + * face :: + * A handle to the parent face object. + * + * encoding :: + * An @FT_Encoding tag identifying the charmap. Use this with + * @FT_Select_Charmap. + * + * platform_id :: + * An ID number describing the platform for the following encoding ID. + * This comes directly from the TrueType specification and gets + * emulated for other formats. + * + * encoding_id :: + * A platform-specific encoding number. This also comes from the + * TrueType specification and gets emulated similarly. + */ + typedef struct FT_CharMapRec_ + { + FT_Face face; + FT_Encoding encoding; + FT_UShort platform_id; + FT_UShort encoding_id; + + } FT_CharMapRec; + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* B A S E O B J E C T C L A S S E S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * @section: + * other_api_data + * + */ + + /************************************************************************** + * + * @type: + * FT_Face_Internal + * + * @description: + * An opaque handle to an `FT_Face_InternalRec` structure that models the + * private data of a given @FT_Face object. + * + * This structure might change between releases of FreeType~2 and is not + * generally available to client applications. + */ + typedef struct FT_Face_InternalRec_* FT_Face_Internal; + + + /************************************************************************** + * + * @section: + * face_creation + * + */ + + /************************************************************************** + * + * @struct: + * FT_FaceRec + * + * @description: + * FreeType root face class structure. A face object models a typeface + * in a font file. + * + * @fields: + * num_faces :: + * The number of faces in the font file. Some font formats can have + * multiple faces in a single font file. + * + * face_index :: + * This field holds two different values. Bits 0-15 are the index of + * the face in the font file (starting with value~0). They are set + * to~0 if there is only one face in the font file. + * + * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation + * fonts only, holding the named instance index for the current face + * index (starting with value~1; value~0 indicates font access without + * a named instance). For non-variation fonts, bits 16-30 are ignored. + * If we have the third named instance of face~4, say, `face_index` is + * set to 0x00030004. + * + * Bit 31 is always zero (that is, `face_index` is always a positive + * value). + * + * [Since 2.9] Changing the design coordinates with + * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does + * not influence the named instance index value (only + * @FT_Set_Named_Instance does that). + * + * face_flags :: + * A set of bit flags that give important information about the face; + * see @FT_FACE_FLAG_XXX for the details. + * + * style_flags :: + * The lower 16~bits contain a set of bit flags indicating the style of + * the face; see @FT_STYLE_FLAG_XXX for the details. + * + * [Since 2.6.1] Bits 16-30 hold the number of named instances + * available for the current face if we have a GX or OpenType variation + * (sub)font. Bit 31 is always zero (that is, `style_flags` is always + * a positive value). Note that a variation font has always at least + * one named instance, namely the default instance. + * + * num_glyphs :: + * The number of glyphs in the face. If the face is scalable and has + * sbits (see `num_fixed_sizes`), it is set to the number of outline + * glyphs. + * + * For CID-keyed fonts (not in an SFNT wrapper) this value gives the + * highest CID used in the font. + * + * family_name :: + * The face's family name. This is an ASCII string, usually in + * English, that describes the typeface's family (like 'Times New + * Roman', 'Bodoni', 'Garamond', etc). This is a least common + * denominator used to list fonts. Some formats (TrueType & OpenType) + * provide localized and Unicode versions of this string. Applications + * should use the format-specific interface to access them. Can be + * `NULL` (e.g., in fonts embedded in a PDF file). + * + * In case the font doesn't provide a specific family name entry, + * FreeType tries to synthesize one, deriving it from other name + * entries. + * + * style_name :: + * The face's style name. This is an ASCII string, usually in English, + * that describes the typeface's style (like 'Italic', 'Bold', + * 'Condensed', etc). Not all font formats provide a style name, so + * this field is optional, and can be set to `NULL`. As for + * `family_name`, some formats provide localized and Unicode versions + * of this string. Applications should use the format-specific + * interface to access them. + * + * num_fixed_sizes :: + * The number of bitmap strikes in the face. Even if the face is + * scalable, there might still be bitmap strikes, which are called + * 'sbits' in that case. + * + * available_sizes :: + * An array of @FT_Bitmap_Size for all bitmap strikes in the face. It + * is set to `NULL` if there is no bitmap strike. + * + * Note that FreeType tries to sanitize the strike data since they are + * sometimes sloppy or incorrect, but this can easily fail. + * + * num_charmaps :: + * The number of charmaps in the face. + * + * charmaps :: + * An array of the charmaps of the face. + * + * generic :: + * A field reserved for client uses. See the @FT_Generic type + * description. + * + * bbox :: + * The font bounding box. Coordinates are expressed in font units (see + * `units_per_EM`). The box is large enough to contain any glyph from + * the font. Thus, `bbox.yMax` can be seen as the 'maximum ascender', + * and `bbox.yMin` as the 'minimum descender'. Only relevant for + * scalable formats. + * + * Note that the bounding box might be off by (at least) one pixel for + * hinted fonts. See @FT_Size_Metrics for further discussion. + * + * Note that the bounding box does not vary in OpenType variation fonts + * and should only be used in relation to the default instance. + * + * units_per_EM :: + * The number of font units per EM square for this face. This is + * typically 2048 for TrueType fonts, and 1000 for Type~1 fonts. Only + * relevant for scalable formats. + * + * ascender :: + * The typographic ascender of the face, expressed in font units. For + * font formats not having this information, it is set to `bbox.yMax`. + * Only relevant for scalable formats. + * + * descender :: + * The typographic descender of the face, expressed in font units. For + * font formats not having this information, it is set to `bbox.yMin`. + * Note that this field is negative for values below the baseline. + * Only relevant for scalable formats. + * + * height :: + * This value is the vertical distance between two consecutive + * baselines, expressed in font units. It is always positive. Only + * relevant for scalable formats. + * + * If you want the global glyph height, use `ascender - descender`. + * + * max_advance_width :: + * The maximum advance width, in font units, for all glyphs in this + * face. This can be used to make word wrapping computations faster. + * Only relevant for scalable formats. + * + * max_advance_height :: + * The maximum advance height, in font units, for all glyphs in this + * face. This is only relevant for vertical layouts, and is set to + * `height` for fonts that do not provide vertical metrics. Only + * relevant for scalable formats. + * + * underline_position :: + * The position, in font units, of the underline line for this face. + * It is the center of the underlining stem. Only relevant for + * scalable formats. + * + * underline_thickness :: + * The thickness, in font units, of the underline for this face. Only + * relevant for scalable formats. + * + * glyph :: + * The face's associated glyph slot(s). + * + * size :: + * The current active size for this face. + * + * charmap :: + * The current active charmap for this face. + * + * @note: + * Fields may be changed after a call to @FT_Attach_File or + * @FT_Attach_Stream. + * + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `ascender`, `descender`, `height`, + * `underline_position`, and `underline_thickness`. + * + * Especially for TrueType fonts see also the documentation for + * @FT_Size_Metrics. + */ + typedef struct FT_FaceRec_ + { + FT_Long num_faces; + FT_Long face_index; + + FT_Long face_flags; + FT_Long style_flags; + + FT_Long num_glyphs; + + FT_String* family_name; + FT_String* style_name; + + FT_Int num_fixed_sizes; + FT_Bitmap_Size* available_sizes; + + FT_Int num_charmaps; + FT_CharMap* charmaps; + + FT_Generic generic; + + /* The following member variables (down to `underline_thickness`) */ + /* are only relevant to scalable outlines; cf. @FT_Bitmap_Size */ + /* for bitmap fonts. */ + FT_BBox bbox; + + FT_UShort units_per_EM; + FT_Short ascender; + FT_Short descender; + FT_Short height; + + FT_Short max_advance_width; + FT_Short max_advance_height; + + FT_Short underline_position; + FT_Short underline_thickness; + + FT_GlyphSlot glyph; + FT_Size size; + FT_CharMap charmap; + + /* private fields, internal to FreeType */ + + FT_Driver driver; + FT_Memory memory; + FT_Stream stream; + + FT_ListRec sizes_list; + + FT_Generic autohint; /* face-specific auto-hinter data */ + void* extensions; /* unused */ + + FT_Face_Internal internal; + + } FT_FaceRec; + + + /************************************************************************** + * + * @enum: + * FT_FACE_FLAG_XXX + * + * @description: + * A list of bit flags used in the `face_flags` field of the @FT_FaceRec + * structure. They inform client applications of properties of the + * corresponding face. + * + * @values: + * FT_FACE_FLAG_SCALABLE :: + * The face contains outline glyphs. Note that a face can contain + * bitmap strikes also, i.e., a face can have both this flag and + * @FT_FACE_FLAG_FIXED_SIZES set. + * + * FT_FACE_FLAG_FIXED_SIZES :: + * The face contains bitmap strikes. See also the `num_fixed_sizes` + * and `available_sizes` fields of @FT_FaceRec. + * + * FT_FACE_FLAG_FIXED_WIDTH :: + * The face contains fixed-width characters (like Courier, Lucida, + * MonoType, etc.). + * + * FT_FACE_FLAG_SFNT :: + * The face uses the SFNT storage scheme. For now, this means TrueType + * and OpenType. + * + * FT_FACE_FLAG_HORIZONTAL :: + * The face contains horizontal glyph metrics. This should be set for + * all common formats. + * + * FT_FACE_FLAG_VERTICAL :: + * The face contains vertical glyph metrics. This is only available in + * some formats, not all of them. + * + * FT_FACE_FLAG_KERNING :: + * The face contains kerning information. If set, the kerning distance + * can be retrieved using the function @FT_Get_Kerning. Otherwise the + * function always returns the vector (0,0). + * + * Note that for TrueType fonts only, FreeType supports both the 'kern' + * table and the basic, pair-wise kerning feature from the 'GPOS' table + * (with `TT_CONFIG_OPTION_GPOS_KERNING` enabled), though FreeType does + * not support the more advanced GPOS layout features; use a library + * like HarfBuzz for those instead. + * + * FT_FACE_FLAG_FAST_GLYPHS :: + * THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. + * + * FT_FACE_FLAG_MULTIPLE_MASTERS :: + * The face contains multiple masters and is capable of interpolating + * between them. Supported formats are Adobe MM, TrueType GX, and + * OpenType variation fonts. + * + * See section @multiple_masters for API details. + * + * FT_FACE_FLAG_GLYPH_NAMES :: + * The face contains glyph names, which can be retrieved using + * @FT_Get_Glyph_Name. Note that some TrueType fonts contain broken + * glyph name tables. Use the function @FT_Has_PS_Glyph_Names when + * needed. + * + * FT_FACE_FLAG_EXTERNAL_STREAM :: + * Used internally by FreeType to indicate that a face's stream was + * provided by the client application and should not be destroyed when + * @FT_Done_Face is called. Don't read or test this flag. + * + * FT_FACE_FLAG_HINTER :: + * The font driver has a hinting machine of its own. For example, with + * TrueType fonts, it makes sense to use data from the SFNT 'gasp' + * table only if the native TrueType hinting engine (with the bytecode + * interpreter) is available and active. + * + * FT_FACE_FLAG_CID_KEYED :: + * The face is CID-keyed. In that case, the face is not accessed by + * glyph indices but by CID values. For subsetted CID-keyed fonts this + * has the consequence that not all index values are a valid argument + * to @FT_Load_Glyph. Only the CID values for which corresponding + * glyphs in the subsetted font exist make `FT_Load_Glyph` return + * successfully; in all other cases you get an + * `FT_Err_Invalid_Argument` error. + * + * Note that CID-keyed fonts that are in an SFNT wrapper (that is, all + * OpenType/CFF fonts) don't have this flag set since the glyphs are + * accessed in the normal way (using contiguous indices); the + * 'CID-ness' isn't visible to the application. + * + * FT_FACE_FLAG_TRICKY :: + * The face is 'tricky', that is, it always needs the font format's + * native hinting engine to get a reasonable result. A typical example + * is the old Chinese font `mingli.ttf` (but not `mingliu.ttc`) that + * uses TrueType bytecode instructions to move and scale all of its + * subglyphs. + * + * It is not possible to auto-hint such fonts using + * @FT_LOAD_FORCE_AUTOHINT; it will also ignore @FT_LOAD_NO_HINTING. + * You have to set both @FT_LOAD_NO_HINTING and @FT_LOAD_NO_AUTOHINT to + * really disable hinting; however, you probably never want this except + * for demonstration purposes. + * + * Currently, there are about a dozen TrueType fonts in the list of + * tricky fonts; they are hard-coded in file `ttobjs.c`. + * + * FT_FACE_FLAG_COLOR :: + * [Since 2.5.1] The face has color glyph tables. See @FT_LOAD_COLOR + * for more information. + * + * FT_FACE_FLAG_VARIATION :: + * [Since 2.9] Set if the current face (or named instance) has been + * altered with @FT_Set_MM_Design_Coordinates, + * @FT_Set_Var_Design_Coordinates, @FT_Set_Var_Blend_Coordinates, or + * @FT_Set_MM_WeightVector to select a non-default instance. + * + * FT_FACE_FLAG_SVG :: + * [Since 2.12] The face has an 'SVG~' OpenType table. + * + * FT_FACE_FLAG_SBIX :: + * [Since 2.12] The face has an 'sbix' OpenType table *and* outlines. + * For such fonts, @FT_FACE_FLAG_SCALABLE is not set by default to + * retain backward compatibility. + * + * FT_FACE_FLAG_SBIX_OVERLAY :: + * [Since 2.12] The face has an 'sbix' OpenType table where outlines + * should be drawn on top of bitmap strikes. + * + */ +#define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) +#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) +#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) +#define FT_FACE_FLAG_SFNT ( 1L << 3 ) +#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 ) +#define FT_FACE_FLAG_VERTICAL ( 1L << 5 ) +#define FT_FACE_FLAG_KERNING ( 1L << 6 ) +#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 ) +#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 ) +#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 ) +#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 ) +#define FT_FACE_FLAG_HINTER ( 1L << 11 ) +#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 ) +#define FT_FACE_FLAG_TRICKY ( 1L << 13 ) +#define FT_FACE_FLAG_COLOR ( 1L << 14 ) +#define FT_FACE_FLAG_VARIATION ( 1L << 15 ) +#define FT_FACE_FLAG_SVG ( 1L << 16 ) +#define FT_FACE_FLAG_SBIX ( 1L << 17 ) +#define FT_FACE_FLAG_SBIX_OVERLAY ( 1L << 18 ) + + + /************************************************************************** + * + * @section: + * font_testing_macros + * + */ + + /************************************************************************** + * + * @macro: + * FT_HAS_HORIZONTAL + * + * @description: + * A macro that returns true whenever a face object contains horizontal + * metrics (this is true for all font formats though). + * + * @also: + * @FT_HAS_VERTICAL can be used to check for vertical metrics. + * + */ +#define FT_HAS_HORIZONTAL( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) ) + + + /************************************************************************** + * + * @macro: + * FT_HAS_VERTICAL + * + * @description: + * A macro that returns true whenever a face object contains real + * vertical metrics (and not only synthesized ones). + * + */ +#define FT_HAS_VERTICAL( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) ) + + + /************************************************************************** + * + * @macro: + * FT_HAS_KERNING + * + * @description: + * A macro that returns true whenever a face object contains kerning data + * that can be accessed with @FT_Get_Kerning. + * + */ +#define FT_HAS_KERNING( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_KERNING ) ) + + + /************************************************************************** + * + * @macro: + * FT_IS_SCALABLE + * + * @description: + * A macro that returns true whenever a face object contains a scalable + * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, and + * PFR font formats). + * + */ +#define FT_IS_SCALABLE( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) ) + + + /************************************************************************** + * + * @macro: + * FT_IS_SFNT + * + * @description: + * A macro that returns true whenever a face object contains a font whose + * format is based on the SFNT storage scheme. This usually means: + * TrueType fonts, OpenType fonts, as well as SFNT-based embedded bitmap + * fonts. + * + * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and + * @FT_TRUETYPE_TABLES_H are available. + * + */ +#define FT_IS_SFNT( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_SFNT ) ) + + + /************************************************************************** + * + * @macro: + * FT_IS_FIXED_WIDTH + * + * @description: + * A macro that returns true whenever a face object contains a font face + * that contains fixed-width (or 'monospace', 'fixed-pitch', etc.) + * glyphs. + * + */ +#define FT_IS_FIXED_WIDTH( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) ) + + + /************************************************************************** + * + * @macro: + * FT_HAS_FIXED_SIZES + * + * @description: + * A macro that returns true whenever a face object contains some + * embedded bitmaps. See the `available_sizes` field of the @FT_FaceRec + * structure. + * + */ +#define FT_HAS_FIXED_SIZES( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) ) + + + /************************************************************************** + * + * @section: + * other_api_data + * + */ + + /************************************************************************** + * + * @macro: + * FT_HAS_FAST_GLYPHS + * + * @description: + * Deprecated. + * + */ +#define FT_HAS_FAST_GLYPHS( face ) 0 + + + /************************************************************************** + * + * @section: + * font_testing_macros + * + */ + + /************************************************************************** + * + * @macro: + * FT_HAS_GLYPH_NAMES + * + * @description: + * A macro that returns true whenever a face object contains some glyph + * names that can be accessed through @FT_Get_Glyph_Name. + * + */ +#define FT_HAS_GLYPH_NAMES( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) ) + + + /************************************************************************** + * + * @macro: + * FT_HAS_MULTIPLE_MASTERS + * + * @description: + * A macro that returns true whenever a face object contains some + * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H + * are then available to choose the exact design you want. + * + */ +#define FT_HAS_MULTIPLE_MASTERS( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) ) + + + /************************************************************************** + * + * @macro: + * FT_IS_NAMED_INSTANCE + * + * @description: + * A macro that returns true whenever a face object is a named instance + * of a GX or OpenType variation font. + * + * [Since 2.9] Changing the design coordinates with + * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does + * not influence the return value of this macro (only + * @FT_Set_Named_Instance does that). + * + * @since: + * 2.7 + * + */ +#define FT_IS_NAMED_INSTANCE( face ) \ + ( !!( (face)->face_index & 0x7FFF0000L ) ) + + + /************************************************************************** + * + * @macro: + * FT_IS_VARIATION + * + * @description: + * A macro that returns true whenever a face object has been altered by + * @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, + * @FT_Set_Var_Blend_Coordinates, or @FT_Set_MM_WeightVector. + * + * @since: + * 2.9 + * + */ +#define FT_IS_VARIATION( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_VARIATION ) ) + + + /************************************************************************** + * + * @macro: + * FT_IS_CID_KEYED + * + * @description: + * A macro that returns true whenever a face object contains a CID-keyed + * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more details. + * + * If this macro is true, all functions defined in @FT_CID_H are + * available. + * + */ +#define FT_IS_CID_KEYED( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) ) + + + /************************************************************************** + * + * @macro: + * FT_IS_TRICKY + * + * @description: + * A macro that returns true whenever a face represents a 'tricky' font. + * See the discussion of @FT_FACE_FLAG_TRICKY for more details. + * + */ +#define FT_IS_TRICKY( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_TRICKY ) ) + + + /************************************************************************** + * + * @macro: + * FT_HAS_COLOR + * + * @description: + * A macro that returns true whenever a face object contains tables for + * color glyphs. + * + * @since: + * 2.5.1 + * + */ +#define FT_HAS_COLOR( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_COLOR ) ) + + + /************************************************************************** + * + * @macro: + * FT_HAS_SVG + * + * @description: + * A macro that returns true whenever a face object contains an 'SVG~' + * OpenType table. + * + * @since: + * 2.12 + */ +#define FT_HAS_SVG( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_SVG ) ) + + + /************************************************************************** + * + * @macro: + * FT_HAS_SBIX + * + * @description: + * A macro that returns true whenever a face object contains an 'sbix' + * OpenType table *and* outline glyphs. + * + * Currently, FreeType only supports bitmap glyphs in PNG format for this + * table (i.e., JPEG and TIFF formats are unsupported, as are + * Apple-specific formats not part of the OpenType specification). + * + * @note: + * For backward compatibility, a font with an 'sbix' table is treated as + * a bitmap-only face. Using @FT_Open_Face with + * @FT_PARAM_TAG_IGNORE_SBIX, an application can switch off 'sbix' + * handling so that the face is treated as an ordinary outline font with + * scalable outlines. + * + * Here is some pseudo code that roughly illustrates how to implement + * 'sbix' handling according to the OpenType specification. + * + * ``` + * if ( FT_HAS_SBIX( face ) ) + * { + * // open font as a scalable one without sbix handling + * FT_Face face2; + * FT_Parameter param = { FT_PARAM_TAG_IGNORE_SBIX, NULL }; + * FT_Open_Args args = { FT_OPEN_PARAMS | ..., + * ..., + * 1, ¶m }; + * + * + * FT_Open_Face( library, &args, 0, &face2 ); + * + * available_size` as necessary into + * `preferred_sizes`[*]> + * + * for ( i = 0; i < face->num_fixed_sizes; i++ ) + * { + * size = preferred_sizes[i].size; + * + * error = FT_Set_Pixel_Sizes( face, size, size ); + * + * + * // check whether we have a glyph in a bitmap strike + * error = FT_Load_Glyph( face, + * glyph_index, + * FT_LOAD_SBITS_ONLY | + * FT_LOAD_BITMAP_METRICS_ONLY ); + * if ( error == FT_Err_Invalid_Argument ) + * continue; + * else if ( error ) + * + * else + * break; + * } + * + * if ( i != face->num_fixed_sizes ) + * + * + * if ( i == face->num_fixed_sizes || + * FT_HAS_SBIX_OVERLAY( face ) ) + * + * } + * ``` + * + * [*] Assuming a target value of 400dpi and available strike sizes 100, + * 200, 300, and 400dpi, a possible order might be [400, 200, 300, 100]: + * scaling 200dpi to 400dpi usually gives better results than scaling + * 300dpi to 400dpi; it is also much faster. However, scaling 100dpi to + * 400dpi can yield a too pixelated result, thus the preference might be + * 300dpi over 100dpi. + * + * @since: + * 2.12 + */ +#define FT_HAS_SBIX( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX ) ) + + + /************************************************************************** + * + * @macro: + * FT_HAS_SBIX_OVERLAY + * + * @description: + * A macro that returns true whenever a face object contains an 'sbix' + * OpenType table with bit~1 in its `flags` field set, instructing the + * application to overlay the bitmap strike with the corresponding + * outline glyph. See @FT_HAS_SBIX for pseudo code how to use it. + * + * @since: + * 2.12 + */ +#define FT_HAS_SBIX_OVERLAY( face ) \ + ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX_OVERLAY ) ) + + + /************************************************************************** + * + * @section: + * face_creation + * + */ + + /************************************************************************** + * + * @enum: + * FT_STYLE_FLAG_XXX + * + * @description: + * A list of bit flags to indicate the style of a given face. These are + * used in the `style_flags` field of @FT_FaceRec. + * + * @values: + * FT_STYLE_FLAG_ITALIC :: + * The face style is italic or oblique. + * + * FT_STYLE_FLAG_BOLD :: + * The face is bold. + * + * @note: + * The style information as provided by FreeType is very basic. More + * details are beyond the scope and should be done on a higher level (for + * example, by analyzing various fields of the 'OS/2' table in SFNT based + * fonts). + */ +#define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) +#define FT_STYLE_FLAG_BOLD ( 1 << 1 ) + + + /************************************************************************** + * + * @section: + * other_api_data + * + */ + + /************************************************************************** + * + * @type: + * FT_Size_Internal + * + * @description: + * An opaque handle to an `FT_Size_InternalRec` structure, used to model + * private data of a given @FT_Size object. + */ + typedef struct FT_Size_InternalRec_* FT_Size_Internal; + + + /************************************************************************** + * + * @section: + * sizing_and_scaling + * + */ + + /************************************************************************** + * + * @struct: + * FT_Size_Metrics + * + * @description: + * The size metrics structure gives the metrics of a size object. + * + * @fields: + * x_ppem :: + * The width of the scaled EM square in pixels, hence the term 'ppem' + * (pixels per EM). It is also referred to as 'nominal width'. + * + * y_ppem :: + * The height of the scaled EM square in pixels, hence the term 'ppem' + * (pixels per EM). It is also referred to as 'nominal height'. + * + * x_scale :: + * A 16.16 fractional scaling value to convert horizontal metrics from + * font units to 26.6 fractional pixels. Only relevant for scalable + * font formats. + * + * y_scale :: + * A 16.16 fractional scaling value to convert vertical metrics from + * font units to 26.6 fractional pixels. Only relevant for scalable + * font formats. + * + * ascender :: + * The ascender in 26.6 fractional pixels, rounded up to an integer + * value. See @FT_FaceRec for the details. + * + * descender :: + * The descender in 26.6 fractional pixels, rounded down to an integer + * value. See @FT_FaceRec for the details. + * + * height :: + * The height in 26.6 fractional pixels, rounded to an integer value. + * See @FT_FaceRec for the details. + * + * max_advance :: + * The maximum advance width in 26.6 fractional pixels, rounded to an + * integer value. See @FT_FaceRec for the details. + * + * @note: + * The scaling values, if relevant, are determined first during a size + * changing operation. The remaining fields are then set by the driver. + * For scalable formats, they are usually set to scaled values of the + * corresponding fields in @FT_FaceRec. Some values like ascender or + * descender are rounded for historical reasons; more precise values (for + * outline fonts) can be derived by scaling the corresponding @FT_FaceRec + * values manually, with code similar to the following. + * + * ``` + * scaled_ascender = FT_MulFix( face->ascender, + * size_metrics->y_scale ); + * ``` + * + * Note that due to glyph hinting and the selected rendering mode these + * values are usually not exact; consequently, they must be treated as + * unreliable with an error margin of at least one pixel! + * + * Indeed, the only way to get the exact metrics is to render _all_ + * glyphs. As this would be a definite performance hit, it is up to + * client applications to perform such computations. + * + * The `FT_Size_Metrics` structure is valid for bitmap fonts also. + * + * + * **TrueType fonts with native bytecode hinting** + * + * All applications that handle TrueType fonts with native hinting must + * be aware that TTFs expect different rounding of vertical font + * dimensions. The application has to cater for this, especially if it + * wants to rely on a TTF's vertical data (for example, to properly align + * box characters vertically). + * + * Only the application knows _in advance_ that it is going to use native + * hinting for TTFs! FreeType, on the other hand, selects the hinting + * mode not at the time of creating an @FT_Size object but much later, + * namely while calling @FT_Load_Glyph. + * + * Here is some pseudo code that illustrates a possible solution. + * + * ``` + * font_format = FT_Get_Font_Format( face ); + * + * if ( !strcmp( font_format, "TrueType" ) && + * do_native_bytecode_hinting ) + * { + * ascender = ROUND( FT_MulFix( face->ascender, + * size_metrics->y_scale ) ); + * descender = ROUND( FT_MulFix( face->descender, + * size_metrics->y_scale ) ); + * } + * else + * { + * ascender = size_metrics->ascender; + * descender = size_metrics->descender; + * } + * + * height = size_metrics->height; + * max_advance = size_metrics->max_advance; + * ``` + */ + typedef struct FT_Size_Metrics_ + { + FT_UShort x_ppem; /* horizontal pixels per EM */ + FT_UShort y_ppem; /* vertical pixels per EM */ + + FT_Fixed x_scale; /* scaling values used to convert font */ + FT_Fixed y_scale; /* units to 26.6 fractional pixels */ + + FT_Pos ascender; /* ascender in 26.6 frac. pixels */ + FT_Pos descender; /* descender in 26.6 frac. pixels */ + FT_Pos height; /* text height in 26.6 frac. pixels */ + FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */ + + } FT_Size_Metrics; + + + /************************************************************************** + * + * @struct: + * FT_SizeRec + * + * @description: + * FreeType root size class structure. A size object models a face + * object at a given size. + * + * @fields: + * face :: + * Handle to the parent face object. + * + * generic :: + * A typeless pointer, unused by the FreeType library or any of its + * drivers. It can be used by client applications to link their own + * data to each size object. + * + * metrics :: + * Metrics for this size object. This field is read-only. + */ + typedef struct FT_SizeRec_ + { + FT_Face face; /* parent face object */ + FT_Generic generic; /* generic pointer for client uses */ + FT_Size_Metrics metrics; /* size metrics */ + FT_Size_Internal internal; + + } FT_SizeRec; + + + /************************************************************************** + * + * @section: + * other_api_data + * + */ + + /************************************************************************** + * + * @struct: + * FT_SubGlyph + * + * @description: + * The subglyph structure is an internal object used to describe + * subglyphs (for example, in the case of composites). + * + * @note: + * The subglyph implementation is not part of the high-level API, hence + * the forward structure declaration. + * + * You can however retrieve subglyph information with + * @FT_Get_SubGlyph_Info. + */ + typedef struct FT_SubGlyphRec_* FT_SubGlyph; + + + /************************************************************************** + * + * @type: + * FT_Slot_Internal + * + * @description: + * An opaque handle to an `FT_Slot_InternalRec` structure, used to model + * private data of a given @FT_GlyphSlot object. + */ + typedef struct FT_Slot_InternalRec_* FT_Slot_Internal; + + + /************************************************************************** + * + * @section: + * glyph_retrieval + * + */ + + /************************************************************************** + * + * @struct: + * FT_GlyphSlotRec + * + * @description: + * FreeType root glyph slot class structure. A glyph slot is a container + * where individual glyphs can be loaded, be they in outline or bitmap + * format. + * + * @fields: + * library :: + * A handle to the FreeType library instance this slot belongs to. + * + * face :: + * A handle to the parent face object. + * + * next :: + * In some cases (like some font tools), several glyph slots per face + * object can be a good thing. As this is rare, the glyph slots are + * listed through a direct, single-linked list using its `next` field. + * + * glyph_index :: + * [Since 2.10] The glyph index passed as an argument to @FT_Load_Glyph + * while initializing the glyph slot. + * + * generic :: + * A typeless pointer unused by the FreeType library or any of its + * drivers. It can be used by client applications to link their own + * data to each glyph slot object. + * + * metrics :: + * The metrics of the last loaded glyph in the slot. The returned + * values depend on the last load flags (see the @FT_Load_Glyph API + * function) and can be expressed either in 26.6 fractional pixels or + * font units. + * + * Note that even when the glyph image is transformed, the metrics are + * not. + * + * linearHoriAdvance :: + * The advance width of the unhinted glyph. Its value is expressed in + * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when + * loading the glyph. This field can be important to perform correct + * WYSIWYG layout. Only relevant for scalable glyphs. + * + * linearVertAdvance :: + * The advance height of the unhinted glyph. Its value is expressed in + * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when + * loading the glyph. This field can be important to perform correct + * WYSIWYG layout. Only relevant for scalable glyphs. + * + * advance :: + * This shorthand is, depending on @FT_LOAD_IGNORE_TRANSFORM, the + * transformed (hinted) advance width for the glyph, in 26.6 fractional + * pixel format. As specified with @FT_LOAD_VERTICAL_LAYOUT, it uses + * either the `horiAdvance` or the `vertAdvance` value of `metrics` + * field. + * + * format :: + * This field indicates the format of the image contained in the glyph + * slot. Typically @FT_GLYPH_FORMAT_BITMAP, @FT_GLYPH_FORMAT_OUTLINE, + * or @FT_GLYPH_FORMAT_COMPOSITE, but other values are possible. + * + * bitmap :: + * This field is used as a bitmap descriptor. Note that the address + * and content of the bitmap buffer can change between calls of + * @FT_Load_Glyph and a few other functions. + * + * bitmap_left :: + * The bitmap's left bearing expressed in integer pixels. + * + * bitmap_top :: + * The bitmap's top bearing expressed in integer pixels. This is the + * distance from the baseline to the top-most glyph scanline, upwards + * y~coordinates being **positive**. + * + * outline :: + * The outline descriptor for the current glyph image if its format is + * @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is loaded, `outline` can be + * transformed, distorted, emboldened, etc. However, it must not be + * freed. + * + * [Since 2.10.1] If @FT_LOAD_NO_SCALE is set, outline coordinates of + * OpenType variation fonts for a selected instance are internally + * handled as 26.6 fractional font units but returned as (rounded) + * integers, as expected. To get unrounded font units, don't use + * @FT_LOAD_NO_SCALE but load the glyph with @FT_LOAD_NO_HINTING and + * scale it, using the font's `units_per_EM` value as the ppem. + * + * num_subglyphs :: + * The number of subglyphs in a composite glyph. This field is only + * valid for the composite glyph format that should normally only be + * loaded with the @FT_LOAD_NO_RECURSE flag. + * + * subglyphs :: + * An array of subglyph descriptors for composite glyphs. There are + * `num_subglyphs` elements in there. Currently internal to FreeType. + * + * control_data :: + * Certain font drivers can also return the control data for a given + * glyph image (e.g. TrueType bytecode, Type~1 charstrings, etc.). + * This field is a pointer to such data; it is currently internal to + * FreeType. + * + * control_len :: + * This is the length in bytes of the control data. Currently internal + * to FreeType. + * + * other :: + * Reserved. + * + * lsb_delta :: + * The difference between hinted and unhinted left side bearing while + * auto-hinting is active. Zero otherwise. + * + * rsb_delta :: + * The difference between hinted and unhinted right side bearing while + * auto-hinting is active. Zero otherwise. + * + * @note: + * If @FT_Load_Glyph is called with default flags (see @FT_LOAD_DEFAULT) + * the glyph image is loaded in the glyph slot in its native format + * (e.g., an outline glyph for TrueType and Type~1 formats). [Since 2.9] + * The prospective bitmap metrics are calculated according to + * @FT_LOAD_TARGET_XXX and other flags even for the outline glyph, even + * if @FT_LOAD_RENDER is not set. + * + * This image can later be converted into a bitmap by calling + * @FT_Render_Glyph. This function searches the current renderer for the + * native image's format, then invokes it. + * + * The renderer is in charge of transforming the native image through the + * slot's face transformation fields, then converting it into a bitmap + * that is returned in `slot->bitmap`. + * + * Note that `slot->bitmap_left` and `slot->bitmap_top` are also used to + * specify the position of the bitmap relative to the current pen + * position (e.g., coordinates (0,0) on the baseline). Of course, + * `slot->format` is also changed to @FT_GLYPH_FORMAT_BITMAP. + * + * Here is a small pseudo code fragment that shows how to use `lsb_delta` + * and `rsb_delta` to do fractional positioning of glyphs: + * + * ``` + * FT_GlyphSlot slot = face->glyph; + * FT_Pos origin_x = 0; + * + * + * for all glyphs do + * + * + * FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); + * + * + * + * + * + * origin_x += slot->advance.x; + * origin_x += slot->lsb_delta - slot->rsb_delta; + * endfor + * ``` + * + * Here is another small pseudo code fragment that shows how to use + * `lsb_delta` and `rsb_delta` to improve integer positioning of glyphs: + * + * ``` + * FT_GlyphSlot slot = face->glyph; + * FT_Pos origin_x = 0; + * FT_Pos prev_rsb_delta = 0; + * + * + * for all glyphs do + * + * + * + * + * if ( prev_rsb_delta - slot->lsb_delta > 32 ) + * origin_x -= 64; + * else if ( prev_rsb_delta - slot->lsb_delta < -31 ) + * origin_x += 64; + * + * prev_rsb_delta = slot->rsb_delta; + * + * + * + * origin_x += slot->advance.x; + * endfor + * ``` + * + * If you use strong auto-hinting, you **must** apply these delta values! + * Otherwise you will experience far too large inter-glyph spacing at + * small rendering sizes in most cases. Note that it doesn't harm to use + * the above code for other hinting modes also, since the delta values + * are zero then. + */ + typedef struct FT_GlyphSlotRec_ + { + FT_Library library; + FT_Face face; + FT_GlyphSlot next; + FT_UInt glyph_index; /* new in 2.10; was reserved previously */ + FT_Generic generic; + + FT_Glyph_Metrics metrics; + FT_Fixed linearHoriAdvance; + FT_Fixed linearVertAdvance; + FT_Vector advance; + + FT_Glyph_Format format; + + FT_Bitmap bitmap; + FT_Int bitmap_left; + FT_Int bitmap_top; + + FT_Outline outline; + + FT_UInt num_subglyphs; + FT_SubGlyph subglyphs; + + void* control_data; + long control_len; + + FT_Pos lsb_delta; + FT_Pos rsb_delta; + + void* other; + + FT_Slot_Internal internal; + + } FT_GlyphSlotRec; + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* F U N C T I O N S */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * @section: + * library_setup + * + */ + + /************************************************************************** + * + * @function: + * FT_Init_FreeType + * + * @description: + * Initialize a new FreeType library object. The set of modules that are + * registered by this function is determined at build time. + * + * @output: + * alibrary :: + * A handle to a new library object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * In case you want to provide your own memory allocating routines, use + * @FT_New_Library instead, followed by a call to @FT_Add_Default_Modules + * (or a series of calls to @FT_Add_Module) and + * @FT_Set_Default_Properties. + * + * See the documentation of @FT_Library and @FT_Face for multi-threading + * issues. + * + * If you need reference-counting (cf. @FT_Reference_Library), use + * @FT_New_Library and @FT_Done_Library. + * + * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is + * set, this function reads the `FREETYPE_PROPERTIES` environment + * variable to control driver properties. See section @properties for + * more. + */ + FT_EXPORT( FT_Error ) + FT_Init_FreeType( FT_Library *alibrary ); + + + /************************************************************************** + * + * @function: + * FT_Done_FreeType + * + * @description: + * Destroy a given FreeType library object and all of its children, + * including resources, drivers, faces, sizes, etc. + * + * @input: + * library :: + * A handle to the target library object. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Done_FreeType( FT_Library library ); + + + /************************************************************************** + * + * @section: + * face_creation + * + */ + + /************************************************************************** + * + * @enum: + * FT_OPEN_XXX + * + * @description: + * A list of bit field constants used within the `flags` field of the + * @FT_Open_Args structure. + * + * @values: + * FT_OPEN_MEMORY :: + * This is a memory-based stream. + * + * FT_OPEN_STREAM :: + * Copy the stream from the `stream` field. + * + * FT_OPEN_PATHNAME :: + * Create a new input stream from a C~path name. + * + * FT_OPEN_DRIVER :: + * Use the `driver` field. + * + * FT_OPEN_PARAMS :: + * Use the `num_params` and `params` fields. + * + * @note: + * The `FT_OPEN_MEMORY`, `FT_OPEN_STREAM`, and `FT_OPEN_PATHNAME` flags + * are mutually exclusive. + */ +#define FT_OPEN_MEMORY 0x1 +#define FT_OPEN_STREAM 0x2 +#define FT_OPEN_PATHNAME 0x4 +#define FT_OPEN_DRIVER 0x8 +#define FT_OPEN_PARAMS 0x10 + + + /* these constants are deprecated; use the corresponding `FT_OPEN_XXX` */ + /* values instead */ +#define ft_open_memory FT_OPEN_MEMORY +#define ft_open_stream FT_OPEN_STREAM +#define ft_open_pathname FT_OPEN_PATHNAME +#define ft_open_driver FT_OPEN_DRIVER +#define ft_open_params FT_OPEN_PARAMS + + + /************************************************************************** + * + * @struct: + * FT_Parameter + * + * @description: + * A simple structure to pass more or less generic parameters to + * @FT_Open_Face and @FT_Face_Properties. + * + * @fields: + * tag :: + * A four-byte identification tag. + * + * data :: + * A pointer to the parameter data. + * + * @note: + * The ID and function of parameters are driver-specific. See section + * @parameter_tags for more information. + */ + typedef struct FT_Parameter_ + { + FT_ULong tag; + FT_Pointer data; + + } FT_Parameter; + + + /************************************************************************** + * + * @struct: + * FT_Open_Args + * + * @description: + * A structure to indicate how to open a new font file or stream. A + * pointer to such a structure can be used as a parameter for the + * functions @FT_Open_Face and @FT_Attach_Stream. + * + * @fields: + * flags :: + * A set of bit flags indicating how to use the structure. + * + * memory_base :: + * The first byte of the file in memory. + * + * memory_size :: + * The size in bytes of the file in memory. + * + * pathname :: + * A pointer to an 8-bit file pathname, which must be a C~string (i.e., + * no null bytes except at the very end). The pointer is not owned by + * FreeType. + * + * stream :: + * A handle to a source stream object. + * + * driver :: + * This field is exclusively used by @FT_Open_Face; it simply specifies + * the font driver to use for opening the face. If set to `NULL`, + * FreeType tries to load the face with each one of the drivers in its + * list. + * + * num_params :: + * The number of extra parameters. + * + * params :: + * Extra parameters passed to the font driver when opening a new face. + * + * @note: + * The stream type is determined by the contents of `flags`: + * + * If the @FT_OPEN_MEMORY bit is set, assume that this is a memory file + * of `memory_size` bytes, located at `memory_address`. The data are not + * copied, and the client is responsible for releasing and destroying + * them _after_ the corresponding call to @FT_Done_Face. + * + * Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a custom + * input stream `stream` is used. + * + * Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this is a + * normal file and use `pathname` to open it. + * + * If none of the above bits are set or if multiple are set at the same + * time, the flags are invalid and @FT_Open_Face fails. + * + * If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to open + * the file with the driver whose handler is in `driver`. + * + * If the @FT_OPEN_PARAMS bit is set, the parameters given by + * `num_params` and `params` is used. They are ignored otherwise. + * + * Ideally, both the `pathname` and `params` fields should be tagged as + * 'const'; this is missing for API backward compatibility. In other + * words, applications should treat them as read-only. + */ + typedef struct FT_Open_Args_ + { + FT_UInt flags; + const FT_Byte* memory_base; + FT_Long memory_size; + FT_String* pathname; + FT_Stream stream; + FT_Module driver; + FT_Int num_params; + FT_Parameter* params; + + } FT_Open_Args; + + + /************************************************************************** + * + * @function: + * FT_New_Face + * + * @description: + * Call @FT_Open_Face to open a font by its pathname. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * pathname :: + * A path to the font file. + * + * face_index :: + * See @FT_Open_Face for a detailed description of this parameter. + * + * @output: + * aface :: + * A handle to a new face object. If `face_index` is greater than or + * equal to zero, it must be non-`NULL`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The `pathname` string should be recognizable as such by a standard + * `fopen` call on your system; in particular, this means that `pathname` + * must not contain null bytes. If that is not sufficient to address all + * file name possibilities (for example, to handle wide character file + * names on Windows in UTF-16 encoding) you might use @FT_Open_Face to + * pass a memory array or a stream object instead. + * + * Use @FT_Done_Face to destroy the created @FT_Face object (along with + * its slot and sizes). + */ + FT_EXPORT( FT_Error ) + FT_New_Face( FT_Library library, + const char* filepathname, + FT_Long face_index, + FT_Face *aface ); + + + /************************************************************************** + * + * @function: + * FT_New_Memory_Face + * + * @description: + * Call @FT_Open_Face to open a font that has been loaded into memory. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * file_base :: + * A pointer to the beginning of the font data. + * + * file_size :: + * The size of the memory chunk used by the font data. + * + * face_index :: + * See @FT_Open_Face for a detailed description of this parameter. + * + * @output: + * aface :: + * A handle to a new face object. If `face_index` is greater than or + * equal to zero, it must be non-`NULL`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You must not deallocate the memory before calling @FT_Done_Face. + */ + FT_EXPORT( FT_Error ) + FT_New_Memory_Face( FT_Library library, + const FT_Byte* file_base, + FT_Long file_size, + FT_Long face_index, + FT_Face *aface ); + + + /************************************************************************** + * + * @function: + * FT_Open_Face + * + * @description: + * Create a face object from a given resource described by @FT_Open_Args. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * args :: + * A pointer to an `FT_Open_Args` structure that must be filled by the + * caller. + * + * face_index :: + * This field holds two different values. Bits 0-15 are the index of + * the face in the font file (starting with value~0). Set it to~0 if + * there is only one face in the font file. + * + * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation + * fonts only, specifying the named instance index for the current face + * index (starting with value~1; value~0 makes FreeType ignore named + * instances). For non-variation fonts, bits 16-30 are ignored. + * Assuming that you want to access the third named instance in face~4, + * `face_index` should be set to 0x00030004. If you want to access + * face~4 without variation handling, simply set `face_index` to + * value~4. + * + * `FT_Open_Face` and its siblings can be used to quickly check whether + * the font format of a given font resource is supported by FreeType. + * In general, if the `face_index` argument is negative, the function's + * return value is~0 if the font format is recognized, or non-zero + * otherwise. The function allocates a more or less empty face handle + * in `*aface` (if `aface` isn't `NULL`); the only two useful fields in + * this special case are `face->num_faces` and `face->style_flags`. + * For any negative value of `face_index`, `face->num_faces` gives the + * number of faces within the font file. For the negative value + * '-(N+1)' (with 'N' a non-negative 16-bit value), bits 16-30 in + * `face->style_flags` give the number of named instances in face 'N' + * if we have a variation font (or zero otherwise). After examination, + * the returned @FT_Face structure should be deallocated with a call to + * @FT_Done_Face. + * + * @output: + * aface :: + * A handle to a new face object. If `face_index` is greater than or + * equal to zero, it must be non-`NULL`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Unlike FreeType 1.x, this function automatically creates a glyph slot + * for the face object that can be accessed directly through + * `face->glyph`. + * + * Each new face object created with this function also owns a default + * @FT_Size object, accessible as `face->size`. + * + * One @FT_Library instance can have multiple face objects, that is, + * @FT_Open_Face and its siblings can be called multiple times using the + * same `library` argument. + * + * See the discussion of reference counters in the description of + * @FT_Reference_Face. + * + * If `FT_OPEN_STREAM` is set in `args->flags`, the stream in + * `args->stream` is automatically closed before this function returns + * any error (including `FT_Err_Invalid_Argument`). + * + * @example: + * To loop over all faces, use code similar to the following snippet + * (omitting the error handling). + * + * ``` + * ... + * FT_Face face; + * FT_Long i, num_faces; + * + * + * error = FT_Open_Face( library, args, -1, &face ); + * if ( error ) { ... } + * + * num_faces = face->num_faces; + * FT_Done_Face( face ); + * + * for ( i = 0; i < num_faces; i++ ) + * { + * ... + * error = FT_Open_Face( library, args, i, &face ); + * ... + * FT_Done_Face( face ); + * ... + * } + * ``` + * + * To loop over all valid values for `face_index`, use something similar + * to the following snippet, again without error handling. The code + * accesses all faces immediately (thus only a single call of + * `FT_Open_Face` within the do-loop), with and without named instances. + * + * ``` + * ... + * FT_Face face; + * + * FT_Long num_faces = 0; + * FT_Long num_instances = 0; + * + * FT_Long face_idx = 0; + * FT_Long instance_idx = 0; + * + * + * do + * { + * FT_Long id = ( instance_idx << 16 ) + face_idx; + * + * + * error = FT_Open_Face( library, args, id, &face ); + * if ( error ) { ... } + * + * num_faces = face->num_faces; + * num_instances = face->style_flags >> 16; + * + * ... + * + * FT_Done_Face( face ); + * + * if ( instance_idx < num_instances ) + * instance_idx++; + * else + * { + * face_idx++; + * instance_idx = 0; + * } + * + * } while ( face_idx < num_faces ) + * ``` + */ + FT_EXPORT( FT_Error ) + FT_Open_Face( FT_Library library, + const FT_Open_Args* args, + FT_Long face_index, + FT_Face *aface ); + + + /************************************************************************** + * + * @function: + * FT_Attach_File + * + * @description: + * Call @FT_Attach_Stream to attach a file. + * + * @inout: + * face :: + * The target face object. + * + * @input: + * filepathname :: + * The pathname. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Attach_File( FT_Face face, + const char* filepathname ); + + + /************************************************************************** + * + * @function: + * FT_Attach_Stream + * + * @description: + * 'Attach' data to a face object. Normally, this is used to read + * additional information for the face object. For example, you can + * attach an AFM file that comes with a Type~1 font to get the kerning + * values and other metrics. + * + * @inout: + * face :: + * The target face object. + * + * @input: + * parameters :: + * A pointer to @FT_Open_Args that must be filled by the caller. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The meaning of the 'attach' (i.e., what really happens when the new + * file is read) is not fixed by FreeType itself. It really depends on + * the font format (and thus the font driver). + * + * Client applications are expected to know what they are doing when + * invoking this function. Most drivers simply do not implement file or + * stream attachments. + */ + FT_EXPORT( FT_Error ) + FT_Attach_Stream( FT_Face face, + const FT_Open_Args* parameters ); + + + /************************************************************************** + * + * @function: + * FT_Reference_Face + * + * @description: + * A counter gets initialized to~1 at the time an @FT_Face structure is + * created. This function increments the counter. @FT_Done_Face then + * only destroys a face if the counter is~1, otherwise it simply + * decrements the counter. + * + * This function helps in managing life-cycles of structures that + * reference @FT_Face objects. + * + * @input: + * face :: + * A handle to a target face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.4.2 + * + */ + FT_EXPORT( FT_Error ) + FT_Reference_Face( FT_Face face ); + + + /************************************************************************** + * + * @function: + * FT_Done_Face + * + * @description: + * Discard a given face object, as well as all of its child slots and + * sizes. + * + * @input: + * face :: + * A handle to a target face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * See the discussion of reference counters in the description of + * @FT_Reference_Face. + */ + FT_EXPORT( FT_Error ) + FT_Done_Face( FT_Face face ); + + + /************************************************************************** + * + * @section: + * sizing_and_scaling + * + */ + + /************************************************************************** + * + * @function: + * FT_Select_Size + * + * @description: + * Select a bitmap strike. To be more precise, this function sets the + * scaling factors of the active @FT_Size object in a face so that + * bitmaps from this particular strike are taken by @FT_Load_Glyph and + * friends. + * + * @inout: + * face :: + * A handle to a target face object. + * + * @input: + * strike_index :: + * The index of the bitmap strike in the `available_sizes` field of + * @FT_FaceRec structure. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * For bitmaps embedded in outline fonts it is common that only a subset + * of the available glyphs at a given ppem value is available. FreeType + * silently uses outlines if there is no bitmap for a given glyph index. + * + * For GX and OpenType variation fonts, a bitmap strike makes sense only + * if the default instance is active (that is, no glyph variation takes + * place); otherwise, FreeType simply ignores bitmap strikes. The same + * is true for all named instances that are different from the default + * instance. + * + * Don't use this function if you are using the FreeType cache API. + */ + FT_EXPORT( FT_Error ) + FT_Select_Size( FT_Face face, + FT_Int strike_index ); + + + /************************************************************************** + * + * @enum: + * FT_Size_Request_Type + * + * @description: + * An enumeration type that lists the supported size request types, i.e., + * what input size (in font units) maps to the requested output size (in + * pixels, as computed from the arguments of @FT_Size_Request). + * + * @values: + * FT_SIZE_REQUEST_TYPE_NOMINAL :: + * The nominal size. The `units_per_EM` field of @FT_FaceRec is used + * to determine both scaling values. + * + * This is the standard scaling found in most applications. In + * particular, use this size request type for TrueType fonts if they + * provide optical scaling or something similar. Note, however, that + * `units_per_EM` is a rather abstract value which bears no relation to + * the actual size of the glyphs in a font. + * + * FT_SIZE_REQUEST_TYPE_REAL_DIM :: + * The real dimension. The sum of the `ascender` and (minus of) the + * `descender` fields of @FT_FaceRec is used to determine both scaling + * values. + * + * FT_SIZE_REQUEST_TYPE_BBOX :: + * The font bounding box. The width and height of the `bbox` field of + * @FT_FaceRec are used to determine the horizontal and vertical + * scaling value, respectively. + * + * FT_SIZE_REQUEST_TYPE_CELL :: + * The `max_advance_width` field of @FT_FaceRec is used to determine + * the horizontal scaling value; the vertical scaling value is + * determined the same way as @FT_SIZE_REQUEST_TYPE_REAL_DIM does. + * Finally, both scaling values are set to the smaller one. This type + * is useful if you want to specify the font size for, say, a window of + * a given dimension and 80x24 cells. + * + * FT_SIZE_REQUEST_TYPE_SCALES :: + * Specify the scaling values directly. + * + * @note: + * The above descriptions only apply to scalable formats. For bitmap + * formats, the behaviour is up to the driver. + * + * See the note section of @FT_Size_Metrics if you wonder how size + * requesting relates to scaling values. + */ + typedef enum FT_Size_Request_Type_ + { + FT_SIZE_REQUEST_TYPE_NOMINAL, + FT_SIZE_REQUEST_TYPE_REAL_DIM, + FT_SIZE_REQUEST_TYPE_BBOX, + FT_SIZE_REQUEST_TYPE_CELL, + FT_SIZE_REQUEST_TYPE_SCALES, + + FT_SIZE_REQUEST_TYPE_MAX + + } FT_Size_Request_Type; + + + /************************************************************************** + * + * @struct: + * FT_Size_RequestRec + * + * @description: + * A structure to model a size request. + * + * @fields: + * type :: + * See @FT_Size_Request_Type. + * + * width :: + * The desired width, given as a 26.6 fractional point value (with 72pt + * = 1in). + * + * height :: + * The desired height, given as a 26.6 fractional point value (with + * 72pt = 1in). + * + * horiResolution :: + * The horizontal resolution (dpi, i.e., pixels per inch). If set to + * zero, `width` is treated as a 26.6 fractional **pixel** value, which + * gets internally rounded to an integer. + * + * vertResolution :: + * The vertical resolution (dpi, i.e., pixels per inch). If set to + * zero, `height` is treated as a 26.6 fractional **pixel** value, + * which gets internally rounded to an integer. + * + * @note: + * If `width` is zero, the horizontal scaling value is set equal to the + * vertical scaling value, and vice versa. + * + * If `type` is `FT_SIZE_REQUEST_TYPE_SCALES`, `width` and `height` are + * interpreted directly as 16.16 fractional scaling values, without any + * further modification, and both `horiResolution` and `vertResolution` + * are ignored. + */ + typedef struct FT_Size_RequestRec_ + { + FT_Size_Request_Type type; + FT_Long width; + FT_Long height; + FT_UInt horiResolution; + FT_UInt vertResolution; + + } FT_Size_RequestRec; + + + /************************************************************************** + * + * @struct: + * FT_Size_Request + * + * @description: + * A handle to a size request structure. + */ + typedef struct FT_Size_RequestRec_ *FT_Size_Request; + + + /************************************************************************** + * + * @function: + * FT_Request_Size + * + * @description: + * Resize the scale of the active @FT_Size object in a face. + * + * @inout: + * face :: + * A handle to a target face object. + * + * @input: + * req :: + * A pointer to a @FT_Size_RequestRec. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Although drivers may select the bitmap strike matching the request, + * you should not rely on this if you intend to select a particular + * bitmap strike. Use @FT_Select_Size instead in that case. + * + * The relation between the requested size and the resulting glyph size + * is dependent entirely on how the size is defined in the source face. + * The font designer chooses the final size of each glyph relative to + * this size. For more information refer to + * 'https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. + * + * Contrary to @FT_Set_Char_Size, this function doesn't have special code + * to normalize zero-valued widths, heights, or resolutions, which are + * treated as @FT_LOAD_NO_SCALE. + * + * Don't use this function if you are using the FreeType cache API. + */ + FT_EXPORT( FT_Error ) + FT_Request_Size( FT_Face face, + FT_Size_Request req ); + + + /************************************************************************** + * + * @function: + * FT_Set_Char_Size + * + * @description: + * Call @FT_Request_Size to request the nominal size (in points). + * + * @inout: + * face :: + * A handle to a target face object. + * + * @input: + * char_width :: + * The nominal width, in 26.6 fractional points. + * + * char_height :: + * The nominal height, in 26.6 fractional points. + * + * horz_resolution :: + * The horizontal resolution in dpi. + * + * vert_resolution :: + * The vertical resolution in dpi. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * While this function allows fractional points as input values, the + * resulting ppem value for the given resolution is always rounded to the + * nearest integer. + * + * If either the character width or height is zero, it is set equal to + * the other value. + * + * If either the horizontal or vertical resolution is zero, it is set + * equal to the other value. + * + * A character width or height smaller than 1pt is set to 1pt; if both + * resolution values are zero, they are set to 72dpi. + * + * Don't use this function if you are using the FreeType cache API. + */ + FT_EXPORT( FT_Error ) + FT_Set_Char_Size( FT_Face face, + FT_F26Dot6 char_width, + FT_F26Dot6 char_height, + FT_UInt horz_resolution, + FT_UInt vert_resolution ); + + + /************************************************************************** + * + * @function: + * FT_Set_Pixel_Sizes + * + * @description: + * Call @FT_Request_Size to request the nominal size (in pixels). + * + * @inout: + * face :: + * A handle to the target face object. + * + * @input: + * pixel_width :: + * The nominal width, in pixels. + * + * pixel_height :: + * The nominal height, in pixels. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should not rely on the resulting glyphs matching or being + * constrained to this pixel size. Refer to @FT_Request_Size to + * understand how requested sizes relate to actual sizes. + * + * Don't use this function if you are using the FreeType cache API. + */ + FT_EXPORT( FT_Error ) + FT_Set_Pixel_Sizes( FT_Face face, + FT_UInt pixel_width, + FT_UInt pixel_height ); + + + /************************************************************************** + * + * @section: + * glyph_retrieval + * + */ + + /************************************************************************** + * + * @function: + * FT_Load_Glyph + * + * @description: + * Load a glyph into the glyph slot of a face object. + * + * @inout: + * face :: + * A handle to the target face object where the glyph is loaded. + * + * @input: + * glyph_index :: + * The index of the glyph in the font file. For CID-keyed fonts + * (either in PS or in CFF format) this argument specifies the CID + * value. + * + * load_flags :: + * A flag indicating what to load for this glyph. The @FT_LOAD_XXX + * flags can be used to control the glyph loading process (e.g., + * whether the outline should be scaled, whether to load bitmaps or + * not, whether to hint the outline, etc). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * For proper scaling and hinting, the active @FT_Size object owned by + * the face has to be meaningfully initialized by calling + * @FT_Set_Char_Size before this function, for example. The loaded + * glyph may be transformed. See @FT_Set_Transform for the details. + * + * For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument` is returned + * for invalid CID values (that is, for CID values that don't have a + * corresponding glyph in the font). See the discussion of the + * @FT_FACE_FLAG_CID_KEYED flag for more details. + * + * If you receive `FT_Err_Glyph_Too_Big`, try getting the glyph outline + * at EM size, then scale it manually and fill it as a graphics + * operation. + */ + FT_EXPORT( FT_Error ) + FT_Load_Glyph( FT_Face face, + FT_UInt glyph_index, + FT_Int32 load_flags ); + + + /************************************************************************** + * + * @section: + * character_mapping + * + */ + + /************************************************************************** + * + * @function: + * FT_Load_Char + * + * @description: + * Load a glyph into the glyph slot of a face object, accessed by its + * character code. + * + * @inout: + * face :: + * A handle to a target face object where the glyph is loaded. + * + * @input: + * char_code :: + * The glyph's character code, according to the current charmap used in + * the face. + * + * load_flags :: + * A flag indicating what to load for this glyph. The @FT_LOAD_XXX + * constants can be used to control the glyph loading process (e.g., + * whether the outline should be scaled, whether to load bitmaps or + * not, whether to hint the outline, etc). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. + * + * Many fonts contain glyphs that can't be loaded by this function since + * its glyph indices are not listed in any of the font's charmaps. + * + * If no active cmap is set up (i.e., `face->charmap` is zero), the call + * to @FT_Get_Char_Index is omitted, and the function behaves identically + * to @FT_Load_Glyph. + */ + FT_EXPORT( FT_Error ) + FT_Load_Char( FT_Face face, + FT_ULong char_code, + FT_Int32 load_flags ); + + + /************************************************************************** + * + * @section: + * glyph_retrieval + * + */ + + /************************************************************************** + * + * @enum: + * FT_LOAD_XXX + * + * @description: + * A list of bit field constants for @FT_Load_Glyph to indicate what kind + * of operations to perform during glyph loading. + * + * @values: + * FT_LOAD_DEFAULT :: + * Corresponding to~0, this value is used as the default glyph load + * operation. In this case, the following happens: + * + * 1. FreeType looks for a bitmap for the glyph corresponding to the + * face's current size. If one is found, the function returns. The + * bitmap data can be accessed from the glyph slot (see note below). + * + * 2. If no embedded bitmap is searched for or found, FreeType looks + * for a scalable outline. If one is found, it is loaded from the font + * file, scaled to device pixels, then 'hinted' to the pixel grid in + * order to optimize it. The outline data can be accessed from the + * glyph slot (see note below). + * + * Note that by default the glyph loader doesn't render outlines into + * bitmaps. The following flags are used to modify this default + * behaviour to more specific and useful cases. + * + * FT_LOAD_NO_SCALE :: + * Don't scale the loaded outline glyph but keep it in font units. + * This flag is also assumed if @FT_Size owned by the face was not + * properly initialized. + * + * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and + * unsets @FT_LOAD_RENDER. + * + * If the font is 'tricky' (see @FT_FACE_FLAG_TRICKY for more), using + * `FT_LOAD_NO_SCALE` usually yields meaningless outlines because the + * subglyphs must be scaled and positioned with hinting instructions. + * This can be solved by loading the font without `FT_LOAD_NO_SCALE` + * and setting the character size to `font->units_per_EM`. + * + * FT_LOAD_NO_HINTING :: + * Disable hinting. This generally generates 'blurrier' bitmap glyphs + * when the glyphs are rendered in any of the anti-aliased modes. See + * also the note below. + * + * This flag is implied by @FT_LOAD_NO_SCALE. + * + * FT_LOAD_RENDER :: + * Call @FT_Render_Glyph after the glyph is loaded. By default, the + * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be + * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME. + * + * This flag is unset by @FT_LOAD_NO_SCALE. + * + * FT_LOAD_NO_BITMAP :: + * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this + * flag. + * + * @FT_LOAD_NO_SCALE always sets this flag. + * + * FT_LOAD_SBITS_ONLY :: + * [Since 2.12] This is the opposite of @FT_LOAD_NO_BITMAP, more or + * less: @FT_Load_Glyph returns `FT_Err_Invalid_Argument` if the face + * contains a bitmap strike for the given size (or the strike selected + * by @FT_Select_Size) but there is no glyph in the strike. + * + * Note that this load flag was part of FreeType since version 2.0.6 + * but previously tagged as internal. + * + * FT_LOAD_VERTICAL_LAYOUT :: + * Load the glyph for vertical text layout. In particular, the + * `advance` value in the @FT_GlyphSlotRec structure is set to the + * `vertAdvance` value of the `metrics` field. + * + * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use this + * flag currently. Reason is that in this case vertical metrics get + * synthesized, and those values are not always consistent across + * various font formats. + * + * FT_LOAD_FORCE_AUTOHINT :: + * Prefer the auto-hinter over the font's native hinter. See also the + * note below. + * + * FT_LOAD_PEDANTIC :: + * Make the font driver perform pedantic verifications during glyph + * loading and hinting. This is mostly used to detect broken glyphs in + * fonts. By default, FreeType tries to handle broken fonts also. + * + * In particular, errors from the TrueType bytecode engine are not + * passed to the application if this flag is not set; this might result + * in partially hinted or distorted glyphs in case a glyph's bytecode + * is buggy. + * + * FT_LOAD_NO_RECURSE :: + * Don't load composite glyphs recursively. Instead, the font driver + * fills the `num_subglyph` and `subglyphs` values of the glyph slot; + * it also sets `glyph->format` to @FT_GLYPH_FORMAT_COMPOSITE. The + * description of subglyphs can then be accessed with + * @FT_Get_SubGlyph_Info. + * + * Don't use this flag for retrieving metrics information since some + * font drivers only return rudimentary data. + * + * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM. + * + * FT_LOAD_IGNORE_TRANSFORM :: + * Ignore the transform matrix set by @FT_Set_Transform. + * + * FT_LOAD_MONOCHROME :: + * This flag is used with @FT_LOAD_RENDER to indicate that you want to + * render an outline glyph to a 1-bit monochrome bitmap glyph, with + * 8~pixels packed into each byte of the bitmap data. + * + * Note that this has no effect on the hinting algorithm used. You + * should rather use @FT_LOAD_TARGET_MONO so that the + * monochrome-optimized hinting algorithm is used. + * + * FT_LOAD_LINEAR_DESIGN :: + * Keep `linearHoriAdvance` and `linearVertAdvance` fields of + * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for details. + * + * FT_LOAD_NO_AUTOHINT :: + * Disable the auto-hinter. See also the note below. + * + * FT_LOAD_COLOR :: + * Load colored glyphs. FreeType searches in the following order; + * there are slight differences depending on the font format. + * + * [Since 2.5] Load embedded color bitmap images (provided + * @FT_LOAD_NO_BITMAP is not set). The resulting color bitmaps, if + * available, have the @FT_PIXEL_MODE_BGRA format, with pre-multiplied + * color channels. If the flag is not set and color bitmaps are found, + * they are converted to 256-level gray bitmaps, using the + * @FT_PIXEL_MODE_GRAY format. + * + * [Since 2.12] If the glyph index maps to an entry in the face's + * 'SVG~' table, load the associated SVG document from this table and + * set the `format` field of @FT_GlyphSlotRec to @FT_GLYPH_FORMAT_SVG + * ([since 2.13.1] provided @FT_LOAD_NO_SVG is not set). Note that + * FreeType itself can't render SVG documents; however, the library + * provides hooks to seamlessly integrate an external renderer. See + * sections @ot_svg_driver and @svg_fonts for more. + * + * [Since 2.10, experimental] If the glyph index maps to an entry in + * the face's 'COLR' table with a 'CPAL' palette table (as defined in + * the OpenType specification), make @FT_Render_Glyph provide a default + * blending of the color glyph layers associated with the glyph index, + * using the same bitmap format as embedded color bitmap images. This + * is mainly for convenience and works only for glyphs in 'COLR' v0 + * tables (or glyphs in 'COLR' v1 tables that exclusively use v0 + * features). For full control of color layers use + * @FT_Get_Color_Glyph_Layer and FreeType's color functions like + * @FT_Palette_Select instead of setting @FT_LOAD_COLOR for rendering + * so that the client application can handle blending by itself. + * + * FT_LOAD_NO_SVG :: + * [Since 2.13.1] Ignore SVG glyph data when loading. + * + * FT_LOAD_COMPUTE_METRICS :: + * [Since 2.6.1] Compute glyph metrics from the glyph data, without the + * use of bundled metrics tables (for example, the 'hdmx' table in + * TrueType fonts). This flag is mainly used by font validating or + * font editing applications, which need to ignore, verify, or edit + * those tables. + * + * Currently, this flag is only implemented for TrueType fonts. + * + * FT_LOAD_BITMAP_METRICS_ONLY :: + * [Since 2.7.1] Request loading of the metrics and bitmap image + * information of a (possibly embedded) bitmap glyph without allocating + * or copying the bitmap image data itself. No effect if the target + * glyph is not a bitmap image. + * + * This flag unsets @FT_LOAD_RENDER. + * + * FT_LOAD_CROP_BITMAP :: + * Ignored. Deprecated. + * + * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH :: + * Ignored. Deprecated. + * + * @note: + * By default, hinting is enabled and the font's native hinter (see + * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can + * disable hinting by setting @FT_LOAD_NO_HINTING or change the + * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set + * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be used + * at all. + * + * See the description of @FT_FACE_FLAG_TRICKY for a special exception + * (affecting only a handful of Asian fonts). + * + * Besides deciding which hinter to use, you can also decide which + * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details. + * + * Note that the auto-hinter needs a valid Unicode cmap (either a native + * one or synthesized by FreeType) for producing correct results. If a + * font provides an incorrect mapping (for example, assigning the + * character code U+005A, LATIN CAPITAL LETTER~Z, to a glyph depicting a + * mathematical integral sign), the auto-hinter might produce useless + * results. + * + */ +#define FT_LOAD_DEFAULT 0x0 +#define FT_LOAD_NO_SCALE ( 1L << 0 ) +#define FT_LOAD_NO_HINTING ( 1L << 1 ) +#define FT_LOAD_RENDER ( 1L << 2 ) +#define FT_LOAD_NO_BITMAP ( 1L << 3 ) +#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 ) +#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 ) +#define FT_LOAD_CROP_BITMAP ( 1L << 6 ) +#define FT_LOAD_PEDANTIC ( 1L << 7 ) +#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 ) +#define FT_LOAD_NO_RECURSE ( 1L << 10 ) +#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 ) +#define FT_LOAD_MONOCHROME ( 1L << 12 ) +#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 ) +#define FT_LOAD_SBITS_ONLY ( 1L << 14 ) +#define FT_LOAD_NO_AUTOHINT ( 1L << 15 ) + /* Bits 16-19 are used by `FT_LOAD_TARGET_` */ +#define FT_LOAD_COLOR ( 1L << 20 ) +#define FT_LOAD_COMPUTE_METRICS ( 1L << 21 ) +#define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 ) +#define FT_LOAD_NO_SVG ( 1L << 24 ) + + /* */ + + /* used internally only by certain font drivers */ +#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 ) +#define FT_LOAD_SVG_ONLY ( 1L << 23 ) + + + /************************************************************************** + * + * @enum: + * FT_LOAD_TARGET_XXX + * + * @description: + * A list of values to select a specific hinting algorithm for the + * hinter. You should OR one of these values to your `load_flags` when + * calling @FT_Load_Glyph. + * + * Note that a font's native hinters may ignore the hinting algorithm you + * have specified (e.g., the TrueType bytecode interpreter). You can set + * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used. + * + * @values: + * FT_LOAD_TARGET_NORMAL :: + * The default hinting algorithm, optimized for standard gray-level + * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO instead. + * + * FT_LOAD_TARGET_LIGHT :: + * A lighter hinting algorithm for gray-level modes. Many generated + * glyphs are fuzzier but better resemble their original shape. This + * is achieved by snapping glyphs to the pixel grid only vertically + * (Y-axis), as is done by FreeType's new CFF engine or Microsoft's + * ClearType font renderer. This preserves inter-glyph spacing in + * horizontal text. The snapping is done either by the native font + * driver, if the driver itself and the font support it, or by the + * auto-hinter. + * + * Advance widths are rounded to integer values; however, using the + * `lsb_delta` and `rsb_delta` fields of @FT_GlyphSlotRec, it is + * possible to get fractional advance widths for subpixel positioning + * (which is recommended to use). + * + * If configuration option `AF_CONFIG_OPTION_TT_SIZE_METRICS` is + * active, TrueType-like metrics are used to make this mode behave + * similarly as in unpatched FreeType versions between 2.4.6 and 2.7.1 + * (inclusive). + * + * FT_LOAD_TARGET_MONO :: + * Strong hinting algorithm that should only be used for monochrome + * output. The result is probably unpleasant if the glyph is rendered + * in non-monochrome modes. + * + * Note that for outline fonts only the TrueType font driver has proper + * monochrome hinting support, provided the TTFs contain hints for B/W + * rendering (which most fonts no longer provide). If these conditions + * are not met it is very likely that you get ugly results at smaller + * sizes. + * + * FT_LOAD_TARGET_LCD :: + * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally + * decimated LCD displays. + * + * FT_LOAD_TARGET_LCD_V :: + * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically + * decimated LCD displays. + * + * @note: + * You should use only _one_ of the `FT_LOAD_TARGET_XXX` values in your + * `load_flags`. They can't be ORed. + * + * If @FT_LOAD_RENDER is also set, the glyph is rendered in the + * corresponding mode (i.e., the mode that matches the used algorithm + * best). An exception is `FT_LOAD_TARGET_MONO` since it implies + * @FT_LOAD_MONOCHROME. + * + * You can use a hinting algorithm that doesn't correspond to the same + * rendering mode. As an example, it is possible to use the 'light' + * hinting algorithm and have the results rendered in horizontal LCD + * pixel mode, with code like + * + * ``` + * FT_Load_Glyph( face, glyph_index, + * load_flags | FT_LOAD_TARGET_LIGHT ); + * + * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); + * ``` + * + * In general, you should stick with one rendering mode. For example, + * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO + * enforces a lot of recomputation for TrueType fonts, which is slow. + * Another reason is caching: Selecting a different mode usually causes + * changes in both the outlines and the rasterized bitmaps; it is thus + * necessary to empty the cache after a mode switch to avoid false hits. + * + */ +#define FT_LOAD_TARGET_( x ) ( FT_STATIC_CAST( FT_Int32, (x) & 15 ) << 16 ) + +#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) +#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) +#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO ) +#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD ) +#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V ) + + + /************************************************************************** + * + * @macro: + * FT_LOAD_TARGET_MODE + * + * @description: + * Return the @FT_Render_Mode corresponding to a given + * @FT_LOAD_TARGET_XXX value. + * + */ +#define FT_LOAD_TARGET_MODE( x ) \ + FT_STATIC_CAST( FT_Render_Mode, ( (x) >> 16 ) & 15 ) + + + /************************************************************************** + * + * @section: + * sizing_and_scaling + * + */ + + /************************************************************************** + * + * @function: + * FT_Set_Transform + * + * @description: + * Set the transformation that is applied to glyph images when they are + * loaded into a glyph slot through @FT_Load_Glyph. + * + * @inout: + * face :: + * A handle to the source face object. + * + * @input: + * matrix :: + * A pointer to the transformation's 2x2 matrix. Use `NULL` for the + * identity matrix. + * delta :: + * A pointer to the translation vector. Use `NULL` for the null + * vector. + * + * @note: + * This function is provided as a convenience, but keep in mind that + * @FT_Matrix coefficients are only 16.16 fixed-point values, which can + * limit the accuracy of the results. Using floating-point computations + * to perform the transform directly in client code instead will always + * yield better numbers. + * + * The transformation is only applied to scalable image formats after the + * glyph has been loaded. It means that hinting is unaltered by the + * transformation and is performed on the character size given in the + * last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. + * + * Note that this also transforms the `face.glyph.advance` field, but + * **not** the values in `face.glyph.metrics`. + */ + FT_EXPORT( void ) + FT_Set_Transform( FT_Face face, + FT_Matrix* matrix, + FT_Vector* delta ); + + + /************************************************************************** + * + * @function: + * FT_Get_Transform + * + * @description: + * Return the transformation that is applied to glyph images when they + * are loaded into a glyph slot through @FT_Load_Glyph. See + * @FT_Set_Transform for more details. + * + * @input: + * face :: + * A handle to the source face object. + * + * @output: + * matrix :: + * A pointer to a transformation's 2x2 matrix. Set this to NULL if you + * are not interested in the value. + * + * delta :: + * A pointer to a translation vector. Set this to NULL if you are not + * interested in the value. + * + * @since: + * 2.11 + * + */ + FT_EXPORT( void ) + FT_Get_Transform( FT_Face face, + FT_Matrix* matrix, + FT_Vector* delta ); + + + /************************************************************************** + * + * @section: + * glyph_retrieval + * + */ + + /************************************************************************** + * + * @enum: + * FT_Render_Mode + * + * @description: + * Render modes supported by FreeType~2. Each mode corresponds to a + * specific type of scanline conversion performed on the outline. + * + * For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode` field + * in the @FT_GlyphSlotRec structure gives the format of the returned + * bitmap. + * + * All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, + * indicating pixel coverage. Use linear alpha blending and gamma + * correction to correctly render non-monochrome glyph bitmaps onto a + * surface; see @FT_Render_Glyph. + * + * The @FT_RENDER_MODE_SDF is a special render mode that uses up to 256 + * distance values, indicating the signed distance from the grid position + * to the nearest outline. + * + * @values: + * FT_RENDER_MODE_NORMAL :: + * Default render mode; it corresponds to 8-bit anti-aliased bitmaps. + * + * FT_RENDER_MODE_LIGHT :: + * This is equivalent to @FT_RENDER_MODE_NORMAL. It is only defined as + * a separate value because render modes are also used indirectly to + * define hinting algorithm selectors. See @FT_LOAD_TARGET_XXX for + * details. + * + * FT_RENDER_MODE_MONO :: + * This mode corresponds to 1-bit bitmaps (with 2~levels of opacity). + * + * FT_RENDER_MODE_LCD :: + * This mode corresponds to horizontal RGB and BGR subpixel displays + * like LCD screens. It produces 8-bit bitmaps that are 3~times the + * width of the original glyph outline in pixels, and which use the + * @FT_PIXEL_MODE_LCD mode. + * + * FT_RENDER_MODE_LCD_V :: + * This mode corresponds to vertical RGB and BGR subpixel displays + * (like PDA screens, rotated LCD displays, etc.). It produces 8-bit + * bitmaps that are 3~times the height of the original glyph outline in + * pixels and use the @FT_PIXEL_MODE_LCD_V mode. + * + * FT_RENDER_MODE_SDF :: + * The positive (unsigned) 8-bit bitmap values can be converted to the + * single-channel signed distance field (SDF) by subtracting 128, with + * the positive and negative results corresponding to the inside and + * the outside of a glyph contour, respectively. The distance units are + * arbitrarily determined by an adjustable @spread property. + * + * @note: + * The selected render mode only affects scalable vector glyphs of a font. + * Embedded bitmaps often have a different pixel mode like + * @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform them + * into 8-bit pixmaps. + * + */ + typedef enum FT_Render_Mode_ + { + FT_RENDER_MODE_NORMAL = 0, + FT_RENDER_MODE_LIGHT, + FT_RENDER_MODE_MONO, + FT_RENDER_MODE_LCD, + FT_RENDER_MODE_LCD_V, + FT_RENDER_MODE_SDF, + + FT_RENDER_MODE_MAX + + } FT_Render_Mode; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Render_Mode` values instead */ +#define ft_render_mode_normal FT_RENDER_MODE_NORMAL +#define ft_render_mode_mono FT_RENDER_MODE_MONO + + + /************************************************************************** + * + * @function: + * FT_Render_Glyph + * + * @description: + * Convert a given glyph image to a bitmap. It does so by inspecting the + * glyph image format, finding the relevant renderer, and invoking it. + * + * @inout: + * slot :: + * A handle to the glyph slot containing the image to convert. + * + * @input: + * render_mode :: + * The render mode used to render the glyph image into a bitmap. See + * @FT_Render_Mode for a list of possible values. + * + * If @FT_RENDER_MODE_NORMAL is used, a previous call of @FT_Load_Glyph + * with flag @FT_LOAD_COLOR makes `FT_Render_Glyph` provide a default + * blending of colored glyph layers associated with the current glyph + * slot (provided the font contains such layers) instead of rendering + * the glyph slot's outline. This is an experimental feature; see + * @FT_LOAD_COLOR for more information. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * When FreeType outputs a bitmap of a glyph, it really outputs an alpha + * coverage map. If a pixel is completely covered by a filled-in + * outline, the bitmap contains 0xFF at that pixel, meaning that + * 0xFF/0xFF fraction of that pixel is covered, meaning the pixel is 100% + * black (or 0% bright). If a pixel is only 50% covered (value 0x80), + * the pixel is made 50% black (50% bright or a middle shade of grey). + * 0% covered means 0% black (100% bright or white). + * + * On high-DPI screens like on smartphones and tablets, the pixels are so + * small that their chance of being completely covered and therefore + * completely black are fairly good. On the low-DPI screens, however, + * the situation is different. The pixels are too large for most of the + * details of a glyph and shades of gray are the norm rather than the + * exception. + * + * This is relevant because all our screens have a second problem: they + * are not linear. 1~+~1 is not~2. Twice the value does not result in + * twice the brightness. When a pixel is only 50% covered, the coverage + * map says 50% black, and this translates to a pixel value of 128 when + * you use 8~bits per channel (0-255). However, this does not translate + * to 50% brightness for that pixel on our sRGB and gamma~2.2 screens. + * Due to their non-linearity, they dwell longer in the darks and only a + * pixel value of about 186 results in 50% brightness -- 128 ends up too + * dark on both bright and dark backgrounds. The net result is that dark + * text looks burnt-out, pixely and blotchy on bright background, bright + * text too frail on dark backgrounds, and colored text on colored + * background (for example, red on green) seems to have dark halos or + * 'dirt' around it. The situation is especially ugly for diagonal stems + * like in 'w' glyph shapes where the quality of FreeType's anti-aliasing + * depends on the correct display of grays. On high-DPI screens where + * smaller, fully black pixels reign supreme, this doesn't matter, but on + * our low-DPI screens with all the gray shades, it does. 0% and 100% + * brightness are the same things in linear and non-linear space, just + * all the shades in-between aren't. + * + * The blending function for placing text over a background is + * + * ``` + * dst = alpha * src + (1 - alpha) * dst , + * ``` + * + * which is known as the OVER operator. + * + * To correctly composite an anti-aliased pixel of a glyph onto a + * surface, + * + * 1. take the foreground and background colors (e.g., in sRGB space) + * and apply gamma to get them in a linear space, + * + * 2. use OVER to blend the two linear colors using the glyph pixel + * as the alpha value (remember, the glyph bitmap is an alpha coverage + * bitmap), and + * + * 3. apply inverse gamma to the blended pixel and write it back to + * the image. + * + * Internal testing at Adobe found that a target inverse gamma of~1.8 for + * step~3 gives good results across a wide range of displays with an sRGB + * gamma curve or a similar one. + * + * This process can cost performance. There is an approximation that + * does not need to know about the background color; see + * https://bel.fi/alankila/lcd/ and + * https://bel.fi/alankila/lcd/alpcor.html for details. + * + * **ATTENTION**: Linear blending is even more important when dealing + * with subpixel-rendered glyphs to prevent color-fringing! A + * subpixel-rendered glyph must first be filtered with a filter that + * gives equal weight to the three color primaries and does not exceed a + * sum of 0x100, see section @lcd_rendering. Then the only difference to + * gray linear blending is that subpixel-rendered linear blending is done + * 3~times per pixel: red foreground subpixel to red background subpixel + * and so on for green and blue. + */ + FT_EXPORT( FT_Error ) + FT_Render_Glyph( FT_GlyphSlot slot, + FT_Render_Mode render_mode ); + + + /************************************************************************** + * + * @enum: + * FT_Kerning_Mode + * + * @description: + * An enumeration to specify the format of kerning values returned by + * @FT_Get_Kerning. + * + * @values: + * FT_KERNING_DEFAULT :: + * Return grid-fitted kerning distances in 26.6 fractional pixels. + * + * FT_KERNING_UNFITTED :: + * Return un-grid-fitted kerning distances in 26.6 fractional pixels. + * + * FT_KERNING_UNSCALED :: + * Return the kerning vector in original font units. + * + * @note: + * `FT_KERNING_DEFAULT` returns full pixel values; it also makes FreeType + * heuristically scale down kerning distances at small ppem values so + * that they don't become too big. + * + * Both `FT_KERNING_DEFAULT` and `FT_KERNING_UNFITTED` use the current + * horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to + * convert font units to pixels. + */ + typedef enum FT_Kerning_Mode_ + { + FT_KERNING_DEFAULT = 0, + FT_KERNING_UNFITTED, + FT_KERNING_UNSCALED + + } FT_Kerning_Mode; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Kerning_Mode` values instead */ +#define ft_kerning_default FT_KERNING_DEFAULT +#define ft_kerning_unfitted FT_KERNING_UNFITTED +#define ft_kerning_unscaled FT_KERNING_UNSCALED + + + /************************************************************************** + * + * @function: + * FT_Get_Kerning + * + * @description: + * Return the kerning vector between two glyphs of the same face. + * + * @input: + * face :: + * A handle to a source face object. + * + * left_glyph :: + * The index of the left glyph in the kern pair. + * + * right_glyph :: + * The index of the right glyph in the kern pair. + * + * kern_mode :: + * See @FT_Kerning_Mode for more information. Determines the scale and + * dimension of the returned kerning vector. + * + * @output: + * akerning :: + * The kerning vector. This is either in font units, fractional pixels + * (26.6 format), or pixels for scalable formats, and in pixels for + * fixed-sizes formats. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Only horizontal layouts (left-to-right & right-to-left) are supported + * by this method. Other layouts, or more sophisticated kernings, are + * out of the scope of this API function -- they can be implemented + * through format-specific interfaces. + * + * Note that, for TrueType fonts only, this can extract data from both + * the 'kern' table and the basic, pair-wise kerning feature from the + * GPOS table (with `TT_CONFIG_OPTION_GPOS_KERNING` enabled), though + * FreeType does not support the more advanced GPOS layout features; use + * a library like HarfBuzz for those instead. If a font has both a + * 'kern' table and kern features of a GPOS table, the 'kern' table will + * be used. + * + * Also note for right-to-left scripts, the functionality may differ for + * fonts with GPOS tables vs. 'kern' tables. For GPOS, right-to-left + * fonts typically use both a placement offset and an advance for pair + * positioning, which this API does not support, so it would output + * kerning values of zero; though if the right-to-left font used only + * advances in GPOS pair positioning, then this API could output kerning + * values for it, but it would use `left_glyph` to mean the first glyph + * for that case. Whereas 'kern' tables are always advance-only and + * always store the left glyph first. + * + * Use @FT_HAS_KERNING to find out whether a font has data that can be + * extracted with `FT_Get_Kerning`. + */ + FT_EXPORT( FT_Error ) + FT_Get_Kerning( FT_Face face, + FT_UInt left_glyph, + FT_UInt right_glyph, + FT_UInt kern_mode, + FT_Vector *akerning ); + + + /************************************************************************** + * + * @function: + * FT_Get_Track_Kerning + * + * @description: + * Return the track kerning for a given face object at a given size. + * + * @input: + * face :: + * A handle to a source face object. + * + * point_size :: + * The point size in 16.16 fractional points. + * + * degree :: + * The degree of tightness. Increasingly negative values represent + * tighter track kerning, while increasingly positive values represent + * looser track kerning. Value zero means no track kerning. + * + * @output: + * akerning :: + * The kerning in 16.16 fractional points, to be uniformly applied + * between all glyphs. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Currently, only the Type~1 font driver supports track kerning, using + * data from AFM files (if attached with @FT_Attach_File or + * @FT_Attach_Stream). + * + * Only very few AFM files come with track kerning data; please refer to + * Adobe's AFM specification for more details. + */ + FT_EXPORT( FT_Error ) + FT_Get_Track_Kerning( FT_Face face, + FT_Fixed point_size, + FT_Int degree, + FT_Fixed* akerning ); + + + /************************************************************************** + * + * @section: + * character_mapping + * + */ + + /************************************************************************** + * + * @function: + * FT_Select_Charmap + * + * @description: + * Select a given charmap by its encoding tag (as listed in + * `freetype.h`). + * + * @inout: + * face :: + * A handle to the source face object. + * + * @input: + * encoding :: + * A handle to the selected encoding. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function returns an error if no charmap in the face corresponds + * to the encoding queried here. + * + * Because many fonts contain more than a single cmap for Unicode + * encoding, this function has some special code to select the one that + * covers Unicode best ('best' in the sense that a UCS-4 cmap is + * preferred to a UCS-2 cmap). It is thus preferable to @FT_Set_Charmap + * in this case. + */ + FT_EXPORT( FT_Error ) + FT_Select_Charmap( FT_Face face, + FT_Encoding encoding ); + + + /************************************************************************** + * + * @function: + * FT_Set_Charmap + * + * @description: + * Select a given charmap for character code to glyph index mapping. + * + * @inout: + * face :: + * A handle to the source face object. + * + * @input: + * charmap :: + * A handle to the selected charmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function returns an error if the charmap is not part of the face + * (i.e., if it is not listed in the `face->charmaps` table). + * + * It also fails if an OpenType type~14 charmap is selected (which + * doesn't map character codes to glyph indices at all). + */ + FT_EXPORT( FT_Error ) + FT_Set_Charmap( FT_Face face, + FT_CharMap charmap ); + + + /************************************************************************** + * + * @function: + * FT_Get_Charmap_Index + * + * @description: + * Retrieve index of a given charmap. + * + * @input: + * charmap :: + * A handle to a charmap. + * + * @return: + * The index into the array of character maps within the face to which + * `charmap` belongs. If an error occurs, -1 is returned. + * + */ + FT_EXPORT( FT_Int ) + FT_Get_Charmap_Index( FT_CharMap charmap ); + + + /************************************************************************** + * + * @function: + * FT_Get_Char_Index + * + * @description: + * Return the glyph index of a given character code. This function uses + * the currently selected charmap to do the mapping. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character code. + * + * @return: + * The glyph index. 0~means 'undefined character code'. + * + * @note: + * If you use FreeType to manipulate the contents of font files directly, + * be aware that the glyph index returned by this function doesn't always + * correspond to the internal indices used within the file. This is done + * to ensure that value~0 always corresponds to the 'missing glyph'. If + * the first glyph is not named '.notdef', then for Type~1 and Type~42 + * fonts, '.notdef' will be moved into the glyph ID~0 position, and + * whatever was there will be moved to the position '.notdef' had. For + * Type~1 fonts, if there is no '.notdef' glyph at all, then one will be + * created at index~0 and whatever was there will be moved to the last + * index -- Type~42 fonts are considered invalid under this condition. + */ + FT_EXPORT( FT_UInt ) + FT_Get_Char_Index( FT_Face face, + FT_ULong charcode ); + + + /************************************************************************** + * + * @function: + * FT_Get_First_Char + * + * @description: + * Return the first character code in the current charmap of a given + * face, together with its corresponding glyph index. + * + * @input: + * face :: + * A handle to the source face object. + * + * @output: + * agindex :: + * Glyph index of first character code. 0~if charmap is empty. + * + * @return: + * The charmap's first character code. + * + * @note: + * You should use this function together with @FT_Get_Next_Char to parse + * all character codes available in a given charmap. The code should + * look like this: + * + * ``` + * FT_ULong charcode; + * FT_UInt gindex; + * + * + * charcode = FT_Get_First_Char( face, &gindex ); + * while ( gindex != 0 ) + * { + * ... do something with (charcode,gindex) pair ... + * + * charcode = FT_Get_Next_Char( face, charcode, &gindex ); + * } + * ``` + * + * Be aware that character codes can have values up to 0xFFFFFFFF; this + * might happen for non-Unicode or malformed cmaps. However, even with + * regular Unicode encoding, so-called 'last resort fonts' (using SFNT + * cmap format 13, see function @FT_Get_CMap_Format) normally have + * entries for all Unicode characters up to 0x1FFFFF, which can cause *a + * lot* of iterations. + * + * Note that `*agindex` is set to~0 if the charmap is empty. The result + * itself can be~0 in two cases: if the charmap is empty or if the + * value~0 is the first valid character code. + */ + FT_EXPORT( FT_ULong ) + FT_Get_First_Char( FT_Face face, + FT_UInt *agindex ); + + + /************************************************************************** + * + * @function: + * FT_Get_Next_Char + * + * @description: + * Return the next character code in the current charmap of a given face + * following the value `char_code`, as well as the corresponding glyph + * index. + * + * @input: + * face :: + * A handle to the source face object. + * + * char_code :: + * The starting character code. + * + * @output: + * agindex :: + * Glyph index of next character code. 0~if charmap is empty. + * + * @return: + * The charmap's next character code. + * + * @note: + * You should use this function with @FT_Get_First_Char to walk over all + * character codes available in a given charmap. See the note for that + * function for a simple code example. + * + * Note that `*agindex` is set to~0 when there are no more codes in the + * charmap. + */ + FT_EXPORT( FT_ULong ) + FT_Get_Next_Char( FT_Face face, + FT_ULong char_code, + FT_UInt *agindex ); + + + /************************************************************************** + * + * @section: + * face_creation + * + */ + + /************************************************************************** + * + * @function: + * FT_Face_Properties + * + * @description: + * Set or override certain (library or module-wide) properties on a + * face-by-face basis. Useful for finer-grained control and avoiding + * locks on shared structures (threads can modify their own faces as they + * see fit). + * + * Contrary to @FT_Property_Set, this function uses @FT_Parameter so that + * you can pass multiple properties to the target face in one call. Note + * that only a subset of the available properties can be controlled. + * + * * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the + * property `no-stem-darkening` provided by the 'autofit', 'cff', + * 'type1', and 't1cid' modules; see @no-stem-darkening). + * + * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding + * to function @FT_Library_SetLcdFilterWeights). + * + * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID + * 'random' operator, corresponding to the `random-seed` property + * provided by the 'cff', 'type1', and 't1cid' modules; see + * @random-seed). + * + * Pass `NULL` as `data` in @FT_Parameter for a given tag to reset the + * option and use the library or module default again. + * + * @input: + * face :: + * A handle to the source face object. + * + * num_properties :: + * The number of properties that follow. + * + * properties :: + * A handle to an @FT_Parameter array with `num_properties` elements. + * + * @return: + * FreeType error code. 0~means success. + * + * @example: + * Here is an example that sets three properties. You must define + * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` to make the LCD filter examples + * work. + * + * ``` + * FT_Parameter property1; + * FT_Bool darken_stems = 1; + * + * FT_Parameter property2; + * FT_LcdFiveTapFilter custom_weight = + * { 0x11, 0x44, 0x56, 0x44, 0x11 }; + * + * FT_Parameter property3; + * FT_Int32 random_seed = 314159265; + * + * FT_Parameter properties[3] = { property1, + * property2, + * property3 }; + * + * + * property1.tag = FT_PARAM_TAG_STEM_DARKENING; + * property1.data = &darken_stems; + * + * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; + * property2.data = custom_weight; + * + * property3.tag = FT_PARAM_TAG_RANDOM_SEED; + * property3.data = &random_seed; + * + * FT_Face_Properties( face, 3, properties ); + * ``` + * + * The next example resets a single property to its default value. + * + * ``` + * FT_Parameter property; + * + * + * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; + * property.data = NULL; + * + * FT_Face_Properties( face, 1, &property ); + * ``` + * + * @since: + * 2.8 + * + */ + FT_EXPORT( FT_Error ) + FT_Face_Properties( FT_Face face, + FT_UInt num_properties, + FT_Parameter* properties ); + + + /************************************************************************** + * + * @section: + * information_retrieval + * + */ + + /************************************************************************** + * + * @function: + * FT_Get_Name_Index + * + * @description: + * Return the glyph index of a given glyph name. This only works + * for those faces where @FT_HAS_GLYPH_NAMES returns true. + * + * @input: + * face :: + * A handle to the source face object. + * + * glyph_name :: + * The glyph name. + * + * @return: + * The glyph index. 0~means 'undefined character code'. + * + * @note: + * Acceptable glyph names might come from the [Adobe Glyph + * List](https://github.com/adobe-type-tools/agl-aglfn). See + * @FT_Get_Glyph_Name for the inverse functionality. + * + * This function has limited capabilities if the config macro + * `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` is not defined in `ftoption.h`: + * It then works only for fonts that actually embed glyph names (which + * many recent OpenType fonts do not). + */ + FT_EXPORT( FT_UInt ) + FT_Get_Name_Index( FT_Face face, + const FT_String* glyph_name ); + + + /************************************************************************** + * + * @function: + * FT_Get_Glyph_Name + * + * @description: + * Retrieve the ASCII name of a given glyph in a face. This only works + * for those faces where @FT_HAS_GLYPH_NAMES returns true. + * + * @input: + * face :: + * A handle to a source face object. + * + * glyph_index :: + * The glyph index. + * + * buffer_max :: + * The maximum number of bytes available in the buffer. + * + * @output: + * buffer :: + * A pointer to a target buffer where the name is copied to. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * An error is returned if the face doesn't provide glyph names or if the + * glyph index is invalid. In all cases of failure, the first byte of + * `buffer` is set to~0 to indicate an empty name. + * + * The glyph name is truncated to fit within the buffer if it is too + * long. The returned string is always zero-terminated. + * + * Be aware that FreeType reorders glyph indices internally so that glyph + * index~0 always corresponds to the 'missing glyph' (called '.notdef'). + * + * This function has limited capabilities if the config macro + * `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` is not defined in `ftoption.h`: + * It then works only for fonts that actually embed glyph names (which + * many recent OpenType fonts do not). + */ + FT_EXPORT( FT_Error ) + FT_Get_Glyph_Name( FT_Face face, + FT_UInt glyph_index, + FT_Pointer buffer, + FT_UInt buffer_max ); + + + /************************************************************************** + * + * @function: + * FT_Get_Postscript_Name + * + * @description: + * Retrieve the ASCII PostScript name of a given face, if available. + * This only works with PostScript, TrueType, and OpenType fonts. + * + * @input: + * face :: + * A handle to the source face object. + * + * @return: + * A pointer to the face's PostScript name. `NULL` if unavailable. + * + * @note: + * The returned pointer is owned by the face and is destroyed with it. + * + * For variation fonts, this string changes if you select a different + * instance, and you have to call `FT_Get_PostScript_Name` again to + * retrieve it. FreeType follows Adobe TechNote #5902, 'Generating + * PostScript Names for Fonts Using OpenType Font Variations'. + * + * https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html + * + * [Since 2.9] Special PostScript names for named instances are only + * returned if the named instance is set with @FT_Set_Named_Instance (and + * the font has corresponding entries in its 'fvar' table or is the + * default named instance). If @FT_IS_VARIATION returns true, the + * algorithmically derived PostScript name is provided, not looking up + * special entries for named instances. + */ + FT_EXPORT( const char* ) + FT_Get_Postscript_Name( FT_Face face ); + + + /************************************************************************** + * + * @enum: + * FT_SUBGLYPH_FLAG_XXX + * + * @description: + * A list of constants describing subglyphs. Please refer to the 'glyf' + * table description in the OpenType specification for the meaning of the + * various flags (which get synthesized for non-OpenType subglyphs). + * + * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description + * + * @values: + * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS :: + * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES :: + * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID :: + * FT_SUBGLYPH_FLAG_SCALE :: + * FT_SUBGLYPH_FLAG_XY_SCALE :: + * FT_SUBGLYPH_FLAG_2X2 :: + * FT_SUBGLYPH_FLAG_USE_MY_METRICS :: + * + */ +#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1 +#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2 +#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4 +#define FT_SUBGLYPH_FLAG_SCALE 8 +#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40 +#define FT_SUBGLYPH_FLAG_2X2 0x80 +#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 + + + /************************************************************************** + * + * @function: + * FT_Get_SubGlyph_Info + * + * @description: + * Retrieve a description of a given subglyph. Only use it if + * `glyph->format` is @FT_GLYPH_FORMAT_COMPOSITE; an error is returned + * otherwise. + * + * @input: + * glyph :: + * The source glyph slot. + * + * sub_index :: + * The index of the subglyph. Must be less than + * `glyph->num_subglyphs`. + * + * @output: + * p_index :: + * The glyph index of the subglyph. + * + * p_flags :: + * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. + * + * p_arg1 :: + * The subglyph's first argument (if any). + * + * p_arg2 :: + * The subglyph's second argument (if any). + * + * p_transform :: + * The subglyph transformation (if any). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The values of `*p_arg1`, `*p_arg2`, and `*p_transform` must be + * interpreted depending on the flags returned in `*p_flags`. See the + * OpenType specification for details. + * + * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description + * + */ + FT_EXPORT( FT_Error ) + FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, + FT_UInt sub_index, + FT_Int *p_index, + FT_UInt *p_flags, + FT_Int *p_arg1, + FT_Int *p_arg2, + FT_Matrix *p_transform ); + + + /************************************************************************** + * + * @enum: + * FT_FSTYPE_XXX + * + * @description: + * A list of bit flags used in the `fsType` field of the OS/2 table in a + * TrueType or OpenType font and the `FSType` entry in a PostScript font. + * These bit flags are returned by @FT_Get_FSType_Flags; they inform + * client applications of embedding and subsetting restrictions + * associated with a font. + * + * See + * https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf + * for more details. + * + * @values: + * FT_FSTYPE_INSTALLABLE_EMBEDDING :: + * Fonts with no fsType bit set may be embedded and permanently + * installed on the remote system by an application. + * + * FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: + * Fonts that have only this bit set must not be modified, embedded or + * exchanged in any manner without first obtaining permission of the + * font software copyright owner. + * + * FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: + * The font may be embedded and temporarily loaded on the remote + * system. Documents containing Preview & Print fonts must be opened + * 'read-only'; no edits can be applied to the document. + * + * FT_FSTYPE_EDITABLE_EMBEDDING :: + * The font may be embedded but must only be installed temporarily on + * other systems. In contrast to Preview & Print fonts, documents + * containing editable fonts may be opened for reading, editing is + * permitted, and changes may be saved. + * + * FT_FSTYPE_NO_SUBSETTING :: + * The font may not be subsetted prior to embedding. + * + * FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: + * Only bitmaps contained in the font may be embedded; no outline data + * may be embedded. If there are no bitmaps available in the font, + * then the font is unembeddable. + * + * @note: + * The flags are ORed together, thus more than a single value can be + * returned. + * + * While the `fsType` flags can indicate that a font may be embedded, a + * license with the font vendor may be separately required to use the + * font in this way. + */ +#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000 +#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002 +#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004 +#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008 +#define FT_FSTYPE_NO_SUBSETTING 0x0100 +#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200 + + + /************************************************************************** + * + * @function: + * FT_Get_FSType_Flags + * + * @description: + * Return the `fsType` flags for a font. + * + * @input: + * face :: + * A handle to the source face object. + * + * @return: + * The `fsType` flags, see @FT_FSTYPE_XXX. + * + * @note: + * Use this function rather than directly reading the `fs_type` field in + * the @PS_FontInfoRec structure, which is only guaranteed to return the + * correct results for Type~1 fonts. + * + * @since: + * 2.3.8 + * + */ + FT_EXPORT( FT_UShort ) + FT_Get_FSType_Flags( FT_Face face ); + + + /************************************************************************** + * + * @section: + * glyph_variants + * + * @title: + * Unicode Variation Sequences + * + * @abstract: + * The FreeType~2 interface to Unicode Variation Sequences (UVS), using + * the SFNT cmap format~14. + * + * @description: + * Many characters, especially for CJK scripts, have variant forms. They + * are a sort of grey area somewhere between being totally irrelevant and + * semantically distinct; for this reason, the Unicode consortium decided + * to introduce Variation Sequences (VS), consisting of a Unicode base + * character and a variation selector instead of further extending the + * already huge number of characters. + * + * Unicode maintains two different sets, namely 'Standardized Variation + * Sequences' and registered 'Ideographic Variation Sequences' (IVS), + * collected in the 'Ideographic Variation Database' (IVD). + * + * https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt + * https://unicode.org/reports/tr37/ https://unicode.org/ivd/ + * + * To date (January 2017), the character with the most ideographic + * variations is U+9089, having 32 such IVS. + * + * Three Mongolian Variation Selectors have the values U+180B-U+180D; 256 + * generic Variation Selectors are encoded in the ranges U+FE00-U+FE0F + * and U+E0100-U+E01EF. IVS currently use Variation Selectors from the + * range U+E0100-U+E01EF only. + * + * A VS consists of the base character value followed by a single + * Variation Selector. For example, to get the first variation of + * U+9089, you have to write the character sequence `U+9089 U+E0100`. + * + * Adobe and MS decided to support both standardized and ideographic VS + * with a new cmap subtable (format~14). It is an odd subtable because + * it is not a mapping of input code points to glyphs, but contains lists + * of all variations supported by the font. + * + * A variation may be either 'default' or 'non-default' for a given font. + * A default variation is the one you will get for that code point if you + * look it up in the standard Unicode cmap. A non-default variation is a + * different glyph. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Face_GetCharVariantIndex + * + * @description: + * Return the glyph index of a given character code as modified by the + * variation selector. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character code point in Unicode. + * + * variantSelector :: + * The Unicode code point of the variation selector. + * + * @return: + * The glyph index. 0~means either 'undefined character code', or + * 'undefined selector code', or 'no variation selector cmap subtable', + * or 'current CharMap is not Unicode'. + * + * @note: + * If you use FreeType to manipulate the contents of font files directly, + * be aware that the glyph index returned by this function doesn't always + * correspond to the internal indices used within the file. This is done + * to ensure that value~0 always corresponds to the 'missing glyph'. + * + * This function is only meaningful if + * a) the font has a variation selector cmap sub table, and + * b) the current charmap has a Unicode encoding. + * + * @since: + * 2.3.6 + * + */ + FT_EXPORT( FT_UInt ) + FT_Face_GetCharVariantIndex( FT_Face face, + FT_ULong charcode, + FT_ULong variantSelector ); + + + /************************************************************************** + * + * @function: + * FT_Face_GetCharVariantIsDefault + * + * @description: + * Check whether this variation of this Unicode character is the one to + * be found in the charmap. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character codepoint in Unicode. + * + * variantSelector :: + * The Unicode codepoint of the variation selector. + * + * @return: + * 1~if found in the standard (Unicode) cmap, 0~if found in the variation + * selector cmap, or -1 if it is not a variation. + * + * @note: + * This function is only meaningful if the font has a variation selector + * cmap subtable. + * + * @since: + * 2.3.6 + * + */ + FT_EXPORT( FT_Int ) + FT_Face_GetCharVariantIsDefault( FT_Face face, + FT_ULong charcode, + FT_ULong variantSelector ); + + + /************************************************************************** + * + * @function: + * FT_Face_GetVariantSelectors + * + * @description: + * Return a zero-terminated list of Unicode variation selectors found in + * the font. + * + * @input: + * face :: + * A handle to the source face object. + * + * @return: + * A pointer to an array of selector code points, or `NULL` if there is + * no valid variation selector cmap subtable. + * + * @note: + * The last item in the array is~0; the array is owned by the @FT_Face + * object but can be overwritten or released on the next call to a + * FreeType function. + * + * @since: + * 2.3.6 + * + */ + FT_EXPORT( FT_UInt32* ) + FT_Face_GetVariantSelectors( FT_Face face ); + + + /************************************************************************** + * + * @function: + * FT_Face_GetVariantsOfChar + * + * @description: + * Return a zero-terminated list of Unicode variation selectors found for + * the specified character code. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character codepoint in Unicode. + * + * @return: + * A pointer to an array of variation selector code points that are + * active for the given character, or `NULL` if the corresponding list is + * empty. + * + * @note: + * The last item in the array is~0; the array is owned by the @FT_Face + * object but can be overwritten or released on the next call to a + * FreeType function. + * + * @since: + * 2.3.6 + * + */ + FT_EXPORT( FT_UInt32* ) + FT_Face_GetVariantsOfChar( FT_Face face, + FT_ULong charcode ); + + + /************************************************************************** + * + * @function: + * FT_Face_GetCharsOfVariant + * + * @description: + * Return a zero-terminated list of Unicode character codes found for the + * specified variation selector. + * + * @input: + * face :: + * A handle to the source face object. + * + * variantSelector :: + * The variation selector code point in Unicode. + * + * @return: + * A list of all the code points that are specified by this selector + * (both default and non-default codes are returned) or `NULL` if there + * is no valid cmap or the variation selector is invalid. + * + * @note: + * The last item in the array is~0; the array is owned by the @FT_Face + * object but can be overwritten or released on the next call to a + * FreeType function. + * + * @since: + * 2.3.6 + * + */ + FT_EXPORT( FT_UInt32* ) + FT_Face_GetCharsOfVariant( FT_Face face, + FT_ULong variantSelector ); + + + /************************************************************************** + * + * @section: + * computations + * + * @title: + * Computations + * + * @abstract: + * Crunching fixed numbers and vectors. + * + * @description: + * This section contains various functions used to perform computations + * on 16.16 fixed-point numbers or 2D vectors. FreeType does not use + * floating-point data types. + * + * **Attention**: Most arithmetic functions take `FT_Long` as arguments. + * For historical reasons, FreeType was designed under the assumption + * that `FT_Long` is a 32-bit integer; results can thus be undefined if + * the arguments don't fit into 32 bits. + * + * @order: + * FT_MulDiv + * FT_MulFix + * FT_DivFix + * FT_RoundFix + * FT_CeilFix + * FT_FloorFix + * FT_Vector_Transform + * FT_Matrix_Multiply + * FT_Matrix_Invert + * + */ + + + /************************************************************************** + * + * @function: + * FT_MulDiv + * + * @description: + * Compute `(a*b)/c` with maximum accuracy, using a 64-bit intermediate + * integer whenever necessary. + * + * This function isn't necessarily as fast as some processor-specific + * operations, but is at least completely portable. + * + * @input: + * a :: + * The first multiplier. + * + * b :: + * The second multiplier. + * + * c :: + * The divisor. + * + * @return: + * The result of `(a*b)/c`. This function never traps when trying to + * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on + * the signs of `a` and `b`. + */ + FT_EXPORT( FT_Long ) + FT_MulDiv( FT_Long a, + FT_Long b, + FT_Long c ); + + + /************************************************************************** + * + * @function: + * FT_MulFix + * + * @description: + * Compute `(a*b)/0x10000` with maximum accuracy. Its main use is to + * multiply a given value by a 16.16 fixed-point factor. + * + * @input: + * a :: + * The first multiplier. + * + * b :: + * The second multiplier. Use a 16.16 factor here whenever possible + * (see note below). + * + * @return: + * The result of `(a*b)/0x10000`. + * + * @note: + * This function has been optimized for the case where the absolute value + * of `a` is less than 2048, and `b` is a 16.16 scaling factor. As this + * happens mainly when scaling from notional units to fractional pixels + * in FreeType, it resulted in noticeable speed improvements between + * versions 2.x and 1.x. + * + * As a conclusion, always try to place a 16.16 factor as the _second_ + * argument of this function; this can make a great difference. + */ + FT_EXPORT( FT_Long ) + FT_MulFix( FT_Long a, + FT_Long b ); + + + /************************************************************************** + * + * @function: + * FT_DivFix + * + * @description: + * Compute `(a*0x10000)/b` with maximum accuracy. Its main use is to + * divide a given value by a 16.16 fixed-point factor. + * + * @input: + * a :: + * The numerator. + * + * b :: + * The denominator. Use a 16.16 factor here. + * + * @return: + * The result of `(a*0x10000)/b`. + */ + FT_EXPORT( FT_Long ) + FT_DivFix( FT_Long a, + FT_Long b ); + + + /************************************************************************** + * + * @function: + * FT_RoundFix + * + * @description: + * Round a 16.16 fixed number. + * + * @input: + * a :: + * The number to be rounded. + * + * @return: + * `a` rounded to the nearest 16.16 fixed integer, halfway cases away + * from zero. + * + * @note: + * The function uses wrap-around arithmetic. + */ + FT_EXPORT( FT_Fixed ) + FT_RoundFix( FT_Fixed a ); + + + /************************************************************************** + * + * @function: + * FT_CeilFix + * + * @description: + * Compute the smallest following integer of a 16.16 fixed number. + * + * @input: + * a :: + * The number for which the ceiling function is to be computed. + * + * @return: + * `a` rounded towards plus infinity. + * + * @note: + * The function uses wrap-around arithmetic. + */ + FT_EXPORT( FT_Fixed ) + FT_CeilFix( FT_Fixed a ); + + + /************************************************************************** + * + * @function: + * FT_FloorFix + * + * @description: + * Compute the largest previous integer of a 16.16 fixed number. + * + * @input: + * a :: + * The number for which the floor function is to be computed. + * + * @return: + * `a` rounded towards minus infinity. + */ + FT_EXPORT( FT_Fixed ) + FT_FloorFix( FT_Fixed a ); + + + /************************************************************************** + * + * @function: + * FT_Vector_Transform + * + * @description: + * Transform a single vector through a 2x2 matrix. + * + * @inout: + * vector :: + * The target vector to transform. + * + * @input: + * matrix :: + * A pointer to the source 2x2 matrix. + * + * @note: + * The result is undefined if either `vector` or `matrix` is invalid. + */ + FT_EXPORT( void ) + FT_Vector_Transform( FT_Vector* vector, + const FT_Matrix* matrix ); + + + /************************************************************************** + * + * @section: + * library_setup + * + */ + + /************************************************************************** + * + * @enum: + * FREETYPE_XXX + * + * @description: + * These three macros identify the FreeType source code version. Use + * @FT_Library_Version to access them at runtime. + * + * @values: + * FREETYPE_MAJOR :: + * The major version number. + * FREETYPE_MINOR :: + * The minor version number. + * FREETYPE_PATCH :: + * The patch level. + * + * @note: + * The version number of FreeType if built as a dynamic link library with + * the 'libtool' package is _not_ controlled by these three macros. + * + */ +#define FREETYPE_MAJOR 2 +#define FREETYPE_MINOR 13 +#define FREETYPE_PATCH 3 + + + /************************************************************************** + * + * @function: + * FT_Library_Version + * + * @description: + * Return the version of the FreeType library being used. This is useful + * when dynamically linking to the library, since one cannot use the + * macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and @FREETYPE_PATCH. + * + * @input: + * library :: + * A source library handle. + * + * @output: + * amajor :: + * The major version number. + * + * aminor :: + * The minor version number. + * + * apatch :: + * The patch version number. + * + * @note: + * The reason why this function takes a `library` argument is because + * certain programs implement library initialization in a custom way that + * doesn't use @FT_Init_FreeType. + * + * In such cases, the library version might not be available before the + * library object has been created. + */ + FT_EXPORT( void ) + FT_Library_Version( FT_Library library, + FT_Int *amajor, + FT_Int *aminor, + FT_Int *apatch ); + + + /************************************************************************** + * + * @section: + * other_api_data + * + */ + + /************************************************************************** + * + * @function: + * FT_Face_CheckTrueTypePatents + * + * @description: + * Deprecated, does nothing. + * + * @input: + * face :: + * A face handle. + * + * @return: + * Always returns false. + * + * @note: + * Since May 2010, TrueType hinting is no longer patented. + * + * @since: + * 2.3.5 + * + */ + FT_EXPORT( FT_Bool ) + FT_Face_CheckTrueTypePatents( FT_Face face ); + + + /************************************************************************** + * + * @function: + * FT_Face_SetUnpatentedHinting + * + * @description: + * Deprecated, does nothing. + * + * @input: + * face :: + * A face handle. + * + * value :: + * New boolean setting. + * + * @return: + * Always returns false. + * + * @note: + * Since May 2010, TrueType hinting is no longer patented. + * + * @since: + * 2.3.5 + * + */ + FT_EXPORT( FT_Bool ) + FT_Face_SetUnpatentedHinting( FT_Face face, + FT_Bool value ); + + /* */ + + +FT_END_HEADER + +#endif /* FREETYPE_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftadvanc.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftadvanc.h new file mode 100644 index 0000000000000000000000000000000000000000..4130246b64647352fe35bae6cd2ab3619a99e6ef --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftadvanc.h @@ -0,0 +1,188 @@ +/**************************************************************************** + * + * ftadvanc.h + * + * Quick computation of advance widths (specification only). + * + * Copyright (C) 2008-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTADVANC_H_ +#define FTADVANC_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * quick_advance + * + * @title: + * Quick retrieval of advance values + * + * @abstract: + * Retrieve horizontal and vertical advance values without processing + * glyph outlines, if possible. + * + * @description: + * This section contains functions to quickly extract advance values + * without handling glyph outlines, if possible. + * + * @order: + * FT_Get_Advance + * FT_Get_Advances + * + */ + + + /************************************************************************** + * + * @enum: + * FT_ADVANCE_FLAG_FAST_ONLY + * + * @description: + * A bit-flag to be OR-ed with the `flags` parameter of the + * @FT_Get_Advance and @FT_Get_Advances functions. + * + * If set, it indicates that you want these functions to fail if the + * corresponding hinting mode or font driver doesn't allow for very quick + * advance computation. + * + * Typically, glyphs that are either unscaled, unhinted, bitmapped, or + * light-hinted can have their advance width computed very quickly. + * + * Normal and bytecode hinted modes that require loading, scaling, and + * hinting of the glyph outline, are extremely slow by comparison. + */ +#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L + + + /************************************************************************** + * + * @function: + * FT_Get_Advance + * + * @description: + * Retrieve the advance value of a given glyph outline in an @FT_Face. + * + * @input: + * face :: + * The source @FT_Face handle. + * + * gindex :: + * The glyph index. + * + * load_flags :: + * A set of bit flags similar to those used when calling + * @FT_Load_Glyph, used to determine what kind of advances you need. + * + * @output: + * padvance :: + * The advance value. If scaling is performed (based on the value of + * `load_flags`), the advance value is in 16.16 format. Otherwise, it + * is in font units. + * + * If @FT_LOAD_VERTICAL_LAYOUT is set, this is the vertical advance + * corresponding to a vertical layout. Otherwise, it is the horizontal + * advance in a horizontal layout. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if + * the corresponding font backend doesn't have a quick way to retrieve + * the advances. + * + * A scaled advance is returned in 16.16 format but isn't transformed by + * the affine transformation specified by @FT_Set_Transform. + */ + FT_EXPORT( FT_Error ) + FT_Get_Advance( FT_Face face, + FT_UInt gindex, + FT_Int32 load_flags, + FT_Fixed *padvance ); + + + /************************************************************************** + * + * @function: + * FT_Get_Advances + * + * @description: + * Retrieve the advance values of several glyph outlines in an @FT_Face. + * + * @input: + * face :: + * The source @FT_Face handle. + * + * start :: + * The first glyph index. + * + * count :: + * The number of advance values you want to retrieve. + * + * load_flags :: + * A set of bit flags similar to those used when calling + * @FT_Load_Glyph. + * + * @output: + * padvance :: + * The advance values. This array, to be provided by the caller, must + * contain at least `count` elements. + * + * If scaling is performed (based on the value of `load_flags`), the + * advance values are in 16.16 format. Otherwise, they are in font + * units. + * + * If @FT_LOAD_VERTICAL_LAYOUT is set, these are the vertical advances + * corresponding to a vertical layout. Otherwise, they are the + * horizontal advances in a horizontal layout. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if + * the corresponding font backend doesn't have a quick way to retrieve + * the advances. + * + * Scaled advances are returned in 16.16 format but aren't transformed by + * the affine transformation specified by @FT_Set_Transform. + */ + FT_EXPORT( FT_Error ) + FT_Get_Advances( FT_Face face, + FT_UInt start, + FT_UInt count, + FT_Int32 load_flags, + FT_Fixed *padvances ); + + /* */ + + +FT_END_HEADER + +#endif /* FTADVANC_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbbox.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbbox.h new file mode 100644 index 0000000000000000000000000000000000000000..9f8dfb01f596d4ef711ecada21ef750ee535eb99 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbbox.h @@ -0,0 +1,101 @@ +/**************************************************************************** + * + * ftbbox.h + * + * FreeType exact bbox computation (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This component has a _single_ role: to compute exact outline bounding + * boxes. + * + * It is separated from the rest of the engine for various technical + * reasons. It may well be integrated in 'ftoutln' later. + * + */ + + +#ifndef FTBBOX_H_ +#define FTBBOX_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * outline_processing + * + */ + + + /************************************************************************** + * + * @function: + * FT_Outline_Get_BBox + * + * @description: + * Compute the exact bounding box of an outline. This is slower than + * computing the control box. However, it uses an advanced algorithm + * that returns _very_ quickly when the two boxes coincide. Otherwise, + * the outline Bezier arcs are traversed to extract their extrema. + * + * @input: + * outline :: + * A pointer to the source outline. + * + * @output: + * abbox :: + * The outline's exact bounding box. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If the font is tricky and the glyph has been loaded with + * @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get + * reasonable values for the BBox it is necessary to load the glyph at a + * large ppem value (so that the hinting instructions can properly shift + * and scale the subglyphs), then extracting the BBox, which can be + * eventually converted back to font units. + */ + FT_EXPORT( FT_Error ) + FT_Outline_Get_BBox( FT_Outline* outline, + FT_BBox *abbox ); + + /* */ + + +FT_END_HEADER + +#endif /* FTBBOX_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbdf.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbdf.h new file mode 100644 index 0000000000000000000000000000000000000000..faaccc341c1cd1f3b5fdded39c0fd5989b3304f0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbdf.h @@ -0,0 +1,212 @@ +/**************************************************************************** + * + * ftbdf.h + * + * FreeType API for accessing BDF-specific strings (specification). + * + * Copyright (C) 2002-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTBDF_H_ +#define FTBDF_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * bdf_fonts + * + * @title: + * BDF and PCF Files + * + * @abstract: + * BDF and PCF specific API. + * + * @description: + * This section contains the declaration of functions specific to BDF and + * PCF fonts. + * + */ + + + /************************************************************************** + * + * @enum: + * BDF_PropertyType + * + * @description: + * A list of BDF property types. + * + * @values: + * BDF_PROPERTY_TYPE_NONE :: + * Value~0 is used to indicate a missing property. + * + * BDF_PROPERTY_TYPE_ATOM :: + * Property is a string atom. + * + * BDF_PROPERTY_TYPE_INTEGER :: + * Property is a 32-bit signed integer. + * + * BDF_PROPERTY_TYPE_CARDINAL :: + * Property is a 32-bit unsigned integer. + */ + typedef enum BDF_PropertyType_ + { + BDF_PROPERTY_TYPE_NONE = 0, + BDF_PROPERTY_TYPE_ATOM = 1, + BDF_PROPERTY_TYPE_INTEGER = 2, + BDF_PROPERTY_TYPE_CARDINAL = 3 + + } BDF_PropertyType; + + + /************************************************************************** + * + * @type: + * BDF_Property + * + * @description: + * A handle to a @BDF_PropertyRec structure to model a given BDF/PCF + * property. + */ + typedef struct BDF_PropertyRec_* BDF_Property; + + + /************************************************************************** + * + * @struct: + * BDF_PropertyRec + * + * @description: + * This structure models a given BDF/PCF property. + * + * @fields: + * type :: + * The property type. + * + * u.atom :: + * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be + * `NULL`, indicating an empty string. + * + * u.integer :: + * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. + * + * u.cardinal :: + * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. + */ + typedef struct BDF_PropertyRec_ + { + BDF_PropertyType type; + union { + const char* atom; + FT_Int32 integer; + FT_UInt32 cardinal; + + } u; + + } BDF_PropertyRec; + + + /************************************************************************** + * + * @function: + * FT_Get_BDF_Charset_ID + * + * @description: + * Retrieve a BDF font character set identity, according to the BDF + * specification. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * acharset_encoding :: + * Charset encoding, as a C~string, owned by the face. + * + * acharset_registry :: + * Charset registry, as a C~string, owned by the face. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with BDF faces, returning an error otherwise. + */ + FT_EXPORT( FT_Error ) + FT_Get_BDF_Charset_ID( FT_Face face, + const char* *acharset_encoding, + const char* *acharset_registry ); + + + /************************************************************************** + * + * @function: + * FT_Get_BDF_Property + * + * @description: + * Retrieve a BDF property from a BDF or PCF font file. + * + * @input: + * face :: + * A handle to the input face. + * + * name :: + * The property name. + * + * @output: + * aproperty :: + * The property. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function works with BDF _and_ PCF fonts. It returns an error + * otherwise. It also returns an error if the property is not in the + * font. + * + * A 'property' is a either key-value pair within the STARTPROPERTIES + * ... ENDPROPERTIES block of a BDF font or a key-value pair from the + * `info->props` array within a `FontRec` structure of a PCF font. + * + * Integer properties are always stored as 'signed' within PCF fonts; + * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value + * for BDF fonts only. + * + * In case of error, `aproperty->type` is always set to + * @BDF_PROPERTY_TYPE_NONE. + */ + FT_EXPORT( FT_Error ) + FT_Get_BDF_Property( FT_Face face, + const char* prop_name, + BDF_PropertyRec *aproperty ); + + /* */ + +FT_END_HEADER + +#endif /* FTBDF_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbitmap.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbitmap.h new file mode 100644 index 0000000000000000000000000000000000000000..21c475917a65090345abb82f7be2d37a66e3ae52 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbitmap.h @@ -0,0 +1,329 @@ +/**************************************************************************** + * + * ftbitmap.h + * + * FreeType utility functions for bitmaps (specification). + * + * Copyright (C) 2004-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTBITMAP_H_ +#define FTBITMAP_H_ + + +#include +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * bitmap_handling + * + * @title: + * Bitmap Handling + * + * @abstract: + * Handling FT_Bitmap objects. + * + * @description: + * This section contains functions for handling @FT_Bitmap objects, + * automatically adjusting the target's bitmap buffer size as needed. + * + * Note that none of the functions changes the bitmap's 'flow' (as + * indicated by the sign of the `pitch` field in @FT_Bitmap). + * + * To set the flow, assign an appropriate positive or negative value to + * the `pitch` field of the target @FT_Bitmap object after calling + * @FT_Bitmap_Init but before calling any of the other functions + * described here. + */ + + + /************************************************************************** + * + * @function: + * FT_Bitmap_Init + * + * @description: + * Initialize a pointer to an @FT_Bitmap structure. + * + * @inout: + * abitmap :: + * A pointer to the bitmap structure. + * + * @note: + * A deprecated name for the same function is `FT_Bitmap_New`. + */ + FT_EXPORT( void ) + FT_Bitmap_Init( FT_Bitmap *abitmap ); + + + /* deprecated */ + FT_EXPORT( void ) + FT_Bitmap_New( FT_Bitmap *abitmap ); + + + /************************************************************************** + * + * @function: + * FT_Bitmap_Copy + * + * @description: + * Copy a bitmap into another one. + * + * @input: + * library :: + * A handle to a library object. + * + * source :: + * A handle to the source bitmap. + * + * @output: + * target :: + * A handle to the target bitmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * `source->buffer` and `target->buffer` must neither be equal nor + * overlap. + */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Copy( FT_Library library, + const FT_Bitmap *source, + FT_Bitmap *target ); + + + /************************************************************************** + * + * @function: + * FT_Bitmap_Embolden + * + * @description: + * Embolden a bitmap. The new bitmap will be about `xStrength` pixels + * wider and `yStrength` pixels higher. The left and bottom borders are + * kept unchanged. + * + * @input: + * library :: + * A handle to a library object. + * + * xStrength :: + * How strong the glyph is emboldened horizontally. Expressed in 26.6 + * pixel format. + * + * yStrength :: + * How strong the glyph is emboldened vertically. Expressed in 26.6 + * pixel format. + * + * @inout: + * bitmap :: + * A handle to the target bitmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The current implementation restricts `xStrength` to be less than or + * equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. + * + * If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, you + * should call @FT_GlyphSlot_Own_Bitmap on the slot first. + * + * Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format are + * converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). + */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Embolden( FT_Library library, + FT_Bitmap* bitmap, + FT_Pos xStrength, + FT_Pos yStrength ); + + + /************************************************************************** + * + * @function: + * FT_Bitmap_Convert + * + * @description: + * Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp to + * a bitmap object with depth 8bpp, making the number of used bytes per + * line (a.k.a. the 'pitch') a multiple of `alignment`. + * + * @input: + * library :: + * A handle to a library object. + * + * source :: + * The source bitmap. + * + * alignment :: + * The pitch of the bitmap is a multiple of this argument. Common + * values are 1, 2, or 4. + * + * @output: + * target :: + * The target bitmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * It is possible to call @FT_Bitmap_Convert multiple times without + * calling @FT_Bitmap_Done (the memory is simply reallocated). + * + * Use @FT_Bitmap_Done to finally remove the bitmap object. + * + * The `library` argument is taken to have access to FreeType's memory + * handling functions. + * + * `source->buffer` and `target->buffer` must neither be equal nor + * overlap. + */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Convert( FT_Library library, + const FT_Bitmap *source, + FT_Bitmap *target, + FT_Int alignment ); + + + /************************************************************************** + * + * @function: + * FT_Bitmap_Blend + * + * @description: + * Blend a bitmap onto another bitmap, using a given color. + * + * @input: + * library :: + * A handle to a library object. + * + * source :: + * The source bitmap, which can have any @FT_Pixel_Mode format. + * + * source_offset :: + * The offset vector to the upper left corner of the source bitmap in + * 26.6 pixel format. It should represent an integer offset; the + * function will set the lowest six bits to zero to enforce that. + * + * color :: + * The color used to draw `source` onto `target`. + * + * @inout: + * target :: + * A handle to an `FT_Bitmap` object. It should be either initialized + * as empty with a call to @FT_Bitmap_Init, or it should be of type + * @FT_PIXEL_MODE_BGRA. + * + * atarget_offset :: + * The offset vector to the upper left corner of the target bitmap in + * 26.6 pixel format. It should represent an integer offset; the + * function will set the lowest six bits to zero to enforce that. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function doesn't perform clipping. + * + * The bitmap in `target` gets allocated or reallocated as needed; the + * vector `atarget_offset` is updated accordingly. + * + * In case of allocation or reallocation, the bitmap's pitch is set to + * `4 * width`. Both `source` and `target` must have the same bitmap + * flow (as indicated by the sign of the `pitch` field). + * + * `source->buffer` and `target->buffer` must neither be equal nor + * overlap. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Blend( FT_Library library, + const FT_Bitmap* source, + const FT_Vector source_offset, + FT_Bitmap* target, + FT_Vector *atarget_offset, + FT_Color color ); + + + /************************************************************************** + * + * @function: + * FT_GlyphSlot_Own_Bitmap + * + * @description: + * Make sure that a glyph slot owns `slot->bitmap`. + * + * @input: + * slot :: + * The glyph slot. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function is to be used in combination with @FT_Bitmap_Embolden. + */ + FT_EXPORT( FT_Error ) + FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot ); + + + /************************************************************************** + * + * @function: + * FT_Bitmap_Done + * + * @description: + * Destroy a bitmap object initialized with @FT_Bitmap_Init. + * + * @input: + * library :: + * A handle to a library object. + * + * bitmap :: + * The bitmap object to be freed. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The `library` argument is taken to have access to FreeType's memory + * handling functions. + */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Done( FT_Library library, + FT_Bitmap *bitmap ); + + + /* */ + + +FT_END_HEADER + +#endif /* FTBITMAP_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbzip2.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbzip2.h new file mode 100644 index 0000000000000000000000000000000000000000..b25cfb5ced24f692c8d869d4212729cc0289a3a5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftbzip2.h @@ -0,0 +1,102 @@ +/**************************************************************************** + * + * ftbzip2.h + * + * Bzip2-compressed stream support. + * + * Copyright (C) 2010-2024 by + * Joel Klinghed. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTBZIP2_H_ +#define FTBZIP2_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /************************************************************************** + * + * @section: + * bzip2 + * + * @title: + * BZIP2 Streams + * + * @abstract: + * Using bzip2-compressed font files. + * + * @description: + * In certain builds of the library, bzip2 compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a bzip2 compressed + * stream from it and re-open the face with it. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream, + * which significantly undermines the performance. + * + * This section contains the declaration of Bzip2-specific functions. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Stream_OpenBzip2 + * + * @description: + * Open a new stream to parse bzip2-compressed font files. This is + * mainly used to support the compressed `*.pcf.bz2` fonts that come with + * XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close` on the new stream will + * **not** call `FT_Stream_Close` on the source stream. None of the + * stream objects will be released to the heap. + * + * This function may return `FT_Err_Unimplemented_Feature` if your build + * of FreeType was not compiled with bzip2 support. + */ + FT_EXPORT( FT_Error ) + FT_Stream_OpenBzip2( FT_Stream stream, + FT_Stream source ); + + /* */ + + +FT_END_HEADER + +#endif /* FTBZIP2_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftcache.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftcache.h new file mode 100644 index 0000000000000000000000000000000000000000..ab2bf361a5c61b546610157424d0cf16d35e1f41 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftcache.h @@ -0,0 +1,1087 @@ +/**************************************************************************** + * + * ftcache.h + * + * FreeType Cache subsystem (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTCACHE_H_ +#define FTCACHE_H_ + + +#include + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * cache_subsystem + * + * @title: + * Cache Sub-System + * + * @abstract: + * How to cache face, size, and glyph data with FreeType~2. + * + * @description: + * This section describes the FreeType~2 cache sub-system, which is used + * to limit the number of concurrently opened @FT_Face and @FT_Size + * objects, as well as caching information like character maps and glyph + * images while limiting their maximum memory usage. + * + * Note that all types and functions begin with the `FTC_` prefix rather + * than the usual `FT_` prefix in the rest of FreeType. + * + * The cache is highly portable and, thus, doesn't know anything about + * the fonts installed on your system, or how to access them. Therefore, + * it requires the following. + * + * * @FTC_FaceID, an arbitrary non-zero value that uniquely identifies + * available or installed font faces, has to be provided to the + * cache by the client. Note that the cache only stores and compares + * these values and doesn't try to interpret them in any way, but they + * have to be persistent on the client side. + * + * * @FTC_Face_Requester, a method to convert an @FTC_FaceID into a new + * @FT_Face object when necessary, has to be provided to the cache by + * the client. The @FT_Face object is completely managed by the cache, + * including its termination through @FT_Done_Face. To monitor + * termination of face objects, the finalizer callback in the `generic` + * field of the @FT_Face object can be used, which might also be used + * to store the @FTC_FaceID of the face. + * + * Clients are free to map face IDs to anything useful. The most simple + * usage is, for example, to associate them to a `{pathname,face_index}` + * pair that is then used by @FTC_Face_Requester to call @FT_New_Face. + * However, more complex schemes are also possible. + * + * Note that for the cache to work correctly, the face ID values must be + * **persistent**, which means that the contents they point to should not + * change at runtime, or that their value should not become invalid. + * If this is unavoidable (e.g., when a font is uninstalled at runtime), + * you should call @FTC_Manager_RemoveFaceID as soon as possible to let + * the cache get rid of any references to the old @FTC_FaceID it may keep + * internally. Failure to do so will lead to incorrect behaviour or even + * crashes in @FTC_Face_Requester. + * + * To use the cache, start with calling @FTC_Manager_New to create a new + * @FTC_Manager object, which models a single cache instance. You can + * then look up @FT_Face and @FT_Size objects with + * @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively, and + * use them in any FreeType work stream. You can also cache other + * FreeType objects as follows. + * + * * If you want to use the charmap caching, call @FTC_CMapCache_New, + * then later use @FTC_CMapCache_Lookup to perform the equivalent of + * @FT_Get_Char_Index, only much faster. + * + * * If you want to use the @FT_Glyph caching, call @FTC_ImageCache_New, + * then later use @FTC_ImageCache_Lookup to retrieve the corresponding + * @FT_Glyph objects from the cache. + * + * * If you need lots of small bitmaps, it is much more memory-efficient + * to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This + * returns @FTC_SBitRec structures, which are used to store small + * bitmaps directly. (A small bitmap is one whose metrics and + * dimensions all fit into 8-bit integers). + * + * @order: + * FTC_Manager + * FTC_FaceID + * FTC_Face_Requester + * + * FTC_Manager_New + * FTC_Manager_Reset + * FTC_Manager_Done + * FTC_Manager_LookupFace + * FTC_Manager_LookupSize + * FTC_Manager_RemoveFaceID + * + * FTC_Node + * FTC_Node_Unref + * + * FTC_ImageCache + * FTC_ImageCache_New + * FTC_ImageCache_Lookup + * + * FTC_SBit + * FTC_SBitCache + * FTC_SBitCache_New + * FTC_SBitCache_Lookup + * + * FTC_CMapCache + * FTC_CMapCache_New + * FTC_CMapCache_Lookup + * + *************************************************************************/ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** BASIC TYPE DEFINITIONS *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * @type: + * FTC_FaceID + * + * @description: + * An opaque pointer type that is used to identity face objects. The + * contents of such objects is application-dependent. + * + * These pointers are typically used to point to a user-defined structure + * containing a font file path, and face index. + * + * @note: + * Never use `NULL` as a valid @FTC_FaceID. + * + * Face IDs are passed by the client to the cache manager that calls, + * when needed, the @FTC_Face_Requester to translate them into new + * @FT_Face objects. + * + * If the content of a given face ID changes at runtime, or if the value + * becomes invalid (e.g., when uninstalling a font), you should + * immediately call @FTC_Manager_RemoveFaceID before any other cache + * function. + * + * Failure to do so will result in incorrect behaviour or even memory + * leaks and crashes. + */ + typedef FT_Pointer FTC_FaceID; + + + /************************************************************************** + * + * @functype: + * FTC_Face_Requester + * + * @description: + * A callback function provided by client applications. It is used by + * the cache manager to translate a given @FTC_FaceID into a new valid + * @FT_Face object, on demand. + * + * @input: + * face_id :: + * The face ID to resolve. + * + * library :: + * A handle to a FreeType library object. + * + * req_data :: + * Application-provided request data (see note below). + * + * @output: + * aface :: + * A new @FT_Face handle. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The third parameter `req_data` is the same as the one passed by the + * client when @FTC_Manager_New is called. + * + * The face requester should not perform funny things on the returned + * face object, like creating a new @FT_Size for it, or setting a + * transformation through @FT_Set_Transform! + */ + typedef FT_Error + (*FTC_Face_Requester)( FTC_FaceID face_id, + FT_Library library, + FT_Pointer req_data, + FT_Face* aface ); + + /* */ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** CACHE MANAGER OBJECT *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * @type: + * FTC_Manager + * + * @description: + * This object corresponds to one instance of the cache-subsystem. It is + * used to cache one or more @FT_Face objects, along with corresponding + * @FT_Size objects. + * + * The manager intentionally limits the total number of opened @FT_Face + * and @FT_Size objects to control memory usage. See the `max_faces` and + * `max_sizes` parameters of @FTC_Manager_New. + * + * The manager is also used to cache 'nodes' of various types while + * limiting their total memory usage. + * + * All limitations are enforced by keeping lists of managed objects in + * most-recently-used order, and flushing old nodes to make room for new + * ones. + */ + typedef struct FTC_ManagerRec_* FTC_Manager; + + + /************************************************************************** + * + * @type: + * FTC_Node + * + * @description: + * An opaque handle to a cache node object. Each cache node is + * reference-counted. A node with a count of~0 might be flushed out of a + * full cache whenever a lookup request is performed. + * + * If you look up nodes, you have the ability to 'acquire' them, i.e., to + * increment their reference count. This will prevent the node from + * being flushed out of the cache until you explicitly 'release' it (see + * @FTC_Node_Unref). + * + * See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. + */ + typedef struct FTC_NodeRec_* FTC_Node; + + + /************************************************************************** + * + * @function: + * FTC_Manager_New + * + * @description: + * Create a new cache manager. + * + * @input: + * library :: + * The parent FreeType library handle to use. + * + * max_faces :: + * Maximum number of opened @FT_Face objects managed by this cache + * instance. Use~0 for defaults. + * + * max_sizes :: + * Maximum number of opened @FT_Size objects managed by this cache + * instance. Use~0 for defaults. + * + * max_bytes :: + * Maximum number of bytes to use for cached data nodes. Use~0 for + * defaults. Note that this value does not account for managed + * @FT_Face and @FT_Size objects. + * + * requester :: + * An application-provided callback used to translate face IDs into + * real @FT_Face objects. + * + * req_data :: + * A generic pointer that is passed to the requester each time it is + * called (see @FTC_Face_Requester). + * + * @output: + * amanager :: + * A handle to a new manager object. 0~in case of failure. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FTC_Manager_New( FT_Library library, + FT_UInt max_faces, + FT_UInt max_sizes, + FT_ULong max_bytes, + FTC_Face_Requester requester, + FT_Pointer req_data, + FTC_Manager *amanager ); + + + /************************************************************************** + * + * @function: + * FTC_Manager_Reset + * + * @description: + * Empty a given cache manager. This simply gets rid of all the + * currently cached @FT_Face and @FT_Size objects within the manager. + * + * @inout: + * manager :: + * A handle to the manager. + */ + FT_EXPORT( void ) + FTC_Manager_Reset( FTC_Manager manager ); + + + /************************************************************************** + * + * @function: + * FTC_Manager_Done + * + * @description: + * Destroy a given manager after emptying it. + * + * @input: + * manager :: + * A handle to the target cache manager object. + */ + FT_EXPORT( void ) + FTC_Manager_Done( FTC_Manager manager ); + + + /************************************************************************** + * + * @function: + * FTC_Manager_LookupFace + * + * @description: + * Retrieve the @FT_Face object that corresponds to a given face ID + * through a cache manager. + * + * @input: + * manager :: + * A handle to the cache manager. + * + * face_id :: + * The ID of the face object. + * + * @output: + * aface :: + * A handle to the face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The returned @FT_Face object is always owned by the manager. You + * should never try to discard it yourself. + * + * The @FT_Face object doesn't necessarily have a current size object + * (i.e., face->size can be~0). If you need a specific 'font size', use + * @FTC_Manager_LookupSize instead. + * + * Never change the face's transformation matrix (i.e., never call the + * @FT_Set_Transform function) on a returned face! If you need to + * transform glyphs, do it yourself after glyph loading. + * + * When you perform a lookup, out-of-memory errors are detected _within_ + * the lookup and force incremental flushes of the cache until enough + * memory is released for the lookup to succeed. + * + * If a lookup fails with `FT_Err_Out_Of_Memory` the cache has already + * been completely flushed, and still no memory was available for the + * operation. + */ + FT_EXPORT( FT_Error ) + FTC_Manager_LookupFace( FTC_Manager manager, + FTC_FaceID face_id, + FT_Face *aface ); + + + /************************************************************************** + * + * @struct: + * FTC_ScalerRec + * + * @description: + * A structure used to describe a given character size in either pixels + * or points to the cache manager. See @FTC_Manager_LookupSize. + * + * @fields: + * face_id :: + * The source face ID. + * + * width :: + * The character width. + * + * height :: + * The character height. + * + * pixel :: + * A Boolean. If 1, the `width` and `height` fields are interpreted as + * integer pixel character sizes. Otherwise, they are expressed as + * 1/64 of points. + * + * x_res :: + * Only used when `pixel` is value~0 to indicate the horizontal + * resolution in dpi. + * + * y_res :: + * Only used when `pixel` is value~0 to indicate the vertical + * resolution in dpi. + * + * @note: + * This type is mainly used to retrieve @FT_Size objects through the + * cache manager. + */ + typedef struct FTC_ScalerRec_ + { + FTC_FaceID face_id; + FT_UInt width; + FT_UInt height; + FT_Int pixel; + FT_UInt x_res; + FT_UInt y_res; + + } FTC_ScalerRec; + + + /************************************************************************** + * + * @struct: + * FTC_Scaler + * + * @description: + * A handle to an @FTC_ScalerRec structure. + */ + typedef struct FTC_ScalerRec_* FTC_Scaler; + + + /************************************************************************** + * + * @function: + * FTC_Manager_LookupSize + * + * @description: + * Retrieve the @FT_Size object that corresponds to a given + * @FTC_ScalerRec pointer through a cache manager. + * + * @input: + * manager :: + * A handle to the cache manager. + * + * scaler :: + * A scaler handle. + * + * @output: + * asize :: + * A handle to the size object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The returned @FT_Size object is always owned by the manager. You + * should never try to discard it by yourself. + * + * You can access the parent @FT_Face object simply as `size->face` if + * you need it. Note that this object is also owned by the manager. + * + * @note: + * When you perform a lookup, out-of-memory errors are detected _within_ + * the lookup and force incremental flushes of the cache until enough + * memory is released for the lookup to succeed. + * + * If a lookup fails with `FT_Err_Out_Of_Memory` the cache has already + * been completely flushed, and still no memory is available for the + * operation. + */ + FT_EXPORT( FT_Error ) + FTC_Manager_LookupSize( FTC_Manager manager, + FTC_Scaler scaler, + FT_Size *asize ); + + + /************************************************************************** + * + * @function: + * FTC_Node_Unref + * + * @description: + * Decrement a cache node's internal reference count. When the count + * reaches 0, it is not destroyed but becomes eligible for subsequent + * cache flushes. + * + * @input: + * node :: + * The cache node handle. + * + * manager :: + * The cache manager handle. + */ + FT_EXPORT( void ) + FTC_Node_Unref( FTC_Node node, + FTC_Manager manager ); + + + /************************************************************************** + * + * @function: + * FTC_Manager_RemoveFaceID + * + * @description: + * A special function used to indicate to the cache manager that a given + * @FTC_FaceID is no longer valid, either because its content changed, or + * because it was deallocated or uninstalled. + * + * @input: + * manager :: + * The cache manager handle. + * + * face_id :: + * The @FTC_FaceID to be removed. + * + * @note: + * This function flushes all nodes from the cache corresponding to this + * `face_id`, with the exception of nodes with a non-null reference + * count. + * + * Such nodes are however modified internally so as to never appear in + * later lookups with the same `face_id` value, and to be immediately + * destroyed when released by all their users. + * + */ + FT_EXPORT( void ) + FTC_Manager_RemoveFaceID( FTC_Manager manager, + FTC_FaceID face_id ); + + + /************************************************************************** + * + * @type: + * FTC_CMapCache + * + * @description: + * An opaque handle used to model a charmap cache. This cache is to hold + * character codes -> glyph indices mappings. + * + */ + typedef struct FTC_CMapCacheRec_* FTC_CMapCache; + + + /************************************************************************** + * + * @function: + * FTC_CMapCache_New + * + * @description: + * Create a new charmap cache. + * + * @input: + * manager :: + * A handle to the cache manager. + * + * @output: + * acache :: + * A new cache handle. `NULL` in case of error. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Like all other caches, this one will be destroyed with the cache + * manager. + * + */ + FT_EXPORT( FT_Error ) + FTC_CMapCache_New( FTC_Manager manager, + FTC_CMapCache *acache ); + + + /************************************************************************** + * + * @function: + * FTC_CMapCache_Lookup + * + * @description: + * Translate a character code into a glyph index, using the charmap + * cache. + * + * @input: + * cache :: + * A charmap cache handle. + * + * face_id :: + * The source face ID. + * + * cmap_index :: + * The index of the charmap in the source face. Any negative value + * means to use the cache @FT_Face's default charmap. + * + * char_code :: + * The character code (in the corresponding charmap). + * + * @return: + * Glyph index. 0~means 'no glyph'. + * + */ + FT_EXPORT( FT_UInt ) + FTC_CMapCache_Lookup( FTC_CMapCache cache, + FTC_FaceID face_id, + FT_Int cmap_index, + FT_UInt32 char_code ); + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** IMAGE CACHE OBJECT *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * @struct: + * FTC_ImageTypeRec + * + * @description: + * A structure used to model the type of images in a glyph cache. + * + * @fields: + * face_id :: + * The face ID. + * + * width :: + * The width in pixels. + * + * height :: + * The height in pixels. + * + * flags :: + * The load flags, as in @FT_Load_Glyph. + * + */ + typedef struct FTC_ImageTypeRec_ + { + FTC_FaceID face_id; + FT_UInt width; + FT_UInt height; + FT_Int32 flags; + + } FTC_ImageTypeRec; + + + /************************************************************************** + * + * @type: + * FTC_ImageType + * + * @description: + * A handle to an @FTC_ImageTypeRec structure. + * + */ + typedef struct FTC_ImageTypeRec_* FTC_ImageType; + + + /* */ + + +#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \ + ( (d1)->face_id == (d2)->face_id && \ + (d1)->width == (d2)->width && \ + (d1)->flags == (d2)->flags ) + + + /************************************************************************** + * + * @type: + * FTC_ImageCache + * + * @description: + * A handle to a glyph image cache object. They are designed to hold + * many distinct glyph images while not exceeding a certain memory + * threshold. + */ + typedef struct FTC_ImageCacheRec_* FTC_ImageCache; + + + /************************************************************************** + * + * @function: + * FTC_ImageCache_New + * + * @description: + * Create a new glyph image cache. + * + * @input: + * manager :: + * The parent manager for the image cache. + * + * @output: + * acache :: + * A handle to the new glyph image cache object. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FTC_ImageCache_New( FTC_Manager manager, + FTC_ImageCache *acache ); + + + /************************************************************************** + * + * @function: + * FTC_ImageCache_Lookup + * + * @description: + * Retrieve a given glyph image from a glyph image cache. + * + * @input: + * cache :: + * A handle to the source glyph image cache. + * + * type :: + * A pointer to a glyph image type descriptor. + * + * gindex :: + * The glyph index to retrieve. + * + * @output: + * aglyph :: + * The corresponding @FT_Glyph object. 0~in case of failure. + * + * anode :: + * Used to return the address of the corresponding cache node after + * incrementing its reference count (see note below). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The returned glyph is owned and managed by the glyph image cache. + * Never try to transform or discard it manually! You can however create + * a copy with @FT_Glyph_Copy and modify the new one. + * + * If `anode` is _not_ `NULL`, it receives the address of the cache node + * containing the glyph image, after increasing its reference count. + * This ensures that the node (as well as the @FT_Glyph) will always be + * kept in the cache until you call @FTC_Node_Unref to 'release' it. + * + * If `anode` is `NULL`, the cache node is left unchanged, which means + * that the @FT_Glyph could be flushed out of the cache on the next call + * to one of the caching sub-system APIs. Don't assume that it is + * persistent! + */ + FT_EXPORT( FT_Error ) + FTC_ImageCache_Lookup( FTC_ImageCache cache, + FTC_ImageType type, + FT_UInt gindex, + FT_Glyph *aglyph, + FTC_Node *anode ); + + + /************************************************************************** + * + * @function: + * FTC_ImageCache_LookupScaler + * + * @description: + * A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec to + * specify the face ID and its size. + * + * @input: + * cache :: + * A handle to the source glyph image cache. + * + * scaler :: + * A pointer to a scaler descriptor. + * + * load_flags :: + * The corresponding load flags. + * + * gindex :: + * The glyph index to retrieve. + * + * @output: + * aglyph :: + * The corresponding @FT_Glyph object. 0~in case of failure. + * + * anode :: + * Used to return the address of the corresponding cache node after + * incrementing its reference count (see note below). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The returned glyph is owned and managed by the glyph image cache. + * Never try to transform or discard it manually! You can however create + * a copy with @FT_Glyph_Copy and modify the new one. + * + * If `anode` is _not_ `NULL`, it receives the address of the cache node + * containing the glyph image, after increasing its reference count. + * This ensures that the node (as well as the @FT_Glyph) will always be + * kept in the cache until you call @FTC_Node_Unref to 'release' it. + * + * If `anode` is `NULL`, the cache node is left unchanged, which means + * that the @FT_Glyph could be flushed out of the cache on the next call + * to one of the caching sub-system APIs. Don't assume that it is + * persistent! + * + * Calls to @FT_Set_Char_Size and friends have no effect on cached + * glyphs; you should always use the FreeType cache API instead. + */ + FT_EXPORT( FT_Error ) + FTC_ImageCache_LookupScaler( FTC_ImageCache cache, + FTC_Scaler scaler, + FT_ULong load_flags, + FT_UInt gindex, + FT_Glyph *aglyph, + FTC_Node *anode ); + + + /************************************************************************** + * + * @type: + * FTC_SBit + * + * @description: + * A handle to a small bitmap descriptor. See the @FTC_SBitRec structure + * for details. + */ + typedef struct FTC_SBitRec_* FTC_SBit; + + + /************************************************************************** + * + * @struct: + * FTC_SBitRec + * + * @description: + * A very compact structure used to describe a small glyph bitmap. + * + * @fields: + * width :: + * The bitmap width in pixels. + * + * height :: + * The bitmap height in pixels. + * + * left :: + * The horizontal distance from the pen position to the left bitmap + * border (a.k.a. 'left side bearing', or 'lsb'). + * + * top :: + * The vertical distance from the pen position (on the baseline) to the + * upper bitmap border (a.k.a. 'top side bearing'). The distance is + * positive for upwards y~coordinates. + * + * format :: + * The format of the glyph bitmap (monochrome or gray). + * + * max_grays :: + * Maximum gray level value (in the range 1 to~255). + * + * pitch :: + * The number of bytes per bitmap line. May be positive or negative. + * + * xadvance :: + * The horizontal advance width in pixels. + * + * yadvance :: + * The vertical advance height in pixels. + * + * buffer :: + * A pointer to the bitmap pixels. + */ + typedef struct FTC_SBitRec_ + { + FT_Byte width; + FT_Byte height; + FT_Char left; + FT_Char top; + + FT_Byte format; + FT_Byte max_grays; + FT_Short pitch; + FT_Char xadvance; + FT_Char yadvance; + + FT_Byte* buffer; + + } FTC_SBitRec; + + + /************************************************************************** + * + * @type: + * FTC_SBitCache + * + * @description: + * A handle to a small bitmap cache. These are special cache objects + * used to store small glyph bitmaps (and anti-aliased pixmaps) in a much + * more efficient way than the traditional glyph image cache implemented + * by @FTC_ImageCache. + */ + typedef struct FTC_SBitCacheRec_* FTC_SBitCache; + + + /************************************************************************** + * + * @function: + * FTC_SBitCache_New + * + * @description: + * Create a new cache to store small glyph bitmaps. + * + * @input: + * manager :: + * A handle to the source cache manager. + * + * @output: + * acache :: + * A handle to the new sbit cache. `NULL` in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FTC_SBitCache_New( FTC_Manager manager, + FTC_SBitCache *acache ); + + + /************************************************************************** + * + * @function: + * FTC_SBitCache_Lookup + * + * @description: + * Look up a given small glyph bitmap in a given sbit cache and 'lock' it + * to prevent its flushing from the cache until needed. + * + * @input: + * cache :: + * A handle to the source sbit cache. + * + * type :: + * A pointer to the glyph image type descriptor. + * + * gindex :: + * The glyph index. + * + * @output: + * sbit :: + * A handle to a small bitmap descriptor. + * + * anode :: + * Used to return the address of the corresponding cache node after + * incrementing its reference count (see note below). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The small bitmap descriptor and its bit buffer are owned by the cache + * and should never be freed by the application. They might as well + * disappear from memory on the next cache lookup, so don't treat them as + * persistent data. + * + * The descriptor's `buffer` field is set to~0 to indicate a missing + * glyph bitmap. + * + * If `anode` is _not_ `NULL`, it receives the address of the cache node + * containing the bitmap, after increasing its reference count. This + * ensures that the node (as well as the image) will always be kept in + * the cache until you call @FTC_Node_Unref to 'release' it. + * + * If `anode` is `NULL`, the cache node is left unchanged, which means + * that the bitmap could be flushed out of the cache on the next call to + * one of the caching sub-system APIs. Don't assume that it is + * persistent! + */ + FT_EXPORT( FT_Error ) + FTC_SBitCache_Lookup( FTC_SBitCache cache, + FTC_ImageType type, + FT_UInt gindex, + FTC_SBit *sbit, + FTC_Node *anode ); + + + /************************************************************************** + * + * @function: + * FTC_SBitCache_LookupScaler + * + * @description: + * A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec to + * specify the face ID and its size. + * + * @input: + * cache :: + * A handle to the source sbit cache. + * + * scaler :: + * A pointer to the scaler descriptor. + * + * load_flags :: + * The corresponding load flags. + * + * gindex :: + * The glyph index. + * + * @output: + * sbit :: + * A handle to a small bitmap descriptor. + * + * anode :: + * Used to return the address of the corresponding cache node after + * incrementing its reference count (see note below). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The small bitmap descriptor and its bit buffer are owned by the cache + * and should never be freed by the application. They might as well + * disappear from memory on the next cache lookup, so don't treat them as + * persistent data. + * + * The descriptor's `buffer` field is set to~0 to indicate a missing + * glyph bitmap. + * + * If `anode` is _not_ `NULL`, it receives the address of the cache node + * containing the bitmap, after increasing its reference count. This + * ensures that the node (as well as the image) will always be kept in + * the cache until you call @FTC_Node_Unref to 'release' it. + * + * If `anode` is `NULL`, the cache node is left unchanged, which means + * that the bitmap could be flushed out of the cache on the next call to + * one of the caching sub-system APIs. Don't assume that it is + * persistent! + */ + FT_EXPORT( FT_Error ) + FTC_SBitCache_LookupScaler( FTC_SBitCache cache, + FTC_Scaler scaler, + FT_ULong load_flags, + FT_UInt gindex, + FTC_SBit *sbit, + FTC_Node *anode ); + + /* */ + + +FT_END_HEADER + +#endif /* FTCACHE_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftchapters.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftchapters.h new file mode 100644 index 0000000000000000000000000000000000000000..e868c9990c25d205cff91fdce0a5662bedde570a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftchapters.h @@ -0,0 +1,168 @@ +/**************************************************************************** + * + * This file defines the structure of the FreeType reference. + * It is used by the python script that generates the HTML files. + * + */ + + + /************************************************************************** + * + * @chapter: + * general_remarks + * + * @title: + * General Remarks + * + * @sections: + * preamble + * header_inclusion + * user_allocation + * + */ + + + /************************************************************************** + * + * @chapter: + * core_api + * + * @title: + * Core API + * + * @sections: + * basic_types + * library_setup + * face_creation + * font_testing_macros + * sizing_and_scaling + * glyph_retrieval + * character_mapping + * information_retrieval + * other_api_data + * + */ + + + /************************************************************************** + * + * @chapter: + * extended_api + * + * @title: + * Extended API + * + * @sections: + * glyph_variants + * color_management + * layer_management + * glyph_management + * mac_specific + * sizes_management + * header_file_macros + * + */ + + + /************************************************************************** + * + * @chapter: + * format_specific + * + * @title: + * Format-Specific API + * + * @sections: + * multiple_masters + * truetype_tables + * type1_tables + * sfnt_names + * bdf_fonts + * cid_fonts + * pfr_fonts + * winfnt_fonts + * svg_fonts + * font_formats + * gasp_table + * + */ + + + /************************************************************************** + * + * @chapter: + * module_specific + * + * @title: + * Controlling FreeType Modules + * + * @sections: + * auto_hinter + * cff_driver + * t1_cid_driver + * tt_driver + * pcf_driver + * ot_svg_driver + * properties + * parameter_tags + * lcd_rendering + * + */ + + + /************************************************************************** + * + * @chapter: + * cache_subsystem + * + * @title: + * Cache Sub-System + * + * @sections: + * cache_subsystem + * + */ + + + /************************************************************************** + * + * @chapter: + * support_api + * + * @title: + * Support API + * + * @sections: + * computations + * list_processing + * outline_processing + * quick_advance + * bitmap_handling + * raster + * glyph_stroker + * system_interface + * module_management + * gzip + * lzw + * bzip2 + * debugging_apis + * + */ + + + /************************************************************************** + * + * @chapter: + * error_codes + * + * @title: + * Error Codes + * + * @sections: + * error_enumerations + * error_code_values + * + */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftcid.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftcid.h new file mode 100644 index 0000000000000000000000000000000000000000..7b213fe4f6ef6f4e3e139dfcd02233dcd824fd4c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftcid.h @@ -0,0 +1,167 @@ +/**************************************************************************** + * + * ftcid.h + * + * FreeType API for accessing CID font information (specification). + * + * Copyright (C) 2007-2024 by + * Dereg Clegg and Michael Toftdal. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTCID_H_ +#define FTCID_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * cid_fonts + * + * @title: + * CID Fonts + * + * @abstract: + * CID-keyed font-specific API. + * + * @description: + * This section contains the declaration of CID-keyed font-specific + * functions. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Get_CID_Registry_Ordering_Supplement + * + * @description: + * Retrieve the Registry/Ordering/Supplement triple (also known as the + * "R/O/S") from a CID-keyed font. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * registry :: + * The registry, as a C~string, owned by the face. + * + * ordering :: + * The ordering, as a C~string, owned by the face. + * + * supplement :: + * The supplement. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with CID faces, returning an error + * otherwise. + * + * @since: + * 2.3.6 + */ + FT_EXPORT( FT_Error ) + FT_Get_CID_Registry_Ordering_Supplement( FT_Face face, + const char* *registry, + const char* *ordering, + FT_Int *supplement ); + + + /************************************************************************** + * + * @function: + * FT_Get_CID_Is_Internally_CID_Keyed + * + * @description: + * Retrieve the type of the input face, CID keyed or not. In contrast + * to the @FT_IS_CID_KEYED macro this function returns successfully also + * for CID-keyed fonts in an SFNT wrapper. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * is_cid :: + * The type of the face as an @FT_Bool. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with CID faces and OpenType fonts, returning + * an error otherwise. + * + * @since: + * 2.3.9 + */ + FT_EXPORT( FT_Error ) + FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face, + FT_Bool *is_cid ); + + + /************************************************************************** + * + * @function: + * FT_Get_CID_From_Glyph_Index + * + * @description: + * Retrieve the CID of the input glyph index. + * + * @input: + * face :: + * A handle to the input face. + * + * glyph_index :: + * The input glyph index. + * + * @output: + * cid :: + * The CID as an @FT_UInt. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with CID faces and OpenType fonts, returning + * an error otherwise. + * + * @since: + * 2.3.9 + */ + FT_EXPORT( FT_Error ) + FT_Get_CID_From_Glyph_Index( FT_Face face, + FT_UInt glyph_index, + FT_UInt *cid ); + + /* */ + + +FT_END_HEADER + +#endif /* FTCID_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftcolor.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftcolor.h new file mode 100644 index 0000000000000000000000000000000000000000..4cd26eb5811fb29e82f4f2a2b10335ea991e47ea --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftcolor.h @@ -0,0 +1,1667 @@ +/**************************************************************************** + * + * ftcolor.h + * + * FreeType's glyph color management (specification). + * + * Copyright (C) 2018-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTCOLOR_H_ +#define FTCOLOR_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * color_management + * + * @title: + * Glyph Color Management + * + * @abstract: + * Retrieving and manipulating OpenType's 'CPAL' table data. + * + * @description: + * The functions described here allow access and manipulation of color + * palette entries in OpenType's 'CPAL' tables. + */ + + + /************************************************************************** + * + * @struct: + * FT_Color + * + * @description: + * This structure models a BGRA color value of a 'CPAL' palette entry. + * + * The used color space is sRGB; the colors are not pre-multiplied, and + * alpha values must be explicitly set. + * + * @fields: + * blue :: + * Blue value. + * + * green :: + * Green value. + * + * red :: + * Red value. + * + * alpha :: + * Alpha value, giving the red, green, and blue color's opacity. + * + * @since: + * 2.10 + */ + typedef struct FT_Color_ + { + FT_Byte blue; + FT_Byte green; + FT_Byte red; + FT_Byte alpha; + + } FT_Color; + + + /************************************************************************** + * + * @enum: + * FT_PALETTE_XXX + * + * @description: + * A list of bit field constants used in the `palette_flags` array of the + * @FT_Palette_Data structure to indicate for which background a palette + * with a given index is usable. + * + * @values: + * FT_PALETTE_FOR_LIGHT_BACKGROUND :: + * The palette is appropriate to use when displaying the font on a + * light background such as white. + * + * FT_PALETTE_FOR_DARK_BACKGROUND :: + * The palette is appropriate to use when displaying the font on a dark + * background such as black. + * + * @since: + * 2.10 + */ +#define FT_PALETTE_FOR_LIGHT_BACKGROUND 0x01 +#define FT_PALETTE_FOR_DARK_BACKGROUND 0x02 + + + /************************************************************************** + * + * @struct: + * FT_Palette_Data + * + * @description: + * This structure holds the data of the 'CPAL' table. + * + * @fields: + * num_palettes :: + * The number of palettes. + * + * palette_name_ids :: + * An optional read-only array of palette name IDs with `num_palettes` + * elements, corresponding to entries like 'dark' or 'light' in the + * font's 'name' table. + * + * An empty name ID in the 'CPAL' table gets represented as value + * 0xFFFF. + * + * `NULL` if the font's 'CPAL' table doesn't contain appropriate data. + * + * palette_flags :: + * An optional read-only array of palette flags with `num_palettes` + * elements. Possible values are an ORed combination of + * @FT_PALETTE_FOR_LIGHT_BACKGROUND and + * @FT_PALETTE_FOR_DARK_BACKGROUND. + * + * `NULL` if the font's 'CPAL' table doesn't contain appropriate data. + * + * num_palette_entries :: + * The number of entries in a single palette. All palettes have the + * same size. + * + * palette_entry_name_ids :: + * An optional read-only array of palette entry name IDs with + * `num_palette_entries`. In each palette, entries with the same index + * have the same function. For example, index~0 might correspond to + * string 'outline' in the font's 'name' table to indicate that this + * palette entry is used for outlines, index~1 might correspond to + * 'fill' to indicate the filling color palette entry, etc. + * + * An empty entry name ID in the 'CPAL' table gets represented as value + * 0xFFFF. + * + * `NULL` if the font's 'CPAL' table doesn't contain appropriate data. + * + * @note: + * Use function @FT_Get_Sfnt_Name to map name IDs and entry name IDs to + * name strings. + * + * Use function @FT_Palette_Select to get the colors associated with a + * palette entry. + * + * @since: + * 2.10 + */ + typedef struct FT_Palette_Data_ { + FT_UShort num_palettes; + const FT_UShort* palette_name_ids; + const FT_UShort* palette_flags; + + FT_UShort num_palette_entries; + const FT_UShort* palette_entry_name_ids; + + } FT_Palette_Data; + + + /************************************************************************** + * + * @function: + * FT_Palette_Data_Get + * + * @description: + * Retrieve the face's color palette data. + * + * @input: + * face :: + * The source face handle. + * + * @output: + * apalette :: + * A pointer to an @FT_Palette_Data structure. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * All arrays in the returned @FT_Palette_Data structure are read-only. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Palette_Data_Get( FT_Face face, + FT_Palette_Data *apalette ); + + + /************************************************************************** + * + * @function: + * FT_Palette_Select + * + * @description: + * This function has two purposes. + * + * (1) It activates a palette for rendering color glyphs, and + * + * (2) it retrieves all (unmodified) color entries of this palette. This + * function returns a read-write array, which means that a calling + * application can modify the palette entries on demand. + * + * A corollary of (2) is that calling the function, then modifying some + * values, then calling the function again with the same arguments resets + * all color entries to the original 'CPAL' values; all user modifications + * are lost. + * + * @input: + * face :: + * The source face handle. + * + * palette_index :: + * The palette index. + * + * @output: + * apalette :: + * An array of color entries for a palette with index `palette_index`, + * having `num_palette_entries` elements (as found in the + * `FT_Palette_Data` structure). If `apalette` is set to `NULL`, no + * array gets returned (and no color entries can be modified). + * + * In case the font doesn't support color palettes, `NULL` is returned. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The array pointed to by `apalette_entries` is owned and managed by + * FreeType. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Palette_Select( FT_Face face, + FT_UShort palette_index, + FT_Color* *apalette ); + + + /************************************************************************** + * + * @function: + * FT_Palette_Set_Foreground_Color + * + * @description: + * 'COLR' uses palette index 0xFFFF to indicate a 'text foreground + * color'. This function sets this value. + * + * @input: + * face :: + * The source face handle. + * + * foreground_color :: + * An `FT_Color` structure to define the text foreground color. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If this function isn't called, the text foreground color is set to + * white opaque (BGRA value 0xFFFFFFFF) if + * @FT_PALETTE_FOR_DARK_BACKGROUND is present for the current palette, + * and black opaque (BGRA value 0x000000FF) otherwise, including the case + * that no palette types are available in the 'CPAL' table. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Palette_Set_Foreground_Color( FT_Face face, + FT_Color foreground_color ); + + + /************************************************************************** + * + * @section: + * layer_management + * + * @title: + * Glyph Layer Management + * + * @abstract: + * Retrieving and manipulating OpenType's 'COLR' table data. + * + * @description: + * The functions described here allow access of colored glyph layer data + * in OpenType's 'COLR' tables. + */ + + + /************************************************************************** + * + * @struct: + * FT_LayerIterator + * + * @description: + * This iterator object is needed for @FT_Get_Color_Glyph_Layer. + * + * @fields: + * num_layers :: + * The number of glyph layers for the requested glyph index. Will be + * set by @FT_Get_Color_Glyph_Layer. + * + * layer :: + * The current layer. Will be set by @FT_Get_Color_Glyph_Layer. + * + * p :: + * An opaque pointer into 'COLR' table data. The caller must set this + * to `NULL` before the first call of @FT_Get_Color_Glyph_Layer. + */ + typedef struct FT_LayerIterator_ + { + FT_UInt num_layers; + FT_UInt layer; + FT_Byte* p; + + } FT_LayerIterator; + + + /************************************************************************** + * + * @function: + * FT_Get_Color_Glyph_Layer + * + * @description: + * This is an interface to the 'COLR' table in OpenType fonts to + * iteratively retrieve the colored glyph layers associated with the + * current glyph slot. + * + * https://docs.microsoft.com/en-us/typography/opentype/spec/colr + * + * The glyph layer data for a given glyph index, if present, provides an + * alternative, multi-color glyph representation: Instead of rendering + * the outline or bitmap with the given glyph index, glyphs with the + * indices and colors returned by this function are rendered layer by + * layer. + * + * The returned elements are ordered in the z~direction from bottom to + * top; the 'n'th element should be rendered with the associated palette + * color and blended on top of the already rendered layers (elements 0, + * 1, ..., n-1). + * + * @input: + * face :: + * A handle to the parent face object. + * + * base_glyph :: + * The glyph index the colored glyph layers are associated with. + * + * @inout: + * iterator :: + * An @FT_LayerIterator object. For the first call you should set + * `iterator->p` to `NULL`. For all following calls, simply use the + * same object again. + * + * @output: + * aglyph_index :: + * The glyph index of the current layer. + * + * acolor_index :: + * The color index into the font face's color palette of the current + * layer. The value 0xFFFF is special; it doesn't reference a palette + * entry but indicates that the text foreground color should be used + * instead (to be set up by the application outside of FreeType). + * + * The color palette can be retrieved with @FT_Palette_Select. + * + * @return: + * Value~1 if everything is OK. If there are no more layers (or if there + * are no layers at all), value~0 gets returned. In case of an error, + * value~0 is returned also. + * + * @note: + * This function is necessary if you want to handle glyph layers by + * yourself. In particular, functions that operate with @FT_GlyphRec + * objects (like @FT_Get_Glyph or @FT_Glyph_To_Bitmap) don't have access + * to this information. + * + * Note that @FT_Render_Glyph is able to handle colored glyph layers + * automatically if the @FT_LOAD_COLOR flag is passed to a previous call + * to @FT_Load_Glyph. [This is an experimental feature.] + * + * @example: + * ``` + * FT_Color* palette; + * FT_LayerIterator iterator; + * + * FT_Bool have_layers; + * FT_UInt layer_glyph_index; + * FT_UInt layer_color_index; + * + * + * error = FT_Palette_Select( face, palette_index, &palette ); + * if ( error ) + * palette = NULL; + * + * iterator.p = NULL; + * have_layers = FT_Get_Color_Glyph_Layer( face, + * glyph_index, + * &layer_glyph_index, + * &layer_color_index, + * &iterator ); + * + * if ( palette && have_layers ) + * { + * do + * { + * FT_Color layer_color; + * + * + * if ( layer_color_index == 0xFFFF ) + * layer_color = text_foreground_color; + * else + * layer_color = palette[layer_color_index]; + * + * // Load and render glyph `layer_glyph_index', then + * // blend resulting pixmap (using color `layer_color') + * // with previously created pixmaps. + * + * } while ( FT_Get_Color_Glyph_Layer( face, + * glyph_index, + * &layer_glyph_index, + * &layer_color_index, + * &iterator ) ); + * } + * ``` + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Bool ) + FT_Get_Color_Glyph_Layer( FT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ); + + + /************************************************************************** + * + * @enum: + * FT_PaintFormat + * + * @description: + * Enumeration describing the different paint format types of the v1 + * extensions to the 'COLR' table, see + * 'https://github.com/googlefonts/colr-gradients-spec'. + * + * The enumeration values loosely correspond with the format numbers of + * the specification: FreeType always returns a fully specified 'Paint' + * structure for the 'Transform', 'Translate', 'Scale', 'Rotate', and + * 'Skew' table types even though the specification has different formats + * depending on whether or not a center is specified, whether the scale + * is uniform in x and y~direction or not, etc. Also, only non-variable + * format identifiers are listed in this enumeration; as soon as support + * for variable 'COLR' v1 fonts is implemented, interpolation is + * performed dependent on axis coordinates, which are configured on the + * @FT_Face through @FT_Set_Var_Design_Coordinates. This implies that + * always static, readily interpolated values are returned in the 'Paint' + * structures. + * + * @since: + * 2.13 + */ + typedef enum FT_PaintFormat_ + { + FT_COLR_PAINTFORMAT_COLR_LAYERS = 1, + FT_COLR_PAINTFORMAT_SOLID = 2, + FT_COLR_PAINTFORMAT_LINEAR_GRADIENT = 4, + FT_COLR_PAINTFORMAT_RADIAL_GRADIENT = 6, + FT_COLR_PAINTFORMAT_SWEEP_GRADIENT = 8, + FT_COLR_PAINTFORMAT_GLYPH = 10, + FT_COLR_PAINTFORMAT_COLR_GLYPH = 11, + FT_COLR_PAINTFORMAT_TRANSFORM = 12, + FT_COLR_PAINTFORMAT_TRANSLATE = 14, + FT_COLR_PAINTFORMAT_SCALE = 16, + FT_COLR_PAINTFORMAT_ROTATE = 24, + FT_COLR_PAINTFORMAT_SKEW = 28, + FT_COLR_PAINTFORMAT_COMPOSITE = 32, + FT_COLR_PAINT_FORMAT_MAX = 33, + FT_COLR_PAINTFORMAT_UNSUPPORTED = 255 + + } FT_PaintFormat; + + + /************************************************************************** + * + * @struct: + * FT_ColorStopIterator + * + * @description: + * This iterator object is needed for @FT_Get_Colorline_Stops. It keeps + * state while iterating over the stops of an @FT_ColorLine, representing + * the `ColorLine` struct of the v1 extensions to 'COLR', see + * 'https://github.com/googlefonts/colr-gradients-spec'. Do not manually + * modify fields of this iterator. + * + * @fields: + * num_color_stops :: + * The number of color stops for the requested glyph index. Set by + * @FT_Get_Paint. + * + * current_color_stop :: + * The current color stop. Set by @FT_Get_Colorline_Stops. + * + * p :: + * An opaque pointer into 'COLR' table data. Set by @FT_Get_Paint. + * Updated by @FT_Get_Colorline_Stops. + * + * read_variable :: + * A boolean keeping track of whether variable color lines are to be + * read. Set by @FT_Get_Paint. + * + * @since: + * 2.13 + */ + typedef struct FT_ColorStopIterator_ + { + FT_UInt num_color_stops; + FT_UInt current_color_stop; + + FT_Byte* p; + + FT_Bool read_variable; + + } FT_ColorStopIterator; + + + /************************************************************************** + * + * @struct: + * FT_ColorIndex + * + * @description: + * A structure representing a `ColorIndex` value of the 'COLR' v1 + * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'. + * + * @fields: + * palette_index :: + * The palette index into a 'CPAL' palette. + * + * alpha :: + * Alpha transparency value multiplied with the value from 'CPAL'. + * + * @since: + * 2.13 + */ + typedef struct FT_ColorIndex_ + { + FT_UInt16 palette_index; + FT_F2Dot14 alpha; + + } FT_ColorIndex; + + + /************************************************************************** + * + * @struct: + * FT_ColorStop + * + * @description: + * A structure representing a `ColorStop` value of the 'COLR' v1 + * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'. + * + * @fields: + * stop_offset :: + * The stop offset along the gradient, expressed as a 16.16 fixed-point + * coordinate. + * + * color :: + * The color information for this stop, see @FT_ColorIndex. + * + * @since: + * 2.13 + */ + typedef struct FT_ColorStop_ + { + FT_Fixed stop_offset; + FT_ColorIndex color; + + } FT_ColorStop; + + + /************************************************************************** + * + * @enum: + * FT_PaintExtend + * + * @description: + * An enumeration representing the 'Extend' mode of the 'COLR' v1 + * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'. + * It describes how the gradient fill continues at the other boundaries. + * + * @since: + * 2.13 + */ + typedef enum FT_PaintExtend_ + { + FT_COLR_PAINT_EXTEND_PAD = 0, + FT_COLR_PAINT_EXTEND_REPEAT = 1, + FT_COLR_PAINT_EXTEND_REFLECT = 2 + + } FT_PaintExtend; + + + /************************************************************************** + * + * @struct: + * FT_ColorLine + * + * @description: + * A structure representing a `ColorLine` value of the 'COLR' v1 + * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'. + * It describes a list of color stops along the defined gradient. + * + * @fields: + * extend :: + * The extend mode at the outer boundaries, see @FT_PaintExtend. + * + * color_stop_iterator :: + * The @FT_ColorStopIterator used to enumerate and retrieve the + * actual @FT_ColorStop's. + * + * @since: + * 2.13 + */ + typedef struct FT_ColorLine_ + { + FT_PaintExtend extend; + FT_ColorStopIterator color_stop_iterator; + + } FT_ColorLine; + + + /************************************************************************** + * + * @struct: + * FT_Affine23 + * + * @description: + * A structure used to store a 2x3 matrix. Coefficients are in + * 16.16 fixed-point format. The computation performed is + * + * ``` + * x' = x*xx + y*xy + dx + * y' = x*yx + y*yy + dy + * ``` + * + * @fields: + * xx :: + * Matrix coefficient. + * + * xy :: + * Matrix coefficient. + * + * dx :: + * x translation. + * + * yx :: + * Matrix coefficient. + * + * yy :: + * Matrix coefficient. + * + * dy :: + * y translation. + * + * @since: + * 2.13 + */ + typedef struct FT_Affine_23_ + { + FT_Fixed xx, xy, dx; + FT_Fixed yx, yy, dy; + + } FT_Affine23; + + + /************************************************************************** + * + * @enum: + * FT_Composite_Mode + * + * @description: + * An enumeration listing the 'COLR' v1 composite modes used in + * @FT_PaintComposite. For more details on each paint mode, see + * 'https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators'. + * + * @since: + * 2.13 + */ + typedef enum FT_Composite_Mode_ + { + FT_COLR_COMPOSITE_CLEAR = 0, + FT_COLR_COMPOSITE_SRC = 1, + FT_COLR_COMPOSITE_DEST = 2, + FT_COLR_COMPOSITE_SRC_OVER = 3, + FT_COLR_COMPOSITE_DEST_OVER = 4, + FT_COLR_COMPOSITE_SRC_IN = 5, + FT_COLR_COMPOSITE_DEST_IN = 6, + FT_COLR_COMPOSITE_SRC_OUT = 7, + FT_COLR_COMPOSITE_DEST_OUT = 8, + FT_COLR_COMPOSITE_SRC_ATOP = 9, + FT_COLR_COMPOSITE_DEST_ATOP = 10, + FT_COLR_COMPOSITE_XOR = 11, + FT_COLR_COMPOSITE_PLUS = 12, + FT_COLR_COMPOSITE_SCREEN = 13, + FT_COLR_COMPOSITE_OVERLAY = 14, + FT_COLR_COMPOSITE_DARKEN = 15, + FT_COLR_COMPOSITE_LIGHTEN = 16, + FT_COLR_COMPOSITE_COLOR_DODGE = 17, + FT_COLR_COMPOSITE_COLOR_BURN = 18, + FT_COLR_COMPOSITE_HARD_LIGHT = 19, + FT_COLR_COMPOSITE_SOFT_LIGHT = 20, + FT_COLR_COMPOSITE_DIFFERENCE = 21, + FT_COLR_COMPOSITE_EXCLUSION = 22, + FT_COLR_COMPOSITE_MULTIPLY = 23, + FT_COLR_COMPOSITE_HSL_HUE = 24, + FT_COLR_COMPOSITE_HSL_SATURATION = 25, + FT_COLR_COMPOSITE_HSL_COLOR = 26, + FT_COLR_COMPOSITE_HSL_LUMINOSITY = 27, + FT_COLR_COMPOSITE_MAX = 28 + + } FT_Composite_Mode; + + + /************************************************************************** + * + * @struct: + * FT_OpaquePaint + * + * @description: + * A structure representing an offset to a `Paint` value stored in any + * of the paint tables of a 'COLR' v1 font. Compare Offset<24> there. + * When 'COLR' v1 paint tables represented by FreeType objects such as + * @FT_PaintColrLayers, @FT_PaintComposite, or @FT_PaintTransform + * reference downstream nested paint tables, we do not immediately + * retrieve them but encapsulate their location in this type. Use + * @FT_Get_Paint to retrieve the actual @FT_COLR_Paint object that + * describes the details of the respective paint table. + * + * @fields: + * p :: + * An internal offset to a Paint table, needs to be set to NULL before + * passing this struct as an argument to @FT_Get_Paint. + * + * insert_root_transform :: + * An internal boolean to track whether an initial root transform is + * to be provided. Do not set this value. + * + * @since: + * 2.13 + */ + typedef struct FT_Opaque_Paint_ + { + FT_Byte* p; + FT_Bool insert_root_transform; + } FT_OpaquePaint; + + + /************************************************************************** + * + * @struct: + * FT_PaintColrLayers + * + * @description: + * A structure representing a `PaintColrLayers` table of a 'COLR' v1 + * font. This table describes a set of layers that are to be composited + * with composite mode `FT_COLR_COMPOSITE_SRC_OVER`. The return value + * of this function is an @FT_LayerIterator initialized so that it can + * be used with @FT_Get_Paint_Layers to retrieve the @FT_OpaquePaint + * objects as references to each layer. + * + * @fields: + * layer_iterator :: + * The layer iterator that describes the layers of this paint. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintColrLayers_ + { + FT_LayerIterator layer_iterator; + + } FT_PaintColrLayers; + + + /************************************************************************** + * + * @struct: + * FT_PaintSolid + * + * @description: + * A structure representing a `PaintSolid` value of the 'COLR' v1 + * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'. + * Using a `PaintSolid` value means that the glyph layer filled with + * this paint is solid-colored and does not contain a gradient. + * + * @fields: + * color :: + * The color information for this solid paint, see @FT_ColorIndex. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintSolid_ + { + FT_ColorIndex color; + + } FT_PaintSolid; + + + /************************************************************************** + * + * @struct: + * FT_PaintLinearGradient + * + * @description: + * A structure representing a `PaintLinearGradient` value of the 'COLR' + * v1 extensions, see + * 'https://github.com/googlefonts/colr-gradients-spec'. The glyph + * layer filled with this paint is drawn filled with a linear gradient. + * + * @fields: + * colorline :: + * The @FT_ColorLine information for this paint, i.e., the list of + * color stops along the gradient. + * + * p0 :: + * The starting point of the gradient definition in font units + * represented as a 16.16 fixed-point `FT_Vector`. + * + * p1 :: + * The end point of the gradient definition in font units + * represented as a 16.16 fixed-point `FT_Vector`. + * + * p2 :: + * Optional point~p2 to rotate the gradient in font units + * represented as a 16.16 fixed-point `FT_Vector`. + * Otherwise equal to~p0. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintLinearGradient_ + { + FT_ColorLine colorline; + + /* TODO: Potentially expose those as x0, y0 etc. */ + FT_Vector p0; + FT_Vector p1; + FT_Vector p2; + + } FT_PaintLinearGradient; + + + /************************************************************************** + * + * @struct: + * FT_PaintRadialGradient + * + * @description: + * A structure representing a `PaintRadialGradient` value of the 'COLR' + * v1 extensions, see + * 'https://github.com/googlefonts/colr-gradients-spec'. The glyph + * layer filled with this paint is drawn filled with a radial gradient. + * + * @fields: + * colorline :: + * The @FT_ColorLine information for this paint, i.e., the list of + * color stops along the gradient. + * + * c0 :: + * The center of the starting point of the radial gradient in font + * units represented as a 16.16 fixed-point `FT_Vector`. + * + * r0 :: + * The radius of the starting circle of the radial gradient in font + * units represented as a 16.16 fixed-point value. + * + * c1 :: + * The center of the end point of the radial gradient in font units + * represented as a 16.16 fixed-point `FT_Vector`. + * + * r1 :: + * The radius of the end circle of the radial gradient in font + * units represented as a 16.16 fixed-point value. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintRadialGradient_ + { + FT_ColorLine colorline; + + FT_Vector c0; + FT_Pos r0; + FT_Vector c1; + FT_Pos r1; + + } FT_PaintRadialGradient; + + + /************************************************************************** + * + * @struct: + * FT_PaintSweepGradient + * + * @description: + * A structure representing a `PaintSweepGradient` value of the 'COLR' + * v1 extensions, see + * 'https://github.com/googlefonts/colr-gradients-spec'. The glyph + * layer filled with this paint is drawn filled with a sweep gradient + * from `start_angle` to `end_angle`. + * + * @fields: + * colorline :: + * The @FT_ColorLine information for this paint, i.e., the list of + * color stops along the gradient. + * + * center :: + * The center of the sweep gradient in font units represented as a + * vector of 16.16 fixed-point values. + * + * start_angle :: + * The start angle of the sweep gradient in 16.16 fixed-point + * format specifying degrees divided by 180.0 (as in the + * spec). Multiply by 180.0f to receive degrees value. Values are + * given counter-clockwise, starting from the (positive) y~axis. + * + * end_angle :: + * The end angle of the sweep gradient in 16.16 fixed-point + * format specifying degrees divided by 180.0 (as in the + * spec). Multiply by 180.0f to receive degrees value. Values are + * given counter-clockwise, starting from the (positive) y~axis. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintSweepGradient_ + { + FT_ColorLine colorline; + + FT_Vector center; + FT_Fixed start_angle; + FT_Fixed end_angle; + + } FT_PaintSweepGradient; + + + /************************************************************************** + * + * @struct: + * FT_PaintGlyph + * + * @description: + * A structure representing a 'COLR' v1 `PaintGlyph` paint table. + * + * @fields: + * paint :: + * An opaque paint object pointing to a `Paint` table that serves as + * the fill for the glyph ID. + * + * glyphID :: + * The glyph ID from the 'glyf' table, which serves as the contour + * information that is filled with paint. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintGlyph_ + { + FT_OpaquePaint paint; + FT_UInt glyphID; + + } FT_PaintGlyph; + + + /************************************************************************** + * + * @struct: + * FT_PaintColrGlyph + * + * @description: + * A structure representing a 'COLR' v1 `PaintColorGlyph` paint table. + * + * @fields: + * glyphID :: + * The glyph ID from the `BaseGlyphV1List` table that is drawn for + * this paint. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintColrGlyph_ + { + FT_UInt glyphID; + + } FT_PaintColrGlyph; + + + /************************************************************************** + * + * @struct: + * FT_PaintTransform + * + * @description: + * A structure representing a 'COLR' v1 `PaintTransform` paint table. + * + * @fields: + * paint :: + * An opaque paint that is subject to being transformed. + * + * affine :: + * A 2x3 transformation matrix in @FT_Affine23 format containing + * 16.16 fixed-point values. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintTransform_ + { + FT_OpaquePaint paint; + FT_Affine23 affine; + + } FT_PaintTransform; + + + /************************************************************************** + * + * @struct: + * FT_PaintTranslate + * + * @description: + * A structure representing a 'COLR' v1 `PaintTranslate` paint table. + * Used for translating downstream paints by a given x and y~delta. + * + * @fields: + * paint :: + * An @FT_OpaquePaint object referencing the paint that is to be + * rotated. + * + * dx :: + * Translation in x~direction in font units represented as a + * 16.16 fixed-point value. + * + * dy :: + * Translation in y~direction in font units represented as a + * 16.16 fixed-point value. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintTranslate_ + { + FT_OpaquePaint paint; + + FT_Fixed dx; + FT_Fixed dy; + + } FT_PaintTranslate; + + + /************************************************************************** + * + * @struct: + * FT_PaintScale + * + * @description: + * A structure representing all of the 'COLR' v1 'PaintScale*' paint + * tables. Used for scaling downstream paints by a given x and y~scale, + * with a given center. This structure is used for all 'PaintScale*' + * types that are part of specification; fields of this structure are + * filled accordingly. If there is a center, the center values are set, + * otherwise they are set to the zero coordinate. If the source font + * file has 'PaintScaleUniform*' set, the scale values are set + * accordingly to the same value. + * + * @fields: + * paint :: + * An @FT_OpaquePaint object referencing the paint that is to be + * scaled. + * + * scale_x :: + * Scale factor in x~direction represented as a + * 16.16 fixed-point value. + * + * scale_y :: + * Scale factor in y~direction represented as a + * 16.16 fixed-point value. + * + * center_x :: + * x~coordinate of center point to scale from represented as a + * 16.16 fixed-point value. + * + * center_y :: + * y~coordinate of center point to scale from represented as a + * 16.16 fixed-point value. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintScale_ + { + FT_OpaquePaint paint; + + FT_Fixed scale_x; + FT_Fixed scale_y; + + FT_Fixed center_x; + FT_Fixed center_y; + + } FT_PaintScale; + + + /************************************************************************** + * + * @struct: + * FT_PaintRotate + * + * @description: + * A structure representing a 'COLR' v1 `PaintRotate` paint table. Used + * for rotating downstream paints with a given center and angle. + * + * @fields: + * paint :: + * An @FT_OpaquePaint object referencing the paint that is to be + * rotated. + * + * angle :: + * The rotation angle that is to be applied in degrees divided by + * 180.0 (as in the spec) represented as a 16.16 fixed-point + * value. Multiply by 180.0f to receive degrees value. + * + * center_x :: + * The x~coordinate of the pivot point of the rotation in font + * units represented as a 16.16 fixed-point value. + * + * center_y :: + * The y~coordinate of the pivot point of the rotation in font + * units represented as a 16.16 fixed-point value. + * + * @since: + * 2.13 + */ + + typedef struct FT_PaintRotate_ + { + FT_OpaquePaint paint; + + FT_Fixed angle; + + FT_Fixed center_x; + FT_Fixed center_y; + + } FT_PaintRotate; + + + /************************************************************************** + * + * @struct: + * FT_PaintSkew + * + * @description: + * A structure representing a 'COLR' v1 `PaintSkew` paint table. Used + * for skewing or shearing downstream paints by a given center and + * angle. + * + * @fields: + * paint :: + * An @FT_OpaquePaint object referencing the paint that is to be + * skewed. + * + * x_skew_angle :: + * The skewing angle in x~direction in degrees divided by 180.0 + * (as in the spec) represented as a 16.16 fixed-point + * value. Multiply by 180.0f to receive degrees. + * + * y_skew_angle :: + * The skewing angle in y~direction in degrees divided by 180.0 + * (as in the spec) represented as a 16.16 fixed-point + * value. Multiply by 180.0f to receive degrees. + * + * center_x :: + * The x~coordinate of the pivot point of the skew in font units + * represented as a 16.16 fixed-point value. + * + * center_y :: + * The y~coordinate of the pivot point of the skew in font units + * represented as a 16.16 fixed-point value. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintSkew_ + { + FT_OpaquePaint paint; + + FT_Fixed x_skew_angle; + FT_Fixed y_skew_angle; + + FT_Fixed center_x; + FT_Fixed center_y; + + } FT_PaintSkew; + + + /************************************************************************** + * + * @struct: + * FT_PaintComposite + * + * @description: + * A structure representing a 'COLR' v1 `PaintComposite` paint table. + * Used for compositing two paints in a 'COLR' v1 directed acyclic graph. + * + * @fields: + * source_paint :: + * An @FT_OpaquePaint object referencing the source that is to be + * composited. + * + * composite_mode :: + * An @FT_Composite_Mode enum value determining the composition + * operation. + * + * backdrop_paint :: + * An @FT_OpaquePaint object referencing the backdrop paint that + * `source_paint` is composited onto. + * + * @since: + * 2.13 + */ + typedef struct FT_PaintComposite_ + { + FT_OpaquePaint source_paint; + FT_Composite_Mode composite_mode; + FT_OpaquePaint backdrop_paint; + + } FT_PaintComposite; + + + /************************************************************************** + * + * @union: + * FT_COLR_Paint + * + * @description: + * A union object representing format and details of a paint table of a + * 'COLR' v1 font, see + * 'https://github.com/googlefonts/colr-gradients-spec'. Use + * @FT_Get_Paint to retrieve a @FT_COLR_Paint for an @FT_OpaquePaint + * object. + * + * @fields: + * format :: + * The gradient format for this Paint structure. + * + * u :: + * Union of all paint table types: + * + * * @FT_PaintColrLayers + * * @FT_PaintGlyph + * * @FT_PaintSolid + * * @FT_PaintLinearGradient + * * @FT_PaintRadialGradient + * * @FT_PaintSweepGradient + * * @FT_PaintTransform + * * @FT_PaintTranslate + * * @FT_PaintRotate + * * @FT_PaintSkew + * * @FT_PaintComposite + * * @FT_PaintColrGlyph + * + * @since: + * 2.13 + */ + typedef struct FT_COLR_Paint_ + { + FT_PaintFormat format; + + union + { + FT_PaintColrLayers colr_layers; + FT_PaintGlyph glyph; + FT_PaintSolid solid; + FT_PaintLinearGradient linear_gradient; + FT_PaintRadialGradient radial_gradient; + FT_PaintSweepGradient sweep_gradient; + FT_PaintTransform transform; + FT_PaintTranslate translate; + FT_PaintScale scale; + FT_PaintRotate rotate; + FT_PaintSkew skew; + FT_PaintComposite composite; + FT_PaintColrGlyph colr_glyph; + + } u; + + } FT_COLR_Paint; + + + /************************************************************************** + * + * @enum: + * FT_Color_Root_Transform + * + * @description: + * An enumeration to specify whether @FT_Get_Color_Glyph_Paint is to + * return a root transform to configure the client's graphics context + * matrix. + * + * @values: + * FT_COLOR_INCLUDE_ROOT_TRANSFORM :: + * Do include the root transform as the initial @FT_COLR_Paint object. + * + * FT_COLOR_NO_ROOT_TRANSFORM :: + * Do not output an initial root transform. + * + * @since: + * 2.13 + */ + typedef enum FT_Color_Root_Transform_ + { + FT_COLOR_INCLUDE_ROOT_TRANSFORM, + FT_COLOR_NO_ROOT_TRANSFORM, + + FT_COLOR_ROOT_TRANSFORM_MAX + + } FT_Color_Root_Transform; + + + /************************************************************************** + * + * @struct: + * FT_ClipBox + * + * @description: + * A structure representing a 'COLR' v1 'ClipBox' table. 'COLR' v1 + * glyphs may optionally define a clip box for aiding allocation or + * defining a maximum drawable region. Use @FT_Get_Color_Glyph_ClipBox + * to retrieve it. + * + * @fields: + * bottom_left :: + * The bottom left corner of the clip box as an @FT_Vector with + * fixed-point coordinates in 26.6 format. + * + * top_left :: + * The top left corner of the clip box as an @FT_Vector with + * fixed-point coordinates in 26.6 format. + * + * top_right :: + * The top right corner of the clip box as an @FT_Vector with + * fixed-point coordinates in 26.6 format. + * + * bottom_right :: + * The bottom right corner of the clip box as an @FT_Vector with + * fixed-point coordinates in 26.6 format. + * + * @since: + * 2.13 + */ + typedef struct FT_ClipBox_ + { + FT_Vector bottom_left; + FT_Vector top_left; + FT_Vector top_right; + FT_Vector bottom_right; + + } FT_ClipBox; + + + /************************************************************************** + * + * @function: + * FT_Get_Color_Glyph_Paint + * + * @description: + * This is the starting point and interface to color gradient + * information in a 'COLR' v1 table in OpenType fonts to recursively + * retrieve the paint tables for the directed acyclic graph of a colored + * glyph, given a glyph ID. + * + * https://github.com/googlefonts/colr-gradients-spec + * + * In a 'COLR' v1 font, each color glyph defines a directed acyclic + * graph of nested paint tables, such as `PaintGlyph`, `PaintSolid`, + * `PaintLinearGradient`, `PaintRadialGradient`, and so on. Using this + * function and specifying a glyph ID, one retrieves the root paint + * table for this glyph ID. + * + * This function allows control whether an initial root transform is + * returned to configure scaling, transform, and translation correctly + * on the client's graphics context. The initial root transform is + * computed and returned according to the values configured for @FT_Size + * and @FT_Set_Transform on the @FT_Face object, see below for details + * of the `root_transform` parameter. This has implications for a + * client 'COLR' v1 implementation: When this function returns an + * initially computed root transform, at the time of executing the + * @FT_PaintGlyph operation, the contours should be retrieved using + * @FT_Load_Glyph at unscaled, untransformed size. This is because the + * root transform applied to the graphics context will take care of + * correct scaling. + * + * Alternatively, to allow hinting of contours, at the time of executing + * @FT_Load_Glyph, the current graphics context transformation matrix + * can be decomposed into a scaling matrix and a remainder, and + * @FT_Load_Glyph can be used to retrieve the contours at scaled size. + * Care must then be taken to blit or clip to the graphics context with + * taking this remainder transformation into account. + * + * @input: + * face :: + * A handle to the parent face object. + * + * base_glyph :: + * The glyph index for which to retrieve the root paint table. + * + * root_transform :: + * Specifies whether an initially computed root is returned by the + * @FT_PaintTransform operation to account for the activated size + * (see @FT_Activate_Size) and the configured transform and translate + * (see @FT_Set_Transform). + * + * This root transform is returned before nodes of the glyph graph of + * the font are returned. Subsequent @FT_COLR_Paint structures + * contain unscaled and untransformed values. The inserted root + * transform enables the client application to apply an initial + * transform to its graphics context. When executing subsequent + * FT_COLR_Paint operations, values from @FT_COLR_Paint operations + * will ultimately be correctly scaled because of the root transform + * applied to the graphics context. Use + * @FT_COLOR_INCLUDE_ROOT_TRANSFORM to include the root transform, use + * @FT_COLOR_NO_ROOT_TRANSFORM to not include it. The latter may be + * useful when traversing the 'COLR' v1 glyph graph and reaching a + * @FT_PaintColrGlyph. When recursing into @FT_PaintColrGlyph and + * painting that inline, no additional root transform is needed as it + * has already been applied to the graphics context at the beginning + * of drawing this glyph. + * + * @output: + * paint :: + * The @FT_OpaquePaint object that references the actual paint table. + * + * The respective actual @FT_COLR_Paint object is retrieved via + * @FT_Get_Paint. + * + * @return: + * Value~1 if everything is OK. If no color glyph is found, or the root + * paint could not be retrieved, value~0 gets returned. In case of an + * error, value~0 is returned also. + * + * @since: + * 2.13 + */ + FT_EXPORT( FT_Bool ) + FT_Get_Color_Glyph_Paint( FT_Face face, + FT_UInt base_glyph, + FT_Color_Root_Transform root_transform, + FT_OpaquePaint* paint ); + + + /************************************************************************** + * + * @function: + * FT_Get_Color_Glyph_ClipBox + * + * @description: + * Search for a 'COLR' v1 clip box for the specified `base_glyph` and + * fill the `clip_box` parameter with the 'COLR' v1 'ClipBox' information + * if one is found. + * + * @input: + * face :: + * A handle to the parent face object. + * + * base_glyph :: + * The glyph index for which to retrieve the clip box. + * + * @output: + * clip_box :: + * The clip box for the requested `base_glyph` if one is found. The + * clip box is computed taking scale and transformations configured on + * the @FT_Face into account. @FT_ClipBox contains @FT_Vector values + * in 26.6 format. + * + * @return: + * Value~1 if a clip box is found. If no clip box is found or an error + * occured, value~0 is returned. + * + * @note: + * To retrieve the clip box in font units, reset scale to units-per-em + * and remove transforms configured using @FT_Set_Transform. + * + * @since: + * 2.13 + */ + FT_EXPORT( FT_Bool ) + FT_Get_Color_Glyph_ClipBox( FT_Face face, + FT_UInt base_glyph, + FT_ClipBox* clip_box ); + + + /************************************************************************** + * + * @function: + * FT_Get_Paint_Layers + * + * @description: + * Access the layers of a `PaintColrLayers` table. + * + * If the root paint of a color glyph, or a nested paint of a 'COLR' + * glyph is a `PaintColrLayers` table, this function retrieves the + * layers of the `PaintColrLayers` table. + * + * The @FT_PaintColrLayers object contains an @FT_LayerIterator, which + * is used here to iterate over the layers. Each layer is returned as + * an @FT_OpaquePaint object, which then can be used with @FT_Get_Paint + * to retrieve the actual paint object. + * + * @input: + * face :: + * A handle to the parent face object. + * + * @inout: + * iterator :: + * The @FT_LayerIterator from an @FT_PaintColrLayers object, for which + * the layers are to be retrieved. The internal state of the iterator + * is incremented after one call to this function for retrieving one + * layer. + * + * @output: + * paint :: + * The @FT_OpaquePaint object that references the actual paint table. + * The respective actual @FT_COLR_Paint object is retrieved via + * @FT_Get_Paint. + * + * @return: + * Value~1 if everything is OK. Value~0 gets returned when the paint + * object can not be retrieved or any other error occurs. + * + * @since: + * 2.13 + */ + FT_EXPORT( FT_Bool ) + FT_Get_Paint_Layers( FT_Face face, + FT_LayerIterator* iterator, + FT_OpaquePaint* paint ); + + + /************************************************************************** + * + * @function: + * FT_Get_Colorline_Stops + * + * @description: + * This is an interface to color gradient information in a 'COLR' v1 + * table in OpenType fonts to iteratively retrieve the gradient and + * solid fill information for colored glyph layers for a specified glyph + * ID. + * + * https://github.com/googlefonts/colr-gradients-spec + * + * @input: + * face :: + * A handle to the parent face object. + * + * @inout: + * iterator :: + * The retrieved @FT_ColorStopIterator, configured on an @FT_ColorLine, + * which in turn got retrieved via paint information in + * @FT_PaintLinearGradient or @FT_PaintRadialGradient. + * + * @output: + * color_stop :: + * Color index and alpha value for the retrieved color stop. + * + * @return: + * Value~1 if everything is OK. If there are no more color stops, + * value~0 gets returned. In case of an error, value~0 is returned + * also. + * + * @since: + * 2.13 + */ + FT_EXPORT( FT_Bool ) + FT_Get_Colorline_Stops( FT_Face face, + FT_ColorStop* color_stop, + FT_ColorStopIterator* iterator ); + + + /************************************************************************** + * + * @function: + * FT_Get_Paint + * + * @description: + * Access the details of a paint using an @FT_OpaquePaint opaque paint + * object, which internally stores the offset to the respective `Paint` + * object in the 'COLR' table. + * + * @input: + * face :: + * A handle to the parent face object. + * + * opaque_paint :: + * The opaque paint object for which the underlying @FT_COLR_Paint + * data is to be retrieved. + * + * @output: + * paint :: + * The specific @FT_COLR_Paint object containing information coming + * from one of the font's `Paint*` tables. + * + * @return: + * Value~1 if everything is OK. Value~0 if no details can be found for + * this paint or any other error occured. + * + * @since: + * 2.13 + */ + FT_EXPORT( FT_Bool ) + FT_Get_Paint( FT_Face face, + FT_OpaquePaint opaque_paint, + FT_COLR_Paint* paint ); + + /* */ + + +FT_END_HEADER + +#endif /* FTCOLOR_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftdriver.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftdriver.h new file mode 100644 index 0000000000000000000000000000000000000000..5c211a69323437d0916deb96389489c31995c91c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftdriver.h @@ -0,0 +1,1320 @@ +/**************************************************************************** + * + * ftdriver.h + * + * FreeType API for controlling driver modules (specification only). + * + * Copyright (C) 2017-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTDRIVER_H_ +#define FTDRIVER_H_ + +#include +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * auto_hinter + * + * @title: + * The auto-hinter + * + * @abstract: + * Controlling the auto-hinting module. + * + * @description: + * While FreeType's auto-hinter doesn't expose API functions by itself, + * it is possible to control its behaviour with @FT_Property_Set and + * @FT_Property_Get. The following lists the available properties + * together with the necessary macros and structures. + * + * Note that the auto-hinter's module name is 'autofitter' for historical + * reasons. + * + * Available properties are @increase-x-height, @no-stem-darkening + * (experimental), @darkening-parameters (experimental), + * @glyph-to-script-map (experimental), @fallback-script (experimental), + * and @default-script (experimental), as documented in the @properties + * section. + * + */ + + + /************************************************************************** + * + * @section: + * cff_driver + * + * @title: + * The CFF driver + * + * @abstract: + * Controlling the CFF driver module. + * + * @description: + * While FreeType's CFF driver doesn't expose API functions by itself, it + * is possible to control its behaviour with @FT_Property_Set and + * @FT_Property_Get. + * + * The CFF driver's module name is 'cff'. + * + * Available properties are @hinting-engine, @no-stem-darkening, + * @darkening-parameters, and @random-seed, as documented in the + * @properties section. + * + * + * **Hinting and anti-aliasing principles of the new engine** + * + * The rasterizer is positioning horizontal features (e.g., ascender + * height & x-height, or crossbars) on the pixel grid and minimizing the + * amount of anti-aliasing applied to them, while placing vertical + * features (vertical stems) on the pixel grid without hinting, thus + * representing the stem position and weight accurately. Sometimes the + * vertical stems may be only partially black. In this context, + * 'anti-aliasing' means that stems are not positioned exactly on pixel + * borders, causing a fuzzy appearance. + * + * There are two principles behind this approach. + * + * 1) No hinting in the horizontal direction: Unlike 'superhinted' + * TrueType, which changes glyph widths to accommodate regular + * inter-glyph spacing, Adobe's approach is 'faithful to the design' in + * representing both the glyph width and the inter-glyph spacing designed + * for the font. This makes the screen display as close as it can be to + * the result one would get with infinite resolution, while preserving + * what is considered the key characteristics of each glyph. Note that + * the distances between unhinted and grid-fitted positions at small + * sizes are comparable to kerning values and thus would be noticeable + * (and distracting) while reading if hinting were applied. + * + * One of the reasons to not hint horizontally is anti-aliasing for LCD + * screens: The pixel geometry of modern displays supplies three vertical + * subpixels as the eye moves horizontally across each visible pixel. On + * devices where we can be certain this characteristic is present a + * rasterizer can take advantage of the subpixels to add increments of + * weight. In Western writing systems this turns out to be the more + * critical direction anyway; the weights and spacing of vertical stems + * (see above) are central to Armenian, Cyrillic, Greek, and Latin type + * designs. Even when the rasterizer uses greyscale anti-aliasing instead + * of color (a necessary compromise when one doesn't know the screen + * characteristics), the unhinted vertical features preserve the design's + * weight and spacing much better than aliased type would. + * + * 2) Alignment in the vertical direction: Weights and spacing along the + * y~axis are less critical; what is much more important is the visual + * alignment of related features (like cap-height and x-height). The + * sense of alignment for these is enhanced by the sharpness of grid-fit + * edges, while the cruder vertical resolution (full pixels instead of + * 1/3 pixels) is less of a problem. + * + * On the technical side, horizontal alignment zones for ascender, + * x-height, and other important height values (traditionally called + * 'blue zones') as defined in the font are positioned independently, + * each being rounded to the nearest pixel edge, taking care of overshoot + * suppression at small sizes, stem darkening, and scaling. + * + * Hstems (that is, hint values defined in the font to help align + * horizontal features) that fall within a blue zone are said to be + * 'captured' and are aligned to that zone. Uncaptured stems are moved + * in one of four ways, top edge up or down, bottom edge up or down. + * Unless there are conflicting hstems, the smallest movement is taken to + * minimize distortion. + * + */ + + + /************************************************************************** + * + * @section: + * pcf_driver + * + * @title: + * The PCF driver + * + * @abstract: + * Controlling the PCF driver module. + * + * @description: + * While FreeType's PCF driver doesn't expose API functions by itself, it + * is possible to control its behaviour with @FT_Property_Set and + * @FT_Property_Get. Right now, there is a single property + * @no-long-family-names available if FreeType is compiled with + * PCF_CONFIG_OPTION_LONG_FAMILY_NAMES. + * + * The PCF driver's module name is 'pcf'. + * + */ + + + /************************************************************************** + * + * @section: + * t1_cid_driver + * + * @title: + * The Type 1 and CID drivers + * + * @abstract: + * Controlling the Type~1 and CID driver modules. + * + * @description: + * It is possible to control the behaviour of FreeType's Type~1 and + * Type~1 CID drivers with @FT_Property_Set and @FT_Property_Get. + * + * Behind the scenes, both drivers use the Adobe CFF engine for hinting; + * however, the used properties must be specified separately. + * + * The Type~1 driver's module name is 'type1'; the CID driver's module + * name is 't1cid'. + * + * Available properties are @hinting-engine, @no-stem-darkening, + * @darkening-parameters, and @random-seed, as documented in the + * @properties section. + * + * Please see the @cff_driver section for more details on the new hinting + * engine. + * + */ + + + /************************************************************************** + * + * @section: + * tt_driver + * + * @title: + * The TrueType driver + * + * @abstract: + * Controlling the TrueType driver module. + * + * @description: + * While FreeType's TrueType driver doesn't expose API functions by + * itself, it is possible to control its behaviour with @FT_Property_Set + * and @FT_Property_Get. + * + * The TrueType driver's module name is 'truetype'; a single property + * @interpreter-version is available, as documented in the @properties + * section. + * + * To help understand the differences between interpreter versions, we + * introduce a list of definitions, kindly provided by Greg Hitchcock. + * + * _Bi-Level Rendering_ + * + * Monochromatic rendering, exclusively used in the early days of + * TrueType by both Apple and Microsoft. Microsoft's GDI interface + * supported hinting of the right-side bearing point, such that the + * advance width could be non-linear. Most often this was done to + * achieve some level of glyph symmetry. To enable reasonable + * performance (e.g., not having to run hinting on all glyphs just to get + * the widths) there was a bit in the head table indicating if the side + * bearing was hinted, and additional tables, 'hdmx' and 'LTSH', to cache + * hinting widths across multiple sizes and device aspect ratios. + * + * _Font Smoothing_ + * + * Microsoft's GDI implementation of anti-aliasing. Not traditional + * anti-aliasing as the outlines were hinted before the sampling. The + * widths matched the bi-level rendering. + * + * _ClearType Rendering_ + * + * Technique that uses physical subpixels to improve rendering on LCD + * (and other) displays. Because of the higher resolution, many methods + * of improving symmetry in glyphs through hinting the right-side bearing + * were no longer necessary. This lead to what GDI calls 'natural + * widths' ClearType, see + * http://rastertragedy.com/RTRCh4.htm#Sec21. Since hinting + * has extra resolution, most non-linearity went away, but it is still + * possible for hints to change the advance widths in this mode. + * + * _ClearType Compatible Widths_ + * + * One of the earliest challenges with ClearType was allowing the + * implementation in GDI to be selected without requiring all UI and + * documents to reflow. To address this, a compatible method of + * rendering ClearType was added where the font hints are executed once + * to determine the width in bi-level rendering, and then re-run in + * ClearType, with the difference in widths being absorbed in the font + * hints for ClearType (mostly in the white space of hints); see + * http://rastertragedy.com/RTRCh4.htm#Sec20. Somewhat by + * definition, compatible width ClearType allows for non-linear widths, + * but only when the bi-level version has non-linear widths. + * + * _ClearType Subpixel Positioning_ + * + * One of the nice benefits of ClearType is the ability to more crisply + * display fractional widths; unfortunately, the GDI model of integer + * bitmaps did not support this. However, the WPF and Direct Write + * frameworks do support fractional widths. DWrite calls this 'natural + * mode', not to be confused with GDI's 'natural widths'. Subpixel + * positioning, in the current implementation of Direct Write, + * unfortunately does not support hinted advance widths, see + * http://rastertragedy.com/RTRCh4.htm#Sec22. Note that the + * TrueType interpreter fully allows the advance width to be adjusted in + * this mode, just the DWrite client will ignore those changes. + * + * _ClearType Backward Compatibility_ + * + * This is a set of exceptions made in the TrueType interpreter to + * minimize hinting techniques that were problematic with the extra + * resolution of ClearType; see + * http://rastertragedy.com/RTRCh4.htm#Sec1 and + * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx. + * This technique is not to be confused with ClearType compatible widths. + * ClearType backward compatibility has no direct impact on changing + * advance widths, but there might be an indirect impact on disabling + * some deltas. This could be worked around in backward compatibility + * mode. + * + * _Native ClearType Mode_ + * + * (Not to be confused with 'natural widths'.) This mode removes all the + * exceptions in the TrueType interpreter when running with ClearType. + * Any issues on widths would still apply, though. + * + */ + + + /************************************************************************** + * + * @section: + * ot_svg_driver + * + * @title: + * The SVG driver + * + * @abstract: + * Controlling the external rendering of OT-SVG glyphs. + * + * @description: + * By default, FreeType can only load the 'SVG~' table of OpenType fonts + * if configuration macro `FT_CONFIG_OPTION_SVG` is defined. To make it + * render SVG glyphs, an external SVG rendering library is needed. All + * details on the interface between FreeType and the external library + * via function hooks can be found in section @svg_fonts. + * + * The OT-SVG driver's module name is 'ot-svg'; it supports a single + * property called @svg-hooks, documented below in the @properties + * section. + * + */ + + + /************************************************************************** + * + * @section: + * properties + * + * @title: + * Driver properties + * + * @abstract: + * Controlling driver modules. + * + * @description: + * Driver modules can be controlled by setting and unsetting properties, + * using the functions @FT_Property_Set and @FT_Property_Get. This + * section documents the available properties, together with auxiliary + * macros and structures. + * + */ + + + /************************************************************************** + * + * @enum: + * FT_HINTING_XXX + * + * @description: + * A list of constants used for the @hinting-engine property to select + * the hinting engine for CFF, Type~1, and CID fonts. + * + * @values: + * FT_HINTING_FREETYPE :: + * Use the old FreeType hinting engine. + * + * FT_HINTING_ADOBE :: + * Use the hinting engine contributed by Adobe. + * + * @since: + * 2.9 + * + */ +#define FT_HINTING_FREETYPE 0 +#define FT_HINTING_ADOBE 1 + + /* these constants (introduced in 2.4.12) are deprecated */ +#define FT_CFF_HINTING_FREETYPE FT_HINTING_FREETYPE +#define FT_CFF_HINTING_ADOBE FT_HINTING_ADOBE + + + /************************************************************************** + * + * @property: + * hinting-engine + * + * @description: + * Thanks to Adobe, which contributed a new hinting (and parsing) engine, + * an application can select between 'freetype' and 'adobe' if compiled + * with `CFF_CONFIG_OPTION_OLD_ENGINE`. If this configuration macro + * isn't defined, 'hinting-engine' does nothing. + * + * The same holds for the Type~1 and CID modules if compiled with + * `T1_CONFIG_OPTION_OLD_ENGINE`. + * + * For the 'cff' module, the default engine is 'adobe'. For both the + * 'type1' and 't1cid' modules, the default engine is 'adobe', too. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 'adobe' or 'freetype'). + * + * @example: + * The following example code demonstrates how to select Adobe's hinting + * engine for the 'cff' module (omitting the error handling). + * + * ``` + * FT_Library library; + * FT_UInt hinting_engine = FT_HINTING_ADOBE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "cff", + * "hinting-engine", &hinting_engine ); + * ``` + * + * @since: + * 2.4.12 (for 'cff' module) + * + * 2.9 (for 'type1' and 't1cid' modules) + * + */ + + + /************************************************************************** + * + * @property: + * no-stem-darkening + * + * @description: + * All glyphs that pass through the auto-hinter will be emboldened unless + * this property is set to TRUE. The same is true for the CFF, Type~1, + * and CID font modules if the 'Adobe' engine is selected (which is the + * default). + * + * Stem darkening emboldens glyphs at smaller sizes to make them more + * readable on common low-DPI screens when using linear alpha blending + * and gamma correction, see @FT_Render_Glyph. When not using linear + * alpha blending and gamma correction, glyphs will appear heavy and + * fuzzy! + * + * Gamma correction essentially lightens fonts since shades of grey are + * shifted to higher pixel values (=~higher brightness) to match the + * original intention to the reality of our screens. The side-effect is + * that glyphs 'thin out'. Mac OS~X and Adobe's proprietary font + * rendering library implement a counter-measure: stem darkening at + * smaller sizes where shades of gray dominate. By emboldening a glyph + * slightly in relation to its pixel size, individual pixels get higher + * coverage of filled-in outlines and are therefore 'blacker'. This + * counteracts the 'thinning out' of glyphs, making text remain readable + * at smaller sizes. + * + * For the auto-hinter, stem-darkening is experimental currently and thus + * switched off by default (that is, `no-stem-darkening` is set to TRUE + * by default). Total consistency with the CFF driver is not achieved + * right now because the emboldening method differs and glyphs must be + * scaled down on the Y-axis to keep outline points inside their + * precomputed blue zones. The smaller the size (especially 9ppem and + * down), the higher the loss of emboldening versus the CFF driver. + * + * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is set. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 1 and 0 for 'on' and 'off', respectively). It + * can also be set per face using @FT_Face_Properties with + * @FT_PARAM_TAG_STEM_DARKENING. + * + * @example: + * ``` + * FT_Library library; + * FT_Bool no_stem_darkening = TRUE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "cff", + * "no-stem-darkening", &no_stem_darkening ); + * ``` + * + * @since: + * 2.4.12 (for 'cff' module) + * + * 2.6.2 (for 'autofitter' module) + * + * 2.9 (for 'type1' and 't1cid' modules) + * + */ + + + /************************************************************************** + * + * @property: + * darkening-parameters + * + * @description: + * By default, the Adobe hinting engine, as used by the CFF, Type~1, and + * CID font drivers, darkens stems as follows (if the `no-stem-darkening` + * property isn't set): + * + * ``` + * stem width <= 0.5px: darkening amount = 0.4px + * stem width = 1px: darkening amount = 0.275px + * stem width = 1.667px: darkening amount = 0.275px + * stem width >= 2.333px: darkening amount = 0px + * ``` + * + * and piecewise linear in-between. At configuration time, these four + * control points can be set with the macro + * `CFF_CONFIG_OPTION_DARKENING_PARAMETERS`; the CFF, Type~1, and CID + * drivers share these values. At runtime, the control points can be + * changed using the `darkening-parameters` property (see the example + * below that demonstrates this for the Type~1 driver). + * + * The x~values give the stem width, and the y~values the darkening + * amount. The unit is 1000th of pixels. All coordinate values must be + * positive; the x~values must be monotonically increasing; the y~values + * must be monotonically decreasing and smaller than or equal to 500 + * (corresponding to half a pixel); the slope of each linear piece must + * be shallower than -1 (e.g., -.4). + * + * The auto-hinter provides this property, too, as an experimental + * feature. See @no-stem-darkening for more. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable, using eight comma-separated integers without spaces. Here + * the above example, using `\` to break the line for readability. + * + * ``` + * FREETYPE_PROPERTIES=\ + * type1:darkening-parameters=500,300,1000,200,1500,100,2000,0 + * ``` + * + * @example: + * ``` + * FT_Library library; + * FT_Int darken_params[8] = { 500, 300, // x1, y1 + * 1000, 200, // x2, y2 + * 1500, 100, // x3, y3 + * 2000, 0 }; // x4, y4 + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "type1", + * "darkening-parameters", darken_params ); + * ``` + * + * @since: + * 2.5.1 (for 'cff' module) + * + * 2.6.2 (for 'autofitter' module) + * + * 2.9 (for 'type1' and 't1cid' modules) + * + */ + + + /************************************************************************** + * + * @property: + * random-seed + * + * @description: + * By default, the seed value for the CFF 'random' operator and the + * similar '0 28 callothersubr pop' command for the Type~1 and CID + * drivers is set to a random value. However, mainly for debugging + * purposes, it is often necessary to use a known value as a seed so that + * the pseudo-random number sequences generated by 'random' are + * repeatable. + * + * The `random-seed` property does that. Its argument is a signed 32bit + * integer; if the value is zero or negative, the seed given by the + * `intitialRandomSeed` private DICT operator in a CFF file gets used (or + * a default value if there is no such operator). If the value is + * positive, use it instead of `initialRandomSeed`, which is consequently + * ignored. + * + * @note: + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable. It can also be set per face using @FT_Face_Properties with + * @FT_PARAM_TAG_RANDOM_SEED. + * + * @since: + * 2.8 (for 'cff' module) + * + * 2.9 (for 'type1' and 't1cid' modules) + * + */ + + + /************************************************************************** + * + * @property: + * no-long-family-names + * + * @description: + * If `PCF_CONFIG_OPTION_LONG_FAMILY_NAMES` is active while compiling + * FreeType, the PCF driver constructs long family names. + * + * There are many PCF fonts just called 'Fixed' which look completely + * different, and which have nothing to do with each other. When + * selecting 'Fixed' in KDE or Gnome one gets results that appear rather + * random, the style changes often if one changes the size and one cannot + * select some fonts at all. The improve this situation, the PCF module + * prepends the foundry name (plus a space) to the family name. It also + * checks whether there are 'wide' characters; all put together, family + * names like 'Sony Fixed' or 'Misc Fixed Wide' are constructed. + * + * If `no-long-family-names` is set, this feature gets switched off. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 1 and 0 for 'on' and 'off', respectively). + * + * @example: + * ``` + * FT_Library library; + * FT_Bool no_long_family_names = TRUE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "pcf", + * "no-long-family-names", + * &no_long_family_names ); + * ``` + * + * @since: + * 2.8 + */ + + + /************************************************************************** + * + * @enum: + * TT_INTERPRETER_VERSION_XXX + * + * @description: + * A list of constants used for the @interpreter-version property to + * select the hinting engine for Truetype fonts. + * + * The numeric value in the constant names represents the version number + * as returned by the 'GETINFO' bytecode instruction. + * + * @values: + * TT_INTERPRETER_VERSION_35 :: + * Version~35 corresponds to MS rasterizer v.1.7 as used e.g. in + * Windows~98; only grayscale and B/W rasterizing is supported. + * + * TT_INTERPRETER_VERSION_38 :: + * Version~38 is the same Version~40. The original 'Infinality' code is + * no longer available. + * + * TT_INTERPRETER_VERSION_40 :: + * Version~40 corresponds to MS rasterizer v.2.1; it is roughly + * equivalent to the hinting provided by DirectWrite ClearType (as can + * be found, for example, in Microsoft's Edge Browser on Windows~10). + * It is used in FreeType to select the 'minimal' subpixel hinting + * code, a stripped-down and higher performance version of the + * 'Infinality' code. + * + * @note: + * This property controls the behaviour of the bytecode interpreter and + * thus how outlines get hinted. It does **not** control how glyph get + * rasterized! In particular, it does not control subpixel color + * filtering. + * + * If FreeType has not been compiled with the configuration option + * `TT_CONFIG_OPTION_SUBPIXEL_HINTING`, selecting version~38 or~40 causes + * an `FT_Err_Unimplemented_Feature` error. + * + * Depending on the graphics framework, Microsoft uses different bytecode + * and rendering engines. As a consequence, the version numbers returned + * by a call to the 'GETINFO' bytecode instruction are more convoluted + * than desired. + * + * Here are two tables that try to shed some light on the possible values + * for the MS rasterizer engine, together with the additional features + * introduced by it. + * + * ``` + * GETINFO framework version feature + * ------------------------------------------------------------------- + * 3 GDI (Win 3.1), v1.0 16-bit, first version + * TrueImage + * 33 GDI (Win NT 3.1), v1.5 32-bit + * HP Laserjet + * 34 GDI (Win 95) v1.6 font smoothing, + * new SCANTYPE opcode + * 35 GDI (Win 98/2000) v1.7 (UN)SCALED_COMPONENT_OFFSET + * bits in composite glyphs + * 36 MGDI (Win CE 2) v1.6+ classic ClearType + * 37 GDI (XP and later), v1.8 ClearType + * GDI+ old (before Vista) + * 38 GDI+ old (Vista, Win 7), v1.9 subpixel ClearType, + * WPF Y-direction ClearType, + * additional error checking + * 39 DWrite (before Win 8) v2.0 subpixel ClearType flags + * in GETINFO opcode, + * bug fixes + * 40 GDI+ (after Win 7), v2.1 Y-direction ClearType flag + * DWrite (Win 8) in GETINFO opcode, + * Gray ClearType + * ``` + * + * The 'version' field gives a rough orientation only, since some + * applications provided certain features much earlier (as an example, + * Microsoft Reader used subpixel and Y-direction ClearType already in + * Windows 2000). Similarly, updates to a given framework might include + * improved hinting support. + * + * ``` + * version sampling rendering comment + * x y x y + * -------------------------------------------------------------- + * v1.0 normal normal B/W B/W bi-level + * v1.6 high high gray gray grayscale + * v1.8 high normal color-filter B/W (GDI) ClearType + * v1.9 high high color-filter gray Color ClearType + * v2.1 high normal gray B/W Gray ClearType + * v2.1 high high gray gray Gray ClearType + * ``` + * + * Color and Gray ClearType are the two available variants of + * 'Y-direction ClearType', meaning grayscale rasterization along the + * Y-direction; the name used in the TrueType specification for this + * feature is 'symmetric smoothing'. 'Classic ClearType' is the original + * algorithm used before introducing a modified version in Win~XP. + * Another name for v1.6's grayscale rendering is 'font smoothing', and + * 'Color ClearType' is sometimes also called 'DWrite ClearType'. To + * differentiate between today's Color ClearType and the earlier + * ClearType variant with B/W rendering along the vertical axis, the + * latter is sometimes called 'GDI ClearType'. + * + * 'Normal' and 'high' sampling describe the (virtual) resolution to + * access the rasterized outline after the hinting process. 'Normal' + * means 1 sample per grid line (i.e., B/W). In the current Microsoft + * implementation, 'high' means an extra virtual resolution of 16x16 (or + * 16x1) grid lines per pixel for bytecode instructions like 'MIRP'. + * After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid + * lines for color filtering if Color ClearType is activated. + * + * Note that 'Gray ClearType' is essentially the same as v1.6's grayscale + * rendering. However, the GETINFO instruction handles it differently: + * v1.6 returns bit~12 (hinting for grayscale), while v2.1 returns + * bits~13 (hinting for ClearType), 18 (symmetrical smoothing), and~19 + * (Gray ClearType). Also, this mode respects bits 2 and~3 for the + * version~1 gasp table exclusively (like Color ClearType), while v1.6 + * only respects the values of version~0 (bits 0 and~1). + * + * Keep in mind that the features of the above interpreter versions might + * not map exactly to FreeType features or behavior because it is a + * fundamentally different library with different internals. + * + */ +#define TT_INTERPRETER_VERSION_35 35 +#define TT_INTERPRETER_VERSION_38 38 +#define TT_INTERPRETER_VERSION_40 40 + + + /************************************************************************** + * + * @property: + * interpreter-version + * + * @description: + * Currently, three versions are available, two representing the bytecode + * interpreter with subpixel hinting support (old 'Infinality' code and + * new stripped-down and higher performance 'minimal' code) and one + * without, respectively. The default is subpixel support if + * `TT_CONFIG_OPTION_SUBPIXEL_HINTING` is defined, and no subpixel + * support otherwise (since it isn't available then). + * + * If subpixel hinting is on, many TrueType bytecode instructions behave + * differently compared to B/W or grayscale rendering (except if 'native + * ClearType' is selected by the font). Microsoft's main idea is to + * render at a much increased horizontal resolution, then sampling down + * the created output to subpixel precision. However, many older fonts + * are not suited to this and must be specially taken care of by applying + * (hardcoded) tweaks in Microsoft's interpreter. + * + * Details on subpixel hinting and some of the necessary tweaks can be + * found in Greg Hitchcock's whitepaper at + * 'https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'. + * Note that FreeType currently doesn't really 'subpixel hint' (6x1, 6x2, + * or 6x5 supersampling) like discussed in the paper. Depending on the + * chosen interpreter, it simply ignores instructions on vertical stems + * to arrive at very similar results. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values '35', '38', or '40'). + * + * @example: + * The following example code demonstrates how to deactivate subpixel + * hinting (omitting the error handling). + * + * ``` + * FT_Library library; + * FT_Face face; + * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_35; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "truetype", + * "interpreter-version", + * &interpreter_version ); + * ``` + * + * @since: + * 2.5 + */ + + + /************************************************************************** + * + * @property: + * spread + * + * @description: + * This property of the 'sdf' and 'bsdf' renderers defines how the signed + * distance field (SDF) is represented in the output bitmap. The output + * values are calculated as follows, '128 * ( SDF / spread + 1 )', with + * the result clamped to the 8-bit range [0..255]. Therefore, 'spread' + * is also the maximum euclidean distance from the edge after which the + * values are clamped. The spread is specified in pixels with the + * default value of 8. For accurate SDF texture mapping (interpolation), + * the spread should be large enough to accommodate the target grid unit. + * + * @example: + * The following example code demonstrates how to set the SDF spread + * (omitting the error handling). + * + * ``` + * FT_Library library; + * FT_Int spread = 2; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "sdf", "spread", &spread ); + * ``` + * + * @note: + * FreeType has two rasterizers for generating SDF, namely: + * + * 1. `sdf` for generating SDF directly from glyph's outline, and + * + * 2. `bsdf` for generating SDF from rasterized bitmaps. + * + * Depending on the glyph type (i.e., outline or bitmap), one of the two + * rasterizers is chosen at runtime and used for generating SDFs. To + * force the use of `bsdf` you should render the glyph with any of the + * FreeType's other rendering modes (e.g., `FT_RENDER_MODE_NORMAL`) and + * then re-render with `FT_RENDER_MODE_SDF`. + * + * There are some issues with stability and possible failures of the SDF + * renderers (specifically `sdf`). + * + * 1. The `sdf` rasterizer is sensitive to really small features (e.g., + * sharp turns that are less than 1~pixel) and imperfections in the + * glyph's outline, causing artifacts in the final output. + * + * 2. The `sdf` rasterizer has limited support for handling intersecting + * contours and *cannot* handle self-intersecting contours whatsoever. + * Self-intersection happens when a single connected contour + * intersects itself at some point; having these in your font + * definitely poses a problem to the rasterizer and cause artifacts, + * too. + * + * 3. Generating SDF for really small glyphs may result in undesirable + * output; the pixel grid (which stores distance information) becomes + * too coarse. + * + * 4. Since the output buffer is normalized, precision at smaller spreads + * is greater than precision at larger spread values because the + * output range of [0..255] gets mapped to a smaller SDF range. A + * spread of~2 should be sufficient in most cases. + * + * Points (1) and (2) can be avoided by using the `bsdf` rasterizer, + * which is more stable than the `sdf` rasterizer in general. + * + * @since: + * 2.11 + */ + + + /************************************************************************** + * + * @property: + * svg-hooks + * + * @description: + * Set up the interface between FreeType and an extern SVG rendering + * library like 'librsvg'. All details on the function hooks can be + * found in section @svg_fonts. + * + * @example: + * The following example code expects that the four hook functions + * `svg_*` are defined elsewhere. Error handling is omitted, too. + * + * ``` + * FT_Library library; + * SVG_RendererHooks hooks = { + * (SVG_Lib_Init_Func)svg_init, + * (SVG_Lib_Free_Func)svg_free, + * (SVG_Lib_Render_Func)svg_render, + * (SVG_Lib_Preset_Slot_Func)svg_preset_slot }; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "ot-svg", + * "svg-hooks", &hooks ); + * ``` + * + * @since: + * 2.12 + */ + + + /************************************************************************** + * + * @property: + * glyph-to-script-map + * + * @description: + * **Experimental only** + * + * The auto-hinter provides various script modules to hint glyphs. + * Examples of supported scripts are Latin or CJK. Before a glyph is + * auto-hinted, the Unicode character map of the font gets examined, and + * the script is then determined based on Unicode character ranges, see + * below. + * + * OpenType fonts, however, often provide much more glyphs than character + * codes (small caps, superscripts, ligatures, swashes, etc.), to be + * controlled by so-called 'features'. Handling OpenType features can be + * quite complicated and thus needs a separate library on top of + * FreeType. + * + * The mapping between glyph indices and scripts (in the auto-hinter + * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an array + * with `num_glyphs` elements, as found in the font's @FT_Face structure. + * The `glyph-to-script-map` property returns a pointer to this array, + * which can be modified as needed. Note that the modification should + * happen before the first glyph gets processed by the auto-hinter so + * that the global analysis of the font shapes actually uses the modified + * mapping. + * + * @example: + * The following example code demonstrates how to access it (omitting the + * error handling). + * + * ``` + * FT_Library library; + * FT_Face face; + * FT_Prop_GlyphToScriptMap prop; + * + * + * FT_Init_FreeType( &library ); + * FT_New_Face( library, "foo.ttf", 0, &face ); + * + * prop.face = face; + * + * FT_Property_Get( library, "autofitter", + * "glyph-to-script-map", &prop ); + * + * // adjust `prop.map' as needed right here + * + * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT ); + * ``` + * + * @since: + * 2.4.11 + * + */ + + + /************************************************************************** + * + * @enum: + * FT_AUTOHINTER_SCRIPT_XXX + * + * @description: + * **Experimental only** + * + * A list of constants used for the @glyph-to-script-map property to + * specify the script submodule the auto-hinter should use for hinting a + * particular glyph. + * + * @values: + * FT_AUTOHINTER_SCRIPT_NONE :: + * Don't auto-hint this glyph. + * + * FT_AUTOHINTER_SCRIPT_LATIN :: + * Apply the latin auto-hinter. For the auto-hinter, 'latin' is a very + * broad term, including Cyrillic and Greek also since characters from + * those scripts share the same design constraints. + * + * By default, characters from the following Unicode ranges are + * assigned to this submodule. + * + * ``` + * U+0020 - U+007F // Basic Latin (no control characters) + * U+00A0 - U+00FF // Latin-1 Supplement (no control characters) + * U+0100 - U+017F // Latin Extended-A + * U+0180 - U+024F // Latin Extended-B + * U+0250 - U+02AF // IPA Extensions + * U+02B0 - U+02FF // Spacing Modifier Letters + * U+0300 - U+036F // Combining Diacritical Marks + * U+0370 - U+03FF // Greek and Coptic + * U+0400 - U+04FF // Cyrillic + * U+0500 - U+052F // Cyrillic Supplement + * U+1D00 - U+1D7F // Phonetic Extensions + * U+1D80 - U+1DBF // Phonetic Extensions Supplement + * U+1DC0 - U+1DFF // Combining Diacritical Marks Supplement + * U+1E00 - U+1EFF // Latin Extended Additional + * U+1F00 - U+1FFF // Greek Extended + * U+2000 - U+206F // General Punctuation + * U+2070 - U+209F // Superscripts and Subscripts + * U+20A0 - U+20CF // Currency Symbols + * U+2150 - U+218F // Number Forms + * U+2460 - U+24FF // Enclosed Alphanumerics + * U+2C60 - U+2C7F // Latin Extended-C + * U+2DE0 - U+2DFF // Cyrillic Extended-A + * U+2E00 - U+2E7F // Supplemental Punctuation + * U+A640 - U+A69F // Cyrillic Extended-B + * U+A720 - U+A7FF // Latin Extended-D + * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures) + * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols + * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement + * ``` + * + * FT_AUTOHINTER_SCRIPT_CJK :: + * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old + * Vietnamese, and some other scripts. + * + * By default, characters from the following Unicode ranges are + * assigned to this submodule. + * + * ``` + * U+1100 - U+11FF // Hangul Jamo + * U+2E80 - U+2EFF // CJK Radicals Supplement + * U+2F00 - U+2FDF // Kangxi Radicals + * U+2FF0 - U+2FFF // Ideographic Description Characters + * U+3000 - U+303F // CJK Symbols and Punctuation + * U+3040 - U+309F // Hiragana + * U+30A0 - U+30FF // Katakana + * U+3100 - U+312F // Bopomofo + * U+3130 - U+318F // Hangul Compatibility Jamo + * U+3190 - U+319F // Kanbun + * U+31A0 - U+31BF // Bopomofo Extended + * U+31C0 - U+31EF // CJK Strokes + * U+31F0 - U+31FF // Katakana Phonetic Extensions + * U+3200 - U+32FF // Enclosed CJK Letters and Months + * U+3300 - U+33FF // CJK Compatibility + * U+3400 - U+4DBF // CJK Unified Ideographs Extension A + * U+4DC0 - U+4DFF // Yijing Hexagram Symbols + * U+4E00 - U+9FFF // CJK Unified Ideographs + * U+A960 - U+A97F // Hangul Jamo Extended-A + * U+AC00 - U+D7AF // Hangul Syllables + * U+D7B0 - U+D7FF // Hangul Jamo Extended-B + * U+F900 - U+FAFF // CJK Compatibility Ideographs + * U+FE10 - U+FE1F // Vertical forms + * U+FE30 - U+FE4F // CJK Compatibility Forms + * U+FF00 - U+FFEF // Halfwidth and Fullwidth Forms + * U+1B000 - U+1B0FF // Kana Supplement + * U+1D300 - U+1D35F // Tai Xuan Hing Symbols + * U+1F200 - U+1F2FF // Enclosed Ideographic Supplement + * U+20000 - U+2A6DF // CJK Unified Ideographs Extension B + * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C + * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D + * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement + * ``` + * + * FT_AUTOHINTER_SCRIPT_INDIC :: + * Apply the indic auto-hinter, covering all major scripts from the + * Indian sub-continent and some other related scripts like Thai, Lao, + * or Tibetan. + * + * By default, characters from the following Unicode ranges are + * assigned to this submodule. + * + * ``` + * U+0900 - U+0DFF // Indic Range + * U+0F00 - U+0FFF // Tibetan + * U+1900 - U+194F // Limbu + * U+1B80 - U+1BBF // Sundanese + * U+A800 - U+A82F // Syloti Nagri + * U+ABC0 - U+ABFF // Meetei Mayek + * U+11800 - U+118DF // Sharada + * ``` + * + * Note that currently Indic support is rudimentary only, missing blue + * zone support. + * + * @since: + * 2.4.11 + * + */ +#define FT_AUTOHINTER_SCRIPT_NONE 0 +#define FT_AUTOHINTER_SCRIPT_LATIN 1 +#define FT_AUTOHINTER_SCRIPT_CJK 2 +#define FT_AUTOHINTER_SCRIPT_INDIC 3 + + + /************************************************************************** + * + * @struct: + * FT_Prop_GlyphToScriptMap + * + * @description: + * **Experimental only** + * + * The data exchange structure for the @glyph-to-script-map property. + * + * @since: + * 2.4.11 + * + */ + typedef struct FT_Prop_GlyphToScriptMap_ + { + FT_Face face; + FT_UShort* map; + + } FT_Prop_GlyphToScriptMap; + + + /************************************************************************** + * + * @property: + * fallback-script + * + * @description: + * **Experimental only** + * + * If no auto-hinter script module can be assigned to a glyph, a fallback + * script gets assigned to it (see also the @glyph-to-script-map + * property). By default, this is @FT_AUTOHINTER_SCRIPT_CJK. Using the + * `fallback-script` property, this fallback value can be changed. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * It's important to use the right timing for changing this value: The + * creation of the glyph-to-script map that eventually uses the fallback + * script value gets triggered either by setting or reading a + * face-specific property like @glyph-to-script-map, or by auto-hinting + * any glyph from that face. In particular, if you have already created + * an @FT_Face structure but not loaded any glyph (using the + * auto-hinter), a change of the fallback script will affect this face. + * + * @example: + * ``` + * FT_Library library; + * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "fallback-script", &fallback_script ); + * ``` + * + * @since: + * 2.4.11 + * + */ + + + /************************************************************************** + * + * @property: + * default-script + * + * @description: + * **Experimental only** + * + * If FreeType gets compiled with `FT_CONFIG_OPTION_USE_HARFBUZZ` to make + * the HarfBuzz library access OpenType features for getting better glyph + * coverages, this property sets the (auto-fitter) script to be used for + * the default (OpenType) script data of a font's GSUB table. Features + * for the default script are intended for all scripts not explicitly + * handled in GSUB; an example is a 'dlig' feature, containing the + * combination of the characters 'T', 'E', and 'L' to form a 'TEL' + * ligature. + * + * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the + * `default-script` property, this default value can be changed. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * It's important to use the right timing for changing this value: The + * creation of the glyph-to-script map that eventually uses the default + * script value gets triggered either by setting or reading a + * face-specific property like @glyph-to-script-map, or by auto-hinting + * any glyph from that face. In particular, if you have already created + * an @FT_Face structure but not loaded any glyph (using the + * auto-hinter), a change of the default script will affect this face. + * + * @example: + * ``` + * FT_Library library; + * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "default-script", &default_script ); + * ``` + * + * @since: + * 2.5.3 + * + */ + + + /************************************************************************** + * + * @property: + * increase-x-height + * + * @description: + * For ppem values in the range 6~<= ppem <= `increase-x-height`, round + * up the font's x~height much more often than normally. If the value is + * set to~0, which is the default, this feature is switched off. Use + * this property to improve the legibility of small font sizes if + * necessary. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * Set this value right after calling @FT_Set_Char_Size, but before + * loading any glyph (using the auto-hinter). + * + * @example: + * ``` + * FT_Library library; + * FT_Face face; + * FT_Prop_IncreaseXHeight prop; + * + * + * FT_Init_FreeType( &library ); + * FT_New_Face( library, "foo.ttf", 0, &face ); + * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 ); + * + * prop.face = face; + * prop.limit = 14; + * + * FT_Property_Set( library, "autofitter", + * "increase-x-height", &prop ); + * ``` + * + * @since: + * 2.4.11 + * + */ + + + /************************************************************************** + * + * @struct: + * FT_Prop_IncreaseXHeight + * + * @description: + * The data exchange structure for the @increase-x-height property. + * + */ + typedef struct FT_Prop_IncreaseXHeight_ + { + FT_Face face; + FT_UInt limit; + + } FT_Prop_IncreaseXHeight; + + + /************************************************************************** + * + * @property: + * warping + * + * @description: + * **Obsolete** + * + * This property was always experimental and probably never worked + * correctly. It was entirely removed from the FreeType~2 sources. This + * entry is only here for historical reference. + * + * Warping only worked in 'normal' auto-hinting mode replacing it. The + * idea of the code was to slightly scale and shift a glyph along the + * non-hinted dimension (which is usually the horizontal axis) so that as + * much of its segments were aligned (more or less) to the grid. To find + * out a glyph's optimal scaling and shifting value, various parameter + * combinations were tried and scored. + * + * @since: + * 2.6 + * + */ + + + /* */ + + +FT_END_HEADER + + +#endif /* FTDRIVER_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fterrdef.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fterrdef.h new file mode 100644 index 0000000000000000000000000000000000000000..a955b18aa76b5825de23482df66bbf80e928fb59 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fterrdef.h @@ -0,0 +1,283 @@ +/**************************************************************************** + * + * fterrdef.h + * + * FreeType error codes (specification). + * + * Copyright (C) 2002-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * @section: + * error_code_values + * + * @title: + * Error Code Values + * + * @abstract: + * All possible error codes returned by FreeType functions. + * + * @description: + * The list below is taken verbatim from the file `fterrdef.h` (loaded + * automatically by including `FT_FREETYPE_H`). The first argument of the + * `FT_ERROR_DEF_` macro is the error label; by default, the prefix + * `FT_Err_` gets added so that you get error names like + * `FT_Err_Cannot_Open_Resource`. The second argument is the error code, + * and the last argument an error string, which is not used by FreeType. + * + * Within your application you should **only** use error names and + * **never** its numeric values! The latter might (and actually do) + * change in forthcoming FreeType versions. + * + * Macro `FT_NOERRORDEF_` defines `FT_Err_Ok`, which is always zero. See + * the 'Error Enumerations' subsection how to automatically generate a + * list of error strings. + * + */ + + + /************************************************************************** + * + * @enum: + * FT_Err_XXX + * + */ + + /* generic errors */ + + FT_NOERRORDEF_( Ok, 0x00, + "no error" ) + + FT_ERRORDEF_( Cannot_Open_Resource, 0x01, + "cannot open resource" ) + FT_ERRORDEF_( Unknown_File_Format, 0x02, + "unknown file format" ) + FT_ERRORDEF_( Invalid_File_Format, 0x03, + "broken file" ) + FT_ERRORDEF_( Invalid_Version, 0x04, + "invalid FreeType version" ) + FT_ERRORDEF_( Lower_Module_Version, 0x05, + "module version is too low" ) + FT_ERRORDEF_( Invalid_Argument, 0x06, + "invalid argument" ) + FT_ERRORDEF_( Unimplemented_Feature, 0x07, + "unimplemented feature" ) + FT_ERRORDEF_( Invalid_Table, 0x08, + "broken table" ) + FT_ERRORDEF_( Invalid_Offset, 0x09, + "broken offset within table" ) + FT_ERRORDEF_( Array_Too_Large, 0x0A, + "array allocation size too large" ) + FT_ERRORDEF_( Missing_Module, 0x0B, + "missing module" ) + FT_ERRORDEF_( Missing_Property, 0x0C, + "missing property" ) + + /* glyph/character errors */ + + FT_ERRORDEF_( Invalid_Glyph_Index, 0x10, + "invalid glyph index" ) + FT_ERRORDEF_( Invalid_Character_Code, 0x11, + "invalid character code" ) + FT_ERRORDEF_( Invalid_Glyph_Format, 0x12, + "unsupported glyph image format" ) + FT_ERRORDEF_( Cannot_Render_Glyph, 0x13, + "cannot render this glyph format" ) + FT_ERRORDEF_( Invalid_Outline, 0x14, + "invalid outline" ) + FT_ERRORDEF_( Invalid_Composite, 0x15, + "invalid composite glyph" ) + FT_ERRORDEF_( Too_Many_Hints, 0x16, + "too many hints" ) + FT_ERRORDEF_( Invalid_Pixel_Size, 0x17, + "invalid pixel size" ) + FT_ERRORDEF_( Invalid_SVG_Document, 0x18, + "invalid SVG document" ) + + /* handle errors */ + + FT_ERRORDEF_( Invalid_Handle, 0x20, + "invalid object handle" ) + FT_ERRORDEF_( Invalid_Library_Handle, 0x21, + "invalid library handle" ) + FT_ERRORDEF_( Invalid_Driver_Handle, 0x22, + "invalid module handle" ) + FT_ERRORDEF_( Invalid_Face_Handle, 0x23, + "invalid face handle" ) + FT_ERRORDEF_( Invalid_Size_Handle, 0x24, + "invalid size handle" ) + FT_ERRORDEF_( Invalid_Slot_Handle, 0x25, + "invalid glyph slot handle" ) + FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26, + "invalid charmap handle" ) + FT_ERRORDEF_( Invalid_Cache_Handle, 0x27, + "invalid cache manager handle" ) + FT_ERRORDEF_( Invalid_Stream_Handle, 0x28, + "invalid stream handle" ) + + /* driver errors */ + + FT_ERRORDEF_( Too_Many_Drivers, 0x30, + "too many modules" ) + FT_ERRORDEF_( Too_Many_Extensions, 0x31, + "too many extensions" ) + + /* memory errors */ + + FT_ERRORDEF_( Out_Of_Memory, 0x40, + "out of memory" ) + FT_ERRORDEF_( Unlisted_Object, 0x41, + "unlisted object" ) + + /* stream errors */ + + FT_ERRORDEF_( Cannot_Open_Stream, 0x51, + "cannot open stream" ) + FT_ERRORDEF_( Invalid_Stream_Seek, 0x52, + "invalid stream seek" ) + FT_ERRORDEF_( Invalid_Stream_Skip, 0x53, + "invalid stream skip" ) + FT_ERRORDEF_( Invalid_Stream_Read, 0x54, + "invalid stream read" ) + FT_ERRORDEF_( Invalid_Stream_Operation, 0x55, + "invalid stream operation" ) + FT_ERRORDEF_( Invalid_Frame_Operation, 0x56, + "invalid frame operation" ) + FT_ERRORDEF_( Nested_Frame_Access, 0x57, + "nested frame access" ) + FT_ERRORDEF_( Invalid_Frame_Read, 0x58, + "invalid frame read" ) + + /* raster errors */ + + FT_ERRORDEF_( Raster_Uninitialized, 0x60, + "raster uninitialized" ) + FT_ERRORDEF_( Raster_Corrupted, 0x61, + "raster corrupted" ) + FT_ERRORDEF_( Raster_Overflow, 0x62, + "raster overflow" ) + FT_ERRORDEF_( Raster_Negative_Height, 0x63, + "negative height while rastering" ) + + /* cache errors */ + + FT_ERRORDEF_( Too_Many_Caches, 0x70, + "too many registered caches" ) + + /* TrueType and SFNT errors */ + + FT_ERRORDEF_( Invalid_Opcode, 0x80, + "invalid opcode" ) + FT_ERRORDEF_( Too_Few_Arguments, 0x81, + "too few arguments" ) + FT_ERRORDEF_( Stack_Overflow, 0x82, + "stack overflow" ) + FT_ERRORDEF_( Code_Overflow, 0x83, + "code overflow" ) + FT_ERRORDEF_( Bad_Argument, 0x84, + "bad argument" ) + FT_ERRORDEF_( Divide_By_Zero, 0x85, + "division by zero" ) + FT_ERRORDEF_( Invalid_Reference, 0x86, + "invalid reference" ) + FT_ERRORDEF_( Debug_OpCode, 0x87, + "found debug opcode" ) + FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88, + "found ENDF opcode in execution stream" ) + FT_ERRORDEF_( Nested_DEFS, 0x89, + "nested DEFS" ) + FT_ERRORDEF_( Invalid_CodeRange, 0x8A, + "invalid code range" ) + FT_ERRORDEF_( Execution_Too_Long, 0x8B, + "execution context too long" ) + FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C, + "too many function definitions" ) + FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D, + "too many instruction definitions" ) + FT_ERRORDEF_( Table_Missing, 0x8E, + "SFNT font table missing" ) + FT_ERRORDEF_( Horiz_Header_Missing, 0x8F, + "horizontal header (hhea) table missing" ) + FT_ERRORDEF_( Locations_Missing, 0x90, + "locations (loca) table missing" ) + FT_ERRORDEF_( Name_Table_Missing, 0x91, + "name table missing" ) + FT_ERRORDEF_( CMap_Table_Missing, 0x92, + "character map (cmap) table missing" ) + FT_ERRORDEF_( Hmtx_Table_Missing, 0x93, + "horizontal metrics (hmtx) table missing" ) + FT_ERRORDEF_( Post_Table_Missing, 0x94, + "PostScript (post) table missing" ) + FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95, + "invalid horizontal metrics" ) + FT_ERRORDEF_( Invalid_CharMap_Format, 0x96, + "invalid character map (cmap) format" ) + FT_ERRORDEF_( Invalid_PPem, 0x97, + "invalid ppem value" ) + FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98, + "invalid vertical metrics" ) + FT_ERRORDEF_( Could_Not_Find_Context, 0x99, + "could not find context" ) + FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A, + "invalid PostScript (post) table format" ) + FT_ERRORDEF_( Invalid_Post_Table, 0x9B, + "invalid PostScript (post) table" ) + FT_ERRORDEF_( DEF_In_Glyf_Bytecode, 0x9C, + "found FDEF or IDEF opcode in glyf bytecode" ) + FT_ERRORDEF_( Missing_Bitmap, 0x9D, + "missing bitmap in strike" ) + FT_ERRORDEF_( Missing_SVG_Hooks, 0x9E, + "SVG hooks have not been set" ) + + /* CFF, CID, and Type 1 errors */ + + FT_ERRORDEF_( Syntax_Error, 0xA0, + "opcode syntax error" ) + FT_ERRORDEF_( Stack_Underflow, 0xA1, + "argument stack underflow" ) + FT_ERRORDEF_( Ignore, 0xA2, + "ignore" ) + FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3, + "no Unicode glyph name found" ) + FT_ERRORDEF_( Glyph_Too_Big, 0xA4, + "glyph too big for hinting" ) + + /* BDF errors */ + + FT_ERRORDEF_( Missing_Startfont_Field, 0xB0, + "`STARTFONT' field missing" ) + FT_ERRORDEF_( Missing_Font_Field, 0xB1, + "`FONT' field missing" ) + FT_ERRORDEF_( Missing_Size_Field, 0xB2, + "`SIZE' field missing" ) + FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, + "`FONTBOUNDINGBOX' field missing" ) + FT_ERRORDEF_( Missing_Chars_Field, 0xB4, + "`CHARS' field missing" ) + FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, + "`STARTCHAR' field missing" ) + FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, + "`ENCODING' field missing" ) + FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, + "`BBX' field missing" ) + FT_ERRORDEF_( Bbx_Too_Big, 0xB8, + "`BBX' too big" ) + FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, + "Font header corrupted or missing fields" ) + FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, + "Font glyphs corrupted or missing fields" ) + + /* */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fterrors.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fterrors.h new file mode 100644 index 0000000000000000000000000000000000000000..c15f26e101d53d9a3b9945e0b4e85c3fbf5e510a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fterrors.h @@ -0,0 +1,296 @@ +/**************************************************************************** + * + * fterrors.h + * + * FreeType error code handling (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * @section: + * error_enumerations + * + * @title: + * Error Enumerations + * + * @abstract: + * How to handle errors and error strings. + * + * @description: + * The header file `fterrors.h` (which is automatically included by + * `freetype.h`) defines the handling of FreeType's enumeration + * constants. It can also be used to generate error message strings + * with a small macro trick explained below. + * + * **Error Formats** + * + * The configuration macro `FT_CONFIG_OPTION_USE_MODULE_ERRORS` can be + * defined in `ftoption.h` in order to make the higher byte indicate the + * module where the error has happened (this is not compatible with + * standard builds of FreeType~2, however). See the file `ftmoderr.h` + * for more details. + * + * **Error Message Strings** + * + * Error definitions are set up with special macros that allow client + * applications to build a table of error message strings. The strings + * are not included in a normal build of FreeType~2 to save space (most + * client applications do not use them). + * + * To do so, you have to define the following macros before including + * this file. + * + * ``` + * FT_ERROR_START_LIST + * ``` + * + * This macro is called before anything else to define the start of the + * error list. It is followed by several `FT_ERROR_DEF` calls. + * + * ``` + * FT_ERROR_DEF( e, v, s ) + * ``` + * + * This macro is called to define one single error. 'e' is the error + * code identifier (e.g., `Invalid_Argument`), 'v' is the error's + * numerical value, and 's' is the corresponding error string. + * + * ``` + * FT_ERROR_END_LIST + * ``` + * + * This macro ends the list. + * + * Additionally, you have to undefine `FTERRORS_H_` before #including + * this file. + * + * Here is a simple example. + * + * ``` + * #undef FTERRORS_H_ + * #define FT_ERRORDEF( e, v, s ) { e, s }, + * #define FT_ERROR_START_LIST { + * #define FT_ERROR_END_LIST { 0, NULL } }; + * + * const struct + * { + * int err_code; + * const char* err_msg; + * } ft_errors[] = + * + * #include + * ``` + * + * An alternative to using an array is a switch statement. + * + * ``` + * #undef FTERRORS_H_ + * #define FT_ERROR_START_LIST switch ( error_code ) { + * #define FT_ERRORDEF( e, v, s ) case v: return s; + * #define FT_ERROR_END_LIST } + * ``` + * + * If you use `FT_CONFIG_OPTION_USE_MODULE_ERRORS`, `error_code` should + * be replaced with `FT_ERROR_BASE(error_code)` in the last example. + */ + + /* */ + + /* In previous FreeType versions we used `__FTERRORS_H__`. However, */ + /* using two successive underscores in a non-system symbol name */ + /* violates the C (and C++) standard, so it was changed to the */ + /* current form. In spite of this, we have to make */ + /* */ + /* ``` */ + /* #undefine __FTERRORS_H__ */ + /* ``` */ + /* */ + /* work for backward compatibility. */ + /* */ +#if !( defined( FTERRORS_H_ ) && defined ( __FTERRORS_H__ ) ) +#define FTERRORS_H_ +#define __FTERRORS_H__ + + + /* include module base error codes */ +#include + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** SETUP MACROS *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#undef FT_NEED_EXTERN_C + + + /* FT_ERR_PREFIX is used as a prefix for error identifiers. */ + /* By default, we use `FT_Err_`. */ + /* */ +#ifndef FT_ERR_PREFIX +#define FT_ERR_PREFIX FT_Err_ +#endif + + + /* FT_ERR_BASE is used as the base for module-specific errors. */ + /* */ +#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS + +#ifndef FT_ERR_BASE +#define FT_ERR_BASE FT_Mod_Err_Base +#endif + +#else + +#undef FT_ERR_BASE +#define FT_ERR_BASE 0 + +#endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */ + + + /* If FT_ERRORDEF is not defined, we need to define a simple */ + /* enumeration type. */ + /* */ +#ifndef FT_ERRORDEF + +#define FT_INCLUDE_ERR_PROTOS + +#define FT_ERRORDEF( e, v, s ) e = v, +#define FT_ERROR_START_LIST enum { +#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) }; + +#ifdef __cplusplus +#define FT_NEED_EXTERN_C + extern "C" { +#endif + +#endif /* !FT_ERRORDEF */ + + + /* this macro is used to define an error */ +#define FT_ERRORDEF_( e, v, s ) \ + FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s ) + + /* this is only used for _Err_Ok, which must be 0! */ +#define FT_NOERRORDEF_( e, v, s ) \ + FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s ) + + +#ifdef FT_ERROR_START_LIST + FT_ERROR_START_LIST +#endif + + + /* now include the error codes */ +#include + + +#ifdef FT_ERROR_END_LIST + FT_ERROR_END_LIST +#endif + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** SIMPLE CLEANUP *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + +#ifdef FT_NEED_EXTERN_C + } +#endif + +#undef FT_ERROR_START_LIST +#undef FT_ERROR_END_LIST + +#undef FT_ERRORDEF +#undef FT_ERRORDEF_ +#undef FT_NOERRORDEF_ + +#undef FT_NEED_EXTERN_C +#undef FT_ERR_BASE + + /* FT_ERR_PREFIX is needed internally */ +#ifndef FT2_BUILD_LIBRARY +#undef FT_ERR_PREFIX +#endif + + /* FT_INCLUDE_ERR_PROTOS: Control whether function prototypes should be */ + /* included with */ + /* */ + /* #include */ + /* */ + /* This is only true where `FT_ERRORDEF` is */ + /* undefined. */ + /* */ + /* FT_ERR_PROTOS_DEFINED: Actual multiple-inclusion protection of */ + /* `fterrors.h`. */ +#ifdef FT_INCLUDE_ERR_PROTOS +#undef FT_INCLUDE_ERR_PROTOS + +#ifndef FT_ERR_PROTOS_DEFINED +#define FT_ERR_PROTOS_DEFINED + + +FT_BEGIN_HEADER + + /************************************************************************** + * + * @function: + * FT_Error_String + * + * @description: + * Retrieve the description of a valid FreeType error code. + * + * @input: + * error_code :: + * A valid FreeType error code. + * + * @return: + * A C~string or `NULL`, if any error occurred. + * + * @note: + * FreeType has to be compiled with `FT_CONFIG_OPTION_ERROR_STRINGS` or + * `FT_DEBUG_LEVEL_ERROR` to get meaningful descriptions. + * 'error_string' will be `NULL` otherwise. + * + * Module identification will be ignored: + * + * ```c + * strcmp( FT_Error_String( FT_Err_Unknown_File_Format ), + * FT_Error_String( BDF_Err_Unknown_File_Format ) ) == 0; + * ``` + */ + FT_EXPORT( const char* ) + FT_Error_String( FT_Error error_code ); + + /* */ + +FT_END_HEADER + + +#endif /* FT_ERR_PROTOS_DEFINED */ + +#endif /* FT_INCLUDE_ERR_PROTOS */ + +#endif /* !(FTERRORS_H_ && __FTERRORS_H__) */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftfntfmt.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftfntfmt.h new file mode 100644 index 0000000000000000000000000000000000000000..24c5b95b658eb97b81b9ac40cad96229ab68be73 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftfntfmt.h @@ -0,0 +1,93 @@ +/**************************************************************************** + * + * ftfntfmt.h + * + * Support functions for font formats. + * + * Copyright (C) 2002-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTFNTFMT_H_ +#define FTFNTFMT_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * font_formats + * + * @title: + * Font Formats + * + * @abstract: + * Getting the font format. + * + * @description: + * The single function in this section can be used to get the font format. + * Note that this information is not needed normally; however, there are + * special cases (like in PDF devices) where it is important to + * differentiate, in spite of FreeType's uniform API. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Get_Font_Format + * + * @description: + * Return a string describing the format of a given face. Possible values + * are 'TrueType', 'Type~1', 'BDF', 'PCF', 'Type~42', 'CID~Type~1', 'CFF', + * 'PFR', and 'Windows~FNT'. + * + * The return value is suitable to be used as an X11 FONT_PROPERTY. + * + * @input: + * face :: + * Input face handle. + * + * @return: + * Font format string. `NULL` in case of error. + * + * @note: + * A deprecated name for the same function is `FT_Get_X11_Font_Format`. + */ + FT_EXPORT( const char* ) + FT_Get_Font_Format( FT_Face face ); + + + /* deprecated */ + FT_EXPORT( const char* ) + FT_Get_X11_Font_Format( FT_Face face ); + + + /* */ + + +FT_END_HEADER + +#endif /* FTFNTFMT_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftgasp.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftgasp.h new file mode 100644 index 0000000000000000000000000000000000000000..b74d95c8cfe13647018b98dad80f4cf046f8359e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftgasp.h @@ -0,0 +1,143 @@ +/**************************************************************************** + * + * ftgasp.h + * + * Access of TrueType's 'gasp' table (specification). + * + * Copyright (C) 2007-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTGASP_H_ +#define FTGASP_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * gasp_table + * + * @title: + * Gasp Table + * + * @abstract: + * Retrieving TrueType 'gasp' table entries. + * + * @description: + * The function @FT_Get_Gasp can be used to query a TrueType or OpenType + * font for specific entries in its 'gasp' table, if any. This is mainly + * useful when implementing native TrueType hinting with the bytecode + * interpreter to duplicate the Windows text rendering results. + */ + + /************************************************************************** + * + * @enum: + * FT_GASP_XXX + * + * @description: + * A list of values and/or bit-flags returned by the @FT_Get_Gasp + * function. + * + * @values: + * FT_GASP_NO_TABLE :: + * This special value means that there is no GASP table in this face. + * It is up to the client to decide what to do. + * + * FT_GASP_DO_GRIDFIT :: + * Grid-fitting and hinting should be performed at the specified ppem. + * This **really** means TrueType bytecode interpretation. If this bit + * is not set, no hinting gets applied. + * + * FT_GASP_DO_GRAY :: + * Anti-aliased rendering should be performed at the specified ppem. + * If not set, do monochrome rendering. + * + * FT_GASP_SYMMETRIC_SMOOTHING :: + * If set, smoothing along multiple axes must be used with ClearType. + * + * FT_GASP_SYMMETRIC_GRIDFIT :: + * Grid-fitting must be used with ClearType's symmetric smoothing. + * + * @note: + * The bit-flags `FT_GASP_DO_GRIDFIT` and `FT_GASP_DO_GRAY` are to be + * used for standard font rasterization only. Independently of that, + * `FT_GASP_SYMMETRIC_SMOOTHING` and `FT_GASP_SYMMETRIC_GRIDFIT` are to + * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT` and + * `FT_GASP_DO_GRAY` are consequently ignored). + * + * 'ClearType' is Microsoft's implementation of LCD rendering, partly + * protected by patents. + * + * @since: + * 2.3.0 + */ +#define FT_GASP_NO_TABLE -1 +#define FT_GASP_DO_GRIDFIT 0x01 +#define FT_GASP_DO_GRAY 0x02 +#define FT_GASP_SYMMETRIC_GRIDFIT 0x04 +#define FT_GASP_SYMMETRIC_SMOOTHING 0x08 + + + /************************************************************************** + * + * @function: + * FT_Get_Gasp + * + * @description: + * For a TrueType or OpenType font file, return the rasterizer behaviour + * flags from the font's 'gasp' table corresponding to a given character + * pixel size. + * + * @input: + * face :: + * The source face handle. + * + * ppem :: + * The vertical character pixel size. + * + * @return: + * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no + * 'gasp' table in the face. + * + * @note: + * If you want to use the MM functionality of OpenType variation fonts + * (i.e., using @FT_Set_Var_Design_Coordinates and friends), call this + * function **after** setting an instance since the return values can + * change. + * + * @since: + * 2.3.0 + */ + FT_EXPORT( FT_Int ) + FT_Get_Gasp( FT_Face face, + FT_UInt ppem ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGASP_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftglyph.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftglyph.h new file mode 100644 index 0000000000000000000000000000000000000000..136264ba755671452d21ed2b8c5c5a453f775eff --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftglyph.h @@ -0,0 +1,750 @@ +/**************************************************************************** + * + * ftglyph.h + * + * FreeType convenience functions to handle glyphs (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file contains the definition of several convenience functions that + * can be used by client applications to easily retrieve glyph bitmaps and + * outlines from a given face. + * + * These functions should be optional if you are writing a font server or + * text layout engine on top of FreeType. However, they are pretty handy + * for many other simple uses of the library. + * + */ + + +#ifndef FTGLYPH_H_ +#define FTGLYPH_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * glyph_management + * + * @title: + * Glyph Management + * + * @abstract: + * Generic interface to manage individual glyph data. + * + * @description: + * This section contains definitions used to manage glyph data through + * generic @FT_Glyph objects. Each of them can contain a bitmap, + * a vector outline, or even images in other formats. These objects are + * detached from @FT_Face, contrary to @FT_GlyphSlot. + * + */ + + + /* forward declaration to a private type */ + typedef struct FT_Glyph_Class_ FT_Glyph_Class; + + + /************************************************************************** + * + * @type: + * FT_Glyph + * + * @description: + * Handle to an object used to model generic glyph images. It is a + * pointer to the @FT_GlyphRec structure and can contain a glyph bitmap + * or pointer. + * + * @note: + * Glyph objects are not owned by the library. You must thus release + * them manually (through @FT_Done_Glyph) _before_ calling + * @FT_Done_FreeType. + */ + typedef struct FT_GlyphRec_* FT_Glyph; + + + /************************************************************************** + * + * @struct: + * FT_GlyphRec + * + * @description: + * The root glyph structure contains a given glyph image plus its advance + * width in 16.16 fixed-point format. + * + * @fields: + * library :: + * A handle to the FreeType library object. + * + * clazz :: + * A pointer to the glyph's class. Private. + * + * format :: + * The format of the glyph's image. + * + * advance :: + * A 16.16 vector that gives the glyph's advance width. + */ + typedef struct FT_GlyphRec_ + { + FT_Library library; + const FT_Glyph_Class* clazz; + FT_Glyph_Format format; + FT_Vector advance; + + } FT_GlyphRec; + + + /************************************************************************** + * + * @type: + * FT_BitmapGlyph + * + * @description: + * A handle to an object used to model a bitmap glyph image. This is a + * 'sub-class' of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. + */ + typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph; + + + /************************************************************************** + * + * @struct: + * FT_BitmapGlyphRec + * + * @description: + * A structure used for bitmap glyph images. This really is a + * 'sub-class' of @FT_GlyphRec. + * + * @fields: + * root :: + * The root fields of @FT_Glyph. + * + * left :: + * The left-side bearing, i.e., the horizontal distance from the + * current pen position to the left border of the glyph bitmap. + * + * top :: + * The top-side bearing, i.e., the vertical distance from the current + * pen position to the top border of the glyph bitmap. This distance + * is positive for upwards~y! + * + * bitmap :: + * A descriptor for the bitmap. + * + * @note: + * You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have + * `glyph->format == FT_GLYPH_FORMAT_BITMAP`. This lets you access the + * bitmap's contents easily. + * + * The corresponding pixel buffer is always owned by @FT_BitmapGlyph and + * is thus created and destroyed with it. + */ + typedef struct FT_BitmapGlyphRec_ + { + FT_GlyphRec root; + FT_Int left; + FT_Int top; + FT_Bitmap bitmap; + + } FT_BitmapGlyphRec; + + + /************************************************************************** + * + * @type: + * FT_OutlineGlyph + * + * @description: + * A handle to an object used to model an outline glyph image. This is a + * 'sub-class' of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. + */ + typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph; + + + /************************************************************************** + * + * @struct: + * FT_OutlineGlyphRec + * + * @description: + * A structure used for outline (vectorial) glyph images. This really is + * a 'sub-class' of @FT_GlyphRec. + * + * @fields: + * root :: + * The root @FT_Glyph fields. + * + * outline :: + * A descriptor for the outline. + * + * @note: + * You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have + * `glyph->format == FT_GLYPH_FORMAT_OUTLINE`. This lets you access the + * outline's content easily. + * + * As the outline is extracted from a glyph slot, its coordinates are + * expressed normally in 26.6 pixels, unless the flag @FT_LOAD_NO_SCALE + * was used in @FT_Load_Glyph or @FT_Load_Char. + * + * The outline's tables are always owned by the object and are destroyed + * with it. + */ + typedef struct FT_OutlineGlyphRec_ + { + FT_GlyphRec root; + FT_Outline outline; + + } FT_OutlineGlyphRec; + + + /************************************************************************** + * + * @type: + * FT_SvgGlyph + * + * @description: + * A handle to an object used to model an SVG glyph. This is a + * 'sub-class' of @FT_Glyph, and a pointer to @FT_SvgGlyphRec. + * + * @since: + * 2.12 + */ + typedef struct FT_SvgGlyphRec_* FT_SvgGlyph; + + + /************************************************************************** + * + * @struct: + * FT_SvgGlyphRec + * + * @description: + * A structure used for OT-SVG glyphs. This is a 'sub-class' of + * @FT_GlyphRec. + * + * @fields: + * root :: + * The root @FT_GlyphRec fields. + * + * svg_document :: + * A pointer to the SVG document. + * + * svg_document_length :: + * The length of `svg_document`. + * + * glyph_index :: + * The index of the glyph to be rendered. + * + * metrics :: + * A metrics object storing the size information. + * + * units_per_EM :: + * The size of the EM square. + * + * start_glyph_id :: + * The first glyph ID in the glyph range covered by this document. + * + * end_glyph_id :: + * The last glyph ID in the glyph range covered by this document. + * + * transform :: + * A 2x2 transformation matrix to apply to the glyph while rendering + * it. + * + * delta :: + * Translation to apply to the glyph while rendering. + * + * @note: + * The Glyph Management API requires @FT_Glyph or its 'sub-class' to have + * all the information needed to completely define the glyph's rendering. + * Outline-based glyphs can directly apply transformations to the outline + * but this is not possible for an SVG document that hasn't been parsed. + * Therefore, the transformation is stored along with the document. In + * the absence of a 'ViewBox' or 'Width'/'Height' attribute, the size of + * the ViewPort should be assumed to be 'units_per_EM'. + */ + typedef struct FT_SvgGlyphRec_ + { + FT_GlyphRec root; + + FT_Byte* svg_document; + FT_ULong svg_document_length; + + FT_UInt glyph_index; + + FT_Size_Metrics metrics; + FT_UShort units_per_EM; + + FT_UShort start_glyph_id; + FT_UShort end_glyph_id; + + FT_Matrix transform; + FT_Vector delta; + + } FT_SvgGlyphRec; + + + /************************************************************************** + * + * @function: + * FT_New_Glyph + * + * @description: + * A function used to create a new empty glyph image. Note that the + * created @FT_Glyph object must be released with @FT_Done_Glyph. + * + * @input: + * library :: + * A handle to the FreeType library object. + * + * format :: + * The format of the glyph's image. + * + * @output: + * aglyph :: + * A handle to the glyph object. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_New_Glyph( FT_Library library, + FT_Glyph_Format format, + FT_Glyph *aglyph ); + + + /************************************************************************** + * + * @function: + * FT_Get_Glyph + * + * @description: + * A function used to extract a glyph image from a slot. Note that the + * created @FT_Glyph object must be released with @FT_Done_Glyph. + * + * @input: + * slot :: + * A handle to the source glyph slot. + * + * @output: + * aglyph :: + * A handle to the glyph object. `NULL` in case of error. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Because `*aglyph->advance.x` and `*aglyph->advance.y` are 16.16 + * fixed-point numbers, `slot->advance.x` and `slot->advance.y` (which + * are in 26.6 fixed-point format) must be in the range ]-32768;32768[. + */ + FT_EXPORT( FT_Error ) + FT_Get_Glyph( FT_GlyphSlot slot, + FT_Glyph *aglyph ); + + + /************************************************************************** + * + * @function: + * FT_Glyph_Copy + * + * @description: + * A function used to copy a glyph image. Note that the created + * @FT_Glyph object must be released with @FT_Done_Glyph. + * + * @input: + * source :: + * A handle to the source glyph object. + * + * @output: + * target :: + * A handle to the target glyph object. `NULL` in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Glyph_Copy( FT_Glyph source, + FT_Glyph *target ); + + + /************************************************************************** + * + * @function: + * FT_Glyph_Transform + * + * @description: + * Transform a glyph image if its format is scalable. + * + * @inout: + * glyph :: + * A handle to the target glyph object. + * + * @input: + * matrix :: + * A pointer to a 2x2 matrix to apply. + * + * delta :: + * A pointer to a 2d vector to apply. Coordinates are expressed in + * 1/64 of a pixel. + * + * @return: + * FreeType error code (if not 0, the glyph format is not scalable). + * + * @note: + * The 2x2 transformation matrix is also applied to the glyph's advance + * vector. + */ + FT_EXPORT( FT_Error ) + FT_Glyph_Transform( FT_Glyph glyph, + const FT_Matrix* matrix, + const FT_Vector* delta ); + + + /************************************************************************** + * + * @enum: + * FT_Glyph_BBox_Mode + * + * @description: + * The mode how the values of @FT_Glyph_Get_CBox are returned. + * + * @values: + * FT_GLYPH_BBOX_UNSCALED :: + * Return unscaled font units. + * + * FT_GLYPH_BBOX_SUBPIXELS :: + * Return unfitted 26.6 coordinates. + * + * FT_GLYPH_BBOX_GRIDFIT :: + * Return grid-fitted 26.6 coordinates. + * + * FT_GLYPH_BBOX_TRUNCATE :: + * Return coordinates in integer pixels. + * + * FT_GLYPH_BBOX_PIXELS :: + * Return grid-fitted pixel coordinates. + */ + typedef enum FT_Glyph_BBox_Mode_ + { + FT_GLYPH_BBOX_UNSCALED = 0, + FT_GLYPH_BBOX_SUBPIXELS = 0, + FT_GLYPH_BBOX_GRIDFIT = 1, + FT_GLYPH_BBOX_TRUNCATE = 2, + FT_GLYPH_BBOX_PIXELS = 3 + + } FT_Glyph_BBox_Mode; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Glyph_BBox_Mode` values instead */ +#define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED +#define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS +#define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT +#define ft_glyph_bbox_truncate FT_GLYPH_BBOX_TRUNCATE +#define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS + + + /************************************************************************** + * + * @function: + * FT_Glyph_Get_CBox + * + * @description: + * Return a glyph's 'control box'. The control box encloses all the + * outline's points, including Bezier control points. Though it + * coincides with the exact bounding box for most glyphs, it can be + * slightly larger in some situations (like when rotating an outline that + * contains Bezier outside arcs). + * + * Computing the control box is very fast, while getting the bounding box + * can take much more time as it needs to walk over all segments and arcs + * in the outline. To get the latter, you can use the 'ftbbox' + * component, which is dedicated to this single task. + * + * @input: + * glyph :: + * A handle to the source glyph object. + * + * mode :: + * The mode that indicates how to interpret the returned bounding box + * values. + * + * @output: + * acbox :: + * The glyph coordinate bounding box. Coordinates are expressed in + * 1/64 of pixels if it is grid-fitted. + * + * @note: + * Coordinates are relative to the glyph origin, using the y~upwards + * convention. + * + * If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode` must + * be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font units in 26.6 + * pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS is another name for + * this constant. + * + * If the font is tricky and the glyph has been loaded with + * @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get + * reasonable values for the CBox it is necessary to load the glyph at a + * large ppem value (so that the hinting instructions can properly shift + * and scale the subglyphs), then extracting the CBox, which can be + * eventually converted back to font units. + * + * Note that the maximum coordinates are exclusive, which means that one + * can compute the width and height of the glyph image (be it in integer + * or 26.6 pixels) as: + * + * ``` + * width = bbox.xMax - bbox.xMin; + * height = bbox.yMax - bbox.yMin; + * ``` + * + * Note also that for 26.6 coordinates, if `bbox_mode` is set to + * @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, + * which corresponds to: + * + * ``` + * bbox.xMin = FLOOR(bbox.xMin); + * bbox.yMin = FLOOR(bbox.yMin); + * bbox.xMax = CEILING(bbox.xMax); + * bbox.yMax = CEILING(bbox.yMax); + * ``` + * + * To get the bbox in pixel coordinates, set `bbox_mode` to + * @FT_GLYPH_BBOX_TRUNCATE. + * + * To get the bbox in grid-fitted pixel coordinates, set `bbox_mode` to + * @FT_GLYPH_BBOX_PIXELS. + */ + FT_EXPORT( void ) + FT_Glyph_Get_CBox( FT_Glyph glyph, + FT_UInt bbox_mode, + FT_BBox *acbox ); + + + /************************************************************************** + * + * @function: + * FT_Glyph_To_Bitmap + * + * @description: + * Convert a given glyph object to a bitmap glyph object. + * + * @inout: + * the_glyph :: + * A pointer to a handle to the target glyph. + * + * @input: + * render_mode :: + * An enumeration that describes how the data is rendered. + * + * origin :: + * A pointer to a vector used to translate the glyph image before + * rendering. Can be~0 (if no translation). The origin is expressed + * in 26.6 pixels. + * + * destroy :: + * A boolean that indicates that the original glyph image should be + * destroyed by this function. It is never destroyed in case of error. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function does nothing if the glyph format isn't scalable. + * + * The glyph image is translated with the `origin` vector before + * rendering. + * + * The first parameter is a pointer to an @FT_Glyph handle that will be + * _replaced_ by this function (with newly allocated data). Typically, + * you would do something like the following (omitting error handling). + * + * ``` + * FT_Glyph glyph; + * FT_BitmapGlyph glyph_bitmap; + * + * + * // load glyph + * error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT ); + * + * // extract glyph image + * error = FT_Get_Glyph( face->glyph, &glyph ); + * + * // convert to a bitmap (default render mode + destroying old) + * if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) + * { + * error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, + * 0, 1 ); + * if ( error ) // `glyph' unchanged + * ... + * } + * + * // access bitmap content by typecasting + * glyph_bitmap = (FT_BitmapGlyph)glyph; + * + * // do funny stuff with it, like blitting/drawing + * ... + * + * // discard glyph image (bitmap or not) + * FT_Done_Glyph( glyph ); + * ``` + * + * Here is another example, again without error handling. + * + * ``` + * FT_Glyph glyphs[MAX_GLYPHS] + * + * + * ... + * + * for ( idx = 0; i < MAX_GLYPHS; i++ ) + * error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || + * FT_Get_Glyph ( face->glyph, &glyphs[idx] ); + * + * ... + * + * for ( idx = 0; i < MAX_GLYPHS; i++ ) + * { + * FT_Glyph bitmap = glyphs[idx]; + * + * + * ... + * + * // after this call, `bitmap' no longer points into + * // the `glyphs' array (and the old value isn't destroyed) + * FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); + * + * ... + * + * FT_Done_Glyph( bitmap ); + * } + * + * ... + * + * for ( idx = 0; i < MAX_GLYPHS; i++ ) + * FT_Done_Glyph( glyphs[idx] ); + * ``` + */ + FT_EXPORT( FT_Error ) + FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, + FT_Render_Mode render_mode, + const FT_Vector* origin, + FT_Bool destroy ); + + + /************************************************************************** + * + * @function: + * FT_Done_Glyph + * + * @description: + * Destroy a given glyph. + * + * @input: + * glyph :: + * A handle to the target glyph object. Can be `NULL`. + */ + FT_EXPORT( void ) + FT_Done_Glyph( FT_Glyph glyph ); + + /* */ + + + /* other helpful functions */ + + /************************************************************************** + * + * @section: + * computations + * + */ + + + /************************************************************************** + * + * @function: + * FT_Matrix_Multiply + * + * @description: + * Perform the matrix operation `b = a*b`. + * + * @input: + * a :: + * A pointer to matrix `a`. + * + * @inout: + * b :: + * A pointer to matrix `b`. + * + * @note: + * The result is undefined if either `a` or `b` is zero. + * + * Since the function uses wrap-around arithmetic, results become + * meaningless if the arguments are very large. + */ + FT_EXPORT( void ) + FT_Matrix_Multiply( const FT_Matrix* a, + FT_Matrix* b ); + + + /************************************************************************** + * + * @function: + * FT_Matrix_Invert + * + * @description: + * Invert a 2x2 matrix. Return an error if it can't be inverted. + * + * @inout: + * matrix :: + * A pointer to the target matrix. Remains untouched in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Matrix_Invert( FT_Matrix* matrix ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGLYPH_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftgxval.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftgxval.h new file mode 100644 index 0000000000000000000000000000000000000000..bfb4d0cdd0d52082a0ee37d6a075d502c3689cc5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftgxval.h @@ -0,0 +1,354 @@ +/**************************************************************************** + * + * ftgxval.h + * + * FreeType API for validating TrueTypeGX/AAT tables (specification). + * + * Copyright (C) 2004-2024 by + * Masatake YAMATO, Redhat K.K, + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ + + +#ifndef FTGXVAL_H_ +#define FTGXVAL_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * gx_validation + * + * @title: + * TrueTypeGX/AAT Validation + * + * @abstract: + * An API to validate TrueTypeGX/AAT tables. + * + * @description: + * This section contains the declaration of functions to validate some + * TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, trak, + * prop, lcar). + * + * @order: + * FT_TrueTypeGX_Validate + * FT_TrueTypeGX_Free + * + * FT_ClassicKern_Validate + * FT_ClassicKern_Free + * + * FT_VALIDATE_GX_LENGTH + * FT_VALIDATE_GXXXX + * FT_VALIDATE_CKERNXXX + * + */ + + /************************************************************************** + * + * + * Warning: Use `FT_VALIDATE_XXX` to validate a table. + * Following definitions are for gxvalid developers. + * + * + */ + +#define FT_VALIDATE_feat_INDEX 0 +#define FT_VALIDATE_mort_INDEX 1 +#define FT_VALIDATE_morx_INDEX 2 +#define FT_VALIDATE_bsln_INDEX 3 +#define FT_VALIDATE_just_INDEX 4 +#define FT_VALIDATE_kern_INDEX 5 +#define FT_VALIDATE_opbd_INDEX 6 +#define FT_VALIDATE_trak_INDEX 7 +#define FT_VALIDATE_prop_INDEX 8 +#define FT_VALIDATE_lcar_INDEX 9 +#define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX + + + /************************************************************************** + * + * @macro: + * FT_VALIDATE_GX_LENGTH + * + * @description: + * The number of tables checked in this module. Use it as a parameter + * for the `table-length` argument of function @FT_TrueTypeGX_Validate. + */ +#define FT_VALIDATE_GX_LENGTH ( FT_VALIDATE_GX_LAST_INDEX + 1 ) + + /* */ + + /* Up to 0x1000 is used by otvalid. + Ox2xxx is reserved for feature OT extension. */ +#define FT_VALIDATE_GX_START 0x4000 +#define FT_VALIDATE_GX_BITFIELD( tag ) \ + ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX ) + + + /************************************************************************** + * + * @enum: + * FT_VALIDATE_GXXXX + * + * @description: + * A list of bit-field constants used with @FT_TrueTypeGX_Validate to + * indicate which TrueTypeGX/AAT Type tables should be validated. + * + * @values: + * FT_VALIDATE_feat :: + * Validate 'feat' table. + * + * FT_VALIDATE_mort :: + * Validate 'mort' table. + * + * FT_VALIDATE_morx :: + * Validate 'morx' table. + * + * FT_VALIDATE_bsln :: + * Validate 'bsln' table. + * + * FT_VALIDATE_just :: + * Validate 'just' table. + * + * FT_VALIDATE_kern :: + * Validate 'kern' table. + * + * FT_VALIDATE_opbd :: + * Validate 'opbd' table. + * + * FT_VALIDATE_trak :: + * Validate 'trak' table. + * + * FT_VALIDATE_prop :: + * Validate 'prop' table. + * + * FT_VALIDATE_lcar :: + * Validate 'lcar' table. + * + * FT_VALIDATE_GX :: + * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern, + * opbd, trak, prop and lcar). + * + */ + +#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat ) +#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort ) +#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx ) +#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln ) +#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just ) +#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern ) +#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd ) +#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak ) +#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop ) +#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar ) + +#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \ + FT_VALIDATE_mort | \ + FT_VALIDATE_morx | \ + FT_VALIDATE_bsln | \ + FT_VALIDATE_just | \ + FT_VALIDATE_kern | \ + FT_VALIDATE_opbd | \ + FT_VALIDATE_trak | \ + FT_VALIDATE_prop | \ + FT_VALIDATE_lcar ) + + + /************************************************************************** + * + * @function: + * FT_TrueTypeGX_Validate + * + * @description: + * Validate various TrueTypeGX tables to assure that all offsets and + * indices are valid. The idea is that a higher-level library that + * actually does the text layout can access those tables without error + * checking (which can be quite time consuming). + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the tables to be validated. See + * @FT_VALIDATE_GXXXX for possible values. + * + * table_length :: + * The size of the `tables` array. Normally, @FT_VALIDATE_GX_LENGTH + * should be passed. + * + * @output: + * tables :: + * The array where all validated sfnt tables are stored. The array + * itself must be allocated by a client. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with TrueTypeGX fonts, returning an error + * otherwise. + * + * After use, the application should deallocate the buffers pointed to by + * each `tables` element, by calling @FT_TrueTypeGX_Free. A `NULL` value + * indicates that the table either doesn't exist in the font, the + * application hasn't asked for validation, or the validator doesn't have + * the ability to validate the sfnt table. + */ + FT_EXPORT( FT_Error ) + FT_TrueTypeGX_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes tables[FT_VALIDATE_GX_LENGTH], + FT_UInt table_length ); + + + /************************************************************************** + * + * @function: + * FT_TrueTypeGX_Free + * + * @description: + * Free the buffer allocated by TrueTypeGX validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer allocated by @FT_TrueTypeGX_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_TrueTypeGX_Validate only. + */ + FT_EXPORT( void ) + FT_TrueTypeGX_Free( FT_Face face, + FT_Bytes table ); + + + /************************************************************************** + * + * @enum: + * FT_VALIDATE_CKERNXXX + * + * @description: + * A list of bit-field constants used with @FT_ClassicKern_Validate to + * indicate the classic kern dialect or dialects. If the selected type + * doesn't fit, @FT_ClassicKern_Validate regards the table as invalid. + * + * @values: + * FT_VALIDATE_MS :: + * Handle the 'kern' table as a classic Microsoft kern table. + * + * FT_VALIDATE_APPLE :: + * Handle the 'kern' table as a classic Apple kern table. + * + * FT_VALIDATE_CKERN :: + * Handle the 'kern' as either classic Apple or Microsoft kern table. + */ +#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 ) +#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 ) + +#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE ) + + + /************************************************************************** + * + * @function: + * FT_ClassicKern_Validate + * + * @description: + * Validate classic (16-bit format) kern table to assure that the + * offsets and indices are valid. The idea is that a higher-level + * library that actually does the text layout can access those tables + * without error checking (which can be quite time consuming). + * + * The 'kern' table validator in @FT_TrueTypeGX_Validate deals with both + * the new 32-bit format and the classic 16-bit format, while + * FT_ClassicKern_Validate only supports the classic 16-bit format. + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the dialect to be validated. See + * @FT_VALIDATE_CKERNXXX for possible values. + * + * @output: + * ckern_table :: + * A pointer to the kern table. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * After use, the application should deallocate the buffers pointed to by + * `ckern_table`, by calling @FT_ClassicKern_Free. A `NULL` value + * indicates that the table doesn't exist in the font. + */ + FT_EXPORT( FT_Error ) + FT_ClassicKern_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes *ckern_table ); + + + /************************************************************************** + * + * @function: + * FT_ClassicKern_Free + * + * @description: + * Free the buffer allocated by classic Kern validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer that is allocated by + * @FT_ClassicKern_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_ClassicKern_Validate only. + */ + FT_EXPORT( void ) + FT_ClassicKern_Free( FT_Face face, + FT_Bytes table ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGXVAL_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftgzip.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftgzip.h new file mode 100644 index 0000000000000000000000000000000000000000..5d02a4bd1c060f54e0fb79c869d755e7cb09a1d9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftgzip.h @@ -0,0 +1,151 @@ +/**************************************************************************** + * + * ftgzip.h + * + * Gzip-compressed stream support. + * + * Copyright (C) 2002-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTGZIP_H_ +#define FTGZIP_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /************************************************************************** + * + * @section: + * gzip + * + * @title: + * GZIP Streams + * + * @abstract: + * Using gzip-compressed font files. + * + * @description: + * In certain builds of the library, gzip compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a gzipped stream from it + * and re-open the face with it. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream, + * which significantly undermines the performance. + * + * This section contains the declaration of Gzip-specific functions. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Stream_OpenGzip + * + * @description: + * Open a new stream to parse gzip-compressed font files. This is mainly + * used to support the compressed `*.pcf.gz` fonts that come with + * XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close` on the new stream will + * **not** call `FT_Stream_Close` on the source stream. None of the + * stream objects will be released to the heap. + * + * This function may return `FT_Err_Unimplemented_Feature` if your build + * of FreeType was not compiled with zlib support. + */ + FT_EXPORT( FT_Error ) + FT_Stream_OpenGzip( FT_Stream stream, + FT_Stream source ); + + + /************************************************************************** + * + * @function: + * FT_Gzip_Uncompress + * + * @description: + * Decompress a zipped input buffer into an output buffer. This function + * is modeled after zlib's `uncompress` function. + * + * @input: + * memory :: + * A FreeType memory handle. + * + * input :: + * The input buffer. + * + * input_len :: + * The length of the input buffer. + * + * @output: + * output :: + * The output buffer. + * + * @inout: + * output_len :: + * Before calling the function, this is the total size of the output + * buffer, which must be large enough to hold the entire uncompressed + * data (so the size of the uncompressed data must be known in + * advance). After calling the function, `output_len` is the size of + * the used data in `output`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function may return `FT_Err_Unimplemented_Feature` if your build + * of FreeType was not compiled with zlib support. + * + * @since: + * 2.5.1 + */ + FT_EXPORT( FT_Error ) + FT_Gzip_Uncompress( FT_Memory memory, + FT_Byte* output, + FT_ULong* output_len, + const FT_Byte* input, + FT_ULong input_len ); + + /* */ + + +FT_END_HEADER + +#endif /* FTGZIP_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftimage.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftimage.h new file mode 100644 index 0000000000000000000000000000000000000000..c059d24a65734f7c5cb987f9595eb0f08db57278 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftimage.h @@ -0,0 +1,1289 @@ +/**************************************************************************** + * + * ftimage.h + * + * FreeType glyph image formats and default raster interface + * (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * Note: A 'raster' is simply a scan-line converter, used to render + * `FT_Outline`s into `FT_Bitmap`s. + * + * Note: This file can be used for `STANDALONE_` compilation of raster + * (B/W) and smooth (anti-aliased) renderers. Therefore, it must + * rely on standard variable types only instead of aliases in + * `fttypes.h`. + * + */ + + +#ifndef FTIMAGE_H_ +#define FTIMAGE_H_ + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * basic_types + * + */ + + + /************************************************************************** + * + * @type: + * FT_Pos + * + * @description: + * The type FT_Pos is used to store vectorial coordinates. Depending on + * the context, these can represent distances in integer font units, or + * 16.16, or 26.6 fixed-point pixel coordinates. + */ + typedef signed long FT_Pos; + + + /************************************************************************** + * + * @struct: + * FT_Vector + * + * @description: + * A simple structure used to store a 2D vector; coordinates are of the + * FT_Pos type. + * + * @fields: + * x :: + * The horizontal coordinate. + * y :: + * The vertical coordinate. + */ + typedef struct FT_Vector_ + { + FT_Pos x; + FT_Pos y; + + } FT_Vector; + + + /************************************************************************** + * + * @struct: + * FT_BBox + * + * @description: + * A structure used to hold an outline's bounding box, i.e., the + * coordinates of its extrema in the horizontal and vertical directions. + * + * @fields: + * xMin :: + * The horizontal minimum (left-most). + * + * yMin :: + * The vertical minimum (bottom-most). + * + * xMax :: + * The horizontal maximum (right-most). + * + * yMax :: + * The vertical maximum (top-most). + * + * @note: + * The bounding box is specified with the coordinates of the lower left + * and the upper right corner. In PostScript, those values are often + * called (llx,lly) and (urx,ury), respectively. + * + * If `yMin` is negative, this value gives the glyph's descender. + * Otherwise, the glyph doesn't descend below the baseline. Similarly, + * if `ymax` is positive, this value gives the glyph's ascender. + * + * `xMin` gives the horizontal distance from the glyph's origin to the + * left edge of the glyph's bounding box. If `xMin` is negative, the + * glyph extends to the left of the origin. + */ + typedef struct FT_BBox_ + { + FT_Pos xMin, yMin; + FT_Pos xMax, yMax; + + } FT_BBox; + + + /************************************************************************** + * + * @enum: + * FT_Pixel_Mode + * + * @description: + * An enumeration type used to describe the format of pixels in a given + * bitmap. Note that additional formats may be added in the future. + * + * @values: + * FT_PIXEL_MODE_NONE :: + * Value~0 is reserved. + * + * FT_PIXEL_MODE_MONO :: + * A monochrome bitmap, using 1~bit per pixel. Note that pixels are + * stored in most-significant order (MSB), which means that the + * left-most pixel in a byte has value 128. + * + * FT_PIXEL_MODE_GRAY :: + * An 8-bit bitmap, generally used to represent anti-aliased glyph + * images. Each pixel is stored in one byte. Note that the number of + * 'gray' levels is stored in the `num_grays` field of the @FT_Bitmap + * structure (it generally is 256). + * + * FT_PIXEL_MODE_GRAY2 :: + * A 2-bit per pixel bitmap, used to represent embedded anti-aliased + * bitmaps in font files according to the OpenType specification. We + * haven't found a single font using this format, however. + * + * FT_PIXEL_MODE_GRAY4 :: + * A 4-bit per pixel bitmap, representing embedded anti-aliased bitmaps + * in font files according to the OpenType specification. We haven't + * found a single font using this format, however. + * + * FT_PIXEL_MODE_LCD :: + * An 8-bit bitmap, representing RGB or BGR decimated glyph images used + * for display on LCD displays; the bitmap is three times wider than + * the original glyph image. See also @FT_RENDER_MODE_LCD. + * + * FT_PIXEL_MODE_LCD_V :: + * An 8-bit bitmap, representing RGB or BGR decimated glyph images used + * for display on rotated LCD displays; the bitmap is three times + * taller than the original glyph image. See also + * @FT_RENDER_MODE_LCD_V. + * + * FT_PIXEL_MODE_BGRA :: + * [Since 2.5] An image with four 8-bit channels per pixel, + * representing a color image (such as emoticons) with alpha channel. + * For each pixel, the format is BGRA, which means, the blue channel + * comes first in memory. The color channels are pre-multiplied and in + * the sRGB colorspace. For example, full red at half-translucent + * opacity will be represented as '00,00,80,80', not '00,00,FF,80'. + * See also @FT_LOAD_COLOR. + */ + typedef enum FT_Pixel_Mode_ + { + FT_PIXEL_MODE_NONE = 0, + FT_PIXEL_MODE_MONO, + FT_PIXEL_MODE_GRAY, + FT_PIXEL_MODE_GRAY2, + FT_PIXEL_MODE_GRAY4, + FT_PIXEL_MODE_LCD, + FT_PIXEL_MODE_LCD_V, + FT_PIXEL_MODE_BGRA, + + FT_PIXEL_MODE_MAX /* do not remove */ + + } FT_Pixel_Mode; + + + /* these constants are deprecated; use the corresponding `FT_Pixel_Mode` */ + /* values instead. */ +#define ft_pixel_mode_none FT_PIXEL_MODE_NONE +#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO +#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY +#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2 +#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4 + + /* */ + + /* For debugging, the @FT_Pixel_Mode enumeration must stay in sync */ + /* with the `pixel_modes` array in file `ftobjs.c`. */ + + + /************************************************************************** + * + * @struct: + * FT_Bitmap + * + * @description: + * A structure used to describe a bitmap or pixmap to the raster. Note + * that we now manage pixmaps of various depths through the `pixel_mode` + * field. + * + * @fields: + * rows :: + * The number of bitmap rows. + * + * width :: + * The number of pixels in bitmap row. + * + * pitch :: + * The pitch's absolute value is the number of bytes taken by one + * bitmap row, including padding. However, the pitch is positive when + * the bitmap has a 'down' flow, and negative when it has an 'up' flow. + * In all cases, the pitch is an offset to add to a bitmap pointer in + * order to go down one row. + * + * Note that 'padding' means the alignment of a bitmap to a byte + * border, and FreeType functions normally align to the smallest + * possible integer value. + * + * For the B/W rasterizer, `pitch` is always an even number. + * + * To change the pitch of a bitmap (say, to make it a multiple of 4), + * use @FT_Bitmap_Convert. Alternatively, you might use callback + * functions to directly render to the application's surface; see the + * file `example2.cpp` in the tutorial for a demonstration. + * + * buffer :: + * A typeless pointer to the bitmap buffer. This value should be + * aligned on 32-bit boundaries in most cases. + * + * num_grays :: + * This field is only used with @FT_PIXEL_MODE_GRAY; it gives the + * number of gray levels used in the bitmap. + * + * pixel_mode :: + * The pixel mode, i.e., how pixel bits are stored. See @FT_Pixel_Mode + * for possible values. + * + * palette_mode :: + * This field is intended for paletted pixel modes; it indicates how + * the palette is stored. Not used currently. + * + * palette :: + * A typeless pointer to the bitmap palette; this field is intended for + * paletted pixel modes. Not used currently. + * + * @note: + * `width` and `rows` refer to the *physical* size of the bitmap, not the + * *logical* one. For example, if @FT_Pixel_Mode is set to + * `FT_PIXEL_MODE_LCD`, the logical width is a just a third of the + * physical one. + */ + typedef struct FT_Bitmap_ + { + unsigned int rows; + unsigned int width; + int pitch; + unsigned char* buffer; + unsigned short num_grays; + unsigned char pixel_mode; + unsigned char palette_mode; + void* palette; + + } FT_Bitmap; + + + /************************************************************************** + * + * @section: + * outline_processing + * + */ + + + /************************************************************************** + * + * @struct: + * FT_Outline + * + * @description: + * This structure is used to describe an outline to the scan-line + * converter. + * + * @fields: + * n_contours :: + * The number of contours in the outline. + * + * n_points :: + * The number of points in the outline. + * + * points :: + * A pointer to an array of `n_points` @FT_Vector elements, giving the + * outline's point coordinates. + * + * tags :: + * A pointer to an array of `n_points` chars, giving each outline + * point's type. + * + * If bit~0 is unset, the point is 'off' the curve, i.e., a Bezier + * control point, while it is 'on' if set. + * + * Bit~1 is meaningful for 'off' points only. If set, it indicates a + * third-order Bezier arc control point; and a second-order control + * point if unset. + * + * If bit~2 is set, bits 5-7 contain the drop-out mode (as defined in + * the OpenType specification; the value is the same as the argument to + * the 'SCANTYPE' instruction). + * + * Bits 3 and~4 are reserved for internal purposes. + * + * contours :: + * An array of `n_contours` shorts, giving the end point of each + * contour within the outline. For example, the first contour is + * defined by the points '0' to `contours[0]`, the second one is + * defined by the points `contours[0]+1` to `contours[1]`, etc. + * + * flags :: + * A set of bit flags used to characterize the outline and give hints + * to the scan-converter and hinter on how to convert/grid-fit it. See + * @FT_OUTLINE_XXX. + * + * @note: + * The B/W rasterizer only checks bit~2 in the `tags` array for the first + * point of each contour. The drop-out mode as given with + * @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and + * @FT_OUTLINE_INCLUDE_STUBS in `flags` is then overridden. + */ + typedef struct FT_Outline_ + { + unsigned short n_contours; /* number of contours in glyph */ + unsigned short n_points; /* number of points in the glyph */ + + FT_Vector* points; /* the outline's points */ + unsigned char* tags; /* the points flags */ + unsigned short* contours; /* the contour end points */ + + int flags; /* outline masks */ + + } FT_Outline; + + /* */ + + /* Following limits must be consistent with */ + /* FT_Outline.{n_contours,n_points} */ +#define FT_OUTLINE_CONTOURS_MAX USHRT_MAX +#define FT_OUTLINE_POINTS_MAX USHRT_MAX + + + /************************************************************************** + * + * @enum: + * FT_OUTLINE_XXX + * + * @description: + * A list of bit-field constants used for the flags in an outline's + * `flags` field. + * + * @values: + * FT_OUTLINE_NONE :: + * Value~0 is reserved. + * + * FT_OUTLINE_OWNER :: + * If set, this flag indicates that the outline's field arrays (i.e., + * `points`, `flags`, and `contours`) are 'owned' by the outline + * object, and should thus be freed when it is destroyed. + * + * FT_OUTLINE_EVEN_ODD_FILL :: + * By default, outlines are filled using the non-zero winding rule. If + * set to 1, the outline will be filled using the even-odd fill rule + * (only works with the smooth rasterizer). + * + * FT_OUTLINE_REVERSE_FILL :: + * By default, outside contours of an outline are oriented in + * clock-wise direction, as defined in the TrueType specification. + * This flag is set if the outline uses the opposite direction + * (typically for Type~1 fonts). This flag is ignored by the scan + * converter. + * + * FT_OUTLINE_IGNORE_DROPOUTS :: + * By default, the scan converter will try to detect drop-outs in an + * outline and correct the glyph bitmap to ensure consistent shape + * continuity. If set, this flag hints the scan-line converter to + * ignore such cases. See below for more information. + * + * FT_OUTLINE_SMART_DROPOUTS :: + * Select smart dropout control. If unset, use simple dropout control. + * Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more + * information. + * + * FT_OUTLINE_INCLUDE_STUBS :: + * If set, turn pixels on for 'stubs', otherwise exclude them. Ignored + * if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more + * information. + * + * FT_OUTLINE_OVERLAP :: + * [Since 2.10.3] This flag indicates that this outline contains + * overlapping contours and the anti-aliased renderer should perform + * oversampling to mitigate possible artifacts. This flag should _not_ + * be set for well designed glyphs without overlaps because it quadruples + * the rendering time. + * + * FT_OUTLINE_HIGH_PRECISION :: + * This flag indicates that the scan-line converter should try to + * convert this outline to bitmaps with the highest possible quality. + * It is typically set for small character sizes. Note that this is + * only a hint that might be completely ignored by a given + * scan-converter. + * + * FT_OUTLINE_SINGLE_PASS :: + * This flag is set to force a given scan-converter to only use a + * single pass over the outline to render a bitmap glyph image. + * Normally, it is set for very large character sizes. It is only a + * hint that might be completely ignored by a given scan-converter. + * + * @note: + * The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and + * @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth rasterizer. + * + * There exists a second mechanism to pass the drop-out mode to the B/W + * rasterizer; see the `tags` field in @FT_Outline. + * + * Please refer to the description of the 'SCANTYPE' instruction in the + * [OpenType specification](https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions#scantype) + * how simple drop-outs, smart drop-outs, and stubs are defined. + */ +#define FT_OUTLINE_NONE 0x0 +#define FT_OUTLINE_OWNER 0x1 +#define FT_OUTLINE_EVEN_ODD_FILL 0x2 +#define FT_OUTLINE_REVERSE_FILL 0x4 +#define FT_OUTLINE_IGNORE_DROPOUTS 0x8 +#define FT_OUTLINE_SMART_DROPOUTS 0x10 +#define FT_OUTLINE_INCLUDE_STUBS 0x20 +#define FT_OUTLINE_OVERLAP 0x40 + +#define FT_OUTLINE_HIGH_PRECISION 0x100 +#define FT_OUTLINE_SINGLE_PASS 0x200 + + + /* these constants are deprecated; use the corresponding */ + /* `FT_OUTLINE_XXX` values instead */ +#define ft_outline_none FT_OUTLINE_NONE +#define ft_outline_owner FT_OUTLINE_OWNER +#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL +#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL +#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS +#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION +#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS + + /* */ + +#define FT_CURVE_TAG( flag ) ( flag & 0x03 ) + + /* see the `tags` field in `FT_Outline` for a description of the values */ +#define FT_CURVE_TAG_ON 0x01 +#define FT_CURVE_TAG_CONIC 0x00 +#define FT_CURVE_TAG_CUBIC 0x02 + +#define FT_CURVE_TAG_HAS_SCANMODE 0x04 + +#define FT_CURVE_TAG_TOUCH_X 0x08 /* reserved for TrueType hinter */ +#define FT_CURVE_TAG_TOUCH_Y 0x10 /* reserved for TrueType hinter */ + +#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \ + FT_CURVE_TAG_TOUCH_Y ) + /* values 0x20, 0x40, and 0x80 are reserved */ + + + /* these constants are deprecated; use the corresponding */ + /* `FT_CURVE_TAG_XXX` values instead */ +#define FT_Curve_Tag_On FT_CURVE_TAG_ON +#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC +#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC +#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X +#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y + + + /************************************************************************** + * + * @functype: + * FT_Outline_MoveToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'move to' + * function during outline walking/decomposition. + * + * A 'move to' is emitted to start a new contour in an outline. + * + * @input: + * to :: + * A pointer to the target point of the 'move to'. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ + typedef int + (*FT_Outline_MoveToFunc)( const FT_Vector* to, + void* user ); + +#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc + + + /************************************************************************** + * + * @functype: + * FT_Outline_LineToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'line to' + * function during outline walking/decomposition. + * + * A 'line to' is emitted to indicate a segment in the outline. + * + * @input: + * to :: + * A pointer to the target point of the 'line to'. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ + typedef int + (*FT_Outline_LineToFunc)( const FT_Vector* to, + void* user ); + +#define FT_Outline_LineTo_Func FT_Outline_LineToFunc + + + /************************************************************************** + * + * @functype: + * FT_Outline_ConicToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'conic to' + * function during outline walking or decomposition. + * + * A 'conic to' is emitted to indicate a second-order Bezier arc in the + * outline. + * + * @input: + * control :: + * An intermediate control point between the last position and the new + * target in `to`. + * + * to :: + * A pointer to the target end point of the conic arc. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ + typedef int + (*FT_Outline_ConicToFunc)( const FT_Vector* control, + const FT_Vector* to, + void* user ); + +#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc + + + /************************************************************************** + * + * @functype: + * FT_Outline_CubicToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'cubic to' + * function during outline walking or decomposition. + * + * A 'cubic to' is emitted to indicate a third-order Bezier arc. + * + * @input: + * control1 :: + * A pointer to the first Bezier control point. + * + * control2 :: + * A pointer to the second Bezier control point. + * + * to :: + * A pointer to the target end point. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ + typedef int + (*FT_Outline_CubicToFunc)( const FT_Vector* control1, + const FT_Vector* control2, + const FT_Vector* to, + void* user ); + +#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc + + + /************************************************************************** + * + * @struct: + * FT_Outline_Funcs + * + * @description: + * A structure to hold various function pointers used during outline + * decomposition in order to emit segments, conic, and cubic Beziers. + * + * @fields: + * move_to :: + * The 'move to' emitter. + * + * line_to :: + * The segment emitter. + * + * conic_to :: + * The second-order Bezier arc emitter. + * + * cubic_to :: + * The third-order Bezier arc emitter. + * + * shift :: + * The shift that is applied to coordinates before they are sent to the + * emitter. + * + * delta :: + * The delta that is applied to coordinates before they are sent to the + * emitter, but after the shift. + * + * @note: + * The point coordinates sent to the emitters are the transformed version + * of the original coordinates (this is important for high accuracy + * during scan-conversion). The transformation is simple: + * + * ``` + * x' = (x << shift) - delta + * y' = (y << shift) - delta + * ``` + * + * Set the values of `shift` and `delta` to~0 to get the original point + * coordinates. + */ + typedef struct FT_Outline_Funcs_ + { + FT_Outline_MoveToFunc move_to; + FT_Outline_LineToFunc line_to; + FT_Outline_ConicToFunc conic_to; + FT_Outline_CubicToFunc cubic_to; + + int shift; + FT_Pos delta; + + } FT_Outline_Funcs; + + + /************************************************************************** + * + * @section: + * basic_types + * + */ + + + /************************************************************************** + * + * @macro: + * FT_IMAGE_TAG + * + * @description: + * This macro converts four-letter tags to an unsigned long type. + * + * @note: + * Since many 16-bit compilers don't like 32-bit enumerations, you should + * redefine this macro in case of problems to something like this: + * + * ``` + * #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value + * ``` + * + * to get a simple enumeration without assigning special numbers. + */ +#ifndef FT_IMAGE_TAG + +#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ + value = ( ( FT_STATIC_BYTE_CAST( unsigned long, _x1 ) << 24 ) | \ + ( FT_STATIC_BYTE_CAST( unsigned long, _x2 ) << 16 ) | \ + ( FT_STATIC_BYTE_CAST( unsigned long, _x3 ) << 8 ) | \ + FT_STATIC_BYTE_CAST( unsigned long, _x4 ) ) + +#endif /* FT_IMAGE_TAG */ + + + /************************************************************************** + * + * @enum: + * FT_Glyph_Format + * + * @description: + * An enumeration type used to describe the format of a given glyph + * image. Note that this version of FreeType only supports two image + * formats, even though future font drivers will be able to register + * their own format. + * + * @values: + * FT_GLYPH_FORMAT_NONE :: + * The value~0 is reserved. + * + * FT_GLYPH_FORMAT_COMPOSITE :: + * The glyph image is a composite of several other images. This format + * is _only_ used with @FT_LOAD_NO_RECURSE, and is used to report + * compound glyphs (like accented characters). + * + * FT_GLYPH_FORMAT_BITMAP :: + * The glyph image is a bitmap, and can be described as an @FT_Bitmap. + * You generally need to access the `bitmap` field of the + * @FT_GlyphSlotRec structure to read it. + * + * FT_GLYPH_FORMAT_OUTLINE :: + * The glyph image is a vectorial outline made of line segments and + * Bezier arcs; it can be described as an @FT_Outline; you generally + * want to access the `outline` field of the @FT_GlyphSlotRec structure + * to read it. + * + * FT_GLYPH_FORMAT_PLOTTER :: + * The glyph image is a vectorial path with no inside and outside + * contours. Some Type~1 fonts, like those in the Hershey family, + * contain glyphs in this format. These are described as @FT_Outline, + * but FreeType isn't currently capable of rendering them correctly. + * + * FT_GLYPH_FORMAT_SVG :: + * [Since 2.12] The glyph is represented by an SVG document in the + * 'SVG~' table. + */ + typedef enum FT_Glyph_Format_ + { + FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), + + FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_SVG, 'S', 'V', 'G', ' ' ) + + } FT_Glyph_Format; + + + /* these constants are deprecated; use the corresponding */ + /* `FT_Glyph_Format` values instead. */ +#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE +#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE +#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP +#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE +#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** R A S T E R D E F I N I T I O N S *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + + /************************************************************************** + * + * @section: + * raster + * + * @title: + * Scanline Converter + * + * @abstract: + * How vectorial outlines are converted into bitmaps and pixmaps. + * + * @description: + * A raster or a rasterizer is a scan converter in charge of producing a + * pixel coverage bitmap that can be used as an alpha channel when + * compositing a glyph with a background. FreeType comes with two + * rasterizers: bilevel `raster1` and anti-aliased `smooth` are two + * separate modules. They are usually called from the high-level + * @FT_Load_Glyph or @FT_Render_Glyph functions and produce the entire + * coverage bitmap at once, while staying largely invisible to users. + * + * Instead of working with complete coverage bitmaps, it is also possible + * to intercept consecutive pixel runs on the same scanline with the same + * coverage, called _spans_, and process them individually. Only the + * `smooth` rasterizer permits this when calling @FT_Outline_Render with + * @FT_Raster_Params as described below. + * + * Working with either complete bitmaps or spans it is important to think + * of them as colorless coverage objects suitable as alpha channels to + * blend arbitrary colors with a background. For best results, it is + * recommended to use gamma correction, too. + * + * This section also describes the public API needed to set up alternative + * @FT_Renderer modules. + * + * @order: + * FT_Span + * FT_SpanFunc + * FT_Raster_Params + * FT_RASTER_FLAG_XXX + * + * FT_Raster + * FT_Raster_NewFunc + * FT_Raster_DoneFunc + * FT_Raster_ResetFunc + * FT_Raster_SetModeFunc + * FT_Raster_RenderFunc + * FT_Raster_Funcs + * + */ + + + /************************************************************************** + * + * @struct: + * FT_Span + * + * @description: + * A structure to model a single span of consecutive pixels when + * rendering an anti-aliased bitmap. + * + * @fields: + * x :: + * The span's horizontal start position. + * + * len :: + * The span's length in pixels. + * + * coverage :: + * The span color/coverage, ranging from 0 (background) to 255 + * (foreground). + * + * @note: + * This structure is used by the span drawing callback type named + * @FT_SpanFunc that takes the y~coordinate of the span as a parameter. + * + * The anti-aliased rasterizer produces coverage values from 0 to 255, + * that is, from completely transparent to completely opaque. + */ + typedef struct FT_Span_ + { + short x; + unsigned short len; + unsigned char coverage; + + } FT_Span; + + + /************************************************************************** + * + * @functype: + * FT_SpanFunc + * + * @description: + * A function used as a call-back by the anti-aliased renderer in order + * to let client applications draw themselves the pixel spans on each + * scan line. + * + * @input: + * y :: + * The scanline's upward y~coordinate. + * + * count :: + * The number of spans to draw on this scanline. + * + * spans :: + * A table of `count` spans to draw on the scanline. + * + * user :: + * User-supplied data that is passed to the callback. + * + * @note: + * This callback allows client applications to directly render the spans + * of the anti-aliased bitmap to any kind of surfaces. + * + * This can be used to write anti-aliased outlines directly to a given + * background bitmap using alpha compositing. It can also be used for + * oversampling and averaging. + */ + typedef void + (*FT_SpanFunc)( int y, + int count, + const FT_Span* spans, + void* user ); + +#define FT_Raster_Span_Func FT_SpanFunc + + + /************************************************************************** + * + * @functype: + * FT_Raster_BitTest_Func + * + * @description: + * Deprecated, unimplemented. + */ + typedef int + (*FT_Raster_BitTest_Func)( int y, + int x, + void* user ); + + + /************************************************************************** + * + * @functype: + * FT_Raster_BitSet_Func + * + * @description: + * Deprecated, unimplemented. + */ + typedef void + (*FT_Raster_BitSet_Func)( int y, + int x, + void* user ); + + + /************************************************************************** + * + * @enum: + * FT_RASTER_FLAG_XXX + * + * @description: + * A list of bit flag constants as used in the `flags` field of a + * @FT_Raster_Params structure. + * + * @values: + * FT_RASTER_FLAG_DEFAULT :: + * This value is 0. + * + * FT_RASTER_FLAG_AA :: + * This flag is set to indicate that an anti-aliased glyph image should + * be generated. Otherwise, it will be monochrome (1-bit). + * + * FT_RASTER_FLAG_DIRECT :: + * This flag is set to indicate direct rendering. In this mode, client + * applications must provide their own span callback. This lets them + * directly draw or compose over an existing bitmap. If this bit is + * _not_ set, the target pixmap's buffer _must_ be zeroed before + * rendering and the output will be clipped to its size. + * + * Direct rendering is only possible with anti-aliased glyphs. + * + * FT_RASTER_FLAG_CLIP :: + * This flag is only used in direct rendering mode. If set, the output + * will be clipped to a box specified in the `clip_box` field of the + * @FT_Raster_Params structure. Otherwise, the `clip_box` is + * effectively set to the bounding box and all spans are generated. + * + * FT_RASTER_FLAG_SDF :: + * This flag is set to indicate that a signed distance field glyph + * image should be generated. This is only used while rendering with + * the @FT_RENDER_MODE_SDF render mode. + */ +#define FT_RASTER_FLAG_DEFAULT 0x0 +#define FT_RASTER_FLAG_AA 0x1 +#define FT_RASTER_FLAG_DIRECT 0x2 +#define FT_RASTER_FLAG_CLIP 0x4 +#define FT_RASTER_FLAG_SDF 0x8 + + /* these constants are deprecated; use the corresponding */ + /* `FT_RASTER_FLAG_XXX` values instead */ +#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT +#define ft_raster_flag_aa FT_RASTER_FLAG_AA +#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT +#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP + + + /************************************************************************** + * + * @struct: + * FT_Raster_Params + * + * @description: + * A structure to hold the parameters used by a raster's render function, + * passed as an argument to @FT_Outline_Render. + * + * @fields: + * target :: + * The target bitmap. + * + * source :: + * A pointer to the source glyph image (e.g., an @FT_Outline). + * + * flags :: + * The rendering flags. + * + * gray_spans :: + * The gray span drawing callback. + * + * black_spans :: + * Unused. + * + * bit_test :: + * Unused. + * + * bit_set :: + * Unused. + * + * user :: + * User-supplied data that is passed to each drawing callback. + * + * clip_box :: + * An optional span clipping box expressed in _integer_ pixels + * (not in 26.6 fixed-point units). + * + * @note: + * The @FT_RASTER_FLAG_AA bit flag must be set in the `flags` to + * generate an anti-aliased glyph bitmap, otherwise a monochrome bitmap + * is generated. The `target` should have appropriate pixel mode and its + * dimensions define the clipping region. + * + * If both @FT_RASTER_FLAG_AA and @FT_RASTER_FLAG_DIRECT bit flags + * are set in `flags`, the raster calls an @FT_SpanFunc callback + * `gray_spans` with `user` data as an argument ignoring `target`. This + * allows direct composition over a pre-existing user surface to perform + * the span drawing and composition. To optionally clip the spans, set + * the @FT_RASTER_FLAG_CLIP flag and `clip_box`. The monochrome raster + * does not support the direct mode. + * + * The gray-level rasterizer always uses 256 gray levels. If you want + * fewer gray levels, you have to use @FT_RASTER_FLAG_DIRECT and reduce + * the levels in the callback function. + */ + typedef struct FT_Raster_Params_ + { + const FT_Bitmap* target; + const void* source; + int flags; + FT_SpanFunc gray_spans; + FT_SpanFunc black_spans; /* unused */ + FT_Raster_BitTest_Func bit_test; /* unused */ + FT_Raster_BitSet_Func bit_set; /* unused */ + void* user; + FT_BBox clip_box; + + } FT_Raster_Params; + + + /************************************************************************** + * + * @type: + * FT_Raster + * + * @description: + * An opaque handle (pointer) to a raster object. Each object can be + * used independently to convert an outline into a bitmap or pixmap. + * + * @note: + * In FreeType 2, all rasters are now encapsulated within specific + * @FT_Renderer modules and only used in their context. + * + */ + typedef struct FT_RasterRec_* FT_Raster; + + + /************************************************************************** + * + * @functype: + * FT_Raster_NewFunc + * + * @description: + * A function used to create a new raster object. + * + * @input: + * memory :: + * A handle to the memory allocator. + * + * @output: + * raster :: + * A handle to the new raster object. + * + * @return: + * Error code. 0~means success. + * + * @note: + * The `memory` parameter is a typeless pointer in order to avoid + * un-wanted dependencies on the rest of the FreeType code. In practice, + * it is an @FT_Memory object, i.e., a handle to the standard FreeType + * memory allocator. However, this field can be completely ignored by a + * given raster implementation. + */ + typedef int + (*FT_Raster_NewFunc)( void* memory, + FT_Raster* raster ); + +#define FT_Raster_New_Func FT_Raster_NewFunc + + + /************************************************************************** + * + * @functype: + * FT_Raster_DoneFunc + * + * @description: + * A function used to destroy a given raster object. + * + * @input: + * raster :: + * A handle to the raster object. + */ + typedef void + (*FT_Raster_DoneFunc)( FT_Raster raster ); + +#define FT_Raster_Done_Func FT_Raster_DoneFunc + + + /************************************************************************** + * + * @functype: + * FT_Raster_ResetFunc + * + * @description: + * FreeType used to provide an area of memory called the 'render pool' + * available to all registered rasterizers. This was not thread safe, + * however, and now FreeType never allocates this pool. + * + * This function is called after a new raster object is created. + * + * @input: + * raster :: + * A handle to the new raster object. + * + * pool_base :: + * Previously, the address in memory of the render pool. Set this to + * `NULL`. + * + * pool_size :: + * Previously, the size in bytes of the render pool. Set this to 0. + * + * @note: + * Rasterizers should rely on dynamic or stack allocation if they want to + * (a handle to the memory allocator is passed to the rasterizer + * constructor). + */ + typedef void + (*FT_Raster_ResetFunc)( FT_Raster raster, + unsigned char* pool_base, + unsigned long pool_size ); + +#define FT_Raster_Reset_Func FT_Raster_ResetFunc + + + /************************************************************************** + * + * @functype: + * FT_Raster_SetModeFunc + * + * @description: + * This function is a generic facility to change modes or attributes in a + * given raster. This can be used for debugging purposes, or simply to + * allow implementation-specific 'features' in a given raster module. + * + * @input: + * raster :: + * A handle to the new raster object. + * + * mode :: + * A 4-byte tag used to name the mode or property. + * + * args :: + * A pointer to the new mode/property to use. + */ + typedef int + (*FT_Raster_SetModeFunc)( FT_Raster raster, + unsigned long mode, + void* args ); + +#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc + + + /************************************************************************** + * + * @functype: + * FT_Raster_RenderFunc + * + * @description: + * Invoke a given raster to scan-convert a given glyph image into a + * target bitmap. + * + * @input: + * raster :: + * A handle to the raster object. + * + * params :: + * A pointer to an @FT_Raster_Params structure used to store the + * rendering parameters. + * + * @return: + * Error code. 0~means success. + * + * @note: + * The exact format of the source image depends on the raster's glyph + * format defined in its @FT_Raster_Funcs structure. It can be an + * @FT_Outline or anything else in order to support a large array of + * glyph formats. + * + * Note also that the render function can fail and return a + * `FT_Err_Unimplemented_Feature` error code if the raster used does not + * support direct composition. + */ + typedef int + (*FT_Raster_RenderFunc)( FT_Raster raster, + const FT_Raster_Params* params ); + +#define FT_Raster_Render_Func FT_Raster_RenderFunc + + + /************************************************************************** + * + * @struct: + * FT_Raster_Funcs + * + * @description: + * A structure used to describe a given raster class to the library. + * + * @fields: + * glyph_format :: + * The supported glyph format for this raster. + * + * raster_new :: + * The raster constructor. + * + * raster_reset :: + * Used to reset the render pool within the raster. + * + * raster_render :: + * A function to render a glyph into a given bitmap. + * + * raster_done :: + * The raster destructor. + */ + typedef struct FT_Raster_Funcs_ + { + FT_Glyph_Format glyph_format; + + FT_Raster_NewFunc raster_new; + FT_Raster_ResetFunc raster_reset; + FT_Raster_SetModeFunc raster_set_mode; + FT_Raster_RenderFunc raster_render; + FT_Raster_DoneFunc raster_done; + + } FT_Raster_Funcs; + + /* */ + + +FT_END_HEADER + +#endif /* FTIMAGE_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftincrem.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftincrem.h new file mode 100644 index 0000000000000000000000000000000000000000..d9ffa83a230781f5391a11e8862b877407e0992f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftincrem.h @@ -0,0 +1,348 @@ +/**************************************************************************** + * + * ftincrem.h + * + * FreeType incremental loading (specification). + * + * Copyright (C) 2002-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTINCREM_H_ +#define FTINCREM_H_ + +#include +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /************************************************************************** + * + * @section: + * incremental + * + * @title: + * Incremental Loading + * + * @abstract: + * Custom Glyph Loading. + * + * @description: + * This section contains various functions used to perform so-called + * 'incremental' glyph loading. This is a mode where all glyphs loaded + * from a given @FT_Face are provided by the client application. + * + * Apart from that, all other tables are loaded normally from the font + * file. This mode is useful when FreeType is used within another + * engine, e.g., a PostScript Imaging Processor. + * + * To enable this mode, you must use @FT_Open_Face, passing an + * @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an + * @FT_Incremental_Interface value. See the comments for + * @FT_Incremental_InterfaceRec for an example. + * + */ + + + /************************************************************************** + * + * @type: + * FT_Incremental + * + * @description: + * An opaque type describing a user-provided object used to implement + * 'incremental' glyph loading within FreeType. This is used to support + * embedded fonts in certain environments (e.g., PostScript + * interpreters), where the glyph data isn't in the font file, or must be + * overridden by different values. + * + * @note: + * It is up to client applications to create and implement + * @FT_Incremental objects, as long as they provide implementations for + * the methods @FT_Incremental_GetGlyphDataFunc, + * @FT_Incremental_FreeGlyphDataFunc and + * @FT_Incremental_GetGlyphMetricsFunc. + * + * See the description of @FT_Incremental_InterfaceRec to understand how + * to use incremental objects with FreeType. + * + */ + typedef struct FT_IncrementalRec_* FT_Incremental; + + + /************************************************************************** + * + * @struct: + * FT_Incremental_MetricsRec + * + * @description: + * A small structure used to contain the basic glyph metrics returned by + * the @FT_Incremental_GetGlyphMetricsFunc method. + * + * @fields: + * bearing_x :: + * Left bearing, in font units. + * + * bearing_y :: + * Top bearing, in font units. + * + * advance :: + * Horizontal component of glyph advance, in font units. + * + * advance_v :: + * Vertical component of glyph advance, in font units. + * + * @note: + * These correspond to horizontal or vertical metrics depending on the + * value of the `vertical` argument to the function + * @FT_Incremental_GetGlyphMetricsFunc. + * + */ + typedef struct FT_Incremental_MetricsRec_ + { + FT_Long bearing_x; + FT_Long bearing_y; + FT_Long advance; + FT_Long advance_v; /* since 2.3.12 */ + + } FT_Incremental_MetricsRec; + + + /************************************************************************** + * + * @struct: + * FT_Incremental_Metrics + * + * @description: + * A handle to an @FT_Incremental_MetricsRec structure. + * + */ + typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics; + + + /************************************************************************** + * + * @type: + * FT_Incremental_GetGlyphDataFunc + * + * @description: + * A function called by FreeType to access a given glyph's data bytes + * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is + * enabled. + * + * Note that the format of the glyph's data bytes depends on the font + * file format. For TrueType, it must correspond to the raw bytes within + * the 'glyf' table. For PostScript formats, it must correspond to the + * **unencrypted** charstring bytes, without any `lenIV` header. It is + * undefined for any other format. + * + * @input: + * incremental :: + * Handle to an opaque @FT_Incremental handle provided by the client + * application. + * + * glyph_index :: + * Index of relevant glyph. + * + * @output: + * adata :: + * A structure describing the returned glyph data bytes (which will be + * accessed as a read-only byte block). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If this function returns successfully the method + * @FT_Incremental_FreeGlyphDataFunc will be called later to release the + * data bytes. + * + * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for + * compound glyphs. + * + */ + typedef FT_Error + (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental, + FT_UInt glyph_index, + FT_Data* adata ); + + + /************************************************************************** + * + * @type: + * FT_Incremental_FreeGlyphDataFunc + * + * @description: + * A function used to release the glyph data bytes returned by a + * successful call to @FT_Incremental_GetGlyphDataFunc. + * + * @input: + * incremental :: + * A handle to an opaque @FT_Incremental handle provided by the client + * application. + * + * data :: + * A structure describing the glyph data bytes (which will be accessed + * as a read-only byte block). + * + */ + typedef void + (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental, + FT_Data* data ); + + + /************************************************************************** + * + * @type: + * FT_Incremental_GetGlyphMetricsFunc + * + * @description: + * A function used to retrieve the basic metrics of a given glyph index + * before accessing its data. This allows for handling font types such + * as PCL~XL Format~1, Class~2 downloaded TrueType fonts, where the glyph + * metrics (`hmtx` and `vmtx` tables) are permitted to be omitted from + * the font, and the relevant metrics included in the header of the glyph + * outline data. Importantly, this is not intended to allow custom glyph + * metrics (for example, Postscript Metrics dictionaries), because that + * conflicts with the requirements of outline hinting. Such custom + * metrics must be handled separately, by the calling application. + * + * @input: + * incremental :: + * A handle to an opaque @FT_Incremental handle provided by the client + * application. + * + * glyph_index :: + * Index of relevant glyph. + * + * vertical :: + * If true, return vertical metrics. + * + * ametrics :: + * This parameter is used for both input and output. The original + * glyph metrics, if any, in font units. If metrics are not available + * all the values must be set to zero. + * + * @output: + * ametrics :: + * The glyph metrics in font units. + * + */ + typedef FT_Error + (*FT_Incremental_GetGlyphMetricsFunc) + ( FT_Incremental incremental, + FT_UInt glyph_index, + FT_Bool vertical, + FT_Incremental_MetricsRec *ametrics ); + + + /************************************************************************** + * + * @struct: + * FT_Incremental_FuncsRec + * + * @description: + * A table of functions for accessing fonts that load data incrementally. + * Used in @FT_Incremental_InterfaceRec. + * + * @fields: + * get_glyph_data :: + * The function to get glyph data. Must not be null. + * + * free_glyph_data :: + * The function to release glyph data. Must not be null. + * + * get_glyph_metrics :: + * The function to get glyph metrics. May be null if the font does not + * require it. + * + */ + typedef struct FT_Incremental_FuncsRec_ + { + FT_Incremental_GetGlyphDataFunc get_glyph_data; + FT_Incremental_FreeGlyphDataFunc free_glyph_data; + FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics; + + } FT_Incremental_FuncsRec; + + + /************************************************************************** + * + * @struct: + * FT_Incremental_InterfaceRec + * + * @description: + * A structure to be used with @FT_Open_Face to indicate that the user + * wants to support incremental glyph loading. You should use it with + * @FT_PARAM_TAG_INCREMENTAL as in the following example: + * + * ``` + * FT_Incremental_InterfaceRec inc_int; + * FT_Parameter parameter; + * FT_Open_Args open_args; + * + * + * // set up incremental descriptor + * inc_int.funcs = my_funcs; + * inc_int.object = my_object; + * + * // set up optional parameter + * parameter.tag = FT_PARAM_TAG_INCREMENTAL; + * parameter.data = &inc_int; + * + * // set up FT_Open_Args structure + * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; + * open_args.pathname = my_font_pathname; + * open_args.num_params = 1; + * open_args.params = ¶meter; // we use one optional argument + * + * // open the font + * error = FT_Open_Face( library, &open_args, index, &face ); + * ... + * ``` + * + */ + typedef struct FT_Incremental_InterfaceRec_ + { + const FT_Incremental_FuncsRec* funcs; + FT_Incremental object; + + } FT_Incremental_InterfaceRec; + + + /************************************************************************** + * + * @type: + * FT_Incremental_Interface + * + * @description: + * A pointer to an @FT_Incremental_InterfaceRec structure. + * + */ + typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface; + + + /* */ + + +FT_END_HEADER + +#endif /* FTINCREM_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlcdfil.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlcdfil.h new file mode 100644 index 0000000000000000000000000000000000000000..76cc549107a78f32f155401c9ac833db4ce660c8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlcdfil.h @@ -0,0 +1,323 @@ +/**************************************************************************** + * + * ftlcdfil.h + * + * FreeType API for color filtering of subpixel bitmap glyphs + * (specification). + * + * Copyright (C) 2006-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTLCDFIL_H_ +#define FTLCDFIL_H_ + +#include +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /************************************************************************** + * + * @section: + * lcd_rendering + * + * @title: + * Subpixel Rendering + * + * @abstract: + * API to control subpixel rendering. + * + * @description: + * FreeType provides two alternative subpixel rendering technologies. + * Should you define `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` in your + * `ftoption.h` file, this enables ClearType-style rendering. + * Otherwise, Harmony LCD rendering is enabled. These technologies are + * controlled differently and API described below, although always + * available, performs its function when appropriate method is enabled + * and does nothing otherwise. + * + * ClearType-style LCD rendering exploits the color-striped structure of + * LCD pixels, increasing the available resolution in the direction of + * the stripe (usually horizontal RGB) by a factor of~3. Using the + * subpixel coverages unfiltered can create severe color fringes + * especially when rendering thin features. Indeed, to produce + * black-on-white text, the nearby color subpixels must be dimmed + * evenly. Therefore, an equalizing 5-tap FIR filter should be applied + * to subpixel coverages regardless of pixel boundaries and should have + * these properties: + * + * 1. It should be symmetrical, like {~a, b, c, b, a~}, to avoid + * any shifts in appearance. + * + * 2. It should be color-balanced, meaning a~+ b~=~c, to reduce color + * fringes by distributing the computed coverage for one subpixel to + * all subpixels equally. + * + * 3. It should be normalized, meaning 2a~+ 2b~+ c~=~1.0 to maintain + * overall brightness. + * + * Boxy 3-tap filter {0, 1/3, 1/3, 1/3, 0} is sharper but is less + * forgiving of non-ideal gamma curves of a screen (and viewing angles), + * beveled filters are fuzzier but more tolerant. + * + * Use the @FT_Library_SetLcdFilter or @FT_Library_SetLcdFilterWeights + * API to specify a low-pass filter, which is then applied to + * subpixel-rendered bitmaps generated through @FT_Render_Glyph. + * + * Harmony LCD rendering is suitable to panels with any regular subpixel + * structure, not just monitors with 3 color striped subpixels, as long + * as the color subpixels have fixed positions relative to the pixel + * center. In this case, each color channel can be rendered separately + * after shifting the outline opposite to the subpixel shift so that the + * coverage maps are aligned. This method is immune to color fringes + * because the shifts do not change integral coverage. + * + * The subpixel geometry must be specified by xy-coordinates for each + * subpixel. By convention they may come in the RGB order: {{-1/3, 0}, + * {0, 0}, {1/3, 0}} for standard RGB striped panel or {{-1/6, 1/4}, + * {-1/6, -1/4}, {1/3, 0}} for a certain PenTile panel. + * + * Use the @FT_Library_SetLcdGeometry API to specify subpixel positions. + * If one follows the RGB order convention, the same order applies to the + * resulting @FT_PIXEL_MODE_LCD and @FT_PIXEL_MODE_LCD_V bitmaps. Note, + * however, that the coordinate frame for the latter must be rotated + * clockwise. Harmony with default LCD geometry is equivalent to + * ClearType with light filter. + * + * As a result of ClearType filtering or Harmony shifts, the resulting + * dimensions of LCD bitmaps can be slightly wider or taller than the + * dimensions the original outline with regard to the pixel grid. + * For example, for @FT_RENDER_MODE_LCD, the filter adds 2~subpixels to + * the left, and 2~subpixels to the right. The bitmap offset values are + * adjusted accordingly, so clients shouldn't need to modify their layout + * and glyph positioning code when enabling the filter. + * + * The ClearType and Harmony rendering is applicable to glyph bitmaps + * rendered through @FT_Render_Glyph, @FT_Load_Glyph, @FT_Load_Char, and + * @FT_Glyph_To_Bitmap, when @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V + * is specified. This API does not control @FT_Outline_Render and + * @FT_Outline_Get_Bitmap. + * + * The described algorithms can completely remove color artefacts when + * combined with gamma-corrected alpha blending in linear space. Each of + * the 3~alpha values (subpixels) must by independently used to blend one + * color channel. That is, red alpha blends the red channel of the text + * color with the red channel of the background pixel. + */ + + + /************************************************************************** + * + * @enum: + * FT_LcdFilter + * + * @description: + * A list of values to identify various types of LCD filters. + * + * @values: + * FT_LCD_FILTER_NONE :: + * Do not perform filtering. When used with subpixel rendering, this + * results in sometimes severe color fringes. + * + * FT_LCD_FILTER_DEFAULT :: + * This is a beveled, normalized, and color-balanced five-tap filter + * with weights of [0x08 0x4D 0x56 0x4D 0x08] in 1/256 units. + * + * FT_LCD_FILTER_LIGHT :: + * this is a boxy, normalized, and color-balanced three-tap filter with + * weights of [0x00 0x55 0x56 0x55 0x00] in 1/256 units. + * + * FT_LCD_FILTER_LEGACY :: + * FT_LCD_FILTER_LEGACY1 :: + * This filter corresponds to the original libXft color filter. It + * provides high contrast output but can exhibit really bad color + * fringes if glyphs are not extremely well hinted to the pixel grid. + * This filter is only provided for comparison purposes, and might be + * disabled or stay unsupported in the future. The second value is + * provided for compatibility with FontConfig, which historically used + * different enumeration, sometimes incorrectly forwarded to FreeType. + * + * @since: + * 2.3.0 (`FT_LCD_FILTER_LEGACY1` since 2.6.2) + */ + typedef enum FT_LcdFilter_ + { + FT_LCD_FILTER_NONE = 0, + FT_LCD_FILTER_DEFAULT = 1, + FT_LCD_FILTER_LIGHT = 2, + FT_LCD_FILTER_LEGACY1 = 3, + FT_LCD_FILTER_LEGACY = 16, + + FT_LCD_FILTER_MAX /* do not remove */ + + } FT_LcdFilter; + + + /************************************************************************** + * + * @function: + * FT_Library_SetLcdFilter + * + * @description: + * This function is used to change filter applied to LCD decimated + * bitmaps, like the ones used when calling @FT_Render_Glyph with + * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V. + * + * @input: + * library :: + * A handle to the target library instance. + * + * filter :: + * The filter type. + * + * You can use @FT_LCD_FILTER_NONE here to disable this feature, or + * @FT_LCD_FILTER_DEFAULT to use a default filter that should work well + * on most LCD screens. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Since 2.10.3 the LCD filtering is enabled with @FT_LCD_FILTER_DEFAULT. + * It is no longer necessary to call this function explicitly except + * to choose a different filter or disable filtering altogether with + * @FT_LCD_FILTER_NONE. + * + * This function does nothing but returns `FT_Err_Unimplemented_Feature` + * if the configuration macro `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is + * not defined in your build of the library. + * + * @since: + * 2.3.0 + */ + FT_EXPORT( FT_Error ) + FT_Library_SetLcdFilter( FT_Library library, + FT_LcdFilter filter ); + + + /************************************************************************** + * + * @function: + * FT_Library_SetLcdFilterWeights + * + * @description: + * This function can be used to enable LCD filter with custom weights, + * instead of using presets in @FT_Library_SetLcdFilter. + * + * @input: + * library :: + * A handle to the target library instance. + * + * weights :: + * A pointer to an array; the function copies the first five bytes and + * uses them to specify the filter weights in 1/256 units. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function does nothing but returns `FT_Err_Unimplemented_Feature` + * if the configuration macro `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is + * not defined in your build of the library. + * + * LCD filter weights can also be set per face using @FT_Face_Properties + * with @FT_PARAM_TAG_LCD_FILTER_WEIGHTS. + * + * @since: + * 2.4.0 + */ + FT_EXPORT( FT_Error ) + FT_Library_SetLcdFilterWeights( FT_Library library, + unsigned char *weights ); + + + /************************************************************************** + * + * @type: + * FT_LcdFiveTapFilter + * + * @description: + * A typedef for passing the five LCD filter weights to + * @FT_Face_Properties within an @FT_Parameter structure. + * + * @since: + * 2.8 + * + */ +#define FT_LCD_FILTER_FIVE_TAPS 5 + + typedef FT_Byte FT_LcdFiveTapFilter[FT_LCD_FILTER_FIVE_TAPS]; + + + /************************************************************************** + * + * @function: + * FT_Library_SetLcdGeometry + * + * @description: + * This function can be used to modify default positions of color + * subpixels, which controls Harmony LCD rendering. + * + * @input: + * library :: + * A handle to the target library instance. + * + * sub :: + * A pointer to an array of 3 vectors in 26.6 fractional pixel format; + * the function modifies the default values, see the note below. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Subpixel geometry examples: + * + * - {{-21, 0}, {0, 0}, {21, 0}} is the default, corresponding to 3 color + * stripes shifted by a third of a pixel. This could be an RGB panel. + * + * - {{21, 0}, {0, 0}, {-21, 0}} looks the same as the default but can + * specify a BGR panel instead, while keeping the bitmap in the same + * RGB888 format. + * + * - {{0, 21}, {0, 0}, {0, -21}} is the vertical RGB, but the bitmap + * stays RGB888 as a result. + * + * - {{-11, 16}, {-11, -16}, {22, 0}} is a certain PenTile arrangement. + * + * This function does nothing and returns `FT_Err_Unimplemented_Feature` + * in the context of ClearType-style subpixel rendering when + * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is defined in your build of the + * library. + * + * @since: + * 2.10.0 + */ + FT_EXPORT( FT_Error ) + FT_Library_SetLcdGeometry( FT_Library library, + FT_Vector sub[3] ); + + /* */ + + +FT_END_HEADER + +#endif /* FTLCDFIL_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlist.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlist.h new file mode 100644 index 0000000000000000000000000000000000000000..47bcdab775ca9285253b812f2b841b9aa8b79195 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlist.h @@ -0,0 +1,296 @@ +/**************************************************************************** + * + * ftlist.h + * + * Generic list support for FreeType (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file implements functions relative to list processing. Its data + * structures are defined in `freetype.h`. + * + */ + + +#ifndef FTLIST_H_ +#define FTLIST_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * list_processing + * + * @title: + * List Processing + * + * @abstract: + * Simple management of lists. + * + * @description: + * This section contains various definitions related to list processing + * using doubly-linked nodes. + * + * @order: + * FT_List + * FT_ListNode + * FT_ListRec + * FT_ListNodeRec + * + * FT_List_Add + * FT_List_Insert + * FT_List_Find + * FT_List_Remove + * FT_List_Up + * FT_List_Iterate + * FT_List_Iterator + * FT_List_Finalize + * FT_List_Destructor + * + */ + + + /************************************************************************** + * + * @function: + * FT_List_Find + * + * @description: + * Find the list node for a given listed object. + * + * @input: + * list :: + * A pointer to the parent list. + * data :: + * The address of the listed object. + * + * @return: + * List node. `NULL` if it wasn't found. + */ + FT_EXPORT( FT_ListNode ) + FT_List_Find( FT_List list, + void* data ); + + + /************************************************************************** + * + * @function: + * FT_List_Add + * + * @description: + * Append an element to the end of a list. + * + * @inout: + * list :: + * A pointer to the parent list. + * node :: + * The node to append. + */ + FT_EXPORT( void ) + FT_List_Add( FT_List list, + FT_ListNode node ); + + + /************************************************************************** + * + * @function: + * FT_List_Insert + * + * @description: + * Insert an element at the head of a list. + * + * @inout: + * list :: + * A pointer to parent list. + * node :: + * The node to insert. + */ + FT_EXPORT( void ) + FT_List_Insert( FT_List list, + FT_ListNode node ); + + + /************************************************************************** + * + * @function: + * FT_List_Remove + * + * @description: + * Remove a node from a list. This function doesn't check whether the + * node is in the list! + * + * @input: + * node :: + * The node to remove. + * + * @inout: + * list :: + * A pointer to the parent list. + */ + FT_EXPORT( void ) + FT_List_Remove( FT_List list, + FT_ListNode node ); + + + /************************************************************************** + * + * @function: + * FT_List_Up + * + * @description: + * Move a node to the head/top of a list. Used to maintain LRU lists. + * + * @inout: + * list :: + * A pointer to the parent list. + * node :: + * The node to move. + */ + FT_EXPORT( void ) + FT_List_Up( FT_List list, + FT_ListNode node ); + + + /************************************************************************** + * + * @functype: + * FT_List_Iterator + * + * @description: + * An FT_List iterator function that is called during a list parse by + * @FT_List_Iterate. + * + * @input: + * node :: + * The current iteration list node. + * + * user :: + * A typeless pointer passed to @FT_List_Iterate. Can be used to point + * to the iteration's state. + */ + typedef FT_Error + (*FT_List_Iterator)( FT_ListNode node, + void* user ); + + + /************************************************************************** + * + * @function: + * FT_List_Iterate + * + * @description: + * Parse a list and calls a given iterator function on each element. + * Note that parsing is stopped as soon as one of the iterator calls + * returns a non-zero value. + * + * @input: + * list :: + * A handle to the list. + * iterator :: + * An iterator function, called on each node of the list. + * user :: + * A user-supplied field that is passed as the second argument to the + * iterator. + * + * @return: + * The result (a FreeType error code) of the last iterator call. + */ + FT_EXPORT( FT_Error ) + FT_List_Iterate( FT_List list, + FT_List_Iterator iterator, + void* user ); + + + /************************************************************************** + * + * @functype: + * FT_List_Destructor + * + * @description: + * An @FT_List iterator function that is called during a list + * finalization by @FT_List_Finalize to destroy all elements in a given + * list. + * + * @input: + * system :: + * The current system object. + * + * data :: + * The current object to destroy. + * + * user :: + * A typeless pointer passed to @FT_List_Iterate. It can be used to + * point to the iteration's state. + */ + typedef void + (*FT_List_Destructor)( FT_Memory memory, + void* data, + void* user ); + + + /************************************************************************** + * + * @function: + * FT_List_Finalize + * + * @description: + * Destroy all elements in the list as well as the list itself. + * + * @input: + * list :: + * A handle to the list. + * + * destroy :: + * A list destructor that will be applied to each element of the list. + * Set this to `NULL` if not needed. + * + * memory :: + * The current memory object that handles deallocation. + * + * user :: + * A user-supplied field that is passed as the last argument to the + * destructor. + * + * @note: + * This function expects that all nodes added by @FT_List_Add or + * @FT_List_Insert have been dynamically allocated. + */ + FT_EXPORT( void ) + FT_List_Finalize( FT_List list, + FT_List_Destructor destroy, + FT_Memory memory, + void* user ); + + /* */ + + +FT_END_HEADER + +#endif /* FTLIST_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlogging.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlogging.h new file mode 100644 index 0000000000000000000000000000000000000000..409db2f313b00d3fcc328214d074bfa158db7e4d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlogging.h @@ -0,0 +1,184 @@ +/**************************************************************************** + * + * ftlogging.h + * + * Additional debugging APIs. + * + * Copyright (C) 2020-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTLOGGING_H_ +#define FTLOGGING_H_ + + +#include +#include FT_CONFIG_CONFIG_H + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * debugging_apis + * + * @title: + * External Debugging APIs + * + * @abstract: + * Public APIs to control the `FT_DEBUG_LOGGING` macro. + * + * @description: + * This section contains the declarations of public functions that + * enables fine control of what the `FT_DEBUG_LOGGING` macro outputs. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Trace_Set_Level + * + * @description: + * Change the levels of tracing components of FreeType at run time. + * + * @input: + * tracing_level :: + * New tracing value. + * + * @example: + * The following call makes FreeType trace everything but the 'memory' + * component. + * + * ``` + * FT_Trace_Set_Level( "any:7 memory:0" ); + * ``` + * + * @note: + * This function does nothing if compilation option `FT_DEBUG_LOGGING` + * isn't set. + * + * @since: + * 2.11 + * + */ + FT_EXPORT( void ) + FT_Trace_Set_Level( const char* tracing_level ); + + + /************************************************************************** + * + * @function: + * FT_Trace_Set_Default_Level + * + * @description: + * Reset tracing value of FreeType's components to the default value + * (i.e., to the value of the `FT2_DEBUG` environment value or to NULL + * if `FT2_DEBUG` is not set). + * + * @note: + * This function does nothing if compilation option `FT_DEBUG_LOGGING` + * isn't set. + * + * @since: + * 2.11 + * + */ + FT_EXPORT( void ) + FT_Trace_Set_Default_Level( void ); + + + /************************************************************************** + * + * @functype: + * FT_Custom_Log_Handler + * + * @description: + * A function typedef that is used to handle the logging of tracing and + * debug messages on a file system. + * + * @input: + * ft_component :: + * The name of `FT_COMPONENT` from which the current debug or error + * message is produced. + * + * fmt :: + * Actual debug or tracing message. + * + * args:: + * Arguments of debug or tracing messages. + * + * @since: + * 2.11 + * + */ + typedef void + (*FT_Custom_Log_Handler)( const char* ft_component, + const char* fmt, + va_list args ); + + + /************************************************************************** + * + * @function: + * FT_Set_Log_Handler + * + * @description: + * A function to set a custom log handler. + * + * @input: + * handler :: + * New logging function. + * + * @note: + * This function does nothing if compilation option `FT_DEBUG_LOGGING` + * isn't set. + * + * @since: + * 2.11 + * + */ + FT_EXPORT( void ) + FT_Set_Log_Handler( FT_Custom_Log_Handler handler ); + + + /************************************************************************** + * + * @function: + * FT_Set_Default_Log_Handler + * + * @description: + * A function to undo the effect of @FT_Set_Log_Handler, resetting the + * log handler to FreeType's built-in version. + * + * @note: + * This function does nothing if compilation option `FT_DEBUG_LOGGING` + * isn't set. + * + * @since: + * 2.11 + * + */ + FT_EXPORT( void ) + FT_Set_Default_Log_Handler( void ); + + /* */ + + +FT_END_HEADER + +#endif /* FTLOGGING_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlzw.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlzw.h new file mode 100644 index 0000000000000000000000000000000000000000..e025881a13a49e513e585e805538c66a56f149d8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftlzw.h @@ -0,0 +1,100 @@ +/**************************************************************************** + * + * ftlzw.h + * + * LZW-compressed stream support. + * + * Copyright (C) 2004-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTLZW_H_ +#define FTLZW_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /************************************************************************** + * + * @section: + * lzw + * + * @title: + * LZW Streams + * + * @abstract: + * Using LZW-compressed font files. + * + * @description: + * In certain builds of the library, LZW compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a LZW stream from it and + * re-open the face with it. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream, + * which significantly undermines the performance. + * + * This section contains the declaration of LZW-specific functions. + * + */ + + /************************************************************************** + * + * @function: + * FT_Stream_OpenLZW + * + * @description: + * Open a new stream to parse LZW-compressed font files. This is mainly + * used to support the compressed `*.pcf.Z` fonts that come with XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close` on the new stream will + * **not** call `FT_Stream_Close` on the source stream. None of the + * stream objects will be released to the heap. + * + * This function may return `FT_Err_Unimplemented_Feature` if your build + * of FreeType was not compiled with LZW support. + */ + FT_EXPORT( FT_Error ) + FT_Stream_OpenLZW( FT_Stream stream, + FT_Stream source ); + + /* */ + + +FT_END_HEADER + +#endif /* FTLZW_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmac.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmac.h new file mode 100644 index 0000000000000000000000000000000000000000..2187f377187664850d5baa9aa8c60fee91baa1c4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmac.h @@ -0,0 +1,289 @@ +/**************************************************************************** + * + * ftmac.h + * + * Additional Mac-specific API. + * + * Copyright (C) 1996-2024 by + * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +/**************************************************************************** + * + * NOTE: Include this file after `FT_FREETYPE_H` and after any + * Mac-specific headers (because this header uses Mac types such as + * 'Handle', 'FSSpec', 'FSRef', etc.) + * + */ + + +#ifndef FTMAC_H_ +#define FTMAC_H_ + + + + +FT_BEGIN_HEADER + + + /* gcc-3.1 and later can warn about functions tagged as deprecated */ +#ifndef FT_DEPRECATED_ATTRIBUTE +#if defined( __GNUC__ ) && \ + ( ( __GNUC__ >= 4 ) || \ + ( ( __GNUC__ == 3 ) && ( __GNUC_MINOR__ >= 1 ) ) ) +#define FT_DEPRECATED_ATTRIBUTE __attribute__(( deprecated )) +#else +#define FT_DEPRECATED_ATTRIBUTE +#endif +#endif + + + /************************************************************************** + * + * @section: + * mac_specific + * + * @title: + * Mac Specific Interface + * + * @abstract: + * Only available on the Macintosh. + * + * @description: + * The following definitions are only available if FreeType is compiled + * on a Macintosh. + * + */ + + + /************************************************************************** + * + * @function: + * FT_New_Face_From_FOND + * + * @description: + * Create a new face object from a FOND resource. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * fond :: + * A FOND resource. + * + * face_index :: + * Only supported for the -1 'sanity check' special case. + * + * @output: + * aface :: + * A handle to a new face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @example: + * This function can be used to create @FT_Face objects from fonts that + * are installed in the system as follows. + * + * ``` + * fond = GetResource( 'FOND', fontName ); + * error = FT_New_Face_From_FOND( library, fond, 0, &face ); + * ``` + */ + FT_EXPORT( FT_Error ) + FT_New_Face_From_FOND( FT_Library library, + Handle fond, + FT_Long face_index, + FT_Face *aface ) + FT_DEPRECATED_ATTRIBUTE; + + + /************************************************************************** + * + * @function: + * FT_GetFile_From_Mac_Name + * + * @description: + * Return an FSSpec for the disk file containing the named font. + * + * @input: + * fontName :: + * Mac OS name of the font (e.g., Times New Roman Bold). + * + * @output: + * pathSpec :: + * FSSpec to the file. For passing to @FT_New_Face_From_FSSpec. + * + * face_index :: + * Index of the face. For passing to @FT_New_Face_From_FSSpec. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_GetFile_From_Mac_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ) + FT_DEPRECATED_ATTRIBUTE; + + + /************************************************************************** + * + * @function: + * FT_GetFile_From_Mac_ATS_Name + * + * @description: + * Return an FSSpec for the disk file containing the named font. + * + * @input: + * fontName :: + * Mac OS name of the font in ATS framework. + * + * @output: + * pathSpec :: + * FSSpec to the file. For passing to @FT_New_Face_From_FSSpec. + * + * face_index :: + * Index of the face. For passing to @FT_New_Face_From_FSSpec. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_GetFile_From_Mac_ATS_Name( const char* fontName, + FSSpec* pathSpec, + FT_Long* face_index ) + FT_DEPRECATED_ATTRIBUTE; + + + /************************************************************************** + * + * @function: + * FT_GetFilePath_From_Mac_ATS_Name + * + * @description: + * Return a pathname of the disk file and face index for given font name + * that is handled by ATS framework. + * + * @input: + * fontName :: + * Mac OS name of the font in ATS framework. + * + * @output: + * path :: + * Buffer to store pathname of the file. For passing to @FT_New_Face. + * The client must allocate this buffer before calling this function. + * + * maxPathSize :: + * Lengths of the buffer `path` that client allocated. + * + * face_index :: + * Index of the face. For passing to @FT_New_Face. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_GetFilePath_From_Mac_ATS_Name( const char* fontName, + UInt8* path, + UInt32 maxPathSize, + FT_Long* face_index ) + FT_DEPRECATED_ATTRIBUTE; + + + /************************************************************************** + * + * @function: + * FT_New_Face_From_FSSpec + * + * @description: + * Create a new face object from a given resource and typeface index + * using an FSSpec to the font file. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * spec :: + * FSSpec to the font file. + * + * face_index :: + * The index of the face within the resource. The first face has + * index~0. + * @output: + * aface :: + * A handle to a new face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * @FT_New_Face_From_FSSpec is identical to @FT_New_Face except it + * accepts an FSSpec instead of a path. + */ + FT_EXPORT( FT_Error ) + FT_New_Face_From_FSSpec( FT_Library library, + const FSSpec *spec, + FT_Long face_index, + FT_Face *aface ) + FT_DEPRECATED_ATTRIBUTE; + + + /************************************************************************** + * + * @function: + * FT_New_Face_From_FSRef + * + * @description: + * Create a new face object from a given resource and typeface index + * using an FSRef to the font file. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * spec :: + * FSRef to the font file. + * + * face_index :: + * The index of the face within the resource. The first face has + * index~0. + * @output: + * aface :: + * A handle to a new face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * @FT_New_Face_From_FSRef is identical to @FT_New_Face except it accepts + * an FSRef instead of a path. + */ + FT_EXPORT( FT_Error ) + FT_New_Face_From_FSRef( FT_Library library, + const FSRef *ref, + FT_Long face_index, + FT_Face *aface ) + FT_DEPRECATED_ATTRIBUTE; + + /* */ + + +FT_END_HEADER + + +#endif /* FTMAC_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmm.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmm.h new file mode 100644 index 0000000000000000000000000000000000000000..c0ddde46fdb2cf8bde9e55342c8fc9867006dd3a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmm.h @@ -0,0 +1,834 @@ +/**************************************************************************** + * + * ftmm.h + * + * FreeType Multiple Master font interface (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTMM_H_ +#define FTMM_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * multiple_masters + * + * @title: + * Multiple Masters + * + * @abstract: + * How to manage Multiple Masters fonts. + * + * @description: + * The following types and functions are used to manage Multiple Master + * fonts, i.e., the selection of specific design instances by setting + * design axis coordinates. + * + * Besides Adobe MM fonts, the interface supports Apple's TrueType GX and + * OpenType variation fonts. Some of the routines only work with Adobe + * MM fonts, others will work with all three types. They are similar + * enough that a consistent interface makes sense. + * + * For Adobe MM fonts, macro @FT_IS_SFNT returns false. For GX and + * OpenType variation fonts, it returns true. + * + */ + + + /************************************************************************** + * + * @enum: + * T1_MAX_MM_XXX + * + * @description: + * Multiple Masters limits as defined in their specifications. + * + * @values: + * T1_MAX_MM_AXIS :: + * The maximum number of Multiple Masters axes. + * + * T1_MAX_MM_DESIGNS :: + * The maximum number of Multiple Masters designs. + * + * T1_MAX_MM_MAP_POINTS :: + * The maximum number of elements in a design map. + * + */ +#define T1_MAX_MM_AXIS 4 +#define T1_MAX_MM_DESIGNS 16 +#define T1_MAX_MM_MAP_POINTS 20 + + + /************************************************************************** + * + * @struct: + * FT_MM_Axis + * + * @description: + * A structure to model a given axis in design space for Multiple Masters + * fonts. + * + * This structure can't be used for TrueType GX or OpenType variation + * fonts. + * + * @fields: + * name :: + * The axis's name. + * + * minimum :: + * The axis's minimum design coordinate. + * + * maximum :: + * The axis's maximum design coordinate. + */ + typedef struct FT_MM_Axis_ + { + FT_String* name; + FT_Long minimum; + FT_Long maximum; + + } FT_MM_Axis; + + + /************************************************************************** + * + * @struct: + * FT_Multi_Master + * + * @description: + * A structure to model the axes and space of a Multiple Masters font. + * + * This structure can't be used for TrueType GX or OpenType variation + * fonts. + * + * @fields: + * num_axis :: + * Number of axes. Cannot exceed~4. + * + * num_designs :: + * Number of designs; should be normally 2^num_axis even though the + * Type~1 specification strangely allows for intermediate designs to be + * present. This number cannot exceed~16. + * + * axis :: + * A table of axis descriptors. + */ + typedef struct FT_Multi_Master_ + { + FT_UInt num_axis; + FT_UInt num_designs; + FT_MM_Axis axis[T1_MAX_MM_AXIS]; + + } FT_Multi_Master; + + + /************************************************************************** + * + * @struct: + * FT_Var_Axis + * + * @description: + * A structure to model a given axis in design space for Multiple + * Masters, TrueType GX, and OpenType variation fonts. + * + * @fields: + * name :: + * The axis's name. Not always meaningful for TrueType GX or OpenType + * variation fonts. + * + * minimum :: + * The axis's minimum design coordinate. + * + * def :: + * The axis's default design coordinate. FreeType computes meaningful + * default values for Adobe MM fonts. + * + * maximum :: + * The axis's maximum design coordinate. + * + * tag :: + * The axis's tag (the equivalent to 'name' for TrueType GX and + * OpenType variation fonts). FreeType provides default values for + * Adobe MM fonts if possible. + * + * strid :: + * The axis name entry in the font's 'name' table. This is another + * (and often better) version of the 'name' field for TrueType GX or + * OpenType variation fonts. Not meaningful for Adobe MM fonts. + * + * @note: + * The fields `minimum`, `def`, and `maximum` are 16.16 fractional values + * for TrueType GX and OpenType variation fonts. For Adobe MM fonts, the + * values are whole numbers (i.e., the fractional part is zero). + */ + typedef struct FT_Var_Axis_ + { + FT_String* name; + + FT_Fixed minimum; + FT_Fixed def; + FT_Fixed maximum; + + FT_ULong tag; + FT_UInt strid; + + } FT_Var_Axis; + + + /************************************************************************** + * + * @struct: + * FT_Var_Named_Style + * + * @description: + * A structure to model a named instance in a TrueType GX or OpenType + * variation font. + * + * This structure can't be used for Adobe MM fonts. + * + * @fields: + * coords :: + * The design coordinates for this instance. This is an array with one + * entry for each axis. + * + * strid :: + * The entry in 'name' table identifying this instance. + * + * psid :: + * The entry in 'name' table identifying a PostScript name for this + * instance. Value 0xFFFF indicates a missing entry. + */ + typedef struct FT_Var_Named_Style_ + { + FT_Fixed* coords; + FT_UInt strid; + FT_UInt psid; /* since 2.7.1 */ + + } FT_Var_Named_Style; + + + /************************************************************************** + * + * @struct: + * FT_MM_Var + * + * @description: + * A structure to model the axes and space of an Adobe MM, TrueType GX, + * or OpenType variation font. + * + * Some fields are specific to one format and not to the others. + * + * @fields: + * num_axis :: + * The number of axes. The maximum value is~4 for Adobe MM fonts; no + * limit in TrueType GX or OpenType variation fonts. + * + * num_designs :: + * The number of designs; should be normally 2^num_axis for Adobe MM + * fonts. Not meaningful for TrueType GX or OpenType variation fonts + * (where every glyph could have a different number of designs). + * + * num_namedstyles :: + * The number of named styles; a 'named style' is a tuple of design + * coordinates that has a string ID (in the 'name' table) associated + * with it. The font can tell the user that, for example, + * [Weight=1.5,Width=1.1] is 'Bold'. Another name for 'named style' is + * 'named instance'. + * + * For Adobe Multiple Masters fonts, this value is always zero because + * the format does not support named styles. + * + * axis :: + * An axis descriptor table. TrueType GX and OpenType variation fonts + * contain slightly more data than Adobe MM fonts. Memory management + * of this pointer is done internally by FreeType. + * + * namedstyle :: + * A named style (instance) table. Only meaningful for TrueType GX and + * OpenType variation fonts. Memory management of this pointer is done + * internally by FreeType. + */ + typedef struct FT_MM_Var_ + { + FT_UInt num_axis; + FT_UInt num_designs; + FT_UInt num_namedstyles; + FT_Var_Axis* axis; + FT_Var_Named_Style* namedstyle; + + } FT_MM_Var; + + + /************************************************************************** + * + * @function: + * FT_Get_Multi_Master + * + * @description: + * Retrieve a variation descriptor of a given Adobe MM font. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @input: + * face :: + * A handle to the source face. + * + * @output: + * amaster :: + * The Multiple Masters descriptor. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Get_Multi_Master( FT_Face face, + FT_Multi_Master *amaster ); + + + /************************************************************************** + * + * @function: + * FT_Get_MM_Var + * + * @description: + * Retrieve a variation descriptor for a given font. + * + * This function works with all supported variation formats. + * + * @input: + * face :: + * A handle to the source face. + * + * @output: + * amaster :: + * The variation descriptor. Allocates a data structure, which the + * user must deallocate with a call to @FT_Done_MM_Var after use. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Get_MM_Var( FT_Face face, + FT_MM_Var* *amaster ); + + + /************************************************************************** + * + * @function: + * FT_Done_MM_Var + * + * @description: + * Free the memory allocated by @FT_Get_MM_Var. + * + * @input: + * library :: + * A handle of the face's parent library object that was used in the + * call to @FT_Get_MM_Var to create `amaster`. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Done_MM_Var( FT_Library library, + FT_MM_Var *amaster ); + + + /************************************************************************** + * + * @function: + * FT_Set_MM_Design_Coordinates + * + * @description: + * For Adobe MM fonts, choose an interpolated font design through design + * coordinates. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * num_coords :: + * The number of available design coordinates. If it is larger than + * the number of axes, ignore the excess values. If it is smaller than + * the number of axes, use default values for the remaining axes. + * + * coords :: + * An array of design coordinates. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * [Since 2.8.1] To reset all axes to the default values, call the + * function with `num_coords` set to zero and `coords` set to `NULL`. + * + * [Since 2.9] If `num_coords` is larger than zero, this function sets + * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field + * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero, + * this bit flag gets unset. + */ + FT_EXPORT( FT_Error ) + FT_Set_MM_Design_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Long* coords ); + + + /************************************************************************** + * + * @function: + * FT_Set_Var_Design_Coordinates + * + * @description: + * Choose an interpolated font design through design coordinates. + * + * This function works with all supported variation formats. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * num_coords :: + * The number of available design coordinates. If it is larger than + * the number of axes, ignore the excess values. If it is smaller than + * the number of axes, use default values for the remaining axes. + * + * coords :: + * An array of design coordinates. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The design coordinates are 16.16 fractional values for TrueType GX and + * OpenType variation fonts. For Adobe MM fonts, the values are supposed + * to be whole numbers (i.e., the fractional part is zero). + * + * [Since 2.8.1] To reset all axes to the default values, call the + * function with `num_coords` set to zero and `coords` set to `NULL`. + * [Since 2.9] 'Default values' means the currently selected named + * instance (or the base font if no named instance is selected). + * + * [Since 2.9] If `num_coords` is larger than zero, this function sets + * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field + * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero, + * this bit flag gets unset. + */ + FT_EXPORT( FT_Error ) + FT_Set_Var_Design_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /************************************************************************** + * + * @function: + * FT_Get_Var_Design_Coordinates + * + * @description: + * Get the design coordinates of the currently selected interpolated + * font. + * + * This function works with all supported variation formats. + * + * @input: + * face :: + * A handle to the source face. + * + * num_coords :: + * The number of design coordinates to retrieve. If it is larger than + * the number of axes, set the excess values to~0. + * + * @output: + * coords :: + * The design coordinates array. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The design coordinates are 16.16 fractional values for TrueType GX and + * OpenType variation fonts. For Adobe MM fonts, the values are whole + * numbers (i.e., the fractional part is zero). + * + * @since: + * 2.7.1 + */ + FT_EXPORT( FT_Error ) + FT_Get_Var_Design_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /************************************************************************** + * + * @function: + * FT_Set_MM_Blend_Coordinates + * + * @description: + * Choose an interpolated font design through normalized blend + * coordinates. + * + * This function works with all supported variation formats. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * num_coords :: + * The number of available design coordinates. If it is larger than + * the number of axes, ignore the excess values. If it is smaller than + * the number of axes, use default values for the remaining axes. + * + * coords :: + * The design coordinates array. Each element is a 16.16 fractional + * value and must be between 0 and 1.0 for Adobe MM fonts, and between + * -1.0 and 1.0 for TrueType GX and OpenType variation fonts. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * [Since 2.8.1] To reset all axes to the default values, call the + * function with `num_coords` set to zero and `coords` set to `NULL`. + * [Since 2.9] 'Default values' means the currently selected named + * instance (or the base font if no named instance is selected). + * + * [Since 2.9] If `num_coords` is larger than zero, this function sets + * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field + * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero, + * this bit flag gets unset. + */ + FT_EXPORT( FT_Error ) + FT_Set_MM_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /************************************************************************** + * + * @function: + * FT_Get_MM_Blend_Coordinates + * + * @description: + * Get the normalized blend coordinates of the currently selected + * interpolated font. + * + * This function works with all supported variation formats. + * + * @input: + * face :: + * A handle to the source face. + * + * num_coords :: + * The number of normalized blend coordinates to retrieve. If it is + * larger than the number of axes, set the excess values to~0.5 for + * Adobe MM fonts, and to~0 for TrueType GX and OpenType variation + * fonts. + * + * @output: + * coords :: + * The normalized blend coordinates array (as 16.16 fractional values). + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.7.1 + */ + FT_EXPORT( FT_Error ) + FT_Get_MM_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /************************************************************************** + * + * @function: + * FT_Set_Var_Blend_Coordinates + * + * @description: + * This is another name of @FT_Set_MM_Blend_Coordinates. + */ + FT_EXPORT( FT_Error ) + FT_Set_Var_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /************************************************************************** + * + * @function: + * FT_Get_Var_Blend_Coordinates + * + * @description: + * This is another name of @FT_Get_MM_Blend_Coordinates. + * + * @since: + * 2.7.1 + */ + FT_EXPORT( FT_Error ) + FT_Get_Var_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + + /************************************************************************** + * + * @function: + * FT_Set_MM_WeightVector + * + * @description: + * For Adobe MM fonts, choose an interpolated font design by directly + * setting the weight vector. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * len :: + * The length of the weight vector array. If it is larger than the + * number of designs, the extra values are ignored. If it is less than + * the number of designs, the remaining values are set to zero. + * + * weightvector :: + * An array representing the weight vector. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Adobe Multiple Master fonts limit the number of designs, and thus the + * length of the weight vector to 16~elements. + * + * If `len` is larger than zero, this function sets the + * @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field (i.e., + * @FT_IS_VARIATION will return true). If `len` is zero, this bit flag + * is unset and the weight vector array is reset to the default values. + * + * The Adobe documentation also states that the values in the + * WeightVector array must total 1.0 +/-~0.001. In practice this does + * not seem to be enforced, so is not enforced here, either. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Set_MM_WeightVector( FT_Face face, + FT_UInt len, + FT_Fixed* weightvector ); + + + /************************************************************************** + * + * @function: + * FT_Get_MM_WeightVector + * + * @description: + * For Adobe MM fonts, retrieve the current weight vector of the font. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @inout: + * face :: + * A handle to the source face. + * + * len :: + * A pointer to the size of the array to be filled. If the size of the + * array is less than the number of designs, `FT_Err_Invalid_Argument` + * is returned, and `len` is set to the required size (the number of + * designs). If the size of the array is greater than the number of + * designs, the remaining entries are set to~0. On successful + * completion, `len` is set to the number of designs (i.e., the number + * of values written to the array). + * + * @output: + * weightvector :: + * An array to be filled. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Adobe Multiple Master fonts limit the number of designs, and thus the + * length of the WeightVector to~16. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Get_MM_WeightVector( FT_Face face, + FT_UInt* len, + FT_Fixed* weightvector ); + + + /************************************************************************** + * + * @enum: + * FT_VAR_AXIS_FLAG_XXX + * + * @description: + * A list of bit flags used in the return value of + * @FT_Get_Var_Axis_Flags. + * + * @values: + * FT_VAR_AXIS_FLAG_HIDDEN :: + * The variation axis should not be exposed to user interfaces. + * + * @since: + * 2.8.1 + */ +#define FT_VAR_AXIS_FLAG_HIDDEN 1 + + + /************************************************************************** + * + * @function: + * FT_Get_Var_Axis_Flags + * + * @description: + * Get the 'flags' field of an OpenType Variation Axis Record. + * + * Not meaningful for Adobe MM fonts (`*flags` is always zero). + * + * @input: + * master :: + * The variation descriptor. + * + * axis_index :: + * The index of the requested variation axis. + * + * @output: + * flags :: + * The 'flags' field. See @FT_VAR_AXIS_FLAG_XXX for possible values. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.8.1 + */ + FT_EXPORT( FT_Error ) + FT_Get_Var_Axis_Flags( FT_MM_Var* master, + FT_UInt axis_index, + FT_UInt* flags ); + + + /************************************************************************** + * + * @function: + * FT_Set_Named_Instance + * + * @description: + * Set or change the current named instance. + * + * @input: + * face :: + * A handle to the source face. + * + * instance_index :: + * The index of the requested instance, starting with value 1. If set + * to value 0, FreeType switches to font access without a named + * instance. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The function uses the value of `instance_index` to set bits 16-30 of + * the face's `face_index` field. It also resets any variation applied + * to the font, and the @FT_FACE_FLAG_VARIATION bit of the face's + * `face_flags` field gets reset to zero (i.e., @FT_IS_VARIATION will + * return false). + * + * For Adobe MM fonts (which don't have named instances) this function + * simply resets the current face to the default instance. + * + * @since: + * 2.9 + */ + FT_EXPORT( FT_Error ) + FT_Set_Named_Instance( FT_Face face, + FT_UInt instance_index ); + + + /************************************************************************** + * + * @function: + * FT_Get_Default_Named_Instance + * + * @description: + * Retrieve the index of the default named instance, to be used with + * @FT_Set_Named_Instance. + * + * The default instance of a variation font is that instance for which + * the nth axis coordinate is equal to `axis[n].def` (as specified in the + * @FT_MM_Var structure), with~n covering all axes. + * + * FreeType synthesizes a named instance for the default instance if the + * font does not contain such an entry. + * + * @input: + * face :: + * A handle to the source face. + * + * @output: + * instance_index :: + * The index of the default named instance. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * For Adobe MM fonts (which don't have named instances) this function + * always returns zero for `instance_index`. + * + * @since: + * 2.13.1 + */ + FT_EXPORT( FT_Error ) + FT_Get_Default_Named_Instance( FT_Face face, + FT_UInt *instance_index ); + + /* */ + + +FT_END_HEADER + +#endif /* FTMM_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmodapi.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmodapi.h new file mode 100644 index 0000000000000000000000000000000000000000..e44bb8155a4147868305bfca8570e41e88f4b3dc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmodapi.h @@ -0,0 +1,807 @@ +/**************************************************************************** + * + * ftmodapi.h + * + * FreeType modules public interface (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTMODAPI_H_ +#define FTMODAPI_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * module_management + * + * @title: + * Module Management + * + * @abstract: + * How to add, upgrade, remove, and control modules from FreeType. + * + * @description: + * The definitions below are used to manage modules within FreeType. + * Internal and external modules can be added, upgraded, and removed at + * runtime. For example, an alternative renderer or proprietary font + * driver can be registered and prioritized. Additionally, some module + * properties can also be controlled. + * + * Here is a list of existing values of the `module_name` field in the + * @FT_Module_Class structure. + * + * ``` + * autofitter + * bdf + * cff + * gxvalid + * otvalid + * pcf + * pfr + * psaux + * pshinter + * psnames + * raster1 + * sfnt + * smooth + * truetype + * type1 + * type42 + * t1cid + * winfonts + * ``` + * + * Note that the FreeType Cache sub-system is not a FreeType module. + * + * @order: + * FT_Module + * FT_Module_Constructor + * FT_Module_Destructor + * FT_Module_Requester + * FT_Module_Class + * + * FT_Add_Module + * FT_Get_Module + * FT_Remove_Module + * FT_Add_Default_Modules + * + * FT_FACE_DRIVER_NAME + * FT_Property_Set + * FT_Property_Get + * FT_Set_Default_Properties + * + * FT_New_Library + * FT_Done_Library + * FT_Reference_Library + * + * FT_Renderer + * FT_Renderer_Class + * + * FT_Get_Renderer + * FT_Set_Renderer + * + * FT_Set_Debug_Hook + * + */ + + + /* module bit flags */ +#define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */ +#define FT_MODULE_RENDERER 2 /* this module is a renderer */ +#define FT_MODULE_HINTER 4 /* this module is a glyph hinter */ +#define FT_MODULE_STYLER 8 /* this module is a styler */ + +#define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */ + /* scalable fonts */ +#define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */ + /* support vector outlines */ +#define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */ + /* own hinter */ +#define FT_MODULE_DRIVER_HINTS_LIGHTLY 0x800 /* the driver's hinter */ + /* produces LIGHT hints */ + + + /* deprecated values */ +#define ft_module_font_driver FT_MODULE_FONT_DRIVER +#define ft_module_renderer FT_MODULE_RENDERER +#define ft_module_hinter FT_MODULE_HINTER +#define ft_module_styler FT_MODULE_STYLER + +#define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE +#define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES +#define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER +#define ft_module_driver_hints_lightly FT_MODULE_DRIVER_HINTS_LIGHTLY + + + typedef FT_Pointer FT_Module_Interface; + + + /************************************************************************** + * + * @functype: + * FT_Module_Constructor + * + * @description: + * A function used to initialize (not create) a new module object. + * + * @input: + * module :: + * The module to initialize. + */ + typedef FT_Error + (*FT_Module_Constructor)( FT_Module module ); + + + /************************************************************************** + * + * @functype: + * FT_Module_Destructor + * + * @description: + * A function used to finalize (not destroy) a given module object. + * + * @input: + * module :: + * The module to finalize. + */ + typedef void + (*FT_Module_Destructor)( FT_Module module ); + + + /************************************************************************** + * + * @functype: + * FT_Module_Requester + * + * @description: + * A function used to query a given module for a specific interface. + * + * @input: + * module :: + * The module to be searched. + * + * name :: + * The name of the interface in the module. + */ + typedef FT_Module_Interface + (*FT_Module_Requester)( FT_Module module, + const char* name ); + + + /************************************************************************** + * + * @struct: + * FT_Module_Class + * + * @description: + * The module class descriptor. While being a public structure necessary + * for FreeType's module bookkeeping, most of the fields are essentially + * internal, not to be used directly by an application. + * + * @fields: + * module_flags :: + * Bit flags describing the module. + * + * module_size :: + * The size of one module object/instance in bytes. + * + * module_name :: + * The name of the module. + * + * module_version :: + * The version, as a 16.16 fixed number (major.minor). + * + * module_requires :: + * The version of FreeType this module requires, as a 16.16 fixed + * number (major.minor). Starts at version 2.0, i.e., 0x20000. + * + * module_interface :: + * A typeless pointer to a structure (which varies between different + * modules) that holds the module's interface functions. This is + * essentially what `get_interface` returns. + * + * module_init :: + * The initializing function. + * + * module_done :: + * The finalizing function. + * + * get_interface :: + * The interface requesting function. + */ + typedef struct FT_Module_Class_ + { + FT_ULong module_flags; + FT_Long module_size; + const FT_String* module_name; + FT_Fixed module_version; + FT_Fixed module_requires; + + const void* module_interface; + + FT_Module_Constructor module_init; + FT_Module_Destructor module_done; + FT_Module_Requester get_interface; + + } FT_Module_Class; + + + /************************************************************************** + * + * @function: + * FT_Add_Module + * + * @description: + * Add a new module to a given library instance. + * + * @inout: + * library :: + * A handle to the library object. + * + * @input: + * clazz :: + * A pointer to class descriptor for the module. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * An error will be returned if a module already exists by that name, or + * if the module requires a version of FreeType that is too great. + */ + FT_EXPORT( FT_Error ) + FT_Add_Module( FT_Library library, + const FT_Module_Class* clazz ); + + + /************************************************************************** + * + * @function: + * FT_Get_Module + * + * @description: + * Find a module by its name. + * + * @input: + * library :: + * A handle to the library object. + * + * module_name :: + * The module's name (as an ASCII string). + * + * @return: + * A module handle. 0~if none was found. + * + * @note: + * FreeType's internal modules aren't documented very well, and you + * should look up the source code for details. + */ + FT_EXPORT( FT_Module ) + FT_Get_Module( FT_Library library, + const char* module_name ); + + + /************************************************************************** + * + * @function: + * FT_Remove_Module + * + * @description: + * Remove a given module from a library instance. + * + * @inout: + * library :: + * A handle to a library object. + * + * @input: + * module :: + * A handle to a module object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The module object is destroyed by the function in case of success. + */ + FT_EXPORT( FT_Error ) + FT_Remove_Module( FT_Library library, + FT_Module module ); + + + /************************************************************************** + * + * @macro: + * FT_FACE_DRIVER_NAME + * + * @description: + * A macro that retrieves the name of a font driver from a face object. + * + * @note: + * The font driver name is a valid `module_name` for @FT_Property_Set + * and @FT_Property_Get. This is not the same as @FT_Get_Font_Format. + * + * @since: + * 2.11 + * + */ +#define FT_FACE_DRIVER_NAME( face ) \ + ( ( *FT_REINTERPRET_CAST( FT_Module_Class**, \ + ( face )->driver ) )->module_name ) + + + /************************************************************************** + * + * @function: + * FT_Property_Set + * + * @description: + * Set a property for a given module. + * + * @input: + * library :: + * A handle to the library the module is part of. + * + * module_name :: + * The module name. + * + * property_name :: + * The property name. Properties are described in section + * @properties. + * + * Note that only a few modules have properties. + * + * value :: + * A generic pointer to a variable or structure that gives the new + * value of the property. The exact definition of `value` is + * dependent on the property; see section @properties. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `module_name` isn't a valid module name, or `property_name` + * doesn't specify a valid property, or if `value` doesn't represent a + * valid value for the given property, an error is returned. + * + * The following example sets property 'bar' (a simple integer) in + * module 'foo' to value~1. + * + * ``` + * FT_UInt bar; + * + * + * bar = 1; + * FT_Property_Set( library, "foo", "bar", &bar ); + * ``` + * + * Note that the FreeType Cache sub-system doesn't recognize module + * property changes. To avoid glyph lookup confusion within the cache + * you should call @FTC_Manager_Reset to completely flush the cache if a + * module property gets changed after @FTC_Manager_New has been called. + * + * It is not possible to set properties of the FreeType Cache sub-system + * itself with FT_Property_Set; use @FTC_Property_Set instead. + * + * @since: + * 2.4.11 + * + */ + FT_EXPORT( FT_Error ) + FT_Property_Set( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + const void* value ); + + + /************************************************************************** + * + * @function: + * FT_Property_Get + * + * @description: + * Get a module's property value. + * + * @input: + * library :: + * A handle to the library the module is part of. + * + * module_name :: + * The module name. + * + * property_name :: + * The property name. Properties are described in section + * @properties. + * + * @inout: + * value :: + * A generic pointer to a variable or structure that gives the value + * of the property. The exact definition of `value` is dependent on + * the property; see section @properties. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `module_name` isn't a valid module name, or `property_name` + * doesn't specify a valid property, or if `value` doesn't represent a + * valid value for the given property, an error is returned. + * + * The following example gets property 'baz' (a range) in module 'foo'. + * + * ``` + * typedef range_ + * { + * FT_Int32 min; + * FT_Int32 max; + * + * } range; + * + * range baz; + * + * + * FT_Property_Get( library, "foo", "baz", &baz ); + * ``` + * + * It is not possible to retrieve properties of the FreeType Cache + * sub-system with FT_Property_Get; use @FTC_Property_Get instead. + * + * @since: + * 2.4.11 + * + */ + FT_EXPORT( FT_Error ) + FT_Property_Get( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + void* value ); + + + /************************************************************************** + * + * @function: + * FT_Set_Default_Properties + * + * @description: + * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is + * set, this function reads the `FREETYPE_PROPERTIES` environment + * variable to control driver properties. See section @properties for + * more. + * + * If the compilation option is not set, this function does nothing. + * + * `FREETYPE_PROPERTIES` has the following syntax form (broken here into + * multiple lines for better readability). + * + * ``` + * + * ':' + * '=' + * + * ':' + * '=' + * ... + * ``` + * + * Example: + * + * ``` + * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ + * cff:no-stem-darkening=0 + * ``` + * + * @inout: + * library :: + * A handle to a new library object. + * + * @since: + * 2.8 + */ + FT_EXPORT( void ) + FT_Set_Default_Properties( FT_Library library ); + + + /************************************************************************** + * + * @function: + * FT_Reference_Library + * + * @description: + * A counter gets initialized to~1 at the time an @FT_Library structure + * is created. This function increments the counter. @FT_Done_Library + * then only destroys a library if the counter is~1, otherwise it simply + * decrements the counter. + * + * This function helps in managing life-cycles of structures that + * reference @FT_Library objects. + * + * @input: + * library :: + * A handle to a target library object. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.4.2 + */ + FT_EXPORT( FT_Error ) + FT_Reference_Library( FT_Library library ); + + + /************************************************************************** + * + * @function: + * FT_New_Library + * + * @description: + * This function is used to create a new FreeType library instance from a + * given memory object. It is thus possible to use libraries with + * distinct memory allocators within the same program. Note, however, + * that the used @FT_Memory structure is expected to remain valid for the + * life of the @FT_Library object. + * + * Normally, you would call this function (followed by a call to + * @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, and a + * call to @FT_Set_Default_Properties) instead of @FT_Init_FreeType to + * initialize the FreeType library. + * + * Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a library + * instance. + * + * @input: + * memory :: + * A handle to the original memory object. + * + * @output: + * alibrary :: + * A pointer to handle of a new library object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * See the discussion of reference counters in the description of + * @FT_Reference_Library. + */ + FT_EXPORT( FT_Error ) + FT_New_Library( FT_Memory memory, + FT_Library *alibrary ); + + + /************************************************************************** + * + * @function: + * FT_Done_Library + * + * @description: + * Discard a given library object. This closes all drivers and discards + * all resource objects. + * + * @input: + * library :: + * A handle to the target library. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * See the discussion of reference counters in the description of + * @FT_Reference_Library. + */ + FT_EXPORT( FT_Error ) + FT_Done_Library( FT_Library library ); + + + /************************************************************************** + * + * @functype: + * FT_DebugHook_Func + * + * @description: + * A drop-in replacement (or rather a wrapper) for the bytecode or + * charstring interpreter's main loop function. + * + * Its job is essentially + * + * - to activate debug mode to enforce single-stepping, + * + * - to call the main loop function to interpret the next opcode, and + * + * - to show the changed context to the user. + * + * An example for such a main loop function is `TT_RunIns` (declared in + * FreeType's internal header file `src/truetype/ttinterp.h`). + * + * Have a look at the source code of the `ttdebug` FreeType demo program + * for an example of a drop-in replacement. + * + * @inout: + * arg :: + * A typeless pointer, to be cast to the main loop function's data + * structure (which depends on the font module). For TrueType fonts + * it is bytecode interpreter's execution context, `TT_ExecContext`, + * which is declared in FreeType's internal header file `tttypes.h`. + */ + typedef FT_Error + (*FT_DebugHook_Func)( void* arg ); + + + /************************************************************************** + * + * @enum: + * FT_DEBUG_HOOK_XXX + * + * @description: + * A list of named debug hook indices. + * + * @values: + * FT_DEBUG_HOOK_TRUETYPE:: + * This hook index identifies the TrueType bytecode debugger. + */ +#define FT_DEBUG_HOOK_TRUETYPE 0 + + + /************************************************************************** + * + * @function: + * FT_Set_Debug_Hook + * + * @description: + * Set a debug hook function for debugging the interpreter of a font + * format. + * + * While this is a public API function, an application needs access to + * FreeType's internal header files to do something useful. + * + * Have a look at the source code of the `ttdebug` FreeType demo program + * for an example of its usage. + * + * @inout: + * library :: + * A handle to the library object. + * + * @input: + * hook_index :: + * The index of the debug hook. You should use defined enumeration + * macros like @FT_DEBUG_HOOK_TRUETYPE. + * + * debug_hook :: + * The function used to debug the interpreter. + * + * @note: + * Currently, four debug hook slots are available, but only one (for the + * TrueType interpreter) is defined. + */ + FT_EXPORT( void ) + FT_Set_Debug_Hook( FT_Library library, + FT_UInt hook_index, + FT_DebugHook_Func debug_hook ); + + + /************************************************************************** + * + * @function: + * FT_Add_Default_Modules + * + * @description: + * Add the set of default drivers to a given library object. This is + * only useful when you create a library object with @FT_New_Library + * (usually to plug a custom memory manager). + * + * @inout: + * library :: + * A handle to a new library object. + */ + FT_EXPORT( void ) + FT_Add_Default_Modules( FT_Library library ); + + + + /************************************************************************** + * + * @section: + * truetype_engine + * + * @title: + * The TrueType Engine + * + * @abstract: + * TrueType bytecode support. + * + * @description: + * This section contains a function used to query the level of TrueType + * bytecode support compiled in this version of the library. + * + */ + + + /************************************************************************** + * + * @enum: + * FT_TrueTypeEngineType + * + * @description: + * A list of values describing which kind of TrueType bytecode engine is + * implemented in a given FT_Library instance. It is used by the + * @FT_Get_TrueType_Engine_Type function. + * + * @values: + * FT_TRUETYPE_ENGINE_TYPE_NONE :: + * The library doesn't implement any kind of bytecode interpreter. + * + * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED :: + * Deprecated and removed. + * + * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: + * The library implements a bytecode interpreter that covers the full + * instruction set of the TrueType virtual machine (this was governed + * by patents until May 2010, hence the name). + * + * @since: + * 2.2 + * + */ + typedef enum FT_TrueTypeEngineType_ + { + FT_TRUETYPE_ENGINE_TYPE_NONE = 0, + FT_TRUETYPE_ENGINE_TYPE_UNPATENTED, + FT_TRUETYPE_ENGINE_TYPE_PATENTED + + } FT_TrueTypeEngineType; + + + /************************************************************************** + * + * @function: + * FT_Get_TrueType_Engine_Type + * + * @description: + * Return an @FT_TrueTypeEngineType value to indicate which level of the + * TrueType virtual machine a given library instance supports. + * + * @input: + * library :: + * A library instance. + * + * @return: + * A value indicating which level is supported. + * + * @since: + * 2.2 + * + */ + FT_EXPORT( FT_TrueTypeEngineType ) + FT_Get_TrueType_Engine_Type( FT_Library library ); + + /* */ + + +FT_END_HEADER + +#endif /* FTMODAPI_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmoderr.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmoderr.h new file mode 100644 index 0000000000000000000000000000000000000000..d02c85b206708cf0bd187b8eb3bb2d2f12e96051 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftmoderr.h @@ -0,0 +1,204 @@ +/**************************************************************************** + * + * ftmoderr.h + * + * FreeType module error offsets (specification). + * + * Copyright (C) 2001-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the FreeType module error codes. + * + * If the macro `FT_CONFIG_OPTION_USE_MODULE_ERRORS` in `ftoption.h` is + * set, the lower byte of an error value identifies the error code as + * usual. In addition, the higher byte identifies the module. For + * example, the error `FT_Err_Invalid_File_Format` has value 0x0003, the + * error `TT_Err_Invalid_File_Format` has value 0x1303, the error + * `T1_Err_Invalid_File_Format` has value 0x1403, etc. + * + * Note that `FT_Err_Ok`, `TT_Err_Ok`, etc. are always equal to zero, + * including the high byte. + * + * If `FT_CONFIG_OPTION_USE_MODULE_ERRORS` isn't set, the higher byte of an + * error value is set to zero. + * + * To hide the various `XXX_Err_` prefixes in the source code, FreeType + * provides some macros in `fttypes.h`. + * + * FT_ERR( err ) + * + * Add current error module prefix (as defined with the `FT_ERR_PREFIX` + * macro) to `err`. For example, in the BDF module the line + * + * ``` + * error = FT_ERR( Invalid_Outline ); + * ``` + * + * expands to + * + * ``` + * error = BDF_Err_Invalid_Outline; + * ``` + * + * For simplicity, you can always use `FT_Err_Ok` directly instead of + * `FT_ERR( Ok )`. + * + * FT_ERR_EQ( errcode, err ) + * FT_ERR_NEQ( errcode, err ) + * + * Compare error code `errcode` with the error `err` for equality and + * inequality, respectively. Example: + * + * ``` + * if ( FT_ERR_EQ( error, Invalid_Outline ) ) + * ... + * ``` + * + * Using this macro you don't have to think about error prefixes. Of + * course, if module errors are not active, the above example is the + * same as + * + * ``` + * if ( error == FT_Err_Invalid_Outline ) + * ... + * ``` + * + * FT_ERROR_BASE( errcode ) + * FT_ERROR_MODULE( errcode ) + * + * Get base error and module error code, respectively. + * + * It can also be used to create a module error message table easily with + * something like + * + * ``` + * #undef FTMODERR_H_ + * #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, + * #define FT_MODERR_START_LIST { + * #define FT_MODERR_END_LIST { 0, 0 } }; + * + * const struct + * { + * int mod_err_offset; + * const char* mod_err_msg + * } ft_mod_errors[] = + * + * #include + * ``` + * + */ + + +#ifndef FTMODERR_H_ +#define FTMODERR_H_ + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** SETUP MACROS *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#undef FT_NEED_EXTERN_C + +#ifndef FT_MODERRDEF + +#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS +#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v, +#else +#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0, +#endif + +#define FT_MODERR_START_LIST enum { +#define FT_MODERR_END_LIST FT_Mod_Err_Max }; + +#ifdef __cplusplus +#define FT_NEED_EXTERN_C + extern "C" { +#endif + +#endif /* !FT_MODERRDEF */ + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** LIST MODULE ERROR BASES *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#ifdef FT_MODERR_START_LIST + FT_MODERR_START_LIST +#endif + + + FT_MODERRDEF( Base, 0x000, "base module" ) + FT_MODERRDEF( Autofit, 0x100, "autofitter module" ) + FT_MODERRDEF( BDF, 0x200, "BDF module" ) + FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" ) + FT_MODERRDEF( Cache, 0x400, "cache module" ) + FT_MODERRDEF( CFF, 0x500, "CFF module" ) + FT_MODERRDEF( CID, 0x600, "CID module" ) + FT_MODERRDEF( Gzip, 0x700, "Gzip module" ) + FT_MODERRDEF( LZW, 0x800, "LZW module" ) + FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" ) + FT_MODERRDEF( PCF, 0xA00, "PCF module" ) + FT_MODERRDEF( PFR, 0xB00, "PFR module" ) + FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" ) + FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" ) + FT_MODERRDEF( PSnames, 0xE00, "PS names module" ) + FT_MODERRDEF( Raster, 0xF00, "raster module" ) + FT_MODERRDEF( SFNT, 0x1000, "SFNT module" ) + FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" ) + FT_MODERRDEF( TrueType, 0x1200, "TrueType module" ) + FT_MODERRDEF( Type1, 0x1300, "Type 1 module" ) + FT_MODERRDEF( Type42, 0x1400, "Type 42 module" ) + FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" ) + FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" ) + FT_MODERRDEF( Sdf, 0x1700, "Signed distance field raster module" ) + + +#ifdef FT_MODERR_END_LIST + FT_MODERR_END_LIST +#endif + + + /*******************************************************************/ + /*******************************************************************/ + /***** *****/ + /***** CLEANUP *****/ + /***** *****/ + /*******************************************************************/ + /*******************************************************************/ + + +#ifdef FT_NEED_EXTERN_C + } +#endif + +#undef FT_MODERR_START_LIST +#undef FT_MODERR_END_LIST +#undef FT_MODERRDEF +#undef FT_NEED_EXTERN_C + + +#endif /* FTMODERR_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftotval.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftotval.h new file mode 100644 index 0000000000000000000000000000000000000000..88c2d29f981f37f68ea2792d8657678b592a11c2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftotval.h @@ -0,0 +1,206 @@ +/**************************************************************************** + * + * ftotval.h + * + * FreeType API for validating OpenType tables (specification). + * + * Copyright (C) 2004-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +/**************************************************************************** + * + * + * Warning: This module might be moved to a different library in the + * future to avoid a tight dependency between FreeType and the + * OpenType specification. + * + * + */ + + +#ifndef FTOTVAL_H_ +#define FTOTVAL_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * ot_validation + * + * @title: + * OpenType Validation + * + * @abstract: + * An API to validate OpenType tables. + * + * @description: + * This section contains the declaration of functions to validate some + * OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). + * + * @order: + * FT_OpenType_Validate + * FT_OpenType_Free + * + * FT_VALIDATE_OTXXX + * + */ + + + /************************************************************************** + * + * @enum: + * FT_VALIDATE_OTXXX + * + * @description: + * A list of bit-field constants used with @FT_OpenType_Validate to + * indicate which OpenType tables should be validated. + * + * @values: + * FT_VALIDATE_BASE :: + * Validate BASE table. + * + * FT_VALIDATE_GDEF :: + * Validate GDEF table. + * + * FT_VALIDATE_GPOS :: + * Validate GPOS table. + * + * FT_VALIDATE_GSUB :: + * Validate GSUB table. + * + * FT_VALIDATE_JSTF :: + * Validate JSTF table. + * + * FT_VALIDATE_MATH :: + * Validate MATH table. + * + * FT_VALIDATE_OT :: + * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). + * + */ +#define FT_VALIDATE_BASE 0x0100 +#define FT_VALIDATE_GDEF 0x0200 +#define FT_VALIDATE_GPOS 0x0400 +#define FT_VALIDATE_GSUB 0x0800 +#define FT_VALIDATE_JSTF 0x1000 +#define FT_VALIDATE_MATH 0x2000 + +#define FT_VALIDATE_OT ( FT_VALIDATE_BASE | \ + FT_VALIDATE_GDEF | \ + FT_VALIDATE_GPOS | \ + FT_VALIDATE_GSUB | \ + FT_VALIDATE_JSTF | \ + FT_VALIDATE_MATH ) + + + /************************************************************************** + * + * @function: + * FT_OpenType_Validate + * + * @description: + * Validate various OpenType tables to assure that all offsets and + * indices are valid. The idea is that a higher-level library that + * actually does the text layout can access those tables without error + * checking (which can be quite time consuming). + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the tables to be validated. See + * @FT_VALIDATE_OTXXX for possible values. + * + * @output: + * BASE_table :: + * A pointer to the BASE table. + * + * GDEF_table :: + * A pointer to the GDEF table. + * + * GPOS_table :: + * A pointer to the GPOS table. + * + * GSUB_table :: + * A pointer to the GSUB table. + * + * JSTF_table :: + * A pointer to the JSTF table. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with OpenType fonts, returning an error + * otherwise. + * + * After use, the application should deallocate the five tables with + * @FT_OpenType_Free. A `NULL` value indicates that the table either + * doesn't exist in the font, or the application hasn't asked for + * validation. + */ + FT_EXPORT( FT_Error ) + FT_OpenType_Validate( FT_Face face, + FT_UInt validation_flags, + FT_Bytes *BASE_table, + FT_Bytes *GDEF_table, + FT_Bytes *GPOS_table, + FT_Bytes *GSUB_table, + FT_Bytes *JSTF_table ); + + + /************************************************************************** + * + * @function: + * FT_OpenType_Free + * + * @description: + * Free the buffer allocated by OpenType validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer that is allocated by + * @FT_OpenType_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_OpenType_Validate only. + */ + FT_EXPORT( void ) + FT_OpenType_Free( FT_Face face, + FT_Bytes table ); + + + /* */ + + +FT_END_HEADER + +#endif /* FTOTVAL_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftoutln.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftoutln.h new file mode 100644 index 0000000000000000000000000000000000000000..86f91634d3c17b9b61f4efb1c3adae8fa9af69b8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftoutln.h @@ -0,0 +1,588 @@ +/**************************************************************************** + * + * ftoutln.h + * + * Support for the FT_Outline type used to store glyph shapes of + * most scalable font formats (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTOUTLN_H_ +#define FTOUTLN_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * outline_processing + * + * @title: + * Outline Processing + * + * @abstract: + * Functions to create, transform, and render vectorial glyph images. + * + * @description: + * This section contains routines used to create and destroy scalable + * glyph images known as 'outlines'. These can also be measured, + * transformed, and converted into bitmaps and pixmaps. + * + * @order: + * FT_Outline + * FT_Outline_New + * FT_Outline_Done + * FT_Outline_Copy + * FT_Outline_Translate + * FT_Outline_Transform + * FT_Outline_Embolden + * FT_Outline_EmboldenXY + * FT_Outline_Reverse + * FT_Outline_Check + * + * FT_Outline_Get_CBox + * FT_Outline_Get_BBox + * + * FT_Outline_Get_Bitmap + * FT_Outline_Render + * FT_Outline_Decompose + * FT_Outline_Funcs + * FT_Outline_MoveToFunc + * FT_Outline_LineToFunc + * FT_Outline_ConicToFunc + * FT_Outline_CubicToFunc + * + * FT_Orientation + * FT_Outline_Get_Orientation + * + * FT_OUTLINE_XXX + * + */ + + + /************************************************************************** + * + * @function: + * FT_Outline_Decompose + * + * @description: + * Walk over an outline's structure to decompose it into individual + * segments and Bezier arcs. This function also emits 'move to' + * operations to indicate the start of new contours in the outline. + * + * @input: + * outline :: + * A pointer to the source target. + * + * func_interface :: + * A table of 'emitters', i.e., function pointers called during + * decomposition to indicate path operations. + * + * @inout: + * user :: + * A typeless pointer that is passed to each emitter during the + * decomposition. It can be used to store the state during the + * decomposition. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Degenerate contours, segments, and Bezier arcs may be reported. In + * most cases, it is best to filter these out before using the outline + * for stroking or other path modification purposes (which may cause + * degenerate segments to become non-degenerate and visible, like when + * stroke caps are used or the path is otherwise outset). Some glyph + * outlines may contain deliberate degenerate single points for mark + * attachement. + * + * Similarly, the function returns success for an empty outline also + * (doing nothing, that is, not calling any emitter); if necessary, you + * should filter this out, too. + */ + FT_EXPORT( FT_Error ) + FT_Outline_Decompose( FT_Outline* outline, + const FT_Outline_Funcs* func_interface, + void* user ); + + + /************************************************************************** + * + * @function: + * FT_Outline_New + * + * @description: + * Create a new outline of a given size. + * + * @input: + * library :: + * A handle to the library object from where the outline is allocated. + * Note however that the new outline will **not** necessarily be + * **freed**, when destroying the library, by @FT_Done_FreeType. + * + * numPoints :: + * The maximum number of points within the outline. Must be smaller + * than or equal to 0xFFFF (65535). + * + * numContours :: + * The maximum number of contours within the outline. This value must + * be in the range 0 to `numPoints`. + * + * @output: + * anoutline :: + * A handle to the new outline. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The reason why this function takes a `library` parameter is simply to + * use the library's memory allocator. + */ + FT_EXPORT( FT_Error ) + FT_Outline_New( FT_Library library, + FT_UInt numPoints, + FT_Int numContours, + FT_Outline *anoutline ); + + + /************************************************************************** + * + * @function: + * FT_Outline_Done + * + * @description: + * Destroy an outline created with @FT_Outline_New. + * + * @input: + * library :: + * A handle of the library object used to allocate the outline. + * + * outline :: + * A pointer to the outline object to be discarded. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If the outline's 'owner' field is not set, only the outline descriptor + * will be released. + */ + FT_EXPORT( FT_Error ) + FT_Outline_Done( FT_Library library, + FT_Outline* outline ); + + + /************************************************************************** + * + * @function: + * FT_Outline_Check + * + * @description: + * Check the contents of an outline descriptor. + * + * @input: + * outline :: + * A handle to a source outline. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * An empty outline, or an outline with a single point only is also + * valid. + */ + FT_EXPORT( FT_Error ) + FT_Outline_Check( FT_Outline* outline ); + + + /************************************************************************** + * + * @function: + * FT_Outline_Get_CBox + * + * @description: + * Return an outline's 'control box'. The control box encloses all the + * outline's points, including Bezier control points. Though it + * coincides with the exact bounding box for most glyphs, it can be + * slightly larger in some situations (like when rotating an outline that + * contains Bezier outside arcs). + * + * Computing the control box is very fast, while getting the bounding box + * can take much more time as it needs to walk over all segments and arcs + * in the outline. To get the latter, you can use the 'ftbbox' + * component, which is dedicated to this single task. + * + * @input: + * outline :: + * A pointer to the source outline descriptor. + * + * @output: + * acbox :: + * The outline's control box. + * + * @note: + * See @FT_Glyph_Get_CBox for a discussion of tricky fonts. + */ + FT_EXPORT( void ) + FT_Outline_Get_CBox( const FT_Outline* outline, + FT_BBox *acbox ); + + + /************************************************************************** + * + * @function: + * FT_Outline_Translate + * + * @description: + * Apply a simple translation to the points of an outline. + * + * @inout: + * outline :: + * A pointer to the target outline descriptor. + * + * @input: + * xOffset :: + * The horizontal offset. + * + * yOffset :: + * The vertical offset. + */ + FT_EXPORT( void ) + FT_Outline_Translate( const FT_Outline* outline, + FT_Pos xOffset, + FT_Pos yOffset ); + + + /************************************************************************** + * + * @function: + * FT_Outline_Copy + * + * @description: + * Copy an outline into another one. Both objects must have the same + * sizes (number of points & number of contours) when this function is + * called. + * + * @input: + * source :: + * A handle to the source outline. + * + * @output: + * target :: + * A handle to the target outline. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Outline_Copy( const FT_Outline* source, + FT_Outline *target ); + + + /************************************************************************** + * + * @function: + * FT_Outline_Transform + * + * @description: + * Apply a simple 2x2 matrix to all of an outline's points. Useful for + * applying rotations, slanting, flipping, etc. + * + * @inout: + * outline :: + * A pointer to the target outline descriptor. + * + * @input: + * matrix :: + * A pointer to the transformation matrix. + * + * @note: + * You can use @FT_Outline_Translate if you need to translate the + * outline's points. + */ + FT_EXPORT( void ) + FT_Outline_Transform( const FT_Outline* outline, + const FT_Matrix* matrix ); + + + /************************************************************************** + * + * @function: + * FT_Outline_Embolden + * + * @description: + * Embolden an outline. The new outline will be at most 4~times + * `strength` pixels wider and higher. You may think of the left and + * bottom borders as unchanged. + * + * Negative `strength` values to reduce the outline thickness are + * possible also. + * + * @inout: + * outline :: + * A handle to the target outline. + * + * @input: + * strength :: + * How strong the glyph is emboldened. Expressed in 26.6 pixel format. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The used algorithm to increase or decrease the thickness of the glyph + * doesn't change the number of points; this means that certain + * situations like acute angles or intersections are sometimes handled + * incorrectly. + * + * If you need 'better' metrics values you should call + * @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. + * + * To get meaningful results, font scaling values must be set with + * functions like @FT_Set_Char_Size before calling FT_Render_Glyph. + * + * @example: + * ``` + * FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); + * + * if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) + * FT_Outline_Embolden( &face->glyph->outline, strength ); + * ``` + * + */ + FT_EXPORT( FT_Error ) + FT_Outline_Embolden( FT_Outline* outline, + FT_Pos strength ); + + + /************************************************************************** + * + * @function: + * FT_Outline_EmboldenXY + * + * @description: + * Embolden an outline. The new outline will be `xstrength` pixels wider + * and `ystrength` pixels higher. Otherwise, it is similar to + * @FT_Outline_Embolden, which uses the same strength in both directions. + * + * @since: + * 2.4.10 + */ + FT_EXPORT( FT_Error ) + FT_Outline_EmboldenXY( FT_Outline* outline, + FT_Pos xstrength, + FT_Pos ystrength ); + + + /************************************************************************** + * + * @function: + * FT_Outline_Reverse + * + * @description: + * Reverse the drawing direction of an outline. This is used to ensure + * consistent fill conventions for mirrored glyphs. + * + * @inout: + * outline :: + * A pointer to the target outline descriptor. + * + * @note: + * This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in the + * outline's `flags` field. + * + * It shouldn't be used by a normal client application, unless it knows + * what it is doing. + */ + FT_EXPORT( void ) + FT_Outline_Reverse( FT_Outline* outline ); + + + /************************************************************************** + * + * @function: + * FT_Outline_Get_Bitmap + * + * @description: + * Render an outline within a bitmap. The outline's image is simply + * OR-ed to the target bitmap. + * + * @input: + * library :: + * A handle to a FreeType library object. + * + * outline :: + * A pointer to the source outline descriptor. + * + * @inout: + * abitmap :: + * A pointer to the target bitmap descriptor. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function does **not create** the bitmap, it only renders an + * outline image within the one you pass to it! Consequently, the + * various fields in `abitmap` should be set accordingly. + * + * It will use the raster corresponding to the default glyph format. + * + * The value of the `num_grays` field in `abitmap` is ignored. If you + * select the gray-level rasterizer, and you want less than 256 gray + * levels, you have to use @FT_Outline_Render directly. + */ + FT_EXPORT( FT_Error ) + FT_Outline_Get_Bitmap( FT_Library library, + FT_Outline* outline, + const FT_Bitmap *abitmap ); + + + /************************************************************************** + * + * @function: + * FT_Outline_Render + * + * @description: + * Render an outline within a bitmap using the current scan-convert. + * + * @input: + * library :: + * A handle to a FreeType library object. + * + * outline :: + * A pointer to the source outline descriptor. + * + * @inout: + * params :: + * A pointer to an @FT_Raster_Params structure used to describe the + * rendering operation. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This advanced function uses @FT_Raster_Params as an argument. + * The field `params.source` will be set to `outline` before the scan + * converter is called, which means that the value you give to it is + * actually ignored. Either `params.target` must point to preallocated + * bitmap, or @FT_RASTER_FLAG_DIRECT must be set in `params.flags` + * allowing FreeType rasterizer to be used for direct composition, + * translucency, etc. See @FT_Raster_Params for more details. + */ + FT_EXPORT( FT_Error ) + FT_Outline_Render( FT_Library library, + FT_Outline* outline, + FT_Raster_Params* params ); + + + /************************************************************************** + * + * @enum: + * FT_Orientation + * + * @description: + * A list of values used to describe an outline's contour orientation. + * + * The TrueType and PostScript specifications use different conventions + * to determine whether outline contours should be filled or unfilled. + * + * @values: + * FT_ORIENTATION_TRUETYPE :: + * According to the TrueType specification, clockwise contours must be + * filled, and counter-clockwise ones must be unfilled. + * + * FT_ORIENTATION_POSTSCRIPT :: + * According to the PostScript specification, counter-clockwise + * contours must be filled, and clockwise ones must be unfilled. + * + * FT_ORIENTATION_FILL_RIGHT :: + * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to + * remember that in TrueType, everything that is to the right of the + * drawing direction of a contour must be filled. + * + * FT_ORIENTATION_FILL_LEFT :: + * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to + * remember that in PostScript, everything that is to the left of the + * drawing direction of a contour must be filled. + * + * FT_ORIENTATION_NONE :: + * The orientation cannot be determined. That is, different parts of + * the glyph have different orientation. + * + */ + typedef enum FT_Orientation_ + { + FT_ORIENTATION_TRUETYPE = 0, + FT_ORIENTATION_POSTSCRIPT = 1, + FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE, + FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT, + FT_ORIENTATION_NONE + + } FT_Orientation; + + + /************************************************************************** + * + * @function: + * FT_Outline_Get_Orientation + * + * @description: + * This function analyzes a glyph outline and tries to compute its fill + * orientation (see @FT_Orientation). This is done by integrating the + * total area covered by the outline. The positive integral corresponds + * to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT is + * returned. The negative integral corresponds to the counter-clockwise + * orientation and @FT_ORIENTATION_TRUETYPE is returned. + * + * Note that this will return @FT_ORIENTATION_TRUETYPE for empty + * outlines. + * + * @input: + * outline :: + * A handle to the source outline. + * + * @return: + * The orientation. + * + */ + FT_EXPORT( FT_Orientation ) + FT_Outline_Get_Orientation( FT_Outline* outline ); + + + /* */ + + +FT_END_HEADER + +#endif /* FTOUTLN_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftparams.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftparams.h new file mode 100644 index 0000000000000000000000000000000000000000..e65e61fd20277ea9b89478566457f566a700e558 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftparams.h @@ -0,0 +1,218 @@ +/**************************************************************************** + * + * ftparams.h + * + * FreeType API for possible FT_Parameter tags (specification only). + * + * Copyright (C) 2017-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTPARAMS_H_ +#define FTPARAMS_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * parameter_tags + * + * @title: + * Parameter Tags + * + * @abstract: + * Macros for driver property and font loading parameter tags. + * + * @description: + * This section contains macros for the @FT_Parameter structure that are + * used with various functions to activate some special functionality or + * different behaviour of various components of FreeType. + * + */ + + + /************************************************************************** + * + * @enum: + * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY + * + * @description: + * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic + * family names in the 'name' table (introduced in OpenType version 1.4). + * Use this for backward compatibility with legacy systems that have a + * four-faces-per-family restriction. + * + * @since: + * 2.8 + * + */ +#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY \ + FT_MAKE_TAG( 'i', 'g', 'p', 'f' ) + + + /* this constant is deprecated */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY \ + FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY + + + /************************************************************************** + * + * @enum: + * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY + * + * @description: + * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic + * subfamily names in the 'name' table (introduced in OpenType version + * 1.4). Use this for backward compatibility with legacy systems that + * have a four-faces-per-family restriction. + * + * @since: + * 2.8 + * + */ +#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY \ + FT_MAKE_TAG( 'i', 'g', 'p', 's' ) + + + /* this constant is deprecated */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY \ + FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY + + + /************************************************************************** + * + * @enum: + * FT_PARAM_TAG_INCREMENTAL + * + * @description: + * An @FT_Parameter tag to be used with @FT_Open_Face to indicate + * incremental glyph loading. + * + */ +#define FT_PARAM_TAG_INCREMENTAL \ + FT_MAKE_TAG( 'i', 'n', 'c', 'r' ) + + + /************************************************************************** + * + * @enum: + * FT_PARAM_TAG_IGNORE_SBIX + * + * @description: + * A tag for @FT_Parameter to make @FT_Open_Face ignore an 'sbix' table + * while loading a font. Use this if @FT_FACE_FLAG_SBIX is set and you + * want to access the outline glyphs in the font. + * + */ +#define FT_PARAM_TAG_IGNORE_SBIX \ + FT_MAKE_TAG( 'i', 's', 'b', 'x' ) + + + /************************************************************************** + * + * @enum: + * FT_PARAM_TAG_LCD_FILTER_WEIGHTS + * + * @description: + * An @FT_Parameter tag to be used with @FT_Face_Properties. The + * corresponding argument specifies the five LCD filter weights for a + * given face (if using @FT_LOAD_TARGET_LCD, for example), overriding the + * global default values or the values set up with + * @FT_Library_SetLcdFilterWeights. + * + * @since: + * 2.8 + * + */ +#define FT_PARAM_TAG_LCD_FILTER_WEIGHTS \ + FT_MAKE_TAG( 'l', 'c', 'd', 'f' ) + + + /************************************************************************** + * + * @enum: + * FT_PARAM_TAG_RANDOM_SEED + * + * @description: + * An @FT_Parameter tag to be used with @FT_Face_Properties. The + * corresponding 32bit signed integer argument overrides the font + * driver's random seed value with a face-specific one; see @random-seed. + * + * @since: + * 2.8 + * + */ +#define FT_PARAM_TAG_RANDOM_SEED \ + FT_MAKE_TAG( 's', 'e', 'e', 'd' ) + + + /************************************************************************** + * + * @enum: + * FT_PARAM_TAG_STEM_DARKENING + * + * @description: + * An @FT_Parameter tag to be used with @FT_Face_Properties. The + * corresponding Boolean argument specifies whether to apply stem + * darkening, overriding the global default values or the values set up + * with @FT_Property_Set (see @no-stem-darkening). + * + * This is a passive setting that only takes effect if the font driver or + * autohinter honors it, which the CFF, Type~1, and CID drivers always + * do, but the autohinter only in 'light' hinting mode (as of version + * 2.9). + * + * @since: + * 2.8 + * + */ +#define FT_PARAM_TAG_STEM_DARKENING \ + FT_MAKE_TAG( 'd', 'a', 'r', 'k' ) + + + /************************************************************************** + * + * @enum: + * FT_PARAM_TAG_UNPATENTED_HINTING + * + * @description: + * Deprecated, no effect. + * + * Previously: A constant used as the tag of an @FT_Parameter structure + * to indicate that unpatented methods only should be used by the + * TrueType bytecode interpreter for a typeface opened by @FT_Open_Face. + * + */ +#define FT_PARAM_TAG_UNPATENTED_HINTING \ + FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) + + + /* */ + + +FT_END_HEADER + + +#endif /* FTPARAMS_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftpfr.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftpfr.h new file mode 100644 index 0000000000000000000000000000000000000000..30db3853a327cd223baffd138e6940c33a2910c1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftpfr.h @@ -0,0 +1,179 @@ +/**************************************************************************** + * + * ftpfr.h + * + * FreeType API for accessing PFR-specific data (specification only). + * + * Copyright (C) 2002-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTPFR_H_ +#define FTPFR_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * pfr_fonts + * + * @title: + * PFR Fonts + * + * @abstract: + * PFR/TrueDoc-specific API. + * + * @description: + * This section contains the declaration of PFR-specific functions. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Get_PFR_Metrics + * + * @description: + * Return the outline and metrics resolutions of a given PFR face. + * + * @input: + * face :: + * Handle to the input face. It can be a non-PFR face. + * + * @output: + * aoutline_resolution :: + * Outline resolution. This is equivalent to `face->units_per_EM` for + * non-PFR fonts. Optional (parameter can be `NULL`). + * + * ametrics_resolution :: + * Metrics resolution. This is equivalent to `outline_resolution` for + * non-PFR fonts. Optional (parameter can be `NULL`). + * + * ametrics_x_scale :: + * A 16.16 fixed-point number used to scale distance expressed in + * metrics units to device subpixels. This is equivalent to + * `face->size->x_scale`, but for metrics only. Optional (parameter + * can be `NULL`). + * + * ametrics_y_scale :: + * Same as `ametrics_x_scale` but for the vertical direction. + * optional (parameter can be `NULL`). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If the input face is not a PFR, this function will return an error. + * However, in all cases, it will return valid values. + */ + FT_EXPORT( FT_Error ) + FT_Get_PFR_Metrics( FT_Face face, + FT_UInt *aoutline_resolution, + FT_UInt *ametrics_resolution, + FT_Fixed *ametrics_x_scale, + FT_Fixed *ametrics_y_scale ); + + + /************************************************************************** + * + * @function: + * FT_Get_PFR_Kerning + * + * @description: + * Return the kerning pair corresponding to two glyphs in a PFR face. + * The distance is expressed in metrics units, unlike the result of + * @FT_Get_Kerning. + * + * @input: + * face :: + * A handle to the input face. + * + * left :: + * Index of the left glyph. + * + * right :: + * Index of the right glyph. + * + * @output: + * avector :: + * A kerning vector. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function always return distances in original PFR metrics units. + * This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED mode, + * which always returns distances converted to outline units. + * + * You can use the value of the `x_scale` and `y_scale` parameters + * returned by @FT_Get_PFR_Metrics to scale these to device subpixels. + */ + FT_EXPORT( FT_Error ) + FT_Get_PFR_Kerning( FT_Face face, + FT_UInt left, + FT_UInt right, + FT_Vector *avector ); + + + /************************************************************************** + * + * @function: + * FT_Get_PFR_Advance + * + * @description: + * Return a given glyph advance, expressed in original metrics units, + * from a PFR font. + * + * @input: + * face :: + * A handle to the input face. + * + * gindex :: + * The glyph index. + * + * @output: + * aadvance :: + * The glyph advance in metrics units. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You can use the `x_scale` or `y_scale` results of @FT_Get_PFR_Metrics + * to convert the advance to device subpixels (i.e., 1/64 of pixels). + */ + FT_EXPORT( FT_Error ) + FT_Get_PFR_Advance( FT_Face face, + FT_UInt gindex, + FT_Pos *aadvance ); + + /* */ + + +FT_END_HEADER + +#endif /* FTPFR_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftrender.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftrender.h new file mode 100644 index 0000000000000000000000000000000000000000..542e2a2f97f0f89df808de26f015ca7e8f4e429c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftrender.h @@ -0,0 +1,244 @@ +/**************************************************************************** + * + * ftrender.h + * + * FreeType renderer modules public interface (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTRENDER_H_ +#define FTRENDER_H_ + + +#include +#include + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * module_management + * + */ + + + /* create a new glyph object */ + typedef FT_Error + (*FT_Glyph_InitFunc)( FT_Glyph glyph, + FT_GlyphSlot slot ); + + /* destroys a given glyph object */ + typedef void + (*FT_Glyph_DoneFunc)( FT_Glyph glyph ); + + typedef void + (*FT_Glyph_TransformFunc)( FT_Glyph glyph, + const FT_Matrix* matrix, + const FT_Vector* delta ); + + typedef void + (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph, + FT_BBox* abbox ); + + typedef FT_Error + (*FT_Glyph_CopyFunc)( FT_Glyph source, + FT_Glyph target ); + + typedef FT_Error + (*FT_Glyph_PrepareFunc)( FT_Glyph glyph, + FT_GlyphSlot slot ); + +/* deprecated */ +#define FT_Glyph_Init_Func FT_Glyph_InitFunc +#define FT_Glyph_Done_Func FT_Glyph_DoneFunc +#define FT_Glyph_Transform_Func FT_Glyph_TransformFunc +#define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc +#define FT_Glyph_Copy_Func FT_Glyph_CopyFunc +#define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc + + + struct FT_Glyph_Class_ + { + FT_Long glyph_size; + FT_Glyph_Format glyph_format; + + FT_Glyph_InitFunc glyph_init; + FT_Glyph_DoneFunc glyph_done; + FT_Glyph_CopyFunc glyph_copy; + FT_Glyph_TransformFunc glyph_transform; + FT_Glyph_GetBBoxFunc glyph_bbox; + FT_Glyph_PrepareFunc glyph_prepare; + }; + + + typedef FT_Error + (*FT_Renderer_RenderFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + FT_Render_Mode mode, + const FT_Vector* origin ); + + typedef FT_Error + (*FT_Renderer_TransformFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + const FT_Matrix* matrix, + const FT_Vector* delta ); + + + typedef void + (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + FT_BBox* cbox ); + + + typedef FT_Error + (*FT_Renderer_SetModeFunc)( FT_Renderer renderer, + FT_ULong mode_tag, + FT_Pointer mode_ptr ); + +/* deprecated identifiers */ +#define FTRenderer_render FT_Renderer_RenderFunc +#define FTRenderer_transform FT_Renderer_TransformFunc +#define FTRenderer_getCBox FT_Renderer_GetCBoxFunc +#define FTRenderer_setMode FT_Renderer_SetModeFunc + + + /************************************************************************** + * + * @struct: + * FT_Renderer_Class + * + * @description: + * The renderer module class descriptor. + * + * @fields: + * root :: + * The root @FT_Module_Class fields. + * + * glyph_format :: + * The glyph image format this renderer handles. + * + * render_glyph :: + * A method used to render the image that is in a given glyph slot into + * a bitmap. + * + * transform_glyph :: + * A method used to transform the image that is in a given glyph slot. + * + * get_glyph_cbox :: + * A method used to access the glyph's cbox. + * + * set_mode :: + * A method used to pass additional parameters. + * + * raster_class :: + * For @FT_GLYPH_FORMAT_OUTLINE renderers only. This is a pointer to + * its raster's class. + */ + typedef struct FT_Renderer_Class_ + { + FT_Module_Class root; + + FT_Glyph_Format glyph_format; + + FT_Renderer_RenderFunc render_glyph; + FT_Renderer_TransformFunc transform_glyph; + FT_Renderer_GetCBoxFunc get_glyph_cbox; + FT_Renderer_SetModeFunc set_mode; + + const FT_Raster_Funcs* raster_class; + + } FT_Renderer_Class; + + + /************************************************************************** + * + * @function: + * FT_Get_Renderer + * + * @description: + * Retrieve the current renderer for a given glyph format. + * + * @input: + * library :: + * A handle to the library object. + * + * format :: + * The glyph format. + * + * @return: + * A renderer handle. 0~if none found. + * + * @note: + * An error will be returned if a module already exists by that name, or + * if the module requires a version of FreeType that is too great. + * + * To add a new renderer, simply use @FT_Add_Module. To retrieve a + * renderer by its name, use @FT_Get_Module. + */ + FT_EXPORT( FT_Renderer ) + FT_Get_Renderer( FT_Library library, + FT_Glyph_Format format ); + + + /************************************************************************** + * + * @function: + * FT_Set_Renderer + * + * @description: + * Set the current renderer to use, and set additional mode. + * + * @inout: + * library :: + * A handle to the library object. + * + * @input: + * renderer :: + * A handle to the renderer object. + * + * num_params :: + * The number of additional parameters. + * + * parameters :: + * Additional parameters. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * In case of success, the renderer will be used to convert glyph images + * in the renderer's known format into bitmaps. + * + * This doesn't change the current renderer for other formats. + * + * Currently, no FreeType renderer module uses `parameters`; you should + * thus always pass `NULL` as the value. + */ + FT_EXPORT( FT_Error ) + FT_Set_Renderer( FT_Library library, + FT_Renderer renderer, + FT_UInt num_params, + FT_Parameter* parameters ); + + /* */ + + +FT_END_HEADER + +#endif /* FTRENDER_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsizes.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsizes.h new file mode 100644 index 0000000000000000000000000000000000000000..4b4199178679d2c6ec3ffa116c847fcc01070379 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsizes.h @@ -0,0 +1,159 @@ +/**************************************************************************** + * + * ftsizes.h + * + * FreeType size objects management (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * Typical application would normally not need to use these functions. + * However, they have been placed in a public API for the rare cases where + * they are needed. + * + */ + + +#ifndef FTSIZES_H_ +#define FTSIZES_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * sizes_management + * + * @title: + * Size Management + * + * @abstract: + * Managing multiple sizes per face. + * + * @description: + * When creating a new face object (e.g., with @FT_New_Face), an @FT_Size + * object is automatically created and used to store all pixel-size + * dependent information, available in the `face->size` field. + * + * It is however possible to create more sizes for a given face, mostly + * in order to manage several character pixel sizes of the same font + * family and style. See @FT_New_Size and @FT_Done_Size. + * + * Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only modify the + * contents of the current 'active' size; you thus need to use + * @FT_Activate_Size to change it. + * + * 99% of applications won't need the functions provided here, especially + * if they use the caching sub-system, so be cautious when using these. + * + */ + + + /************************************************************************** + * + * @function: + * FT_New_Size + * + * @description: + * Create a new size object from a given face object. + * + * @input: + * face :: + * A handle to a parent face object. + * + * @output: + * asize :: + * A handle to a new size object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You need to call @FT_Activate_Size in order to select the new size for + * upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, + * @FT_Load_Glyph, @FT_Load_Char, etc. + */ + FT_EXPORT( FT_Error ) + FT_New_Size( FT_Face face, + FT_Size* size ); + + + /************************************************************************** + * + * @function: + * FT_Done_Size + * + * @description: + * Discard a given size object. Note that @FT_Done_Face automatically + * discards all size objects allocated with @FT_New_Size. + * + * @input: + * size :: + * A handle to a target size object. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Done_Size( FT_Size size ); + + + /************************************************************************** + * + * @function: + * FT_Activate_Size + * + * @description: + * Even though it is possible to create several size objects for a given + * face (see @FT_New_Size for details), functions like @FT_Load_Glyph or + * @FT_Load_Char only use the one that has been activated last to + * determine the 'current character pixel size'. + * + * This function can be used to 'activate' a previously created size + * object. + * + * @input: + * size :: + * A handle to a target size object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `face` is the size's parent face object, this function changes the + * value of `face->size` to the input size handle. + */ + FT_EXPORT( FT_Error ) + FT_Activate_Size( FT_Size size ); + + /* */ + + +FT_END_HEADER + +#endif /* FTSIZES_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsnames.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsnames.h new file mode 100644 index 0000000000000000000000000000000000000000..544f29749e983ab97e3ca95776cf61f2298311ec --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsnames.h @@ -0,0 +1,272 @@ +/**************************************************************************** + * + * ftsnames.h + * + * Simple interface to access SFNT 'name' tables (which are used + * to hold font names, copyright info, notices, etc.) (specification). + * + * This is _not_ used to retrieve glyph names! + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTSNAMES_H_ +#define FTSNAMES_H_ + + +#include +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * sfnt_names + * + * @title: + * SFNT Names + * + * @abstract: + * Access the names embedded in TrueType and OpenType files. + * + * @description: + * The TrueType and OpenType specifications allow the inclusion of a + * special names table ('name') in font files. This table contains + * textual (and internationalized) information regarding the font, like + * family name, copyright, version, etc. + * + * The definitions below are used to access them if available. + * + * Note that this has nothing to do with glyph names! + * + */ + + + /************************************************************************** + * + * @struct: + * FT_SfntName + * + * @description: + * A structure used to model an SFNT 'name' table entry. + * + * @fields: + * platform_id :: + * The platform ID for `string`. See @TT_PLATFORM_XXX for possible + * values. + * + * encoding_id :: + * The encoding ID for `string`. See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, + * @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX for possible + * values. + * + * language_id :: + * The language ID for `string`. See @TT_MAC_LANGID_XXX and + * @TT_MS_LANGID_XXX for possible values. + * + * Registered OpenType values for `language_id` are always smaller than + * 0x8000; values equal or larger than 0x8000 usually indicate a + * language tag string (introduced in OpenType version 1.6). Use + * function @FT_Get_Sfnt_LangTag with `language_id` as its argument to + * retrieve the associated language tag. + * + * name_id :: + * An identifier for `string`. See @TT_NAME_ID_XXX for possible + * values. + * + * string :: + * The 'name' string. Note that its format differs depending on the + * (platform,encoding) pair, being either a string of bytes (without a + * terminating `NULL` byte) or containing UTF-16BE entities. + * + * string_len :: + * The length of `string` in bytes. + * + * @note: + * Please refer to the TrueType or OpenType specification for more + * details. + */ + typedef struct FT_SfntName_ + { + FT_UShort platform_id; + FT_UShort encoding_id; + FT_UShort language_id; + FT_UShort name_id; + + FT_Byte* string; /* this string is *not* null-terminated! */ + FT_UInt string_len; /* in bytes */ + + } FT_SfntName; + + + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_Name_Count + * + * @description: + * Retrieve the number of name strings in the SFNT 'name' table. + * + * @input: + * face :: + * A handle to the source face. + * + * @return: + * The number of strings in the 'name' table. + * + * @note: + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`. + */ + FT_EXPORT( FT_UInt ) + FT_Get_Sfnt_Name_Count( FT_Face face ); + + + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_Name + * + * @description: + * Retrieve a string of the SFNT 'name' table for a given index. + * + * @input: + * face :: + * A handle to the source face. + * + * idx :: + * The index of the 'name' string. + * + * @output: + * aname :: + * The indexed @FT_SfntName structure. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The `string` array returned in the `aname` structure is not + * null-terminated. Note that you don't have to deallocate `string` by + * yourself; FreeType takes care of it if you call @FT_Done_Face. + * + * Use @FT_Get_Sfnt_Name_Count to get the total number of available + * 'name' table entries, then do a loop until you get the right platform, + * encoding, and name ID. + * + * 'name' table format~1 entries can use language tags also, see + * @FT_Get_Sfnt_LangTag. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`. + */ + FT_EXPORT( FT_Error ) + FT_Get_Sfnt_Name( FT_Face face, + FT_UInt idx, + FT_SfntName *aname ); + + + /************************************************************************** + * + * @struct: + * FT_SfntLangTag + * + * @description: + * A structure to model a language tag entry from an SFNT 'name' table. + * + * @fields: + * string :: + * The language tag string, encoded in UTF-16BE (without trailing + * `NULL` bytes). + * + * string_len :: + * The length of `string` in **bytes**. + * + * @note: + * Please refer to the TrueType or OpenType specification for more + * details. + * + * @since: + * 2.8 + */ + typedef struct FT_SfntLangTag_ + { + FT_Byte* string; /* this string is *not* null-terminated! */ + FT_UInt string_len; /* in bytes */ + + } FT_SfntLangTag; + + + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_LangTag + * + * @description: + * Retrieve the language tag associated with a language ID of an SFNT + * 'name' table entry. + * + * @input: + * face :: + * A handle to the source face. + * + * langID :: + * The language ID, as returned by @FT_Get_Sfnt_Name. This is always a + * value larger than 0x8000. + * + * @output: + * alangTag :: + * The language tag associated with the 'name' table entry's language + * ID. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The `string` array returned in the `alangTag` structure is not + * null-terminated. Note that you don't have to deallocate `string` by + * yourself; FreeType takes care of it if you call @FT_Done_Face. + * + * Only 'name' table format~1 supports language tags. For format~0 + * tables, this function always returns FT_Err_Invalid_Table. For + * invalid format~1 language ID values, FT_Err_Invalid_Argument is + * returned. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`. + * + * @since: + * 2.8 + */ + FT_EXPORT( FT_Error ) + FT_Get_Sfnt_LangTag( FT_Face face, + FT_UInt langID, + FT_SfntLangTag *alangTag ); + + + /* */ + + +FT_END_HEADER + +#endif /* FTSNAMES_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftstroke.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftstroke.h new file mode 100644 index 0000000000000000000000000000000000000000..d22a9a8170498c544fa3c875e94f1ebca1c7fa30 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftstroke.h @@ -0,0 +1,773 @@ +/**************************************************************************** + * + * ftstroke.h + * + * FreeType path stroker (specification). + * + * Copyright (C) 2002-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTSTROKE_H_ +#define FTSTROKE_H_ + +#include +#include + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * glyph_stroker + * + * @title: + * Glyph Stroker + * + * @abstract: + * Generating bordered and stroked glyphs. + * + * @description: + * This component generates stroked outlines of a given vectorial glyph. + * It also allows you to retrieve the 'outside' and/or the 'inside' + * borders of the stroke. + * + * This can be useful to generate 'bordered' glyph, i.e., glyphs + * displayed with a colored (and anti-aliased) border around their + * shape. + * + * @order: + * FT_Stroker + * + * FT_Stroker_LineJoin + * FT_Stroker_LineCap + * FT_StrokerBorder + * + * FT_Outline_GetInsideBorder + * FT_Outline_GetOutsideBorder + * + * FT_Glyph_Stroke + * FT_Glyph_StrokeBorder + * + * FT_Stroker_New + * FT_Stroker_Set + * FT_Stroker_Rewind + * FT_Stroker_ParseOutline + * FT_Stroker_Done + * + * FT_Stroker_BeginSubPath + * FT_Stroker_EndSubPath + * + * FT_Stroker_LineTo + * FT_Stroker_ConicTo + * FT_Stroker_CubicTo + * + * FT_Stroker_GetBorderCounts + * FT_Stroker_ExportBorder + * FT_Stroker_GetCounts + * FT_Stroker_Export + * + */ + + + /************************************************************************** + * + * @type: + * FT_Stroker + * + * @description: + * Opaque handle to a path stroker object. + */ + typedef struct FT_StrokerRec_* FT_Stroker; + + + /************************************************************************** + * + * @enum: + * FT_Stroker_LineJoin + * + * @description: + * These values determine how two joining lines are rendered in a + * stroker. + * + * @values: + * FT_STROKER_LINEJOIN_ROUND :: + * Used to render rounded line joins. Circular arcs are used to join + * two lines smoothly. + * + * FT_STROKER_LINEJOIN_BEVEL :: + * Used to render beveled line joins. The outer corner of the joined + * lines is filled by enclosing the triangular region of the corner + * with a straight line between the outer corners of each stroke. + * + * FT_STROKER_LINEJOIN_MITER_FIXED :: + * Used to render mitered line joins, with fixed bevels if the miter + * limit is exceeded. The outer edges of the strokes for the two + * segments are extended until they meet at an angle. A bevel join + * (see above) is used if the segments meet at too sharp an angle and + * the outer edges meet beyond a distance corresponding to the meter + * limit. This prevents long spikes being created. + * `FT_STROKER_LINEJOIN_MITER_FIXED` generates a miter line join as + * used in PostScript and PDF. + * + * FT_STROKER_LINEJOIN_MITER_VARIABLE :: + * FT_STROKER_LINEJOIN_MITER :: + * Used to render mitered line joins, with variable bevels if the miter + * limit is exceeded. The intersection of the strokes is clipped + * perpendicularly to the bisector, at a distance corresponding to + * the miter limit. This prevents long spikes being created. + * `FT_STROKER_LINEJOIN_MITER_VARIABLE` generates a mitered line join + * as used in XPS. `FT_STROKER_LINEJOIN_MITER` is an alias for + * `FT_STROKER_LINEJOIN_MITER_VARIABLE`, retained for backward + * compatibility. + */ + typedef enum FT_Stroker_LineJoin_ + { + FT_STROKER_LINEJOIN_ROUND = 0, + FT_STROKER_LINEJOIN_BEVEL = 1, + FT_STROKER_LINEJOIN_MITER_VARIABLE = 2, + FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE, + FT_STROKER_LINEJOIN_MITER_FIXED = 3 + + } FT_Stroker_LineJoin; + + + /************************************************************************** + * + * @enum: + * FT_Stroker_LineCap + * + * @description: + * These values determine how the end of opened sub-paths are rendered in + * a stroke. + * + * @values: + * FT_STROKER_LINECAP_BUTT :: + * The end of lines is rendered as a full stop on the last point + * itself. + * + * FT_STROKER_LINECAP_ROUND :: + * The end of lines is rendered as a half-circle around the last point. + * + * FT_STROKER_LINECAP_SQUARE :: + * The end of lines is rendered as a square around the last point. + */ + typedef enum FT_Stroker_LineCap_ + { + FT_STROKER_LINECAP_BUTT = 0, + FT_STROKER_LINECAP_ROUND, + FT_STROKER_LINECAP_SQUARE + + } FT_Stroker_LineCap; + + + /************************************************************************** + * + * @enum: + * FT_StrokerBorder + * + * @description: + * These values are used to select a given stroke border in + * @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder. + * + * @values: + * FT_STROKER_BORDER_LEFT :: + * Select the left border, relative to the drawing direction. + * + * FT_STROKER_BORDER_RIGHT :: + * Select the right border, relative to the drawing direction. + * + * @note: + * Applications are generally interested in the 'inside' and 'outside' + * borders. However, there is no direct mapping between these and the + * 'left' and 'right' ones, since this really depends on the glyph's + * drawing orientation, which varies between font formats. + * + * You can however use @FT_Outline_GetInsideBorder and + * @FT_Outline_GetOutsideBorder to get these. + */ + typedef enum FT_StrokerBorder_ + { + FT_STROKER_BORDER_LEFT = 0, + FT_STROKER_BORDER_RIGHT + + } FT_StrokerBorder; + + + /************************************************************************** + * + * @function: + * FT_Outline_GetInsideBorder + * + * @description: + * Retrieve the @FT_StrokerBorder value corresponding to the 'inside' + * borders of a given outline. + * + * @input: + * outline :: + * The source outline handle. + * + * @return: + * The border index. @FT_STROKER_BORDER_RIGHT for empty or invalid + * outlines. + */ + FT_EXPORT( FT_StrokerBorder ) + FT_Outline_GetInsideBorder( FT_Outline* outline ); + + + /************************************************************************** + * + * @function: + * FT_Outline_GetOutsideBorder + * + * @description: + * Retrieve the @FT_StrokerBorder value corresponding to the 'outside' + * borders of a given outline. + * + * @input: + * outline :: + * The source outline handle. + * + * @return: + * The border index. @FT_STROKER_BORDER_LEFT for empty or invalid + * outlines. + */ + FT_EXPORT( FT_StrokerBorder ) + FT_Outline_GetOutsideBorder( FT_Outline* outline ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_New + * + * @description: + * Create a new stroker object. + * + * @input: + * library :: + * FreeType library handle. + * + * @output: + * astroker :: + * A new stroker object handle. `NULL` in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_New( FT_Library library, + FT_Stroker *astroker ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_Set + * + * @description: + * Reset a stroker object's attributes. + * + * @input: + * stroker :: + * The target stroker handle. + * + * radius :: + * The border radius. + * + * line_cap :: + * The line cap style. + * + * line_join :: + * The line join style. + * + * miter_limit :: + * The maximum reciprocal sine of half-angle at the miter join, + * expressed as 16.16 fixed-point value. + * + * @note: + * The `radius` is expressed in the same units as the outline + * coordinates. + * + * The `miter_limit` multiplied by the `radius` gives the maximum size + * of a miter spike, at which it is clipped for + * @FT_STROKER_LINEJOIN_MITER_VARIABLE or replaced with a bevel join for + * @FT_STROKER_LINEJOIN_MITER_FIXED. + * + * This function calls @FT_Stroker_Rewind automatically. + */ + FT_EXPORT( void ) + FT_Stroker_Set( FT_Stroker stroker, + FT_Fixed radius, + FT_Stroker_LineCap line_cap, + FT_Stroker_LineJoin line_join, + FT_Fixed miter_limit ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_Rewind + * + * @description: + * Reset a stroker object without changing its attributes. You should + * call this function before beginning a new series of calls to + * @FT_Stroker_BeginSubPath or @FT_Stroker_EndSubPath. + * + * @input: + * stroker :: + * The target stroker handle. + */ + FT_EXPORT( void ) + FT_Stroker_Rewind( FT_Stroker stroker ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_ParseOutline + * + * @description: + * A convenience function used to parse a whole outline with the stroker. + * The resulting outline(s) can be retrieved later by functions like + * @FT_Stroker_GetCounts and @FT_Stroker_Export. + * + * @input: + * stroker :: + * The target stroker handle. + * + * outline :: + * The source outline. + * + * opened :: + * A boolean. If~1, the outline is treated as an open path instead of + * a closed one. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `opened` is~0 (the default), the outline is treated as a closed + * path, and the stroker generates two distinct 'border' outlines. + * + * If `opened` is~1, the outline is processed as an open path, and the + * stroker generates a single 'stroke' outline. + * + * This function calls @FT_Stroker_Rewind automatically. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_ParseOutline( FT_Stroker stroker, + FT_Outline* outline, + FT_Bool opened ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_BeginSubPath + * + * @description: + * Start a new sub-path in the stroker. + * + * @input: + * stroker :: + * The target stroker handle. + * + * to :: + * A pointer to the start vector. + * + * open :: + * A boolean. If~1, the sub-path is treated as an open one. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function is useful when you need to stroke a path that is not + * stored as an @FT_Outline object. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_BeginSubPath( FT_Stroker stroker, + FT_Vector* to, + FT_Bool open ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_EndSubPath + * + * @description: + * Close the current sub-path in the stroker. + * + * @input: + * stroker :: + * The target stroker handle. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function after @FT_Stroker_BeginSubPath. If the + * subpath was not 'opened', this function 'draws' a single line segment + * to the start position when needed. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_EndSubPath( FT_Stroker stroker ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_LineTo + * + * @description: + * 'Draw' a single line segment in the stroker's current sub-path, from + * the last position. + * + * @input: + * stroker :: + * The target stroker handle. + * + * to :: + * A pointer to the destination point. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function between @FT_Stroker_BeginSubPath and + * @FT_Stroker_EndSubPath. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_LineTo( FT_Stroker stroker, + FT_Vector* to ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_ConicTo + * + * @description: + * 'Draw' a single quadratic Bezier in the stroker's current sub-path, + * from the last position. + * + * @input: + * stroker :: + * The target stroker handle. + * + * control :: + * A pointer to a Bezier control point. + * + * to :: + * A pointer to the destination point. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function between @FT_Stroker_BeginSubPath and + * @FT_Stroker_EndSubPath. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_ConicTo( FT_Stroker stroker, + FT_Vector* control, + FT_Vector* to ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_CubicTo + * + * @description: + * 'Draw' a single cubic Bezier in the stroker's current sub-path, from + * the last position. + * + * @input: + * stroker :: + * The target stroker handle. + * + * control1 :: + * A pointer to the first Bezier control point. + * + * control2 :: + * A pointer to second Bezier control point. + * + * to :: + * A pointer to the destination point. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should call this function between @FT_Stroker_BeginSubPath and + * @FT_Stroker_EndSubPath. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_CubicTo( FT_Stroker stroker, + FT_Vector* control1, + FT_Vector* control2, + FT_Vector* to ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_GetBorderCounts + * + * @description: + * Call this function once you have finished parsing your paths with the + * stroker. It returns the number of points and contours necessary to + * export one of the 'border' or 'stroke' outlines generated by the + * stroker. + * + * @input: + * stroker :: + * The target stroker handle. + * + * border :: + * The border index. + * + * @output: + * anum_points :: + * The number of points. + * + * anum_contours :: + * The number of contours. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * When an outline, or a sub-path, is 'closed', the stroker generates two + * independent 'border' outlines, named 'left' and 'right'. + * + * When the outline, or a sub-path, is 'opened', the stroker merges the + * 'border' outlines with caps. The 'left' border receives all points, + * while the 'right' border becomes empty. + * + * Use the function @FT_Stroker_GetCounts instead if you want to retrieve + * the counts associated to both borders. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_GetBorderCounts( FT_Stroker stroker, + FT_StrokerBorder border, + FT_UInt *anum_points, + FT_UInt *anum_contours ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_ExportBorder + * + * @description: + * Call this function after @FT_Stroker_GetBorderCounts to export the + * corresponding border to your own @FT_Outline structure. + * + * Note that this function appends the border points and contours to your + * outline, but does not try to resize its arrays. + * + * @input: + * stroker :: + * The target stroker handle. + * + * border :: + * The border index. + * + * outline :: + * The target outline handle. + * + * @note: + * Always call this function after @FT_Stroker_GetBorderCounts to get + * sure that there is enough room in your @FT_Outline object to receive + * all new data. + * + * When an outline, or a sub-path, is 'closed', the stroker generates two + * independent 'border' outlines, named 'left' and 'right'. + * + * When the outline, or a sub-path, is 'opened', the stroker merges the + * 'border' outlines with caps. The 'left' border receives all points, + * while the 'right' border becomes empty. + * + * Use the function @FT_Stroker_Export instead if you want to retrieve + * all borders at once. + */ + FT_EXPORT( void ) + FT_Stroker_ExportBorder( FT_Stroker stroker, + FT_StrokerBorder border, + FT_Outline* outline ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_GetCounts + * + * @description: + * Call this function once you have finished parsing your paths with the + * stroker. It returns the number of points and contours necessary to + * export all points/borders from the stroked outline/path. + * + * @input: + * stroker :: + * The target stroker handle. + * + * @output: + * anum_points :: + * The number of points. + * + * anum_contours :: + * The number of contours. + * + * @return: + * FreeType error code. 0~means success. + */ + FT_EXPORT( FT_Error ) + FT_Stroker_GetCounts( FT_Stroker stroker, + FT_UInt *anum_points, + FT_UInt *anum_contours ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_Export + * + * @description: + * Call this function after @FT_Stroker_GetBorderCounts to export all + * borders to your own @FT_Outline structure. + * + * Note that this function appends the border points and contours to your + * outline, but does not try to resize its arrays. + * + * @input: + * stroker :: + * The target stroker handle. + * + * outline :: + * The target outline handle. + */ + FT_EXPORT( void ) + FT_Stroker_Export( FT_Stroker stroker, + FT_Outline* outline ); + + + /************************************************************************** + * + * @function: + * FT_Stroker_Done + * + * @description: + * Destroy a stroker object. + * + * @input: + * stroker :: + * A stroker handle. Can be `NULL`. + */ + FT_EXPORT( void ) + FT_Stroker_Done( FT_Stroker stroker ); + + + /************************************************************************** + * + * @function: + * FT_Glyph_Stroke + * + * @description: + * Stroke a given outline glyph object with a given stroker. + * + * @inout: + * pglyph :: + * Source glyph handle on input, new glyph handle on output. + * + * @input: + * stroker :: + * A stroker handle. + * + * destroy :: + * A Boolean. If~1, the source glyph object is destroyed on success. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source glyph is untouched in case of error. + * + * Adding stroke may yield a significantly wider and taller glyph + * depending on how large of a radius was used to stroke the glyph. You + * may need to manually adjust horizontal and vertical advance amounts to + * account for this added size. + */ + FT_EXPORT( FT_Error ) + FT_Glyph_Stroke( FT_Glyph *pglyph, + FT_Stroker stroker, + FT_Bool destroy ); + + + /************************************************************************** + * + * @function: + * FT_Glyph_StrokeBorder + * + * @description: + * Stroke a given outline glyph object with a given stroker, but only + * return either its inside or outside border. + * + * @inout: + * pglyph :: + * Source glyph handle on input, new glyph handle on output. + * + * @input: + * stroker :: + * A stroker handle. + * + * inside :: + * A Boolean. If~1, return the inside border, otherwise the outside + * border. + * + * destroy :: + * A Boolean. If~1, the source glyph object is destroyed on success. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source glyph is untouched in case of error. + * + * Adding stroke may yield a significantly wider and taller glyph + * depending on how large of a radius was used to stroke the glyph. You + * may need to manually adjust horizontal and vertical advance amounts to + * account for this added size. + */ + FT_EXPORT( FT_Error ) + FT_Glyph_StrokeBorder( FT_Glyph *pglyph, + FT_Stroker stroker, + FT_Bool inside, + FT_Bool destroy ); + + /* */ + +FT_END_HEADER + +#endif /* FTSTROKE_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsynth.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsynth.h new file mode 100644 index 0000000000000000000000000000000000000000..21295c64e2403ff63cd2792a85f6ed99e4d1dabb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsynth.h @@ -0,0 +1,104 @@ +/**************************************************************************** + * + * ftsynth.h + * + * FreeType synthesizing code for emboldening and slanting + * (specification). + * + * Copyright (C) 2000-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /********* *********/ + /********* WARNING, THIS IS ALPHA CODE! THIS API *********/ + /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/ + /********* FREETYPE DEVELOPMENT TEAM *********/ + /********* *********/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /* Main reason for not lifting the functions in this module to a */ + /* 'standard' API is that the used parameters for emboldening and */ + /* slanting are not configurable. Consider the functions as a */ + /* code resource that should be copied into the application and */ + /* adapted to the particular needs. */ + + +#ifndef FTSYNTH_H_ +#define FTSYNTH_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /* Embolden a glyph by a 'reasonable' value (which is highly a matter of */ + /* taste). This function is actually a convenience function, providing */ + /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */ + /* */ + /* For emboldened outlines the height, width, and advance metrics are */ + /* increased by the strength of the emboldening -- this even affects */ + /* mono-width fonts! */ + /* */ + /* You can also call @FT_Outline_Get_CBox to get precise values. */ + FT_EXPORT( void ) + FT_GlyphSlot_Embolden( FT_GlyphSlot slot ); + + /* Precisely adjust the glyph weight either horizontally or vertically. */ + /* The `xdelta` and `ydelta` values are fractions of the face Em size */ + /* (in fixed-point format). Considering that a regular face would have */ + /* stem widths on the order of 0.1 Em, a delta of 0.05 (0x0CCC) should */ + /* be very noticeable. To increase or decrease the weight, use positive */ + /* or negative values, respectively. */ + FT_EXPORT( void ) + FT_GlyphSlot_AdjustWeight( FT_GlyphSlot slot, + FT_Fixed xdelta, + FT_Fixed ydelta ); + + + /* Slant an outline glyph to the right by about 12 degrees. */ + FT_EXPORT( void ) + FT_GlyphSlot_Oblique( FT_GlyphSlot slot ); + + /* Slant an outline glyph by a given sine of an angle. You can apply */ + /* slant along either x- or y-axis by choosing a corresponding non-zero */ + /* argument. If both slants are non-zero, some affine transformation */ + /* will result. */ + FT_EXPORT( void ) + FT_GlyphSlot_Slant( FT_GlyphSlot slot, + FT_Fixed xslant, + FT_Fixed yslant ); + + /* */ + + +FT_END_HEADER + +#endif /* FTSYNTH_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsystem.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsystem.h new file mode 100644 index 0000000000000000000000000000000000000000..a1cbc9ad4826da3f0cb2b1969a4d51d160a92f29 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftsystem.h @@ -0,0 +1,350 @@ +/**************************************************************************** + * + * ftsystem.h + * + * FreeType low-level system interface definition (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTSYSTEM_H_ +#define FTSYSTEM_H_ + + + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * system_interface + * + * @title: + * System Interface + * + * @abstract: + * How FreeType manages memory and i/o. + * + * @description: + * This section contains various definitions related to memory management + * and i/o access. You need to understand this information if you want to + * use a custom memory manager or you own i/o streams. + * + */ + + + /************************************************************************** + * + * M E M O R Y M A N A G E M E N T + * + */ + + + /************************************************************************** + * + * @type: + * FT_Memory + * + * @description: + * A handle to a given memory manager object, defined with an + * @FT_MemoryRec structure. + * + */ + typedef struct FT_MemoryRec_* FT_Memory; + + + /************************************************************************** + * + * @functype: + * FT_Alloc_Func + * + * @description: + * A function used to allocate `size` bytes from `memory`. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * size :: + * The size in bytes to allocate. + * + * @return: + * Address of new memory block. 0~in case of failure. + * + */ + typedef void* + (*FT_Alloc_Func)( FT_Memory memory, + long size ); + + + /************************************************************************** + * + * @functype: + * FT_Free_Func + * + * @description: + * A function used to release a given block of memory. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * block :: + * The address of the target memory block. + * + */ + typedef void + (*FT_Free_Func)( FT_Memory memory, + void* block ); + + + /************************************************************************** + * + * @functype: + * FT_Realloc_Func + * + * @description: + * A function used to re-allocate a given block of memory. + * + * @input: + * memory :: + * A handle to the source memory manager. + * + * cur_size :: + * The block's current size in bytes. + * + * new_size :: + * The block's requested new size. + * + * block :: + * The block's current address. + * + * @return: + * New block address. 0~in case of memory shortage. + * + * @note: + * In case of error, the old block must still be available. + * + */ + typedef void* + (*FT_Realloc_Func)( FT_Memory memory, + long cur_size, + long new_size, + void* block ); + + + /************************************************************************** + * + * @struct: + * FT_MemoryRec + * + * @description: + * A structure used to describe a given memory manager to FreeType~2. + * + * @fields: + * user :: + * A generic typeless pointer for user data. + * + * alloc :: + * A pointer type to an allocation function. + * + * free :: + * A pointer type to an memory freeing function. + * + * realloc :: + * A pointer type to a reallocation function. + * + */ + struct FT_MemoryRec_ + { + void* user; + FT_Alloc_Func alloc; + FT_Free_Func free; + FT_Realloc_Func realloc; + }; + + + /************************************************************************** + * + * I / O M A N A G E M E N T + * + */ + + + /************************************************************************** + * + * @type: + * FT_Stream + * + * @description: + * A handle to an input stream. + * + * @also: + * See @FT_StreamRec for the publicly accessible fields of a given stream + * object. + * + */ + typedef struct FT_StreamRec_* FT_Stream; + + + /************************************************************************** + * + * @struct: + * FT_StreamDesc + * + * @description: + * A union type used to store either a long or a pointer. This is used + * to store a file descriptor or a `FILE*` in an input stream. + * + */ + typedef union FT_StreamDesc_ + { + long value; + void* pointer; + + } FT_StreamDesc; + + + /************************************************************************** + * + * @functype: + * FT_Stream_IoFunc + * + * @description: + * A function used to seek and read data from a given input stream. + * + * @input: + * stream :: + * A handle to the source stream. + * + * offset :: + * The offset from the start of the stream to seek to. + * + * buffer :: + * The address of the read buffer. + * + * count :: + * The number of bytes to read from the stream. + * + * @return: + * If count >~0, return the number of bytes effectively read by the + * stream (after seeking to `offset`). If count ==~0, return the status + * of the seek operation (non-zero indicates an error). + * + */ + typedef unsigned long + (*FT_Stream_IoFunc)( FT_Stream stream, + unsigned long offset, + unsigned char* buffer, + unsigned long count ); + + + /************************************************************************** + * + * @functype: + * FT_Stream_CloseFunc + * + * @description: + * A function used to close a given input stream. + * + * @input: + * stream :: + * A handle to the target stream. + * + */ + typedef void + (*FT_Stream_CloseFunc)( FT_Stream stream ); + + + /************************************************************************** + * + * @struct: + * FT_StreamRec + * + * @description: + * A structure used to describe an input stream. + * + * @input: + * base :: + * For memory-based streams, this is the address of the first stream + * byte in memory. This field should always be set to `NULL` for + * disk-based streams. + * + * size :: + * The stream size in bytes. + * + * In case of compressed streams where the size is unknown before + * actually doing the decompression, the value is set to 0x7FFFFFFF. + * (Note that this size value can occur for normal streams also; it is + * thus just a hint.) + * + * pos :: + * The current position within the stream. + * + * descriptor :: + * This field is a union that can hold an integer or a pointer. It is + * used by stream implementations to store file descriptors or `FILE*` + * pointers. + * + * pathname :: + * This field is completely ignored by FreeType. However, it is often + * useful during debugging to use it to store the stream's filename + * (where available). + * + * read :: + * The stream's input function. + * + * close :: + * The stream's close function. + * + * memory :: + * The memory manager to use to preload frames. This is set internally + * by FreeType and shouldn't be touched by stream implementations. + * + * cursor :: + * This field is set and used internally by FreeType when parsing + * frames. In particular, the `FT_GET_XXX` macros use this instead of + * the `pos` field. + * + * limit :: + * This field is set and used internally by FreeType when parsing + * frames. + * + */ + typedef struct FT_StreamRec_ + { + unsigned char* base; + unsigned long size; + unsigned long pos; + + FT_StreamDesc descriptor; + FT_StreamDesc pathname; + FT_Stream_IoFunc read; + FT_Stream_CloseFunc close; + + FT_Memory memory; + unsigned char* cursor; + unsigned char* limit; + + } FT_StreamRec; + + /* */ + + +FT_END_HEADER + +#endif /* FTSYSTEM_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fttrigon.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fttrigon.h new file mode 100644 index 0000000000000000000000000000000000000000..7f9cb74a89dfa70e98a0c90788b5b58c7170d1b9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fttrigon.h @@ -0,0 +1,350 @@ +/**************************************************************************** + * + * fttrigon.h + * + * FreeType trigonometric functions (specification). + * + * Copyright (C) 2001-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTTRIGON_H_ +#define FTTRIGON_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * computations + * + */ + + + /************************************************************************** + * + * @type: + * FT_Angle + * + * @description: + * This type is used to model angle values in FreeType. Note that the + * angle is a 16.16 fixed-point value expressed in degrees. + * + */ + typedef FT_Fixed FT_Angle; + + + /************************************************************************** + * + * @macro: + * FT_ANGLE_PI + * + * @description: + * The angle pi expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_PI ( 180L << 16 ) + + + /************************************************************************** + * + * @macro: + * FT_ANGLE_2PI + * + * @description: + * The angle 2*pi expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) + + + /************************************************************************** + * + * @macro: + * FT_ANGLE_PI2 + * + * @description: + * The angle pi/2 expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) + + + /************************************************************************** + * + * @macro: + * FT_ANGLE_PI4 + * + * @description: + * The angle pi/4 expressed in @FT_Angle units. + * + */ +#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) + + + /************************************************************************** + * + * @function: + * FT_Sin + * + * @description: + * Return the sinus of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The sinus value. + * + * @note: + * If you need both the sinus and cosinus for a given angle, use the + * function @FT_Vector_Unit. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Sin( FT_Angle angle ); + + + /************************************************************************** + * + * @function: + * FT_Cos + * + * @description: + * Return the cosinus of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The cosinus value. + * + * @note: + * If you need both the sinus and cosinus for a given angle, use the + * function @FT_Vector_Unit. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Cos( FT_Angle angle ); + + + /************************************************************************** + * + * @function: + * FT_Tan + * + * @description: + * Return the tangent of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The tangent value. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Tan( FT_Angle angle ); + + + /************************************************************************** + * + * @function: + * FT_Atan2 + * + * @description: + * Return the arc-tangent corresponding to a given vector (x,y) in the 2d + * plane. + * + * @input: + * x :: + * The horizontal vector coordinate. + * + * y :: + * The vertical vector coordinate. + * + * @return: + * The arc-tangent value (i.e. angle). + * + */ + FT_EXPORT( FT_Angle ) + FT_Atan2( FT_Fixed x, + FT_Fixed y ); + + + /************************************************************************** + * + * @function: + * FT_Angle_Diff + * + * @description: + * Return the difference between two angles. The result is always + * constrained to the ]-PI..PI] interval. + * + * @input: + * angle1 :: + * First angle. + * + * angle2 :: + * Second angle. + * + * @return: + * Constrained value of `angle2-angle1`. + * + */ + FT_EXPORT( FT_Angle ) + FT_Angle_Diff( FT_Angle angle1, + FT_Angle angle2 ); + + + /************************************************************************** + * + * @function: + * FT_Vector_Unit + * + * @description: + * Return the unit vector corresponding to a given angle. After the + * call, the value of `vec.x` will be `cos(angle)`, and the value of + * `vec.y` will be `sin(angle)`. + * + * This function is useful to retrieve both the sinus and cosinus of a + * given angle quickly. + * + * @output: + * vec :: + * The address of target vector. + * + * @input: + * angle :: + * The input angle. + * + */ + FT_EXPORT( void ) + FT_Vector_Unit( FT_Vector* vec, + FT_Angle angle ); + + + /************************************************************************** + * + * @function: + * FT_Vector_Rotate + * + * @description: + * Rotate a vector by a given angle. + * + * @inout: + * vec :: + * The address of target vector. + * + * @input: + * angle :: + * The input angle. + * + */ + FT_EXPORT( void ) + FT_Vector_Rotate( FT_Vector* vec, + FT_Angle angle ); + + + /************************************************************************** + * + * @function: + * FT_Vector_Length + * + * @description: + * Return the length of a given vector. + * + * @input: + * vec :: + * The address of target vector. + * + * @return: + * The vector length, expressed in the same units that the original + * vector coordinates. + * + */ + FT_EXPORT( FT_Fixed ) + FT_Vector_Length( FT_Vector* vec ); + + + /************************************************************************** + * + * @function: + * FT_Vector_Polarize + * + * @description: + * Compute both the length and angle of a given vector. + * + * @input: + * vec :: + * The address of source vector. + * + * @output: + * length :: + * The vector length. + * + * angle :: + * The vector angle. + * + */ + FT_EXPORT( void ) + FT_Vector_Polarize( FT_Vector* vec, + FT_Fixed *length, + FT_Angle *angle ); + + + /************************************************************************** + * + * @function: + * FT_Vector_From_Polar + * + * @description: + * Compute vector coordinates from a length and angle. + * + * @output: + * vec :: + * The address of source vector. + * + * @input: + * length :: + * The vector length. + * + * angle :: + * The vector angle. + * + */ + FT_EXPORT( void ) + FT_Vector_From_Polar( FT_Vector* vec, + FT_Fixed length, + FT_Angle angle ); + + /* */ + + +FT_END_HEADER + +#endif /* FTTRIGON_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fttypes.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fttypes.h new file mode 100644 index 0000000000000000000000000000000000000000..f428f482a3748aa78680ab59350e6e10745994b1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/fttypes.h @@ -0,0 +1,617 @@ +/**************************************************************************** + * + * fttypes.h + * + * FreeType simple types definitions (specification only). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTTYPES_H_ +#define FTTYPES_H_ + + +#include +#include FT_CONFIG_CONFIG_H +#include +#include + +#include + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * basic_types + * + * @title: + * Basic Data Types + * + * @abstract: + * The basic data types defined by the library. + * + * @description: + * This section contains the basic data types defined by FreeType~2, + * ranging from simple scalar types to bitmap descriptors. More + * font-specific structures are defined in a different section. Note + * that FreeType does not use floating-point data types. Fractional + * values are represented by fixed-point integers, with lower bits + * storing the fractional part. + * + * @order: + * FT_Byte + * FT_Bytes + * FT_Char + * FT_Int + * FT_UInt + * FT_Int16 + * FT_UInt16 + * FT_Int32 + * FT_UInt32 + * FT_Int64 + * FT_UInt64 + * FT_Short + * FT_UShort + * FT_Long + * FT_ULong + * FT_Bool + * FT_Offset + * FT_PtrDist + * FT_String + * FT_Tag + * FT_Error + * FT_Fixed + * FT_Pointer + * FT_Pos + * FT_Vector + * FT_BBox + * FT_Matrix + * FT_FWord + * FT_UFWord + * FT_F2Dot14 + * FT_UnitVector + * FT_F26Dot6 + * FT_Data + * + * FT_MAKE_TAG + * + * FT_Generic + * FT_Generic_Finalizer + * + * FT_Bitmap + * FT_Pixel_Mode + * FT_Palette_Mode + * FT_Glyph_Format + * FT_IMAGE_TAG + * + */ + + + /************************************************************************** + * + * @type: + * FT_Bool + * + * @description: + * A typedef of unsigned char, used for simple booleans. As usual, + * values 1 and~0 represent true and false, respectively. + */ + typedef unsigned char FT_Bool; + + + /************************************************************************** + * + * @type: + * FT_FWord + * + * @description: + * A signed 16-bit integer used to store a distance in original font + * units. + */ + typedef signed short FT_FWord; /* distance in FUnits */ + + + /************************************************************************** + * + * @type: + * FT_UFWord + * + * @description: + * An unsigned 16-bit integer used to store a distance in original font + * units. + */ + typedef unsigned short FT_UFWord; /* unsigned distance */ + + + /************************************************************************** + * + * @type: + * FT_Char + * + * @description: + * A simple typedef for the _signed_ char type. + */ + typedef signed char FT_Char; + + + /************************************************************************** + * + * @type: + * FT_Byte + * + * @description: + * A simple typedef for the _unsigned_ char type. + */ + typedef unsigned char FT_Byte; + + + /************************************************************************** + * + * @type: + * FT_Bytes + * + * @description: + * A typedef for constant memory areas. + */ + typedef const FT_Byte* FT_Bytes; + + + /************************************************************************** + * + * @type: + * FT_Tag + * + * @description: + * A typedef for 32-bit tags (as used in the SFNT format). + */ + typedef FT_UInt32 FT_Tag; + + + /************************************************************************** + * + * @type: + * FT_String + * + * @description: + * A simple typedef for the char type, usually used for strings. + */ + typedef char FT_String; + + + /************************************************************************** + * + * @type: + * FT_Short + * + * @description: + * A typedef for signed short. + */ + typedef signed short FT_Short; + + + /************************************************************************** + * + * @type: + * FT_UShort + * + * @description: + * A typedef for unsigned short. + */ + typedef unsigned short FT_UShort; + + + /************************************************************************** + * + * @type: + * FT_Int + * + * @description: + * A typedef for the int type. + */ + typedef signed int FT_Int; + + + /************************************************************************** + * + * @type: + * FT_UInt + * + * @description: + * A typedef for the unsigned int type. + */ + typedef unsigned int FT_UInt; + + + /************************************************************************** + * + * @type: + * FT_Long + * + * @description: + * A typedef for signed long. + */ + typedef signed long FT_Long; + + + /************************************************************************** + * + * @type: + * FT_ULong + * + * @description: + * A typedef for unsigned long. + */ + typedef unsigned long FT_ULong; + + + /************************************************************************** + * + * @type: + * FT_F2Dot14 + * + * @description: + * A signed 2.14 fixed-point type used for unit vectors. + */ + typedef signed short FT_F2Dot14; + + + /************************************************************************** + * + * @type: + * FT_F26Dot6 + * + * @description: + * A signed 26.6 fixed-point type used for vectorial pixel coordinates. + */ + typedef signed long FT_F26Dot6; + + + /************************************************************************** + * + * @type: + * FT_Fixed + * + * @description: + * This type is used to store 16.16 fixed-point values, like scaling + * values or matrix coefficients. + */ + typedef signed long FT_Fixed; + + + /************************************************************************** + * + * @type: + * FT_Error + * + * @description: + * The FreeType error code type. A value of~0 is always interpreted as a + * successful operation. + */ + typedef int FT_Error; + + + /************************************************************************** + * + * @type: + * FT_Pointer + * + * @description: + * A simple typedef for a typeless pointer. + */ + typedef void* FT_Pointer; + + + /************************************************************************** + * + * @type: + * FT_Offset + * + * @description: + * This is equivalent to the ANSI~C `size_t` type, i.e., the largest + * _unsigned_ integer type used to express a file size or position, or a + * memory block size. + */ + typedef size_t FT_Offset; + + + /************************************************************************** + * + * @type: + * FT_PtrDist + * + * @description: + * This is equivalent to the ANSI~C `ptrdiff_t` type, i.e., the largest + * _signed_ integer type used to express the distance between two + * pointers. + */ + typedef ft_ptrdiff_t FT_PtrDist; + + + /************************************************************************** + * + * @struct: + * FT_UnitVector + * + * @description: + * A simple structure used to store a 2D vector unit vector. Uses + * FT_F2Dot14 types. + * + * @fields: + * x :: + * Horizontal coordinate. + * + * y :: + * Vertical coordinate. + */ + typedef struct FT_UnitVector_ + { + FT_F2Dot14 x; + FT_F2Dot14 y; + + } FT_UnitVector; + + + /************************************************************************** + * + * @struct: + * FT_Matrix + * + * @description: + * A simple structure used to store a 2x2 matrix. Coefficients are in + * 16.16 fixed-point format. The computation performed is: + * + * ``` + * x' = x*xx + y*xy + * y' = x*yx + y*yy + * ``` + * + * @fields: + * xx :: + * Matrix coefficient. + * + * xy :: + * Matrix coefficient. + * + * yx :: + * Matrix coefficient. + * + * yy :: + * Matrix coefficient. + */ + typedef struct FT_Matrix_ + { + FT_Fixed xx, xy; + FT_Fixed yx, yy; + + } FT_Matrix; + + + /************************************************************************** + * + * @struct: + * FT_Data + * + * @description: + * Read-only binary data represented as a pointer and a length. + * + * @fields: + * pointer :: + * The data. + * + * length :: + * The length of the data in bytes. + */ + typedef struct FT_Data_ + { + const FT_Byte* pointer; + FT_UInt length; + + } FT_Data; + + + /************************************************************************** + * + * @functype: + * FT_Generic_Finalizer + * + * @description: + * Describe a function used to destroy the 'client' data of any FreeType + * object. See the description of the @FT_Generic type for details of + * usage. + * + * @input: + * The address of the FreeType object that is under finalization. Its + * client data is accessed through its `generic` field. + */ + typedef void (*FT_Generic_Finalizer)( void* object ); + + + /************************************************************************** + * + * @struct: + * FT_Generic + * + * @description: + * Client applications often need to associate their own data to a + * variety of FreeType core objects. For example, a text layout API + * might want to associate a glyph cache to a given size object. + * + * Some FreeType object contains a `generic` field, of type `FT_Generic`, + * which usage is left to client applications and font servers. + * + * It can be used to store a pointer to client-specific data, as well as + * the address of a 'finalizer' function, which will be called by + * FreeType when the object is destroyed (for example, the previous + * client example would put the address of the glyph cache destructor in + * the `finalizer` field). + * + * @fields: + * data :: + * A typeless pointer to any client-specified data. This field is + * completely ignored by the FreeType library. + * + * finalizer :: + * A pointer to a 'generic finalizer' function, which will be called + * when the object is destroyed. If this field is set to `NULL`, no + * code will be called. + */ + typedef struct FT_Generic_ + { + void* data; + FT_Generic_Finalizer finalizer; + + } FT_Generic; + + + /************************************************************************** + * + * @macro: + * FT_MAKE_TAG + * + * @description: + * This macro converts four-letter tags that are used to label TrueType + * tables into an `FT_Tag` type, to be used within FreeType. + * + * @note: + * The produced values **must** be 32-bit integers. Don't redefine this + * macro. + */ +#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ + ( ( FT_STATIC_BYTE_CAST( FT_Tag, _x1 ) << 24 ) | \ + ( FT_STATIC_BYTE_CAST( FT_Tag, _x2 ) << 16 ) | \ + ( FT_STATIC_BYTE_CAST( FT_Tag, _x3 ) << 8 ) | \ + FT_STATIC_BYTE_CAST( FT_Tag, _x4 ) ) + + + /*************************************************************************/ + /*************************************************************************/ + /* */ + /* L I S T M A N A G E M E N T */ + /* */ + /*************************************************************************/ + /*************************************************************************/ + + + /************************************************************************** + * + * @section: + * list_processing + * + */ + + + /************************************************************************** + * + * @type: + * FT_ListNode + * + * @description: + * Many elements and objects in FreeType are listed through an @FT_List + * record (see @FT_ListRec). As its name suggests, an FT_ListNode is a + * handle to a single list element. + */ + typedef struct FT_ListNodeRec_* FT_ListNode; + + + /************************************************************************** + * + * @type: + * FT_List + * + * @description: + * A handle to a list record (see @FT_ListRec). + */ + typedef struct FT_ListRec_* FT_List; + + + /************************************************************************** + * + * @struct: + * FT_ListNodeRec + * + * @description: + * A structure used to hold a single list element. + * + * @fields: + * prev :: + * The previous element in the list. `NULL` if first. + * + * next :: + * The next element in the list. `NULL` if last. + * + * data :: + * A typeless pointer to the listed object. + */ + typedef struct FT_ListNodeRec_ + { + FT_ListNode prev; + FT_ListNode next; + void* data; + + } FT_ListNodeRec; + + + /************************************************************************** + * + * @struct: + * FT_ListRec + * + * @description: + * A structure used to hold a simple doubly-linked list. These are used + * in many parts of FreeType. + * + * @fields: + * head :: + * The head (first element) of doubly-linked list. + * + * tail :: + * The tail (last element) of doubly-linked list. + */ + typedef struct FT_ListRec_ + { + FT_ListNode head; + FT_ListNode tail; + + } FT_ListRec; + + /* */ + + +#define FT_IS_EMPTY( list ) ( (list).head == 0 ) +#define FT_BOOL( x ) FT_STATIC_CAST( FT_Bool, (x) != 0 ) + + /* concatenate C tokens */ +#define FT_ERR_XCAT( x, y ) x ## y +#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) + + /* see `ftmoderr.h` for descriptions of the following macros */ + +#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) + +#define FT_ERROR_BASE( x ) ( (x) & 0xFF ) +#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U ) + +#define FT_ERR_EQ( x, e ) \ + ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) ) +#define FT_ERR_NEQ( x, e ) \ + ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) ) + + +FT_END_HEADER + +#endif /* FTTYPES_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftwinfnt.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftwinfnt.h new file mode 100644 index 0000000000000000000000000000000000000000..25f2bbcfd241ac7490837d804264196198fa3af9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ftwinfnt.h @@ -0,0 +1,276 @@ +/**************************************************************************** + * + * ftwinfnt.h + * + * FreeType API for accessing Windows fnt-specific data. + * + * Copyright (C) 2003-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTWINFNT_H_ +#define FTWINFNT_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * winfnt_fonts + * + * @title: + * Window FNT Files + * + * @abstract: + * Windows FNT-specific API. + * + * @description: + * This section contains the declaration of Windows FNT-specific + * functions. + * + */ + + + /************************************************************************** + * + * @enum: + * FT_WinFNT_ID_XXX + * + * @description: + * A list of valid values for the `charset` byte in @FT_WinFNT_HeaderRec. + * Exact mapping tables for the various 'cpXXXX' encodings (except for + * 'cp1361') can be found at 'ftp://ftp.unicode.org/Public/' in the + * `MAPPINGS/VENDORS/MICSFT/WINDOWS` subdirectory. 'cp1361' is roughly a + * superset of `MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT`. + * + * @values: + * FT_WinFNT_ID_DEFAULT :: + * This is used for font enumeration and font creation as a 'don't + * care' value. Valid font files don't contain this value. When + * querying for information about the character set of the font that is + * currently selected into a specified device context, this return + * value (of the related Windows API) simply denotes failure. + * + * FT_WinFNT_ID_SYMBOL :: + * There is no known mapping table available. + * + * FT_WinFNT_ID_MAC :: + * Mac Roman encoding. + * + * FT_WinFNT_ID_OEM :: + * From Michael Poettgen : + * + * The 'Windows Font Mapping' article says that `FT_WinFNT_ID_OEM` is + * used for the charset of vector fonts, like `modern.fon`, + * `roman.fon`, and `script.fon` on Windows. + * + * The 'CreateFont' documentation says: The `FT_WinFNT_ID_OEM` value + * specifies a character set that is operating-system dependent. + * + * The 'IFIMETRICS' documentation from the 'Windows Driver Development + * Kit' says: This font supports an OEM-specific character set. The + * OEM character set is system dependent. + * + * In general OEM, as opposed to ANSI (i.e., 'cp1252'), denotes the + * second default codepage that most international versions of Windows + * have. It is one of the OEM codepages from + * + * https://docs.microsoft.com/en-us/windows/desktop/intl/code-page-identifiers + * , + * + * and is used for the 'DOS boxes', to support legacy applications. A + * German Windows version for example usually uses ANSI codepage 1252 + * and OEM codepage 850. + * + * FT_WinFNT_ID_CP874 :: + * A superset of Thai TIS 620 and ISO 8859-11. + * + * FT_WinFNT_ID_CP932 :: + * A superset of Japanese Shift-JIS (with minor deviations). + * + * FT_WinFNT_ID_CP936 :: + * A superset of simplified Chinese GB 2312-1980 (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP949 :: + * A superset of Korean Hangul KS~C 5601-1987 (with different ordering + * and minor deviations). + * + * FT_WinFNT_ID_CP950 :: + * A superset of traditional Chinese Big~5 ETen (with different + * ordering and minor deviations). + * + * FT_WinFNT_ID_CP1250 :: + * A superset of East European ISO 8859-2 (with slightly different + * ordering). + * + * FT_WinFNT_ID_CP1251 :: + * A superset of Russian ISO 8859-5 (with different ordering). + * + * FT_WinFNT_ID_CP1252 :: + * ANSI encoding. A superset of ISO 8859-1. + * + * FT_WinFNT_ID_CP1253 :: + * A superset of Greek ISO 8859-7 (with minor modifications). + * + * FT_WinFNT_ID_CP1254 :: + * A superset of Turkish ISO 8859-9. + * + * FT_WinFNT_ID_CP1255 :: + * A superset of Hebrew ISO 8859-8 (with some modifications). + * + * FT_WinFNT_ID_CP1256 :: + * A superset of Arabic ISO 8859-6 (with different ordering). + * + * FT_WinFNT_ID_CP1257 :: + * A superset of Baltic ISO 8859-13 (with some deviations). + * + * FT_WinFNT_ID_CP1258 :: + * For Vietnamese. This encoding doesn't cover all necessary + * characters. + * + * FT_WinFNT_ID_CP1361 :: + * Korean (Johab). + */ + +#define FT_WinFNT_ID_CP1252 0 +#define FT_WinFNT_ID_DEFAULT 1 +#define FT_WinFNT_ID_SYMBOL 2 +#define FT_WinFNT_ID_MAC 77 +#define FT_WinFNT_ID_CP932 128 +#define FT_WinFNT_ID_CP949 129 +#define FT_WinFNT_ID_CP1361 130 +#define FT_WinFNT_ID_CP936 134 +#define FT_WinFNT_ID_CP950 136 +#define FT_WinFNT_ID_CP1253 161 +#define FT_WinFNT_ID_CP1254 162 +#define FT_WinFNT_ID_CP1258 163 +#define FT_WinFNT_ID_CP1255 177 +#define FT_WinFNT_ID_CP1256 178 +#define FT_WinFNT_ID_CP1257 186 +#define FT_WinFNT_ID_CP1251 204 +#define FT_WinFNT_ID_CP874 222 +#define FT_WinFNT_ID_CP1250 238 +#define FT_WinFNT_ID_OEM 255 + + + /************************************************************************** + * + * @struct: + * FT_WinFNT_HeaderRec + * + * @description: + * Windows FNT Header info. + */ + typedef struct FT_WinFNT_HeaderRec_ + { + FT_UShort version; + FT_ULong file_size; + FT_Byte copyright[60]; + FT_UShort file_type; + FT_UShort nominal_point_size; + FT_UShort vertical_resolution; + FT_UShort horizontal_resolution; + FT_UShort ascent; + FT_UShort internal_leading; + FT_UShort external_leading; + FT_Byte italic; + FT_Byte underline; + FT_Byte strike_out; + FT_UShort weight; + FT_Byte charset; + FT_UShort pixel_width; + FT_UShort pixel_height; + FT_Byte pitch_and_family; + FT_UShort avg_width; + FT_UShort max_width; + FT_Byte first_char; + FT_Byte last_char; + FT_Byte default_char; + FT_Byte break_char; + FT_UShort bytes_per_row; + FT_ULong device_offset; + FT_ULong face_name_offset; + FT_ULong bits_pointer; + FT_ULong bits_offset; + FT_Byte reserved; + FT_ULong flags; + FT_UShort A_space; + FT_UShort B_space; + FT_UShort C_space; + FT_UShort color_table_offset; + FT_ULong reserved1[4]; + + } FT_WinFNT_HeaderRec; + + + /************************************************************************** + * + * @struct: + * FT_WinFNT_Header + * + * @description: + * A handle to an @FT_WinFNT_HeaderRec structure. + */ + typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header; + + + /************************************************************************** + * + * @function: + * FT_Get_WinFNT_Header + * + * @description: + * Retrieve a Windows FNT font info header. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * aheader :: + * The WinFNT header. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with Windows FNT faces, returning an error + * otherwise. + */ + FT_EXPORT( FT_Error ) + FT_Get_WinFNT_Header( FT_Face face, + FT_WinFNT_HeaderRec *aheader ); + + /* */ + + +FT_END_HEADER + +#endif /* FTWINFNT_H_ */ + + +/* END */ + + +/* Local Variables: */ +/* coding: utf-8 */ +/* End: */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/autohint.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/autohint.h new file mode 100644 index 0000000000000000000000000000000000000000..066a0f4a90bea6f5049487d20380a0937a798075 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/autohint.h @@ -0,0 +1,234 @@ +/**************************************************************************** + * + * autohint.h + * + * High-level 'autohint' module-specific interface (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * The auto-hinter is used to load and automatically hint glyphs if a + * format-specific hinter isn't available. + * + */ + + +#ifndef AUTOHINT_H_ +#define AUTOHINT_H_ + + + /************************************************************************** + * + * A small technical note regarding automatic hinting in order to clarify + * this module interface. + * + * An automatic hinter might compute two kinds of data for a given face: + * + * - global hints: Usually some metrics that describe global properties + * of the face. It is computed by scanning more or less + * aggressively the glyphs in the face, and thus can be + * very slow to compute (even if the size of global hints + * is really small). + * + * - glyph hints: These describe some important features of the glyph + * outline, as well as how to align them. They are + * generally much faster to compute than global hints. + * + * The current FreeType auto-hinter does a pretty good job while performing + * fast computations for both global and glyph hints. However, we might be + * interested in introducing more complex and powerful algorithms in the + * future, like the one described in the John D. Hobby paper, which + * unfortunately requires a lot more horsepower. + * + * Because a sufficiently sophisticated font management system would + * typically implement an LRU cache of opened face objects to reduce memory + * usage, it is a good idea to be able to avoid recomputing global hints + * every time the same face is re-opened. + * + * We thus provide the ability to cache global hints outside of the face + * object, in order to speed up font re-opening time. Of course, this + * feature is purely optional, so most client programs won't even notice + * it. + * + * I initially thought that it would be a good idea to cache the glyph + * hints too. However, my general idea now is that if you really need to + * cache these too, you are simply in need of a new font format, where all + * this information could be stored within the font file and decoded on the + * fly. + * + */ + + +#include + + +FT_BEGIN_HEADER + + + typedef struct FT_AutoHinterRec_ *FT_AutoHinter; + + + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlobalGetFunc + * + * @description: + * Retrieve the global hints computed for a given face object. The + * resulting data is dissociated from the face and will survive a call to + * FT_Done_Face(). It must be discarded through the API + * FT_AutoHinter_GlobalDoneFunc(). + * + * @input: + * hinter :: + * A handle to the source auto-hinter. + * + * face :: + * A handle to the source face object. + * + * @output: + * global_hints :: + * A typeless pointer to the global hints. + * + * global_len :: + * The size in bytes of the global hints. + */ + typedef void + (*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter hinter, + FT_Face face, + void** global_hints, + long* global_len ); + + + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlobalDoneFunc + * + * @description: + * Discard the global hints retrieved through + * FT_AutoHinter_GlobalGetFunc(). This is the only way these hints are + * freed from memory. + * + * @input: + * hinter :: + * A handle to the auto-hinter module. + * + * global :: + * A pointer to retrieved global hints to discard. + */ + typedef void + (*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter hinter, + void* global ); + + + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlobalResetFunc + * + * @description: + * This function is used to recompute the global metrics in a given font. + * This is useful when global font data changes (e.g. Multiple Masters + * fonts where blend coordinates change). + * + * @input: + * hinter :: + * A handle to the source auto-hinter. + * + * face :: + * A handle to the face. + */ + typedef void + (*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter hinter, + FT_Face face ); + + + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlyphLoadFunc + * + * @description: + * This function is used to load, scale, and automatically hint a glyph + * from a given face. + * + * @input: + * face :: + * A handle to the face. + * + * glyph_index :: + * The glyph index. + * + * load_flags :: + * The load flags. + * + * @note: + * This function is capable of loading composite glyphs by hinting each + * sub-glyph independently (which improves quality). + * + * It will call the font driver with @FT_Load_Glyph, with + * @FT_LOAD_NO_SCALE set. + */ + typedef FT_Error + (*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter hinter, + FT_GlyphSlot slot, + FT_Size size, + FT_UInt glyph_index, + FT_Int32 load_flags ); + + + /************************************************************************** + * + * @struct: + * FT_AutoHinter_InterfaceRec + * + * @description: + * The auto-hinter module's interface. + */ + typedef struct FT_AutoHinter_InterfaceRec_ + { + FT_AutoHinter_GlobalResetFunc reset_face; + FT_AutoHinter_GlobalGetFunc get_global_hints; + FT_AutoHinter_GlobalDoneFunc done_global_hints; + FT_AutoHinter_GlyphLoadFunc load_glyph; + + } FT_AutoHinter_InterfaceRec, *FT_AutoHinter_Interface; + + +#define FT_DECLARE_AUTOHINTER_INTERFACE( class_ ) \ + FT_CALLBACK_TABLE const FT_AutoHinter_InterfaceRec class_; + +#define FT_DEFINE_AUTOHINTER_INTERFACE( \ + class_, \ + reset_face_, \ + get_global_hints_, \ + done_global_hints_, \ + load_glyph_ ) \ + FT_CALLBACK_TABLE_DEF \ + const FT_AutoHinter_InterfaceRec class_ = \ + { \ + reset_face_, \ + get_global_hints_, \ + done_global_hints_, \ + load_glyph_ \ + }; + + +FT_END_HEADER + +#endif /* AUTOHINT_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/cffotypes.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/cffotypes.h new file mode 100644 index 0000000000000000000000000000000000000000..053b8a3c9010225915e045eade318093da956cce --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/cffotypes.h @@ -0,0 +1,107 @@ +/**************************************************************************** + * + * cffotypes.h + * + * Basic OpenType/CFF object type definitions (specification). + * + * Copyright (C) 2017-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef CFFOTYPES_H_ +#define CFFOTYPES_H_ + +#include +#include +#include +#include +#include + + +FT_BEGIN_HEADER + + + typedef TT_Face CFF_Face; + + + /************************************************************************** + * + * @type: + * CFF_Size + * + * @description: + * A handle to an OpenType size object. + */ + typedef struct CFF_SizeRec_ + { + FT_SizeRec root; + FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */ + + } CFF_SizeRec, *CFF_Size; + + + /************************************************************************** + * + * @type: + * CFF_GlyphSlot + * + * @description: + * A handle to an OpenType glyph slot object. + */ + typedef struct CFF_GlyphSlotRec_ + { + FT_GlyphSlotRec root; + + FT_Bool hint; + FT_Bool scaled; + + FT_Fixed x_scale; + FT_Fixed y_scale; + + } CFF_GlyphSlotRec, *CFF_GlyphSlot; + + + /************************************************************************** + * + * @type: + * CFF_Internal + * + * @description: + * The interface to the 'internal' field of `FT_Size`. + */ + typedef struct CFF_InternalRec_ + { + PSH_Globals topfont; + PSH_Globals subfonts[CFF_MAX_CID_FONTS]; + + } CFF_InternalRec, *CFF_Internal; + + + /************************************************************************** + * + * Subglyph transformation record. + */ + typedef struct CFF_Transform_ + { + FT_Fixed xx, xy; /* transformation matrix coefficients */ + FT_Fixed yx, yy; + FT_F26Dot6 ox, oy; /* offsets */ + + } CFF_Transform; + + +FT_END_HEADER + + +#endif /* CFFOTYPES_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/cfftypes.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/cfftypes.h new file mode 100644 index 0000000000000000000000000000000000000000..19e9eca1a024dae023b0a2eceefa455837b97f20 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/cfftypes.h @@ -0,0 +1,416 @@ +/**************************************************************************** + * + * cfftypes.h + * + * Basic OpenType/CFF type definitions and interface (specification + * only). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef CFFTYPES_H_ +#define CFFTYPES_H_ + + +#include +#include +#include +#include +#include +#include + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @struct: + * CFF_IndexRec + * + * @description: + * A structure used to model a CFF Index table. + * + * @fields: + * stream :: + * The source input stream. + * + * start :: + * The position of the first index byte in the input stream. + * + * count :: + * The number of elements in the index. + * + * off_size :: + * The size in bytes of object offsets in index. + * + * data_offset :: + * The position of first data byte in the index's bytes. + * + * data_size :: + * The size of the data table in this index. + * + * offsets :: + * A table of element offsets in the index. Must be loaded explicitly. + * + * bytes :: + * If the index is loaded in memory, its bytes. + */ + typedef struct CFF_IndexRec_ + { + FT_Stream stream; + FT_ULong start; + FT_UInt hdr_size; + FT_UInt count; + FT_Byte off_size; + FT_ULong data_offset; + FT_ULong data_size; + + FT_ULong* offsets; + FT_Byte* bytes; + + } CFF_IndexRec, *CFF_Index; + + + typedef struct CFF_EncodingRec_ + { + FT_UInt format; + FT_ULong offset; + + FT_UInt count; + FT_UShort sids [256]; /* avoid dynamic allocations */ + FT_UShort codes[256]; + + } CFF_EncodingRec, *CFF_Encoding; + + + typedef struct CFF_CharsetRec_ + { + + FT_UInt format; + FT_ULong offset; + + FT_UShort* sids; + FT_UShort* cids; /* the inverse mapping of `sids'; only needed */ + /* for CID-keyed fonts */ + FT_UInt max_cid; + FT_UInt num_glyphs; + + } CFF_CharsetRec, *CFF_Charset; + + + /* cf. similar fields in file `ttgxvar.h' from the `truetype' module */ + + typedef struct CFF_VarData_ + { +#if 0 + FT_UInt itemCount; /* not used; always zero */ + FT_UInt shortDeltaCount; /* not used; always zero */ +#endif + + FT_UInt regionIdxCount; /* number of region indexes */ + FT_UInt* regionIndices; /* array of `regionIdxCount' indices; */ + /* these index `varRegionList' */ + } CFF_VarData; + + + /* contribution of one axis to a region */ + typedef struct CFF_AxisCoords_ + { + FT_Fixed startCoord; + FT_Fixed peakCoord; /* zero peak means no effect (factor = 1) */ + FT_Fixed endCoord; + + } CFF_AxisCoords; + + + typedef struct CFF_VarRegion_ + { + CFF_AxisCoords* axisList; /* array of axisCount records */ + + } CFF_VarRegion; + + + typedef struct CFF_VStoreRec_ + { + FT_UInt dataCount; + CFF_VarData* varData; /* array of dataCount records */ + /* vsindex indexes this array */ + FT_UShort axisCount; + FT_UInt regionCount; /* total number of regions defined */ + CFF_VarRegion* varRegionList; + + } CFF_VStoreRec, *CFF_VStore; + + + /* forward reference */ + typedef struct CFF_FontRec_* CFF_Font; + + + /* This object manages one cached blend vector. */ + /* */ + /* There is a BlendRec for Private DICT parsing in each subfont */ + /* and a BlendRec for charstrings in CF2_Font instance data. */ + /* A cached BV may be used across DICTs or Charstrings if inputs */ + /* have not changed. */ + /* */ + /* `usedBV' is reset at the start of each parse or charstring. */ + /* vsindex cannot be changed after a BV is used. */ + /* */ + /* Note: NDV is long (32/64 bit), while BV is 16.16 (FT_Int32). */ + typedef struct CFF_BlendRec_ + { + FT_Bool builtBV; /* blendV has been built */ + FT_Bool usedBV; /* blendV has been used */ + CFF_Font font; /* top level font struct */ + FT_UInt lastVsindex; /* last vsindex used */ + FT_UInt lenNDV; /* normDV length (aka numAxes) */ + FT_Fixed* lastNDV; /* last NDV used */ + FT_UInt lenBV; /* BlendV length (aka numMasters) */ + FT_Int32* BV; /* current blendV (per DICT/glyph) */ + + } CFF_BlendRec, *CFF_Blend; + + + typedef struct CFF_FontRecDictRec_ + { + FT_UInt version; + FT_UInt notice; + FT_UInt copyright; + FT_UInt full_name; + FT_UInt family_name; + FT_UInt weight; + FT_Bool is_fixed_pitch; + FT_Fixed italic_angle; + FT_Fixed underline_position; + FT_Fixed underline_thickness; + FT_Int paint_type; + FT_Int charstring_type; + FT_Matrix font_matrix; + FT_Bool has_font_matrix; + FT_ULong units_per_em; /* temporarily used as scaling value also */ + FT_Vector font_offset; + FT_ULong unique_id; + FT_BBox font_bbox; + FT_Pos stroke_width; + FT_ULong charset_offset; + FT_ULong encoding_offset; + FT_ULong charstrings_offset; + FT_ULong private_offset; + FT_ULong private_size; + FT_Long synthetic_base; + FT_UInt embedded_postscript; + + /* these should only be used for the top-level font dictionary */ + FT_UInt cid_registry; + FT_UInt cid_ordering; + FT_Long cid_supplement; + + FT_Long cid_font_version; + FT_Long cid_font_revision; + FT_Long cid_font_type; + FT_ULong cid_count; + FT_ULong cid_uid_base; + FT_ULong cid_fd_array_offset; + FT_ULong cid_fd_select_offset; + FT_UInt cid_font_name; + + /* the next fields come from the data of the deprecated */ + /* `MultipleMaster' operator; they are needed to parse the (also */ + /* deprecated) `blend' operator in Type 2 charstrings */ + FT_UShort num_designs; + FT_UShort num_axes; + + /* fields for CFF2 */ + FT_ULong vstore_offset; + FT_UInt maxstack; + + } CFF_FontRecDictRec, *CFF_FontRecDict; + + + /* forward reference */ + typedef struct CFF_SubFontRec_* CFF_SubFont; + + + typedef struct CFF_PrivateRec_ + { + FT_Byte num_blue_values; + FT_Byte num_other_blues; + FT_Byte num_family_blues; + FT_Byte num_family_other_blues; + + FT_Fixed blue_values[14]; + FT_Fixed other_blues[10]; + FT_Fixed family_blues[14]; + FT_Fixed family_other_blues[10]; + + FT_Fixed blue_scale; + FT_Pos blue_shift; + FT_Pos blue_fuzz; + FT_Pos standard_width; + FT_Pos standard_height; + + FT_Byte num_snap_widths; + FT_Byte num_snap_heights; + FT_Pos snap_widths[13]; + FT_Pos snap_heights[13]; + FT_Bool force_bold; + FT_Fixed force_bold_threshold; + FT_Int lenIV; + FT_Int language_group; + FT_Fixed expansion_factor; + FT_Long initial_random_seed; + FT_ULong local_subrs_offset; + FT_Pos default_width; + FT_Pos nominal_width; + + /* fields for CFF2 */ + FT_UInt vsindex; + CFF_SubFont subfont; + + } CFF_PrivateRec, *CFF_Private; + + + typedef struct CFF_FDSelectRec_ + { + FT_Byte format; + FT_UInt range_count; + + /* that's the table, taken from the file `as is' */ + FT_Byte* data; + FT_UInt data_size; + + /* small cache for format 3 only */ + FT_UInt cache_first; + FT_UInt cache_count; + FT_Byte cache_fd; + + } CFF_FDSelectRec, *CFF_FDSelect; + + + /* A SubFont packs a font dict and a private dict together. They are */ + /* needed to support CID-keyed CFF fonts. */ + typedef struct CFF_SubFontRec_ + { + CFF_FontRecDictRec font_dict; + CFF_PrivateRec private_dict; + + /* fields for CFF2 */ + CFF_BlendRec blend; /* current blend vector */ + FT_UInt lenNDV; /* current length NDV or zero */ + FT_Fixed* NDV; /* ptr to current NDV or NULL */ + + /* `blend_stack' is a writable buffer to hold blend results. */ + /* This buffer is to the side of the normal cff parser stack; */ + /* `cff_parse_blend' and `cff_blend_doBlend' push blend results here. */ + /* The normal stack then points to these values instead of the DICT */ + /* because all other operators in Private DICT clear the stack. */ + /* `blend_stack' could be cleared at each operator other than blend. */ + /* Blended values are stored as 5-byte fixed-point values. */ + + FT_Byte* blend_stack; /* base of stack allocation */ + FT_Byte* blend_top; /* first empty slot */ + FT_UInt blend_used; /* number of bytes in use */ + FT_UInt blend_alloc; /* number of bytes allocated */ + + CFF_IndexRec local_subrs_index; + FT_Byte** local_subrs; /* array of pointers */ + /* into Local Subrs INDEX data */ + + FT_UInt32 random; + + } CFF_SubFontRec; + + +#define CFF_MAX_CID_FONTS 256 + + + typedef struct CFF_FontRec_ + { + FT_Library library; + FT_Stream stream; + FT_Memory memory; /* TODO: take this from stream->memory? */ + FT_ULong base_offset; /* offset to start of CFF */ + FT_UInt num_faces; + FT_UInt num_glyphs; + + FT_Byte version_major; + FT_Byte version_minor; + FT_Byte header_size; + + FT_UInt top_dict_length; /* cff2 only */ + + FT_Bool cff2; + + CFF_IndexRec name_index; + CFF_IndexRec top_dict_index; + CFF_IndexRec global_subrs_index; + + CFF_EncodingRec encoding; + CFF_CharsetRec charset; + + CFF_IndexRec charstrings_index; + CFF_IndexRec font_dict_index; + CFF_IndexRec private_index; + CFF_IndexRec local_subrs_index; + + FT_String* font_name; + + /* array of pointers into Global Subrs INDEX data */ + FT_Byte** global_subrs; + + /* array of pointers into String INDEX data stored at string_pool */ + FT_UInt num_strings; + FT_Byte** strings; + FT_Byte* string_pool; + FT_ULong string_pool_size; + + CFF_SubFontRec top_font; + FT_UInt num_subfonts; + CFF_SubFont subfonts[CFF_MAX_CID_FONTS]; + + CFF_FDSelectRec fd_select; + + /* interface to PostScript hinter */ + PSHinter_Service pshinter; + + /* interface to Postscript Names service */ + FT_Service_PsCMaps psnames; + + /* interface to CFFLoad service */ + const void* cffload; + + /* since version 2.3.0 */ + PS_FontInfoRec* font_info; /* font info dictionary */ + + /* since version 2.3.6 */ + FT_String* registry; + FT_String* ordering; + + /* since version 2.4.12 */ + FT_Generic cf2_instance; + + /* since version 2.7.1 */ + CFF_VStoreRec vstore; /* parsed vstore structure */ + + /* since version 2.9 */ + PS_FontExtraRec* font_extra; + + } CFF_FontRec; + + +FT_END_HEADER + +#endif /* CFFTYPES_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/compiler-macros.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/compiler-macros.h new file mode 100644 index 0000000000000000000000000000000000000000..a66df44ff61ecfc606620c1fb7d757ab59abf53f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/compiler-macros.h @@ -0,0 +1,343 @@ +/**************************************************************************** + * + * internal/compiler-macros.h + * + * Compiler-specific macro definitions used internally by FreeType. + * + * Copyright (C) 2020-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +#ifndef INTERNAL_COMPILER_MACROS_H_ +#define INTERNAL_COMPILER_MACROS_H_ + +#include + +FT_BEGIN_HEADER + + /* Fix compiler warning with sgi compiler. */ +#if defined( __sgi ) && !defined( __GNUC__ ) +# if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 ) +# pragma set woff 3505 +# endif +#endif + + /* Fix compiler warning with sgi compiler. */ +#if defined( __sgi ) && !defined( __GNUC__ ) +# if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 ) +# pragma set woff 3505 +# endif +#endif + + /* Newer compilers warn for fall-through case statements. */ +#ifndef FALL_THROUGH +# if ( defined( __STDC_VERSION__ ) && __STDC_VERSION__ > 201710L ) || \ + ( defined( __cplusplus ) && __cplusplus > 201402L ) +# define FALL_THROUGH [[__fallthrough__]] +# elif ( defined( __GNUC__ ) && __GNUC__ >= 7 ) || \ + ( defined( __clang__ ) && \ + ( defined( __apple_build_version__ ) \ + ? __apple_build_version__ >= 12000000 \ + : __clang_major__ >= 10 ) ) +# define FALL_THROUGH __attribute__(( __fallthrough__ )) +# else +# define FALL_THROUGH ( (void)0 ) +# endif +#endif + + /* + * When defining a macro that expands to a non-trivial C statement, use + * FT_BEGIN_STMNT and FT_END_STMNT to enclose the macro's body. This + * ensures there are no surprises when the macro is invoked in conditional + * branches. + * + * Example: + * + * #define LOG( ... ) \ + * FT_BEGIN_STMNT \ + * if ( logging_enabled ) \ + * log( __VA_ARGS__ ); \ + * FT_END_STMNT + */ +#define FT_BEGIN_STMNT do { +#define FT_END_STMNT } while ( 0 ) + + /* + * FT_DUMMY_STMNT expands to an empty C statement. Useful for + * conditionally defined statement macros. + * + * Example: + * + * #ifdef BUILD_CONFIG_LOGGING + * #define LOG( ... ) \ + * FT_BEGIN_STMNT \ + * if ( logging_enabled ) \ + * log( __VA_ARGS__ ); \ + * FT_END_STMNT + * #else + * # define LOG( ... ) FT_DUMMY_STMNT + * #endif + */ +#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT + +#ifdef __UINTPTR_TYPE__ + /* + * GCC and Clang both provide a `__UINTPTR_TYPE__` that can be used to + * avoid a dependency on `stdint.h`. + */ +# define FT_UINT_TO_POINTER( x ) (void *)(__UINTPTR_TYPE__)(x) +#elif defined( _WIN64 ) + /* only 64bit Windows uses the LLP64 data model, i.e., */ + /* 32-bit integers, 64-bit pointers. */ +# define FT_UINT_TO_POINTER( x ) (void *)(unsigned __int64)(x) +#else +# define FT_UINT_TO_POINTER( x ) (void *)(unsigned long)(x) +#endif + + /* + * Use `FT_TYPEOF( type )` to cast a value to `type`. This is useful to + * suppress signedness compilation warnings in macros. + * + * Example: + * + * #define PAD_( x, n ) ( (x) & ~FT_TYPEOF( x )( (n) - 1 ) ) + * + * (The `typeof` condition is taken from gnulib's `intprops.h` header + * file.) + */ +#if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \ + ( defined( __IBMC__ ) && __IBMC__ >= 1210 && \ + defined( __IBM__TYPEOF__ ) ) || \ + ( defined( __SUNPRO_C ) && __SUNPRO_C >= 0x5110 && !__STDC__ ) ) +#define FT_TYPEOF( type ) ( __typeof__ ( type ) ) +#else +#define FT_TYPEOF( type ) /* empty */ +#endif + + /* + * Mark a function declaration as internal to the library. This ensures + * that it will not be exposed by default to client code, and helps + * generate smaller and faster code on ELF-based platforms. Place this + * before a function declaration. + */ + + /* Visual C, mingw */ +#if defined( _WIN32 ) +#define FT_INTERNAL_FUNCTION_ATTRIBUTE /* empty */ + + /* gcc, clang */ +#elif ( defined( __GNUC__ ) && __GNUC__ >= 4 ) || defined( __clang__ ) +#define FT_INTERNAL_FUNCTION_ATTRIBUTE \ + __attribute__(( visibility( "hidden" ) )) + + /* Sun */ +#elif defined( __SUNPRO_C ) && __SUNPRO_C >= 0x550 +#define FT_INTERNAL_FUNCTION_ATTRIBUTE __hidden + +#else +#define FT_INTERNAL_FUNCTION_ATTRIBUTE /* empty */ +#endif + + /* + * FreeType supports compilation of its C sources with a C++ compiler (in + * C++ mode); this introduces a number of subtle issues. + * + * The main one is that a C++ function declaration and its definition must + * have the same 'linkage'. Because all FreeType headers declare their + * functions with C linkage (i.e., within an `extern "C" { ... }` block + * due to the magic of FT_BEGIN_HEADER and FT_END_HEADER), their + * definition in FreeType sources should also be prefixed with `extern + * "C"` when compiled in C++ mode. + * + * The `FT_FUNCTION_DECLARATION` and `FT_FUNCTION_DEFINITION` macros are + * provided to deal with this case, as well as `FT_CALLBACK_DEF` and its + * siblings below. + */ + + /* + * `FT_FUNCTION_DECLARATION( type )` can be used to write a C function + * declaration to ensure it will have C linkage when the library is built + * with a C++ compiler. The parameter is the function's return type, so a + * declaration would look like + * + * FT_FUNCTION_DECLARATION( int ) + * foo( int x ); + * + * NOTE: This requires that all uses are inside of `FT_BEGIN_HEADER ... + * FT_END_HEADER` blocks, which guarantees that the declarations have C + * linkage when the headers are included by C++ sources. + * + * NOTE: Do not use directly. Use `FT_LOCAL`, `FT_BASE`, and `FT_EXPORT` + * instead. + */ +#define FT_FUNCTION_DECLARATION( x ) extern x + + /* + * Same as `FT_FUNCTION_DECLARATION`, but for function definitions instead. + * + * NOTE: Do not use directly. Use `FT_LOCAL_DEF`, `FT_BASE_DEF`, and + * `FT_EXPORT_DEF` instead. + */ +#ifdef __cplusplus +#define FT_FUNCTION_DEFINITION( x ) extern "C" x +#else +#define FT_FUNCTION_DEFINITION( x ) x +#endif + + /* + * Use `FT_LOCAL` and `FT_LOCAL_DEF` to declare and define, respectively, + * an internal FreeType function that is only used by the sources of a + * single `src/module/` directory. This ensures that the functions are + * turned into static ones at build time, resulting in smaller and faster + * code. + */ +#ifdef FT_MAKE_OPTION_SINGLE_OBJECT + +#define FT_LOCAL( x ) static x +#define FT_LOCAL_DEF( x ) static x + +#else + +#define FT_LOCAL( x ) FT_INTERNAL_FUNCTION_ATTRIBUTE \ + FT_FUNCTION_DECLARATION( x ) +#define FT_LOCAL_DEF( x ) FT_FUNCTION_DEFINITION( x ) + +#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */ + + /* + * Use `FT_LOCAL_ARRAY` and `FT_LOCAL_ARRAY_DEF` to declare and define, + * respectively, a constant array that must be accessed from several + * sources in the same `src/module/` sub-directory, and which are internal + * to the library. + */ +#define FT_LOCAL_ARRAY( x ) FT_INTERNAL_FUNCTION_ATTRIBUTE \ + extern const x +#define FT_LOCAL_ARRAY_DEF( x ) FT_FUNCTION_DEFINITION( const x ) + + /* + * `Use FT_BASE` and `FT_BASE_DEF` to declare and define, respectively, an + * internal library function that is used by more than a single module. + */ +#define FT_BASE( x ) FT_INTERNAL_FUNCTION_ATTRIBUTE \ + FT_FUNCTION_DECLARATION( x ) +#define FT_BASE_DEF( x ) FT_FUNCTION_DEFINITION( x ) + + + /* + * NOTE: Conditionally define `FT_EXPORT_VAR` due to its definition in + * `src/smooth/ftgrays.h` to make the header more portable. + */ +#ifndef FT_EXPORT_VAR +#define FT_EXPORT_VAR( x ) FT_FUNCTION_DECLARATION( x ) +#endif + + /* + * When compiling FreeType as a DLL or DSO with hidden visibility, + * some systems/compilers need a special attribute in front OR after + * the return type of function declarations. + * + * Two macros are used within the FreeType source code to define + * exported library functions: `FT_EXPORT` and `FT_EXPORT_DEF`. + * + * - `FT_EXPORT( return_type )` + * + * is used in a function declaration, as in + * + * ``` + * FT_EXPORT( FT_Error ) + * FT_Init_FreeType( FT_Library* alibrary ); + * ``` + * + * - `FT_EXPORT_DEF( return_type )` + * + * is used in a function definition, as in + * + * ``` + * FT_EXPORT_DEF( FT_Error ) + * FT_Init_FreeType( FT_Library* alibrary ) + * { + * ... some code ... + * return FT_Err_Ok; + * } + * ``` + * + * You can provide your own implementation of `FT_EXPORT` and + * `FT_EXPORT_DEF` here if you want. + * + * To export a variable, use `FT_EXPORT_VAR`. + */ + + /* See `freetype/config/public-macros.h` for the `FT_EXPORT` definition */ +#define FT_EXPORT_DEF( x ) FT_FUNCTION_DEFINITION( x ) + + /* + * The following macros are needed to compile the library with a + * C++ compiler and with 16bit compilers. + */ + + /* + * This is special. Within C++, you must specify `extern "C"` for + * functions which are used via function pointers, and you also + * must do that for structures which contain function pointers to + * assure C linkage -- it's not possible to have (local) anonymous + * functions which are accessed by (global) function pointers. + * + * + * FT_CALLBACK_DEF is used to _define_ a callback function, + * located in the same source code file as the structure that uses + * it. FT_COMPARE_DEF, in addition, ensures the `cdecl` calling + * convention on x86, required by the C library function `qsort`. + * + * FT_BASE_CALLBACK and FT_BASE_CALLBACK_DEF are used to declare + * and define a callback function, respectively, in a similar way + * as FT_BASE and FT_BASE_DEF work. + * + * FT_CALLBACK_TABLE is used to _declare_ a constant variable that + * contains pointers to callback functions. + * + * FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable + * that contains pointers to callback functions. + * + * + * Some 16bit compilers have to redefine these macros to insert + * the infamous `_cdecl` or `__fastcall` declarations. + */ +#ifdef __cplusplus +#define FT_CALLBACK_DEF( x ) extern "C" x +#else +#define FT_CALLBACK_DEF( x ) static x +#endif + +#if defined( __GNUC__ ) && defined( __i386__ ) +#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x ) __attribute__(( cdecl )) +#elif defined( _MSC_VER ) && defined( _M_IX86 ) +#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x ) __cdecl +#elif defined( __WATCOMC__ ) && __WATCOMC__ >= 1240 +#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x ) __watcall +#else +#define FT_COMPARE_DEF( x ) FT_CALLBACK_DEF( x ) +#endif + +#define FT_BASE_CALLBACK( x ) FT_FUNCTION_DECLARATION( x ) +#define FT_BASE_CALLBACK_DEF( x ) FT_FUNCTION_DEFINITION( x ) + +#ifndef FT_CALLBACK_TABLE +#ifdef __cplusplus +#define FT_CALLBACK_TABLE extern "C" +#define FT_CALLBACK_TABLE_DEF extern "C" +#else +#define FT_CALLBACK_TABLE extern +#define FT_CALLBACK_TABLE_DEF /* nothing */ +#endif +#endif /* FT_CALLBACK_TABLE */ + +FT_END_HEADER + +#endif /* INTERNAL_COMPILER_MACROS_H_ */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftcalc.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftcalc.h new file mode 100644 index 0000000000000000000000000000000000000000..d8556ccf9a5f8c48e94a8245a56007b2a9f995c3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftcalc.h @@ -0,0 +1,584 @@ +/**************************************************************************** + * + * ftcalc.h + * + * Arithmetic computations (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTCALC_H_ +#define FTCALC_H_ + + +#include + +#include "compiler-macros.h" + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * FT_MulDiv() and FT_MulFix() are declared in freetype.h. + * + */ + +#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER + /* Provide assembler fragments for performance-critical functions. */ + /* These must be defined `static __inline__' with GCC. */ + +#if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */ + +#define FT_MULFIX_ASSEMBLER FT_MulFix_arm + + /* documentation is in freetype.h */ + + static __inline FT_Int32 + FT_MulFix_arm( FT_Int32 a, + FT_Int32 b ) + { + FT_Int32 t, t2; + + + __asm + { + smull t2, t, b, a /* (lo=t2,hi=t) = a*b */ + mov a, t, asr #31 /* a = (hi >> 31) */ + add a, a, #0x8000 /* a += 0x8000 */ + adds t2, t2, a /* t2 += a */ + adc t, t, #0 /* t += carry */ + mov a, t2, lsr #16 /* a = t2 >> 16 */ + orr a, a, t, lsl #16 /* a |= t << 16 */ + } + return a; + } + +#endif /* __CC_ARM || __ARMCC__ */ + + +#ifdef __GNUC__ + +#if defined( __arm__ ) && \ + ( !defined( __thumb__ ) || defined( __thumb2__ ) ) && \ + !( defined( __CC_ARM ) || defined( __ARMCC__ ) ) + +#define FT_MULFIX_ASSEMBLER FT_MulFix_arm + + /* documentation is in freetype.h */ + + static __inline__ FT_Int32 + FT_MulFix_arm( FT_Int32 a, + FT_Int32 b ) + { + FT_Int32 t, t2; + + + __asm__ __volatile__ ( + "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */ + "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */ +#if defined( __clang__ ) && defined( __thumb2__ ) + "add.w %0, %0, #0x8000\n\t" /* %0 += 0x8000 */ +#else + "add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */ +#endif + "adds %1, %1, %0\n\t" /* %1 += %0 */ + "adc %2, %2, #0\n\t" /* %2 += carry */ + "mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */ + "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */ + : "=r"(a), "=&r"(t2), "=&r"(t) + : "r"(a), "r"(b) + : "cc" ); + return a; + } + +#endif /* __arm__ && */ + /* ( __thumb2__ || !__thumb__ ) && */ + /* !( __CC_ARM || __ARMCC__ ) */ + + +#if defined( __i386__ ) + +#define FT_MULFIX_ASSEMBLER FT_MulFix_i386 + + /* documentation is in freetype.h */ + + static __inline__ FT_Int32 + FT_MulFix_i386( FT_Int32 a, + FT_Int32 b ) + { + FT_Int32 result; + + + __asm__ __volatile__ ( + "imul %%edx\n" + "movl %%edx, %%ecx\n" + "sarl $31, %%ecx\n" + "addl $0x8000, %%ecx\n" + "addl %%ecx, %%eax\n" + "adcl $0, %%edx\n" + "shrl $16, %%eax\n" + "shll $16, %%edx\n" + "addl %%edx, %%eax\n" + : "=a"(result), "=d"(b) + : "a"(a), "d"(b) + : "%ecx", "cc" ); + return result; + } + +#endif /* i386 */ + +#endif /* __GNUC__ */ + + +#ifdef _MSC_VER /* Visual C++ */ + +#ifdef _M_IX86 + +#define FT_MULFIX_ASSEMBLER FT_MulFix_i386 + + /* documentation is in freetype.h */ + + static __inline FT_Int32 + FT_MulFix_i386( FT_Int32 a, + FT_Int32 b ) + { + FT_Int32 result; + + __asm + { + mov eax, a + mov edx, b + imul edx + mov ecx, edx + sar ecx, 31 + add ecx, 8000h + add eax, ecx + adc edx, 0 + shr eax, 16 + shl edx, 16 + add eax, edx + mov result, eax + } + return result; + } + +#endif /* _M_IX86 */ + +#endif /* _MSC_VER */ + + +#if defined( __GNUC__ ) && defined( __x86_64__ ) + +#define FT_MULFIX_ASSEMBLER FT_MulFix_x86_64 + + static __inline__ FT_Int32 + FT_MulFix_x86_64( FT_Int32 a, + FT_Int32 b ) + { + /* Temporarily disable the warning that C90 doesn't support */ + /* `long long'. */ +#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wlong-long" +#endif + +#if 1 + /* Technically not an assembly fragment, but GCC does a really good */ + /* job at inlining it and generating good machine code for it. */ + long long ret, tmp; + + + ret = (long long)a * b; + tmp = ret >> 63; + ret += 0x8000 + tmp; + + return (FT_Int32)( ret >> 16 ); +#else + + /* For some reason, GCC 4.6 on Ubuntu 12.04 generates invalid machine */ + /* code from the lines below. The main issue is that `wide_a' is not */ + /* properly initialized by sign-extending `a'. Instead, the generated */ + /* machine code assumes that the register that contains `a' on input */ + /* can be used directly as a 64-bit value, which is wrong most of the */ + /* time. */ + long long wide_a = (long long)a; + long long wide_b = (long long)b; + long long result; + + + __asm__ __volatile__ ( + "imul %2, %1\n" + "mov %1, %0\n" + "sar $63, %0\n" + "lea 0x8000(%1, %0), %0\n" + "sar $16, %0\n" + : "=&r"(result), "=&r"(wide_a) + : "r"(wide_b) + : "cc" ); + + return (FT_Int32)result; +#endif + +#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 ) +#pragma GCC diagnostic pop +#endif + } + +#endif /* __GNUC__ && __x86_64__ */ + +#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */ + + +#ifdef FT_CONFIG_OPTION_INLINE_MULFIX +#ifdef FT_MULFIX_ASSEMBLER +#define FT_MulFix( a, b ) FT_MULFIX_ASSEMBLER( (FT_Int32)(a), (FT_Int32)(b) ) +#endif +#endif + + + /************************************************************************** + * + * @function: + * FT_MulDiv_No_Round + * + * @description: + * A very simple function used to perform the computation '(a*b)/c' + * (without rounding) with maximum accuracy (it uses a 64-bit + * intermediate integer whenever necessary). + * + * This function isn't necessarily as fast as some processor-specific + * operations, but is at least completely portable. + * + * @input: + * a :: + * The first multiplier. + * b :: + * The second multiplier. + * c :: + * The divisor. + * + * @return: + * The result of '(a*b)/c'. This function never traps when trying to + * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on + * the signs of 'a' and 'b'. + */ + FT_BASE( FT_Long ) + FT_MulDiv_No_Round( FT_Long a, + FT_Long b, + FT_Long c ); + + + /************************************************************************** + * + * @function: + * FT_MulAddFix + * + * @description: + * Compute `(s[0] * f[0] + s[1] * f[1] + ...) / 0x10000`, where `s[n]` is + * usually a 16.16 scalar. + * + * @input: + * s :: + * The array of scalars. + * f :: + * The array of factors. + * count :: + * The number of entries in the array. + * + * @return: + * The result of `(s[0] * f[0] + s[1] * f[1] + ...) / 0x10000`. + * + * @note: + * This function is currently used for the scaled delta computation of + * variation stores. It internally uses 64-bit data types when + * available, otherwise it emulates 64-bit math by using 32-bit + * operations, which produce a correct result but most likely at a slower + * performance in comparison to the implementation base on `int64_t`. + * + */ + FT_BASE( FT_Int32 ) + FT_MulAddFix( FT_Fixed* s, + FT_Int32* f, + FT_UInt count ); + + + /* + * A variant of FT_Matrix_Multiply which scales its result afterwards. The + * idea is that both `a' and `b' are scaled by factors of 10 so that the + * values are as precise as possible to get a correct result during the + * 64bit multiplication. Let `sa' and `sb' be the scaling factors of `a' + * and `b', respectively, then the scaling factor of the result is `sa*sb'. + */ + FT_BASE( void ) + FT_Matrix_Multiply_Scaled( const FT_Matrix* a, + FT_Matrix *b, + FT_Long scaling ); + + + /* + * Check a matrix. If the transformation would lead to extreme shear or + * extreme scaling, for example, return 0. If everything is OK, return 1. + * + * Based on geometric considerations we use the following inequality to + * identify a degenerate matrix. + * + * 32 * abs(xx*yy - xy*yx) < xx^2 + xy^2 + yx^2 + yy^2 + * + * Value 32 is heuristic. + */ + FT_BASE( FT_Bool ) + FT_Matrix_Check( const FT_Matrix* matrix ); + + + /* + * A variant of FT_Vector_Transform. See comments for + * FT_Matrix_Multiply_Scaled. + */ + FT_BASE( void ) + FT_Vector_Transform_Scaled( FT_Vector* vector, + const FT_Matrix* matrix, + FT_Long scaling ); + + + /* + * This function normalizes a vector and returns its original length. The + * normalized vector is a 16.16 fixed-point unit vector with length close + * to 0x10000. The accuracy of the returned length is limited to 16 bits + * also. The function utilizes quick inverse square root approximation + * without divisions and square roots relying on Newton's iterations + * instead. + */ + FT_BASE( FT_UInt32 ) + FT_Vector_NormLen( FT_Vector* vector ); + + + /* + * Return -1, 0, or +1, depending on the orientation of a given corner. We + * use the Cartesian coordinate system, with positive vertical values going + * upwards. The function returns +1 if the corner turns to the left, -1 to + * the right, and 0 for undecidable cases. + */ + FT_BASE( FT_Int ) + ft_corner_orientation( FT_Pos in_x, + FT_Pos in_y, + FT_Pos out_x, + FT_Pos out_y ); + + + /* + * Return TRUE if a corner is flat or nearly flat. This is equivalent to + * saying that the corner point is close to its neighbors, or inside an + * ellipse defined by the neighbor focal points to be more precise. + */ + FT_BASE( FT_Int ) + ft_corner_is_flat( FT_Pos in_x, + FT_Pos in_y, + FT_Pos out_x, + FT_Pos out_y ); + + + /* + * Return the most significant bit index. + */ + +#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER + +#if defined( __clang__ ) || ( defined( __GNUC__ ) && \ + ( __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4 ) ) ) + +#if FT_SIZEOF_INT == 4 + +#define FT_MSB( x ) ( 31 - __builtin_clz( x ) ) + +#elif FT_SIZEOF_LONG == 4 + +#define FT_MSB( x ) ( 31 - __builtin_clzl( x ) ) + +#endif + +#elif defined( _MSC_VER ) && _MSC_VER >= 1400 + +#if defined( _WIN32_WCE ) + +#include +#pragma intrinsic( _CountLeadingZeros ) + +#define FT_MSB( x ) ( 31 - _CountLeadingZeros( x ) ) + +#elif defined( _M_ARM64 ) || defined( _M_ARM ) || defined( _M_ARM64EC ) + +#include +#pragma intrinsic( _CountLeadingZeros ) + +#define FT_MSB( x ) ( 31 - _CountLeadingZeros( x ) ) + +#elif defined( _M_IX86 ) || defined( _M_AMD64 ) || defined( _M_IA64 ) + +#include +#pragma intrinsic( _BitScanReverse ) + + static __inline FT_Int32 + FT_MSB_i386( FT_UInt32 x ) + { + unsigned long where; + + + _BitScanReverse( &where, x ); + + return (FT_Int32)where; + } + +#define FT_MSB( x ) FT_MSB_i386( x ) + +#endif + +#elif defined( __WATCOMC__ ) && defined( __386__ ) + + extern __inline FT_Int32 + FT_MSB_i386( FT_UInt32 x ); + +#pragma aux FT_MSB_i386 = \ + "bsr eax, eax" \ + __parm [__eax] __nomemory \ + __value [__eax] \ + __modify __exact [__eax] __nomemory; + +#define FT_MSB( x ) FT_MSB_i386( x ) + +#elif defined( __SunOS_5_11 ) + +#include + +#define FT_MSB( x ) ( fls( x ) - 1 ) + +#elif defined( __DECC ) || defined( __DECCXX ) + +#include + +#define FT_MSB( x ) (FT_Int)( 63 - _leadz( x ) ) + +#elif defined( _CRAYC ) + +#include + +#define FT_MSB( x ) (FT_Int)( 31 - _leadz32( x ) ) + +#endif /* FT_MSB macro definitions */ + +#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */ + + +#ifndef FT_MSB + + FT_BASE( FT_Int ) + FT_MSB( FT_UInt32 z ); + +#endif + + + /* + * Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses + * two fixed-point arguments instead. + */ + FT_BASE( FT_Fixed ) + FT_Hypot( FT_Fixed x, + FT_Fixed y ); + + + /************************************************************************** + * + * @function: + * FT_SqrtFixed + * + * @description: + * Computes the square root of a 16.16 fixed-point value. + * + * @input: + * x :: + * The value to compute the root for. + * + * @return: + * The result of 'sqrt(x)'. + * + * @note: + * This function is slow and should be avoided. Consider @FT_Hypot or + * @FT_Vector_NormLen instead. + */ + FT_BASE( FT_UInt32 ) + FT_SqrtFixed( FT_UInt32 x ); + + +#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) * 64 ) /* << 6 */ +#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) * 16384 ) /* << 14 */ +#define INT_TO_FIXED( x ) ( (FT_Long)(x) * 65536 ) /* << 16 */ +#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) * 4 ) /* << 2 */ +#define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 ) + +#define ROUND_F26DOT6( x ) ( ( (x) + 32 - ( x < 0 ) ) & -64 ) + + /* + * The following macros have two purposes. + * + * - Tag places where overflow is expected and harmless. + * + * - Avoid run-time sanitizer errors. + * + * Use with care! + */ +#define ADD_INT( a, b ) \ + (FT_Int)( (FT_UInt)(a) + (FT_UInt)(b) ) +#define SUB_INT( a, b ) \ + (FT_Int)( (FT_UInt)(a) - (FT_UInt)(b) ) +#define MUL_INT( a, b ) \ + (FT_Int)( (FT_UInt)(a) * (FT_UInt)(b) ) +#define NEG_INT( a ) \ + (FT_Int)( (FT_UInt)0 - (FT_UInt)(a) ) + +#define ADD_LONG( a, b ) \ + (FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) ) +#define SUB_LONG( a, b ) \ + (FT_Long)( (FT_ULong)(a) - (FT_ULong)(b) ) +#define MUL_LONG( a, b ) \ + (FT_Long)( (FT_ULong)(a) * (FT_ULong)(b) ) +#define NEG_LONG( a ) \ + (FT_Long)( (FT_ULong)0 - (FT_ULong)(a) ) + +#define ADD_INT32( a, b ) \ + (FT_Int32)( (FT_UInt32)(a) + (FT_UInt32)(b) ) +#define SUB_INT32( a, b ) \ + (FT_Int32)( (FT_UInt32)(a) - (FT_UInt32)(b) ) +#define MUL_INT32( a, b ) \ + (FT_Int32)( (FT_UInt32)(a) * (FT_UInt32)(b) ) +#define NEG_INT32( a ) \ + (FT_Int32)( (FT_UInt32)0 - (FT_UInt32)(a) ) + +#ifdef FT_INT64 + +#define ADD_INT64( a, b ) \ + (FT_Int64)( (FT_UInt64)(a) + (FT_UInt64)(b) ) +#define SUB_INT64( a, b ) \ + (FT_Int64)( (FT_UInt64)(a) - (FT_UInt64)(b) ) +#define MUL_INT64( a, b ) \ + (FT_Int64)( (FT_UInt64)(a) * (FT_UInt64)(b) ) +#define NEG_INT64( a ) \ + (FT_Int64)( (FT_UInt64)0 - (FT_UInt64)(a) ) + +#endif /* FT_INT64 */ + + +FT_END_HEADER + +#endif /* FTCALC_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftdebug.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftdebug.h new file mode 100644 index 0000000000000000000000000000000000000000..916ac50873cd688df89995747a61ed154d83cb0a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftdebug.h @@ -0,0 +1,442 @@ +/**************************************************************************** + * + * ftdebug.h + * + * Debugging and logging component (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * + * IMPORTANT: A description of FreeType's debugging support can be + * found in 'docs/DEBUG.TXT'. Read it if you need to use or + * understand this code. + * + */ + + +#ifndef FTDEBUG_H_ +#define FTDEBUG_H_ + + +#include +#include FT_CONFIG_CONFIG_H +#include + +#include "compiler-macros.h" + +#ifdef FT_DEBUG_LOGGING +#define DLG_STATIC +#include +#include + +#include +#endif /* FT_DEBUG_LOGGING */ + + +FT_BEGIN_HEADER + + /* force the definition of FT_DEBUG_LEVEL_TRACE if FT_DEBUG_LOGGING is */ + /* already defined. */ + /* */ +#ifdef FT_DEBUG_LOGGING +#undef FT_DEBUG_LEVEL_TRACE +#define FT_DEBUG_LEVEL_TRACE +#endif + + /* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */ + /* is already defined; this simplifies the following #ifdefs */ + /* */ +#ifdef FT_DEBUG_LEVEL_TRACE +#undef FT_DEBUG_LEVEL_ERROR +#define FT_DEBUG_LEVEL_ERROR +#endif + + + /************************************************************************** + * + * Define the trace enums as well as the trace levels array when they are + * needed. + * + */ + +#ifdef FT_DEBUG_LEVEL_TRACE + +#define FT_TRACE_DEF( x ) trace_ ## x , + + /* defining the enumeration */ + typedef enum FT_Trace_ + { +#include + trace_count + + } FT_Trace; + + + /* a pointer to the array of trace levels, */ + /* provided by `src/base/ftdebug.c' */ + extern int* ft_trace_levels; + +#undef FT_TRACE_DEF + +#endif /* FT_DEBUG_LEVEL_TRACE */ + + + /************************************************************************** + * + * Define the FT_TRACE macro + * + * IMPORTANT! + * + * Each component must define the macro FT_COMPONENT to a valid FT_Trace + * value before using any TRACE macro. + * + * To get consistent logging output, there should be no newline character + * (i.e., '\n') or a single trailing one in the message string of + * `FT_TRACEx` and `FT_ERROR`. + */ + + + /************************************************************************* + * + * If FT_DEBUG_LOGGING is enabled, tracing messages are sent to dlg's API. + * If FT_DEBUG_LOGGING is disabled, tracing messages are sent to + * `FT_Message` (defined in ftdebug.c). + */ +#ifdef FT_DEBUG_LOGGING + + /* we need two macros to convert the names of `FT_COMPONENT` to a string */ +#define FT_LOGGING_TAG( x ) FT_LOGGING_TAG_( x ) +#define FT_LOGGING_TAG_( x ) #x + + /* we need two macros to convert the component and the trace level */ + /* to a string that combines them */ +#define FT_LOGGING_TAGX( x, y ) FT_LOGGING_TAGX_( x, y ) +#define FT_LOGGING_TAGX_( x, y ) #x ":" #y + + +#define FT_LOG( level, varformat ) \ + do \ + { \ + const char* dlg_tag = FT_LOGGING_TAGX( FT_COMPONENT, level ); \ + \ + \ + ft_add_tag( dlg_tag ); \ + if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \ + { \ + if ( custom_output_handler != NULL ) \ + FT_Logging_Callback varformat; \ + else \ + dlg_trace varformat; \ + } \ + ft_remove_tag( dlg_tag ); \ + } while( 0 ) + +#else /* !FT_DEBUG_LOGGING */ + +#define FT_LOG( level, varformat ) \ + do \ + { \ + if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \ + FT_Message varformat; \ + } while ( 0 ) + +#endif /* !FT_DEBUG_LOGGING */ + + +#ifdef FT_DEBUG_LEVEL_TRACE + + /* we need two macros here to make cpp expand `FT_COMPONENT' */ +#define FT_TRACE_COMP( x ) FT_TRACE_COMP_( x ) +#define FT_TRACE_COMP_( x ) trace_ ## x + +#define FT_TRACE( level, varformat ) FT_LOG( level, varformat ) + +#else /* !FT_DEBUG_LEVEL_TRACE */ + +#define FT_TRACE( level, varformat ) do { } while ( 0 ) /* nothing */ + +#endif /* !FT_DEBUG_LEVEL_TRACE */ + + + /************************************************************************** + * + * @function: + * FT_Trace_Get_Count + * + * @description: + * Return the number of available trace components. + * + * @return: + * The number of trace components. 0 if FreeType 2 is not built with + * FT_DEBUG_LEVEL_TRACE definition. + * + * @note: + * This function may be useful if you want to access elements of the + * internal trace levels array by an index. + */ + FT_BASE( FT_Int ) + FT_Trace_Get_Count( void ); + + + /************************************************************************** + * + * @function: + * FT_Trace_Get_Name + * + * @description: + * Return the name of a trace component. + * + * @input: + * The index of the trace component. + * + * @return: + * The name of the trace component. This is a statically allocated + * C~string, so do not free it after use. `NULL` if FreeType is not + * built with FT_DEBUG_LEVEL_TRACE definition. + * + * @note: + * Use @FT_Trace_Get_Count to get the number of available trace + * components. + */ + FT_BASE( const char* ) + FT_Trace_Get_Name( FT_Int idx ); + + + /************************************************************************** + * + * @function: + * FT_Trace_Disable + * + * @description: + * Switch off tracing temporarily. It can be activated again with + * @FT_Trace_Enable. + */ + FT_BASE( void ) + FT_Trace_Disable( void ); + + + /************************************************************************** + * + * @function: + * FT_Trace_Enable + * + * @description: + * Activate tracing. Use it after tracing has been switched off with + * @FT_Trace_Disable. + */ + FT_BASE( void ) + FT_Trace_Enable( void ); + + + /************************************************************************** + * + * You need two opening and closing parentheses! + * + * Example: FT_TRACE0(( "Value is %i", foo )) + * + * Output of the FT_TRACEX macros is sent to stderr. + * + */ + +#define FT_TRACE0( varformat ) FT_TRACE( 0, varformat ) +#define FT_TRACE1( varformat ) FT_TRACE( 1, varformat ) +#define FT_TRACE2( varformat ) FT_TRACE( 2, varformat ) +#define FT_TRACE3( varformat ) FT_TRACE( 3, varformat ) +#define FT_TRACE4( varformat ) FT_TRACE( 4, varformat ) +#define FT_TRACE5( varformat ) FT_TRACE( 5, varformat ) +#define FT_TRACE6( varformat ) FT_TRACE( 6, varformat ) +#define FT_TRACE7( varformat ) FT_TRACE( 7, varformat ) + + + /************************************************************************** + * + * Define the FT_ERROR macro. + * + * Output of this macro is sent to stderr. + * + */ + +#ifdef FT_DEBUG_LEVEL_ERROR + + /************************************************************************** + * + * If FT_DEBUG_LOGGING is enabled, error messages are sent to dlg's API. + * If FT_DEBUG_LOGGING is disabled, error messages are sent to `FT_Message` + * (defined in ftdebug.c). + * + */ +#ifdef FT_DEBUG_LOGGING + +#define FT_ERROR( varformat ) \ + do \ + { \ + const char* dlg_tag = FT_LOGGING_TAG( FT_COMPONENT ); \ + \ + \ + ft_add_tag( dlg_tag ); \ + dlg_trace varformat; \ + ft_remove_tag( dlg_tag ); \ + } while ( 0 ) + +#else /* !FT_DEBUG_LOGGING */ + +#define FT_ERROR( varformat ) FT_Message varformat + +#endif /* !FT_DEBUG_LOGGING */ + + +#else /* !FT_DEBUG_LEVEL_ERROR */ + +#define FT_ERROR( varformat ) do { } while ( 0 ) /* nothing */ + +#endif /* !FT_DEBUG_LEVEL_ERROR */ + + + /************************************************************************** + * + * Define the FT_ASSERT and FT_THROW macros. The call to `FT_Throw` makes + * it possible to easily set a breakpoint at this function. + * + */ + +#ifdef FT_DEBUG_LEVEL_ERROR + +#define FT_ASSERT( condition ) \ + do \ + { \ + if ( !( condition ) ) \ + FT_Panic( "assertion failed on line %d of file %s\n", \ + __LINE__, __FILE__ ); \ + } while ( 0 ) + +#define FT_THROW( e ) \ + ( FT_Throw( FT_ERR_CAT( FT_ERR_PREFIX, e ), \ + __LINE__, \ + __FILE__ ) | \ + FT_ERR_CAT( FT_ERR_PREFIX, e ) ) + +#else /* !FT_DEBUG_LEVEL_ERROR */ + +#define FT_ASSERT( condition ) do { } while ( 0 ) + +#define FT_THROW( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) + +#endif /* !FT_DEBUG_LEVEL_ERROR */ + + + /************************************************************************** + * + * Define `FT_Message` and `FT_Panic` when needed. + * + */ + +#ifdef FT_DEBUG_LEVEL_ERROR + +#include "stdio.h" /* for vfprintf() */ + + /* print a message */ + FT_BASE( void ) + FT_Message( const char* fmt, + ... ); + + /* print a message and exit */ + FT_BASE( void ) + FT_Panic( const char* fmt, + ... ); + + /* report file name and line number of an error */ + FT_BASE( int ) + FT_Throw( FT_Error error, + int line, + const char* file ); + +#endif /* FT_DEBUG_LEVEL_ERROR */ + + + FT_BASE( void ) + ft_debug_init( void ); + + +#ifdef FT_DEBUG_LOGGING + + /************************************************************************** + * + * 'dlg' uses output handlers to control how and where log messages are + * printed. Therefore we need to define a default output handler for + * FreeType. + */ + FT_BASE( void ) + ft_log_handler( const struct dlg_origin* origin, + const char* string, + void* data ); + + + /************************************************************************** + * + * 1. `ft_default_log_handler` stores the function pointer that is used + * internally by FreeType to print logs to a file. + * + * 2. `custom_output_handler` stores the function pointer to the callback + * function provided by the user. + * + * It is defined in `ftdebug.c`. + */ + extern dlg_handler ft_default_log_handler; + extern FT_Custom_Log_Handler custom_output_handler; + + + /************************************************************************** + * + * If FT_DEBUG_LOGGING macro is enabled, FreeType needs to initialize and + * un-initialize `FILE*`. + * + * These functions are defined in `ftdebug.c`. + */ + FT_BASE( void ) + ft_logging_init( void ); + + FT_BASE( void ) + ft_logging_deinit( void ); + + + /************************************************************************** + * + * For printing the name of `FT_COMPONENT` along with the actual log we + * need to add a tag with the name of `FT_COMPONENT`. + * + * These functions are defined in `ftdebug.c`. + */ + FT_BASE( void ) + ft_add_tag( const char* tag ); + + FT_BASE( void ) + ft_remove_tag( const char* tag ); + + + /************************************************************************** + * + * A function to print log data using a custom callback logging function + * (which is set using `FT_Set_Log_Handler`). + * + * This function is defined in `ftdebug.c`. + */ + FT_BASE( void ) + FT_Logging_Callback( const char* fmt, + ... ); + +#endif /* FT_DEBUG_LOGGING */ + + +FT_END_HEADER + +#endif /* FTDEBUG_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftdrv.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftdrv.h new file mode 100644 index 0000000000000000000000000000000000000000..d5e470292b0afffd39f6de29596d2db32befe8c0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftdrv.h @@ -0,0 +1,289 @@ +/**************************************************************************** + * + * ftdrv.h + * + * FreeType internal font driver interface (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTDRV_H_ +#define FTDRV_H_ + + +#include + +#include "compiler-macros.h" + +FT_BEGIN_HEADER + + + typedef FT_Error + (*FT_Face_InitFunc)( FT_Stream stream, + FT_Face face, + FT_Int typeface_index, + FT_Int num_params, + FT_Parameter* parameters ); + + typedef void + (*FT_Face_DoneFunc)( FT_Face face ); + + + typedef FT_Error + (*FT_Size_InitFunc)( FT_Size size ); + + typedef void + (*FT_Size_DoneFunc)( FT_Size size ); + + + typedef FT_Error + (*FT_Slot_InitFunc)( FT_GlyphSlot slot ); + + typedef void + (*FT_Slot_DoneFunc)( FT_GlyphSlot slot ); + + + typedef FT_Error + (*FT_Size_RequestFunc)( FT_Size size, + FT_Size_Request req ); + + typedef FT_Error + (*FT_Size_SelectFunc)( FT_Size size, + FT_ULong size_index ); + + typedef FT_Error + (*FT_Slot_LoadFunc)( FT_GlyphSlot slot, + FT_Size size, + FT_UInt glyph_index, + FT_Int32 load_flags ); + + + typedef FT_Error + (*FT_Face_GetKerningFunc)( FT_Face face, + FT_UInt left_glyph, + FT_UInt right_glyph, + FT_Vector* kerning ); + + + typedef FT_Error + (*FT_Face_AttachFunc)( FT_Face face, + FT_Stream stream ); + + + typedef FT_Error + (*FT_Face_GetAdvancesFunc)( FT_Face face, + FT_UInt first, + FT_UInt count, + FT_Int32 flags, + FT_Fixed* advances ); + + + /************************************************************************** + * + * @struct: + * FT_Driver_ClassRec + * + * @description: + * The font driver class. This structure mostly contains pointers to + * driver methods. + * + * @fields: + * root :: + * The parent module. + * + * face_object_size :: + * The size of a face object in bytes. + * + * size_object_size :: + * The size of a size object in bytes. + * + * slot_object_size :: + * The size of a glyph object in bytes. + * + * init_face :: + * The format-specific face constructor. + * + * done_face :: + * The format-specific face destructor. + * + * init_size :: + * The format-specific size constructor. + * + * done_size :: + * The format-specific size destructor. + * + * init_slot :: + * The format-specific slot constructor. + * + * done_slot :: + * The format-specific slot destructor. + * + * + * load_glyph :: + * A function handle to load a glyph to a slot. This field is + * mandatory! + * + * get_kerning :: + * A function handle to return the unscaled kerning for a given pair of + * glyphs. Can be set to 0 if the format doesn't support kerning. + * + * attach_file :: + * This function handle is used to read additional data for a face from + * another file/stream. For example, this can be used to add data from + * AFM or PFM files on a Type 1 face, or a CIDMap on a CID-keyed face. + * + * get_advances :: + * A function handle used to return advance widths of 'count' glyphs + * (in font units), starting at 'first'. The 'vertical' flag must be + * set to get vertical advance heights. The 'advances' buffer is + * caller-allocated. The idea of this function is to be able to + * perform device-independent text layout without loading a single + * glyph image. + * + * request_size :: + * A handle to a function used to request the new character size. Can + * be set to 0 if the scaling done in the base layer suffices. + * + * select_size :: + * A handle to a function used to select a new fixed size. It is used + * only if @FT_FACE_FLAG_FIXED_SIZES is set. Can be set to 0 if the + * scaling done in the base layer suffices. + * + * @note: + * Most function pointers, with the exception of `load_glyph`, can be set + * to 0 to indicate a default behaviour. + */ + typedef struct FT_Driver_ClassRec_ + { + FT_Module_Class root; + + FT_Long face_object_size; + FT_Long size_object_size; + FT_Long slot_object_size; + + FT_Face_InitFunc init_face; + FT_Face_DoneFunc done_face; + + FT_Size_InitFunc init_size; + FT_Size_DoneFunc done_size; + + FT_Slot_InitFunc init_slot; + FT_Slot_DoneFunc done_slot; + + FT_Slot_LoadFunc load_glyph; + + FT_Face_GetKerningFunc get_kerning; + FT_Face_AttachFunc attach_file; + FT_Face_GetAdvancesFunc get_advances; + + /* since version 2.2 */ + FT_Size_RequestFunc request_size; + FT_Size_SelectFunc select_size; + + } FT_Driver_ClassRec, *FT_Driver_Class; + + + /************************************************************************** + * + * @macro: + * FT_DECLARE_DRIVER + * + * @description: + * Used to create a forward declaration of an FT_Driver_ClassRec struct + * instance. + * + * @macro: + * FT_DEFINE_DRIVER + * + * @description: + * Used to initialize an instance of FT_Driver_ClassRec struct. + * + * `ftinit.c` (ft_create_default_module_classes) already contains a + * mechanism to call these functions for the default modules described in + * `ftmodule.h`. + * + * The struct will be allocated in the global scope (or the scope where + * the macro is used). + */ +#define FT_DECLARE_DRIVER( class_ ) \ + FT_CALLBACK_TABLE \ + const FT_Driver_ClassRec class_; + +#define FT_DEFINE_DRIVER( \ + class_, \ + flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_, \ + face_object_size_, \ + size_object_size_, \ + slot_object_size_, \ + init_face_, \ + done_face_, \ + init_size_, \ + done_size_, \ + init_slot_, \ + done_slot_, \ + load_glyph_, \ + get_kerning_, \ + attach_file_, \ + get_advances_, \ + request_size_, \ + select_size_ ) \ + FT_CALLBACK_TABLE_DEF \ + const FT_Driver_ClassRec class_ = \ + { \ + FT_DEFINE_ROOT_MODULE( flags_, \ + size_, \ + name_, \ + version_, \ + requires_, \ + interface_, \ + init_, \ + done_, \ + get_interface_ ) \ + \ + face_object_size_, \ + size_object_size_, \ + slot_object_size_, \ + \ + init_face_, \ + done_face_, \ + \ + init_size_, \ + done_size_, \ + \ + init_slot_, \ + done_slot_, \ + \ + load_glyph_, \ + \ + get_kerning_, \ + attach_file_, \ + get_advances_, \ + \ + request_size_, \ + select_size_ \ + }; + + +FT_END_HEADER + +#endif /* FTDRV_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftgloadr.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftgloadr.h new file mode 100644 index 0000000000000000000000000000000000000000..84b5df6ca7492b787eaf6708a7a9b21c47f839ad --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftgloadr.h @@ -0,0 +1,147 @@ +/**************************************************************************** + * + * ftgloadr.h + * + * The FreeType glyph loader (specification). + * + * Copyright (C) 2002-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTGLOADR_H_ +#define FTGLOADR_H_ + + +#include + +#include "compiler-macros.h" + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @struct: + * FT_GlyphLoader + * + * @description: + * The glyph loader is an internal object used to load several glyphs + * together (for example, in the case of composites). + */ + typedef struct FT_SubGlyphRec_ + { + FT_Int index; + FT_UShort flags; + FT_Int arg1; + FT_Int arg2; + FT_Matrix transform; + + } FT_SubGlyphRec; + + + typedef struct FT_GlyphLoadRec_ + { + FT_Outline outline; /* outline */ + FT_Vector* extra_points; /* extra points table */ + FT_Vector* extra_points2; /* second extra points table */ + FT_UInt num_subglyphs; /* number of subglyphs */ + FT_SubGlyph subglyphs; /* subglyphs */ + + } FT_GlyphLoadRec, *FT_GlyphLoad; + + + typedef struct FT_GlyphLoaderRec_ + { + FT_Memory memory; + FT_UInt max_points; + FT_UInt max_contours; + FT_UInt max_subglyphs; + FT_Bool use_extra; + + FT_GlyphLoadRec base; + FT_GlyphLoadRec current; + + void* other; /* for possible future extension? */ + + } FT_GlyphLoaderRec, *FT_GlyphLoader; + + + /* create new empty glyph loader */ + FT_BASE( FT_Error ) + FT_GlyphLoader_New( FT_Memory memory, + FT_GlyphLoader *aloader ); + + /* add an extra points table to a glyph loader */ + FT_BASE( FT_Error ) + FT_GlyphLoader_CreateExtra( FT_GlyphLoader loader ); + + /* destroy a glyph loader */ + FT_BASE( void ) + FT_GlyphLoader_Done( FT_GlyphLoader loader ); + + /* reset a glyph loader (frees everything int it) */ + FT_BASE( void ) + FT_GlyphLoader_Reset( FT_GlyphLoader loader ); + + /* rewind a glyph loader */ + FT_BASE( void ) + FT_GlyphLoader_Rewind( FT_GlyphLoader loader ); + + /* check that there is enough space to add `n_points' and `n_contours' */ + /* to the glyph loader */ + FT_BASE( FT_Error ) + FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader, + FT_UInt n_points, + FT_UInt n_contours ); + + +#define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \ + ( (_count) == 0 || \ + ( (FT_UInt)(_loader)->base.outline.n_points + \ + (FT_UInt)(_loader)->current.outline.n_points + \ + (FT_UInt)(_count) ) <= (_loader)->max_points ) + +#define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \ + ( (_count) == 0 || \ + ( (FT_UInt)(_loader)->base.outline.n_contours + \ + (FT_UInt)(_loader)->current.outline.n_contours + \ + (FT_UInt)(_count) ) <= (_loader)->max_contours ) + +#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points, _contours ) \ + ( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \ + FT_GLYPHLOADER_CHECK_C( _loader, _contours ) ) \ + ? 0 \ + : FT_GlyphLoader_CheckPoints( (_loader), \ + (FT_UInt)(_points), \ + (FT_UInt)(_contours) ) ) + + + /* check that there is enough space to add `n_subs' sub-glyphs to */ + /* a glyph loader */ + FT_BASE( FT_Error ) + FT_GlyphLoader_CheckSubGlyphs( FT_GlyphLoader loader, + FT_UInt n_subs ); + + /* prepare a glyph loader, i.e. empty the current glyph */ + FT_BASE( void ) + FT_GlyphLoader_Prepare( FT_GlyphLoader loader ); + + /* add the current glyph to the base glyph */ + FT_BASE( void ) + FT_GlyphLoader_Add( FT_GlyphLoader loader ); + + +FT_END_HEADER + +#endif /* FTGLOADR_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/fthash.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/fthash.h new file mode 100644 index 0000000000000000000000000000000000000000..5d71b8a368475d837ef1b41a56cf7cb6323c3eb2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/fthash.h @@ -0,0 +1,135 @@ +/**************************************************************************** + * + * fthash.h + * + * Hashing functions (specification). + * + */ + +/* + * Copyright 2000 Computing Research Labs, New Mexico State University + * Copyright 2001-2015 + * Francesco Zappa Nardelli + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT + * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + /************************************************************************** + * + * This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 + * + * taken from Mark Leisher's xmbdfed package + * + */ + + +#ifndef FTHASH_H_ +#define FTHASH_H_ + + +#include + + +FT_BEGIN_HEADER + + + typedef union FT_Hashkey_ + { + FT_Int num; + const char* str; + + } FT_Hashkey; + + + typedef struct FT_HashnodeRec_ + { + FT_Hashkey key; + size_t data; + + } FT_HashnodeRec; + + typedef struct FT_HashnodeRec_ *FT_Hashnode; + + + typedef FT_ULong + (*FT_Hash_LookupFunc)( FT_Hashkey* key ); + + typedef FT_Bool + (*FT_Hash_CompareFunc)( FT_Hashkey* a, + FT_Hashkey* b ); + + + typedef struct FT_HashRec_ + { + FT_UInt limit; + FT_UInt size; + FT_UInt used; + + FT_Hash_LookupFunc lookup; + FT_Hash_CompareFunc compare; + + FT_Hashnode* table; + + } FT_HashRec; + + typedef struct FT_HashRec_ *FT_Hash; + + + FT_Error + ft_hash_str_init( FT_Hash hash, + FT_Memory memory ); + + FT_Error + ft_hash_num_init( FT_Hash hash, + FT_Memory memory ); + + void + ft_hash_str_free( FT_Hash hash, + FT_Memory memory ); + +#define ft_hash_num_free ft_hash_str_free + + FT_Error + ft_hash_str_insert( const char* key, + size_t data, + FT_Hash hash, + FT_Memory memory ); + + FT_Error + ft_hash_num_insert( FT_Int num, + size_t data, + FT_Hash hash, + FT_Memory memory ); + + size_t* + ft_hash_str_lookup( const char* key, + FT_Hash hash ); + + size_t* + ft_hash_num_lookup( FT_Int num, + FT_Hash hash ); + + +FT_END_HEADER + + +#endif /* FTHASH_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftmemory.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftmemory.h new file mode 100644 index 0000000000000000000000000000000000000000..9c05e18233e9be2a37781f11924795f843ed45c0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/internal/ftmemory.h @@ -0,0 +1,401 @@ +/**************************************************************************** + * + * ftmemory.h + * + * The FreeType memory management macros (specification). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTMEMORY_H_ +#define FTMEMORY_H_ + + +#include +#include FT_CONFIG_CONFIG_H +#include + +#include "compiler-macros.h" + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @macro: + * FT_SET_ERROR + * + * @description: + * This macro is used to set an implicit 'error' variable to a given + * expression's value (usually a function call), and convert it to a + * boolean which is set whenever the value is != 0. + */ +#undef FT_SET_ERROR +#define FT_SET_ERROR( expression ) \ + ( ( error = (expression) ) != 0 ) + + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** M E M O R Y ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /* The calculation `NULL + n' is undefined in C. Even if the resulting */ + /* pointer doesn't get dereferenced, this causes warnings with */ + /* sanitizers. */ + /* */ + /* We thus provide a macro that should be used if `base' can be NULL. */ +#define FT_OFFSET( base, count ) ( (base) ? (base) + (count) : NULL ) + + + /* + * C++ refuses to handle statements like p = (void*)anything, with `p' a + * typed pointer. Since we don't have a `typeof' operator in standard C++, + * we have to use a template to emulate it. + */ + +#ifdef __cplusplus + +extern "C++" +{ + template inline T* + cplusplus_typeof( T*, + void *v ) + { + return static_cast ( v ); + } +} + +#define FT_ASSIGNP( p, val ) (p) = cplusplus_typeof( (p), (val) ) + +#else + +#define FT_ASSIGNP( p, val ) (p) = (val) + +#endif + + + +#ifdef FT_DEBUG_MEMORY + + FT_BASE( const char* ) ft_debug_file_; + FT_BASE( long ) ft_debug_lineno_; + +#define FT_DEBUG_INNER( exp ) ( ft_debug_file_ = __FILE__, \ + ft_debug_lineno_ = __LINE__, \ + (exp) ) + +#define FT_ASSIGNP_INNER( p, exp ) ( ft_debug_file_ = __FILE__, \ + ft_debug_lineno_ = __LINE__, \ + FT_ASSIGNP( p, exp ) ) + +#else /* !FT_DEBUG_MEMORY */ + +#define FT_DEBUG_INNER( exp ) (exp) +#define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp ) + +#endif /* !FT_DEBUG_MEMORY */ + + + /* + * The allocation functions return a pointer, and the error code is written + * to through the `p_error' parameter. + */ + + /* The `q' variants of the functions below (`q' for `quick') don't fill */ + /* the allocated or reallocated memory with zero bytes. */ + + FT_BASE( FT_Pointer ) + ft_mem_alloc( FT_Memory memory, + FT_Long size, + FT_Error *p_error ); + + FT_BASE( FT_Pointer ) + ft_mem_qalloc( FT_Memory memory, + FT_Long size, + FT_Error *p_error ); + + FT_BASE( FT_Pointer ) + ft_mem_realloc( FT_Memory memory, + FT_Long item_size, + FT_Long cur_count, + FT_Long new_count, + void* block, + FT_Error *p_error ); + + FT_BASE( FT_Pointer ) + ft_mem_qrealloc( FT_Memory memory, + FT_Long item_size, + FT_Long cur_count, + FT_Long new_count, + void* block, + FT_Error *p_error ); + + FT_BASE( void ) + ft_mem_free( FT_Memory memory, + const void* P ); + + + /* The `Q' variants of the macros below (`Q' for `quick') don't fill */ + /* the allocated or reallocated memory with zero bytes. */ + +#define FT_MEM_ALLOC( ptr, size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, \ + (FT_Long)(size), \ + &error ) ) + +#define FT_MEM_FREE( ptr ) \ + FT_BEGIN_STMNT \ + FT_DEBUG_INNER( ft_mem_free( memory, (ptr) ) ); \ + (ptr) = NULL; \ + FT_END_STMNT + +#define FT_MEM_NEW( ptr ) \ + FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) ) + +#define FT_MEM_REALLOC( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ + 1, \ + (FT_Long)(cursz), \ + (FT_Long)(newsz), \ + (ptr), \ + &error ) ) + +#define FT_MEM_QALLOC( ptr, size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, \ + (FT_Long)(size), \ + &error ) ) + +#define FT_MEM_QNEW( ptr ) \ + FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) ) + +#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + 1, \ + (FT_Long)(cursz), \ + (FT_Long)(newsz), \ + (ptr), \ + &error ) ) + +#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ + (FT_Long)(item_size), \ + 0, \ + (FT_Long)(count), \ + NULL, \ + &error ) ) + +#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ + (FT_Long)(itmsz), \ + (FT_Long)(oldcnt), \ + (FT_Long)(newcnt), \ + (ptr), \ + &error ) ) + +#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + (FT_Long)(item_size), \ + 0, \ + (FT_Long)(count), \ + NULL, \ + &error ) ) + +#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + (FT_Long)(itmsz), \ + (FT_Long)(oldcnt), \ + (FT_Long)(newcnt), \ + (ptr), \ + &error ) ) + + +#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) + + +#define FT_MEM_SET( dest, byte, count ) \ + ft_memset( dest, byte, (FT_Offset)(count) ) + +#define FT_MEM_COPY( dest, source, count ) \ + ft_memcpy( dest, source, (FT_Offset)(count) ) + +#define FT_MEM_MOVE( dest, source, count ) \ + ft_memmove( dest, source, (FT_Offset)(count) ) + + +#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) + +#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) ) + + +#define FT_ARRAY_ZERO( dest, count ) \ + FT_MEM_ZERO( dest, \ + (FT_Offset)(count) * sizeof ( *(dest) ) ) + +#define FT_ARRAY_COPY( dest, source, count ) \ + FT_MEM_COPY( dest, \ + source, \ + (FT_Offset)(count) * sizeof ( *(dest) ) ) + +#define FT_ARRAY_MOVE( dest, source, count ) \ + FT_MEM_MOVE( dest, \ + source, \ + (FT_Offset)(count) * sizeof ( *(dest) ) ) + + + /* + * Return the maximum number of addressable elements in an array. We limit + * ourselves to INT_MAX, rather than UINT_MAX, to avoid any problems. + */ +#define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) ) + +#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) + + + /************************************************************************** + * + * The following functions macros expect that their pointer argument is + * _typed_ in order to automatically compute array element sizes. + */ + +#define FT_MEM_NEW_ARRAY( ptr, count ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ + sizeof ( *(ptr) ), \ + 0, \ + (FT_Long)(count), \ + NULL, \ + &error ) ) + +#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ + sizeof ( *(ptr) ), \ + (FT_Long)(cursz), \ + (FT_Long)(newsz), \ + (ptr), \ + &error ) ) + +#define FT_MEM_QNEW_ARRAY( ptr, count ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + sizeof ( *(ptr) ), \ + 0, \ + (FT_Long)(count), \ + NULL, \ + &error ) ) + +#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ + FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ + sizeof ( *(ptr) ), \ + (FT_Long)(cursz), \ + (FT_Long)(newsz), \ + (ptr), \ + &error ) ) + +#define FT_ALLOC( ptr, size ) \ + FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) ) + +#define FT_REALLOC( ptr, cursz, newsz ) \ + FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) ) + +#define FT_ALLOC_MULT( ptr, count, item_size ) \ + FT_MEM_SET_ERROR( FT_MEM_ALLOC_MULT( ptr, count, item_size ) ) + +#define FT_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_MEM_SET_ERROR( FT_MEM_REALLOC_MULT( ptr, oldcnt, \ + newcnt, itmsz ) ) + +#define FT_QALLOC( ptr, size ) \ + FT_MEM_SET_ERROR( FT_MEM_QALLOC( ptr, size ) ) + +#define FT_QREALLOC( ptr, cursz, newsz ) \ + FT_MEM_SET_ERROR( FT_MEM_QREALLOC( ptr, cursz, newsz ) ) + +#define FT_QALLOC_MULT( ptr, count, item_size ) \ + FT_MEM_SET_ERROR( FT_MEM_QALLOC_MULT( ptr, count, item_size ) ) + +#define FT_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ + FT_MEM_SET_ERROR( FT_MEM_QREALLOC_MULT( ptr, oldcnt, \ + newcnt, itmsz ) ) + +#define FT_FREE( ptr ) FT_MEM_FREE( ptr ) + +#define FT_NEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_NEW( ptr ) ) + +#define FT_NEW_ARRAY( ptr, count ) \ + FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) + +#define FT_RENEW_ARRAY( ptr, curcnt, newcnt ) \ + FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) + +#define FT_QNEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) ) + +#define FT_QNEW_ARRAY( ptr, count ) \ + FT_MEM_SET_ERROR( FT_MEM_QNEW_ARRAY( ptr, count ) ) + +#define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \ + FT_MEM_SET_ERROR( FT_MEM_QRENEW_ARRAY( ptr, curcnt, newcnt ) ) + + + FT_BASE( FT_Pointer ) + ft_mem_strdup( FT_Memory memory, + const char* str, + FT_Error *p_error ); + + FT_BASE( FT_Pointer ) + ft_mem_dup( FT_Memory memory, + const void* address, + FT_ULong size, + FT_Error *p_error ); + + +#define FT_MEM_STRDUP( dst, str ) \ + (dst) = (char*)ft_mem_strdup( memory, (const char*)(str), &error ) + +#define FT_STRDUP( dst, str ) \ + FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) ) + +#define FT_MEM_DUP( dst, address, size ) \ + FT_ASSIGNP_INNER( dst, ft_mem_dup( memory, \ + (address), \ + (FT_ULong)(size), \ + &error ) ) + +#define FT_DUP( dst, address, size ) \ + FT_MEM_SET_ERROR( FT_MEM_DUP( dst, address, size ) ) + + + /* Return >= 1 if a truncation occurs. */ + /* Return 0 if the source string fits the buffer. */ + /* This is *not* the same as strlcpy(). */ + FT_BASE( FT_Int ) + ft_mem_strcpyn( char* dst, + const char* src, + FT_ULong size ); + +#define FT_STRCPYN( dst, src, size ) \ + ft_mem_strcpyn( (char*)dst, (const char*)(src), (FT_ULong)(size) ) + + +FT_END_HEADER + +#endif /* FTMEMORY_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/otsvg.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/otsvg.h new file mode 100644 index 0000000000000000000000000000000000000000..85d2713757a03db0a28b16d3bf61712349990ebc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/otsvg.h @@ -0,0 +1,336 @@ +/**************************************************************************** + * + * otsvg.h + * + * Interface for OT-SVG support related things (specification). + * + * Copyright (C) 2022-2024 by + * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef OTSVG_H_ +#define OTSVG_H_ + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * svg_fonts + * + * @title: + * OpenType SVG Fonts + * + * @abstract: + * OT-SVG API between FreeType and an external SVG rendering library. + * + * @description: + * This section describes the four hooks necessary to render SVG + * 'documents' that are contained in an OpenType font's 'SVG~' table. + * + * For more information on the implementation, see our standard hooks + * based on 'librsvg' in the [FreeType Demo + * Programs](https://gitlab.freedesktop.org/freetype/freetype-demos) + * repository. + * + */ + + + /************************************************************************** + * + * @functype: + * SVG_Lib_Init_Func + * + * @description: + * A callback that is called when the first OT-SVG glyph is rendered in + * the lifetime of an @FT_Library object. In a typical implementation, + * one would want to allocate a structure and point the `data_pointer` + * to it and perform any library initializations that might be needed. + * + * @inout: + * data_pointer :: + * The SVG rendering module stores a pointer variable that can be used + * by clients to store any data that needs to be shared across + * different hooks. `data_pointer` is essentially a pointer to that + * pointer such that it can be written to as well as read from. + * + * @return: + * FreeType error code. 0 means success. + * + * @since: + * 2.12 + */ + typedef FT_Error + (*SVG_Lib_Init_Func)( FT_Pointer *data_pointer ); + + + /************************************************************************** + * + * @functype: + * SVG_Lib_Free_Func + * + * @description: + * A callback that is called when the `ot-svg` module is being freed. + * It is only called if the init hook was called earlier. This means + * that neither the init nor the free hook is called if no OT-SVG glyph + * is rendered. + * + * In a typical implementation, one would want to free any state + * structure that was allocated in the init hook and perform any + * library-related closure that might be needed. + * + * @inout: + * data_pointer :: + * The SVG rendering module stores a pointer variable that can be used + * by clients to store any data that needs to be shared across + * different hooks. `data_pointer` is essentially a pointer to that + * pointer such that it can be written to as well as read from. + * + * @since: + * 2.12 + */ + typedef void + (*SVG_Lib_Free_Func)( FT_Pointer *data_pointer ); + + + /************************************************************************** + * + * @functype: + * SVG_Lib_Render_Func + * + * @description: + * A callback that is called to render an OT-SVG glyph. This callback + * hook is called right after the preset hook @SVG_Lib_Preset_Slot_Func + * has been called with `cache` set to `TRUE`. The data necessary to + * render is available through the handle @FT_SVG_Document, which is set + * in the `other` field of @FT_GlyphSlotRec. + * + * The render hook is expected to render the SVG glyph to the bitmap + * buffer that is allocated already at `slot->bitmap.buffer`. It also + * sets the `num_grays` value as well as `slot->format`. + * + * @input: + * slot :: + * The slot to render. + * + * @inout: + * data_pointer :: + * The SVG rendering module stores a pointer variable that can be used + * by clients to store any data that needs to be shared across + * different hooks. `data_pointer` is essentially a pointer to that + * pointer such that it can be written to as well as read from. + * + * @return: + * FreeType error code. 0 means success. + * + * @since: + * 2.12 + */ + typedef FT_Error + (*SVG_Lib_Render_Func)( FT_GlyphSlot slot, + FT_Pointer *data_pointer ); + + + /************************************************************************** + * + * @functype: + * SVG_Lib_Preset_Slot_Func + * + * @description: + * A callback that is called to preset the glyph slot. It is called from + * two places. + * + * 1. When `FT_Load_Glyph` needs to preset the glyph slot. + * + * 2. Right before the `svg` module calls the render callback hook. + * + * When it is the former, the argument `cache` is set to `FALSE`. When + * it is the latter, the argument `cache` is set to `TRUE`. This + * distinction has been made because many calculations that are necessary + * for presetting a glyph slot are the same needed later for the render + * callback hook. Thus, if `cache` is `TRUE`, the hook can _cache_ those + * calculations in a memory block referenced by the state pointer. + * + * This hook is expected to preset the slot by setting parameters such as + * `bitmap_left`, `bitmap_top`, `width`, `rows`, `pitch`, and + * `pixel_mode`. It is also expected to set all the metrics for the slot + * including the vertical advance if it is not already set. Typically, + * fonts have horizontal advances but not vertical ones. If those are + * available, they had already been set, otherwise they have to be + * estimated and set manually. The hook must take into account the + * transformations that have been set, and translate the transformation + * matrices into the SVG coordinate system, as the original matrix is + * intended for the TTF/CFF coordinate system. + * + * @input: + * slot :: + * The glyph slot that has the SVG document loaded. + * + * cache :: + * See description. + * + * @inout: + * data_pointer :: + * The SVG rendering module stores a pointer variable that can be used + * by clients to store any data that needs to be shared across + * different hooks. `data_pointer` is essentially a pointer to that + * pointer such that it can be written to as well as read from. + * + * @return: + * FreeType error code. 0 means success. + * + * @since: + * 2.12 + */ + typedef FT_Error + (*SVG_Lib_Preset_Slot_Func)( FT_GlyphSlot slot, + FT_Bool cache, + FT_Pointer *state ); + + + /************************************************************************** + * + * @struct: + * SVG_RendererHooks + * + * @description: + * A structure that stores the four hooks needed to render OT-SVG glyphs + * properly. The structure is publicly used to set the hooks via the + * @svg-hooks driver property. + * + * The behavior of each hook is described in its documentation. One + * thing to note is that the preset hook and the render hook often need + * to do the same operations; therefore, it's better to cache the + * intermediate data in a state structure to avoid calculating it twice. + * For example, in the preset hook one can draw the glyph on a recorder + * surface and later create a bitmap surface from it in the render hook. + * + * All four hooks must be non-NULL. + * + * @fields: + * init_svg :: + * The initialization hook. + * + * free_svg :: + * The cleanup hook. + * + * render_hook :: + * The render hook. + * + * preset_slot :: + * The preset hook. + * + * @since: + * 2.12 + */ + typedef struct SVG_RendererHooks_ + { + SVG_Lib_Init_Func init_svg; + SVG_Lib_Free_Func free_svg; + SVG_Lib_Render_Func render_svg; + + SVG_Lib_Preset_Slot_Func preset_slot; + + } SVG_RendererHooks; + + + /************************************************************************** + * + * @struct: + * FT_SVG_DocumentRec + * + * @description: + * A structure that models one SVG document. + * + * @fields: + * svg_document :: + * A pointer to the SVG document. + * + * svg_document_length :: + * The length of `svg_document`. + * + * metrics :: + * A metrics object storing the size information. + * + * units_per_EM :: + * The size of the EM square. + * + * start_glyph_id :: + * The first glyph ID in the glyph range covered by this document. + * + * end_glyph_id :: + * The last glyph ID in the glyph range covered by this document. + * + * transform :: + * A 2x2 transformation matrix to apply to the glyph while rendering + * it. + * + * delta :: + * The translation to apply to the glyph while rendering. + * + * @note: + * When an @FT_GlyphSlot object `slot` is passed down to a renderer, the + * renderer can only access the `metrics` and `units_per_EM` fields via + * `slot->face`. However, when @FT_Glyph_To_Bitmap sets up a dummy + * object, it has no way to set a `face` object. Thus, metrics + * information and `units_per_EM` (which is necessary for OT-SVG) has to + * be stored separately. + * + * @since: + * 2.12 + */ + typedef struct FT_SVG_DocumentRec_ + { + FT_Byte* svg_document; + FT_ULong svg_document_length; + + FT_Size_Metrics metrics; + FT_UShort units_per_EM; + + FT_UShort start_glyph_id; + FT_UShort end_glyph_id; + + FT_Matrix transform; + FT_Vector delta; + + } FT_SVG_DocumentRec; + + + /************************************************************************** + * + * @type: + * FT_SVG_Document + * + * @description: + * A handle to an @FT_SVG_DocumentRec object. + * + * @since: + * 2.12 + */ + typedef struct FT_SVG_DocumentRec_* FT_SVG_Document; + + +FT_END_HEADER + +#endif /* OTSVG_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/t1tables.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/t1tables.h new file mode 100644 index 0000000000000000000000000000000000000000..1f7697552f15787c49efda834bda4e24112813f5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/t1tables.h @@ -0,0 +1,735 @@ +/**************************************************************************** + * + * t1tables.h + * + * Basic Type 1/Type 2 tables definitions and interface (specification + * only). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef T1TABLES_H_ +#define T1TABLES_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * type1_tables + * + * @title: + * Type 1 Tables + * + * @abstract: + * Type~1-specific font tables. + * + * @description: + * This section contains the definition of Type~1-specific tables, + * including structures related to other PostScript font formats. + * + * @order: + * PS_FontInfoRec + * PS_FontInfo + * PS_PrivateRec + * PS_Private + * + * CID_FaceDictRec + * CID_FaceDict + * CID_FaceInfoRec + * CID_FaceInfo + * + * FT_Has_PS_Glyph_Names + * FT_Get_PS_Font_Info + * FT_Get_PS_Font_Private + * FT_Get_PS_Font_Value + * + * T1_Blend_Flags + * T1_EncodingType + * PS_Dict_Keys + * + */ + + + /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */ + /* structures in order to support Multiple Master fonts. */ + + + /************************************************************************** + * + * @struct: + * PS_FontInfoRec + * + * @description: + * A structure used to model a Type~1 or Type~2 FontInfo dictionary. + * Note that for Multiple Master fonts, each instance has its own + * FontInfo dictionary. + */ + typedef struct PS_FontInfoRec_ + { + FT_String* version; + FT_String* notice; + FT_String* full_name; + FT_String* family_name; + FT_String* weight; + FT_Long italic_angle; + FT_Bool is_fixed_pitch; + FT_Short underline_position; + FT_UShort underline_thickness; + + } PS_FontInfoRec; + + + /************************************************************************** + * + * @struct: + * PS_FontInfo + * + * @description: + * A handle to a @PS_FontInfoRec structure. + */ + typedef struct PS_FontInfoRec_* PS_FontInfo; + + + /************************************************************************** + * + * @struct: + * T1_FontInfo + * + * @description: + * This type is equivalent to @PS_FontInfoRec. It is deprecated but kept + * to maintain source compatibility between various versions of FreeType. + */ + typedef PS_FontInfoRec T1_FontInfo; + + + /************************************************************************** + * + * @struct: + * PS_PrivateRec + * + * @description: + * A structure used to model a Type~1 or Type~2 private dictionary. Note + * that for Multiple Master fonts, each instance has its own Private + * dictionary. + */ + typedef struct PS_PrivateRec_ + { + FT_Int unique_id; + FT_Int lenIV; + + FT_Byte num_blue_values; + FT_Byte num_other_blues; + FT_Byte num_family_blues; + FT_Byte num_family_other_blues; + + FT_Short blue_values[14]; + FT_Short other_blues[10]; + + FT_Short family_blues [14]; + FT_Short family_other_blues[10]; + + FT_Fixed blue_scale; + FT_Int blue_shift; + FT_Int blue_fuzz; + + FT_UShort standard_width[1]; + FT_UShort standard_height[1]; + + FT_Byte num_snap_widths; + FT_Byte num_snap_heights; + FT_Bool force_bold; + FT_Bool round_stem_up; + + FT_Short snap_widths [13]; /* including std width */ + FT_Short snap_heights[13]; /* including std height */ + + FT_Fixed expansion_factor; + + FT_Long language_group; + FT_Long password; + + FT_Short min_feature[2]; + + } PS_PrivateRec; + + + /************************************************************************** + * + * @struct: + * PS_Private + * + * @description: + * A handle to a @PS_PrivateRec structure. + */ + typedef struct PS_PrivateRec_* PS_Private; + + + /************************************************************************** + * + * @struct: + * T1_Private + * + * @description: + * This type is equivalent to @PS_PrivateRec. It is deprecated but kept + * to maintain source compatibility between various versions of FreeType. + */ + typedef PS_PrivateRec T1_Private; + + + /************************************************************************** + * + * @enum: + * T1_Blend_Flags + * + * @description: + * A set of flags used to indicate which fields are present in a given + * blend dictionary (font info or private). Used to support Multiple + * Masters fonts. + * + * @values: + * T1_BLEND_UNDERLINE_POSITION :: + * T1_BLEND_UNDERLINE_THICKNESS :: + * T1_BLEND_ITALIC_ANGLE :: + * T1_BLEND_BLUE_VALUES :: + * T1_BLEND_OTHER_BLUES :: + * T1_BLEND_STANDARD_WIDTH :: + * T1_BLEND_STANDARD_HEIGHT :: + * T1_BLEND_STEM_SNAP_WIDTHS :: + * T1_BLEND_STEM_SNAP_HEIGHTS :: + * T1_BLEND_BLUE_SCALE :: + * T1_BLEND_BLUE_SHIFT :: + * T1_BLEND_FAMILY_BLUES :: + * T1_BLEND_FAMILY_OTHER_BLUES :: + * T1_BLEND_FORCE_BOLD :: + */ + typedef enum T1_Blend_Flags_ + { + /* required fields in a FontInfo blend dictionary */ + T1_BLEND_UNDERLINE_POSITION = 0, + T1_BLEND_UNDERLINE_THICKNESS, + T1_BLEND_ITALIC_ANGLE, + + /* required fields in a Private blend dictionary */ + T1_BLEND_BLUE_VALUES, + T1_BLEND_OTHER_BLUES, + T1_BLEND_STANDARD_WIDTH, + T1_BLEND_STANDARD_HEIGHT, + T1_BLEND_STEM_SNAP_WIDTHS, + T1_BLEND_STEM_SNAP_HEIGHTS, + T1_BLEND_BLUE_SCALE, + T1_BLEND_BLUE_SHIFT, + T1_BLEND_FAMILY_BLUES, + T1_BLEND_FAMILY_OTHER_BLUES, + T1_BLEND_FORCE_BOLD, + + T1_BLEND_MAX /* do not remove */ + + } T1_Blend_Flags; + + + /* these constants are deprecated; use the corresponding */ + /* `T1_Blend_Flags` values instead */ +#define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION +#define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS +#define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE +#define t1_blend_blue_values T1_BLEND_BLUE_VALUES +#define t1_blend_other_blues T1_BLEND_OTHER_BLUES +#define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH +#define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT +#define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS +#define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS +#define t1_blend_blue_scale T1_BLEND_BLUE_SCALE +#define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT +#define t1_blend_family_blues T1_BLEND_FAMILY_BLUES +#define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES +#define t1_blend_force_bold T1_BLEND_FORCE_BOLD +#define t1_blend_max T1_BLEND_MAX + + /* */ + + + /************************************************************************** + * + * @struct: + * CID_FaceDictRec + * + * @description: + * A structure used to represent data in a CID top-level dictionary. In + * most cases, they are part of the font's '/FDArray' array. Within a + * CID font file, such (internal) subfont dictionaries are enclosed by + * '%ADOBeginFontDict' and '%ADOEndFontDict' comments. + * + * Note that `CID_FaceDictRec` misses a field for the '/FontName' + * keyword, specifying the subfont's name (the top-level font name is + * given by the '/CIDFontName' keyword). This is an oversight, but it + * doesn't limit the 'cid' font module's functionality because FreeType + * neither needs this entry nor gives access to CID subfonts. + */ + typedef struct CID_FaceDictRec_ + { + PS_PrivateRec private_dict; + + FT_UInt len_buildchar; + FT_Fixed forcebold_threshold; + FT_Pos stroke_width; + FT_Fixed expansion_factor; /* this is a duplicate of */ + /* `private_dict->expansion_factor' */ + FT_Byte paint_type; + FT_Byte font_type; + FT_Matrix font_matrix; + FT_Vector font_offset; + + FT_UInt num_subrs; + FT_ULong subrmap_offset; + FT_UInt sd_bytes; + + } CID_FaceDictRec; + + + /************************************************************************** + * + * @struct: + * CID_FaceDict + * + * @description: + * A handle to a @CID_FaceDictRec structure. + */ + typedef struct CID_FaceDictRec_* CID_FaceDict; + + + /************************************************************************** + * + * @struct: + * CID_FontDict + * + * @description: + * This type is equivalent to @CID_FaceDictRec. It is deprecated but + * kept to maintain source compatibility between various versions of + * FreeType. + */ + typedef CID_FaceDictRec CID_FontDict; + + + /************************************************************************** + * + * @struct: + * CID_FaceInfoRec + * + * @description: + * A structure used to represent CID Face information. + */ + typedef struct CID_FaceInfoRec_ + { + FT_String* cid_font_name; + FT_Fixed cid_version; + FT_Int cid_font_type; + + FT_String* registry; + FT_String* ordering; + FT_Int supplement; + + PS_FontInfoRec font_info; + FT_BBox font_bbox; + FT_ULong uid_base; + + FT_Int num_xuid; + FT_ULong xuid[16]; + + FT_ULong cidmap_offset; + FT_UInt fd_bytes; + FT_UInt gd_bytes; + FT_ULong cid_count; + + FT_UInt num_dicts; + CID_FaceDict font_dicts; + + FT_ULong data_offset; + + } CID_FaceInfoRec; + + + /************************************************************************** + * + * @struct: + * CID_FaceInfo + * + * @description: + * A handle to a @CID_FaceInfoRec structure. + */ + typedef struct CID_FaceInfoRec_* CID_FaceInfo; + + + /************************************************************************** + * + * @struct: + * CID_Info + * + * @description: + * This type is equivalent to @CID_FaceInfoRec. It is deprecated but kept + * to maintain source compatibility between various versions of FreeType. + */ + typedef CID_FaceInfoRec CID_Info; + + + /************************************************************************** + * + * @function: + * FT_Has_PS_Glyph_Names + * + * @description: + * Return true if a given face provides reliable PostScript glyph names. + * This is similar to using the @FT_HAS_GLYPH_NAMES macro, except that + * certain fonts (mostly TrueType) contain incorrect glyph name tables. + * + * When this function returns true, the caller is sure that the glyph + * names returned by @FT_Get_Glyph_Name are reliable. + * + * @input: + * face :: + * face handle + * + * @return: + * Boolean. True if glyph names are reliable. + * + */ + FT_EXPORT( FT_Int ) + FT_Has_PS_Glyph_Names( FT_Face face ); + + + /************************************************************************** + * + * @function: + * FT_Get_PS_Font_Info + * + * @description: + * Retrieve the @PS_FontInfoRec structure corresponding to a given + * PostScript font. + * + * @input: + * face :: + * PostScript face handle. + * + * @output: + * afont_info :: + * A pointer to a @PS_FontInfoRec object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * String pointers within the @PS_FontInfoRec structure are owned by the + * face and don't need to be freed by the caller. Missing entries in the + * font's FontInfo dictionary are represented by `NULL` pointers. + * + * The following font formats support this feature: 'Type~1', 'Type~42', + * 'CFF', 'CID~Type~1'. For other font formats this function returns the + * `FT_Err_Invalid_Argument` error code. + * + * @example: + * ``` + * PS_FontInfoRec font_info; + * + * + * error = FT_Get_PS_Font_Info( face, &font_info ); + * ... + * ``` + * + */ + FT_EXPORT( FT_Error ) + FT_Get_PS_Font_Info( FT_Face face, + PS_FontInfo afont_info ); + + + /************************************************************************** + * + * @function: + * FT_Get_PS_Font_Private + * + * @description: + * Retrieve the @PS_PrivateRec structure corresponding to a given + * PostScript font. + * + * @input: + * face :: + * PostScript face handle. + * + * @output: + * afont_private :: + * A pointer to a @PS_PrivateRec object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The string pointers within the @PS_PrivateRec structure are owned by + * the face and don't need to be freed by the caller. + * + * Only the 'Type~1' font format supports this feature. For other font + * formats this function returns the `FT_Err_Invalid_Argument` error + * code. + * + * @example: + * ``` + * PS_PrivateRec font_private; + * + * + * error = FT_Get_PS_Font_Private( face, &font_private ); + * ... + * ``` + * + */ + FT_EXPORT( FT_Error ) + FT_Get_PS_Font_Private( FT_Face face, + PS_Private afont_private ); + + + /************************************************************************** + * + * @enum: + * T1_EncodingType + * + * @description: + * An enumeration describing the 'Encoding' entry in a Type 1 dictionary. + * + * @values: + * T1_ENCODING_TYPE_NONE :: + * T1_ENCODING_TYPE_ARRAY :: + * T1_ENCODING_TYPE_STANDARD :: + * T1_ENCODING_TYPE_ISOLATIN1 :: + * T1_ENCODING_TYPE_EXPERT :: + * + * @since: + * 2.4.8 + */ + typedef enum T1_EncodingType_ + { + T1_ENCODING_TYPE_NONE = 0, + T1_ENCODING_TYPE_ARRAY, + T1_ENCODING_TYPE_STANDARD, + T1_ENCODING_TYPE_ISOLATIN1, + T1_ENCODING_TYPE_EXPERT + + } T1_EncodingType; + + + /************************************************************************** + * + * @enum: + * PS_Dict_Keys + * + * @description: + * An enumeration used in calls to @FT_Get_PS_Font_Value to identify the + * Type~1 dictionary entry to retrieve. + * + * @values: + * PS_DICT_FONT_TYPE :: + * PS_DICT_FONT_MATRIX :: + * PS_DICT_FONT_BBOX :: + * PS_DICT_PAINT_TYPE :: + * PS_DICT_FONT_NAME :: + * PS_DICT_UNIQUE_ID :: + * PS_DICT_NUM_CHAR_STRINGS :: + * PS_DICT_CHAR_STRING_KEY :: + * PS_DICT_CHAR_STRING :: + * PS_DICT_ENCODING_TYPE :: + * PS_DICT_ENCODING_ENTRY :: + * PS_DICT_NUM_SUBRS :: + * PS_DICT_SUBR :: + * PS_DICT_STD_HW :: + * PS_DICT_STD_VW :: + * PS_DICT_NUM_BLUE_VALUES :: + * PS_DICT_BLUE_VALUE :: + * PS_DICT_BLUE_FUZZ :: + * PS_DICT_NUM_OTHER_BLUES :: + * PS_DICT_OTHER_BLUE :: + * PS_DICT_NUM_FAMILY_BLUES :: + * PS_DICT_FAMILY_BLUE :: + * PS_DICT_NUM_FAMILY_OTHER_BLUES :: + * PS_DICT_FAMILY_OTHER_BLUE :: + * PS_DICT_BLUE_SCALE :: + * PS_DICT_BLUE_SHIFT :: + * PS_DICT_NUM_STEM_SNAP_H :: + * PS_DICT_STEM_SNAP_H :: + * PS_DICT_NUM_STEM_SNAP_V :: + * PS_DICT_STEM_SNAP_V :: + * PS_DICT_FORCE_BOLD :: + * PS_DICT_RND_STEM_UP :: + * PS_DICT_MIN_FEATURE :: + * PS_DICT_LEN_IV :: + * PS_DICT_PASSWORD :: + * PS_DICT_LANGUAGE_GROUP :: + * PS_DICT_VERSION :: + * PS_DICT_NOTICE :: + * PS_DICT_FULL_NAME :: + * PS_DICT_FAMILY_NAME :: + * PS_DICT_WEIGHT :: + * PS_DICT_IS_FIXED_PITCH :: + * PS_DICT_UNDERLINE_POSITION :: + * PS_DICT_UNDERLINE_THICKNESS :: + * PS_DICT_FS_TYPE :: + * PS_DICT_ITALIC_ANGLE :: + * + * @since: + * 2.4.8 + */ + typedef enum PS_Dict_Keys_ + { + /* conventionally in the font dictionary */ + PS_DICT_FONT_TYPE, /* FT_Byte */ + PS_DICT_FONT_MATRIX, /* FT_Fixed */ + PS_DICT_FONT_BBOX, /* FT_Fixed */ + PS_DICT_PAINT_TYPE, /* FT_Byte */ + PS_DICT_FONT_NAME, /* FT_String* */ + PS_DICT_UNIQUE_ID, /* FT_Int */ + PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */ + PS_DICT_CHAR_STRING_KEY, /* FT_String* */ + PS_DICT_CHAR_STRING, /* FT_String* */ + PS_DICT_ENCODING_TYPE, /* T1_EncodingType */ + PS_DICT_ENCODING_ENTRY, /* FT_String* */ + + /* conventionally in the font Private dictionary */ + PS_DICT_NUM_SUBRS, /* FT_Int */ + PS_DICT_SUBR, /* FT_String* */ + PS_DICT_STD_HW, /* FT_UShort */ + PS_DICT_STD_VW, /* FT_UShort */ + PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */ + PS_DICT_BLUE_VALUE, /* FT_Short */ + PS_DICT_BLUE_FUZZ, /* FT_Int */ + PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */ + PS_DICT_OTHER_BLUE, /* FT_Short */ + PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */ + PS_DICT_FAMILY_BLUE, /* FT_Short */ + PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */ + PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */ + PS_DICT_BLUE_SCALE, /* FT_Fixed */ + PS_DICT_BLUE_SHIFT, /* FT_Int */ + PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */ + PS_DICT_STEM_SNAP_H, /* FT_Short */ + PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */ + PS_DICT_STEM_SNAP_V, /* FT_Short */ + PS_DICT_FORCE_BOLD, /* FT_Bool */ + PS_DICT_RND_STEM_UP, /* FT_Bool */ + PS_DICT_MIN_FEATURE, /* FT_Short */ + PS_DICT_LEN_IV, /* FT_Int */ + PS_DICT_PASSWORD, /* FT_Long */ + PS_DICT_LANGUAGE_GROUP, /* FT_Long */ + + /* conventionally in the font FontInfo dictionary */ + PS_DICT_VERSION, /* FT_String* */ + PS_DICT_NOTICE, /* FT_String* */ + PS_DICT_FULL_NAME, /* FT_String* */ + PS_DICT_FAMILY_NAME, /* FT_String* */ + PS_DICT_WEIGHT, /* FT_String* */ + PS_DICT_IS_FIXED_PITCH, /* FT_Bool */ + PS_DICT_UNDERLINE_POSITION, /* FT_Short */ + PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */ + PS_DICT_FS_TYPE, /* FT_UShort */ + PS_DICT_ITALIC_ANGLE, /* FT_Long */ + + PS_DICT_MAX = PS_DICT_ITALIC_ANGLE + + } PS_Dict_Keys; + + + /************************************************************************** + * + * @function: + * FT_Get_PS_Font_Value + * + * @description: + * Retrieve the value for the supplied key from a PostScript font. + * + * @input: + * face :: + * PostScript face handle. + * + * key :: + * An enumeration value representing the dictionary key to retrieve. + * + * idx :: + * For array values, this specifies the index to be returned. + * + * value :: + * A pointer to memory into which to write the value. + * + * valen_len :: + * The size, in bytes, of the memory supplied for the value. + * + * @output: + * value :: + * The value matching the above key, if it exists. + * + * @return: + * The amount of memory (in bytes) required to hold the requested value + * (if it exists, -1 otherwise). + * + * @note: + * The values returned are not pointers into the internal structures of + * the face, but are 'fresh' copies, so that the memory containing them + * belongs to the calling application. This also enforces the + * 'read-only' nature of these values, i.e., this function cannot be + * used to manipulate the face. + * + * `value` is a void pointer because the values returned can be of + * various types. + * + * If either `value` is `NULL` or `value_len` is too small, just the + * required memory size for the requested entry is returned. + * + * The `idx` parameter is used, not only to retrieve elements of, for + * example, the FontMatrix or FontBBox, but also to retrieve name keys + * from the CharStrings dictionary, and the charstrings themselves. It + * is ignored for atomic values. + * + * `PS_DICT_BLUE_SCALE` returns a value that is scaled up by 1000. To + * get the value as in the font stream, you need to divide by 65536000.0 + * (to remove the FT_Fixed scale, and the x1000 scale). + * + * IMPORTANT: Only key/value pairs read by the FreeType interpreter can + * be retrieved. So, for example, PostScript procedures such as NP, ND, + * and RD are not available. Arbitrary keys are, obviously, not be + * available either. + * + * If the font's format is not PostScript-based, this function returns + * the `FT_Err_Invalid_Argument` error code. + * + * @since: + * 2.4.8 + * + */ + FT_EXPORT( FT_Long ) + FT_Get_PS_Font_Value( FT_Face face, + PS_Dict_Keys key, + FT_UInt idx, + void *value, + FT_Long value_len ); + + /* */ + +FT_END_HEADER + +#endif /* T1TABLES_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ttnameid.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ttnameid.h new file mode 100644 index 0000000000000000000000000000000000000000..499c9c42566b50456a82db999c3f4a595b82fc2e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/ttnameid.h @@ -0,0 +1,1235 @@ +/**************************************************************************** + * + * ttnameid.h + * + * TrueType name ID definitions (specification only). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef TTNAMEID_H_ +#define TTNAMEID_H_ + + + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * truetype_tables + */ + + + /************************************************************************** + * + * Possible values for the 'platform' identifier code in the name records + * of an SFNT 'name' table. + * + */ + + + /************************************************************************** + * + * @enum: + * TT_PLATFORM_XXX + * + * @description: + * A list of valid values for the `platform_id` identifier code in + * @FT_CharMapRec and @FT_SfntName structures. + * + * @values: + * TT_PLATFORM_APPLE_UNICODE :: + * Used by Apple to indicate a Unicode character map and/or name entry. + * See @TT_APPLE_ID_XXX for corresponding `encoding_id` values. Note + * that name entries in this format are coded as big-endian UCS-2 + * character codes _only_. + * + * TT_PLATFORM_MACINTOSH :: + * Used by Apple to indicate a MacOS-specific charmap and/or name + * entry. See @TT_MAC_ID_XXX for corresponding `encoding_id` values. + * Note that most TrueType fonts contain an Apple roman charmap to be + * usable on MacOS systems (even if they contain a Microsoft charmap as + * well). + * + * TT_PLATFORM_ISO :: + * This value was used to specify ISO/IEC 10646 charmaps. It is + * however now deprecated. See @TT_ISO_ID_XXX for a list of + * corresponding `encoding_id` values. + * + * TT_PLATFORM_MICROSOFT :: + * Used by Microsoft to indicate Windows-specific charmaps. See + * @TT_MS_ID_XXX for a list of corresponding `encoding_id` values. + * Note that most fonts contain a Unicode charmap using + * (`TT_PLATFORM_MICROSOFT`, @TT_MS_ID_UNICODE_CS). + * + * TT_PLATFORM_CUSTOM :: + * Used to indicate application-specific charmaps. + * + * TT_PLATFORM_ADOBE :: + * This value isn't part of any font format specification, but is used + * by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec + * structure. See @TT_ADOBE_ID_XXX. + */ + +#define TT_PLATFORM_APPLE_UNICODE 0 +#define TT_PLATFORM_MACINTOSH 1 +#define TT_PLATFORM_ISO 2 /* deprecated */ +#define TT_PLATFORM_MICROSOFT 3 +#define TT_PLATFORM_CUSTOM 4 +#define TT_PLATFORM_ADOBE 7 /* artificial */ + + + /************************************************************************** + * + * @enum: + * TT_APPLE_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id` for + * @TT_PLATFORM_APPLE_UNICODE charmaps and name entries. + * + * @values: + * TT_APPLE_ID_DEFAULT :: + * Unicode version 1.0. + * + * TT_APPLE_ID_UNICODE_1_1 :: + * Unicode 1.1; specifies Hangul characters starting at U+34xx. + * + * TT_APPLE_ID_ISO_10646 :: + * Deprecated (identical to preceding). + * + * TT_APPLE_ID_UNICODE_2_0 :: + * Unicode 2.0 and beyond (UTF-16 BMP only). + * + * TT_APPLE_ID_UNICODE_32 :: + * Unicode 3.1 and beyond, using UTF-32. + * + * TT_APPLE_ID_VARIANT_SELECTOR :: + * From Adobe, not Apple. Not a normal cmap. Specifies variations on + * a real cmap. + * + * TT_APPLE_ID_FULL_UNICODE :: + * Used for fallback fonts that provide complete Unicode coverage with + * a type~13 cmap. + */ + +#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */ +#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */ +#define TT_APPLE_ID_ISO_10646 2 /* deprecated */ +#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */ +#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */ +#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */ +#define TT_APPLE_ID_FULL_UNICODE 6 /* used with type 13 cmaps */ + + + /************************************************************************** + * + * @enum: + * TT_MAC_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id` for + * @TT_PLATFORM_MACINTOSH charmaps and name entries. + */ + +#define TT_MAC_ID_ROMAN 0 +#define TT_MAC_ID_JAPANESE 1 +#define TT_MAC_ID_TRADITIONAL_CHINESE 2 +#define TT_MAC_ID_KOREAN 3 +#define TT_MAC_ID_ARABIC 4 +#define TT_MAC_ID_HEBREW 5 +#define TT_MAC_ID_GREEK 6 +#define TT_MAC_ID_RUSSIAN 7 +#define TT_MAC_ID_RSYMBOL 8 +#define TT_MAC_ID_DEVANAGARI 9 +#define TT_MAC_ID_GURMUKHI 10 +#define TT_MAC_ID_GUJARATI 11 +#define TT_MAC_ID_ORIYA 12 +#define TT_MAC_ID_BENGALI 13 +#define TT_MAC_ID_TAMIL 14 +#define TT_MAC_ID_TELUGU 15 +#define TT_MAC_ID_KANNADA 16 +#define TT_MAC_ID_MALAYALAM 17 +#define TT_MAC_ID_SINHALESE 18 +#define TT_MAC_ID_BURMESE 19 +#define TT_MAC_ID_KHMER 20 +#define TT_MAC_ID_THAI 21 +#define TT_MAC_ID_LAOTIAN 22 +#define TT_MAC_ID_GEORGIAN 23 +#define TT_MAC_ID_ARMENIAN 24 +#define TT_MAC_ID_MALDIVIAN 25 +#define TT_MAC_ID_SIMPLIFIED_CHINESE 25 +#define TT_MAC_ID_TIBETAN 26 +#define TT_MAC_ID_MONGOLIAN 27 +#define TT_MAC_ID_GEEZ 28 +#define TT_MAC_ID_SLAVIC 29 +#define TT_MAC_ID_VIETNAMESE 30 +#define TT_MAC_ID_SINDHI 31 +#define TT_MAC_ID_UNINTERP 32 + + + /************************************************************************** + * + * @enum: + * TT_ISO_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id` for @TT_PLATFORM_ISO + * charmaps and name entries. + * + * Their use is now deprecated. + * + * @values: + * TT_ISO_ID_7BIT_ASCII :: + * ASCII. + * TT_ISO_ID_10646 :: + * ISO/10646. + * TT_ISO_ID_8859_1 :: + * Also known as Latin-1. + */ + +#define TT_ISO_ID_7BIT_ASCII 0 +#define TT_ISO_ID_10646 1 +#define TT_ISO_ID_8859_1 2 + + + /************************************************************************** + * + * @enum: + * TT_MS_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id` for + * @TT_PLATFORM_MICROSOFT charmaps and name entries. + * + * @values: + * TT_MS_ID_SYMBOL_CS :: + * Microsoft symbol encoding. See @FT_ENCODING_MS_SYMBOL. + * + * TT_MS_ID_UNICODE_CS :: + * Microsoft WGL4 charmap, matching Unicode. See @FT_ENCODING_UNICODE. + * + * TT_MS_ID_SJIS :: + * Shift JIS Japanese encoding. See @FT_ENCODING_SJIS. + * + * TT_MS_ID_PRC :: + * Chinese encodings as used in the People's Republic of China (PRC). + * This means the encodings GB~2312 and its supersets GBK and GB~18030. + * See @FT_ENCODING_PRC. + * + * TT_MS_ID_BIG_5 :: + * Traditional Chinese as used in Taiwan and Hong Kong. See + * @FT_ENCODING_BIG5. + * + * TT_MS_ID_WANSUNG :: + * Korean Extended Wansung encoding. See @FT_ENCODING_WANSUNG. + * + * TT_MS_ID_JOHAB :: + * Korean Johab encoding. See @FT_ENCODING_JOHAB. + * + * TT_MS_ID_UCS_4 :: + * UCS-4 or UTF-32 charmaps. This has been added to the OpenType + * specification version 1.4 (mid-2001). + */ + +#define TT_MS_ID_SYMBOL_CS 0 +#define TT_MS_ID_UNICODE_CS 1 +#define TT_MS_ID_SJIS 2 +#define TT_MS_ID_PRC 3 +#define TT_MS_ID_BIG_5 4 +#define TT_MS_ID_WANSUNG 5 +#define TT_MS_ID_JOHAB 6 +#define TT_MS_ID_UCS_4 10 + + /* this value is deprecated */ +#define TT_MS_ID_GB2312 TT_MS_ID_PRC + + + /************************************************************************** + * + * @enum: + * TT_ADOBE_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id` for @TT_PLATFORM_ADOBE + * charmaps. This is a FreeType-specific extension! + * + * @values: + * TT_ADOBE_ID_STANDARD :: + * Adobe standard encoding. + * TT_ADOBE_ID_EXPERT :: + * Adobe expert encoding. + * TT_ADOBE_ID_CUSTOM :: + * Adobe custom encoding. + * TT_ADOBE_ID_LATIN_1 :: + * Adobe Latin~1 encoding. + */ + +#define TT_ADOBE_ID_STANDARD 0 +#define TT_ADOBE_ID_EXPERT 1 +#define TT_ADOBE_ID_CUSTOM 2 +#define TT_ADOBE_ID_LATIN_1 3 + + + /************************************************************************** + * + * @enum: + * TT_MAC_LANGID_XXX + * + * @description: + * Possible values of the language identifier field in the name records + * of the SFNT 'name' table if the 'platform' identifier code is + * @TT_PLATFORM_MACINTOSH. These values are also used as return values + * for function @FT_Get_CMap_Language_ID. + * + * The canonical source for Apple's IDs is + * + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html + */ + +#define TT_MAC_LANGID_ENGLISH 0 +#define TT_MAC_LANGID_FRENCH 1 +#define TT_MAC_LANGID_GERMAN 2 +#define TT_MAC_LANGID_ITALIAN 3 +#define TT_MAC_LANGID_DUTCH 4 +#define TT_MAC_LANGID_SWEDISH 5 +#define TT_MAC_LANGID_SPANISH 6 +#define TT_MAC_LANGID_DANISH 7 +#define TT_MAC_LANGID_PORTUGUESE 8 +#define TT_MAC_LANGID_NORWEGIAN 9 +#define TT_MAC_LANGID_HEBREW 10 +#define TT_MAC_LANGID_JAPANESE 11 +#define TT_MAC_LANGID_ARABIC 12 +#define TT_MAC_LANGID_FINNISH 13 +#define TT_MAC_LANGID_GREEK 14 +#define TT_MAC_LANGID_ICELANDIC 15 +#define TT_MAC_LANGID_MALTESE 16 +#define TT_MAC_LANGID_TURKISH 17 +#define TT_MAC_LANGID_CROATIAN 18 +#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19 +#define TT_MAC_LANGID_URDU 20 +#define TT_MAC_LANGID_HINDI 21 +#define TT_MAC_LANGID_THAI 22 +#define TT_MAC_LANGID_KOREAN 23 +#define TT_MAC_LANGID_LITHUANIAN 24 +#define TT_MAC_LANGID_POLISH 25 +#define TT_MAC_LANGID_HUNGARIAN 26 +#define TT_MAC_LANGID_ESTONIAN 27 +#define TT_MAC_LANGID_LETTISH 28 +#define TT_MAC_LANGID_SAAMISK 29 +#define TT_MAC_LANGID_FAEROESE 30 +#define TT_MAC_LANGID_FARSI 31 +#define TT_MAC_LANGID_RUSSIAN 32 +#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33 +#define TT_MAC_LANGID_FLEMISH 34 +#define TT_MAC_LANGID_IRISH 35 +#define TT_MAC_LANGID_ALBANIAN 36 +#define TT_MAC_LANGID_ROMANIAN 37 +#define TT_MAC_LANGID_CZECH 38 +#define TT_MAC_LANGID_SLOVAK 39 +#define TT_MAC_LANGID_SLOVENIAN 40 +#define TT_MAC_LANGID_YIDDISH 41 +#define TT_MAC_LANGID_SERBIAN 42 +#define TT_MAC_LANGID_MACEDONIAN 43 +#define TT_MAC_LANGID_BULGARIAN 44 +#define TT_MAC_LANGID_UKRAINIAN 45 +#define TT_MAC_LANGID_BYELORUSSIAN 46 +#define TT_MAC_LANGID_UZBEK 47 +#define TT_MAC_LANGID_KAZAKH 48 +#define TT_MAC_LANGID_AZERBAIJANI 49 +#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49 +#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50 +#define TT_MAC_LANGID_ARMENIAN 51 +#define TT_MAC_LANGID_GEORGIAN 52 +#define TT_MAC_LANGID_MOLDAVIAN 53 +#define TT_MAC_LANGID_KIRGHIZ 54 +#define TT_MAC_LANGID_TAJIKI 55 +#define TT_MAC_LANGID_TURKMEN 56 +#define TT_MAC_LANGID_MONGOLIAN 57 +#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57 +#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58 +#define TT_MAC_LANGID_PASHTO 59 +#define TT_MAC_LANGID_KURDISH 60 +#define TT_MAC_LANGID_KASHMIRI 61 +#define TT_MAC_LANGID_SINDHI 62 +#define TT_MAC_LANGID_TIBETAN 63 +#define TT_MAC_LANGID_NEPALI 64 +#define TT_MAC_LANGID_SANSKRIT 65 +#define TT_MAC_LANGID_MARATHI 66 +#define TT_MAC_LANGID_BENGALI 67 +#define TT_MAC_LANGID_ASSAMESE 68 +#define TT_MAC_LANGID_GUJARATI 69 +#define TT_MAC_LANGID_PUNJABI 70 +#define TT_MAC_LANGID_ORIYA 71 +#define TT_MAC_LANGID_MALAYALAM 72 +#define TT_MAC_LANGID_KANNADA 73 +#define TT_MAC_LANGID_TAMIL 74 +#define TT_MAC_LANGID_TELUGU 75 +#define TT_MAC_LANGID_SINHALESE 76 +#define TT_MAC_LANGID_BURMESE 77 +#define TT_MAC_LANGID_KHMER 78 +#define TT_MAC_LANGID_LAO 79 +#define TT_MAC_LANGID_VIETNAMESE 80 +#define TT_MAC_LANGID_INDONESIAN 81 +#define TT_MAC_LANGID_TAGALOG 82 +#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83 +#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84 +#define TT_MAC_LANGID_AMHARIC 85 +#define TT_MAC_LANGID_TIGRINYA 86 +#define TT_MAC_LANGID_GALLA 87 +#define TT_MAC_LANGID_SOMALI 88 +#define TT_MAC_LANGID_SWAHILI 89 +#define TT_MAC_LANGID_RUANDA 90 +#define TT_MAC_LANGID_RUNDI 91 +#define TT_MAC_LANGID_CHEWA 92 +#define TT_MAC_LANGID_MALAGASY 93 +#define TT_MAC_LANGID_ESPERANTO 94 +#define TT_MAC_LANGID_WELSH 128 +#define TT_MAC_LANGID_BASQUE 129 +#define TT_MAC_LANGID_CATALAN 130 +#define TT_MAC_LANGID_LATIN 131 +#define TT_MAC_LANGID_QUECHUA 132 +#define TT_MAC_LANGID_GUARANI 133 +#define TT_MAC_LANGID_AYMARA 134 +#define TT_MAC_LANGID_TATAR 135 +#define TT_MAC_LANGID_UIGHUR 136 +#define TT_MAC_LANGID_DZONGKHA 137 +#define TT_MAC_LANGID_JAVANESE 138 +#define TT_MAC_LANGID_SUNDANESE 139 + + /* The following codes are new as of 2000-03-10 */ +#define TT_MAC_LANGID_GALICIAN 140 +#define TT_MAC_LANGID_AFRIKAANS 141 +#define TT_MAC_LANGID_BRETON 142 +#define TT_MAC_LANGID_INUKTITUT 143 +#define TT_MAC_LANGID_SCOTTISH_GAELIC 144 +#define TT_MAC_LANGID_MANX_GAELIC 145 +#define TT_MAC_LANGID_IRISH_GAELIC 146 +#define TT_MAC_LANGID_TONGAN 147 +#define TT_MAC_LANGID_GREEK_POLYTONIC 148 +#define TT_MAC_LANGID_GREELANDIC 149 +#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150 + + + /************************************************************************** + * + * @enum: + * TT_MS_LANGID_XXX + * + * @description: + * Possible values of the language identifier field in the name records + * of the SFNT 'name' table if the 'platform' identifier code is + * @TT_PLATFORM_MICROSOFT. These values are also used as return values + * for function @FT_Get_CMap_Language_ID. + * + * The canonical source for Microsoft's IDs is + * + * https://docs.microsoft.com/en-us/windows/desktop/Intl/language-identifier-constants-and-strings , + * + * however, we only provide macros for language identifiers present in + * the OpenType specification: Microsoft has abandoned the concept of + * LCIDs (language code identifiers), and format~1 of the 'name' table + * provides a better mechanism for languages not covered here. + * + * More legacy values not listed in the reference can be found in the + * @FT_TRUETYPE_IDS_H header file. + */ + +#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401 +#define TT_MS_LANGID_ARABIC_IRAQ 0x0801 +#define TT_MS_LANGID_ARABIC_EGYPT 0x0C01 +#define TT_MS_LANGID_ARABIC_LIBYA 0x1001 +#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401 +#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801 +#define TT_MS_LANGID_ARABIC_TUNISIA 0x1C01 +#define TT_MS_LANGID_ARABIC_OMAN 0x2001 +#define TT_MS_LANGID_ARABIC_YEMEN 0x2401 +#define TT_MS_LANGID_ARABIC_SYRIA 0x2801 +#define TT_MS_LANGID_ARABIC_JORDAN 0x2C01 +#define TT_MS_LANGID_ARABIC_LEBANON 0x3001 +#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401 +#define TT_MS_LANGID_ARABIC_UAE 0x3801 +#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3C01 +#define TT_MS_LANGID_ARABIC_QATAR 0x4001 +#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402 +#define TT_MS_LANGID_CATALAN_CATALAN 0x0403 +#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404 +#define TT_MS_LANGID_CHINESE_PRC 0x0804 +#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0C04 +#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004 +#define TT_MS_LANGID_CHINESE_MACAO 0x1404 +#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405 +#define TT_MS_LANGID_DANISH_DENMARK 0x0406 +#define TT_MS_LANGID_GERMAN_GERMANY 0x0407 +#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807 +#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0C07 +#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007 +#define TT_MS_LANGID_GERMAN_LIECHTENSTEIN 0x1407 +#define TT_MS_LANGID_GREEK_GREECE 0x0408 +#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409 +#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809 +#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0C09 +#define TT_MS_LANGID_ENGLISH_CANADA 0x1009 +#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409 +#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809 +#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1C09 +#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009 +#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409 +#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809 +#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2C09 +#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009 +#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409 +#define TT_MS_LANGID_ENGLISH_INDIA 0x4009 +#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409 +#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809 +#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040A +#define TT_MS_LANGID_SPANISH_MEXICO 0x080A +#define TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT 0x0C0A +#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100A +#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140A +#define TT_MS_LANGID_SPANISH_PANAMA 0x180A +#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1C0A +#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200A +#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240A +#define TT_MS_LANGID_SPANISH_PERU 0x280A +#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2C0A +#define TT_MS_LANGID_SPANISH_ECUADOR 0x300A +#define TT_MS_LANGID_SPANISH_CHILE 0x340A +#define TT_MS_LANGID_SPANISH_URUGUAY 0x380A +#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3C0A +#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400A +#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440A +#define TT_MS_LANGID_SPANISH_HONDURAS 0x480A +#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4C0A +#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500A +#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540A +#define TT_MS_LANGID_FINNISH_FINLAND 0x040B +#define TT_MS_LANGID_FRENCH_FRANCE 0x040C +#define TT_MS_LANGID_FRENCH_BELGIUM 0x080C +#define TT_MS_LANGID_FRENCH_CANADA 0x0C0C +#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100C +#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140C +#define TT_MS_LANGID_FRENCH_MONACO 0x180C +#define TT_MS_LANGID_HEBREW_ISRAEL 0x040D +#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040E +#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040F +#define TT_MS_LANGID_ITALIAN_ITALY 0x0410 +#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810 +#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411 +#define TT_MS_LANGID_KOREAN_KOREA 0x0412 +#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413 +#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814 +#define TT_MS_LANGID_POLISH_POLAND 0x0415 +#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416 +#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816 +#define TT_MS_LANGID_ROMANSH_SWITZERLAND 0x0417 +#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418 +#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419 +#define TT_MS_LANGID_CROATIAN_CROATIA 0x041A +#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081A +#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0C1A +#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101A +#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141A +#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181A +#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x1C1A +#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZ_CYRILLIC 0x201A +#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041B +#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041C +#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041D +#define TT_MS_LANGID_SWEDISH_FINLAND 0x081D +#define TT_MS_LANGID_THAI_THAILAND 0x041E +#define TT_MS_LANGID_TURKISH_TURKEY 0x041F +#define TT_MS_LANGID_URDU_PAKISTAN 0x0420 +#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421 +#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422 +#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423 +#define TT_MS_LANGID_SLOVENIAN_SLOVENIA 0x0424 +#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425 +#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426 +#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427 +#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428 +#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042A +#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042B +#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042C +#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082C +#define TT_MS_LANGID_BASQUE_BASQUE 0x042D +#define TT_MS_LANGID_UPPER_SORBIAN_GERMANY 0x042E +#define TT_MS_LANGID_LOWER_SORBIAN_GERMANY 0x082E +#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042F +#define TT_MS_LANGID_SETSWANA_SOUTH_AFRICA 0x0432 +#define TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA 0x0434 +#define TT_MS_LANGID_ISIZULU_SOUTH_AFRICA 0x0435 +#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436 +#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437 +#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438 +#define TT_MS_LANGID_HINDI_INDIA 0x0439 +#define TT_MS_LANGID_MALTESE_MALTA 0x043A +#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY 0x043B +#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN 0x083B +#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND 0x0C3B +#define TT_MS_LANGID_SAMI_LULE_NORWAY 0x103B +#define TT_MS_LANGID_SAMI_LULE_SWEDEN 0x143B +#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY 0x183B +#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN 0x1C3B +#define TT_MS_LANGID_SAMI_SKOLT_FINLAND 0x203B +#define TT_MS_LANGID_SAMI_INARI_FINLAND 0x243B +#define TT_MS_LANGID_IRISH_IRELAND 0x083C +#define TT_MS_LANGID_MALAY_MALAYSIA 0x043E +#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083E +#define TT_MS_LANGID_KAZAKH_KAZAKHSTAN 0x043F +#define TT_MS_LANGID_KYRGYZ_KYRGYZSTAN /* Cyrillic */ 0x0440 +#define TT_MS_LANGID_KISWAHILI_KENYA 0x0441 +#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843 +#define TT_MS_LANGID_TATAR_RUSSIA 0x0444 +#define TT_MS_LANGID_BENGALI_INDIA 0x0445 +#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845 +#define TT_MS_LANGID_PUNJABI_INDIA 0x0446 +#define TT_MS_LANGID_GUJARATI_INDIA 0x0447 +#define TT_MS_LANGID_ODIA_INDIA 0x0448 +#define TT_MS_LANGID_TAMIL_INDIA 0x0449 +#define TT_MS_LANGID_TELUGU_INDIA 0x044A +#define TT_MS_LANGID_KANNADA_INDIA 0x044B +#define TT_MS_LANGID_MALAYALAM_INDIA 0x044C +#define TT_MS_LANGID_ASSAMESE_INDIA 0x044D +#define TT_MS_LANGID_MARATHI_INDIA 0x044E +#define TT_MS_LANGID_SANSKRIT_INDIA 0x044F +#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450 +#define TT_MS_LANGID_MONGOLIAN_PRC 0x0850 +#define TT_MS_LANGID_TIBETAN_PRC 0x0451 +#define TT_MS_LANGID_WELSH_UNITED_KINGDOM 0x0452 +#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453 +#define TT_MS_LANGID_LAO_LAOS 0x0454 +#define TT_MS_LANGID_GALICIAN_GALICIAN 0x0456 +#define TT_MS_LANGID_KONKANI_INDIA 0x0457 +#define TT_MS_LANGID_SYRIAC_SYRIA 0x045A +#define TT_MS_LANGID_SINHALA_SRI_LANKA 0x045B +#define TT_MS_LANGID_INUKTITUT_CANADA 0x045D +#define TT_MS_LANGID_INUKTITUT_CANADA_LATIN 0x085D +#define TT_MS_LANGID_AMHARIC_ETHIOPIA 0x045E +#define TT_MS_LANGID_TAMAZIGHT_ALGERIA 0x085F +#define TT_MS_LANGID_NEPALI_NEPAL 0x0461 +#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462 +#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463 +#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464 +#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465 +#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468 +#define TT_MS_LANGID_YORUBA_NIGERIA 0x046A +#define TT_MS_LANGID_QUECHUA_BOLIVIA 0x046B +#define TT_MS_LANGID_QUECHUA_ECUADOR 0x086B +#define TT_MS_LANGID_QUECHUA_PERU 0x0C6B +#define TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA 0x046C +#define TT_MS_LANGID_BASHKIR_RUSSIA 0x046D +#define TT_MS_LANGID_LUXEMBOURGISH_LUXEMBOURG 0x046E +#define TT_MS_LANGID_GREENLANDIC_GREENLAND 0x046F +#define TT_MS_LANGID_IGBO_NIGERIA 0x0470 +#define TT_MS_LANGID_YI_PRC 0x0478 +#define TT_MS_LANGID_MAPUDUNGUN_CHILE 0x047A +#define TT_MS_LANGID_MOHAWK_MOHAWK 0x047C +#define TT_MS_LANGID_BRETON_FRANCE 0x047E +#define TT_MS_LANGID_UIGHUR_PRC 0x0480 +#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481 +#define TT_MS_LANGID_OCCITAN_FRANCE 0x0482 +#define TT_MS_LANGID_CORSICAN_FRANCE 0x0483 +#define TT_MS_LANGID_ALSATIAN_FRANCE 0x0484 +#define TT_MS_LANGID_YAKUT_RUSSIA 0x0485 +#define TT_MS_LANGID_KICHE_GUATEMALA 0x0486 +#define TT_MS_LANGID_KINYARWANDA_RWANDA 0x0487 +#define TT_MS_LANGID_WOLOF_SENEGAL 0x0488 +#define TT_MS_LANGID_DARI_AFGHANISTAN 0x048C + + /* */ + + + /* legacy macro definitions not present in OpenType 1.8.1 */ +#define TT_MS_LANGID_ARABIC_GENERAL 0x0001 +#define TT_MS_LANGID_CATALAN_SPAIN \ + TT_MS_LANGID_CATALAN_CATALAN +#define TT_MS_LANGID_CHINESE_GENERAL 0x0004 +#define TT_MS_LANGID_CHINESE_MACAU \ + TT_MS_LANGID_CHINESE_MACAO +#define TT_MS_LANGID_GERMAN_LIECHTENSTEI \ + TT_MS_LANGID_GERMAN_LIECHTENSTEIN +#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009 +#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809 +#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3C09 +#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT \ + TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT +#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40AU +#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1C0C +#define TT_MS_LANGID_FRENCH_REUNION 0x200C +#define TT_MS_LANGID_FRENCH_CONGO 0x240C + /* which was formerly: */ +#define TT_MS_LANGID_FRENCH_ZAIRE \ + TT_MS_LANGID_FRENCH_CONGO +#define TT_MS_LANGID_FRENCH_SENEGAL 0x280C +#define TT_MS_LANGID_FRENCH_CAMEROON 0x2C0C +#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300C +#define TT_MS_LANGID_FRENCH_MALI 0x340C +#define TT_MS_LANGID_FRENCH_MOROCCO 0x380C +#define TT_MS_LANGID_FRENCH_HAITI 0x3C0C +#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40CU +#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA \ + TT_MS_LANGID_KOREAN_KOREA +#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 +#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND \ + TT_MS_LANGID_ROMANSH_SWITZERLAND +#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818 +#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819 +#define TT_MS_LANGID_URDU_INDIA 0x0820 +#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827 +#define TT_MS_LANGID_SLOVENE_SLOVENIA \ + TT_MS_LANGID_SLOVENIAN_SLOVENIA +#define TT_MS_LANGID_FARSI_IRAN 0x0429 +#define TT_MS_LANGID_BASQUE_SPAIN \ + TT_MS_LANGID_BASQUE_BASQUE +#define TT_MS_LANGID_SORBIAN_GERMANY \ + TT_MS_LANGID_UPPER_SORBIAN_GERMANY +#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430 +#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431 +#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA \ + TT_MS_LANGID_SETSWANA_SOUTH_AFRICA +#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 +#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA \ + TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA +#define TT_MS_LANGID_ZULU_SOUTH_AFRICA \ + TT_MS_LANGID_ISIZULU_SOUTH_AFRICA +#define TT_MS_LANGID_SAAMI_LAPONIA 0x043B + /* the next two values are incorrectly inverted */ +#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C +#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C +#define TT_MS_LANGID_YIDDISH_GERMANY 0x043D +#define TT_MS_LANGID_KAZAK_KAZAKSTAN \ + TT_MS_LANGID_KAZAKH_KAZAKHSTAN +#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \ + TT_MS_LANGID_KYRGYZ_KYRGYZSTAN +#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN \ + TT_MS_LANGID_KYRGYZ_KYRGYZSTAN +#define TT_MS_LANGID_SWAHILI_KENYA \ + TT_MS_LANGID_KISWAHILI_KENYA +#define TT_MS_LANGID_TATAR_TATARSTAN \ + TT_MS_LANGID_TATAR_RUSSIA +#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846 +#define TT_MS_LANGID_ORIYA_INDIA \ + TT_MS_LANGID_ODIA_INDIA +#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN \ + TT_MS_LANGID_MONGOLIAN_PRC +#define TT_MS_LANGID_TIBETAN_CHINA \ + TT_MS_LANGID_TIBETAN_PRC +#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851 +#define TT_MS_LANGID_TIBETAN_BHUTAN \ + TT_MS_LANGID_DZONGHKA_BHUTAN +#define TT_MS_LANGID_WELSH_WALES \ + TT_MS_LANGID_WELSH_UNITED_KINGDOM +#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455 +#define TT_MS_LANGID_GALICIAN_SPAIN \ + TT_MS_LANGID_GALICIAN_GALICIAN +#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458 +#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459 +#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859 +#define TT_MS_LANGID_SINHALESE_SRI_LANKA \ + TT_MS_LANGID_SINHALA_SRI_LANKA +#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045C +#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045F +#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN \ + TT_MS_LANGID_TAMAZIGHT_ALGERIA +#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460 +#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860 +#define TT_MS_LANGID_KASHMIRI_INDIA \ + TT_MS_LANGID_KASHMIRI_SASIA +#define TT_MS_LANGID_NEPALI_INDIA 0x0861 +#define TT_MS_LANGID_DIVEHI_MALDIVES \ + TT_MS_LANGID_DHIVEHI_MALDIVES +#define TT_MS_LANGID_EDO_NIGERIA 0x0466 +#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467 +#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469 +#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA \ + TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA +#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \ + TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA +#define TT_MS_LANGID_KANURI_NIGERIA 0x0471 +#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472 +#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473 +#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873 +#define TT_MS_LANGID_TIGRIGNA_ERYTREA \ + TT_MS_LANGID_TIGRIGNA_ERYTHREA +#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474 +#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475 +#define TT_MS_LANGID_LATIN 0x0476 +#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477 +#define TT_MS_LANGID_YI_CHINA \ + TT_MS_LANGID_YI_PRC +#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479 +#define TT_MS_LANGID_UIGHUR_CHINA \ + TT_MS_LANGID_UIGHUR_PRC + + + /************************************************************************** + * + * @enum: + * TT_NAME_ID_XXX + * + * @description: + * Possible values of the 'name' identifier field in the name records of + * an SFNT 'name' table. These values are platform independent. + */ + +#define TT_NAME_ID_COPYRIGHT 0 +#define TT_NAME_ID_FONT_FAMILY 1 +#define TT_NAME_ID_FONT_SUBFAMILY 2 +#define TT_NAME_ID_UNIQUE_ID 3 +#define TT_NAME_ID_FULL_NAME 4 +#define TT_NAME_ID_VERSION_STRING 5 +#define TT_NAME_ID_PS_NAME 6 +#define TT_NAME_ID_TRADEMARK 7 + + /* the following values are from the OpenType spec */ +#define TT_NAME_ID_MANUFACTURER 8 +#define TT_NAME_ID_DESIGNER 9 +#define TT_NAME_ID_DESCRIPTION 10 +#define TT_NAME_ID_VENDOR_URL 11 +#define TT_NAME_ID_DESIGNER_URL 12 +#define TT_NAME_ID_LICENSE 13 +#define TT_NAME_ID_LICENSE_URL 14 + /* number 15 is reserved */ +#define TT_NAME_ID_TYPOGRAPHIC_FAMILY 16 +#define TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY 17 +#define TT_NAME_ID_MAC_FULL_NAME 18 + + /* The following code is new as of 2000-01-21 */ +#define TT_NAME_ID_SAMPLE_TEXT 19 + + /* This is new in OpenType 1.3 */ +#define TT_NAME_ID_CID_FINDFONT_NAME 20 + + /* This is new in OpenType 1.5 */ +#define TT_NAME_ID_WWS_FAMILY 21 +#define TT_NAME_ID_WWS_SUBFAMILY 22 + + /* This is new in OpenType 1.7 */ +#define TT_NAME_ID_LIGHT_BACKGROUND 23 +#define TT_NAME_ID_DARK_BACKGROUND 24 + + /* This is new in OpenType 1.8 */ +#define TT_NAME_ID_VARIATIONS_PREFIX 25 + + /* these two values are deprecated */ +#define TT_NAME_ID_PREFERRED_FAMILY TT_NAME_ID_TYPOGRAPHIC_FAMILY +#define TT_NAME_ID_PREFERRED_SUBFAMILY TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY + + + /************************************************************************** + * + * @enum: + * TT_UCR_XXX + * + * @description: + * Possible bit mask values for the `ulUnicodeRangeX` fields in an SFNT + * 'OS/2' table. + */ + + /* ulUnicodeRange1 */ + /* --------------- */ + + /* Bit 0 Basic Latin */ +#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */ + /* Bit 1 C1 Controls and Latin-1 Supplement */ +#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */ + /* Bit 2 Latin Extended-A */ +#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */ + /* Bit 3 Latin Extended-B */ +#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */ + /* Bit 4 IPA Extensions */ + /* Phonetic Extensions */ + /* Phonetic Extensions Supplement */ +#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */ + /* U+1D00-U+1D7F */ + /* U+1D80-U+1DBF */ + /* Bit 5 Spacing Modifier Letters */ + /* Modifier Tone Letters */ +#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */ + /* U+A700-U+A71F */ + /* Bit 6 Combining Diacritical Marks */ + /* Combining Diacritical Marks Supplement */ +#define TT_UCR_COMBINING_DIACRITICAL_MARKS (1L << 6) /* U+0300-U+036F */ + /* U+1DC0-U+1DFF */ + /* Bit 7 Greek and Coptic */ +#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */ + /* Bit 8 Coptic */ +#define TT_UCR_COPTIC (1L << 8) /* U+2C80-U+2CFF */ + /* Bit 9 Cyrillic */ + /* Cyrillic Supplement */ + /* Cyrillic Extended-A */ + /* Cyrillic Extended-B */ +#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */ + /* U+0500-U+052F */ + /* U+2DE0-U+2DFF */ + /* U+A640-U+A69F */ + /* Bit 10 Armenian */ +#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */ + /* Bit 11 Hebrew */ +#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */ + /* Bit 12 Vai */ +#define TT_UCR_VAI (1L << 12) /* U+A500-U+A63F */ + /* Bit 13 Arabic */ + /* Arabic Supplement */ +#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */ + /* U+0750-U+077F */ + /* Bit 14 NKo */ +#define TT_UCR_NKO (1L << 14) /* U+07C0-U+07FF */ + /* Bit 15 Devanagari */ +#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */ + /* Bit 16 Bengali */ +#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */ + /* Bit 17 Gurmukhi */ +#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */ + /* Bit 18 Gujarati */ +#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */ + /* Bit 19 Oriya */ +#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */ + /* Bit 20 Tamil */ +#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */ + /* Bit 21 Telugu */ +#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */ + /* Bit 22 Kannada */ +#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */ + /* Bit 23 Malayalam */ +#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */ + /* Bit 24 Thai */ +#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */ + /* Bit 25 Lao */ +#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */ + /* Bit 26 Georgian */ + /* Georgian Supplement */ +#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */ + /* U+2D00-U+2D2F */ + /* Bit 27 Balinese */ +#define TT_UCR_BALINESE (1L << 27) /* U+1B00-U+1B7F */ + /* Bit 28 Hangul Jamo */ +#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */ + /* Bit 29 Latin Extended Additional */ + /* Latin Extended-C */ + /* Latin Extended-D */ +#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */ + /* U+2C60-U+2C7F */ + /* U+A720-U+A7FF */ + /* Bit 30 Greek Extended */ +#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */ + /* Bit 31 General Punctuation */ + /* Supplemental Punctuation */ +#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */ + /* U+2E00-U+2E7F */ + + /* ulUnicodeRange2 */ + /* --------------- */ + + /* Bit 32 Superscripts And Subscripts */ +#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */ + /* Bit 33 Currency Symbols */ +#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */ + /* Bit 34 Combining Diacritical Marks For Symbols */ +#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ + (1L << 2) /* U+20D0-U+20FF */ + /* Bit 35 Letterlike Symbols */ +#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */ + /* Bit 36 Number Forms */ +#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */ + /* Bit 37 Arrows */ + /* Supplemental Arrows-A */ + /* Supplemental Arrows-B */ + /* Miscellaneous Symbols and Arrows */ +#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */ + /* U+27F0-U+27FF */ + /* U+2900-U+297F */ + /* U+2B00-U+2BFF */ + /* Bit 38 Mathematical Operators */ + /* Supplemental Mathematical Operators */ + /* Miscellaneous Mathematical Symbols-A */ + /* Miscellaneous Mathematical Symbols-B */ +#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */ + /* U+2A00-U+2AFF */ + /* U+27C0-U+27EF */ + /* U+2980-U+29FF */ + /* Bit 39 Miscellaneous Technical */ +#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */ + /* Bit 40 Control Pictures */ +#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */ + /* Bit 41 Optical Character Recognition */ +#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */ + /* Bit 42 Enclosed Alphanumerics */ +#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */ + /* Bit 43 Box Drawing */ +#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */ + /* Bit 44 Block Elements */ +#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */ + /* Bit 45 Geometric Shapes */ +#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */ + /* Bit 46 Miscellaneous Symbols */ +#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */ + /* Bit 47 Dingbats */ +#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */ + /* Bit 48 CJK Symbols and Punctuation */ +#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */ + /* Bit 49 Hiragana */ +#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */ + /* Bit 50 Katakana */ + /* Katakana Phonetic Extensions */ +#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */ + /* U+31F0-U+31FF */ + /* Bit 51 Bopomofo */ + /* Bopomofo Extended */ +#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */ + /* U+31A0-U+31BF */ + /* Bit 52 Hangul Compatibility Jamo */ +#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */ + /* Bit 53 Phags-Pa */ +#define TT_UCR_CJK_MISC (1L << 21) /* U+A840-U+A87F */ +#define TT_UCR_KANBUN TT_UCR_CJK_MISC /* deprecated */ +#define TT_UCR_PHAGSPA + /* Bit 54 Enclosed CJK Letters and Months */ +#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */ + /* Bit 55 CJK Compatibility */ +#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */ + /* Bit 56 Hangul Syllables */ +#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */ + /* Bit 57 High Surrogates */ + /* High Private Use Surrogates */ + /* Low Surrogates */ + + /* According to OpenType specs v.1.3+, */ + /* setting bit 57 implies that there is */ + /* at least one codepoint beyond the */ + /* Basic Multilingual Plane that is */ + /* supported by this font. So it really */ + /* means >= U+10000. */ +#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DB7F */ + /* U+DB80-U+DBFF */ + /* U+DC00-U+DFFF */ +#define TT_UCR_NON_PLANE_0 TT_UCR_SURROGATES + /* Bit 58 Phoenician */ +#define TT_UCR_PHOENICIAN (1L << 26) /*U+10900-U+1091F*/ + /* Bit 59 CJK Unified Ideographs */ + /* CJK Radicals Supplement */ + /* Kangxi Radicals */ + /* Ideographic Description Characters */ + /* CJK Unified Ideographs Extension A */ + /* CJK Unified Ideographs Extension B */ + /* Kanbun */ +#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */ + /* U+2E80-U+2EFF */ + /* U+2F00-U+2FDF */ + /* U+2FF0-U+2FFF */ + /* U+3400-U+4DB5 */ + /*U+20000-U+2A6DF*/ + /* U+3190-U+319F */ + /* Bit 60 Private Use */ +#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */ + /* Bit 61 CJK Strokes */ + /* CJK Compatibility Ideographs */ + /* CJK Compatibility Ideographs Supplement */ +#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+31C0-U+31EF */ + /* U+F900-U+FAFF */ + /*U+2F800-U+2FA1F*/ + /* Bit 62 Alphabetic Presentation Forms */ +#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */ + /* Bit 63 Arabic Presentation Forms-A */ +#define TT_UCR_ARABIC_PRESENTATION_FORMS_A (1L << 31) /* U+FB50-U+FDFF */ + + /* ulUnicodeRange3 */ + /* --------------- */ + + /* Bit 64 Combining Half Marks */ +#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */ + /* Bit 65 Vertical forms */ + /* CJK Compatibility Forms */ +#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE10-U+FE1F */ + /* U+FE30-U+FE4F */ + /* Bit 66 Small Form Variants */ +#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */ + /* Bit 67 Arabic Presentation Forms-B */ +#define TT_UCR_ARABIC_PRESENTATION_FORMS_B (1L << 3) /* U+FE70-U+FEFE */ + /* Bit 68 Halfwidth and Fullwidth Forms */ +#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */ + /* Bit 69 Specials */ +#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */ + /* Bit 70 Tibetan */ +#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FFF */ + /* Bit 71 Syriac */ +#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */ + /* Bit 72 Thaana */ +#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */ + /* Bit 73 Sinhala */ +#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */ + /* Bit 74 Myanmar */ +#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */ + /* Bit 75 Ethiopic */ + /* Ethiopic Supplement */ + /* Ethiopic Extended */ +#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+137F */ + /* U+1380-U+139F */ + /* U+2D80-U+2DDF */ + /* Bit 76 Cherokee */ +#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */ + /* Bit 77 Unified Canadian Aboriginal Syllabics */ +#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+167F */ + /* Bit 78 Ogham */ +#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */ + /* Bit 79 Runic */ +#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */ + /* Bit 80 Khmer */ + /* Khmer Symbols */ +#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */ + /* U+19E0-U+19FF */ + /* Bit 81 Mongolian */ +#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */ + /* Bit 82 Braille Patterns */ +#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */ + /* Bit 83 Yi Syllables */ + /* Yi Radicals */ +#define TT_UCR_YI (1L << 19) /* U+A000-U+A48F */ + /* U+A490-U+A4CF */ + /* Bit 84 Tagalog */ + /* Hanunoo */ + /* Buhid */ + /* Tagbanwa */ +#define TT_UCR_PHILIPPINE (1L << 20) /* U+1700-U+171F */ + /* U+1720-U+173F */ + /* U+1740-U+175F */ + /* U+1760-U+177F */ + /* Bit 85 Old Italic */ +#define TT_UCR_OLD_ITALIC (1L << 21) /*U+10300-U+1032F*/ + /* Bit 86 Gothic */ +#define TT_UCR_GOTHIC (1L << 22) /*U+10330-U+1034F*/ + /* Bit 87 Deseret */ +#define TT_UCR_DESERET (1L << 23) /*U+10400-U+1044F*/ + /* Bit 88 Byzantine Musical Symbols */ + /* Musical Symbols */ + /* Ancient Greek Musical Notation */ +#define TT_UCR_MUSICAL_SYMBOLS (1L << 24) /*U+1D000-U+1D0FF*/ + /*U+1D100-U+1D1FF*/ + /*U+1D200-U+1D24F*/ + /* Bit 89 Mathematical Alphanumeric Symbols */ +#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS (1L << 25) /*U+1D400-U+1D7FF*/ + /* Bit 90 Private Use (plane 15) */ + /* Private Use (plane 16) */ +#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY (1L << 26) /*U+F0000-U+FFFFD*/ + /*U+100000-U+10FFFD*/ + /* Bit 91 Variation Selectors */ + /* Variation Selectors Supplement */ +#define TT_UCR_VARIATION_SELECTORS (1L << 27) /* U+FE00-U+FE0F */ + /*U+E0100-U+E01EF*/ + /* Bit 92 Tags */ +#define TT_UCR_TAGS (1L << 28) /*U+E0000-U+E007F*/ + /* Bit 93 Limbu */ +#define TT_UCR_LIMBU (1L << 29) /* U+1900-U+194F */ + /* Bit 94 Tai Le */ +#define TT_UCR_TAI_LE (1L << 30) /* U+1950-U+197F */ + /* Bit 95 New Tai Lue */ +#define TT_UCR_NEW_TAI_LUE (1L << 31) /* U+1980-U+19DF */ + + /* ulUnicodeRange4 */ + /* --------------- */ + + /* Bit 96 Buginese */ +#define TT_UCR_BUGINESE (1L << 0) /* U+1A00-U+1A1F */ + /* Bit 97 Glagolitic */ +#define TT_UCR_GLAGOLITIC (1L << 1) /* U+2C00-U+2C5F */ + /* Bit 98 Tifinagh */ +#define TT_UCR_TIFINAGH (1L << 2) /* U+2D30-U+2D7F */ + /* Bit 99 Yijing Hexagram Symbols */ +#define TT_UCR_YIJING (1L << 3) /* U+4DC0-U+4DFF */ + /* Bit 100 Syloti Nagri */ +#define TT_UCR_SYLOTI_NAGRI (1L << 4) /* U+A800-U+A82F */ + /* Bit 101 Linear B Syllabary */ + /* Linear B Ideograms */ + /* Aegean Numbers */ +#define TT_UCR_LINEAR_B (1L << 5) /*U+10000-U+1007F*/ + /*U+10080-U+100FF*/ + /*U+10100-U+1013F*/ + /* Bit 102 Ancient Greek Numbers */ +#define TT_UCR_ANCIENT_GREEK_NUMBERS (1L << 6) /*U+10140-U+1018F*/ + /* Bit 103 Ugaritic */ +#define TT_UCR_UGARITIC (1L << 7) /*U+10380-U+1039F*/ + /* Bit 104 Old Persian */ +#define TT_UCR_OLD_PERSIAN (1L << 8) /*U+103A0-U+103DF*/ + /* Bit 105 Shavian */ +#define TT_UCR_SHAVIAN (1L << 9) /*U+10450-U+1047F*/ + /* Bit 106 Osmanya */ +#define TT_UCR_OSMANYA (1L << 10) /*U+10480-U+104AF*/ + /* Bit 107 Cypriot Syllabary */ +#define TT_UCR_CYPRIOT_SYLLABARY (1L << 11) /*U+10800-U+1083F*/ + /* Bit 108 Kharoshthi */ +#define TT_UCR_KHAROSHTHI (1L << 12) /*U+10A00-U+10A5F*/ + /* Bit 109 Tai Xuan Jing Symbols */ +#define TT_UCR_TAI_XUAN_JING (1L << 13) /*U+1D300-U+1D35F*/ + /* Bit 110 Cuneiform */ + /* Cuneiform Numbers and Punctuation */ +#define TT_UCR_CUNEIFORM (1L << 14) /*U+12000-U+123FF*/ + /*U+12400-U+1247F*/ + /* Bit 111 Counting Rod Numerals */ +#define TT_UCR_COUNTING_ROD_NUMERALS (1L << 15) /*U+1D360-U+1D37F*/ + /* Bit 112 Sundanese */ +#define TT_UCR_SUNDANESE (1L << 16) /* U+1B80-U+1BBF */ + /* Bit 113 Lepcha */ +#define TT_UCR_LEPCHA (1L << 17) /* U+1C00-U+1C4F */ + /* Bit 114 Ol Chiki */ +#define TT_UCR_OL_CHIKI (1L << 18) /* U+1C50-U+1C7F */ + /* Bit 115 Saurashtra */ +#define TT_UCR_SAURASHTRA (1L << 19) /* U+A880-U+A8DF */ + /* Bit 116 Kayah Li */ +#define TT_UCR_KAYAH_LI (1L << 20) /* U+A900-U+A92F */ + /* Bit 117 Rejang */ +#define TT_UCR_REJANG (1L << 21) /* U+A930-U+A95F */ + /* Bit 118 Cham */ +#define TT_UCR_CHAM (1L << 22) /* U+AA00-U+AA5F */ + /* Bit 119 Ancient Symbols */ +#define TT_UCR_ANCIENT_SYMBOLS (1L << 23) /*U+10190-U+101CF*/ + /* Bit 120 Phaistos Disc */ +#define TT_UCR_PHAISTOS_DISC (1L << 24) /*U+101D0-U+101FF*/ + /* Bit 121 Carian */ + /* Lycian */ + /* Lydian */ +#define TT_UCR_OLD_ANATOLIAN (1L << 25) /*U+102A0-U+102DF*/ + /*U+10280-U+1029F*/ + /*U+10920-U+1093F*/ + /* Bit 122 Domino Tiles */ + /* Mahjong Tiles */ +#define TT_UCR_GAME_TILES (1L << 26) /*U+1F030-U+1F09F*/ + /*U+1F000-U+1F02F*/ + /* Bit 123-127 Reserved for process-internal usage */ + + /* */ + + /* for backward compatibility with older FreeType versions */ +#define TT_UCR_ARABIC_PRESENTATION_A \ + TT_UCR_ARABIC_PRESENTATION_FORMS_A +#define TT_UCR_ARABIC_PRESENTATION_B \ + TT_UCR_ARABIC_PRESENTATION_FORMS_B + +#define TT_UCR_COMBINING_DIACRITICS \ + TT_UCR_COMBINING_DIACRITICAL_MARKS +#define TT_UCR_COMBINING_DIACRITICS_SYMB \ + TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB + + +FT_END_HEADER + +#endif /* TTNAMEID_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/tttables.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/tttables.h new file mode 100644 index 0000000000000000000000000000000000000000..ad4112e4e7c1cf5438a331bfd17abd37697a004a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/tttables.h @@ -0,0 +1,856 @@ +/**************************************************************************** + * + * tttables.h + * + * Basic SFNT/TrueType tables definitions and interface + * (specification only). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef TTTABLES_H_ +#define TTTABLES_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + /************************************************************************** + * + * @section: + * truetype_tables + * + * @title: + * TrueType Tables + * + * @abstract: + * TrueType-specific table types and functions. + * + * @description: + * This section contains definitions of some basic tables specific to + * TrueType and OpenType as well as some routines used to access and + * process them. + * + * @order: + * TT_Header + * TT_HoriHeader + * TT_VertHeader + * TT_OS2 + * TT_Postscript + * TT_PCLT + * TT_MaxProfile + * + * FT_Sfnt_Tag + * FT_Get_Sfnt_Table + * FT_Load_Sfnt_Table + * FT_Sfnt_Table_Info + * + * FT_Get_CMap_Language_ID + * FT_Get_CMap_Format + * + * FT_PARAM_TAG_UNPATENTED_HINTING + * + */ + + + /************************************************************************** + * + * @struct: + * TT_Header + * + * @description: + * A structure to model a TrueType font header table. All fields follow + * the OpenType specification. The 64-bit timestamps are stored in + * two-element arrays `Created` and `Modified`, first the upper then + * the lower 32~bits. + */ + typedef struct TT_Header_ + { + FT_Fixed Table_Version; + FT_Fixed Font_Revision; + + FT_Long CheckSum_Adjust; + FT_Long Magic_Number; + + FT_UShort Flags; + FT_UShort Units_Per_EM; + + FT_ULong Created [2]; + FT_ULong Modified[2]; + + FT_Short xMin; + FT_Short yMin; + FT_Short xMax; + FT_Short yMax; + + FT_UShort Mac_Style; + FT_UShort Lowest_Rec_PPEM; + + FT_Short Font_Direction; + FT_Short Index_To_Loc_Format; + FT_Short Glyph_Data_Format; + + } TT_Header; + + + /************************************************************************** + * + * @struct: + * TT_HoriHeader + * + * @description: + * A structure to model a TrueType horizontal header, the 'hhea' table, + * as well as the corresponding horizontal metrics table, 'hmtx'. + * + * @fields: + * Version :: + * The table version. + * + * Ascender :: + * The font's ascender, i.e., the distance from the baseline to the + * top-most of all glyph points found in the font. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoAscender` field of the 'OS/2' table instead + * if you want the correct one. + * + * Descender :: + * The font's descender, i.e., the distance from the baseline to the + * bottom-most of all glyph points found in the font. It is negative. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoDescender` field of the 'OS/2' table + * instead if you want the correct one. + * + * Line_Gap :: + * The font's line gap, i.e., the distance to add to the ascender and + * descender to get the BTB, i.e., the baseline-to-baseline distance + * for the font. + * + * advance_Width_Max :: + * This field is the maximum of all advance widths found in the font. + * It can be used to compute the maximum width of an arbitrary string + * of text. + * + * min_Left_Side_Bearing :: + * The minimum left side bearing of all glyphs within the font. + * + * min_Right_Side_Bearing :: + * The minimum right side bearing of all glyphs within the font. + * + * xMax_Extent :: + * The maximum horizontal extent (i.e., the 'width' of a glyph's + * bounding box) for all glyphs in the font. + * + * caret_Slope_Rise :: + * The rise coefficient of the cursor's slope of the cursor + * (slope=rise/run). + * + * caret_Slope_Run :: + * The run coefficient of the cursor's slope. + * + * caret_Offset :: + * The cursor's offset for slanted fonts. + * + * Reserved :: + * 8~reserved bytes. + * + * metric_Data_Format :: + * Always~0. + * + * number_Of_HMetrics :: + * Number of HMetrics entries in the 'hmtx' table -- this value can be + * smaller than the total number of glyphs in the font. + * + * long_metrics :: + * A pointer into the 'hmtx' table. + * + * short_metrics :: + * A pointer into the 'hmtx' table. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `caret_Slope_Rise`, + * `caret_Slope_Run`, and `caret_Offset`. + */ + typedef struct TT_HoriHeader_ + { + FT_Fixed Version; + FT_Short Ascender; + FT_Short Descender; + FT_Short Line_Gap; + + FT_UShort advance_Width_Max; /* advance width maximum */ + + FT_Short min_Left_Side_Bearing; /* minimum left-sb */ + FT_Short min_Right_Side_Bearing; /* minimum right-sb */ + FT_Short xMax_Extent; /* xmax extents */ + FT_Short caret_Slope_Rise; + FT_Short caret_Slope_Run; + FT_Short caret_Offset; + + FT_Short Reserved[4]; + + FT_Short metric_Data_Format; + FT_UShort number_Of_HMetrics; + + /* The following fields are not defined by the OpenType specification */ + /* but they are used to connect the metrics header to the relevant */ + /* 'hmtx' table. */ + + void* long_metrics; + void* short_metrics; + + } TT_HoriHeader; + + + /************************************************************************** + * + * @struct: + * TT_VertHeader + * + * @description: + * A structure used to model a TrueType vertical header, the 'vhea' + * table, as well as the corresponding vertical metrics table, 'vmtx'. + * + * @fields: + * Version :: + * The table version. + * + * Ascender :: + * The font's ascender, i.e., the distance from the baseline to the + * top-most of all glyph points found in the font. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoAscender` field of the 'OS/2' table instead + * if you want the correct one. + * + * Descender :: + * The font's descender, i.e., the distance from the baseline to the + * bottom-most of all glyph points found in the font. It is negative. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoDescender` field of the 'OS/2' table + * instead if you want the correct one. + * + * Line_Gap :: + * The font's line gap, i.e., the distance to add to the ascender and + * descender to get the BTB, i.e., the baseline-to-baseline distance + * for the font. + * + * advance_Height_Max :: + * This field is the maximum of all advance heights found in the font. + * It can be used to compute the maximum height of an arbitrary string + * of text. + * + * min_Top_Side_Bearing :: + * The minimum top side bearing of all glyphs within the font. + * + * min_Bottom_Side_Bearing :: + * The minimum bottom side bearing of all glyphs within the font. + * + * yMax_Extent :: + * The maximum vertical extent (i.e., the 'height' of a glyph's + * bounding box) for all glyphs in the font. + * + * caret_Slope_Rise :: + * The rise coefficient of the cursor's slope of the cursor + * (slope=rise/run). + * + * caret_Slope_Run :: + * The run coefficient of the cursor's slope. + * + * caret_Offset :: + * The cursor's offset for slanted fonts. + * + * Reserved :: + * 8~reserved bytes. + * + * metric_Data_Format :: + * Always~0. + * + * number_Of_VMetrics :: + * Number of VMetrics entries in the 'vmtx' table -- this value can be + * smaller than the total number of glyphs in the font. + * + * long_metrics :: + * A pointer into the 'vmtx' table. + * + * short_metrics :: + * A pointer into the 'vmtx' table. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `Ascender`, `Descender`, + * `Line_Gap`, `caret_Slope_Rise`, `caret_Slope_Run`, and `caret_Offset`. + */ + typedef struct TT_VertHeader_ + { + FT_Fixed Version; + FT_Short Ascender; + FT_Short Descender; + FT_Short Line_Gap; + + FT_UShort advance_Height_Max; /* advance height maximum */ + + FT_Short min_Top_Side_Bearing; /* minimum top-sb */ + FT_Short min_Bottom_Side_Bearing; /* minimum bottom-sb */ + FT_Short yMax_Extent; /* ymax extents */ + FT_Short caret_Slope_Rise; + FT_Short caret_Slope_Run; + FT_Short caret_Offset; + + FT_Short Reserved[4]; + + FT_Short metric_Data_Format; + FT_UShort number_Of_VMetrics; + + /* The following fields are not defined by the OpenType specification */ + /* but they are used to connect the metrics header to the relevant */ + /* 'vmtx' table. */ + + void* long_metrics; + void* short_metrics; + + } TT_VertHeader; + + + /************************************************************************** + * + * @struct: + * TT_OS2 + * + * @description: + * A structure to model a TrueType 'OS/2' table. All fields comply to + * the OpenType specification. + * + * Note that we now support old Mac fonts that do not include an 'OS/2' + * table. In this case, the `version` field is always set to 0xFFFF. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `sCapHeight`, `sTypoAscender`, + * `sTypoDescender`, `sTypoLineGap`, `sxHeight`, `usWinAscent`, + * `usWinDescent`, `yStrikeoutPosition`, `yStrikeoutSize`, + * `ySubscriptXOffset`, `ySubScriptXSize`, `ySubscriptYOffset`, + * `ySubscriptYSize`, `ySuperscriptXOffset`, `ySuperscriptXSize`, + * `ySuperscriptYOffset`, and `ySuperscriptYSize`. + * + * Possible values for bits in the `ulUnicodeRangeX` fields are given by + * the @TT_UCR_XXX macros. + */ + + typedef struct TT_OS2_ + { + FT_UShort version; /* 0x0001 - more or 0xFFFF */ + FT_Short xAvgCharWidth; + FT_UShort usWeightClass; + FT_UShort usWidthClass; + FT_UShort fsType; + FT_Short ySubscriptXSize; + FT_Short ySubscriptYSize; + FT_Short ySubscriptXOffset; + FT_Short ySubscriptYOffset; + FT_Short ySuperscriptXSize; + FT_Short ySuperscriptYSize; + FT_Short ySuperscriptXOffset; + FT_Short ySuperscriptYOffset; + FT_Short yStrikeoutSize; + FT_Short yStrikeoutPosition; + FT_Short sFamilyClass; + + FT_Byte panose[10]; + + FT_ULong ulUnicodeRange1; /* Bits 0-31 */ + FT_ULong ulUnicodeRange2; /* Bits 32-63 */ + FT_ULong ulUnicodeRange3; /* Bits 64-95 */ + FT_ULong ulUnicodeRange4; /* Bits 96-127 */ + + FT_Char achVendID[4]; + + FT_UShort fsSelection; + FT_UShort usFirstCharIndex; + FT_UShort usLastCharIndex; + FT_Short sTypoAscender; + FT_Short sTypoDescender; + FT_Short sTypoLineGap; + FT_UShort usWinAscent; + FT_UShort usWinDescent; + + /* only version 1 and higher: */ + + FT_ULong ulCodePageRange1; /* Bits 0-31 */ + FT_ULong ulCodePageRange2; /* Bits 32-63 */ + + /* only version 2 and higher: */ + + FT_Short sxHeight; + FT_Short sCapHeight; + FT_UShort usDefaultChar; + FT_UShort usBreakChar; + FT_UShort usMaxContext; + + /* only version 5 and higher: */ + + FT_UShort usLowerOpticalPointSize; /* in twips (1/20 points) */ + FT_UShort usUpperOpticalPointSize; /* in twips (1/20 points) */ + + } TT_OS2; + + + /************************************************************************** + * + * @struct: + * TT_Postscript + * + * @description: + * A structure to model a TrueType 'post' table. All fields comply to + * the OpenType specification. This structure does not reference a + * font's PostScript glyph names; use @FT_Get_Glyph_Name to retrieve + * them. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `underlinePosition` and + * `underlineThickness`. + */ + typedef struct TT_Postscript_ + { + FT_Fixed FormatType; + FT_Fixed italicAngle; + FT_Short underlinePosition; + FT_Short underlineThickness; + FT_ULong isFixedPitch; + FT_ULong minMemType42; + FT_ULong maxMemType42; + FT_ULong minMemType1; + FT_ULong maxMemType1; + + /* Glyph names follow in the 'post' table, but we don't */ + /* load them by default. */ + + } TT_Postscript; + + + /************************************************************************** + * + * @struct: + * TT_PCLT + * + * @description: + * A structure to model a TrueType 'PCLT' table. All fields comply to + * the OpenType specification. + */ + typedef struct TT_PCLT_ + { + FT_Fixed Version; + FT_ULong FontNumber; + FT_UShort Pitch; + FT_UShort xHeight; + FT_UShort Style; + FT_UShort TypeFamily; + FT_UShort CapHeight; + FT_UShort SymbolSet; + FT_Char TypeFace[16]; + FT_Char CharacterComplement[8]; + FT_Char FileName[6]; + FT_Char StrokeWeight; + FT_Char WidthType; + FT_Byte SerifStyle; + FT_Byte Reserved; + + } TT_PCLT; + + + /************************************************************************** + * + * @struct: + * TT_MaxProfile + * + * @description: + * The maximum profile ('maxp') table contains many max values, which can + * be used to pre-allocate arrays for speeding up glyph loading and + * hinting. + * + * @fields: + * version :: + * The version number. + * + * numGlyphs :: + * The number of glyphs in this TrueType font. + * + * maxPoints :: + * The maximum number of points in a non-composite TrueType glyph. See + * also `maxCompositePoints`. + * + * maxContours :: + * The maximum number of contours in a non-composite TrueType glyph. + * See also `maxCompositeContours`. + * + * maxCompositePoints :: + * The maximum number of points in a composite TrueType glyph. See + * also `maxPoints`. + * + * maxCompositeContours :: + * The maximum number of contours in a composite TrueType glyph. See + * also `maxContours`. + * + * maxZones :: + * The maximum number of zones used for glyph hinting. + * + * maxTwilightPoints :: + * The maximum number of points in the twilight zone used for glyph + * hinting. + * + * maxStorage :: + * The maximum number of elements in the storage area used for glyph + * hinting. + * + * maxFunctionDefs :: + * The maximum number of function definitions in the TrueType bytecode + * for this font. + * + * maxInstructionDefs :: + * The maximum number of instruction definitions in the TrueType + * bytecode for this font. + * + * maxStackElements :: + * The maximum number of stack elements used during bytecode + * interpretation. + * + * maxSizeOfInstructions :: + * The maximum number of TrueType opcodes used for glyph hinting. + * + * maxComponentElements :: + * The maximum number of simple (i.e., non-composite) glyphs in a + * composite glyph. + * + * maxComponentDepth :: + * The maximum nesting depth of composite glyphs. + * + * @note: + * This structure is only used during font loading. + */ + typedef struct TT_MaxProfile_ + { + FT_Fixed version; + FT_UShort numGlyphs; + FT_UShort maxPoints; + FT_UShort maxContours; + FT_UShort maxCompositePoints; + FT_UShort maxCompositeContours; + FT_UShort maxZones; + FT_UShort maxTwilightPoints; + FT_UShort maxStorage; + FT_UShort maxFunctionDefs; + FT_UShort maxInstructionDefs; + FT_UShort maxStackElements; + FT_UShort maxSizeOfInstructions; + FT_UShort maxComponentElements; + FT_UShort maxComponentDepth; + + } TT_MaxProfile; + + + /************************************************************************** + * + * @enum: + * FT_Sfnt_Tag + * + * @description: + * An enumeration to specify indices of SFNT tables loaded and parsed by + * FreeType during initialization of an SFNT font. Used in the + * @FT_Get_Sfnt_Table API function. + * + * @values: + * FT_SFNT_HEAD :: + * To access the font's @TT_Header structure. + * + * FT_SFNT_MAXP :: + * To access the font's @TT_MaxProfile structure. + * + * FT_SFNT_OS2 :: + * To access the font's @TT_OS2 structure. + * + * FT_SFNT_HHEA :: + * To access the font's @TT_HoriHeader structure. + * + * FT_SFNT_VHEA :: + * To access the font's @TT_VertHeader structure. + * + * FT_SFNT_POST :: + * To access the font's @TT_Postscript structure. + * + * FT_SFNT_PCLT :: + * To access the font's @TT_PCLT structure. + */ + typedef enum FT_Sfnt_Tag_ + { + FT_SFNT_HEAD, + FT_SFNT_MAXP, + FT_SFNT_OS2, + FT_SFNT_HHEA, + FT_SFNT_VHEA, + FT_SFNT_POST, + FT_SFNT_PCLT, + + FT_SFNT_MAX + + } FT_Sfnt_Tag; + + /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag` */ + /* values instead */ +#define ft_sfnt_head FT_SFNT_HEAD +#define ft_sfnt_maxp FT_SFNT_MAXP +#define ft_sfnt_os2 FT_SFNT_OS2 +#define ft_sfnt_hhea FT_SFNT_HHEA +#define ft_sfnt_vhea FT_SFNT_VHEA +#define ft_sfnt_post FT_SFNT_POST +#define ft_sfnt_pclt FT_SFNT_PCLT + + + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_Table + * + * @description: + * Return a pointer to a given SFNT table stored within a face. + * + * @input: + * face :: + * A handle to the source. + * + * tag :: + * The index of the SFNT table. + * + * @return: + * A type-less pointer to the table. This will be `NULL` in case of + * error, or if the corresponding table was not found **OR** loaded from + * the file. + * + * Use a typecast according to `tag` to access the structure elements. + * + * @note: + * The table is owned by the face object and disappears with it. + * + * This function is only useful to access SFNT tables that are loaded by + * the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for a + * list. + * + * @example: + * Here is an example demonstrating access to the 'vhea' table. + * + * ``` + * TT_VertHeader* vert_header; + * + * + * vert_header = + * (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); + * ``` + */ + FT_EXPORT( void* ) + FT_Get_Sfnt_Table( FT_Face face, + FT_Sfnt_Tag tag ); + + + /************************************************************************** + * + * @function: + * FT_Load_Sfnt_Table + * + * @description: + * Load any SFNT font table into client memory. + * + * @input: + * face :: + * A handle to the source face. + * + * tag :: + * The four-byte tag of the table to load. Use value~0 if you want to + * access the whole font file. Otherwise, you can use one of the + * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new + * one with @FT_MAKE_TAG. + * + * offset :: + * The starting offset in the table (or file if tag~==~0). + * + * @output: + * buffer :: + * The target buffer address. The client must ensure that the memory + * array is big enough to hold the data. + * + * @inout: + * length :: + * If the `length` parameter is `NULL`, try to load the whole table. + * Return an error code if it fails. + * + * Else, if `*length` is~0, exit immediately while returning the + * table's (or file) full size in it. + * + * Else the number of bytes to read from the table or file, from the + * starting offset. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If you need to determine the table's length you should first call this + * function with `*length` set to~0, as in the following example: + * + * ``` + * FT_ULong length = 0; + * + * + * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); + * if ( error ) { ... table does not exist ... } + * + * buffer = malloc( length ); + * if ( buffer == NULL ) { ... not enough memory ... } + * + * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); + * if ( error ) { ... could not load table ... } + * ``` + * + * Note that structures like @TT_Header or @TT_OS2 can't be used with + * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that + * those structures depend on the processor architecture, with varying + * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian). + * + */ + FT_EXPORT( FT_Error ) + FT_Load_Sfnt_Table( FT_Face face, + FT_ULong tag, + FT_Long offset, + FT_Byte* buffer, + FT_ULong* length ); + + + /************************************************************************** + * + * @function: + * FT_Sfnt_Table_Info + * + * @description: + * Return information on an SFNT table. + * + * @input: + * face :: + * A handle to the source face. + * + * table_index :: + * The index of an SFNT table. The function returns + * FT_Err_Table_Missing for an invalid value. + * + * @inout: + * tag :: + * The name tag of the SFNT table. If the value is `NULL`, + * `table_index` is ignored, and `length` returns the number of SFNT + * tables in the font. + * + * @output: + * length :: + * The length of the SFNT table (or the number of SFNT tables, + * depending on `tag`). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * While parsing fonts, FreeType handles SFNT tables with length zero as + * missing. + * + */ + FT_EXPORT( FT_Error ) + FT_Sfnt_Table_Info( FT_Face face, + FT_UInt table_index, + FT_ULong *tag, + FT_ULong *length ); + + + /************************************************************************** + * + * @function: + * FT_Get_CMap_Language_ID + * + * @description: + * Return cmap language ID as specified in the OpenType standard. + * Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. + * + * @input: + * charmap :: + * The target charmap. + * + * @return: + * The language ID of `charmap`. If `charmap` doesn't belong to an SFNT + * face, just return~0 as the default value. + * + * For a format~14 cmap (to access Unicode IVS), the return value is + * 0xFFFFFFFF. + */ + FT_EXPORT( FT_ULong ) + FT_Get_CMap_Language_ID( FT_CharMap charmap ); + + + /************************************************************************** + * + * @function: + * FT_Get_CMap_Format + * + * @description: + * Return the format of an SFNT 'cmap' table. + * + * @input: + * charmap :: + * The target charmap. + * + * @return: + * The format of `charmap`. If `charmap` doesn't belong to an SFNT face + * (including the synthetic Unicode charmap sometimes created by + * FreeType), return -1. + */ + FT_EXPORT( FT_Long ) + FT_Get_CMap_Format( FT_CharMap charmap ); + + /* */ + + +FT_END_HEADER + +#endif /* TTTABLES_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/tttags.h b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/tttags.h new file mode 100644 index 0000000000000000000000000000000000000000..92ab8ae8e7f7d49fb512e467f89fc9734a2669cd --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtFreetype/freetype/tttags.h @@ -0,0 +1,124 @@ +/**************************************************************************** + * + * tttags.h + * + * Tags for TrueType and OpenType tables (specification only). + * + * Copyright (C) 1996-2024 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef TTAGS_H_ +#define TTAGS_H_ + + +#include + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + +#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' ) +#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' ) +#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) +#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' ) +#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' ) +#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) +#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) +#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' ) +#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' ) +#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) +#define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' ) +#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) +#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) +#define TTAG_COLR FT_MAKE_TAG( 'C', 'O', 'L', 'R' ) +#define TTAG_CPAL FT_MAKE_TAG( 'C', 'P', 'A', 'L' ) +#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) +#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) +#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) +#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) +#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) +#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) +#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' ) +#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) +#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) +#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) +#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) +#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' ) +#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' ) +#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) +#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' ) +#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' ) +#define TTAG_HVAR FT_MAKE_TAG( 'H', 'V', 'A', 'R' ) +#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' ) +#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' ) +#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) +#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' ) +#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' ) +#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' ) +#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' ) +#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' ) +#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) +#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) +#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) +#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' ) +#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) +#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' ) +#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' ) +#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) +#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' ) +#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' ) +#define TTAG_MVAR FT_MAKE_TAG( 'M', 'V', 'A', 'R' ) +#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) +#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' ) +#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) +#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) +#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) +#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' ) +#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) +#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) +#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' ) +#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' ) +#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' ) +#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' ) +#define TTAG_SVG FT_MAKE_TAG( 'S', 'V', 'G', ' ' ) +#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) +#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) +#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) +#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) +#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' ) +#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' ) +#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) +#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) +#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) +#define TTAG_VVAR FT_MAKE_TAG( 'V', 'V', 'A', 'R' ) +#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' ) +#define TTAG_wOF2 FT_MAKE_TAG( 'w', 'O', 'F', '2' ) + +/* used by "Keyboard.dfont" on legacy Mac OS X */ +#define TTAG_0xA5kbd FT_MAKE_TAG( 0xA5, 'k', 'b', 'd' ) + +/* used by "LastResort.dfont" on legacy Mac OS X */ +#define TTAG_0xA5lst FT_MAKE_TAG( 0xA5, 'l', 's', 't' ) + + +FT_END_HEADER + +#endif /* TTAGS_H_ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/cs_mipmap_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/cs_mipmap_p.h new file mode 100644 index 0000000000000000000000000000000000000000..75f780bfc7e483d5fc977cc47f0aafb0ab5fdd4b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/cs_mipmap_p.h @@ -0,0 +1,939 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef CS_MIPMAP_P_H +#define CS_MIPMAP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#ifdef Q_OS_WIN + +#include + +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 10.1 +// +// +// Buffer Definitions: +// +// cbuffer CB0 +// { +// +// uint SrcMipLevel; // Offset: 0 Size: 4 +// uint NumMipLevels; // Offset: 4 Size: 4 +// float2 TexelSize; // Offset: 8 Size: 8 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim HLSL Bind Count +// ------------------------------ ---------- ------- ----------- -------------- ------ +// BilinearClamp sampler NA NA s0 1 +// SrcMip texture float4 2d t0 1 +// OutMip1 UAV float4 2d u0 1 +// OutMip2 UAV float4 2d u1 1 +// OutMip3 UAV float4 2d u2 1 +// OutMip4 UAV float4 2d u3 1 +// CB0 cbuffer NA NA cb0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// no Input +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// no Output +cs_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer CB0[1], immediateIndexed +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_uav_typed_texture2d (float,float,float,float) u0 +dcl_uav_typed_texture2d (float,float,float,float) u1 +dcl_uav_typed_texture2d (float,float,float,float) u2 +dcl_uav_typed_texture2d (float,float,float,float) u3 +dcl_input vThreadIDInGroupFlattened +dcl_input vThreadID.xy +dcl_temps 6 +dcl_tgsm_structured g0, 4, 64 +dcl_tgsm_structured g1, 4, 64 +dcl_tgsm_structured g2, 4, 64 +dcl_tgsm_structured g3, 4, 64 +dcl_thread_group 8, 8, 1 +utof r0.xy, vThreadID.xyxx +add r0.xy, r0.xyxx, l(0.250000, 0.250000, 0.000000, 0.000000) +mul r0.zw, r0.xxxy, cb0[0].zzzw +utof r1.x, cb0[0].x +sample_l_indexable(texture2d)(float,float,float,float) r2.xyzw, r0.zwzz, t0.xyzw, s0, r1.x +mul r3.xyz, cb0[0].zwzz, l(0.500000, 0.500000, 0.500000, 0.000000) +mov r3.w, l(0) +mad r3.xyzw, cb0[0].zwzw, r0.xyxy, r3.zwxy +sample_l_indexable(texture2d)(float,float,float,float) r4.xyzw, r3.xyxx, t0.xyzw, s0, r1.x +add r2.xyzw, r2.xyzw, r4.xyzw +mov r3.x, l(0) +mul r3.y, cb0[0].w, l(0.500000) +mad r0.xy, cb0[0].zwzz, r0.xyxx, r3.xyxx +sample_l_indexable(texture2d)(float,float,float,float) r0.xyzw, r0.xyxx, t0.xyzw, s0, r1.x +add r0.xyzw, r0.xyzw, r2.xyzw +sample_l_indexable(texture2d)(float,float,float,float) r1.xyzw, r3.zwzz, t0.xyzw, s0, r1.x +add r0.xyzw, r0.xyzw, r1.xyzw +mul r1.xyzw, r0.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000) +store_uav_typed u0.xyzw, vThreadID.xyyy, r1.xyzw +ieq r2.x, cb0[0].y, l(1) +if_nz r2.x + ret +endif +store_structured g0.x, vThreadIDInGroupFlattened.x, l(0), r1.x +store_structured g1.x, vThreadIDInGroupFlattened.x, l(0), r1.y +store_structured g2.x, vThreadIDInGroupFlattened.x, l(0), r1.z +store_structured g3.x, vThreadIDInGroupFlattened.x, l(0), r1.w +sync_g_t +and r2.x, vThreadIDInGroupFlattened.x, l(9) +if_z r2.x + iadd r2.xyz, vThreadIDInGroupFlattened.xxxx, l(1, 8, 9, 0) + ld_structured r3.x, r2.x, l(0), g0.xxxx + ld_structured r3.y, r2.x, l(0), g1.xxxx + ld_structured r3.z, r2.x, l(0), g2.xxxx + ld_structured r3.w, r2.x, l(0), g3.xxxx + ld_structured r4.x, r2.y, l(0), g0.xxxx + ld_structured r4.y, r2.y, l(0), g1.xxxx + ld_structured r4.z, r2.y, l(0), g2.xxxx + ld_structured r4.w, r2.y, l(0), g3.xxxx + ld_structured r5.x, r2.z, l(0), g0.xxxx + ld_structured r5.y, r2.z, l(0), g1.xxxx + ld_structured r5.z, r2.z, l(0), g2.xxxx + ld_structured r5.w, r2.z, l(0), g3.xxxx + mad r0.xyzw, r0.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000), r3.xyzw + add r0.xyzw, r4.xyzw, r0.xyzw + add r0.xyzw, r5.xyzw, r0.xyzw + mul r1.xyzw, r0.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000) + ushr r0.xyzw, vThreadID.xyyy, l(1, 1, 1, 1) + store_uav_typed u1.xyzw, r0.xyzw, r1.xyzw + store_structured g0.x, vThreadIDInGroupFlattened.x, l(0), r1.x + store_structured g1.x, vThreadIDInGroupFlattened.x, l(0), r1.y + store_structured g2.x, vThreadIDInGroupFlattened.x, l(0), r1.z + store_structured g3.x, vThreadIDInGroupFlattened.x, l(0), r1.w +endif +ieq r0.x, cb0[0].y, l(2) +if_nz r0.x + ret +endif +sync_g_t +and r0.x, vThreadIDInGroupFlattened.x, l(27) +if_z r0.x + iadd r0.xyz, vThreadIDInGroupFlattened.xxxx, l(2, 16, 18, 0) + ld_structured r2.x, r0.x, l(0), g0.xxxx + ld_structured r2.y, r0.x, l(0), g1.xxxx + ld_structured r2.z, r0.x, l(0), g2.xxxx + ld_structured r2.w, r0.x, l(0), g3.xxxx + ld_structured r3.x, r0.y, l(0), g0.xxxx + ld_structured r3.y, r0.y, l(0), g1.xxxx + ld_structured r3.z, r0.y, l(0), g2.xxxx + ld_structured r3.w, r0.y, l(0), g3.xxxx + ld_structured r4.x, r0.z, l(0), g0.xxxx + ld_structured r4.y, r0.z, l(0), g1.xxxx + ld_structured r4.z, r0.z, l(0), g2.xxxx + ld_structured r4.w, r0.z, l(0), g3.xxxx + add r0.xyzw, r1.xyzw, r2.xyzw + add r0.xyzw, r3.xyzw, r0.xyzw + add r0.xyzw, r4.xyzw, r0.xyzw + mul r1.xyzw, r0.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000) + ushr r0.xyzw, vThreadID.xyyy, l(2, 2, 2, 2) + store_uav_typed u2.xyzw, r0.xyzw, r1.xyzw + store_structured g0.x, vThreadIDInGroupFlattened.x, l(0), r1.x + store_structured g1.x, vThreadIDInGroupFlattened.x, l(0), r1.y + store_structured g2.x, vThreadIDInGroupFlattened.x, l(0), r1.z + store_structured g3.x, vThreadIDInGroupFlattened.x, l(0), r1.w +endif +ieq r0.x, cb0[0].y, l(3) +if_nz r0.x + ret +endif +sync_g_t +if_z vThreadIDInGroupFlattened.x + ld_structured r0.x, l(4), l(0), g0.xxxx + ld_structured r0.y, l(4), l(0), g1.xxxx + ld_structured r0.z, l(4), l(0), g2.xxxx + ld_structured r0.w, l(4), l(0), g3.xxxx + ld_structured r2.x, l(32), l(0), g0.xxxx + ld_structured r2.y, l(32), l(0), g1.xxxx + ld_structured r2.z, l(32), l(0), g2.xxxx + ld_structured r2.w, l(32), l(0), g3.xxxx + ld_structured r3.x, l(36), l(0), g0.xxxx + ld_structured r3.y, l(36), l(0), g1.xxxx + ld_structured r3.z, l(36), l(0), g2.xxxx + ld_structured r3.w, l(36), l(0), g3.xxxx + add r0.xyzw, r0.xyzw, r1.xyzw + add r0.xyzw, r2.xyzw, r0.xyzw + add r0.xyzw, r3.xyzw, r0.xyzw + mul r0.xyzw, r0.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000) + ushr r1.xyzw, vThreadID.xyyy, l(3, 3, 3, 3) + store_uav_typed u3.xyzw, r1.xyzw, r0.xyzw +endif +ret +// Approximately 111 instruction slots used +#endif + +inline constexpr BYTE g_csMipmap[] = +{ + 68, 88, 66, 67, 133, 122, + 5, 181, 163, 163, 140, 185, + 158, 179, 4, 65, 180, 238, + 158, 10, 1, 0, 0, 0, + 60, 17, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 200, 2, 0, 0, 216, 2, + 0, 0, 232, 2, 0, 0, + 160, 16, 0, 0, 82, 68, + 69, 70, 140, 2, 0, 0, + 1, 0, 0, 0, 88, 1, + 0, 0, 7, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 83, 67, 0, 1, 0, 0, + 100, 2, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 28, 1, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 42, 1, 0, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 1, 0, 0, 0, + 13, 0, 0, 0, 49, 1, + 0, 0, 4, 0, 0, 0, + 5, 0, 0, 0, 4, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 1, 0, + 0, 0, 13, 0, 0, 0, + 57, 1, 0, 0, 4, 0, + 0, 0, 5, 0, 0, 0, + 4, 0, 0, 0, 255, 255, + 255, 255, 1, 0, 0, 0, + 1, 0, 0, 0, 13, 0, + 0, 0, 65, 1, 0, 0, + 4, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 2, 0, + 0, 0, 1, 0, 0, 0, + 13, 0, 0, 0, 73, 1, + 0, 0, 4, 0, 0, 0, + 5, 0, 0, 0, 4, 0, + 0, 0, 255, 255, 255, 255, + 3, 0, 0, 0, 1, 0, + 0, 0, 13, 0, 0, 0, + 81, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 66, 105, 108, 105, + 110, 101, 97, 114, 67, 108, + 97, 109, 112, 0, 83, 114, + 99, 77, 105, 112, 0, 79, + 117, 116, 77, 105, 112, 49, + 0, 79, 117, 116, 77, 105, + 112, 50, 0, 79, 117, 116, + 77, 105, 112, 51, 0, 79, + 117, 116, 77, 105, 112, 52, + 0, 67, 66, 48, 0, 171, + 171, 171, 81, 1, 0, 0, + 3, 0, 0, 0, 112, 1, + 0, 0, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 232, 1, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 2, 0, 0, 0, + 252, 1, 0, 0, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 32, 2, 0, 0, 4, 0, + 0, 0, 4, 0, 0, 0, + 2, 0, 0, 0, 252, 1, + 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 45, 2, + 0, 0, 8, 0, 0, 0, + 8, 0, 0, 0, 2, 0, + 0, 0, 64, 2, 0, 0, + 0, 0, 0, 0, 255, 255, + 255, 255, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 83, 114, 99, 77, + 105, 112, 76, 101, 118, 101, + 108, 0, 100, 119, 111, 114, + 100, 0, 171, 171, 0, 0, + 19, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 244, 1, 0, 0, 78, 117, + 109, 77, 105, 112, 76, 101, + 118, 101, 108, 115, 0, 84, + 101, 120, 101, 108, 83, 105, + 122, 101, 0, 102, 108, 111, + 97, 116, 50, 0, 171, 171, + 1, 0, 3, 0, 1, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 55, 2, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 49, + 48, 46, 49, 0, 73, 83, + 71, 78, 8, 0, 0, 0, + 0, 0, 0, 0, 8, 0, + 0, 0, 79, 83, 71, 78, + 8, 0, 0, 0, 0, 0, + 0, 0, 8, 0, 0, 0, + 83, 72, 69, 88, 176, 13, + 0, 0, 80, 0, 5, 0, + 108, 3, 0, 0, 106, 8, + 0, 1, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 90, 0, 0, 3, 0, 96, + 16, 0, 0, 0, 0, 0, + 88, 24, 0, 4, 0, 112, + 16, 0, 0, 0, 0, 0, + 85, 85, 0, 0, 156, 24, + 0, 4, 0, 224, 17, 0, + 0, 0, 0, 0, 85, 85, + 0, 0, 156, 24, 0, 4, + 0, 224, 17, 0, 1, 0, + 0, 0, 85, 85, 0, 0, + 156, 24, 0, 4, 0, 224, + 17, 0, 2, 0, 0, 0, + 85, 85, 0, 0, 156, 24, + 0, 4, 0, 224, 17, 0, + 3, 0, 0, 0, 85, 85, + 0, 0, 95, 0, 0, 2, + 0, 64, 2, 0, 95, 0, + 0, 2, 50, 0, 2, 0, + 104, 0, 0, 2, 6, 0, + 0, 0, 160, 0, 0, 5, + 0, 240, 17, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 64, 0, 0, 0, 160, 0, + 0, 5, 0, 240, 17, 0, + 1, 0, 0, 0, 4, 0, + 0, 0, 64, 0, 0, 0, + 160, 0, 0, 5, 0, 240, + 17, 0, 2, 0, 0, 0, + 4, 0, 0, 0, 64, 0, + 0, 0, 160, 0, 0, 5, + 0, 240, 17, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 64, 0, 0, 0, 155, 0, + 0, 4, 8, 0, 0, 0, + 8, 0, 0, 0, 1, 0, + 0, 0, 86, 0, 0, 4, + 50, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 2, 0, + 0, 0, 0, 10, 50, 0, + 16, 0, 0, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 62, 0, 0, + 128, 62, 0, 0, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 194, 0, 16, 0, + 0, 0, 0, 0, 6, 4, + 16, 0, 0, 0, 0, 0, + 166, 142, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 86, 0, 0, 6, 18, 0, + 16, 0, 1, 0, 0, 0, + 10, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 72, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 242, 0, 16, 0, 2, 0, + 0, 0, 230, 10, 16, 0, + 0, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 56, 0, + 0, 11, 114, 0, 16, 0, + 3, 0, 0, 0, 230, 138, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 63, + 0, 0, 0, 63, 0, 0, + 0, 63, 0, 0, 0, 0, + 54, 0, 0, 5, 130, 0, + 16, 0, 3, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 3, 0, + 0, 0, 230, 142, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 4, 16, 0, + 0, 0, 0, 0, 230, 4, + 16, 0, 3, 0, 0, 0, + 72, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 242, 0, 16, 0, 4, 0, + 0, 0, 70, 0, 16, 0, + 3, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 7, 242, 0, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 4, 0, + 0, 0, 54, 0, 0, 5, + 18, 0, 16, 0, 3, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 34, 0, 16, 0, + 3, 0, 0, 0, 58, 128, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 0, 63, + 50, 0, 0, 10, 50, 0, + 16, 0, 0, 0, 0, 0, + 230, 138, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 3, 0, 0, 0, 72, 0, + 0, 141, 194, 0, 0, 128, + 67, 85, 21, 0, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 0, 16, 0, 0, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 7, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 2, 0, 0, 0, + 72, 0, 0, 141, 194, 0, + 0, 128, 67, 85, 21, 0, + 242, 0, 16, 0, 1, 0, + 0, 0, 230, 10, 16, 0, + 3, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 56, 0, 0, 10, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 62, + 0, 0, 128, 62, 0, 0, + 128, 62, 0, 0, 128, 62, + 164, 0, 0, 6, 242, 224, + 17, 0, 0, 0, 0, 0, + 70, 5, 2, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 32, 0, 0, 8, 18, 0, + 16, 0, 2, 0, 0, 0, + 26, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 1, 0, + 0, 0, 31, 0, 4, 3, + 10, 0, 16, 0, 2, 0, + 0, 0, 62, 0, 0, 1, + 21, 0, 0, 1, 168, 0, + 0, 8, 18, 240, 17, 0, + 0, 0, 0, 0, 10, 64, + 2, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 1, 0, 0, 0, + 168, 0, 0, 8, 18, 240, + 17, 0, 1, 0, 0, 0, + 10, 64, 2, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 1, 0, + 0, 0, 168, 0, 0, 8, + 18, 240, 17, 0, 2, 0, + 0, 0, 10, 64, 2, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 42, 0, 16, 0, + 1, 0, 0, 0, 168, 0, + 0, 8, 18, 240, 17, 0, + 3, 0, 0, 0, 10, 64, + 2, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 58, 0, + 16, 0, 1, 0, 0, 0, + 190, 24, 0, 1, 1, 0, + 0, 6, 18, 0, 16, 0, + 2, 0, 0, 0, 10, 64, + 2, 0, 1, 64, 0, 0, + 9, 0, 0, 0, 31, 0, + 0, 3, 10, 0, 16, 0, + 2, 0, 0, 0, 30, 0, + 0, 9, 114, 0, 16, 0, + 2, 0, 0, 0, 6, 64, + 2, 0, 2, 64, 0, 0, + 1, 0, 0, 0, 8, 0, + 0, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 18, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 34, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 1, 0, 0, 0, 167, 0, + 0, 9, 66, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 2, 0, 0, 0, 167, 0, + 0, 9, 130, 0, 16, 0, + 3, 0, 0, 0, 10, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 3, 0, 0, 0, 167, 0, + 0, 9, 18, 0, 16, 0, + 4, 0, 0, 0, 26, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 34, 0, 16, 0, + 4, 0, 0, 0, 26, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 1, 0, 0, 0, 167, 0, + 0, 9, 66, 0, 16, 0, + 4, 0, 0, 0, 26, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 2, 0, 0, 0, 167, 0, + 0, 9, 130, 0, 16, 0, + 4, 0, 0, 0, 26, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 3, 0, 0, 0, 167, 0, + 0, 9, 18, 0, 16, 0, + 5, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 34, 0, 16, 0, + 5, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 1, 0, 0, 0, 167, 0, + 0, 9, 66, 0, 16, 0, + 5, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 2, 0, 0, 0, 167, 0, + 0, 9, 130, 0, 16, 0, + 5, 0, 0, 0, 42, 0, + 16, 0, 2, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 3, 0, 0, 0, 50, 0, + 0, 12, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 62, 0, 0, 128, 62, + 0, 0, 128, 62, 0, 0, + 128, 62, 70, 14, 16, 0, + 3, 0, 0, 0, 0, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 7, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 5, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 10, 242, 0, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 62, 0, 0, + 128, 62, 0, 0, 128, 62, + 0, 0, 128, 62, 85, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 5, + 2, 0, 2, 64, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 164, 0, + 0, 7, 242, 224, 17, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 168, 0, 0, 8, + 18, 240, 17, 0, 0, 0, + 0, 0, 10, 64, 2, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 1, 0, 0, 0, 168, 0, + 0, 8, 18, 240, 17, 0, + 1, 0, 0, 0, 10, 64, + 2, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 26, 0, + 16, 0, 1, 0, 0, 0, + 168, 0, 0, 8, 18, 240, + 17, 0, 2, 0, 0, 0, + 10, 64, 2, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 42, 0, 16, 0, 1, 0, + 0, 0, 168, 0, 0, 8, + 18, 240, 17, 0, 3, 0, + 0, 0, 10, 64, 2, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 58, 0, 16, 0, + 1, 0, 0, 0, 21, 0, + 0, 1, 32, 0, 0, 8, + 18, 0, 16, 0, 0, 0, + 0, 0, 26, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 2, 0, 0, 0, 31, 0, + 4, 3, 10, 0, 16, 0, + 0, 0, 0, 0, 62, 0, + 0, 1, 21, 0, 0, 1, + 190, 24, 0, 1, 1, 0, + 0, 6, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 64, + 2, 0, 1, 64, 0, 0, + 27, 0, 0, 0, 31, 0, + 0, 3, 10, 0, 16, 0, + 0, 0, 0, 0, 30, 0, + 0, 9, 114, 0, 16, 0, + 0, 0, 0, 0, 6, 64, + 2, 0, 2, 64, 0, 0, + 2, 0, 0, 0, 16, 0, + 0, 0, 18, 0, 0, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 18, 0, 16, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 34, 0, 16, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 1, 0, 0, 0, 167, 0, + 0, 9, 66, 0, 16, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 2, 0, 0, 0, 167, 0, + 0, 9, 130, 0, 16, 0, + 2, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 3, 0, 0, 0, 167, 0, + 0, 9, 18, 0, 16, 0, + 3, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 34, 0, 16, 0, + 3, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 1, 0, 0, 0, 167, 0, + 0, 9, 66, 0, 16, 0, + 3, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 2, 0, 0, 0, 167, 0, + 0, 9, 130, 0, 16, 0, + 3, 0, 0, 0, 26, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 3, 0, 0, 0, 167, 0, + 0, 9, 18, 0, 16, 0, + 4, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 34, 0, 16, 0, + 4, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 1, 0, 0, 0, 167, 0, + 0, 9, 66, 0, 16, 0, + 4, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 2, 0, 0, 0, 167, 0, + 0, 9, 130, 0, 16, 0, + 4, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 3, 0, 0, 0, 0, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 70, 14, 16, 0, 2, 0, + 0, 0, 0, 0, 0, 7, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 62, 0, 0, 128, 62, + 0, 0, 128, 62, 0, 0, + 128, 62, 85, 0, 0, 9, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 5, 2, 0, + 2, 64, 0, 0, 2, 0, + 0, 0, 2, 0, 0, 0, + 2, 0, 0, 0, 2, 0, + 0, 0, 164, 0, 0, 7, + 242, 224, 17, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 1, 0, 0, 0, + 168, 0, 0, 8, 18, 240, + 17, 0, 0, 0, 0, 0, + 10, 64, 2, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 1, 0, + 0, 0, 168, 0, 0, 8, + 18, 240, 17, 0, 1, 0, + 0, 0, 10, 64, 2, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 26, 0, 16, 0, + 1, 0, 0, 0, 168, 0, + 0, 8, 18, 240, 17, 0, + 2, 0, 0, 0, 10, 64, + 2, 0, 1, 64, 0, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 1, 0, 0, 0, + 168, 0, 0, 8, 18, 240, + 17, 0, 3, 0, 0, 0, + 10, 64, 2, 0, 1, 64, + 0, 0, 0, 0, 0, 0, + 58, 0, 16, 0, 1, 0, + 0, 0, 21, 0, 0, 1, + 32, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 26, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 3, 0, + 0, 0, 31, 0, 4, 3, + 10, 0, 16, 0, 0, 0, + 0, 0, 62, 0, 0, 1, + 21, 0, 0, 1, 190, 24, + 0, 1, 31, 0, 0, 2, + 10, 64, 2, 0, 167, 0, + 0, 9, 18, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 34, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 1, 0, 0, 0, 167, 0, + 0, 9, 66, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 2, 0, 0, 0, 167, 0, + 0, 9, 130, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 4, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 3, 0, 0, 0, 167, 0, + 0, 9, 18, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 32, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 34, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 32, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 1, 0, 0, 0, 167, 0, + 0, 9, 66, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 32, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 2, 0, 0, 0, 167, 0, + 0, 9, 130, 0, 16, 0, + 2, 0, 0, 0, 1, 64, + 0, 0, 32, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 3, 0, 0, 0, 167, 0, + 0, 9, 18, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 36, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 0, 0, 0, 0, 167, 0, + 0, 9, 34, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 36, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 1, 0, 0, 0, 167, 0, + 0, 9, 66, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 36, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 2, 0, 0, 0, 167, 0, + 0, 9, 130, 0, 16, 0, + 3, 0, 0, 0, 1, 64, + 0, 0, 36, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 0, 6, 240, 17, 0, + 3, 0, 0, 0, 0, 0, + 0, 7, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 7, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 14, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 10, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 62, 0, 0, 128, 62, + 0, 0, 128, 62, 0, 0, + 128, 62, 85, 0, 0, 9, + 242, 0, 16, 0, 1, 0, + 0, 0, 70, 5, 2, 0, + 2, 64, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 3, 0, + 0, 0, 164, 0, 0, 7, + 242, 224, 17, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 1, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 21, 0, 0, 1, 62, 0, + 0, 1, 83, 84, 65, 84, + 148, 0, 0, 0, 111, 0, + 0, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 22, 0, 0, 0, + 5, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 6, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0 +}; + +#endif // Q_OS_WIN + +#endif // CS_MIPMAP_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstractfileiconengine_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstractfileiconengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7c92f0307b9df3b9fc3828d4499320b486e19dab --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstractfileiconengine_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTFILEICONENGINE_P_H +#define QABSTRACTFILEICONENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QAbstractFileIconEngine : public QPixmapIconEngine +{ +public: + explicit QAbstractFileIconEngine(const QFileInfo &info, QPlatformTheme::IconOptions opts) + : QPixmapIconEngine(), m_fileInfo(info), m_options(opts) {} + + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State) override; + QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State, qreal scale) override; + QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override; + bool isNull() override { return false; } + + QFileInfo fileInfo() const { return m_fileInfo; } + QPlatformTheme::IconOptions options() const { return m_options; } + + // Helper to convert a sequence of ints to a list of QSize + template static QList toSizeList(It i1, It i2); + +protected: + virtual QPixmap filePixmap(const QSize &size, QIcon::Mode mode, QIcon::State) = 0; + virtual QString cacheKey() const; + +private: + const QFileInfo m_fileInfo; + const QPlatformTheme::IconOptions m_options; +}; + +template +inline QList QAbstractFileIconEngine::toSizeList(It i1, It i2) +{ + QList result; + result.reserve(int(i2 - i1)); + for ( ; i1 != i2; ++i1) + result.append(QSize(*i1, *i1)); + return result; +} + +QT_END_NAMESPACE + +#endif // QABSTRACTFILEICONENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstractfileiconprovider_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstractfileiconprovider_p.h new file mode 100644 index 0000000000000000000000000000000000000000..276932d5e450a68186ebd82772325ae0b860cd5b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstractfileiconprovider_p.h @@ -0,0 +1,52 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTFILEICONPROVIDER_P_H +#define QABSTRACTFILEICONPROVIDER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#if QT_CONFIG(mimetype) +#include +#endif +#include "qabstractfileiconprovider.h" + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QAbstractFileIconProviderPrivate +{ + Q_DECLARE_PUBLIC(QAbstractFileIconProvider) + +public: + QAbstractFileIconProviderPrivate(QAbstractFileIconProvider *q); + virtual ~QAbstractFileIconProviderPrivate(); + + QIcon getPlatformThemeIcon(QAbstractFileIconProvider::IconType type) const; + QIcon getIconThemeIcon(QAbstractFileIconProvider::IconType type) const; + QIcon getPlatformThemeIcon(const QFileInfo &info) const; + QIcon getIconThemeIcon(const QFileInfo &info) const; + + static void clearIconTypeCache(); + static QString getFileType(const QFileInfo &info); + + QAbstractFileIconProvider *q_ptr = nullptr; + QAbstractFileIconProvider::Options options = {}; + +#if QT_CONFIG(mimetype) + QMimeDatabase mimeDatabase; +#endif +}; + +QT_END_NAMESPACE + +#endif // QABSTRACTFILEICONPROVIDER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstractlayoutstyleinfo_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstractlayoutstyleinfo_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f7a3e82475dde4ee93b39a6d3279d9ae3b830a58 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstractlayoutstyleinfo_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTLAYOUTSTYLEINFO_P_H +#define QABSTRACTLAYOUTSTYLEINFO_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include "qlayoutpolicy_p.h" + +QT_BEGIN_NAMESPACE + + +class Q_GUI_EXPORT QAbstractLayoutStyleInfo { +public: + + QAbstractLayoutStyleInfo() : m_isWindow(false) {} + virtual ~QAbstractLayoutStyleInfo() {} + virtual qreal combinedLayoutSpacing(QLayoutPolicy::ControlTypes /*controls1*/, + QLayoutPolicy::ControlTypes /*controls2*/, Qt::Orientation /*orientation*/) const { + return -1; + } + + virtual qreal perItemSpacing(QLayoutPolicy::ControlType /*control1*/, + QLayoutPolicy::ControlType /*control2*/, + Qt::Orientation /*orientation*/) const { + return -1; + } + + virtual qreal spacing(Qt::Orientation orientation) const = 0; + + virtual bool hasChangedCore() const { return false; } // ### Remove when usage is gone from subclasses + + virtual void invalidate() { } + + virtual qreal windowMargin(Qt::Orientation orientation) const = 0; + + bool isWindow() const { + return m_isWindow; + } + +protected: + unsigned m_isWindow : 1; + mutable unsigned m_hSpacingState: 2; + mutable unsigned m_vSpacingState: 2; + mutable qreal m_spacing[2]; +}; + +QT_END_NAMESPACE + +#endif // QABSTRACTLAYOUTSTYLEINFO_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstracttextdocumentlayout_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstracttextdocumentlayout_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6049228df54bba56c6d6a6e662c215047800d0fb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qabstracttextdocumentlayout_p.h @@ -0,0 +1,78 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTTEXTDOCUMENTLAYOUT_P_H +#define QABSTRACTTEXTDOCUMENTLAYOUT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "private/qobject_p.h" +#include "qtextdocument_p.h" +#include "qabstracttextdocumentlayout.h" + +#include "QtCore/qhash.h" +#include + +QT_BEGIN_NAMESPACE + +struct QTextObjectHandler +{ + QTextObjectHandler() : iface(nullptr) {} + QTextObjectInterface *iface; + QPointer component; +}; +typedef QHash HandlerHash; + +class Q_GUI_EXPORT QAbstractTextDocumentLayoutPrivate : public QObjectPrivate +{ +public: + Q_DECLARE_PUBLIC(QAbstractTextDocumentLayout) + + inline QAbstractTextDocumentLayoutPrivate() + : paintDevice(nullptr) {} + ~QAbstractTextDocumentLayoutPrivate(); + + inline void setDocument(QTextDocument *doc) { + document = doc; + docPrivate = nullptr; + if (doc) + docPrivate = QTextDocumentPrivate::get(doc); + } + + static QAbstractTextDocumentLayoutPrivate *get(QAbstractTextDocumentLayout *layout) + { + return layout->d_func(); + } + + bool hasHandlers() const + { + return !handlers.isEmpty(); + } + + inline int _q_dynamicPageCountSlot() const + { return q_func()->pageCount(); } + inline QSizeF _q_dynamicDocumentSizeSlot() const + { return q_func()->documentSize(); } + + HandlerHash handlers; + + void _q_handlerDestroyed(QObject *obj); + QPaintDevice *paintDevice; + + QTextDocument *document; + QTextDocumentPrivate *docPrivate; +}; + +QT_END_NAMESPACE + +#endif // QABSTRACTTEXTDOCUMENTLAYOUT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qaccessiblebridgeutils_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qaccessiblebridgeutils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4ed82c08ceb0439a2eb7d1cb0673852e29279c23 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qaccessiblebridgeutils_p.h @@ -0,0 +1,36 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QACCESSIBLEBRIDGEUTILS_H +#define QACCESSIBLEBRIDGEUTILS_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include +#include + +QT_REQUIRE_CONFIG(accessibility); + +QT_BEGIN_NAMESPACE + +namespace QAccessibleBridgeUtils { + Q_GUI_EXPORT QStringList effectiveActionNames(QAccessibleInterface *iface); + Q_GUI_EXPORT bool performEffectiveAction(QAccessibleInterface *iface, const QString &actionName); + Q_GUI_EXPORT QString accessibleId(QAccessibleInterface *accessible); +} + +QT_END_NAMESPACE + +#endif //QACCESSIBLEBRIDGEUTILS_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qaccessiblecache_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qaccessiblecache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6693bdc29e1df416d2c9a88ac56820ee202122e6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qaccessiblecache_p.h @@ -0,0 +1,72 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QACCESSIBLECACHE_P +#define QACCESSIBLECACHE_P + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#include "qaccessible.h" + +#if QT_CONFIG(accessibility) + +Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QMacAccessibilityElement)); + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QAccessibleCache :public QObject +{ + Q_OBJECT + +public: + ~QAccessibleCache() override; + static QAccessibleCache *instance(); + QAccessibleInterface *interfaceForId(QAccessible::Id id) const; + QAccessible::Id idForInterface(QAccessibleInterface *iface) const; + QAccessible::Id idForObject(QObject *obj) const; + bool containsObject(QObject *obj) const; + QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const; + void deleteInterface(QAccessible::Id id, QObject *obj = nullptr); + +#ifdef Q_OS_APPLE + QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *elementForId(QAccessible::Id axid) const; + void insertElement(QAccessible::Id axid, QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *element) const; +#endif + +private Q_SLOTS: + void objectDestroyed(QObject *obj); + +private: + QAccessible::Id acquireId() const; + + mutable QHash idToInterface; + mutable QHash interfaceToId; + mutable QMultiHash> objectToId; + +#ifdef Q_OS_APPLE + void removeAccessibleElement(QAccessible::Id axid); + mutable QHash accessibleElements; +#endif + + friend class QAccessible; + friend class QAccessibleInterface; +}; + +QT_END_NAMESPACE + +#endif // QT_CONFIG(accessibility) + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qaction_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qaction_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5df6783bb8c653a5ddeb0f3b005ced28ed69e8a8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qaction_p.h @@ -0,0 +1,102 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QACTION_P_H +#define QACTION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#if QT_CONFIG(shortcut) +# include +#endif + +#include +#include "private/qobject_p.h" + +QT_REQUIRE_CONFIG(action); + +QT_BEGIN_NAMESPACE + +class QShortcutMap; + +class Q_GUI_EXPORT QActionPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QAction) +public: + QActionPrivate(); + ~QActionPrivate(); + + virtual void destroy(); + +#if QT_CONFIG(shortcut) + virtual QShortcutMap::ContextMatcher contextMatcher() const; +#endif + + static QActionPrivate *get(QAction *q) + { + return q->d_func(); + } + + bool setEnabled(bool enable, bool byGroup); + void setVisible(bool b); + + QPointer group; + QString text; + QString iconText; + QIcon icon; + QString tooltip; + QString statustip; + QString whatsthis; +#if QT_CONFIG(shortcut) + QList shortcuts; +#endif + QVariant userData; + + QObjectList associatedObjects; + virtual QObject *menu() const; + virtual void setMenu(QObject *menu); + +#if QT_CONFIG(shortcut) + QList shortcutIds; + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut; + uint autorepeat : 1; +#endif + QFont font; + uint enabled : 1, explicitEnabled : 1, explicitEnabledValue : 1; + uint visible : 1, forceInvisible : 1; + uint checkable : 1; + uint checked : 1; + uint separator : 1; + uint fontSet : 1; + + int iconVisibleInMenu : 2; // Only has values -1, 0, and 1 + int shortcutVisibleInContextMenu : 2; // Only has values -1, 0, and 1 + + QAction::MenuRole menuRole = QAction::TextHeuristicRole; + QAction::Priority priority = QAction::NormalPriority; + +#if QT_CONFIG(shortcut) + void redoGrab(QShortcutMap &map); + void redoGrabAlternate(QShortcutMap &map); + void setShortcutEnabled(bool enable, QShortcutMap &map); +#endif // QT_NO_SHORTCUT + + bool showStatusText(QObject *widget, const QString &str); + void sendDataChanged(); +}; + +QT_END_NAMESPACE + +#endif // QACTION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qactiongroup_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qactiongroup_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cbcf829c3149f5284338d52771ee8b8af734a948 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qactiongroup_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QGUIACTIONGROUP_P_H +#define QGUIACTIONGROUP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#if QT_CONFIG(shortcut) +# include +#endif + +#include +#include "private/qobject_p.h" + +QT_REQUIRE_CONFIG(action); + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QActionGroupPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QActionGroup) +public: + enum Signal { Triggered, Hovered }; + + QActionGroupPrivate(); + ~QActionGroupPrivate(); + + virtual void emitSignal(Signal, QAction *) {} + + QList actions; + QPointer current; + uint enabled : 1; + uint visible : 1; + QActionGroup::ExclusionPolicy exclusionPolicy = QActionGroup::ExclusionPolicy::Exclusive; + +private: + void _q_actionTriggered(); //private slot + void _q_actionChanged(); //private slot + void _q_actionHovered(); //private slot +}; + +QT_END_NAMESPACE + +#endif // QACTIONGROUP_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qastchandler_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qastchandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..46be7589eff4a3d2b103339a62d96b3d5959938b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qastchandler_p.h @@ -0,0 +1,38 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QASTCHANDLER_H +#define QASTCHANDLER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtexturefilehandler_p.h" + +QT_BEGIN_NAMESPACE + +class QAstcHandler : public QTextureFileHandler +{ +public: + using QTextureFileHandler::QTextureFileHandler; + ~QAstcHandler() override; + + static bool canRead(const QByteArray &suffix, const QByteArray &block); + + QTextureFileData read() override; + +private: + quint32 astcGLFormat(quint8 xBlockDim, quint8 yBlockDim) const; +}; + +QT_END_NAMESPACE + +#endif // QASTCHANDLER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbackingstoredefaultcompositor_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbackingstoredefaultcompositor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e39172b4ba207f4e28cc64ec032ab57b0df67a17 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbackingstoredefaultcompositor_p.h @@ -0,0 +1,110 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QBACKINGSTOREDEFAULTCOMPOSITOR_P_H +#define QBACKINGSTOREDEFAULTCOMPOSITOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QBackingStoreDefaultCompositor +{ +public: + ~QBackingStoreDefaultCompositor(); + + void reset(); + + QRhiTexture *toTexture(const QPlatformBackingStore *backingStore, + QRhi *rhi, + QRhiResourceUpdateBatch *resourceUpdates, + const QRegion &dirtyRegion, + QPlatformBackingStore::TextureFlags *flags) const; + + QPlatformBackingStore::FlushResult flush(QPlatformBackingStore *backingStore, + QRhi *rhi, + QRhiSwapChain *swapchain, + QWindow *window, + qreal sourceDevicePixelRatio, + const QRegion ®ion, + const QPoint &offset, + QPlatformTextureList *textures, + bool translucentBackground); + +private: + enum UpdateUniformOption { + NeedsRedBlueSwap = 1 << 0, + NeedsAlphaRotate = 1 << 1 + }; + Q_DECLARE_FLAGS(UpdateUniformOptions, UpdateUniformOption) + enum UpdateQuadDataOption { + NeedsLinearFiltering = 1 << 0 + }; + Q_DECLARE_FLAGS(UpdateQuadDataOptions, UpdateQuadDataOption) + + void ensureResources(QRhiResourceUpdateBatch *resourceUpdates, QRhiRenderPassDescriptor *rpDesc); + QRhiTexture *toTexture(const QImage &image, + QRhi *rhi, + QRhiResourceUpdateBatch *resourceUpdates, + const QRegion &dirtyRegion, + QPlatformBackingStore::TextureFlags *flags) const; + + mutable QRhi *m_rhi = nullptr; + mutable std::unique_ptr m_texture; + + std::unique_ptr m_vbuf; + std::unique_ptr m_samplerNearest; + std::unique_ptr m_samplerLinear; + std::unique_ptr m_psNoBlend; + std::unique_ptr m_psBlend; + std::unique_ptr m_psPremulBlend; + + struct PerQuadData { + QRhiBuffer *ubuf = nullptr; + // All srbs are layout-compatible. + QRhiShaderResourceBindings *srb = nullptr; + QRhiShaderResourceBindings *srbExtra = nullptr; // may be null (used for stereo) + QRhiTexture *lastUsedTexture = nullptr; + QRhiTexture *lastUsedTextureExtra = nullptr; // may be null (used for stereo) + QRhiSampler::Filter lastUsedFilter = QRhiSampler::None; + bool isValid() const { return ubuf && srb; } + void reset() { + delete ubuf; + ubuf = nullptr; + delete srb; + srb = nullptr; + if (srbExtra) { + delete srbExtra; + srbExtra = nullptr; + } + lastUsedTexture = nullptr; + lastUsedTextureExtra = nullptr; + lastUsedFilter = QRhiSampler::None; + } + }; + PerQuadData m_widgetQuadData; + QVarLengthArray m_textureQuadData; + + PerQuadData createPerQuadData(QRhiTexture *texture, QRhiTexture *textureExtra = nullptr); + void updatePerQuadData(PerQuadData *d, QRhiTexture *texture, QRhiTexture *textureExtra = nullptr, + UpdateQuadDataOptions options = {}); + void updateUniforms(PerQuadData *d, QRhiResourceUpdateBatch *resourceUpdates, + const QMatrix4x4 &target, const QMatrix3x3 &source, + UpdateUniformOptions options = {}); +}; + +QT_END_NAMESPACE + +#endif // QBACKINGSTOREDEFAULTCOMPOSITOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbackingstorerhisupport_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbackingstorerhisupport_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0e26500121099941f7b23e44338a01b71c0aeb93 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbackingstorerhisupport_p.h @@ -0,0 +1,77 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QBACKINGSTORERHISUPPORT_P_H +#define QBACKINGSTORERHISUPPORT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QBackingStoreRhiSupport +{ +public: + ~QBackingStoreRhiSupport(); + + void reset(); + + void setFormat(const QSurfaceFormat &format) { m_format = format; } + void setWindow(QWindow *window) { m_window = window; } + void setConfig(const QPlatformBackingStoreRhiConfig &config) { m_config = config; } + + bool create(); + + QRhiSwapChain *swapChainForWindow(QWindow *window); + + static QSurface::SurfaceType surfaceTypeForConfig(const QPlatformBackingStoreRhiConfig &config); + + static bool checkForceRhi(QPlatformBackingStoreRhiConfig *outConfig, QSurface::SurfaceType *outType); + + static QRhi::Implementation apiToRhiBackend(QPlatformBackingStoreRhiConfig::Api api); + + QRhi *rhi() const { return m_rhi; } + +private: + QSurfaceFormat m_format; + QWindow *m_window = nullptr; + QPlatformBackingStoreRhiConfig m_config; + QRhi *m_rhi = nullptr; + QOffscreenSurface *m_openGLFallbackSurface = nullptr; + struct SwapchainData { + QRhiSwapChain *swapchain = nullptr; + QRhiRenderPassDescriptor *renderPassDescriptor = nullptr; + QObject *windowWatcher = nullptr; + void reset(); + }; + QHash m_swapchains; + friend class QBackingStoreRhiSupportWindowWatcher; +}; + +class QBackingStoreRhiSupportWindowWatcher : public QObject +{ +public: + QBackingStoreRhiSupportWindowWatcher(QBackingStoreRhiSupport *rhiSupport) : m_rhiSupport(rhiSupport) { } + bool eventFilter(QObject *obj, QEvent *ev) override; +private: + QBackingStoreRhiSupport *m_rhiSupport; +}; + +QT_END_NAMESPACE + +#endif // QBACKINGSTORERHISUPPORT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbasicvulkanplatforminstance_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbasicvulkanplatforminstance_p.h new file mode 100644 index 0000000000000000000000000000000000000000..08f15d1bb23106b601972f1bb424b2065b23893c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbasicvulkanplatforminstance_p.h @@ -0,0 +1,88 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QBASICVULKANPLATFORMINSTANCE_P_H +#define QBASICVULKANPLATFORMINSTANCE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QBasicPlatformVulkanInstance : public QPlatformVulkanInstance +{ +public: + QBasicPlatformVulkanInstance(); + ~QBasicPlatformVulkanInstance(); + + QVulkanInfoVector supportedLayers() const override; + QVulkanInfoVector supportedExtensions() const override; + QVersionNumber supportedApiVersion() const override; + bool isValid() const override; + VkResult errorCode() const override; + VkInstance vkInstance() const override; + QByteArrayList enabledLayers() const override; + QByteArrayList enabledExtensions() const override; + PFN_vkVoidFunction getInstanceProcAddr(const char *name) override; + bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override; + void setDebugFilters(const QList &filters) override; + void setDebugUtilsFilters(const QList &filters) override; + + void destroySurface(VkSurfaceKHR surface) const; + const QList *debugFilters() const { return &m_debugFilters; } + const QList *debugUtilsFilters() const { return &m_debugUtilsFilters; } + +protected: + void loadVulkanLibrary(const QString &defaultLibraryName, int defaultLibraryVersion = -1); + void init(QLibrary *lib); + void initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts); + + VkInstance m_vkInst = VK_NULL_HANDLE; + PFN_vkGetInstanceProcAddr m_vkGetInstanceProcAddr = nullptr; + PFN_vkGetPhysicalDeviceSurfaceSupportKHR m_getPhysDevSurfaceSupport; + PFN_vkDestroySurfaceKHR m_destroySurface; + +private: + void setupDebugOutput(); + + std::unique_ptr m_vulkanLib; + + bool m_ownsVkInst = false; + VkResult m_errorCode = VK_SUCCESS; + QVulkanInfoVector m_supportedLayers; + QVulkanInfoVector m_supportedExtensions; + QVersionNumber m_supportedApiVersion; + QByteArrayList m_enabledLayers; + QByteArrayList m_enabledExtensions; + + PFN_vkCreateInstance m_vkCreateInstance; + PFN_vkEnumerateInstanceLayerProperties m_vkEnumerateInstanceLayerProperties; + PFN_vkEnumerateInstanceExtensionProperties m_vkEnumerateInstanceExtensionProperties; + + PFN_vkDestroyInstance m_vkDestroyInstance; + +#ifdef VK_EXT_debug_utils + VkDebugUtilsMessengerEXT m_debugMessenger = VK_NULL_HANDLE; + PFN_vkDestroyDebugUtilsMessengerEXT m_vkDestroyDebugUtilsMessengerEXT; +#endif + QList m_debugFilters; + QList m_debugUtilsFilters; +}; + +QT_END_NAMESPACE + +#endif // QBASICVULKANPLATFORMINSTANCE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbezier_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbezier_p.h new file mode 100644 index 0000000000000000000000000000000000000000..baf76d6de03837e5ff82101262a48b0029ecd70e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbezier_p.h @@ -0,0 +1,231 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QBEZIER_P_H +#define QBEZIER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtCore/qline.h" +#include "QtCore/qlist.h" +#include "QtCore/qpoint.h" +#include "QtCore/qrect.h" +#include "QtGui/qtransform.h" +#include + +QT_BEGIN_NAMESPACE + +class QPolygonF; + +class Q_GUI_EXPORT QBezier +{ +public: + static QBezier fromPoints(const QPointF &p1, const QPointF &p2, + const QPointF &p3, const QPointF &p4) + { return {p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y(), p4.x(), p4.y()}; } + + static void coefficients(qreal t, qreal &a, qreal &b, qreal &c, qreal &d); + + inline QPointF pointAt(qreal t) const; + inline QPointF normalVector(qreal t) const; + + inline QPointF derivedAt(qreal t) const; + inline QPointF secondDerivedAt(qreal t) const; + + QPolygonF toPolygon(qreal bezier_flattening_threshold = 0.5) const; + void addToPolygon(QPolygonF *p, qreal bezier_flattening_threshold = 0.5) const; + void addToPolygon(QDataBuffer &polygon, qreal bezier_flattening_threshold) const; + + QRectF bounds() const; + qreal length(qreal error = 0.01) const; + void addIfClose(qreal *length, qreal error) const; + + qreal tAtLength(qreal len) const; + + int stationaryYPoints(qreal &t0, qreal &t1) const; + qreal tForY(qreal t0, qreal t1, qreal y) const; + + QPointF pt1() const { return QPointF(x1, y1); } + QPointF pt2() const { return QPointF(x2, y2); } + QPointF pt3() const { return QPointF(x3, y3); } + QPointF pt4() const { return QPointF(x4, y4); } + + QBezier mapBy(const QTransform &transform) const; + + inline QPointF midPoint() const; + inline QLineF midTangent() const; + + inline QLineF startTangent() const; + inline QLineF endTangent() const; + + inline void parameterSplitLeft(qreal t, QBezier *left); + inline std::pair split() const; + + int shifted(QBezier *curveSegments, int maxSegmets, + qreal offset, float threshold) const; + + QBezier bezierOnInterval(qreal t0, qreal t1) const; + QBezier getSubRange(qreal t0, qreal t1) const; + + qreal x1, y1, x2, y2, x3, y3, x4, y4; +}; + +inline QPointF QBezier::midPoint() const +{ + return QPointF((x1 + x4 + 3*(x2 + x3))/8., (y1 + y4 + 3*(y2 + y3))/8.); +} + +inline QLineF QBezier::midTangent() const +{ + QPointF mid = midPoint(); + QLineF dir(QLineF(x1, y1, x2, y2).pointAt(0.5), QLineF(x3, y3, x4, y4).pointAt(0.5)); + return QLineF(mid.x() - dir.dx(), mid.y() - dir.dy(), + mid.x() + dir.dx(), mid.y() + dir.dy()); +} + +inline QLineF QBezier::startTangent() const +{ + QLineF tangent(pt1(), pt2()); + if (tangent.isNull()) + tangent = QLineF(pt1(), pt3()); + if (tangent.isNull()) + tangent = QLineF(pt1(), pt4()); + return tangent; +} + +inline QLineF QBezier::endTangent() const +{ + QLineF tangent(pt4(), pt3()); + if (tangent.isNull()) + tangent = QLineF(pt4(), pt2()); + if (tangent.isNull()) + tangent = QLineF(pt4(), pt1()); + return tangent; +} + +inline void QBezier::coefficients(qreal t, qreal &a, qreal &b, qreal &c, qreal &d) +{ + qreal m_t = 1. - t; + b = m_t * m_t; + c = t * t; + d = c * t; + a = b * m_t; + b *= 3. * t; + c *= 3. * m_t; +} + +inline QPointF QBezier::pointAt(qreal t) const +{ + // numerically more stable: + qreal x, y; + + qreal m_t = 1. - t; + { + qreal a = x1*m_t + x2*t; + qreal b = x2*m_t + x3*t; + qreal c = x3*m_t + x4*t; + a = a*m_t + b*t; + b = b*m_t + c*t; + x = a*m_t + b*t; + } + { + qreal a = y1*m_t + y2*t; + qreal b = y2*m_t + y3*t; + qreal c = y3*m_t + y4*t; + a = a*m_t + b*t; + b = b*m_t + c*t; + y = a*m_t + b*t; + } + return QPointF(x, y); +} + +inline QPointF QBezier::normalVector(qreal t) const +{ + qreal m_t = 1. - t; + qreal a = m_t * m_t; + qreal b = t * m_t; + qreal c = t * t; + + return QPointF((y2-y1) * a + (y3-y2) * b + (y4-y3) * c, -(x2-x1) * a - (x3-x2) * b - (x4-x3) * c); +} + +inline QPointF QBezier::derivedAt(qreal t) const +{ + // p'(t) = 3 * (-(1-2t+t^2) * p0 + (1 - 4 * t + 3 * t^2) * p1 + (2 * t - 3 * t^2) * p2 + t^2 * p3) + + qreal m_t = 1. - t; + + qreal d = t * t; + qreal a = -m_t * m_t; + qreal b = 1 - 4 * t + 3 * d; + qreal c = 2 * t - 3 * d; + + return 3 * QPointF(a * x1 + b * x2 + c * x3 + d * x4, + a * y1 + b * y2 + c * y3 + d * y4); +} + +inline QPointF QBezier::secondDerivedAt(qreal t) const +{ + qreal a = 2. - 2. * t; + qreal b = -4 + 6 * t; + qreal c = 2 - 6 * t; + qreal d = 2 * t; + + return 3 * QPointF(a * x1 + b * x2 + c * x3 + d * x4, + a * y1 + b * y2 + c * y3 + d * y4); +} + +std::pair QBezier::split() const +{ + const auto mid = [](QPointF lhs, QPointF rhs) { return (lhs + rhs) * .5; }; + + const QPointF mid_12 = mid(pt1(), pt2()); + const QPointF mid_23 = mid(pt2(), pt3()); + const QPointF mid_34 = mid(pt3(), pt4()); + const QPointF mid_12_23 = mid(mid_12, mid_23); + const QPointF mid_23_34 = mid(mid_23, mid_34); + const QPointF mid_12_23__23_34 = mid(mid_12_23, mid_23_34); + + return { + fromPoints(pt1(), mid_12, mid_12_23, mid_12_23__23_34), + fromPoints(mid_12_23__23_34, mid_23_34, mid_34, pt4()), + }; +} + +inline void QBezier::parameterSplitLeft(qreal t, QBezier *left) +{ + left->x1 = x1; + left->y1 = y1; + + left->x2 = x1 + t * ( x2 - x1 ); + left->y2 = y1 + t * ( y2 - y1 ); + + left->x3 = x2 + t * ( x3 - x2 ); // temporary holding spot + left->y3 = y2 + t * ( y3 - y2 ); // temporary holding spot + + x3 = x3 + t * ( x4 - x3 ); + y3 = y3 + t * ( y4 - y3 ); + + x2 = left->x3 + t * ( x3 - left->x3); + y2 = left->y3 + t * ( y3 - left->y3); + + left->x3 = left->x2 + t * ( left->x3 - left->x2 ); + left->y3 = left->y2 + t * ( left->y3 - left->y2 ); + + left->x4 = x1 = left->x3 + t * (x2 - left->x3); + left->y4 = y1 = left->y3 + t * (y2 - left->y3); +} + +QT_END_NAMESPACE + +#endif // QBEZIER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qblendfunctions_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qblendfunctions_p.h new file mode 100644 index 0000000000000000000000000000000000000000..409ca9e5471be11922547b8db4163b5fdbb6f321 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qblendfunctions_p.h @@ -0,0 +1,448 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QBLENDFUNCTIONS_P_H +#define QBLENDFUNCTIONS_P_H + +#include +#include +#include "qdrawhelper_p.h" + +QT_BEGIN_NAMESPACE + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +template +void qt_scale_image_16bit(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, int srch, + const QRectF &targetRect, + const QRectF &srcRect, + const QRect &clip, + T blender) +{ + qreal sx = srcRect.width() / (qreal) targetRect.width(); + qreal sy = srcRect.height() / (qreal) targetRect.height(); + + const int ix = 0x00010000 * sx; + const int iy = 0x00010000 * sy; + +// qDebug() << "scale:" << Qt::endl +// << " - target" << targetRect << Qt::endl +// << " - source" << srcRect << Qt::endl +// << " - clip" << clip << Qt::endl +// << " - sx=" << sx << " sy=" << sy << " ix=" << ix << " iy=" << iy; + + QRect tr = targetRect.normalized().toRect(); + tr = tr.intersected(clip); + if (tr.isEmpty()) + return; + const int tx1 = tr.left(); + const int ty1 = tr.top(); + int h = tr.height(); + int w = tr.width(); + + quint32 basex; + quint32 srcy; + + if (sx < 0) { + int dstx = qFloor((tx1 + qreal(0.5) - targetRect.right()) * sx * 65536) + 1; + basex = quint32(srcRect.right() * 65536) + dstx; + } else { + int dstx = qCeil((tx1 + qreal(0.5) - targetRect.left()) * sx * 65536) - 1; + basex = quint32(srcRect.left() * 65536) + dstx; + } + if (sy < 0) { + int dsty = qFloor((ty1 + qreal(0.5) - targetRect.bottom()) * sy * 65536) + 1; + srcy = quint32(srcRect.bottom() * 65536) + dsty; + } else { + int dsty = qCeil((ty1 + qreal(0.5) - targetRect.top()) * sy * 65536) - 1; + srcy = quint32(srcRect.top() * 65536) + dsty; + } + + quint16 *dst = ((quint16 *) (destPixels + ty1 * dbpl)) + tx1; + + // this bounds check here is required as floating point rounding above might in some cases lead to + // w/h values that are one pixel too large, falling outside of the valid image area. + const int ystart = srcy >> 16; + if (ystart >= srch && iy < 0) { + srcy += iy; + --h; + } + const int xstart = basex >> 16; + if (xstart >= (int)(sbpl/sizeof(SRC)) && ix < 0) { + basex += ix; + --w; + } + int yend = (srcy + iy * (h - 1)) >> 16; + if (yend < 0 || yend >= srch) + --h; + int xend = (basex + ix * (w - 1)) >> 16; + if (xend < 0 || xend >= (int)(sbpl/sizeof(SRC))) + --w; + + while (--h >= 0) { + const SRC *src = (const SRC *) (srcPixels + (srcy >> 16) * sbpl); + quint32 srcx = basex; + int x = 0; + for (; x> 16]); srcx += ix; + blender.write(&dst[x+1], src[srcx >> 16]); srcx += ix; + blender.write(&dst[x+2], src[srcx >> 16]); srcx += ix; + blender.write(&dst[x+3], src[srcx >> 16]); srcx += ix; + blender.write(&dst[x+4], src[srcx >> 16]); srcx += ix; + blender.write(&dst[x+5], src[srcx >> 16]); srcx += ix; + blender.write(&dst[x+6], src[srcx >> 16]); srcx += ix; + blender.write(&dst[x+7], src[srcx >> 16]); srcx += ix; + } + for (; x> 16]); + srcx += ix; + } + blender.flush(&dst[x]); + dst = (quint16 *)(((uchar *) dst) + dbpl); + srcy += iy; + } +} + +template void qt_scale_image_32bit(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, int srch, + const QRectF &targetRect, + const QRectF &srcRect, + const QRect &clip, + T blender) +{ + qreal sx = srcRect.width() / (qreal) targetRect.width(); + qreal sy = srcRect.height() / (qreal) targetRect.height(); + + const int ix = 0x00010000 * sx; + const int iy = 0x00010000 * sy; + +// qDebug() << "scale:" << Qt::endl +// << " - target" << targetRect << Qt::endl +// << " - source" << srcRect << Qt::endl +// << " - clip" << clip << Qt::endl +// << " - sx=" << sx << " sy=" << sy << " ix=" << ix << " iy=" << iy; + + QRect tr = targetRect.normalized().toRect(); + tr = tr.intersected(clip); + if (tr.isEmpty()) + return; + const int tx1 = tr.left(); + const int ty1 = tr.top(); + int h = tr.height(); + int w = tr.width(); + + quint32 basex; + quint32 srcy; + + if (sx < 0) { + int dstx = qFloor((tx1 + qreal(0.5) - targetRect.right()) * sx * 65536) + 1; + basex = quint32(srcRect.right() * 65536) + dstx; + } else { + int dstx = qCeil((tx1 + qreal(0.5) - targetRect.left()) * sx * 65536) - 1; + basex = quint32(srcRect.left() * 65536) + dstx; + } + if (sy < 0) { + int dsty = qFloor((ty1 + qreal(0.5) - targetRect.bottom()) * sy * 65536) + 1; + srcy = quint32(srcRect.bottom() * 65536) + dsty; + } else { + int dsty = qCeil((ty1 + qreal(0.5) - targetRect.top()) * sy * 65536) - 1; + srcy = quint32(srcRect.top() * 65536) + dsty; + } + + quint32 *dst = ((quint32 *) (destPixels + ty1 * dbpl)) + tx1; + + // this bounds check here is required as floating point rounding above might in some cases lead to + // w/h values that are one pixel too large, falling outside of the valid image area. + const int ystart = srcy >> 16; + if (ystart >= srch && iy < 0) { + srcy += iy; + --h; + } + const int xstart = basex >> 16; + if (xstart >= (int)(sbpl/sizeof(quint32)) && ix < 0) { + basex += ix; + --w; + } + int yend = (srcy + iy * (h - 1)) >> 16; + if (yend < 0 || yend >= srch) + --h; + int xend = (basex + ix * (w - 1)) >> 16; + if (xend < 0 || xend >= (int)(sbpl/sizeof(quint32))) + --w; + + while (--h >= 0) { + const uint *src = (const quint32 *) (srcPixels + (srcy >> 16) * sbpl); + quint32 srcx = basex; + int x = 0; + for (; x> 16]); + srcx += ix; + } + blender.flush(&dst[x]); + dst = (quint32 *)(((uchar *) dst) + dbpl); + srcy += iy; + } +} + +struct QTransformImageVertex +{ + qreal x, y, u, v; // destination coordinates (x, y) and source coordinates (u, v) +}; + +template +void qt_transform_image_rasterize(DestT *destPixels, int dbpl, + const SrcT *srcPixels, int sbpl, + const QTransformImageVertex &topLeft, const QTransformImageVertex &bottomLeft, + const QTransformImageVertex &topRight, const QTransformImageVertex &bottomRight, + const QRect &sourceRect, + const QRect &clip, + qreal topY, qreal bottomY, + int dudx, int dvdx, int dudy, int dvdy, int u0, int v0, + Blender blender) +{ + qint64 fromY = qMax(qRound(topY), clip.top()); + qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height()); + if (fromY >= toY) + return; + + qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y); + qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y); + qint64 dx_l = qint64(leftSlope * 0x10000); + qint64 dx_r = qint64(rightSlope * 0x10000); + qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000); + qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000); + + qint64 sourceRectTop = qint64(sourceRect.top()); + qint64 sourceRectLeft = qint64(sourceRect.left()); + qint64 sourceRectWidth = qint64(sourceRect.width()); + qint64 sourceRectHeight = qint64(sourceRect.height()); + qint64 clipLeft = qint64(clip.left()); + qint64 clipWidth = qint64(clip.width()); + + qint64 fromX, toX, x1, x2, u, v, i, ii; + DestT *line; + for (qint64 y = fromY; y < toY; ++y) { + line = reinterpret_cast(reinterpret_cast(destPixels) + y * dbpl); + + fromX = qMax(x_l >> 16, clipLeft); + toX = qMin(x_r >> 16, clipLeft + clipWidth); + if (fromX < toX) { + // Because of rounding, we can get source coordinates outside the source image. + // Clamp these coordinates to the source rect to avoid segmentation fault and + // garbage on the screen. + + // Find the first pixel on the current scan line where the source coordinates are within the source rect. + x1 = fromX; + u = x1 * dudx + y * dudy + u0; + v = x1 * dvdx + y * dvdy + v0; + for (; x1 < toX; ++x1) { + qint64 uu = u >> 16; + qint64 vv = v >> 16; + if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth + && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) { + break; + } + u += dudx; + v += dvdx; + } + + // Find the last pixel on the current scan line where the source coordinates are within the source rect. + x2 = toX; + u = (x2 - 1) * dudx + y * dudy + u0; + v = (x2 - 1) * dvdx + y * dvdy + v0; + for (; x2 > x1; --x2) { + qint64 uu = u >> 16; + qint64 vv = v >> 16; + if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth + && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) { + break; + } + u -= dudx; + v -= dvdx; + } + + // Set up values at the beginning of the scan line. + u = fromX * dudx + y * dudy + u0; + v = fromX * dvdx + y * dvdy + v0; + line += fromX; + + // Beginning of the scan line, with per-pixel checks. + i = x1 - fromX; + while (i) { + qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1); + qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1); + blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + vv * sbpl)[uu]); + u += dudx; + v += dvdx; + ++line; + --i; + } + + // Middle of the scan line, without checks. + // Manual loop unrolling. + i = x2 - x1; + ii = i >> 3; + while (ii) { + blender.write(&line[0], reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; + blender.write(&line[1], reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; + blender.write(&line[2], reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; + blender.write(&line[3], reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; + blender.write(&line[4], reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; + blender.write(&line[5], reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; + blender.write(&line[6], reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; + blender.write(&line[7], reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; + + line += 8; + + --ii; + } + switch (i & 7) { + case 7: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 6: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 5: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 4: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 3: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 2: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; Q_FALLTHROUGH(); + case 1: blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line; + } + + // End of the scan line, with per-pixel checks. + i = toX - x2; + while (i) { + qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1); + qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1); + blender.write(line, reinterpret_cast(reinterpret_cast(srcPixels) + vv * sbpl)[uu]); + u += dudx; + v += dvdx; + ++line; + --i; + } + + blender.flush(line); + } + x_l += dx_l; + x_r += dx_r; + } +} + +template +void qt_transform_image(DestT *destPixels, int dbpl, + const SrcT *srcPixels, int sbpl, + const QRectF &targetRect, + const QRectF &sourceRect, + const QRect &clip, + const QTransform &targetRectTransform, + Blender blender) +{ + enum Corner + { + TopLeft, + TopRight, + BottomRight, + BottomLeft + }; + + // map source rectangle to destination. + QTransformImageVertex v[4]; + v[TopLeft].u = v[BottomLeft].u = sourceRect.left(); + v[TopLeft].v = v[TopRight].v = sourceRect.top(); + v[TopRight].u = v[BottomRight].u = sourceRect.right(); + v[BottomLeft].v = v[BottomRight].v = sourceRect.bottom(); + targetRectTransform.map(targetRect.left(), targetRect.top(), &v[TopLeft].x, &v[TopLeft].y); + targetRectTransform.map(targetRect.right(), targetRect.top(), &v[TopRight].x, &v[TopRight].y); + targetRectTransform.map(targetRect.left(), targetRect.bottom(), &v[BottomLeft].x, &v[BottomLeft].y); + targetRectTransform.map(targetRect.right(), targetRect.bottom(), &v[BottomRight].x, &v[BottomRight].y); + + // find topmost vertex. + int topmost = 0; + for (int i = 1; i < 4; ++i) { + if (v[i].y < v[topmost].y) + topmost = i; + } + // rearrange array such that topmost vertex is at index 0. + switch (topmost) { + case 1: + { + QTransformImageVertex t = v[0]; + for (int i = 0; i < 3; ++i) + v[i] = v[i+1]; + v[3] = t; + } + break; + case 2: + qSwap(v[0], v[2]); + qSwap(v[1], v[3]); + break; + case 3: + { + QTransformImageVertex t = v[3]; + for (int i = 3; i > 0; --i) + v[i] = v[i-1]; + v[0] = t; + } + break; + } + + // if necessary, swap vertex 1 and 3 such that 1 is to the left of 3. + qreal dx1 = v[1].x - v[0].x; + qreal dy1 = v[1].y - v[0].y; + qreal dx2 = v[3].x - v[0].x; + qreal dy2 = v[3].y - v[0].y; + if (dx1 * dy2 - dx2 * dy1 > 0) + qSwap(v[1], v[3]); + + QTransformImageVertex u = {v[1].x - v[0].x, v[1].y - v[0].y, v[1].u - v[0].u, v[1].v - v[0].v}; + QTransformImageVertex w = {v[2].x - v[0].x, v[2].y - v[0].y, v[2].u - v[0].u, v[2].v - v[0].v}; + + qreal det = u.x * w.y - u.y * w.x; + if (det == 0) + return; + + qreal invDet = 1.0 / det; + qreal m11, m12, m21, m22, mdx, mdy; + + m11 = (u.u * w.y - u.y * w.u) * invDet; + m12 = (u.x * w.u - u.u * w.x) * invDet; + m21 = (u.v * w.y - u.y * w.v) * invDet; + m22 = (u.x * w.v - u.v * w.x) * invDet; + mdx = v[0].u - m11 * v[0].x - m12 * v[0].y; + mdy = v[0].v - m21 * v[0].x - m22 * v[0].y; + + int dudx = int(m11 * 0x10000); + int dvdx = int(m21 * 0x10000); + int dudy = int(m12 * 0x10000); + int dvdy = int(m22 * 0x10000); + int u0 = qCeil((qreal(0.5) * m11 + qreal(0.5) * m12 + mdx) * 0x10000) - 1; + int v0 = qCeil((qreal(0.5) * m21 + qreal(0.5) * m22 + mdy) * 0x10000) - 1; + + int x1 = qFloor(sourceRect.left()); + int y1 = qFloor(sourceRect.top()); + int x2 = qCeil(sourceRect.right()); + int y2 = qCeil(sourceRect.bottom()); + QRect sourceRectI(x1, y1, x2 - x1, y2 - y1); + + // rasterize trapezoids. + if (v[1].y < v[3].y) { + qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[0], v[1], v[0], v[3], sourceRectI, clip, v[0].y, v[1].y, dudx, dvdx, dudy, dvdy, u0, v0, blender); + qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[1], v[2], v[0], v[3], sourceRectI, clip, v[1].y, v[3].y, dudx, dvdx, dudy, dvdy, u0, v0, blender); + qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[1], v[2], v[3], v[2], sourceRectI, clip, v[3].y, v[2].y, dudx, dvdx, dudy, dvdy, u0, v0, blender); + } else { + qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[0], v[1], v[0], v[3], sourceRectI, clip, v[0].y, v[3].y, dudx, dvdx, dudy, dvdy, u0, v0, blender); + qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[0], v[1], v[3], v[2], sourceRectI, clip, v[3].y, v[1].y, dudx, dvdx, dudy, dvdy, u0, v0, blender); + qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[1], v[2], v[3], v[2], sourceRectI, clip, v[1].y, v[2].y, dudx, dvdx, dudy, dvdy, u0, v0, blender); + } +} + +QT_END_NAMESPACE + +#endif // QBLENDFUNCTIONS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qblittable_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qblittable_p.h new file mode 100644 index 0000000000000000000000000000000000000000..41a6fa01b47ebdb83b1e9e07c1e9e88ecb89772b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qblittable_p.h @@ -0,0 +1,97 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QBLITTABLE_P_H +#define QBLITTABLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + + +#ifndef QT_NO_BLITTABLE +QT_BEGIN_NAMESPACE + +class QImage; +class QBlittablePrivate; + +class Q_GUI_EXPORT QBlittable +{ + Q_DECLARE_PRIVATE(QBlittable) +public: + enum Capability { + + SolidRectCapability = 0x0001, + SourcePixmapCapability = 0x0002, + SourceOverPixmapCapability = 0x0004, + SourceOverScaledPixmapCapability = 0x0008, + AlphaFillRectCapability = 0x0010, + OpacityPixmapCapability = 0x0020, + DrawScaledCachedGlyphsCapability = 0x0040, + SubPixelGlyphsCapability = 0x0080, + ComplexClipCapability = 0x0100, + + // Internal ones + OutlineCapability = 0x0001000 + }; + Q_DECLARE_FLAGS (Capabilities, Capability) + + QBlittable(const QSize &size, Capabilities caps); + virtual ~QBlittable(); + + Capabilities capabilities() const; + QSize size() const; + + virtual void fillRect(const QRectF &rect, const QColor &color) = 0; + virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect) = 0; + virtual void alphaFillRect(const QRectF &rect, const QColor &color, QPainter::CompositionMode cmode) { + Q_UNUSED(rect); + Q_UNUSED(color); + Q_UNUSED(cmode); + qWarning("Please implement alphaFillRect function in your platform or remove AlphaFillRectCapability from it"); + } + virtual void drawPixmapOpacity(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect, QPainter::CompositionMode cmode, qreal opacity) { + Q_UNUSED(rect); + Q_UNUSED(pixmap); + Q_UNUSED(subrect); + Q_UNUSED(cmode); + Q_UNUSED(opacity); + qWarning("Please implement drawPixmapOpacity function in your platform or remove OpacityPixmapCapability from it"); + } + virtual bool drawCachedGlyphs(const QPaintEngineState *state, QFontEngine::GlyphFormat glyphFormat, int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, QFontEngine *fontEngine) { + Q_UNUSED(state); + Q_UNUSED(glyphFormat); + Q_UNUSED(numGlyphs); + Q_UNUSED(glyphs); + Q_UNUSED(positions); + Q_UNUSED(fontEngine); + qWarning("Please implement drawCachedGlyphs function in your platform or remove DrawCachedGlyphsCapability from it"); + return true; + } + + + QImage *lock(); + void unlock(); + + bool isLocked() const; + +protected: + virtual QImage *doLock() = 0; + virtual void doUnlock() = 0; + QBlittablePrivate *d_ptr; +}; + +QT_END_NAMESPACE +#endif //QT_NO_BLITTABLE +#endif //QBLITTABLE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbmphandler_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbmphandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c312a4b7f07249a2502444c9b22fd518f927738d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qbmphandler_p.h @@ -0,0 +1,108 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QBMPHANDLER_P_H +#define QBMPHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtGui/qimageiohandler.h" + +#ifndef QT_NO_IMAGEFORMAT_BMP + +QT_BEGIN_NAMESPACE + +struct BMP_FILEHDR { // BMP file header + char bfType[2]; // "BM" + qint32 bfSize; // size of file + qint16 bfReserved1; + qint16 bfReserved2; + qint32 bfOffBits; // pointer to the pixmap bits +}; + +struct BMP_INFOHDR { // BMP information header + qint32 biSize; // size of this struct + qint32 biWidth; // pixmap width + qint32 biHeight; // pixmap height + qint16 biPlanes; // should be 1 + qint16 biBitCount; // number of bits per pixel + qint32 biCompression; // compression method + qint32 biSizeImage; // size of image + qint32 biXPelsPerMeter; // horizontal resolution + qint32 biYPelsPerMeter; // vertical resolution + qint32 biClrUsed; // number of colors used + qint32 biClrImportant; // number of important colors + // V4: + quint32 biRedMask; + quint32 biGreenMask; + quint32 biBlueMask; + quint32 biAlphaMask; + qint32 biCSType; + qint32 biEndpoints[9]; + qint32 biGammaRed; + qint32 biGammaGreen; + qint32 biGammaBlue; + // V5: + qint32 biIntent; + qint32 biProfileData; + qint32 biProfileSize; + qint32 biReserved; +}; + +// BMP-Handler, which is also able to read and write the DIB +// (Device-Independent-Bitmap) format used internally in the Windows operating +// system for OLE/clipboard operations. DIB is a subset of BMP (without file +// header). The Windows platform plugin accesses the DIB-functionality. + +class QBmpHandler : public QImageIOHandler +{ +public: + enum InternalFormat { + DibFormat, + BmpFormat + }; + + explicit QBmpHandler(InternalFormat fmt = BmpFormat); + bool canRead() const override; + bool read(QImage *image) override; + bool write(const QImage &image) override; + + static bool canRead(QIODevice *device); + + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant &value) override; + bool supportsOption(ImageOption option) const override; + +private: + bool readHeader(); + inline QByteArray formatName() const; + + enum State { + Ready, + ReadHeader, + Error + }; + + const InternalFormat m_format; + + State state; + BMP_FILEHDR fileHeader; + BMP_INFOHDR infoHeader; + qint64 startpos; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_IMAGEFORMAT_BMP + +#endif // QBMPHANDLER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcmyk_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcmyk_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9236bbb93b656c6c8e5a9e8941683f4a36a9f821 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcmyk_p.h @@ -0,0 +1,94 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCMYK_P_H +#define QCMYK_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QCmyk32 +{ +private: + uint m_cmyk = 0; + friend constexpr bool comparesEqual(const QCmyk32 &lhs, const QCmyk32 &rhs) noexcept + { + return lhs.m_cmyk == rhs.m_cmyk; + } + +public: + QCmyk32() = default; + + constexpr QCmyk32(int cyan, int magenta, int yellow, int black) : +#if QT_BYTE_ORDER == Q_BIG_ENDIAN + m_cmyk(cyan << 24 | magenta << 16 | yellow << 8 | black) +#else + m_cmyk(cyan | magenta << 8 | yellow << 16 | black << 24) +#endif + { + } + +#if QT_BYTE_ORDER == Q_BIG_ENDIAN + constexpr int cyan() const noexcept { return (m_cmyk >> 24) & 0xff; } + constexpr int magenta() const noexcept { return (m_cmyk >> 16) & 0xff; } + constexpr int yellow() const noexcept { return (m_cmyk >> 8) & 0xff; } + constexpr int black() const noexcept { return (m_cmyk ) & 0xff; } +#else + constexpr int cyan() const noexcept { return (m_cmyk ) & 0xff; } + constexpr int magenta() const noexcept { return (m_cmyk >> 8) & 0xff; } + constexpr int yellow() const noexcept { return (m_cmyk >> 16) & 0xff; } + constexpr int black() const noexcept { return (m_cmyk >> 24) & 0xff; } +#endif + + QColor toColor() const noexcept + { + return QColor::fromCmyk(cyan(), magenta(), yellow(), black()); + } + + constexpr uint toUint() const noexcept + { + return m_cmyk; + } + + constexpr static QCmyk32 fromCmyk32(uint cmyk) noexcept + { + QCmyk32 result; + result.m_cmyk = cmyk; + return result; + } + + static QCmyk32 fromRgba(QRgb rgba) noexcept + { + const QColor c = QColor(rgba).toCmyk(); + return QCmyk32(c.cyan(), c.magenta(), c.yellow(), c.black()); + } + + static QCmyk32 fromColor(const QColor &color) noexcept + { + QColor c = color.toCmyk(); + return QCmyk32(c.cyan(), c.magenta(), c.yellow(), c.black()); + } + + Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE(QCmyk32) +}; + +static_assert(sizeof(QCmyk32) == sizeof(int)); +static_assert(alignof(QCmyk32) == alignof(int)); +static_assert(std::is_standard_layout_v); + +QT_END_NAMESPACE + +#endif // QCMYK_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolor_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..10adb395c378361764336d924b25e448044b3149 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolor_p.h @@ -0,0 +1,29 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLOR_P_H +#define QCOLOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtGui/qrgb.h" + +#include + +QT_BEGIN_NAMESPACE + +std::optional qt_get_hex_rgb(const char *) Q_DECL_PURE_FUNCTION; + +QT_END_NAMESPACE + +#endif // QCOLOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolorclut_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolorclut_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cf784543ff2fb8b66d0e07ba7d4be56b5df91fe9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolorclut_p.h @@ -0,0 +1,127 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLORCLUT_H +#define QCOLORCLUT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +// A 3/4-dimensional lookup table compatible with ICC lut8, lut16, mAB, and mBA formats. +class QColorCLUT +{ + inline static QColorVector interpolate(const QColorVector &a, const QColorVector &b, float t) + { + return a + (b - a) * t; // faster than std::lerp by assuming no super large or non-number floats + } + inline static void interpolateIn(QColorVector &a, const QColorVector &b, float t) + { + a += (b - a) * t; + } +public: + uint32_t gridPointsX = 0; + uint32_t gridPointsY = 0; + uint32_t gridPointsZ = 0; + uint32_t gridPointsW = 1; + QList table; + + bool isEmpty() const { return table.isEmpty(); } + + QColorVector apply(const QColorVector &v) const + { + Q_ASSERT(table.size() == qsizetype(gridPointsX * gridPointsY * gridPointsZ * gridPointsW)); + QColorVector frac; + const float x = std::clamp(v.x, 0.0f, 1.0f) * (gridPointsX - 1); + const float y = std::clamp(v.y, 0.0f, 1.0f) * (gridPointsY - 1); + const float z = std::clamp(v.z, 0.0f, 1.0f) * (gridPointsZ - 1); + const float w = std::clamp(v.w, 0.0f, 1.0f) * (gridPointsW - 1); + const uint32_t lox = static_cast(std::floor(x)); + const uint32_t hix = std::min(lox + 1, gridPointsX - 1); + const uint32_t loy = static_cast(std::floor(y)); + const uint32_t hiy = std::min(loy + 1, gridPointsY - 1); + const uint32_t loz = static_cast(std::floor(z)); + const uint32_t hiz = std::min(loz + 1, gridPointsZ - 1); + const uint32_t low = static_cast(std::floor(w)); + const uint32_t hiw = std::min(low + 1, gridPointsW - 1); + frac.x = x - static_cast(lox); + frac.y = y - static_cast(loy); + frac.z = z - static_cast(loz); + frac.w = w - static_cast(low); + if (gridPointsW > 1) { + auto index = [&](qsizetype x, qsizetype y, qsizetype z, qsizetype w) -> qsizetype { + return x * gridPointsW * gridPointsZ * gridPointsY + + y * gridPointsW * gridPointsZ + + z * gridPointsW + + w; + }; + QColorVector tmp[8]; + // interpolate over w + tmp[0] = interpolate(table[index(lox, loy, loz, low)], + table[index(lox, loy, loz, hiw)], frac.w); + tmp[1] = interpolate(table[index(lox, loy, hiz, low)], + table[index(lox, loy, hiz, hiw)], frac.w); + tmp[2] = interpolate(table[index(lox, hiy, loz, low)], + table[index(lox, hiy, loz, hiw)], frac.w); + tmp[3] = interpolate(table[index(lox, hiy, hiz, low)], + table[index(lox, hiy, hiz, hiw)], frac.w); + tmp[4] = interpolate(table[index(hix, loy, loz, low)], + table[index(hix, loy, loz, hiw)], frac.w); + tmp[5] = interpolate(table[index(hix, loy, hiz, low)], + table[index(hix, loy, hiz, hiw)], frac.w); + tmp[6] = interpolate(table[index(hix, hiy, loz, low)], + table[index(hix, hiy, loz, hiw)], frac.w); + tmp[7] = interpolate(table[index(hix, hiy, hiz, low)], + table[index(hix, hiy, hiz, hiw)], frac.w); + // interpolate over z + for (int i = 0; i < 4; ++i) + interpolateIn(tmp[i * 2], tmp[i * 2 + 1], frac.z); + // interpolate over y + for (int i = 0; i < 2; ++i) + interpolateIn(tmp[i * 4], tmp[i * 4 + 2], frac.y); + // interpolate over x + interpolateIn(tmp[0], tmp[4], frac.x); + return tmp[0]; + } + auto index = [&](qsizetype x, qsizetype y, qsizetype z) -> qsizetype { + return x * gridPointsZ * gridPointsY + + y * gridPointsZ + + z; + }; + QColorVector tmp[8] = { + table[index(lox, loy, loz)], + table[index(lox, loy, hiz)], + table[index(lox, hiy, loz)], + table[index(lox, hiy, hiz)], + table[index(hix, loy, loz)], + table[index(hix, loy, hiz)], + table[index(hix, hiy, loz)], + table[index(hix, hiy, hiz)] + }; + // interpolate over z + for (int i = 0; i < 4; ++i) + interpolateIn(tmp[i * 2], tmp[i * 2 + 1], frac.z); + // interpolate over y + for (int i = 0; i < 2; ++i) + interpolateIn(tmp[i * 4], tmp[i * 4 + 2], frac.y); + // interpolate over x + interpolateIn(tmp[0], tmp[4], frac.x); + return tmp[0]; + } +}; + +QT_END_NAMESPACE + +#endif // QCOLORCLUT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolormatrix_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolormatrix_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6fe57cb67876a241e46f3e4aa8ec29828e3b1ac8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolormatrix_p.h @@ -0,0 +1,356 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLORMATRIX_H +#define QCOLORMATRIX_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +// An abstract 3 value color +class QColorVector +{ +public: + QColorVector() = default; + constexpr QColorVector(float x, float y, float z, float w = 0.0f) noexcept : x(x), y(y), z(z), w(w) { } + static constexpr QColorVector fromXYChromaticity(QPointF chr) + { return {float(chr.x() / chr.y()), 1.0f, float((1.0f - chr.x() - chr.y()) / chr.y())}; } + float x = 0.0f; // X, x, L, or red/cyan + float y = 0.0f; // Y, y, a, or green/magenta + float z = 0.0f; // Z, Y, b, or blue/yellow + float w = 0.0f; // unused, or black + + constexpr bool isNull() const noexcept + { + return !x && !y && !z && !w; + } + bool isValid() const noexcept + { + return std::isfinite(x) && std::isfinite(y) && std::isfinite(z); + } + + static constexpr bool isValidChromaticity(const QPointF &chr) + { + if (chr.x() < qreal(0.0) || chr.x() > qreal(1.0)) + return false; + if (chr.y() <= qreal(0.0) || chr.y() > qreal(1.0)) + return false; + if (chr.x() + chr.y() > qreal(1.0)) + return false; + return true; + } + + constexpr QColorVector operator*(float f) const { return QColorVector(x * f, y * f, z * f, w * f); } + constexpr QColorVector operator+(const QColorVector &v) const { return QColorVector(x + v.x, y + v.y, z + v.z, w + v.w); } + constexpr QColorVector operator-(const QColorVector &v) const { return QColorVector(x - v.x, y - v.y, z - v.z, w - v.w); } + void operator+=(const QColorVector &v) { x += v.x; y += v.y; z += v.z; w += v.w; } + + QPointF toChromaticity() const + { + if (isNull()) + return QPointF(); + float mag = 1.0f / (x + y + z); + return QPointF(x * mag, y * mag); + } + + // Common whitepoints: + static constexpr QPointF D50Chromaticity() { return QPointF(0.34567, 0.35850); } + static constexpr QPointF D65Chromaticity() { return QPointF(0.31271, 0.32902); } + static constexpr QColorVector D50() { return fromXYChromaticity(D50Chromaticity()); } + static constexpr QColorVector D65() { return fromXYChromaticity(D65Chromaticity()); } + + QColorVector xyzToLab() const + { + constexpr QColorVector ref = D50(); + constexpr float eps = 0.008856f; + constexpr float kap = 903.3f; +#if defined(__SSE2__) + const __m128 iref = _mm_setr_ps(1.f / ref.x, 1.f / ref.y, 1.f / ref.z, 0.f); + __m128 v = _mm_loadu_ps(&x); + v = _mm_mul_ps(v, iref); + + const __m128 f3 = _mm_set1_ps(3.f); + __m128 est = _mm_add_ps(_mm_set1_ps(0.25f), _mm_mul_ps(v, _mm_set1_ps(0.75f))); // float est = 0.25f + (x * 0.75f); + __m128 estsq = _mm_mul_ps(est, est); + est = _mm_sub_ps(est, _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(estsq, est), v), + _mm_rcp_ps(_mm_mul_ps(estsq, f3)))); // est -= ((est * est * est) - x) / (3.f * (est * est)); + estsq = _mm_mul_ps(est, est); + est = _mm_sub_ps(est, _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(estsq, est), v), + _mm_rcp_ps(_mm_mul_ps(estsq, f3)))); // est -= ((est * est * est) - x) / (3.f * (est * est)); + estsq = _mm_mul_ps(est, est); + est = _mm_sub_ps(est, _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(estsq, est), v), + _mm_rcp_ps(_mm_mul_ps(estsq, f3)))); // est -= ((est * est * est) - x) / (3.f * (est * est)); + estsq = _mm_mul_ps(est, est); + est = _mm_sub_ps(est, _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(estsq, est), v), + _mm_rcp_ps(_mm_mul_ps(estsq, f3)))); // est -= ((est * est * est) - x) / (3.f * (est * est)); + + __m128 kapmul = _mm_mul_ps(_mm_add_ps(_mm_mul_ps(v, _mm_set1_ps(kap)), _mm_set1_ps(16.f)), + _mm_set1_ps(1.f / 116.f)); // f_ = (kap * f_ + 16.f) * (1.f / 116.f); + __m128 cmpgt = _mm_cmpgt_ps(v, _mm_set1_ps(eps)); // if (f_ > eps) +#if defined(__SSE4_1__) + v = _mm_blendv_ps(kapmul, est, cmpgt); // if (..) f_ =.. else f_ =.. +#else + v = _mm_or_ps(_mm_and_ps(cmpgt, est), _mm_andnot_ps(cmpgt, kapmul)); +#endif + alignas(16) float out[4]; + _mm_store_ps(out, v); + const float L = 116.f * out[1] - 16.f; + const float a = 500.f * (out[0] - out[1]); + const float b = 200.f * (out[1] - out[2]); +#else + float xr = x * (1.f / ref.x); + float yr = y * (1.f / ref.y); + float zr = z * (1.f / ref.z); + + float fx, fy, fz; + if (xr > eps) + fx = fastCbrt(xr); + else + fx = (kap * xr + 16.f) * (1.f / 116.f); + if (yr > eps) + fy = fastCbrt(yr); + else + fy = (kap * yr + 16.f) * (1.f / 116.f); + if (zr > eps) + fz = fastCbrt(zr); + else + fz = (kap * zr + 16.f) * (1.f / 116.f); + + const float L = 116.f * fy - 16.f; + const float a = 500.f * (fx - fy); + const float b = 200.f * (fy - fz); +#endif + // We output Lab values that has been scaled to 0.0->1.0 values, see also labToXyz. + return QColorVector(L * (1.f / 100.f), (a + 128.f) * (1.f / 255.f), (b + 128.f) * (1.f / 255.f)); + } + + QColorVector labToXyz() const + { + constexpr QColorVector ref = D50(); + constexpr float eps = 0.008856f; + constexpr float kap = 903.3f; + // This transform has been guessed from the ICC spec, but it is not stated + // anywhere to be the one to use to map to and from 0.0->1.0 values: + const float L = x * 100.f; + const float a = (y * 255.f) - 128.f; + const float b = (z * 255.f) - 128.f; + // From here is official Lab->XYZ conversion: + float fy = (L + 16.f) * (1.f / 116.f); + float fx = fy + (a * (1.f / 500.f)); + float fz = fy - (b * (1.f / 200.f)); + + float xr, yr, zr; + if (fx * fx * fx > eps) + xr = fx * fx * fx; + else + xr = (116.f * fx - 16) * (1.f / kap); + if (L > (kap * eps)) + yr = fy * fy * fy; + else + yr = L * (1.f / kap); + if (fz * fz * fz > eps) + zr = fz * fz * fz; + else + zr = (116.f * fz - 16) * (1.f / kap); + + xr = xr * ref.x; + yr = yr * ref.y; + zr = zr * ref.z; + return QColorVector(xr, yr, zr); + } + friend inline bool comparesEqual(const QColorVector &lhs, const QColorVector &rhs) noexcept; + Q_DECLARE_EQUALITY_COMPARABLE(QColorVector); + +private: + static float fastCbrt(float x) + { + // This gives us cube root within the precision we need. + float est = 0.25f + (x * 0.75f); // guessing a cube-root of numbers between 0.01 and 1. + est -= ((est * est * est) - x) / (3.f * (est * est)); + est -= ((est * est * est) - x) / (3.f * (est * est)); + est -= ((est * est * est) - x) / (3.f * (est * est)); + est -= ((est * est * est) - x) / (3.f * (est * est)); + // Q_ASSERT(qAbs(est - std::cbrt(x)) < 0.0001f); + return est; + } +}; + +inline bool comparesEqual(const QColorVector &v1, const QColorVector &v2) noexcept +{ + return (std::abs(v1.x - v2.x) < (1.0f / 2048.0f)) + && (std::abs(v1.y - v2.y) < (1.0f / 2048.0f)) + && (std::abs(v1.z - v2.z) < (1.0f / 2048.0f)) + && (std::abs(v1.w - v2.w) < (1.0f / 2048.0f)); +} + +// A matrix mapping 3 value colors. +// Not using QTransform because only floats are needed and performance is critical. +class QColorMatrix +{ +public: + // We are storing the matrix transposed as that is more convenient: + QColorVector r; + QColorVector g; + QColorVector b; + + constexpr bool isNull() const + { + return r.isNull() && g.isNull() && b.isNull(); + } + constexpr float determinant() const + { + return r.x * (b.z * g.y - g.z * b.y) - + r.y * (b.z * g.x - g.z * b.x) + + r.z * (b.y * g.x - g.y * b.x); + } + bool isValid() const + { + // A color matrix must be invertible + return std::isnormal(determinant()); + } + bool isIdentity() const noexcept + { + return *this == identity(); + } + + QColorMatrix inverted() const + { + float det = determinant(); + det = 1.0f / det; + QColorMatrix inv; + inv.r.x = (g.y * b.z - b.y * g.z) * det; + inv.r.y = (b.y * r.z - r.y * b.z) * det; + inv.r.z = (r.y * g.z - g.y * r.z) * det; + inv.g.x = (b.x * g.z - g.x * b.z) * det; + inv.g.y = (r.x * b.z - b.x * r.z) * det; + inv.g.z = (g.x * r.z - r.x * g.z) * det; + inv.b.x = (g.x * b.y - b.x * g.y) * det; + inv.b.y = (b.x * r.y - r.x * b.y) * det; + inv.b.z = (r.x * g.y - g.x * r.y) * det; + return inv; + } + friend inline constexpr QColorMatrix operator*(const QColorMatrix &a, const QColorMatrix &o) + { + QColorMatrix comb; + comb.r.x = a.r.x * o.r.x + a.g.x * o.r.y + a.b.x * o.r.z; + comb.g.x = a.r.x * o.g.x + a.g.x * o.g.y + a.b.x * o.g.z; + comb.b.x = a.r.x * o.b.x + a.g.x * o.b.y + a.b.x * o.b.z; + + comb.r.y = a.r.y * o.r.x + a.g.y * o.r.y + a.b.y * o.r.z; + comb.g.y = a.r.y * o.g.x + a.g.y * o.g.y + a.b.y * o.g.z; + comb.b.y = a.r.y * o.b.x + a.g.y * o.b.y + a.b.y * o.b.z; + + comb.r.z = a.r.z * o.r.x + a.g.z * o.r.y + a.b.z * o.r.z; + comb.g.z = a.r.z * o.g.x + a.g.z * o.g.y + a.b.z * o.g.z; + comb.b.z = a.r.z * o.b.x + a.g.z * o.b.y + a.b.z * o.b.z; + return comb; + + } + QColorVector map(const QColorVector &c) const + { + return QColorVector { c.x * r.x + c.y * g.x + c.z * b.x, + c.x * r.y + c.y * g.y + c.z * b.y, + c.x * r.z + c.y * g.z + c.z * b.z }; + } + QColorMatrix transposed() const + { + return QColorMatrix { { r.x, g.x, b.x }, + { r.y, g.y, b.y }, + { r.z, g.z, b.z } }; + } + + static QColorMatrix identity() + { + return { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f } }; + } + static QColorMatrix fromScale(QColorVector v) + { + return QColorMatrix { { v.x, 0.0f, 0.0f }, + { 0.0f, v.y, 0.0f }, + { 0.0f, 0.0f, v.z } }; + } + static QColorMatrix chromaticAdaptation(const QColorVector &whitePoint) + { + constexpr QColorVector whitePointD50 = QColorVector::D50(); + if (whitePoint != whitePointD50) { + // A chromatic adaptation to map a white point to XYZ D50. + + // The Bradford method chromatic adaptation matrix: + const QColorMatrix abrad = { { 0.8951f, -0.7502f, 0.0389f }, + { 0.2664f, 1.7135f, -0.0685f }, + { -0.1614f, 0.0367f, 1.0296f } }; + const QColorMatrix abradinv = { { 0.9869929f, 0.4323053f, -0.0085287f }, + { -0.1470543f, 0.5183603f, 0.0400428f }, + { 0.1599627f, 0.0492912f, 0.9684867f } }; + + const QColorVector srcCone = abrad.map(whitePoint); + if (srcCone.x && srcCone.y && srcCone.z) { + const QColorVector dstCone = abrad.map(whitePointD50); + const QColorMatrix wToD50 = { { dstCone.x / srcCone.x, 0, 0 }, + { 0, dstCone.y / srcCone.y, 0 }, + { 0, 0, dstCone.z / srcCone.z } }; + return abradinv * (wToD50 * abrad); + } + } + return QColorMatrix::identity(); + } + + // These are used to recognize matrices from ICC profiles: + static QColorMatrix toXyzFromSRgb() + { + return QColorMatrix { { 0.4360217452f, 0.2224751115f, 0.0139281144f }, + { 0.3851087987f, 0.7169067264f, 0.0971015394f }, + { 0.1430812478f, 0.0606181994f, 0.7141585946f } }; + } + static QColorMatrix toXyzFromAdobeRgb() + { + return QColorMatrix { { 0.6097189188f, 0.3111021519f, 0.0194766335f }, + { 0.2052682191f, 0.6256770492f, 0.0608891509f }, + { 0.1492247432f, 0.0632209629f, 0.7448224425f } }; + } + static QColorMatrix toXyzFromDciP3D65() + { + return QColorMatrix { { 0.5150973201f, 0.2411795557f, -0.0010491034f }, + { 0.2919696569f, 0.6922441125f, 0.0418830328f }, + { 0.1571449190f, 0.0665764511f, 0.7843542695f } }; + } + static QColorMatrix toXyzFromProPhotoRgb() + { + return QColorMatrix { { 0.7976672649f, 0.2880374491f, 0.0000000000f }, + { 0.1351922452f, 0.7118769884f, 0.0000000000f }, + { 0.0313525312f, 0.0000856627f, 0.8251883388f } }; + } + static QColorMatrix toXyzFromBt2020() + { + return QColorMatrix { { 0.673447f, 0.279037f, -0.00192261f }, + { 0.165665f, 0.675339f, 0.0299835f }, + { 0.125092f, 0.0456238f, 0.797134f } }; + } + friend inline bool comparesEqual(const QColorMatrix &lhs, const QColorMatrix &rhs) noexcept; + Q_DECLARE_EQUALITY_COMPARABLE(QColorMatrix); +}; + +inline bool comparesEqual(const QColorMatrix &m1, const QColorMatrix &m2) noexcept +{ + return (m1.r == m2.r) && (m1.g == m2.g) && (m1.b == m2.b); +} + +QT_END_NAMESPACE + +#endif // QCOLORMATRIX_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolorspace_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolorspace_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c8d2f0b5b60c783a4d7888d73f098df6b088ce99 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolorspace_p.h @@ -0,0 +1,152 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLORSPACE_P_H +#define QCOLORSPACE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qcolorspace.h" +#include "qcolorclut_p.h" +#include "qcolormatrix_p.h" +#include "qcolortrc_p.h" +#include "qcolortrclut_p.h" + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class Q_AUTOTEST_EXPORT QColorSpacePrimaries +{ +public: + QColorSpacePrimaries() = default; + QColorSpacePrimaries(QColorSpace::Primaries primaries); + QColorSpacePrimaries(QPointF whitePoint, + QPointF redPoint, + QPointF greenPoint, + QPointF bluePoint) + : whitePoint(whitePoint) + , redPoint(redPoint) + , greenPoint(greenPoint) + , bluePoint(bluePoint) + { } + + QColorMatrix toXyzMatrix() const; + bool areValid() const; + + QPointF whitePoint; + QPointF redPoint; + QPointF greenPoint; + QPointF bluePoint; +}; + +class QColorSpacePrivate : public QSharedData +{ +public: + QColorSpacePrivate(); + QColorSpacePrivate(QColorSpace::NamedColorSpace namedColorSpace); + QColorSpacePrivate(QColorSpace::Primaries primaries, QColorSpace::TransferFunction transferFunction, float gamma); + QColorSpacePrivate(QColorSpace::Primaries primaries, const QList &transferFunctionTable); + QColorSpacePrivate(const QColorSpacePrimaries &primaries, QColorSpace::TransferFunction transferFunction, float gamma); + QColorSpacePrivate(const QColorSpacePrimaries &primaries, const QList &transferFunctionTable); + QColorSpacePrivate(const QColorSpacePrimaries &primaries, + const QList &redTransferFunctionTable, + const QList &greenTransferFunctionTable, + const QList &blueRransferFunctionTable); + QColorSpacePrivate(QPointF whitePoint, QColorSpace::TransferFunction transferFunction, float gamma); + QColorSpacePrivate(QPointF whitePoint, const QList &transferFunctionTable); + QColorSpacePrivate(const QColorSpacePrivate &other) = default; + + static const QColorSpacePrivate *get(const QColorSpace &colorSpace) + { + return colorSpace.d_ptr.get(); + } + + static QColorSpacePrivate *get(QColorSpace &colorSpace) + { + return colorSpace.d_ptr.get(); + } + + bool equals(const QColorSpacePrivate *other) const; + bool isValid() const noexcept; + + void initialize(); + void setToXyzMatrix(); + void setTransferFunction(); + void identifyColorSpace(); + void setTransferFunctionTable(const QList &transferFunctionTable); + void setTransferFunctionTables(const QList &redTransferFunctionTable, + const QList &greenTransferFunctionTable, + const QList &blueTransferFunctionTable); + QColorTransform transformationToColorSpace(const QColorSpacePrivate *out) const; + QColorTransform transformationToXYZ() const; + + bool isThreeComponentMatrix() const; + void clearElementListProcessingForEdit(); + + static constexpr QColorSpace::NamedColorSpace Unknown = QColorSpace::NamedColorSpace(0); + QColorSpace::NamedColorSpace namedColorSpace = Unknown; + + QColorSpace::Primaries primaries = QColorSpace::Primaries::Custom; + QColorSpace::TransferFunction transferFunction = QColorSpace::TransferFunction::Custom; + QColorSpace::TransformModel transformModel = QColorSpace::TransformModel::ThreeComponentMatrix; + QColorSpace::ColorModel colorModel = QColorSpace::ColorModel::Undefined; + float gamma = 0.0f; + QColorVector whitePoint; + + // Three component matrix data: + QColorTrc trc[3]; + QColorMatrix toXyz; + QColorMatrix chad; + + // Element list processing data: + struct TransferElement { + QColorTrc trc[4]; + }; + using Element = std::variant; + bool isPcsLab = false; + // A = device, B = PCS + QList mAB, mBA; + + // Metadata + QString description; + QString userDescription; + QByteArray iccProfile; + + // Cached tables for three component matrix transform: + Q_CONSTINIT static QBasicMutex s_lutWriteLock; + struct LUT { + LUT() = default; + ~LUT() = default; + LUT(const LUT &other) + { + if (other.generated.loadAcquire()) { + table[0] = other.table[0]; + table[1] = other.table[1]; + table[2] = other.table[2]; + generated.storeRelaxed(1); + } + } + std::shared_ptr &operator[](int i) { return table[i]; } + const std::shared_ptr &operator[](int i) const { return table[i]; } + std::shared_ptr table[3]; + QAtomicInt generated; + } mutable lut; +}; + +QT_END_NAMESPACE + +#endif // QCOLORSPACE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransferfunction_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransferfunction_p.h new file mode 100644 index 0000000000000000000000000000000000000000..be6e6ff1306c16b42c49e503992f8dae78c8bc60 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransferfunction_p.h @@ -0,0 +1,198 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLORTRANSFERFUNCTION_P_H +#define QCOLORTRANSFERFUNCTION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +// Defines a ICC parametric curve type 4 +class QColorTransferFunction +{ +public: + QColorTransferFunction() noexcept + : m_a(1.0f), m_b(0.0f), m_c(1.0f), m_d(0.0f), m_e(0.0f), m_f(0.0f), m_g(1.0f) + , m_flags(Hints(Hint::Calculated) | Hint::IsGamma | Hint::IsIdentity) + { } + + QColorTransferFunction(float a, float b, float c, float d, float e, float f, float g) noexcept + : m_a(a), m_b(b), m_c(c), m_d(d), m_e(e), m_f(f), m_g(g), m_flags() + { } + + bool isGamma() const + { + updateHints(); + return m_flags & Hint::IsGamma; + } + bool isIdentity() const + { + updateHints(); + return m_flags & Hint::IsIdentity; + } + bool isSRgb() const + { + updateHints(); + return m_flags & Hint::IsSRgb; + } + + float apply(float x) const + { + if (x < m_d) + return m_c * x + m_f; + float t = std::pow(m_a * x + m_b, m_g); + if (std::isfinite(t)) + return t + m_e; + if (t > 0.f) + return 1.f; + else + return 0.f; + } + + QColorTransferFunction inverted() const + { + float a, b, c, d, e, f, g; + + d = m_c * m_d + m_f; + + if (std::isnormal(m_c)) { + c = 1.0f / m_c; + f = -m_f / m_c; + } else { + c = 0.0f; + f = 0.0f; + } + + bool valid_abeg = std::isnormal(m_a) && std::isnormal(m_g); + if (valid_abeg) + a = std::pow(1.0f / m_a, m_g); + if (valid_abeg && !std::isfinite(a)) + valid_abeg = false; + if (valid_abeg) { + b = -a * m_e; + e = -m_b / m_a; + g = 1.0f / m_g; + } else { + a = 0.0f; + b = 0.0f; + e = 1.0f; + g = 1.0f; + } + + return QColorTransferFunction(a, b, c, d, e, f, g); + } + + // A few predefined curves: + static QColorTransferFunction fromGamma(float gamma) + { + return QColorTransferFunction(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, gamma, + Hints(Hint::Calculated) | Hint::IsGamma | + (paramCompare(gamma, 1.0f) ? Hint::IsIdentity : Hint::NoHint)); + } + static QColorTransferFunction fromSRgb() + { + return QColorTransferFunction(1.0f / 1.055f, 0.055f / 1.055f, 1.0f / 12.92f, 0.04045f, 0.0f, 0.0f, 2.4f, + Hints(Hint::Calculated) | Hint::IsSRgb); + } + static QColorTransferFunction fromProPhotoRgb() + { + return QColorTransferFunction(1.0f, 0.0f, 1.0f / 16.0f, 16.0f / 512.0f, 0.0f, 0.0f, 1.8f, + Hints(Hint::Calculated)); + } + static QColorTransferFunction fromBt2020() + { + return QColorTransferFunction(1.0f / 1.0993f, 0.0993f / 1.0993f, 1.0f / 4.5f, 0.08145f, 0.0f, 0.0f, 2.2f, + Hints(Hint::Calculated)); + } + bool matches(const QColorTransferFunction &o) const + { + return paramCompare(m_a, o.m_a) && paramCompare(m_b, o.m_b) + && paramCompare(m_c, o.m_c) && paramCompare(m_d, o.m_d) + && paramCompare(m_e, o.m_e) && paramCompare(m_f, o.m_f) + && paramCompare(m_g, o.m_g); + } + friend inline bool operator==(const QColorTransferFunction &f1, const QColorTransferFunction &f2); + friend inline bool operator!=(const QColorTransferFunction &f1, const QColorTransferFunction &f2); + + float m_a; + float m_b; + float m_c; + float m_d; + float m_e; + float m_f; + float m_g; + + enum class Hint : quint32 { + NoHint = 0, + Calculated = 1, + IsGamma = 2, + IsIdentity = 4, + IsSRgb = 8 + }; + + Q_DECLARE_FLAGS(Hints, Hint); + +private: + QColorTransferFunction(float a, float b, float c, float d, float e, float f, float g, Hints flags) noexcept + : m_a(a), m_b(b), m_c(c), m_d(d), m_e(e), m_f(f), m_g(g), m_flags(flags) + { } + static inline bool paramCompare(float p1, float p2) + { + // Much fuzzier than fuzzy compare. + // It tries match parameters that has been passed through a 8.8 + // fixed point form. + return (qAbs(p1 - p2) <= (1.0f / 512.0f)); + } + + void updateHints() const + { + if (m_flags & Hint::Calculated) + return; + // We do not consider the case with m_d = 1.0f linear or simple, + // since it wouldn't be linear for applyExtended(). + bool simple = paramCompare(m_a, 1.0f) && paramCompare(m_b, 0.0f) + && paramCompare(m_d, 0.0f) + && paramCompare(m_e, 0.0f); + if (simple) { + m_flags |= Hint::IsGamma; + if (qFuzzyCompare(m_g, 1.0f)) + m_flags |= Hint::IsIdentity; + } else { + if (*this == fromSRgb()) + m_flags |= Hint::IsSRgb; + } + m_flags |= Hint::Calculated; + } + + mutable Hints m_flags; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QColorTransferFunction::Hints); + +inline bool operator==(const QColorTransferFunction &f1, const QColorTransferFunction &f2) +{ + return f1.matches(f2); +} +inline bool operator!=(const QColorTransferFunction &f1, const QColorTransferFunction &f2) +{ + return !f1.matches(f2); +} + +QT_END_NAMESPACE + +#endif // QCOLORTRANSFERFUNCTION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransfergeneric_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransfergeneric_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ae4142e5795344001000ad333efdfc4a33ea82df --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransfergeneric_p.h @@ -0,0 +1,109 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLORTRANSFERGENERIC_P_H +#define QCOLORTRANSFERGENERIC_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include + +QT_BEGIN_NAMESPACE + +// Defines the a generic transfer function for our HDR functions +class QColorTransferGenericFunction +{ +public: + using ConverterPtr = float (*)(float); + constexpr QColorTransferGenericFunction(ConverterPtr toLinear = nullptr, ConverterPtr fromLinear = nullptr) noexcept + : m_toLinear(toLinear), m_fromLinear(fromLinear) + {} + + static QColorTransferGenericFunction hlg() + { + return QColorTransferGenericFunction(hlgToLinear, hlgFromLinear); + } + static QColorTransferGenericFunction pq() + { + return QColorTransferGenericFunction(pqToLinear, pqFromLinear); + } + + float apply(float x) const + { + return m_toLinear(x); + } + + float applyInverse(float x) const + { + return m_fromLinear(x); + } + + bool operator==(const QColorTransferGenericFunction &o) const noexcept + { + return m_toLinear == o.m_toLinear && m_fromLinear == o.m_fromLinear; + } + bool operator!=(const QColorTransferGenericFunction &o) const noexcept + { + return m_toLinear != o.m_toLinear || m_fromLinear != o.m_fromLinear; + } + +private: + ConverterPtr m_toLinear = nullptr; + ConverterPtr m_fromLinear = nullptr; + + // HLG from linear [0-12] -> [0-1] + static float hlgFromLinear(float x) + { + if (x > 1.f) + return m_hlg_a * std::log(x - m_hlg_b) + m_hlg_c; + return std::sqrt(x * 0.25f); + } + + // HLG to linear [0-1] -> [0-12] + static float hlgToLinear(float x) + { + if (x < 0.5f) + return (x * x) * 4.f; + return std::exp((x - m_hlg_c) / m_hlg_a) + m_hlg_b; + } + + constexpr static float m_hlg_a = 0.17883277f; + constexpr static float m_hlg_b = 1.f - (4.f * m_hlg_a); + constexpr static float m_hlg_c = 0.55991073f; // 0.5 - a * ln(4 * a) + + // PQ to linear [0-1] -> [0-64] + static float pqToLinear(float x) + { + x = std::pow(x, 1.f / m_pq_m2); + return std::pow((m_pq_c1 - x) / (m_pq_c3 * x - m_pq_c2), (1.f / m_pq_m1)) * m_pq_f; + } + + // PQ from linear [0-64] -> [0-1] + static float pqFromLinear(float x) + { + x = std::pow(x * (1.f / m_pq_f), m_pq_m1); + return std::pow((m_pq_c1 + m_pq_c2 * x) / (1.f + m_pq_c3 * x), m_pq_m2); + } + + constexpr static float m_pq_c1 = 107.f / 128.f; // c3 - c2 + 1 + constexpr static float m_pq_c2 = 2413.f / 128.f; + constexpr static float m_pq_c3 = 2392.f / 128.f; + constexpr static float m_pq_m1 = 1305.f / 8192.f; + constexpr static float m_pq_m2 = 2523.f / 32.f; + constexpr static float m_pq_f = 64.f; // This might need to be set based on scene metadata +}; + +QT_END_NAMESPACE + +#endif // QCOLORTRANSFERGENERIC_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransfertable_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransfertable_p.h new file mode 100644 index 0000000000000000000000000000000000000000..08739c43ca3f323b61f262472e0cc282db517e23 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransfertable_p.h @@ -0,0 +1,242 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLORTRANSFERTABLE_P_H +#define QCOLORTRANSFERTABLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qcolortransferfunction_p.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +// Defines either an ICC TRC 'curve' or a lut8/lut16 A or B table +class Q_GUI_EXPORT QColorTransferTable +{ +public: + enum Type : uint8_t { + TwoWay = 0, + OneWay, + }; + QColorTransferTable() noexcept = default; + QColorTransferTable(uint32_t size, const QList &table, Type type = TwoWay) noexcept + : m_type(type), m_tableSize(size), m_table8(table) + { + Q_ASSERT(qsizetype(size) <= table.size()); + } + QColorTransferTable(uint32_t size, const QList &table, Type type = TwoWay) noexcept + : m_type(type), m_tableSize(size), m_table16(table) + { + Q_ASSERT(qsizetype(size) <= table.size()); + } + + bool isEmpty() const noexcept + { + return m_tableSize == 0; + } + + bool isIdentity() const + { + if (isEmpty()) + return true; + if (m_tableSize != 2) + return false; + if (!m_table8.isEmpty()) + return m_table8[0] == 0 && m_table8[1] == 255; + return m_table16[0] == 0 && m_table16[1] == 65535; + } + + bool checkValidity() const + { + if (isEmpty()) + return true; + // Only one table can be set + if (!m_table8.isEmpty() && !m_table16.isEmpty()) + return false; + // At least 2 elements + if (m_tableSize < 2) + return false; + return (m_type == OneWay) || checkInvertibility(); + } + bool checkInvertibility() const + { + // The two-way tables must describe an injective curve: + if (!m_table8.isEmpty()) { + uint8_t val = 0; + for (uint i = 0; i < m_tableSize; ++i) { + if (m_table8[i] < val) + return false; + val = m_table8[i]; + } + } + if (!m_table16.isEmpty()) { + uint16_t val = 0; + for (uint i = 0; i < m_tableSize; ++i) { + if (m_table16[i] < val) + return false; + val = m_table16[i]; + } + } + return true; + } + + float apply(float x) const + { + if (isEmpty()) + return x; + x = std::clamp(x, 0.0f, 1.0f); + x *= m_tableSize - 1; + const uint32_t lo = static_cast(x); + const uint32_t hi = std::min(lo + 1, m_tableSize - 1); + const float frac = x - lo; + if (!m_table16.isEmpty()) + return (m_table16[lo] + (m_table16[hi] - m_table16[lo]) * frac) * (1.0f/65535.0f); + if (!m_table8.isEmpty()) + return (m_table8[lo] + (m_table8[hi] - m_table8[lo]) * frac) * (1.0f/255.0f); + return x; + } + + // Apply inverse, optimized by giving a previous result for a value < x. + float applyInverse(float x, float resultLargerThan = 0.0f) const + { + Q_ASSERT(resultLargerThan >= 0.0f && resultLargerThan <= 1.0f); + Q_ASSERT(m_type == TwoWay); + if (x <= 0.0f) + return 0.0f; + if (x >= 1.0f) + return 1.0f; + if (!m_table16.isEmpty()) + return inverseLookup(x * 65535.0f, resultLargerThan, m_table16, m_tableSize - 1); + if (!m_table8.isEmpty()) + return inverseLookup(x * 255.0f, resultLargerThan, m_table8, m_tableSize - 1); + return x; + } + + bool asColorTransferFunction(QColorTransferFunction *transferFn) + { + Q_ASSERT(transferFn); + if (isEmpty()) { + *transferFn = QColorTransferFunction(); + return true; + } + if (m_tableSize < 2) + return false; + if (!m_table8.isEmpty() && (m_table8[0] != 0 || m_table8[m_tableSize - 1] != 255)) + return false; + if (!m_table16.isEmpty() && (m_table16[0] != 0 || m_table16[m_tableSize - 1] != 65535)) + return false; + if (m_tableSize == 2) { + *transferFn = QColorTransferFunction(); // Linear + return true; + } + // The following heuristics are based on those from Skia: + if (m_tableSize == 26 && !m_table16.isEmpty()) { + // code.facebook.com/posts/411525055626587/under-the-hood-improving-facebook-photos + if (m_table16[6] != 3062) + return false; + if (m_table16[12] != 12824) + return false; + if (m_table16[18] != 31237) + return false; + *transferFn = QColorTransferFunction::fromSRgb(); + return true; + } + if (m_tableSize == 1024 && !m_table16.isEmpty()) { + // HP and Canon sRGB gamma tables: + if (m_table16[257] != 3366) + return false; + if (m_table16[513] != 14116) + return false; + if (m_table16[768] != 34318) + return false; + *transferFn = QColorTransferFunction::fromSRgb(); + return true; + } + if (m_tableSize == 4096 && !m_table16.isEmpty()) { + // Nikon, Epson, and lcms2 sRGB gamma tables: + if (m_table16[515] != 960) + return false; + if (m_table16[1025] != 3342) + return false; + if (m_table16[2051] != 14079) + return false; + *transferFn = QColorTransferFunction::fromSRgb(); + return true; + } + return false; + } + friend inline bool operator!=(const QColorTransferTable &t1, const QColorTransferTable &t2); + friend inline bool operator==(const QColorTransferTable &t1, const QColorTransferTable &t2); + + Type m_type = TwoWay; + uint32_t m_tableSize = 0; + QList m_table8; + QList m_table16; +private: + template + static float inverseLookup(float needle, float resultLargerThan, const QList &table, quint32 tableMax) + { + uint32_t i = qMax(static_cast(resultLargerThan * tableMax), 1U) - 1; + auto it = std::lower_bound(table.cbegin() + i, table.cend(), needle); + i = it - table.cbegin(); + if (i == 0) + return 0.0f; + if (i >= tableMax) + return 1.0f; + const float y1 = table[i - 1]; + const float y2 = table[i]; + Q_ASSERT(needle >= y1 && needle <= y2); + const float fr = (needle - y1) / (y2 - y1); + return (i + fr) * (1.0f / tableMax); + } + +}; + +inline bool operator!=(const QColorTransferTable &t1, const QColorTransferTable &t2) +{ + if (t1.m_tableSize != t2.m_tableSize) + return true; + if (t1.m_type != t2.m_type) + return true; + if (t1.m_table8.isEmpty() != t2.m_table8.isEmpty()) + return true; + if (t1.m_table16.isEmpty() != t2.m_table16.isEmpty()) + return true; + if (!t1.m_table8.isEmpty()) { + for (uint32_t i = 0; i < t1.m_tableSize; ++i) { + if (t1.m_table8[i] != t2.m_table8[i]) + return true; + } + } + if (!t1.m_table16.isEmpty()) { + for (uint32_t i = 0; i < t1.m_tableSize; ++i) { + if (t1.m_table16[i] != t2.m_table16[i]) + return true; + } + } + return false; +} + +inline bool operator==(const QColorTransferTable &t1, const QColorTransferTable &t2) +{ + return !(t1 != t2); +} + +QT_END_NAMESPACE + +#endif // QCOLORTRANSFERTABLE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransform_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransform_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0e315e3c3b87b3c8be8892f5b2b999b6f420f2b1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortransform_p.h @@ -0,0 +1,67 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLORTRANSFORM_P_H +#define QCOLORTRANSFORM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qcolormatrix_p.h" +#include "qcolorspace_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QCmyk32; + +class QColorTransformPrivate : public QSharedData +{ +public: + QColorMatrix colorMatrix; // Combined colorSpaceIn->toXyz and colorSpaceOut->toXyz.inverted() + QExplicitlySharedDataPointer colorSpaceIn; + QExplicitlySharedDataPointer colorSpaceOut; + + static QColorTransformPrivate *get(const QColorTransform &q) + { return q.d.data(); } + + void updateLutsIn() const; + void updateLutsOut() const; + bool isIdentity() const; + + Q_GUI_EXPORT void prepare(); + enum TransformFlag { + Unpremultiplied = 0, + InputOpaque = 1, + InputPremultiplied = 2, + OutputPremultiplied = 4, + Premultiplied = (InputPremultiplied | OutputPremultiplied) + }; + Q_DECLARE_FLAGS(TransformFlags, TransformFlag) + + QColorVector map(QColorVector color) const; + QColorVector mapExtended(QColorVector color) const; + + template + void apply(D *dst, const S *src, qsizetype count, TransformFlags flags) const; + +private: + void pcsAdapt(QColorVector *buffer, qsizetype len) const; + template + void applyConvertIn(const S *src, QColorVector *buffer, qsizetype len, TransformFlags flags) const; + template + void applyConvertOut(D *dst, const S *src, QColorVector *buffer, qsizetype len, TransformFlags flags) const; +}; + +QT_END_NAMESPACE + +#endif // QCOLORTRANSFORM_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortrc_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortrc_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dc4f679c48ef6f4504a28784d421675388c2bb5b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortrc_p.h @@ -0,0 +1,140 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLORTRC_P_H +#define QCOLORTRC_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qcolortransferfunction_p.h" +#include "qcolortransfergeneric_p.h" +#include "qcolortransfertable_p.h" + +QT_BEGIN_NAMESPACE + +// Defines a TRC (Tone Reproduction Curve) +class Q_GUI_EXPORT QColorTrc +{ +public: + QColorTrc() noexcept : m_type(Type::Uninitialized) { } + QColorTrc(const QColorTransferFunction &fun) : m_type(Type::ParameterizedFunction), m_fun(fun) { } + QColorTrc(const QColorTransferTable &table) : m_type(Type::Table), m_table(table) { } + QColorTrc(const QColorTransferGenericFunction &hdr) : m_type(Type::GenericFunction), m_hdr(hdr) { } + QColorTrc(QColorTransferFunction &&fun) noexcept : m_type(Type::ParameterizedFunction), m_fun(std::move(fun)) { } + QColorTrc(QColorTransferTable &&table) noexcept : m_type(Type::Table), m_table(std::move(table)) { } + QColorTrc(QColorTransferGenericFunction &&hdr) noexcept : m_type(Type::GenericFunction), m_hdr(std::move(hdr)) { } + + enum class Type { + Uninitialized, + ParameterizedFunction, + GenericFunction, + Table, + }; + + bool isIdentity() const + { + return (m_type == Type::ParameterizedFunction && m_fun.isIdentity()) + || (m_type == Type::Table && m_table.isIdentity()); + } + bool isValid() const + { + return m_type != Type::Uninitialized; + } + float apply(float x) const + { + switch (m_type) { + case Type::ParameterizedFunction: + return fun().apply(x); + case Type::GenericFunction: + return hdr().apply(x); + case Type::Table: + return table().apply(x); + default: + break; + } + return x; + } + float applyExtended(float x) const + { + switch (m_type) { + case Type::ParameterizedFunction: + return std::copysign(fun().apply(std::abs(x)), x); + case Type::GenericFunction: + return hdr().apply(x); + case Type::Table: + return table().apply(x); + default: + break; + } + return x; + } + float applyInverse(float x) const + { + switch (m_type) { + case Type::ParameterizedFunction: + return fun().inverted().apply(x); + case Type::GenericFunction: + return hdr().applyInverse(x); + case Type::Table: + return table().applyInverse(x); + default: + break; + } + return x; + } + float applyInverseExtended(float x) const + { + switch (m_type) { + case Type::ParameterizedFunction: + return std::copysign(applyInverse(std::abs(x)), x); + case Type::GenericFunction: + return hdr().applyInverse(x); + case Type::Table: + return table().applyInverse(x); + default: + break; + } + return x; + } + + const QColorTransferTable &table() const { return m_table; } + const QColorTransferFunction &fun() const{ return m_fun; } + const QColorTransferGenericFunction &hdr() const { return m_hdr; } + Type type() const noexcept { return m_type; } + + Type m_type; + + friend inline bool comparesEqual(const QColorTrc &lhs, const QColorTrc &rhs); + Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QColorTrc); + + QColorTransferFunction m_fun; + QColorTransferTable m_table; + QColorTransferGenericFunction m_hdr; +}; + +inline bool comparesEqual(const QColorTrc &o1, const QColorTrc &o2) +{ + if (o1.m_type != o2.m_type) + return false; + if (o1.m_type == QColorTrc::Type::ParameterizedFunction) + return o1.m_fun == o2.m_fun; + if (o1.m_type == QColorTrc::Type::Table) + return o1.m_table == o2.m_table; + if (o1.m_type == QColorTrc::Type::GenericFunction) + return o1.m_hdr == o2.m_hdr; + return true; +} + +QT_END_NAMESPACE + +#endif // QCOLORTRC diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortrclut_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortrclut_p.h new file mode 100644 index 0000000000000000000000000000000000000000..13a17242fc8555382f1966c872a61418d01ca3d5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcolortrclut_p.h @@ -0,0 +1,272 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLORTRCLUT_P_H +#define QCOLORTRCLUT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +#include +#include + +#if defined(__SSE2__) +#include +#elif defined(__ARM_NEON__) +#include +#endif + +QT_BEGIN_NAMESPACE + +class QColorTransferGenericFunction; +class QColorTransferFunction; +class QColorTransferTable; +class QColorTrc; + +class Q_GUI_EXPORT QColorTrcLut +{ +public: + static constexpr uint32_t ShiftUp = 4; // Amount to shift up from 1->255 + static constexpr uint32_t ShiftDown = (8 - ShiftUp); // Amount to shift down from 1->65280 + static constexpr qsizetype Resolution = (1 << ShiftUp) * 255; // Number of entries in table + + enum Direction { + ToLinear = 1, + FromLinear = 2, + BiLinear = ToLinear | FromLinear + }; + + static std::shared_ptr fromGamma(float gamma, Direction dir = BiLinear); + static std::shared_ptr fromTrc(const QColorTrc &trc, Direction dir = BiLinear); + void setFromGamma(float gamma, Direction dir = BiLinear); + void setFromTransferFunction(const QColorTransferFunction &transFn, Direction dir = BiLinear); + void setFromTransferTable(const QColorTransferTable &transTable, Direction dir = BiLinear); + void setFromTransferGenericFunction(const QColorTransferGenericFunction &transfn, Direction dir); + void setFromTrc(const QColorTrc &trc, Direction dir); + + // The following methods all convert opaque or unpremultiplied colors: + + QRgba64 toLinear64(QRgb rgb32) const + { +#if defined(__SSE2__) + __m128i v = _mm_cvtsi32_si128(rgb32); + v = _mm_unpacklo_epi8(v, _mm_setzero_si128()); + const __m128i vidx = _mm_slli_epi16(v, ShiftUp); + const int ridx = _mm_extract_epi16(vidx, 2); + const int gidx = _mm_extract_epi16(vidx, 1); + const int bidx = _mm_extract_epi16(vidx, 0); + v = _mm_slli_epi16(v, 8); // a * 256 + v = _mm_insert_epi16(v, m_toLinear[ridx], 0); + v = _mm_insert_epi16(v, m_toLinear[gidx], 1); + v = _mm_insert_epi16(v, m_toLinear[bidx], 2); + v = _mm_add_epi16(v, _mm_srli_epi16(v, 8)); + QRgba64 rgba64; + _mm_storel_epi64(reinterpret_cast<__m128i *>(&rgba64), v); + return rgba64; +#elif defined(__ARM_NEON__) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN + uint8x8_t v8 = vreinterpret_u8_u32(vmov_n_u32(rgb32)); + uint16x4_t v16 = vget_low_u16(vmovl_u8(v8)); + const uint16x4_t vidx = vshl_n_u16(v16, ShiftUp); + const int ridx = vget_lane_u16(vidx, 2); + const int gidx = vget_lane_u16(vidx, 1); + const int bidx = vget_lane_u16(vidx, 0); + v16 = vshl_n_u16(v16, 8); // a * 256 + v16 = vset_lane_u16(m_toLinear[ridx], v16, 0); + v16 = vset_lane_u16(m_toLinear[gidx], v16, 1); + v16 = vset_lane_u16(m_toLinear[bidx], v16, 2); + v16 = vadd_u16(v16, vshr_n_u16(v16, 8)); + return QRgba64::fromRgba64(vget_lane_u64(vreinterpret_u64_u16(v16), 0)); +#else + uint r = m_toLinear[qRed(rgb32) << ShiftUp]; + uint g = m_toLinear[qGreen(rgb32) << ShiftUp]; + uint b = m_toLinear[qBlue(rgb32) << ShiftUp]; + r = r + (r >> 8); + g = g + (g >> 8); + b = b + (b >> 8); + return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257); +#endif + } + QRgba64 toLinear64(QRgba64) const = delete; + + QRgb toLinear(QRgb rgb32) const + { + return convertWithTable(rgb32, m_toLinear.get()); + } + + QRgba64 toLinear(QRgba64 rgb64) const + { + return convertWithTable(rgb64, m_toLinear.get()); + } + + float u8ToLinearF32(int c) const + { + ushort v = m_toLinear[c << ShiftUp]; + return v * (1.0f / (255*256)); + } + + float u16ToLinearF32(int c) const + { + c -= (c >> 8); + ushort v = m_toLinear[c >> ShiftDown]; + return v * (1.0f / (255*256)); + } + + float toLinear(float f) const + { + ushort v = m_toLinear[(int)(f * Resolution + 0.5f)]; + return v * (1.0f / (255*256)); + } + + QRgb fromLinear64(QRgba64 rgb64) const + { +#if defined(__SSE2__) + __m128i v = _mm_loadl_epi64(reinterpret_cast(&rgb64)); + v = _mm_sub_epi16(v, _mm_srli_epi16(v, 8)); + const __m128i vidx = _mm_srli_epi16(v, ShiftDown); + const int ridx = _mm_extract_epi16(vidx, 0); + const int gidx = _mm_extract_epi16(vidx, 1); + const int bidx = _mm_extract_epi16(vidx, 2); + v = _mm_insert_epi16(v, m_fromLinear[ridx], 2); + v = _mm_insert_epi16(v, m_fromLinear[gidx], 1); + v = _mm_insert_epi16(v, m_fromLinear[bidx], 0); + v = _mm_add_epi16(v, _mm_set1_epi16(0x80)); + v = _mm_srli_epi16(v, 8); + v = _mm_packus_epi16(v, v); + return _mm_cvtsi128_si32(v); +#elif defined(__ARM_NEON__) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN + uint16x4_t v = vreinterpret_u16_u64(vmov_n_u64(rgb64)); + v = vsub_u16(v, vshr_n_u16(v, 8)); + const uint16x4_t vidx = vshr_n_u16(v, ShiftDown); + const int ridx = vget_lane_u16(vidx, 0); + const int gidx = vget_lane_u16(vidx, 1); + const int bidx = vget_lane_u16(vidx, 2); + v = vset_lane_u16(m_fromLinear[ridx], v, 2); + v = vset_lane_u16(m_fromLinear[gidx], v, 1); + v = vset_lane_u16(m_fromLinear[bidx], v, 0); + uint8x8_t v8 = vrshrn_n_u16(vcombine_u16(v, v), 8); + return vget_lane_u32(vreinterpret_u32_u8(v8), 0); +#else + uint a = rgb64.alpha(); + uint r = rgb64.red(); + uint g = rgb64.green(); + uint b = rgb64.blue(); + a = a - (a >> 8); + r = r - (r >> 8); + g = g - (g >> 8); + b = b - (b >> 8); + a = (a + 0x80) >> 8; + r = (m_fromLinear[r >> ShiftDown] + 0x80) >> 8; + g = (m_fromLinear[g >> ShiftDown] + 0x80) >> 8; + b = (m_fromLinear[b >> ShiftDown] + 0x80) >> 8; + return (a << 24) | (r << 16) | (g << 8) | b; +#endif + } + + QRgb fromLinear(QRgb rgb32) const + { + return convertWithTable(rgb32, m_fromLinear.get()); + } + + QRgba64 fromLinear(QRgba64 rgb64) const + { + return convertWithTable(rgb64, m_fromLinear.get()); + } + + int u8FromLinearF32(float f) const + { + ushort v = m_fromLinear[(int)(f * Resolution + 0.5f)]; + return (v + 0x80) >> 8; + } + int u16FromLinearF32(float f) const + { + ushort v = m_fromLinear[(int)(f * Resolution + 0.5f)]; + return v + (v >> 8); + } + float fromLinear(float f) const + { + ushort v = m_fromLinear[(int)(f * Resolution + 0.5f)]; + return v * (1.0f / (255*256)); + } + + // We translate to 0-65280 (255*256) instead to 0-65535 to make simple + // shifting an accurate conversion. + // We translate from 0->Resolution (4080 = 255*16) for the same speed up, + // and to keep the tables small enough to fit in most inner caches. + std::unique_ptr m_toLinear; // [0->Resolution] -> [0-65280] + std::unique_ptr m_fromLinear; // [0->Resolution] -> [0-65280] + ushort m_unclampedToLinear = Resolution; + +private: + QColorTrcLut() = default; + + static std::shared_ptr create(); + + Q_ALWAYS_INLINE static QRgb convertWithTable(QRgb rgb32, const ushort *table) + { + const int r = (table[qRed(rgb32) << ShiftUp] + 0x80) >> 8; + const int g = (table[qGreen(rgb32) << ShiftUp] + 0x80) >> 8; + const int b = (table[qBlue(rgb32) << ShiftUp] + 0x80) >> 8; + return (rgb32 & 0xff000000) | (r << 16) | (g << 8) | b; + } + Q_ALWAYS_INLINE static QRgba64 convertWithTable(QRgba64 rgb64, const ushort *table) + { +#if defined(__SSE2__) + __m128i v = _mm_loadl_epi64(reinterpret_cast(&rgb64)); + v = _mm_sub_epi16(v, _mm_srli_epi16(v, 8)); + const __m128i vidx = _mm_srli_epi16(v, ShiftDown); + const int ridx = _mm_extract_epi16(vidx, 2); + const int gidx = _mm_extract_epi16(vidx, 1); + const int bidx = _mm_extract_epi16(vidx, 0); + v = _mm_insert_epi16(v, table[ridx], 2); + v = _mm_insert_epi16(v, table[gidx], 1); + v = _mm_insert_epi16(v, table[bidx], 0); + v = _mm_add_epi16(v, _mm_srli_epi16(v, 8)); + QRgba64 rgba64; + _mm_storel_epi64(reinterpret_cast<__m128i *>(&rgba64), v); + return rgba64; +#elif defined(__ARM_NEON__) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN + uint16x4_t v = vreinterpret_u16_u64(vmov_n_u64(rgb64)); + v = vsub_u16(v, vshr_n_u16(v, 8)); + const uint16x4_t vidx = vshr_n_u16(v, ShiftDown); + const int ridx = vget_lane_u16(vidx, 2); + const int gidx = vget_lane_u16(vidx, 1); + const int bidx = vget_lane_u16(vidx, 0); + v = vset_lane_u16(table[ridx], v, 2); + v = vset_lane_u16(table[gidx], v, 1); + v = vset_lane_u16(table[bidx], v, 0); + v = vadd_u16(v, vshr_n_u16(v, 8)); + return QRgba64::fromRgba64(vget_lane_u64(vreinterpret_u64_u16(v), 0)); +#else + ushort r = rgb64.red(); + ushort g = rgb64.green(); + ushort b = rgb64.blue(); + r = r - (r >> 8); + g = g - (g >> 8); + b = b - (b >> 8); + r = table[r >> ShiftDown]; + g = table[g >> ShiftDown]; + b = table[b >> ShiftDown]; + r = r + (r >> 8); + g = g + (g >> 8); + b = b + (b >> 8); + return QRgba64::fromRgba64(r, g, b, rgb64.alpha()); +#endif + } +}; + +QT_END_NAMESPACE + +#endif // QCOLORTRCLUT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcosmeticstroker_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcosmeticstroker_p.h new file mode 100644 index 0000000000000000000000000000000000000000..67ed13b455786909bcbca85ddaf01683a02c2240 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcosmeticstroker_p.h @@ -0,0 +1,128 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOSMETICSTROKER_P_H +#define QCOSMETICSTROKER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + + +class QCosmeticStroker; + + +typedef bool (*StrokeLine)(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, qreal y2, int caps); + +class QCosmeticStroker +{ +public: + struct Point { + int x; + int y; + }; + struct PointF { + qreal x; + qreal y; + }; + + enum Caps { + NoCaps = 0, + CapBegin = 0x1, + CapEnd = 0x2 + }; + + // used to avoid drop outs or duplicated points + enum Direction { + NoDirection = 0, + TopToBottom = 0x1, + BottomToTop = 0x2, + LeftToRight = 0x4, + RightToLeft = 0x8, + VerticalMask = 0x3, + HorizontalMask = 0xc + }; + + QCosmeticStroker(QRasterPaintEngineState *s, const QRect &dr, const QRect &dr_unclipped) + : state(s), + deviceRect(dr_unclipped), + clip(dr), + pattern(nullptr), + reversePattern(nullptr), + patternSize(0), + patternLength(0), + patternOffset(0), + current_span(0), + lastDir(NoDirection), + lastAxisAligned(false) + { setup(); } + + ~QCosmeticStroker() { free(pattern); free(reversePattern); } + + void drawLine(const QPointF &p1, const QPointF &p2); + void drawPath(const QVectorPath &path); + void drawPoints(const QPoint *points, int num); + void drawPoints(const QPointF *points, int num); + + + QRasterPaintEngineState *state; + QRect deviceRect; + QRect clip; + // clip bounds in real + qreal xmin, xmax; + qreal ymin, ymax; + + StrokeLine stroke; + bool drawCaps; + + int *pattern; + int *reversePattern; + int patternSize; + int patternLength; + int patternOffset; + + enum { NSPANS = 255 }; + QT_FT_Span spans[NSPANS]; + int current_span; + ProcessSpans blend; + + int opacity; + + uint color; + uint *pixels; + int ppl; + + Direction lastDir; + Point lastPixel; + bool lastAxisAligned; + +private: + void setup(); + + void renderCubic(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4, int caps); + void renderCubicSubdivision(PointF *points, int level, int caps); + // used for closed subpaths + void calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal ry2); + +public: + bool clipLine(qreal &x1, qreal &y1, qreal &x2, qreal &y2); +}; + +QT_END_NAMESPACE + +#endif // QCOSMETICLINE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcssparser_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcssparser_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f99825b629f7f13b6ed24b3a5f4a26780a09c55c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcssparser_p.h @@ -0,0 +1,881 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCSSPARSER_P_H +#define QCSSPARSER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QIcon; +QT_END_NAMESPACE + +#ifndef QT_NO_CSSPARSER + +// VxWorks defines NONE as (-1) "for times when NULL won't do" +#if defined(Q_OS_VXWORKS) && defined(NONE) +# undef NONE +#endif +#if defined(Q_OS_INTEGRITY) +# undef Value +#endif +// Hurd has #define TILDE 0x00080000 from +#if defined(TILDE) +# undef TILDE +#endif + +#define QT_CSS_DECLARE_TYPEINFO(Class, Type) \ + } /* namespace QCss */ \ + Q_DECLARE_TYPEINFO(QCss:: Class, Type); \ + namespace QCss { + +QT_BEGIN_NAMESPACE + +namespace QCss +{ + +enum Property { + UnknownProperty, + BackgroundColor, + Color, + Float, + Font, + FontFamily, + FontSize, + FontStyle, + FontWeight, + Margin, + MarginBottom, + MarginLeft, + MarginRight, + MarginTop, + QtBlockIndent, + QtListIndent, + QtParagraphType, + QtTableType, + QtUserState, + TextDecoration, + TextIndent, + TextUnderlineStyle, + VerticalAlignment, + Whitespace, + QtSelectionForeground, + QtSelectionBackground, + Border, + BorderLeft, + BorderRight, + BorderTop, + BorderBottom, + BorderCollapse, + Padding, + PaddingLeft, + PaddingRight, + PaddingTop, + PaddingBottom, + PageBreakBefore, + PageBreakAfter, + QtAlternateBackground, + BorderLeftStyle, + BorderRightStyle, + BorderTopStyle, + BorderBottomStyle, + BorderStyles, + BorderLeftColor, + BorderRightColor, + BorderTopColor, + BorderBottomColor, + BorderColor, + BorderLeftWidth, + BorderRightWidth, + BorderTopWidth, + BorderBottomWidth, + BorderWidth, + BorderTopLeftRadius, + BorderTopRightRadius, + BorderBottomLeftRadius, + BorderBottomRightRadius, + BorderRadius, + Background, + BackgroundOrigin, + BackgroundClip, + BackgroundRepeat, + BackgroundPosition, + BackgroundAttachment, + BackgroundImage, + BorderImage, + QtSpacing, + Width, + Height, + MinimumWidth, + MinimumHeight, + MaximumWidth, + MaximumHeight, + QtImage, + Left, + Right, + Top, + Bottom, + QtOrigin, + QtPosition, + Position, + QtStyleFeatures, + QtBackgroundRole, + ListStyleType, + ListStyle, + QtImageAlignment, + TextAlignment, + Outline, + OutlineOffset, + OutlineWidth, + OutlineColor, + OutlineStyle, + OutlineRadius, + OutlineTopLeftRadius, + OutlineTopRightRadius, + OutlineBottomLeftRadius, + OutlineBottomRightRadius, + FontVariant, + TextTransform, + QtListNumberPrefix, + QtListNumberSuffix, + LineHeight, + QtLineHeightType, + FontKerning, + QtForegroundTextureCacheKey, + QtIcon, + LetterSpacing, + WordSpacing, + TextDecorationColor, + QtPlaceHolderTextColor, + QtAccent, + QtStrokeWidth, + QtStrokeColor, + QtStrokeLineCap, + QtStrokeLineJoin, + QtStrokeMiterLimit, + QtStrokeDashArray, + QtStrokeDashOffset, + QtForeground, + NumProperties +}; + +enum KnownValue { + UnknownValue, + Value_Normal, + Value_Pre, + Value_NoWrap, + Value_PreLine, + Value_PreWrap, + Value_Small, + Value_Medium, + Value_Large, + Value_XLarge, + Value_XXLarge, + Value_Italic, + Value_Oblique, + Value_Bold, + Value_Underline, + Value_Overline, + Value_LineThrough, + Value_Sub, + Value_Super, + Value_Left, + Value_Right, + Value_Top, + Value_Bottom, + Value_Center, + Value_Native, + Value_Solid, + Value_Dotted, + Value_Dashed, + Value_DotDash, + Value_DotDotDash, + Value_Double, + Value_Groove, + Value_Ridge, + Value_Inset, + Value_Outset, + Value_Wave, + Value_Middle, + Value_Auto, + Value_Always, + Value_None, + Value_Transparent, + Value_Disc, + Value_Circle, + Value_Square, + Value_Decimal, + Value_LowerAlpha, + Value_UpperAlpha, + Value_LowerRoman, + Value_UpperRoman, + Value_SmallCaps, + Value_Uppercase, + Value_Lowercase, + Value_SquareCap, + Value_FlatCap, + Value_RoundCap, + Value_MiterJoin, + Value_BevelJoin, + Value_RoundJoin, + Value_SvgMiterJoin, + + /* keep these in same order as QPalette::ColorRole */ + Value_FirstColorRole, + Value_WindowText = Value_FirstColorRole, + Value_Button, + Value_Light, + Value_Midlight, + Value_Dark, + Value_Mid, + Value_Text, + Value_BrightText, + Value_ButtonText, + Value_Base, + Value_Window, + Value_Shadow, + Value_Highlight, + Value_HighlightedText, + Value_Link, + Value_LinkVisited, + Value_AlternateBase, + Value_LastColorRole = Value_AlternateBase, + + Value_Disabled, + Value_Active, + Value_Selected, + Value_On, + Value_Off, + + NumKnownValues +}; + +enum BorderStyle { + BorderStyle_Unknown, + BorderStyle_None, + BorderStyle_Dotted, + BorderStyle_Dashed, + BorderStyle_Solid, + BorderStyle_Double, + BorderStyle_DotDash, + BorderStyle_DotDotDash, + BorderStyle_Groove, + BorderStyle_Ridge, + BorderStyle_Inset, + BorderStyle_Outset, + BorderStyle_Native, + NumKnownBorderStyles +}; + +enum Edge { + TopEdge, + RightEdge, + BottomEdge, + LeftEdge, + NumEdges +}; + +enum Corner { + TopLeftCorner, + TopRightCorner, + BottomLeftCorner, + BottomRightCorner +}; + +enum TileMode { + TileMode_Unknown, + TileMode_Round, + TileMode_Stretch, + TileMode_Repeat, + NumKnownTileModes +}; + +enum Repeat { + Repeat_Unknown, + Repeat_None, + Repeat_X, + Repeat_Y, + Repeat_XY, + NumKnownRepeats +}; + +enum Origin { + Origin_Unknown, + Origin_Padding, + Origin_Border, + Origin_Content, + Origin_Margin, + NumKnownOrigins +}; + +enum PositionMode { + PositionMode_Unknown, + PositionMode_Static, + PositionMode_Relative, + PositionMode_Absolute, + PositionMode_Fixed, + NumKnownPositionModes +}; + +enum Attachment { + Attachment_Unknown, + Attachment_Fixed, + Attachment_Scroll, + NumKnownAttachments +}; + +enum StyleFeature { + StyleFeature_None = 0, + StyleFeature_BackgroundColor = 1, + StyleFeature_BackgroundGradient = 2, + NumKnownStyleFeatures = 4 +}; + +struct Value +{ + enum Type { + Unknown, + Number, + Percentage, + Length, + String, + Identifier, + KnownIdentifier, + Uri, + Color, + Function, + TermOperatorSlash, + TermOperatorComma + }; + inline Value() : type(Unknown) { } + Type type; + QVariant variant; + + Q_GUI_EXPORT QString toString() const; +}; +QT_CSS_DECLARE_TYPEINFO(Value, Q_RELOCATABLE_TYPE) + +struct ColorData { + ColorData() : role(QPalette::NoRole), type(Invalid) {} + ColorData(const QColor &col) : color(col), role(QPalette::NoRole), type(Color) {} + ColorData(QPalette::ColorRole r) : role(r), type(Role) {} + QColor color; + QPalette::ColorRole role; + enum { Invalid, Color, Role} type; +}; +QT_CSS_DECLARE_TYPEINFO(ColorData, Q_RELOCATABLE_TYPE) + +struct BrushData { + BrushData() : role(QPalette::NoRole), type(Invalid) {} + BrushData(const QBrush &br) : brush(br), role(QPalette::NoRole), type(Brush) {} + BrushData(QPalette::ColorRole r) : role(r), type(Role) {} + QBrush brush; + QPalette::ColorRole role; + enum { Invalid, Brush, Role, DependsOnThePalette } type; +}; +QT_CSS_DECLARE_TYPEINFO(BrushData, Q_RELOCATABLE_TYPE) + +struct BackgroundData { + BrushData brush; + QString image; + Repeat repeat; + Qt::Alignment alignment; +}; +QT_CSS_DECLARE_TYPEINFO(BackgroundData, Q_RELOCATABLE_TYPE) + +struct LengthData { + qreal number; + enum { None, Px, Ex, Em, Percent } unit; +}; +QT_CSS_DECLARE_TYPEINFO(LengthData, Q_PRIMITIVE_TYPE) + +struct BorderData { + LengthData width; + BorderStyle style; + BrushData color; +}; +QT_CSS_DECLARE_TYPEINFO(BorderData, Q_RELOCATABLE_TYPE) + +// 1. StyleRule - x:hover, y:clicked > z:checked { prop1: value1; prop2: value2; } +// 2. QList - x:hover, y:clicked z:checked +// 3. QList - y:clicked z:checked +// 4. QList - { prop1: value1; prop2: value2; } +// 5. Declaration - prop1: value1; + +struct Q_GUI_EXPORT Declaration +{ + struct DeclarationData : public QSharedData + { + inline DeclarationData() : propertyId(UnknownProperty), important(false), inheritable(false) {} + QString property; + Property propertyId; + QList values; + QVariant parsed; + bool important:1; + bool inheritable:1; + }; + QExplicitlySharedDataPointer d; + inline Declaration() : d(new DeclarationData()) {} + inline bool isEmpty() const { return d->property.isEmpty() && d->propertyId == UnknownProperty; } + + // helper functions + QColor colorValue(const QPalette & = QPalette()) const; + void colorValues(QColor *c, const QPalette & = QPalette()) const; + QBrush brushValue(const QPalette & = QPalette()) const; + void brushValues(QBrush *c, const QPalette & = QPalette()) const; + + BorderStyle styleValue() const; + void styleValues(BorderStyle *s) const; + + Origin originValue() const; + Repeat repeatValue() const; + Qt::Alignment alignmentValue() const; + PositionMode positionValue() const; + Attachment attachmentValue() const; + int styleFeaturesValue() const; + + bool intValue(int *i, const char *unit = nullptr) const; + bool realValue(qreal *r, const char *unit = nullptr) const; + + QSize sizeValue() const; + QRect rectValue() const; + QString uriValue() const; + QIcon iconValue() const; + + void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const; + bool borderCollapseValue() const; + + QList dashArray() const; +}; +QT_CSS_DECLARE_TYPEINFO(Declaration, Q_RELOCATABLE_TYPE) + +const quint64 PseudoClass_Unknown = Q_UINT64_C(0x0000000000000000); +const quint64 PseudoClass_Enabled = Q_UINT64_C(0x0000000000000001); +const quint64 PseudoClass_Disabled = Q_UINT64_C(0x0000000000000002); +const quint64 PseudoClass_Pressed = Q_UINT64_C(0x0000000000000004); +const quint64 PseudoClass_Focus = Q_UINT64_C(0x0000000000000008); +const quint64 PseudoClass_Hover = Q_UINT64_C(0x0000000000000010); +const quint64 PseudoClass_Checked = Q_UINT64_C(0x0000000000000020); +const quint64 PseudoClass_Unchecked = Q_UINT64_C(0x0000000000000040); +const quint64 PseudoClass_Indeterminate = Q_UINT64_C(0x0000000000000080); +const quint64 PseudoClass_Unspecified = Q_UINT64_C(0x0000000000000100); +const quint64 PseudoClass_Selected = Q_UINT64_C(0x0000000000000200); +const quint64 PseudoClass_Horizontal = Q_UINT64_C(0x0000000000000400); +const quint64 PseudoClass_Vertical = Q_UINT64_C(0x0000000000000800); +const quint64 PseudoClass_Window = Q_UINT64_C(0x0000000000001000); +const quint64 PseudoClass_Children = Q_UINT64_C(0x0000000000002000); +const quint64 PseudoClass_Sibling = Q_UINT64_C(0x0000000000004000); +const quint64 PseudoClass_Default = Q_UINT64_C(0x0000000000008000); +const quint64 PseudoClass_First = Q_UINT64_C(0x0000000000010000); +const quint64 PseudoClass_Last = Q_UINT64_C(0x0000000000020000); +const quint64 PseudoClass_Middle = Q_UINT64_C(0x0000000000040000); +const quint64 PseudoClass_OnlyOne = Q_UINT64_C(0x0000000000080000); +const quint64 PseudoClass_PreviousSelected = Q_UINT64_C(0x0000000000100000); +const quint64 PseudoClass_NextSelected = Q_UINT64_C(0x0000000000200000); +const quint64 PseudoClass_Flat = Q_UINT64_C(0x0000000000400000); +const quint64 PseudoClass_Left = Q_UINT64_C(0x0000000000800000); +const quint64 PseudoClass_Right = Q_UINT64_C(0x0000000001000000); +const quint64 PseudoClass_Top = Q_UINT64_C(0x0000000002000000); +const quint64 PseudoClass_Bottom = Q_UINT64_C(0x0000000004000000); +const quint64 PseudoClass_Exclusive = Q_UINT64_C(0x0000000008000000); +const quint64 PseudoClass_NonExclusive = Q_UINT64_C(0x0000000010000000); +const quint64 PseudoClass_Frameless = Q_UINT64_C(0x0000000020000000); +const quint64 PseudoClass_ReadOnly = Q_UINT64_C(0x0000000040000000); +const quint64 PseudoClass_Active = Q_UINT64_C(0x0000000080000000); +const quint64 PseudoClass_Closable = Q_UINT64_C(0x0000000100000000); +const quint64 PseudoClass_Movable = Q_UINT64_C(0x0000000200000000); +const quint64 PseudoClass_Floatable = Q_UINT64_C(0x0000000400000000); +const quint64 PseudoClass_Minimized = Q_UINT64_C(0x0000000800000000); +const quint64 PseudoClass_Maximized = Q_UINT64_C(0x0000001000000000); +const quint64 PseudoClass_On = Q_UINT64_C(0x0000002000000000); +const quint64 PseudoClass_Off = Q_UINT64_C(0x0000004000000000); +const quint64 PseudoClass_Editable = Q_UINT64_C(0x0000008000000000); +const quint64 PseudoClass_Item = Q_UINT64_C(0x0000010000000000); +const quint64 PseudoClass_Closed = Q_UINT64_C(0x0000020000000000); +const quint64 PseudoClass_Open = Q_UINT64_C(0x0000040000000000); +const quint64 PseudoClass_EditFocus = Q_UINT64_C(0x0000080000000000); +const quint64 PseudoClass_Alternate = Q_UINT64_C(0x0000100000000000); +// The Any specifier is never generated, but can be used as a wildcard in searches. +const quint64 PseudoClass_Any = Q_UINT64_C(0x0000ffffffffffff); +const int NumPseudos = 45; + +struct Pseudo +{ + Pseudo() : type(0), negated(false) { } + quint64 type; + QString name; + QString function; + bool negated; +}; +QT_CSS_DECLARE_TYPEINFO(Pseudo, Q_RELOCATABLE_TYPE) + +struct AttributeSelector +{ + enum ValueMatchType { + NoMatch, + MatchEqual, + MatchIncludes, + MatchDashMatch, + MatchBeginsWith, + MatchEndsWith, + MatchContains + }; + + QString name; + QString value; + ValueMatchType valueMatchCriterium = NoMatch; +}; +QT_CSS_DECLARE_TYPEINFO(AttributeSelector, Q_RELOCATABLE_TYPE) + +struct BasicSelector +{ + inline BasicSelector() : relationToNext(NoRelation) {} + + enum Relation { + NoRelation, + MatchNextSelectorIfAncestor, + MatchNextSelectorIfParent, + MatchNextSelectorIfDirectAdjecent, + MatchNextSelectorIfIndirectAdjecent, + }; + + QString elementName; + + QStringList ids; + QList pseudos; + QList attributeSelectors; + + Relation relationToNext; +}; +QT_CSS_DECLARE_TYPEINFO(BasicSelector, Q_RELOCATABLE_TYPE) + +struct Q_GUI_EXPORT Selector +{ + QList basicSelectors; + int specificity() const; + quint64 pseudoClass(quint64 *negated = nullptr) const; + QString pseudoElement() const; +}; +QT_CSS_DECLARE_TYPEINFO(Selector, Q_RELOCATABLE_TYPE) + +struct StyleRule +{ + StyleRule() : order(0) { } + QList selectors; + QList declarations; + int order; +}; +QT_CSS_DECLARE_TYPEINFO(StyleRule, Q_RELOCATABLE_TYPE) + +struct MediaRule +{ + QStringList media; + QList styleRules; +}; +QT_CSS_DECLARE_TYPEINFO(MediaRule, Q_RELOCATABLE_TYPE) + +struct PageRule +{ + QString selector; + QList declarations; +}; +QT_CSS_DECLARE_TYPEINFO(PageRule, Q_RELOCATABLE_TYPE) + +struct ImportRule +{ + QString href; + QStringList media; +}; +QT_CSS_DECLARE_TYPEINFO(ImportRule, Q_RELOCATABLE_TYPE) + +enum StyleSheetOrigin { + StyleSheetOrigin_Unspecified, + StyleSheetOrigin_UserAgent, + StyleSheetOrigin_User, + StyleSheetOrigin_Author, + StyleSheetOrigin_Inline +}; + +struct StyleSheet +{ + StyleSheet() : origin(StyleSheetOrigin_Unspecified), depth(0) { } + QList styleRules; // only contains rules that are not indexed + QList mediaRules; + QList pageRules; + QList importRules; + StyleSheetOrigin origin; + int depth; // applicable only for inline style sheets + QMultiHash nameIndex; + QMultiHash idIndex; + + Q_GUI_EXPORT void buildIndexes(Qt::CaseSensitivity nameCaseSensitivity = Qt::CaseSensitive); +}; +QT_CSS_DECLARE_TYPEINFO(StyleSheet, Q_RELOCATABLE_TYPE) + + +class Q_GUI_EXPORT StyleSelector +{ +public: + StyleSelector() : nameCaseSensitivity(Qt::CaseSensitive) {} + virtual ~StyleSelector(); + + union NodePtr { + void *ptr; + int id; + }; + + QList styleRulesForNode(NodePtr node); + QList declarationsForNode(NodePtr node, const char *extraPseudo = nullptr); + + virtual bool nodeNameEquals(NodePtr node, const QString& nodeName) const; + virtual QString attributeValue(NodePtr node, const QCss::AttributeSelector &aSelector) const = 0; + virtual bool hasAttributes(NodePtr node) const = 0; + virtual QStringList nodeIds(NodePtr node) const; + virtual QStringList nodeNames(NodePtr node) const = 0; + virtual bool isNullNode(NodePtr node) const = 0; + virtual NodePtr parentNode(NodePtr node) const = 0; + virtual NodePtr previousSiblingNode(NodePtr node) const = 0; + virtual NodePtr duplicateNode(NodePtr node) const = 0; + virtual void freeNode(NodePtr node) const = 0; + + QList styleSheets; + QString medium; + Qt::CaseSensitivity nameCaseSensitivity; +private: + void matchRule(NodePtr node, const StyleRule &rules, StyleSheetOrigin origin, + int depth, QMultiMap *weightedRules); + bool selectorMatches(const Selector &rule, NodePtr node); + bool basicSelectorMatches(const BasicSelector &rule, NodePtr node); +}; + +enum TokenType { + NONE, + + S, + + CDO, + CDC, + INCLUDES, + DASHMATCH, + BEGINSWITH, + ENDSWITH, + CONTAINS, + + LBRACE, + PLUS, + GREATER, + COMMA, + TILDE, + + STRING, + INVALID, + + IDENT, + + HASH, + + ATKEYWORD_SYM, + + EXCLAMATION_SYM, + + LENGTH, + + PERCENTAGE, + NUMBER, + + FUNCTION, + + COLON, + SEMICOLON, + RBRACE, + SLASH, + MINUS, + DOT, + STAR, + LBRACKET, + RBRACKET, + EQUAL, + LPAREN, + RPAREN, + OR +}; + +struct Symbol +{ + inline Symbol() : token(NONE), start(0), len(-1) {} + TokenType token; + QString text; + int start, len; + Q_GUI_EXPORT QString lexem() const; +}; +QT_CSS_DECLARE_TYPEINFO(Symbol, Q_RELOCATABLE_TYPE) + +class Q_GUI_EXPORT Scanner +{ +public: + static QString preprocess(const QString &input, bool *hasEscapeSequences = nullptr); + static void scan(const QString &preprocessedInput, QList *symbols); +}; + +class Q_GUI_EXPORT Parser +{ +public: + Parser(); + explicit Parser(const QString &css, bool file = false); + + void init(const QString &css, bool file = false); + bool parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity = Qt::CaseSensitive); + Symbol errorSymbol(); + + bool parseImport(ImportRule *importRule); + bool parseMedia(MediaRule *mediaRule); + bool parseMedium(QStringList *media); + bool parsePage(PageRule *pageRule); + bool parsePseudoPage(QString *selector); + bool parseNextOperator(Value *value); + bool parseCombinator(BasicSelector::Relation *relation); + bool parseProperty(Declaration *decl); + bool parseRuleset(StyleRule *styleRule); + bool parseSelector(Selector *sel); + bool parseSimpleSelector(BasicSelector *basicSel); + bool parseClass(QString *name); + bool parseElementName(QString *name); + bool parseAttrib(AttributeSelector *attr); + bool parsePseudo(Pseudo *pseudo); + bool parseNextDeclaration(Declaration *declaration); + bool parsePrio(Declaration *declaration); + bool parseExpr(QList *values); + bool parseTerm(Value *value); + bool parseFunction(QString *name, QString *args); + bool parseHexColor(QColor *col); + bool testAndParseUri(QString *uri); + + inline bool testRuleset() { return testSelector(); } + inline bool testSelector() { return testSimpleSelector(); } + inline bool parseNextSelector(Selector *sel) { if (!testSelector()) return recordError(); return parseSelector(sel); } + bool testSimpleSelector(); + inline bool parseNextSimpleSelector(BasicSelector *basicSel) { if (!testSimpleSelector()) return recordError(); return parseSimpleSelector(basicSel); } + inline bool testElementName() { return test(IDENT) || test(STAR); } + inline bool testClass() { return test(DOT); } + inline bool testAttrib() { return test(LBRACKET); } + inline bool testPseudo() { return test(COLON); } + inline bool testMedium() { return test(IDENT); } + inline bool parseNextMedium(QStringList *media) { if (!testMedium()) return recordError(); return parseMedium(media); } + inline bool testPseudoPage() { return test(COLON); } + inline bool testImport() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1StringView("import")); } + inline bool testMedia() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1StringView("media")); } + inline bool testPage() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1StringView("page")); } + inline bool testCombinator() { return test(PLUS) || test(GREATER) || test(TILDE) || test(S); } + inline bool testProperty() { return test(IDENT); } + bool testTerm(); + inline bool testExpr() { return testTerm(); } + inline bool parseNextExpr(QList *values) + { + if (!testExpr()) + return recordError(); + return parseExpr(values); + } + bool testPrio(); + inline bool testHexColor() { return test(HASH); } + inline bool testFunction() { return test(FUNCTION); } + inline bool parseNextFunction(QString *name, QString *args) { if (!testFunction()) return recordError(); return parseFunction(name, args); } + + inline bool lookupElementName() const { return lookup() == IDENT || lookup() == STAR; } + + inline void skipSpace() { while (test(S)) {}; } + + inline bool hasNext() const { return index < symbols.size(); } + inline TokenType next() { return symbols.at(index++).token; } + bool next(TokenType t); + bool test(TokenType t); + inline void prev() { index--; } + inline const Symbol &symbol() const { return symbols.at(index - 1); } + inline QString lexem() const { return symbol().lexem(); } + QString unquotedLexem() const; + QString lexemUntil(TokenType t); + bool until(TokenType target, TokenType target2 = NONE); + inline TokenType lookup() const { + return (index - 1) < symbols.size() ? symbols.at(index - 1).token : NONE; + } + + bool testTokenAndEndsWith(TokenType t, QLatin1StringView str); + + inline bool recordError() { errorIndex = index; return false; } + + QList symbols; + int index; + int errorIndex; + bool hasEscapeSequences; + QString sourcePath; +}; + +struct Q_GUI_EXPORT ValueExtractor +{ + ValueExtractor(const QList &declarations, const QPalette & = QPalette()); + + bool extractFont(QFont *font, int *fontSizeAdjustment); + bool extractBackground(QBrush *, QString *, Repeat *, Qt::Alignment *, QCss::Origin *, QCss::Attachment *, + QCss::Origin *); + bool extractGeometry(int *w, int *h, int *minw, int *minh, int *maxw, int *maxh); + bool extractPosition(int *l, int *t, int *r, int *b, QCss::Origin *, Qt::Alignment *, + QCss::PositionMode *, Qt::Alignment *); + bool extractBox(int *margins, int *paddings, int *spacing = nullptr); + bool extractBorder(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii); + bool extractOutline(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets); + bool extractPalette(QBrush *foreground, QBrush *selectedForeground, QBrush *selectedBackground, + QBrush *alternateBackground, QBrush *placeHolderTextForeground, + QBrush *accent); + int extractStyleFeatures(); + bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size); + bool extractIcon(QIcon *icon, QSize *size); + + void lengthValues(const Declaration &decl, int *m); + QTextLength textLength(const Declaration &decl); + +private: + void extractFont(); + void borderValue(const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color); + LengthData lengthValue(const Value& v); + int lengthValue(const Declaration &decl); + QSize sizeValue(const Declaration &decl); + void sizeValues(const Declaration &decl, QSize *radii); + + QList declarations; + QFont f; + int adjustment; + int fontExtracted; + QPalette pal; +}; + +} // namespace QCss + +QT_END_NAMESPACE + +QT_DECL_METATYPE_EXTERN_TAGGED(QCss::BackgroundData, QCss__BackgroundData, Q_GUI_EXPORT) +QT_DECL_METATYPE_EXTERN_TAGGED(QCss::LengthData, QCss__LengthData, Q_GUI_EXPORT) +QT_DECL_METATYPE_EXTERN_TAGGED(QCss::BorderData, QCss__BorderData, Q_GUI_EXPORT) + +#undef QT_CSS_DECLARE_TYPEINFO + +#endif // QT_NO_CSSPARSER + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcssutil_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcssutil_p.h new file mode 100644 index 0000000000000000000000000000000000000000..634c48e4e0c35b18a7fc188eb4f1c287f52f897a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcssutil_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCSSUTIL_P_H +#define QCSSUTIL_P_H + +#include "QtCore/qglobal.h" + +#ifndef QT_NO_CSSPARSER + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qcssparser_p.h" +#include "QtCore/qsize.h" + +QT_BEGIN_NAMESPACE + +class QPainter; + +extern void qDrawEdge(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, qreal dw1, qreal dw2, + QCss::Edge edge, QCss::BorderStyle style, QBrush c); + +extern void qDrawRoundedCorners(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, + const QSizeF& r1, const QSizeF& r2, + QCss::Edge edge, QCss::BorderStyle s, QBrush c); + +extern void Q_GUI_EXPORT qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles, + const int *borders, const QBrush *colors, const QSize *radii); + +extern void Q_GUI_EXPORT qNormalizeRadii(const QRect &br, const QSize *radii, + QSize *tlr, QSize *trr, QSize *blr, QSize *brr); + +QT_END_NAMESPACE + +#endif //QT_NO_CSSPARSER + +#endif // QCSSUTIL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcursor_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcursor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1ad419fc9ac2677b7b40a8e7e29600ea7a754ab7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qcursor_p.h @@ -0,0 +1,51 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCURSOR_P_H +#define QCURSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtCore/qatomic.h" +#include "QtCore/qnamespace.h" +#include "QtGui/qpixmap.h" + + +QT_BEGIN_NAMESPACE + + +class QBitmap; +class QCursorData { +public: + QCursorData(Qt::CursorShape s = Qt::ArrowCursor); + ~QCursorData(); + + static void initialize(); + static void cleanup(); + + QAtomicInt ref; + Qt::CursorShape cshape; + QBitmap *bm, *bmm; + QPixmap pixmap; + short hx, hy; + static bool initialized; + void update(); + static QCursorData *setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY, + qreal devicePixelRatio); +}; + +extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp + +QT_END_NAMESPACE + +#endif // QCURSOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdatabuffer_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdatabuffer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9c3b983db210e366cc1f42a2a63823ccbdc48a13 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdatabuffer_p.h @@ -0,0 +1,121 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDATABUFFER_P_H +#define QDATABUFFER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtCore/qbytearray.h" + +#include + +QT_BEGIN_NAMESPACE + +template class QDataBuffer +{ + Q_DISABLE_COPY_MOVE(QDataBuffer) +public: + explicit QDataBuffer(qsizetype res) + { + capacity = res; + if (res) { + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") + buffer = (Type*) malloc(capacity * sizeof(Type)); + QT_WARNING_POP + Q_CHECK_PTR(buffer); + } else { + buffer = nullptr; + } + siz = 0; + } + + ~QDataBuffer() + { + if (buffer) + free(buffer); + } + + inline void reset() { siz = 0; } + + inline bool isEmpty() const { return siz==0; } + + qsizetype size() const { return siz; } + inline Type *data() const { return buffer; } + + Type &at(qsizetype i) { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } + const Type &at(qsizetype i) const { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } + inline Type &last() { Q_ASSERT(!isEmpty()); return buffer[siz-1]; } + inline const Type &last() const { Q_ASSERT(!isEmpty()); return buffer[siz-1]; } + inline Type &first() { Q_ASSERT(!isEmpty()); return buffer[0]; } + inline const Type &first() const { Q_ASSERT(!isEmpty()); return buffer[0]; } + + inline void add(const Type &t) { + reserve(siz + 1); + buffer[siz] = t; + ++siz; + } + + inline void pop_back() { + Q_ASSERT(siz > 0); + --siz; + } + + void resize(qsizetype size) { + reserve(size); + siz = size; + } + + void reserve(qsizetype size) { + if (size > capacity) { + if (capacity == 0) + capacity = 1; + while (capacity < size) + capacity *= 2; + buffer = (Type*) realloc(static_cast(buffer), capacity * sizeof(Type)); + Q_CHECK_PTR(buffer); + } + } + + void shrink(qsizetype size) { + Q_ASSERT(capacity >= size); + capacity = size; + if (size) { + buffer = (Type*) realloc(static_cast(buffer), capacity * sizeof(Type)); + Q_CHECK_PTR(buffer); + siz = std::min(siz, size); + } else { + free(buffer); + buffer = nullptr; + siz = 0; + } + } + + inline void swap(QDataBuffer &other) { + qSwap(capacity, other.capacity); + qSwap(siz, other.siz); + qSwap(buffer, other.buffer); + } + + inline QDataBuffer &operator<<(const Type &t) { add(t); return *this; } + +private: + qsizetype capacity; + qsizetype siz; + Type *buffer; +}; + +QT_END_NAMESPACE + +#endif // QDATABUFFER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdistancefield_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdistancefield_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1077446776bb50ad115bc60187d31358a70a55f5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdistancefield_p.h @@ -0,0 +1,96 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDISTANCEFIELD_H +#define QDISTANCEFIELD_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(const QRawFont &f); +bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(QFontEngine *fontEngine); + +int Q_GUI_EXPORT QT_DISTANCEFIELD_BASEFONTSIZE(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_TILESIZE(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_SCALE(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_RADIUS(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_HIGHGLYPHCOUNT(); + +class Q_GUI_EXPORT QDistanceFieldData : public QSharedData +{ +public: + QDistanceFieldData() : glyph(0), width(0), height(0), nbytes(0), data(nullptr) {} + QDistanceFieldData(const QDistanceFieldData &other); + ~QDistanceFieldData(); + + static QDistanceFieldData *create(const QSize &size); + static QDistanceFieldData *create(const QPainterPath &path, bool doubleResolution); + static QDistanceFieldData *create(QSize size, const QPainterPath &path, bool doubleResolution); + + glyph_t glyph; + int width; + int height; + int nbytes; + uchar *data; +}; + +class Q_GUI_EXPORT QDistanceField +{ +public: + QDistanceField(); + QDistanceField(int width, int height); + QDistanceField(const QRawFont &font, glyph_t glyph, bool doubleResolution = false); + QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false); + QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution = false); + QDistanceField(QSize size, const QPainterPath &path, glyph_t glyph, bool doubleResolution = false); + + bool isNull() const; + + glyph_t glyph() const; + void setGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution = false); + void setGlyph(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false); + + int width() const; + int height() const; + + QDistanceField copy(const QRect &rect = QRect()) const; + inline QDistanceField copy(int x, int y, int w, int h) const + { return copy(QRect(x, y, w, h)); } + + uchar *bits(); + const uchar *bits() const; + const uchar *constBits() const; + + uchar *scanLine(int); + const uchar *scanLine(int) const; + const uchar *constScanLine(int) const; + + QImage toImage(QImage::Format format = QImage::Format_ARGB32_Premultiplied) const; + +private: + QDistanceField(QDistanceFieldData *data); + QSharedDataPointer d; + + friend class QDistanceFieldData; +}; + +QT_END_NAMESPACE + +#endif // QDISTANCEFIELD_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdnd_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdnd_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0808c606621ec10dbbd5eb8a874d2b778558f61e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdnd_p.h @@ -0,0 +1,84 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDND_P_H +#define QDND_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtCore/qobject.h" +#include "QtCore/qmap.h" +#include "QtCore/qmimedata.h" +#include "QtGui/qdrag.h" +#include "QtGui/qpixmap.h" +#include "QtGui/qcursor.h" +#include "QtGui/qwindow.h" +#include "QtCore/qpoint.h" +#include "private/qobject_p.h" +#include "QtGui/qbackingstore.h" + +#include + +QT_REQUIRE_CONFIG(draganddrop); + +QT_BEGIN_NAMESPACE + +class QPlatformDrag; + +class QDragPrivate : public QObjectPrivate +{ +public: + QDragPrivate() + : source(nullptr) + , target(nullptr) + , data(nullptr) + { } + QObject *source; + QObject *target; + QMimeData *data; + QPixmap pixmap; + QPoint hotspot; + Qt::DropAction executed_action; + Qt::DropActions supported_actions; + Qt::DropAction default_action; + QMap customCursors; +}; + +class Q_GUI_EXPORT QDragManager : public QObject { + Q_OBJECT + +public: + QDragManager(); + ~QDragManager(); + static QDragManager *self(); + + Qt::DropAction drag(QDrag *); + + void setCurrentTarget(QObject *target, bool dropped = false); + QObject *currentTarget() const; + + QPointer object() const { return m_object; } + QObject *source() const; + +private: + QObject *m_currentDropTarget; + QPlatformDrag *m_platformDrag; + QPointer m_object; + + static QDragManager *m_instance; + Q_DISABLE_COPY_MOVE(QDragManager) +}; + +QT_END_NAMESPACE + +#endif // QDND_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawhelper_neon_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawhelper_neon_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6237852febc1711282f8525a1f86d31de3a3f935 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawhelper_neon_p.h @@ -0,0 +1,111 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDRAWHELPER_NEON_P_H +#define QDRAWHELPER_NEON_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +#ifdef __ARM_NEON__ + +void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + +void qt_blend_rgb32_on_rgb32_neon(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + +void qt_blend_argb32_on_rgb16_neon(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + +void qt_blend_argb32_on_argb32_scanline_neon(uint *dest, + const uint *src, + int length, + uint const_alpha); + +void qt_blend_rgb16_on_argb32_neon(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + +void qt_blend_rgb16_on_rgb16_neon(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + +void qt_alphamapblit_quint16_neon(QRasterBuffer *rasterBuffer, + int x, int y, const QRgba64 &color, + const uchar *bitmap, + int mapWidth, int mapHeight, int mapStride, + const QClipData *clip, bool /*useGammaCorrection*/); + +void qt_scale_image_argb32_on_rgb16_neon(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, int srch, + const QRectF &targetRect, + const QRectF &sourceRect, + const QRect &clip, + int const_alpha); + +void qt_scale_image_rgb16_on_rgb16_neon(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, int srch, + const QRectF &targetRect, + const QRectF &sourceRect, + const QRect &clip, + int const_alpha); + +void qt_transform_image_argb32_on_rgb16_neon(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + const QRectF &targetRect, + const QRectF &sourceRect, + const QRect &clip, + const QTransform &targetRectTransform, + int const_alpha); + +void qt_transform_image_rgb16_on_rgb16_neon(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + const QRectF &targetRect, + const QRectF &sourceRect, + const QRect &clip, + const QTransform &targetRectTransform, + int const_alpha); + +void qt_memfill32_neon(quint32 *dest, quint32 value, qsizetype count); +void qt_memrotate90_16_neon(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl); +void qt_memrotate270_16_neon(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl); + +uint * QT_FASTCALL qt_destFetchRGB16_neon(uint *buffer, + QRasterBuffer *rasterBuffer, + int x, int y, int length); + +void QT_FASTCALL qt_destStoreRGB16_neon(QRasterBuffer *rasterBuffer, + int x, int y, const uint *buffer, int length); + +void QT_FASTCALL comp_func_solid_SourceOver_neon(uint *destPixels, int length, uint color, uint const_alpha); +void QT_FASTCALL comp_func_Plus_neon(uint *dst, const uint *src, int length, uint const_alpha); + +const uint * QT_FASTCALL qt_fetchUntransformed_888_neon(uint *buffer, const Operator *, const QSpanData *data, + int y, int x, int length); + +#endif // __ARM_NEON__ + +QT_END_NAMESPACE + +#endif // QDRAWHELPER_NEON_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawhelper_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawhelper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4b25bef9f59494e0edf74be737785c5ffaddc5be --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawhelper_p.h @@ -0,0 +1,1046 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDRAWHELPER_P_H +#define QDRAWHELPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtCore/qmath.h" +#include "QtGui/qcolor.h" +#include "QtGui/qpainter.h" +#include "QtGui/qimage.h" +#include "QtGui/qrgba64.h" +#ifndef QT_FT_BEGIN_HEADER +#define QT_FT_BEGIN_HEADER +#define QT_FT_END_HEADER +#endif +#include "private/qpixellayout_p.h" +#include "private/qrasterdefs_p.h" +#include + +#include + +QT_BEGIN_NAMESPACE + +#if defined(Q_CC_GNU) +# define Q_DECL_RESTRICT __restrict__ +# if defined(Q_PROCESSOR_X86_32) && defined(Q_CC_GNU) && !defined(Q_CC_CLANG) +# define Q_DECL_VECTORCALL __attribute__((sseregparm,regparm(3))) +# else +# define Q_DECL_VECTORCALL +# endif +#elif defined(Q_CC_MSVC) +# define Q_DECL_RESTRICT __restrict +# define Q_DECL_VECTORCALL __vectorcall +#else +# define Q_DECL_RESTRICT +# define Q_DECL_VECTORCALL +#endif + +static const uint AMASK = 0xff000000; +static const uint RMASK = 0x00ff0000; +static const uint GMASK = 0x0000ff00; +static const uint BMASK = 0x000000ff; + +struct QSolidData; +struct QTextureData; +struct QGradientData; +struct QLinearGradientData; +struct QRadialGradientData; +struct QConicalGradientData; +struct QSpanData; +class QGradient; +class QRasterBuffer; +class QClipData; +class QRasterPaintEngineState; + +template class QRgbaFloat; +typedef QRgbaFloat QRgbaFloat32; + +typedef QT_FT_SpanFunc ProcessSpans; +typedef void (*BitmapBlitFunc)(QRasterBuffer *rasterBuffer, + int x, int y, const QRgba64 &color, + const uchar *bitmap, + int mapWidth, int mapHeight, int mapStride); + +typedef void (*AlphamapBlitFunc)(QRasterBuffer *rasterBuffer, + int x, int y, const QRgba64 &color, + const uchar *bitmap, + int mapWidth, int mapHeight, int mapStride, + const QClipData *clip, bool useGammaCorrection); + +typedef void (*AlphaRGBBlitFunc)(QRasterBuffer *rasterBuffer, + int x, int y, const QRgba64 &color, + const uint *rgbmask, + int mapWidth, int mapHeight, int mapStride, + const QClipData *clip, bool useGammaCorrection); + +typedef void (*RectFillFunc)(QRasterBuffer *rasterBuffer, + int x, int y, int width, int height, + const QRgba64 &color); + +typedef void (*SrcOverBlendFunc)(uchar *destPixels, int dbpl, + const uchar *src, int spbl, + int w, int h, + int const_alpha); + +typedef void (*SrcOverScaleFunc)(uchar *destPixels, int dbpl, + const uchar *src, int spbl, int srch, + const QRectF &targetRect, + const QRectF &sourceRect, + const QRect &clipRect, + int const_alpha); + +typedef void (*SrcOverTransformFunc)(uchar *destPixels, int dbpl, + const uchar *src, int spbl, + const QRectF &targetRect, + const QRectF &sourceRect, + const QRect &clipRect, + const QTransform &targetRectTransform, + int const_alpha); + +struct DrawHelper { + ProcessSpans blendColor; + BitmapBlitFunc bitmapBlit; + AlphamapBlitFunc alphamapBlit; + AlphaRGBBlitFunc alphaRGBBlit; + RectFillFunc fillRect; +}; + +extern SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats]; +extern SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats]; +extern SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats]; + +extern DrawHelper qDrawHelper[QImage::NImageFormats]; + +struct quint24 { + quint24() = default; + quint24(uint value) + { + data[0] = uchar(value >> 16); + data[1] = uchar(value >> 8); + data[2] = uchar(value); + } + operator uint() const + { + return data[2] | (data[1] << 8) | (data[0] << 16); + } + + uchar data[3]; +}; + +void qBlendGradient(int count, const QT_FT_Span *spans, void *userData); +void qBlendTexture(int count, const QT_FT_Span *spans, void *userData); +#ifdef Q_PROCESSOR_X86 +extern void (*qt_memfill64)(quint64 *dest, quint64 value, qsizetype count); +extern void (*qt_memfill32)(quint32 *dest, quint32 value, qsizetype count); +#else +extern void qt_memfill64(quint64 *dest, quint64 value, qsizetype count); +extern void qt_memfill32(quint32 *dest, quint32 value, qsizetype count); +#endif +extern void qt_memfill24(quint24 *dest, quint24 value, qsizetype count); +extern void qt_memfill16(quint16 *dest, quint16 value, qsizetype count); + +typedef void (QT_FASTCALL *CompositionFunction)(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha); +typedef void (QT_FASTCALL *CompositionFunction64)(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha); +typedef void (QT_FASTCALL *CompositionFunctionFP)(QRgbaFloat32 *Q_DECL_RESTRICT dest, const QRgbaFloat32 *Q_DECL_RESTRICT src, int length, uint const_alpha); +typedef void (QT_FASTCALL *CompositionFunctionSolid)(uint *dest, int length, uint color, uint const_alpha); +typedef void (QT_FASTCALL *CompositionFunctionSolid64)(QRgba64 *dest, int length, QRgba64 color, uint const_alpha); +typedef void (QT_FASTCALL *CompositionFunctionSolidFP)(QRgbaFloat32 *dest, int length, QRgbaFloat32 color, uint const_alpha); + +struct LinearGradientValues +{ + qreal dx; + qreal dy; + qreal l; + qreal off; +}; + +struct RadialGradientValues +{ + qreal dx; + qreal dy; + qreal dr; + qreal sqrfr; + qreal a; + bool extended; +}; + +struct Operator; +typedef uint* (QT_FASTCALL *DestFetchProc)(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length); +typedef QRgba64* (QT_FASTCALL *DestFetchProc64)(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length); +typedef QRgbaFloat32* (QT_FASTCALL *DestFetchProcFP)(QRgbaFloat32 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length); +typedef void (QT_FASTCALL *DestStoreProc)(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length); +typedef void (QT_FASTCALL *DestStoreProc64)(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length); +typedef void (QT_FASTCALL *DestStoreProcFP)(QRasterBuffer *rasterBuffer, int x, int y, const QRgbaFloat32 *buffer, int length); +typedef const uint* (QT_FASTCALL *SourceFetchProc)(uint *buffer, const Operator *o, const QSpanData *data, int y, int x, int length); +typedef const QRgba64* (QT_FASTCALL *SourceFetchProc64)(QRgba64 *buffer, const Operator *o, const QSpanData *data, int y, int x, int length); +typedef const QRgbaFloat32* (QT_FASTCALL *SourceFetchProcFP)(QRgbaFloat32 *buffer, const Operator *o, const QSpanData *data, int y, int x, int length); + +struct Operator +{ + QPainter::CompositionMode mode; + DestFetchProc destFetch; + DestStoreProc destStore; + SourceFetchProc srcFetch; + CompositionFunctionSolid funcSolid; + CompositionFunction func; + + DestFetchProc64 destFetch64; + DestStoreProc64 destStore64; + SourceFetchProc64 srcFetch64; + CompositionFunctionSolid64 funcSolid64; + CompositionFunction64 func64; + + DestFetchProcFP destFetchFP; + DestStoreProcFP destStoreFP; + SourceFetchProcFP srcFetchFP; + CompositionFunctionSolidFP funcSolidFP; + CompositionFunctionFP funcFP; + + union { + LinearGradientValues linear; + RadialGradientValues radial; + }; +}; + +class QRasterPaintEngine; + +struct QLinearGradientData +{ + struct { + qreal x; + qreal y; + } origin; + struct { + qreal x; + qreal y; + } end; +}; + +struct QRadialGradientData +{ + struct { + qreal x; + qreal y; + qreal radius; + } center; + struct { + qreal x; + qreal y; + qreal radius; + } focal; +}; + +struct QConicalGradientData +{ + struct { + qreal x; + qreal y; + } center; + qreal angle; +}; + +struct QGradientData +{ + QGradient::Spread spread; + + union { + QLinearGradientData linear; + QRadialGradientData radial; + QConicalGradientData conical; + }; + +#define GRADIENT_STOPTABLE_SIZE 1024 +#define GRADIENT_STOPTABLE_SIZE_SHIFT 10 + +#if QT_CONFIG(raster_64bit) || QT_CONFIG(raster_fp) + const QRgba64 *colorTable64; //[GRADIENT_STOPTABLE_SIZE]; +#endif + const QRgb *colorTable32; //[GRADIENT_STOPTABLE_SIZE]; + + uint alphaColor : 1; +}; + +struct QTextureData +{ + const uchar *imageData; + const uchar *scanLine(int y) const { return imageData + y*bytesPerLine; } + + int width; + int height; + // clip rect + int x1; + int y1; + int x2; + int y2; + qsizetype bytesPerLine; + QImage::Format format; + const QList *colorTable; + bool hasAlpha; + enum Type { + Plain, + Tiled, + Pattern + }; + Type type; + int const_alpha; +}; + +struct QSpanData +{ + QSpanData() : tempImage(nullptr) {} + ~QSpanData() { delete tempImage; } + + QRasterBuffer *rasterBuffer; + ProcessSpans blend; + ProcessSpans unclipped_blend; + BitmapBlitFunc bitmapBlit; + AlphamapBlitFunc alphamapBlit; + AlphaRGBBlitFunc alphaRGBBlit; + RectFillFunc fillRect; + qreal m11, m12, m13, m21, m22, m23, m33, dx, dy; // inverse xform matrix + const QClipData *clip; + enum Type { + None, + Solid, + LinearGradient, + RadialGradient, + ConicalGradient, + Texture + } type : 8; + signed int txop : 8; + uint fast_matrix : 1; + bool bilinear; + QImage *tempImage; + QColor solidColor; + union { + QGradientData gradient; + QTextureData texture; + }; + std::shared_ptr cachedGradient; + + + void init(QRasterBuffer *rb, const QRasterPaintEngine *pe); + void setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode, bool isCosmetic); + void setupMatrix(const QTransform &matrix, int bilinear); + void initTexture(const QImage *image, int alpha, QTextureData::Type = QTextureData::Plain, const QRect &sourceRect = QRect()); + void adjustSpanMethods(); +}; + +static inline uint qt_gradient_clamp(const QGradientData *data, int ipos) +{ + if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) { + if (data->spread == QGradient::RepeatSpread) { + ipos = ipos % GRADIENT_STOPTABLE_SIZE; + ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos; + } else if (data->spread == QGradient::ReflectSpread) { + const int limit = GRADIENT_STOPTABLE_SIZE * 2; + ipos = ipos % limit; + ipos = ipos < 0 ? limit + ipos : ipos; + ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - 1 - ipos : ipos; + } else { + if (ipos < 0) + ipos = 0; + else if (ipos >= GRADIENT_STOPTABLE_SIZE) + ipos = GRADIENT_STOPTABLE_SIZE-1; + } + } + + Q_ASSERT(ipos >= 0); + Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE); + + return ipos; +} + +static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos) +{ + int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5)); + return data->colorTable32[qt_gradient_clamp(data, ipos)]; +} + +#if QT_CONFIG(raster_64bit) +static inline const QRgba64& qt_gradient_pixel64(const QGradientData *data, qreal pos) +{ + int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5)); + return data->colorTable64[qt_gradient_clamp(data, ipos)]; +} +#endif + +static inline qreal qRadialDeterminant(qreal a, qreal b, qreal c) +{ + return (b * b) - (4 * a * c); +} + +template static +const BlendType * QT_FASTCALL qt_fetch_radial_gradient_template(BlendType *buffer, const Operator *op, + const QSpanData *data, int y, int x, int length) +{ + // avoid division by zero + if (qFuzzyIsNull(op->radial.a)) { + RadialFetchFunc::memfill(buffer, RadialFetchFunc::null(), length); + return buffer; + } + + const BlendType *b = buffer; + qreal rx = data->m21 * (y + qreal(0.5)) + + data->dx + data->m11 * (x + qreal(0.5)); + qreal ry = data->m22 * (y + qreal(0.5)) + + data->dy + data->m12 * (x + qreal(0.5)); + bool affine = !data->m13 && !data->m23; + + BlendType *end = buffer + length; + qreal inv_a = 1 / qreal(2 * op->radial.a); + + if (affine) { + rx -= data->gradient.radial.focal.x; + ry -= data->gradient.radial.focal.y; + + const qreal delta_rx = data->m11; + const qreal delta_ry = data->m12; + + qreal b = 2*(op->radial.dr*data->gradient.radial.focal.radius + rx * op->radial.dx + ry * op->radial.dy); + qreal delta_b = 2*(delta_rx * op->radial.dx + delta_ry * op->radial.dy); + const qreal b_delta_b = 2 * b * delta_b; + const qreal delta_b_delta_b = 2 * delta_b * delta_b; + + const qreal bb = b * b; + const qreal delta_bb = delta_b * delta_b; + + b *= inv_a; + delta_b *= inv_a; + + const qreal rxrxryry = rx * rx + ry * ry; + const qreal delta_rxrxryry = delta_rx * delta_rx + delta_ry * delta_ry; + const qreal rx_plus_ry = 2*(rx * delta_rx + ry * delta_ry); + const qreal delta_rx_plus_ry = 2 * delta_rxrxryry; + + inv_a *= inv_a; + + qreal det = (bb - 4 * op->radial.a * (op->radial.sqrfr - rxrxryry)) * inv_a; + qreal delta_det = (b_delta_b + delta_bb + 4 * op->radial.a * (rx_plus_ry + delta_rxrxryry)) * inv_a; + const qreal delta_delta_det = (delta_b_delta_b + 4 * op->radial.a * delta_rx_plus_ry) * inv_a; + + RadialFetchFunc::fetch(buffer, end, op, data, det, delta_det, delta_delta_det, b, delta_b); + } else { + qreal rw = data->m23 * (y + qreal(0.5)) + + data->m33 + data->m13 * (x + qreal(0.5)); + + while (buffer < end) { + if (rw == 0) { + *buffer = RadialFetchFunc::null(); + } else { + qreal invRw = 1 / rw; + qreal gx = rx * invRw - data->gradient.radial.focal.x; + qreal gy = ry * invRw - data->gradient.radial.focal.y; + qreal b = 2*(op->radial.dr*data->gradient.radial.focal.radius + gx*op->radial.dx + gy*op->radial.dy); + qreal det = qRadialDeterminant(op->radial.a, b, op->radial.sqrfr - (gx*gx + gy*gy)); + + BlendType result = RadialFetchFunc::null(); + if (det >= 0) { + qreal detSqrt = qSqrt(det); + + qreal s0 = (-b - detSqrt) * inv_a; + qreal s1 = (-b + detSqrt) * inv_a; + + qreal s = qMax(s0, s1); + + if (data->gradient.radial.focal.radius + op->radial.dr * s >= 0) + result = RadialFetchFunc::fetchSingle(data->gradient, s); + } + + *buffer = result; + } + + rx += data->m11; + ry += data->m12; + rw += data->m13; + + ++buffer; + } + } + + return b; +} + +template +class QRadialFetchSimd +{ +public: + static uint null() { return 0; } + static uint fetchSingle(const QGradientData& gradient, qreal v) + { + return qt_gradient_pixel(&gradient, v); + } + static void memfill(uint *buffer, uint fill, int length) + { + qt_memfill32(buffer, fill, length); + } + static void fetch(uint *buffer, uint *end, const Operator *op, const QSpanData *data, qreal det, + qreal delta_det, qreal delta_delta_det, qreal b, qreal delta_b) + { + typename Simd::Vect_buffer_f det_vec; + typename Simd::Vect_buffer_f delta_det4_vec; + typename Simd::Vect_buffer_f b_vec; + + for (int i = 0; i < 4; ++i) { + det_vec.f[i] = det; + delta_det4_vec.f[i] = 4 * delta_det; + b_vec.f[i] = b; + + det += delta_det; + delta_det += delta_delta_det; + b += delta_b; + } + + const typename Simd::Float32x4 v_delta_delta_det16 = Simd::v_dup(16 * delta_delta_det); + const typename Simd::Float32x4 v_delta_delta_det6 = Simd::v_dup(6 * delta_delta_det); + const typename Simd::Float32x4 v_delta_b4 = Simd::v_dup(4 * delta_b); + + const typename Simd::Float32x4 v_r0 = Simd::v_dup(data->gradient.radial.focal.radius); + const typename Simd::Float32x4 v_dr = Simd::v_dup(op->radial.dr); + +#if defined(__ARM_NEON__) + // NEON doesn't have SIMD sqrt, but uses rsqrt instead that can't be taken of 0. + const typename Simd::Float32x4 v_min = Simd::v_dup(std::numeric_limits::epsilon()); +#else + const typename Simd::Float32x4 v_min = Simd::v_dup(0.0f); +#endif + const typename Simd::Float32x4 v_max = Simd::v_dup(float(GRADIENT_STOPTABLE_SIZE-1)); + const typename Simd::Float32x4 v_half = Simd::v_dup(0.5f); + + const typename Simd::Int32x4 v_repeat_mask = Simd::v_dup(~(uint(0xffffff) << GRADIENT_STOPTABLE_SIZE_SHIFT)); + const typename Simd::Int32x4 v_reflect_mask = Simd::v_dup(~(uint(0xffffff) << (GRADIENT_STOPTABLE_SIZE_SHIFT+1))); + + const typename Simd::Int32x4 v_reflect_limit = Simd::v_dup(2 * GRADIENT_STOPTABLE_SIZE - 1); + + const int extended_mask = op->radial.extended ? 0x0 : ~0x0; + +#define FETCH_RADIAL_LOOP_PROLOGUE \ + while (buffer < end) { \ + typename Simd::Vect_buffer_i v_buffer_mask; \ + v_buffer_mask.v = Simd::v_greaterOrEqual(det_vec.v, v_min); \ + const typename Simd::Float32x4 v_index_local = Simd::v_sub(Simd::v_sqrt(Simd::v_max(v_min, det_vec.v)), b_vec.v); \ + const typename Simd::Float32x4 v_index = Simd::v_add(Simd::v_mul(v_index_local, v_max), v_half); \ + v_buffer_mask.v = Simd::v_and(v_buffer_mask.v, Simd::v_greaterOrEqual(Simd::v_add(v_r0, Simd::v_mul(v_dr, v_index_local)), v_min)); \ + typename Simd::Vect_buffer_i index_vec; +#define FETCH_RADIAL_LOOP_CLAMP_REPEAT \ + index_vec.v = Simd::v_and(v_repeat_mask, Simd::v_toInt(v_index)); +#define FETCH_RADIAL_LOOP_CLAMP_REFLECT \ + const typename Simd::Int32x4 v_index_i = Simd::v_and(v_reflect_mask, Simd::v_toInt(v_index)); \ + const typename Simd::Int32x4 v_index_i_inv = Simd::v_sub(v_reflect_limit, v_index_i); \ + index_vec.v = Simd::v_min_16(v_index_i, v_index_i_inv); +#define FETCH_RADIAL_LOOP_CLAMP_PAD \ + index_vec.v = Simd::v_toInt(Simd::v_min(v_max, Simd::v_max(v_min, v_index))); +#define FETCH_RADIAL_LOOP_EPILOGUE \ + det_vec.v = Simd::v_add(Simd::v_add(det_vec.v, delta_det4_vec.v), v_delta_delta_det6); \ + delta_det4_vec.v = Simd::v_add(delta_det4_vec.v, v_delta_delta_det16); \ + b_vec.v = Simd::v_add(b_vec.v, v_delta_b4); \ + for (int i = 0; i < 4; ++i) \ + *buffer++ = (extended_mask | v_buffer_mask.i[i]) & data->gradient.colorTable32[index_vec.i[i]]; \ + } + +#define FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP) \ + FETCH_RADIAL_LOOP_PROLOGUE \ + FETCH_RADIAL_LOOP_CLAMP \ + FETCH_RADIAL_LOOP_EPILOGUE + + switch (data->gradient.spread) { + case QGradient::RepeatSpread: + FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP_REPEAT) + break; + case QGradient::ReflectSpread: + FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP_REFLECT) + break; + case QGradient::PadSpread: + FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP_PAD) + break; + default: + Q_UNREACHABLE(); + } + } +}; + +static inline uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) { + uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; + t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; + t &= 0xff00ff; + + x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; + x = (x + ((x >> 8) & 0xff00ff) + 0x800080); + x &= 0xff00ff00; + x |= t; + return x; +} + +#if Q_PROCESSOR_WORDSIZE == 8 // 64-bit versions + +static inline uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) { + quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a; + t += (((quint64(y)) | ((quint64(y)) << 24)) & 0x00ff00ff00ff00ff) * b; + t >>= 8; + t &= 0x00ff00ff00ff00ff; + return (uint(t)) | (uint(t >> 24)); +} + +static inline uint BYTE_MUL(uint x, uint a) { + quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a; + t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080) >> 8; + t &= 0x00ff00ff00ff00ff; + return (uint(t)) | (uint(t >> 24)); +} + +#else // 32-bit versions + +static inline uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) { + uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; + t >>= 8; + t &= 0xff00ff; + + x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; + x &= 0xff00ff00; + x |= t; + return x; +} + +static inline uint BYTE_MUL(uint x, uint a) { + uint t = (x & 0xff00ff) * a; + t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; + t &= 0xff00ff; + + x = ((x >> 8) & 0xff00ff) * a; + x = (x + ((x >> 8) & 0xff00ff) + 0x800080); + x &= 0xff00ff00; + x |= t; + return x; +} +#endif + +static inline void blend_pixel(quint32 &dst, const quint32 src) +{ + if (src >= 0xff000000) + dst = src; + else if (src != 0) + dst = src + BYTE_MUL(dst, qAlpha(~src)); +} + +static inline void blend_pixel(quint32 &dst, const quint32 src, const int const_alpha) +{ + if (const_alpha == 255) + return blend_pixel(dst, src); + if (src != 0) { + const quint32 s = BYTE_MUL(src, const_alpha); + dst = s + BYTE_MUL(dst, qAlpha(~s)); + } +} + +#if defined(__SSE2__) +static inline uint Q_DECL_VECTORCALL interpolate_4_pixels_sse2(__m128i vt, __m128i vb, uint distx, uint disty) +{ + // First interpolate top and bottom pixels in parallel. + vt = _mm_unpacklo_epi8(vt, _mm_setzero_si128()); + vb = _mm_unpacklo_epi8(vb, _mm_setzero_si128()); + vt = _mm_mullo_epi16(vt, _mm_set1_epi16(256 - disty)); + vb = _mm_mullo_epi16(vb, _mm_set1_epi16(disty)); + __m128i vlr = _mm_add_epi16(vt, vb); + vlr = _mm_srli_epi16(vlr, 8); + // vlr now contains the result of the first two interpolate calls vlr = unpacked((xright << 64) | xleft) + + // Now the last interpolate between left and right.. + const __m128i vidistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(256 - distx), _MM_SHUFFLE(0, 0, 0, 0)); + const __m128i vdistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(distx), _MM_SHUFFLE(0, 0, 0, 0)); + const __m128i vmulx = _mm_unpacklo_epi16(vidistx, vdistx); + vlr = _mm_unpacklo_epi16(vlr, _mm_srli_si128(vlr, 8)); + // vlr now contains the colors of left and right interleaved { la, ra, lr, rr, lg, rg, lb, rb } + vlr = _mm_madd_epi16(vlr, vmulx); // Multiply and horizontal add. + vlr = _mm_srli_epi32(vlr, 8); + vlr = _mm_packs_epi32(vlr, vlr); + vlr = _mm_packus_epi16(vlr, vlr); + return _mm_cvtsi128_si32(vlr); +} + +static inline uint interpolate_4_pixels(uint tl, uint tr, uint bl, uint br, uint distx, uint disty) +{ + __m128i vt = _mm_unpacklo_epi32(_mm_cvtsi32_si128(tl), _mm_cvtsi32_si128(tr)); + __m128i vb = _mm_unpacklo_epi32(_mm_cvtsi32_si128(bl), _mm_cvtsi32_si128(br)); + return interpolate_4_pixels_sse2(vt, vb, distx, disty); +} + +static inline uint interpolate_4_pixels(const uint t[], const uint b[], uint distx, uint disty) +{ + __m128i vt = _mm_loadl_epi64((const __m128i*)t); + __m128i vb = _mm_loadl_epi64((const __m128i*)b); + return interpolate_4_pixels_sse2(vt, vb, distx, disty); +} + +static constexpr inline bool hasFastInterpolate4() { return true; } + +#elif defined(__ARM_NEON__) +static inline uint interpolate_4_pixels_neon(uint32x2_t vt32, uint32x2_t vb32, uint distx, uint disty) +{ + uint16x8_t vt16 = vmovl_u8(vreinterpret_u8_u32(vt32)); + uint16x8_t vb16 = vmovl_u8(vreinterpret_u8_u32(vb32)); + vt16 = vmulq_n_u16(vt16, 256 - disty); + vt16 = vmlaq_n_u16(vt16, vb16, disty); + vt16 = vshrq_n_u16(vt16, 8); + uint16x4_t vl16 = vget_low_u16(vt16); + uint16x4_t vr16 = vget_high_u16(vt16); + vl16 = vmul_n_u16(vl16, 256 - distx); + vl16 = vmla_n_u16(vl16, vr16, distx); + vl16 = vshr_n_u16(vl16, 8); + uint8x8_t vr = vmovn_u16(vcombine_u16(vl16, vl16)); + return vget_lane_u32(vreinterpret_u32_u8(vr), 0); +} + +static inline uint interpolate_4_pixels(uint tl, uint tr, uint bl, uint br, uint distx, uint disty) +{ + uint32x2_t vt32 = vmov_n_u32(tl); + uint32x2_t vb32 = vmov_n_u32(bl); + vt32 = vset_lane_u32(tr, vt32, 1); + vb32 = vset_lane_u32(br, vb32, 1); + return interpolate_4_pixels_neon(vt32, vb32, distx, disty); +} + +static inline uint interpolate_4_pixels(const uint t[], const uint b[], uint distx, uint disty) +{ + uint32x2_t vt32 = vld1_u32(t); + uint32x2_t vb32 = vld1_u32(b); + return interpolate_4_pixels_neon(vt32, vb32, distx, disty); +} + +static constexpr inline bool hasFastInterpolate4() { return true; } + +#else +static inline uint interpolate_4_pixels(uint tl, uint tr, uint bl, uint br, uint distx, uint disty) +{ + uint idistx = 256 - distx; + uint idisty = 256 - disty; + uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); + uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); + return INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); +} + +static inline uint interpolate_4_pixels(const uint t[], const uint b[], uint distx, uint disty) +{ + return interpolate_4_pixels(t[0], t[1], b[0], b[1], distx, disty); +} + +static constexpr inline bool hasFastInterpolate4() { return false; } + +#endif + +static inline QRgba64 multiplyAlpha256(QRgba64 rgba64, uint alpha256) +{ + return QRgba64::fromRgba64((rgba64.red() * alpha256) >> 8, + (rgba64.green() * alpha256) >> 8, + (rgba64.blue() * alpha256) >> 8, + (rgba64.alpha() * alpha256) >> 8); +} +static inline QRgba64 interpolate256(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2) +{ + return QRgba64::fromRgba64(multiplyAlpha256(x, alpha1) + multiplyAlpha256(y, alpha2)); +} + +#ifdef __SSE2__ +static inline QRgba64 interpolate_4_pixels_rgb64(const QRgba64 t[], const QRgba64 b[], uint distx, uint disty) +{ + __m128i vt = _mm_loadu_si128((const __m128i*)t); + if (disty) { + __m128i vb = _mm_loadu_si128((const __m128i*)b); + vt = _mm_mulhi_epu16(vt, _mm_set1_epi16(0x10000 - disty)); + vb = _mm_mulhi_epu16(vb, _mm_set1_epi16(disty)); + vt = _mm_add_epi16(vt, vb); + } + if (distx) { + const __m128i vdistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(distx), _MM_SHUFFLE(0, 0, 0, 0)); + const __m128i vidistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(0x10000 - distx), _MM_SHUFFLE(0, 0, 0, 0)); + vt = _mm_mulhi_epu16(vt, _mm_unpacklo_epi64(vidistx, vdistx)); + vt = _mm_add_epi16(vt, _mm_srli_si128(vt, 8)); + } +#ifdef Q_PROCESSOR_X86_64 + return QRgba64::fromRgba64(_mm_cvtsi128_si64(vt)); +#else + QRgba64 out; + _mm_storel_epi64((__m128i*)&out, vt); + return out; +#endif // Q_PROCESSOR_X86_64 +} +#elif defined(__ARM_NEON__) +static inline QRgba64 interpolate_4_pixels_rgb64(const QRgba64 t[], const QRgba64 b[], uint distx, uint disty) +{ + uint64x1x2_t vt = vld2_u64(reinterpret_cast(t)); + if (disty) { + uint64x1x2_t vb = vld2_u64(reinterpret_cast(b)); + uint32x4_t vt0 = vmull_n_u16(vreinterpret_u16_u64(vt.val[0]), 0x10000 - disty); + uint32x4_t vt1 = vmull_n_u16(vreinterpret_u16_u64(vt.val[1]), 0x10000 - disty); + vt0 = vmlal_n_u16(vt0, vreinterpret_u16_u64(vb.val[0]), disty); + vt1 = vmlal_n_u16(vt1, vreinterpret_u16_u64(vb.val[1]), disty); + vt.val[0] = vreinterpret_u64_u16(vshrn_n_u32(vt0, 16)); + vt.val[1] = vreinterpret_u64_u16(vshrn_n_u32(vt1, 16)); + } + if (distx) { + uint32x4_t vt0 = vmull_n_u16(vreinterpret_u16_u64(vt.val[0]), 0x10000 - distx); + vt0 = vmlal_n_u16(vt0, vreinterpret_u16_u64(vt.val[1]), distx); + vt.val[0] = vreinterpret_u64_u16(vshrn_n_u32(vt0, 16)); + } + QRgba64 out; + vst1_u64(reinterpret_cast(&out), vt.val[0]); + return out; +} +#else +static inline QRgba64 interpolate_4_pixels_rgb64(const QRgba64 t[], const QRgba64 b[], uint distx, uint disty) +{ + const uint dx = distx>>8; + const uint dy = disty>>8; + const uint idx = 256 - dx; + const uint idy = 256 - dy; + QRgba64 xtop = interpolate256(t[0], idx, t[1], dx); + QRgba64 xbot = interpolate256(b[0], idx, b[1], dx); + return interpolate256(xtop, idy, xbot, dy); +} +#endif // __SSE2__ + +#if QT_CONFIG(raster_fp) +static inline QRgbaFloat32 multiplyAlpha_rgba32f(QRgbaFloat32 c, float a) +{ + return QRgbaFloat32 { c.r * a, c.g * a, c.b * a, c.a * a }; +} + +static inline QRgbaFloat32 interpolate_rgba32f(QRgbaFloat32 x, float alpha1, QRgbaFloat32 y, float alpha2) +{ + x = multiplyAlpha_rgba32f(x, alpha1); + y = multiplyAlpha_rgba32f(y, alpha2); + return QRgbaFloat32 { x.r + y.r, x.g + y.g, x.b + y.b, x.a + y.a }; +} +#ifdef __SSE2__ +static inline __m128 Q_DECL_VECTORCALL interpolate_rgba32f(__m128 x, __m128 alpha1, __m128 y, __m128 alpha2) +{ + return _mm_add_ps(_mm_mul_ps(x, alpha1), _mm_mul_ps(y, alpha2)); +} +#endif + +static inline QRgbaFloat32 interpolate_4_pixels_rgba32f(const QRgbaFloat32 t[], const QRgbaFloat32 b[], uint distx, uint disty) +{ + constexpr float f = 1.0f / 65536.0f; + const float dx = distx * f; + const float dy = disty * f; + const float idx = 1.0f - dx; + const float idy = 1.0f - dy; +#ifdef __SSE2__ + const __m128 vtl = _mm_load_ps((const float *)&t[0]); + const __m128 vtr = _mm_load_ps((const float *)&t[1]); + const __m128 vbl = _mm_load_ps((const float *)&b[0]); + const __m128 vbr = _mm_load_ps((const float *)&b[1]); + + const __m128 vdx = _mm_set1_ps(dx); + const __m128 vidx = _mm_set1_ps(idx); + __m128 vt = interpolate_rgba32f(vtl, vidx, vtr, vdx); + __m128 vb = interpolate_rgba32f(vbl, vidx, vbr, vdx); + const __m128 vdy = _mm_set1_ps(dy); + const __m128 vidy = _mm_set1_ps(idy); + vt = interpolate_rgba32f(vt, vidy, vb, vdy); + QRgbaFloat32 res; + _mm_store_ps((float*)&res, vt); + return res; +#else + QRgbaFloat32 xtop = interpolate_rgba32f(t[0], idx, t[1], dx); + QRgbaFloat32 xbot = interpolate_rgba32f(b[0], idx, b[1], dx); + xtop = interpolate_rgba32f(xtop, idy, xbot, dy); + return xtop; +#endif +} +#endif // QT_CONFIG(raster_fp) + +static inline uint BYTE_MUL_RGB16(uint x, uint a) { + a += 1; + uint t = (((x & 0x07e0)*a) >> 8) & 0x07e0; + t |= (((x & 0xf81f)*(a>>2)) >> 6) & 0xf81f; + return t; +} + +static inline uint BYTE_MUL_RGB16_32(uint x, uint a) { + uint t = (((x & 0xf81f07e0) >> 5)*a) & 0xf81f07e0; + t |= (((x & 0x07e0f81f)*a) >> 5) & 0x07e0f81f; + return t; +} + +// qt_div_255 is a fast rounded division by 255 using an approximation that is accurate for all positive 16-bit integers +static constexpr inline int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } +static constexpr inline uint qt_div_257_floor(uint x) { return (x - (x >> 8)) >> 8; } +static constexpr inline uint qt_div_257(uint x) { return qt_div_257_floor(x + 128); } +static constexpr inline uint qt_div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; } + +template inline void qt_memfill_template(T *dest, T color, qsizetype count) +{ + if (!count) + return; + + qsizetype n = (count + 7) / 8; + switch (count & 0x07) + { + case 0: do { *dest++ = color; Q_FALLTHROUGH(); + case 7: *dest++ = color; Q_FALLTHROUGH(); + case 6: *dest++ = color; Q_FALLTHROUGH(); + case 5: *dest++ = color; Q_FALLTHROUGH(); + case 4: *dest++ = color; Q_FALLTHROUGH(); + case 3: *dest++ = color; Q_FALLTHROUGH(); + case 2: *dest++ = color; Q_FALLTHROUGH(); + case 1: *dest++ = color; + } while (--n > 0); + } +} + +template inline void qt_memfill(T *dest, T value, qsizetype count) +{ + qt_memfill_template(dest, value, count); +} + +template<> inline void qt_memfill(quint64 *dest, quint64 color, qsizetype count) +{ + qt_memfill64(dest, color, count); +} + +template<> inline void qt_memfill(quint32 *dest, quint32 color, qsizetype count) +{ + qt_memfill32(dest, color, count); +} + +template<> inline void qt_memfill(quint24 *dest, quint24 color, qsizetype count) +{ + qt_memfill24(dest, color, count); +} + +template<> inline void qt_memfill(quint16 *dest, quint16 color, qsizetype count) +{ + qt_memfill16(dest, color, count); +} + +template<> inline void qt_memfill(quint8 *dest, quint8 color, qsizetype count) +{ + memset(dest, color, count); +} + +template static +inline void qt_rectfill(T *dest, T value, + int x, int y, int width, int height, qsizetype stride) +{ + char *d = reinterpret_cast(dest + x) + y * stride; + if (uint(stride) == (width * sizeof(T))) { + qt_memfill(reinterpret_cast(d), value, qsizetype(width) * height); + } else { + for (int j = 0; j < height; ++j) { + dest = reinterpret_cast(d); + qt_memfill(dest, value, width); + d += stride; + } + } +} + +inline ushort qConvertRgb32To16(uint c) +{ + return (((c) >> 3) & 0x001f) + | (((c) >> 5) & 0x07e0) + | (((c) >> 8) & 0xf800); +} + +inline QRgb qConvertRgb16To32(uint c) +{ + return 0xff000000 + | ((((c) << 3) & 0xf8) | (((c) >> 2) & 0x7)) + | ((((c) << 5) & 0xfc00) | (((c) >> 1) & 0x300)) + | ((((c) << 8) & 0xf80000) | (((c) << 3) & 0x70000)); +} + +const uint qt_bayer_matrix[16][16] = { + { 0x1, 0xc0, 0x30, 0xf0, 0xc, 0xcc, 0x3c, 0xfc, + 0x3, 0xc3, 0x33, 0xf3, 0xf, 0xcf, 0x3f, 0xff}, + { 0x80, 0x40, 0xb0, 0x70, 0x8c, 0x4c, 0xbc, 0x7c, + 0x83, 0x43, 0xb3, 0x73, 0x8f, 0x4f, 0xbf, 0x7f}, + { 0x20, 0xe0, 0x10, 0xd0, 0x2c, 0xec, 0x1c, 0xdc, + 0x23, 0xe3, 0x13, 0xd3, 0x2f, 0xef, 0x1f, 0xdf}, + { 0xa0, 0x60, 0x90, 0x50, 0xac, 0x6c, 0x9c, 0x5c, + 0xa3, 0x63, 0x93, 0x53, 0xaf, 0x6f, 0x9f, 0x5f}, + { 0x8, 0xc8, 0x38, 0xf8, 0x4, 0xc4, 0x34, 0xf4, + 0xb, 0xcb, 0x3b, 0xfb, 0x7, 0xc7, 0x37, 0xf7}, + { 0x88, 0x48, 0xb8, 0x78, 0x84, 0x44, 0xb4, 0x74, + 0x8b, 0x4b, 0xbb, 0x7b, 0x87, 0x47, 0xb7, 0x77}, + { 0x28, 0xe8, 0x18, 0xd8, 0x24, 0xe4, 0x14, 0xd4, + 0x2b, 0xeb, 0x1b, 0xdb, 0x27, 0xe7, 0x17, 0xd7}, + { 0xa8, 0x68, 0x98, 0x58, 0xa4, 0x64, 0x94, 0x54, + 0xab, 0x6b, 0x9b, 0x5b, 0xa7, 0x67, 0x97, 0x57}, + { 0x2, 0xc2, 0x32, 0xf2, 0xe, 0xce, 0x3e, 0xfe, + 0x1, 0xc1, 0x31, 0xf1, 0xd, 0xcd, 0x3d, 0xfd}, + { 0x82, 0x42, 0xb2, 0x72, 0x8e, 0x4e, 0xbe, 0x7e, + 0x81, 0x41, 0xb1, 0x71, 0x8d, 0x4d, 0xbd, 0x7d}, + { 0x22, 0xe2, 0x12, 0xd2, 0x2e, 0xee, 0x1e, 0xde, + 0x21, 0xe1, 0x11, 0xd1, 0x2d, 0xed, 0x1d, 0xdd}, + { 0xa2, 0x62, 0x92, 0x52, 0xae, 0x6e, 0x9e, 0x5e, + 0xa1, 0x61, 0x91, 0x51, 0xad, 0x6d, 0x9d, 0x5d}, + { 0xa, 0xca, 0x3a, 0xfa, 0x6, 0xc6, 0x36, 0xf6, + 0x9, 0xc9, 0x39, 0xf9, 0x5, 0xc5, 0x35, 0xf5}, + { 0x8a, 0x4a, 0xba, 0x7a, 0x86, 0x46, 0xb6, 0x76, + 0x89, 0x49, 0xb9, 0x79, 0x85, 0x45, 0xb5, 0x75}, + { 0x2a, 0xea, 0x1a, 0xda, 0x26, 0xe6, 0x16, 0xd6, + 0x29, 0xe9, 0x19, 0xd9, 0x25, 0xe5, 0x15, 0xd5}, + { 0xaa, 0x6a, 0x9a, 0x5a, 0xa6, 0x66, 0x96, 0x56, + 0xa9, 0x69, 0x99, 0x59, 0xa5, 0x65, 0x95, 0x55} +}; + +#define ARGB_COMBINE_ALPHA(argb, alpha) \ + ((((argb >> 24) * alpha) >> 8) << 24) | (argb & 0x00ffffff) + + +#if Q_PROCESSOR_WORDSIZE == 8 // 64-bit versions +#define AMIX(mask) (qMin(((quint64(s)&mask) + (quint64(d)&mask)), quint64(mask))) +#define MIX(mask) (qMin(((quint64(s)&mask) + (quint64(d)&mask)), quint64(mask))) +#else // 32 bits +// The mask for alpha can overflow over 32 bits +#define AMIX(mask) quint32(qMin(((quint64(s)&mask) + (quint64(d)&mask)), quint64(mask))) +#define MIX(mask) (qMin(((quint32(s)&mask) + (quint32(d)&mask)), quint32(mask))) +#endif + +inline uint comp_func_Plus_one_pixel_const_alpha(uint d, const uint s, const uint const_alpha, const uint one_minus_const_alpha) +{ + const uint result = uint(AMIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK)); + return INTERPOLATE_PIXEL_255(result, const_alpha, d, one_minus_const_alpha); +} + +inline uint comp_func_Plus_one_pixel(uint d, const uint s) +{ + const uint result = uint(AMIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK)); + return result; +} + +#undef MIX +#undef AMIX + +// must be multiple of 4 for easier SIMD implementations +static constexpr int BufferSize = 2048; + +// A buffer of intermediate results used by simple bilinear scaling. +struct IntermediateBuffer +{ + // The idea is first to do the interpolation between the row s1 and the row s2 + // into this intermediate buffer, then later interpolate between two pixel of this buffer. + // + // buffer_rb is a buffer of red-blue component of the pixel, in the form 0x00RR00BB + // buffer_ag is the alpha-green component of the pixel, in the form 0x00AA00GG + // +1 for the last pixel to interpolate with, and +1 for rounding errors. + quint32 buffer_rb[BufferSize+2]; + quint32 buffer_ag[BufferSize+2]; +}; + +QT_END_NAMESPACE + +#endif // QDRAWHELPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawhelper_x86_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawhelper_x86_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5c0a2f29c9f497ed7cfc11266602136b890be8ea --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawhelper_x86_p.h @@ -0,0 +1,52 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDRAWHELPER_X86_P_H +#define QDRAWHELPER_X86_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +#ifdef __SSE2__ +void qt_memfill64_sse2(quint64 *dest, quint64 value, qsizetype count); +void qt_memfill32_sse2(quint32 *dest, quint32 value, qsizetype count); +void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y, + const QRgba64 &color, + const uchar *src, int width, int height, int stride); +void qt_bitmapblit8888_sse2(QRasterBuffer *rasterBuffer, int x, int y, + const QRgba64 &color, + const uchar *src, int width, int height, int stride); +void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y, + const QRgba64 &color, + const uchar *src, int width, int height, int stride); +void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); +void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + +void qt_memfill64_avx2(quint64 *dest, quint64 value, qsizetype count); +void qt_memfill32_avx2(quint32 *dest, quint32 value, qsizetype count); +#endif // __SSE2__ + +static const int numCompositionFunctions = 38; + +QT_END_NAMESPACE + +#endif // QDRAWHELPER_X86_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawingprimitive_sse2_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawingprimitive_sse2_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3be84954257b4a79a71abe5ef692c654618445e8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qdrawingprimitive_sse2_p.h @@ -0,0 +1,280 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDRAWINGPRIMITIVE_SSE2_P_H +#define QDRAWINGPRIMITIVE_SSE2_P_H + +#include +#include +#include "qdrawhelper_x86_p.h" +#include "qrgba64_p.h" + +#ifdef __SSE2__ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +/* + * Multiply the components of pixelVector by alphaChannel + * Each 32bits components of alphaChannel must be in the form 0x00AA00AA + * colorMask must have 0x00ff00ff on each 32 bits component + * half must have the value 128 (0x80) for each 32 bits component + */ +#define BYTE_MUL_SSE2(result, pixelVector, alphaChannel, colorMask, half) \ +{ \ + /* 1. separate the colors in 2 vectors so each color is on 16 bits \ + (in order to be multiplied by the alpha \ + each 32 bit of dstVectorAG are in the form 0x00AA00GG \ + each 32 bit of dstVectorRB are in the form 0x00RR00BB */\ + __m128i pixelVectorAG = _mm_srli_epi16(pixelVector, 8); \ + __m128i pixelVectorRB = _mm_and_si128(pixelVector, colorMask); \ + \ + /* 2. multiply the vectors by the alpha channel */\ + pixelVectorAG = _mm_mullo_epi16(pixelVectorAG, alphaChannel); \ + pixelVectorRB = _mm_mullo_epi16(pixelVectorRB, alphaChannel); \ + \ + /* 3. divide by 255, that's the tricky part. \ + we do it like for BYTE_MUL(), with bit shift: X/255 ~= (X + X/256 + rounding)/256 */ \ + /** so first (X + X/256 + rounding) */\ + pixelVectorRB = _mm_add_epi16(pixelVectorRB, _mm_srli_epi16(pixelVectorRB, 8)); \ + pixelVectorRB = _mm_add_epi16(pixelVectorRB, half); \ + pixelVectorAG = _mm_add_epi16(pixelVectorAG, _mm_srli_epi16(pixelVectorAG, 8)); \ + pixelVectorAG = _mm_add_epi16(pixelVectorAG, half); \ + \ + /** second divide by 256 */\ + pixelVectorRB = _mm_srli_epi16(pixelVectorRB, 8); \ + /** for AG, we could >> 8 to divide followed by << 8 to put the \ + bytes in the correct position. By masking instead, we execute \ + only one instruction */\ + pixelVectorAG = _mm_andnot_si128(colorMask, pixelVectorAG); \ + \ + /* 4. combine the 2 pairs of colors */ \ + result = _mm_or_si128(pixelVectorAG, pixelVectorRB); \ +} + +/* + * Each 32bits components of alphaChannel must be in the form 0x00AA00AA + * oneMinusAlphaChannel must be 255 - alpha for each 32 bits component + * colorMask must have 0x00ff00ff on each 32 bits component + * half must have the value 128 (0x80) for each 32 bits component + */ +#define INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, alphaChannel, oneMinusAlphaChannel, colorMask, half) { \ + /* interpolate AG */\ + __m128i srcVectorAG = _mm_srli_epi16(srcVector, 8); \ + __m128i dstVectorAG = _mm_srli_epi16(dstVector, 8); \ + __m128i srcVectorAGalpha = _mm_mullo_epi16(srcVectorAG, alphaChannel); \ + __m128i dstVectorAGoneMinusAlphalpha = _mm_mullo_epi16(dstVectorAG, oneMinusAlphaChannel); \ + __m128i finalAG = _mm_add_epi16(srcVectorAGalpha, dstVectorAGoneMinusAlphalpha); \ + finalAG = _mm_add_epi16(finalAG, _mm_srli_epi16(finalAG, 8)); \ + finalAG = _mm_add_epi16(finalAG, half); \ + finalAG = _mm_andnot_si128(colorMask, finalAG); \ + \ + /* interpolate RB */\ + __m128i srcVectorRB = _mm_and_si128(srcVector, colorMask); \ + __m128i dstVectorRB = _mm_and_si128(dstVector, colorMask); \ + __m128i srcVectorRBalpha = _mm_mullo_epi16(srcVectorRB, alphaChannel); \ + __m128i dstVectorRBoneMinusAlphalpha = _mm_mullo_epi16(dstVectorRB, oneMinusAlphaChannel); \ + __m128i finalRB = _mm_add_epi16(srcVectorRBalpha, dstVectorRBoneMinusAlphalpha); \ + finalRB = _mm_add_epi16(finalRB, _mm_srli_epi16(finalRB, 8)); \ + finalRB = _mm_add_epi16(finalRB, half); \ + finalRB = _mm_srli_epi16(finalRB, 8); \ + \ + /* combine */\ + result = _mm_or_si128(finalAG, finalRB); \ +} + +// same as BLEND_SOURCE_OVER_ARGB32_SSE2, but for one vector srcVector +#define BLEND_SOURCE_OVER_ARGB32_SSE2_helper(dst, srcVector, nullVector, half, one, colorMask, alphaMask) { \ + const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); \ + if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) { \ + /* all opaque */ \ + _mm_store_si128((__m128i *)&dst[x], srcVector); \ + } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) != 0xffff) { \ + /* not fully transparent */ \ + /* extract the alpha channel on 2 x 16 bits */ \ + /* so we have room for the multiplication */ \ + /* each 32 bits will be in the form 0x00AA00AA */ \ + /* with A being the 1 - alpha */ \ + __m128i alphaChannel = _mm_srli_epi32(srcVector, 24); \ + alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); \ + alphaChannel = _mm_sub_epi16(one, alphaChannel); \ + \ + const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); \ + __m128i destMultipliedByOneMinusAlpha; \ + BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); \ + \ + /* result = s + d * (1-alpha) */\ + const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); \ + _mm_store_si128((__m128i *)&dst[x], result); \ + } \ + } + + +// Basically blend src over dst with the const alpha defined as constAlphaVector. +// nullVector, half, one, colorMask are constant across the whole image/texture, and should be defined as: +//const __m128i nullVector = _mm_set1_epi32(0); +//const __m128i half = _mm_set1_epi16(0x80); +//const __m128i one = _mm_set1_epi16(0xff); +//const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); +//const __m128i alphaMask = _mm_set1_epi32(0xff000000); +// +// The computation being done is: +// result = s + d * (1-alpha) +// with shortcuts if fully opaque or fully transparent. +#define BLEND_SOURCE_OVER_ARGB32_SSE2(dst, src, length, nullVector, half, one, colorMask, alphaMask) { \ + int x = 0; \ +\ + /* First, get dst aligned. */ \ + ALIGNMENT_PROLOGUE_16BYTES(dst, x, length) { \ + blend_pixel(dst[x], src[x]); \ + } \ +\ + for (; x < length-3; x += 4) { \ + const __m128i srcVector = _mm_loadu_si128((const __m128i *)&src[x]); \ + BLEND_SOURCE_OVER_ARGB32_SSE2_helper(dst, srcVector, nullVector, half, one, colorMask, alphaMask) \ + } \ + SIMD_EPILOGUE(x, length, 3) { \ + blend_pixel(dst[x], src[x]); \ + } \ +} + +// Basically blend src over dst with the const alpha defined as constAlphaVector. +// nullVector, half, one, colorMask are constant across the whole image/texture, and should be defined as: +//const __m128i nullVector = _mm_set1_epi32(0); +//const __m128i half = _mm_set1_epi16(0x80); +//const __m128i one = _mm_set1_epi16(0xff); +//const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); +// +// The computation being done is: +// dest = (s + d * sia) * ca + d * cia +// = s * ca + d * (sia * ca + cia) +// = s * ca + d * (1 - sa*ca) +#define BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_SSE2(dst, src, length, nullVector, half, one, colorMask, constAlphaVector) \ +{ \ + int x = 0; \ +\ + ALIGNMENT_PROLOGUE_16BYTES(dst, x, length) { \ + blend_pixel(dst[x], src[x], const_alpha); \ + } \ +\ + for (; x < length-3; x += 4) { \ + __m128i srcVector = _mm_loadu_si128((const __m128i *)&src[x]); \ + if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) { \ + BYTE_MUL_SSE2(srcVector, srcVector, constAlphaVector, colorMask, half); \ +\ + __m128i alphaChannel = _mm_srli_epi32(srcVector, 24); \ + alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); \ + alphaChannel = _mm_sub_epi16(one, alphaChannel); \ + \ + const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); \ + __m128i destMultipliedByOneMinusAlpha; \ + BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); \ + \ + const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); \ + _mm_store_si128((__m128i *)&dst[x], result); \ + } \ + } \ + SIMD_EPILOGUE(x, length, 3) { \ + blend_pixel(dst[x], src[x], const_alpha); \ + } \ +} + +QT_END_NAMESPACE + +#endif // __SSE2__ + +QT_BEGIN_NAMESPACE +#if QT_COMPILER_SUPPORTS_HERE(SSE4_1) +QT_FUNCTION_TARGET(SSE2) +static inline void Q_DECL_VECTORCALL reciprocal_mul_ss(__m128 &ia, const __m128 a, float mul) +{ + ia = _mm_rcp_ss(a); // Approximate 1/a + // Improve precision of ia using Newton-Raphson + ia = _mm_sub_ss(_mm_add_ss(ia, ia), _mm_mul_ss(ia, _mm_mul_ss(ia, a))); + ia = _mm_mul_ss(ia, _mm_set_ss(mul)); + ia = _mm_shuffle_ps(ia, ia, _MM_SHUFFLE(0,0,0,0)); +} + +QT_FUNCTION_TARGET(SSE4_1) +static inline QRgb qUnpremultiply_sse4(QRgb p) +{ + const uint alpha = qAlpha(p); + if (alpha == 255) + return p; + if (alpha == 0) + return 0; + const __m128 va = _mm_set1_ps(alpha); + __m128 via; + reciprocal_mul_ss(via, va, 255.0f); // Approximate 1/a + __m128i vl = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(p)); + vl = _mm_cvtps_epi32(_mm_mul_ps(_mm_cvtepi32_ps(vl), via)); + vl = _mm_packus_epi32(vl, vl); + vl = _mm_insert_epi16(vl, alpha, 3); + vl = _mm_packus_epi16(vl, vl); + return _mm_cvtsi128_si32(vl); +} + +template +QT_FUNCTION_TARGET(SSE4_1) +static inline uint qConvertArgb32ToA2rgb30_sse4(QRgb p) +{ + const uint alpha = qAlpha(p); + if (alpha == 255) + return qConvertRgb32ToRgb30(p); + if (alpha == 0) + return 0; + constexpr float mult = 1023.0f / (255 >> 6); + const uint newalpha = (alpha >> 6); + const __m128 va = _mm_set1_ps(alpha); + __m128 via; + reciprocal_mul_ss(via, va, mult * newalpha); + __m128i vl = _mm_cvtsi32_si128(p); + vl = _mm_cvtepu8_epi32(vl); + vl = _mm_cvtps_epi32(_mm_mul_ps(_mm_cvtepi32_ps(vl), via)); + vl = _mm_packus_epi32(vl, vl); + uint rgb30 = (newalpha << 30); + rgb30 |= ((uint)_mm_extract_epi16(vl, 1)) << 10; + if (PixelOrder == PixelOrderRGB) { + rgb30 |= ((uint)_mm_extract_epi16(vl, 2)) << 20; + rgb30 |= ((uint)_mm_extract_epi16(vl, 0)); + } else { + rgb30 |= ((uint)_mm_extract_epi16(vl, 0)) << 20; + rgb30 |= ((uint)_mm_extract_epi16(vl, 2)); + } + return rgb30; +} + +template +QT_FUNCTION_TARGET(SSE4_1) +static inline uint qConvertRgba64ToRgb32_sse4(QRgba64 p) +{ + if (p.isTransparent()) + return 0; + __m128i vl = _mm_loadl_epi64(reinterpret_cast(&p)); + if (!p.isOpaque()) { + const __m128 va = _mm_set1_ps(p.alpha()); + __m128 via; + reciprocal_mul_ss(via, va, 65535.0f); + vl = _mm_unpacklo_epi16(vl, _mm_setzero_si128()); + vl = _mm_cvtps_epi32(_mm_mul_ps(_mm_cvtepi32_ps(vl) , via)); + vl = _mm_packus_epi32(vl, vl); + vl = _mm_insert_epi16(vl, p.alpha(), 3); + } + if (PixelOrder == PixelOrderBGR) + vl = _mm_shufflelo_epi16(vl, _MM_SHUFFLE(3, 0, 1, 2)); + return toArgb32(vl); +} +#endif +QT_END_NAMESPACE + +#endif // QDRAWINGPRIMITIVE_SSE2_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qedidparser_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qedidparser_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f26317d103430c1c1e113e4736ca73d4c11937ed --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qedidparser_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2017 Pier Luigi Fiorini +// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QEDIDPARSER_P_H +#define QEDIDPARSER_P_H + +#include +#include +#include + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QEdidParser +{ +public: + bool parse(const QByteArray &blob); + + QString identifier; + QString manufacturer; + QString model; + QString serialNumber; + QSizeF physicalSize; + qreal gamma; + QPointF redChromaticity; + QPointF greenChromaticity; + QPointF blueChromaticity; + QPointF whiteChromaticity; + QList> tables; + bool sRgb; + bool useTables; + +private: + QString parseEdidString(const quint8 *data); +}; + +QT_END_NAMESPACE + +#endif // QEDIDPARSER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qedidvendortable_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qedidvendortable_p.h new file mode 100644 index 0000000000000000000000000000000000000000..859f4874f59d89a78da6bcd30a37613c20af8972 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qedidvendortable_p.h @@ -0,0 +1,2507 @@ +// Copyright (C) 2017 Pier Luigi Fiorini +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +/* + * This lookup table was generated from https://github.com/vcrhonek/hwdata/raw/master/pnp.ids + * + * Do not change this file directly, instead edit the + * qtbase/util/edid/qedidvendortable.py script and regenerate this file. + */ + +#ifndef QEDIDVENDORTABLE_P_H +#define QEDIDVENDORTABLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +struct VendorTable { + const char id[4]; + const char name[78]; +}; + +static const VendorTable q_edidVendorTable[] = { + { "AAA", "Avolites Ltd" }, + { "AAE", "Anatek Electronics Inc." }, + { "AAM", "Aava Mobile Oy" }, + { "AAN", "AAEON Technology Inc." }, + { "AAT", "Ann Arbor Technologies" }, + { "ABA", "ABBAHOME INC." }, + { "ABC", "AboCom System Inc." }, + { "ABD", "Allen Bradley Company" }, + { "ABE", "Alcatel Bell" }, + { "ABO", "D-Link Systems Inc" }, + { "ABS", "Abaco Systems, Inc." }, + { "ABT", "Anchor Bay Technologies, Inc." }, + { "ABV", "Advanced Research Technology" }, + { "ACA", "Ariel Corporation" }, + { "ACB", "Aculab Ltd" }, + { "ACC", "Accton Technology Corporation" }, + { "ACD", "AWETA BV" }, + { "ACE", "Actek Engineering Pty Ltd" }, + { "ACG", "A&R Cambridge Ltd." }, + { "ACH", "Archtek Telecom Corporation" }, + { "ACI", "Ancor Communications Inc" }, + { "ACK", "Acksys" }, + { "ACL", "Apricot Computers" }, + { "ACM", "Acroloop Motion Control Systems Inc" }, + { "ACO", "Allion Computer Inc." }, + { "ACP", "Aspen Tech Inc" }, + { "ACR", "Acer Technologies" }, + { "ACS", "Altos Computer Systems" }, + { "ACT", "Applied Creative Technology" }, + { "ACU", "Acculogic" }, + { "ACV", "ActivCard S.A" }, + { "ADA", "Addi-Data GmbH" }, + { "ADB", "Aldebbaron" }, + { "ADC", "Acnhor Datacomm" }, + { "ADD", "Advanced Peripheral Devices Inc" }, + { "ADE", "Arithmos, Inc." }, + { "ADH", "Aerodata Holdings Ltd" }, + { "ADI", "ADI Systems Inc" }, + { "ADK", "Adtek System Science Company Ltd" }, + { "ADL", "ASTRA Security Products Ltd" }, + { "ADM", "Ad Lib MultiMedia Inc" }, + { "ADN", "Analog & Digital Devices Tel. Inc" }, + { "ADP", "Adaptec Inc" }, + { "ADR", "Nasa Ames Research Center" }, + { "ADS", "Analog Devices Inc" }, + { "ADT", "Adtek" }, + { "ADV", "Advanced Micro Devices Inc" }, + { "ADX", "Adax Inc" }, + { "ADZ", "ADDER TECHNOLOGY LTD" }, + { "AEC", "Antex Electronics Corporation" }, + { "AED", "Advanced Electronic Designs, Inc." }, + { "AEI", "Actiontec Electric Inc" }, + { "AEJ", "Alpha Electronics Company" }, + { "AEM", "ASEM S.p.A." }, + { "AEN", "Avencall" }, + { "AEP", "Aetas Peripheral International" }, + { "AET", "Aethra Telecomunicazioni S.r.l." }, + { "AFA", "Alfa Inc" }, + { "AGC", "Beijing Aerospace Golden Card Electronic Engineering Co.,Ltd." }, + { "AGI", "Artish Graphics Inc" }, + { "AGL", "Argolis" }, + { "AGM", "Advan Int'l Corporation" }, + { "AGO", "AlgolTek, Inc." }, + { "AGT", "Agilent Technologies" }, + { "AHC", "Advantech Co., Ltd." }, + { "AHQ", "Astro HQ LLC" }, + { "AHS", "Beijing AnHeng SecoTech Information Technology Co., Ltd." }, + { "AIC", "Arnos Insturments & Computer Systems" }, + { "AIE", "Altmann Industrieelektronik" }, + { "AII", "Amptron International Inc." }, + { "AIK", "Dongguan Alllike Electronics Co., Ltd." }, + { "AIL", "Altos India Ltd" }, + { "AIM", "AIMS Lab Inc" }, + { "AIR", "Advanced Integ. Research Inc" }, + { "AIS", "Alien Internet Services" }, + { "AIW", "Aiwa Company Ltd" }, + { "AIX", "ALTINEX, INC." }, + { "AJA", "AJA Video Systems, Inc." }, + { "AKB", "Akebia Ltd" }, + { "AKE", "AKAMI Electric Co.,Ltd" }, + { "AKI", "AKIA Corporation" }, + { "AKL", "AMiT Ltd" }, + { "AKM", "Asahi Kasei Microsystems Company Ltd" }, + { "AKP", "Atom Komplex Prylad" }, + { "AKY", "Askey Computer Corporation" }, + { "ALA", "Alacron Inc" }, + { "ALC", "Altec Corporation" }, + { "ALD", "In4S Inc" }, + { "ALE", "Alenco BV" }, + { "ALG", "Realtek Semiconductor Corp." }, + { "ALH", "AL Systems" }, + { "ALI", "Acer Labs" }, + { "ALJ", "Altec Lansing" }, + { "ALK", "Acrolink Inc" }, + { "ALL", "Alliance Semiconductor Corporation" }, + { "ALM", "Acutec Ltd." }, + { "ALN", "Alana Technologies" }, + { "ALO", "Algolith Inc." }, + { "ALP", "ALPS ALPINE CO., LTD." }, + { "ALR", "Advanced Logic" }, + { "ALS", "Avance Logic Inc" }, + { "ALT", "Altra" }, + { "ALV", "AlphaView LCD" }, + { "ALX", "ALEXON Co.,Ltd." }, + { "AMA", "Asia Microelectronic Development Inc" }, + { "AMB", "Ambient Technologies, Inc." }, + { "AMC", "Attachmate Corporation" }, + { "AMD", "Amdek Corporation" }, + { "AMI", "American Megatrends Inc" }, + { "AML", "Anderson Multimedia Communications (HK) Limited" }, + { "AMN", "Amimon LTD." }, + { "AMO", "Amino Technologies PLC and Amino Communications Limited" }, + { "AMP", "AMP Inc" }, + { "AMR", "AmTRAN Technology Co., Ltd." }, + { "AMS", "ARMSTEL, Inc." }, + { "AMT", "AMT International Industry" }, + { "AMX", "AMX LLC" }, + { "ANA", "Anakron" }, + { "ANC", "Ancot" }, + { "AND", "Adtran Inc" }, + { "ANI", "Anigma Inc" }, + { "ANK", "Anko Electronic Company Ltd" }, + { "ANL", "Analogix Semiconductor, Inc" }, + { "ANO", "Anorad Corporation" }, + { "ANP", "Andrew Network Production" }, + { "ANR", "ANR Ltd" }, + { "ANS", "Ansel Communication Company" }, + { "ANT", "Ace CAD Enterprise Company Ltd" }, + { "ANV", "Beijing ANTVR Technology Co., Ltd." }, + { "ANW", "Analog Way SAS" }, + { "ANX", "Acer Netxus Inc" }, + { "AOA", "AOpen Inc." }, + { "AOE", "Advanced Optics Electronics, Inc." }, + { "AOL", "America OnLine" }, + { "AOT", "Alcatel" }, + { "APC", "American Power Conversion" }, + { "APD", "AppliAdata" }, + { "APE", "ALPS ALPINE CO., LTD." }, + { "APG", "Horner Electric Inc" }, + { "API", "A Plus Info Corporation" }, + { "APL", "Aplicom Oy" }, + { "APM", "Applied Memory Tech" }, + { "APN", "Appian Tech Inc" }, + { "APP", "Apple Computer Inc" }, + { "APR", "Aprilia s.p.a." }, + { "APS", "Autologic Inc" }, + { "APT", "Audio Processing Technology Ltd" }, + { "APV", "A+V Link" }, + { "APX", "AP Designs Ltd" }, + { "ARC", "Alta Research Corporation" }, + { "ARD", "AREC Inc." }, + { "ARE", "ICET S.p.A." }, + { "ARG", "Argus Electronics Co., LTD" }, + { "ARI", "Argosy Research Inc" }, + { "ARK", "Ark Logic Inc" }, + { "ARL", "Arlotto Comnet Inc" }, + { "ARM", "Arima" }, + { "ARO", "Poso International B.V." }, + { "ARR", "ARRIS Group, Inc." }, + { "ARS", "Arescom Inc" }, + { "ART", "Corion Industrial Corporation" }, + { "ASC", "Ascom Strategic Technology Unit" }, + { "ASD", "USC Information Sciences Institute" }, + { "ASE", "AseV Display Labs" }, + { "ASH", "Ashton Bentley Concepts" }, + { "ASI", "Ahead Systems" }, + { "ASK", "Ask A/S" }, + { "ASL", "AccuScene Corporation Ltd" }, + { "ASM", "ASEM S.p.A." }, + { "ASN", "Asante Tech Inc" }, + { "ASP", "ASP Microelectronics Ltd" }, + { "AST", "AST Research Inc" }, + { "ASU", "Asuscom Network Inc" }, + { "ASX", "AudioScience" }, + { "ASY", "Rockwell Collins / Airshow Systems" }, + { "ATA", "Allied Telesyn International (Asia) Pte Ltd" }, + { "ATC", "Ably-Tech Corporation" }, + { "ATD", "Alpha Telecom Inc" }, + { "ATE", "Innovate Ltd" }, + { "ATH", "Athena Informatica S.R.L." }, + { "ATI", "Allied Telesis KK" }, + { "ATJ", "ArchiTek Corporation" }, + { "ATK", "Allied Telesyn Int'l" }, + { "ATL", "Arcus Technology Ltd" }, + { "ATM", "ATM Ltd" }, + { "ATN", "Athena Smartcard Solutions Ltd." }, + { "ATO", "ASTRO DESIGN, INC." }, + { "ATP", "Alpha-Top Corporation" }, + { "ATT", "AT&T" }, + { "ATV", "Office Depot, Inc." }, + { "ATX", "Athenix Corporation" }, + { "AUG", "August Home, Inc." }, + { "AUI", "ALPS ALPINE CO., LTD." }, + { "AUO", "AU Optronics" }, + { "AUR", "Aureal Semiconductor" }, + { "AUS", "ASUSTek COMPUTER INC" }, + { "AUT", "Autotime Corporation" }, + { "AUV", "Auvidea GmbH" }, + { "AVA", "Avaya Communication" }, + { "AVC", "Auravision Corporation" }, + { "AVD", "Avid Electronics Corporation" }, + { "AVE", "Add Value Enterpises (Asia) Pte Ltd" }, + { "AVG", "Avegant Corporation" }, + { "AVI", "Nippon Avionics Co.,Ltd" }, + { "AVJ", "Atelier Vision Corporation" }, + { "AVL", "Avalue Technology Inc." }, + { "AVM", "AVM GmbH" }, + { "AVN", "Advance Computer Corporation" }, + { "AVO", "Avocent Corporation" }, + { "AVR", "AVer Information Inc." }, + { "AVS", "Avatron Software Inc." }, + { "AVT", "Avtek (Electronics) Pty Ltd" }, + { "AVV", "SBS Technologies (Canada), Inc. (was Avvida Systems, Inc.)" }, + { "AVX", "A/Vaux Electronics" }, + { "AWC", "Access Works Comm Inc" }, + { "AWL", "Aironet Wireless Communications, Inc" }, + { "AWS", "Wave Systems" }, + { "AXB", "Adrienne Electronics Corporation" }, + { "AXC", "AXIOMTEK CO., LTD." }, + { "AXE", "Axell Corporation" }, + { "AXI", "American Magnetics" }, + { "AXL", "Axel" }, + { "AXO", "Axonic Labs LLC" }, + { "AXP", "American Express" }, + { "AXT", "Axtend Technologies Inc" }, + { "AXX", "Axxon Computer Corporation" }, + { "AXY", "AXYZ Automation Services, Inc" }, + { "AYD", "Aydin Displays" }, + { "AYR", "Airlib, Inc" }, + { "AZH", "Shenzhen three Connaught Information Technology Co., Ltd. (3nod Group)" }, + { "AZM", "AZ Middelheim - Radiotherapy" }, + { "AZT", "Aztech Systems Ltd" }, + { "BAC", "Biometric Access Corporation" }, + { "BAN", "Banyan" }, + { "BBB", "an-najah university" }, + { "BBH", "B&Bh" }, + { "BBL", "Brain Boxes Limited" }, + { "BBV", "BlueBox Video Limited" }, + { "BBX", "Black Box Corporation" }, + { "BCC", "Beaver Computer Corporaton" }, + { "BCD", "Barco GmbH" }, + { "BCI", "Broadata Communications Inc." }, + { "BCM", "Broadcom" }, + { "BCQ", "Deutsche Telekom Berkom GmbH" }, + { "BCS", "Booria CAD/CAM systems" }, + { "BDO", "Brahler ICS" }, + { "BDR", "Blonder Tongue Labs, Inc." }, + { "BDS", "Barco Display Systems" }, + { "BEC", "Beckhoff Automation" }, + { "BEI", "Beckworth Enterprises Inc" }, + { "BEK", "Beko Elektronik A.S." }, + { "BEL", "Beltronic Industrieelektronik GmbH" }, + { "BEO", "Baug & Olufsen" }, + { "BFE", "B.F. Engineering Corporation" }, + { "BGB", "Barco Graphics N.V" }, + { "BGT", "Budzetron Inc" }, + { "BHZ", "BitHeadz, Inc." }, + { "BIA", "Biamp Systems Corporation" }, + { "BIC", "Big Island Communications" }, + { "BII", "Boeckeler Instruments Inc" }, + { "BIL", "Billion Electric Company Ltd" }, + { "BIO", "BioLink Technologies International, Inc." }, + { "BIT", "Bit 3 Computer" }, + { "BLD", "BILD INNOVATIVE TECHNOLOGY LLC" }, + { "BLI", "Busicom" }, + { "BLN", "BioLink Technologies" }, + { "BLP", "Bloomberg L.P." }, + { "BMD", "Blackmagic Design" }, + { "BMI", "Benson Medical Instruments Company" }, + { "BML", "BIOMED Lab" }, + { "BMS", "BIOMEDISYS" }, + { "BNE", "Bull AB" }, + { "BNK", "Banksia Tech Pty Ltd" }, + { "BNO", "Bang & Olufsen" }, + { "BNS", "Boulder Nonlinear Systems" }, + { "BOB", "Rainy Orchard" }, + { "BOE", "BOE" }, + { "BOI", "NINGBO BOIGLE DIGITAL TECHNOLOGY CO.,LTD" }, + { "BOS", "BOS" }, + { "BPD", "Micro Solutions, Inc." }, + { "BPS", "Barco, N.V." }, + { "BPU", "Best Power" }, + { "BRA", "Braemac Pty Ltd" }, + { "BRC", "BARC" }, + { "BRG", "Bridge Information Co., Ltd" }, + { "BRI", "Boca Research Inc" }, + { "BRM", "Braemar Inc" }, + { "BRO", "BROTHER INDUSTRIES,LTD." }, + { "BSE", "Bose Corporation" }, + { "BSG", "Robert Bosch GmbH" }, + { "BSL", "Biomedical Systems Laboratory" }, + { "BSN", "BRIGHTSIGN, LLC" }, + { "BST", "BodySound Technologies, Inc." }, + { "BTC", "Bit 3 Computer" }, + { "BTE", "Brilliant Technology" }, + { "BTF", "Bitfield Oy" }, + { "BTI", "BusTech Inc" }, + { "BTO", "BioTao Ltd" }, + { "BUF", "Yasuhiko Shirai Melco Inc" }, + { "BUG", "B.U.G., Inc." }, + { "BUJ", "ATI Tech Inc" }, + { "BUL", "Bull" }, + { "BUR", "Bernecker & Rainer Ind-Eletronik GmbH" }, + { "BUS", "BusTek" }, + { "BUT", "21ST CENTURY ENTERTAINMENT" }, + { "BWK", "Bitworks Inc." }, + { "BXE", "Buxco Electronics" }, + { "BYD", "byd:sign corporation" }, + { "CAA", "Castles Automation Co., Ltd" }, + { "CAC", "CA & F Elettronica" }, + { "CAG", "CalComp" }, + { "CAI", "Canon Inc." }, + { "CAL", "Acon" }, + { "CAM", "Cambridge Audio" }, + { "CAN", "Canopus Company Ltd" }, + { "CAR", "Cardinal Company Ltd" }, + { "CAS", "CASIO COMPUTER CO.,LTD" }, + { "CAT", "Consultancy in Advanced Technology" }, + { "CAV", "Cavium Networks, Inc" }, + { "CBI", "ComputerBoards Inc" }, + { "CBR", "Cebra Tech A/S" }, + { "CBT", "Cabletime Ltd" }, + { "CBX", "Cybex Computer Products Corporation" }, + { "CCC", "C-Cube Microsystems" }, + { "CCI", "Cache" }, + { "CCJ", "CONTEC CO.,LTD." }, + { "CCL", "CCL/ITRI" }, + { "CCP", "Capetronic USA Inc" }, + { "CDC", "Core Dynamics Corporation" }, + { "CDD", "Convergent Data Devices" }, + { "CDE", "Colin.de" }, + { "CDG", "Christie Digital Systems Inc" }, + { "CDI", "Concept Development Inc" }, + { "CDK", "Cray Communications" }, + { "CDN", "Codenoll Technical Corporation" }, + { "CDP", "CalComp" }, + { "CDS", "Computer Diagnostic Systems" }, + { "CDT", "IBM Corporation" }, + { "CDV", "Convergent Design Inc." }, + { "CEA", "Consumer Electronics Association" }, + { "CEC", "Chicony Electronics Company Ltd" }, + { "CED", "Cambridge Electronic Design Ltd" }, + { "CEF", "Cefar Digital Vision" }, + { "CEI", "Crestron Electronics, Inc." }, + { "CEM", "MEC Electronics GmbH" }, + { "CEN", "Centurion Technologies P/L" }, + { "CEP", "C-DAC" }, + { "CER", "Ceronix" }, + { "CET", "TEC CORPORATION" }, + { "CFG", "Atlantis" }, + { "CFR", "Meta View, Inc." }, + { "CGA", "Chunghwa Picture Tubes, LTD" }, + { "CGS", "Chyron Corp" }, + { "CGT", "congatec AG" }, + { "CHA", "Chase Research PLC" }, + { "CHD", "ChangHong Electric Co.,Ltd" }, + { "CHE", "Acer Inc" }, + { "CHG", "Sichuan Changhong Electric CO, LTD." }, + { "CHI", "Chrontel Inc" }, + { "CHL", "Chloride-R&D" }, + { "CHM", "CHIC TECHNOLOGY CORP." }, + { "CHO", "Sichuang Changhong Corporation" }, + { "CHP", "CH Products" }, + { "CHR", "christmann informationstechnik + medien GmbH & Co. KG" }, + { "CHS", "Agentur Chairos" }, + { "CHT", "Chunghwa Picture Tubes,LTD." }, + { "CHY", "Cherry GmbH" }, + { "CIC", "Comm. Intelligence Corporation" }, + { "CIE", "Convergent Engineering, Inc." }, + { "CII", "Cromack Industries Inc" }, + { "CIL", "Citicom Infotech Private Limited" }, + { "CIN", "Citron GmbH" }, + { "CIP", "Ciprico Inc" }, + { "CIR", "Cirrus Logic Inc" }, + { "CIS", "Cisco Systems Inc" }, + { "CIT", "Citifax Limited" }, + { "CKC", "The Concept Keyboard Company Ltd" }, + { "CKJ", "Carina System Co., Ltd." }, + { "CLA", "Clarion Company Ltd" }, + { "CLD", "COMMAT L.t.d." }, + { "CLE", "Classe Audio" }, + { "CLG", "CoreLogic" }, + { "CLI", "Cirrus Logic Inc" }, + { "CLM", "CrystaLake Multimedia" }, + { "CLO", "Clone Computers" }, + { "CLR", "Clover Electronics" }, + { "CLT", "automated computer control systems" }, + { "CLV", "Clevo Company" }, + { "CLX", "CardLogix" }, + { "CMC", "CMC Ltd" }, + { "CMD", "Colorado MicroDisplay, Inc." }, + { "CMG", "Chenming Mold Ind. Corp." }, + { "CMI", "C-Media Electronics" }, + { "CMK", "Comark LLC" }, + { "CMM", "Comtime GmbH" }, + { "CMN", "Chimei Innolux Corporation" }, + { "CMO", "Chi Mei Optoelectronics corp." }, + { "CMR", "Cambridge Research Systems Ltd" }, + { "CMS", "CompuMaster Srl" }, + { "CMX", "Comex Electronics AB" }, + { "CNB", "American Power Conversion" }, + { "CNC", "Alvedon Computers Ltd" }, + { "CND", "Micro-Star Int'l Co., Ltd." }, + { "CNE", "Cine-tal" }, + { "CNI", "Connect Int'l A/S" }, + { "CNN", "Canon Inc" }, + { "CNT", "COINT Multimedia Systems" }, + { "COB", "COBY Electronics Co., Ltd" }, + { "COD", "CODAN Pty. Ltd." }, + { "COI", "Codec Inc." }, + { "COL", "Rockwell Collins, Inc." }, + { "COM", "Comtrol Corporation" }, + { "CON", "Contec Company Ltd" }, + { "COO", "coolux GmbH" }, + { "COR", "Corollary Inc" }, + { "COS", "CoStar Corporation" }, + { "COT", "Core Technology Inc" }, + { "COW", "Polycow Productions" }, + { "COX", "Comrex" }, + { "CPC", "Ciprico Inc" }, + { "CPD", "CompuAdd" }, + { "CPI", "Computer Peripherals Inc" }, + { "CPL", "Compal Electronics Inc" }, + { "CPM", "Capella Microsystems Inc." }, + { "CPP", "Compound Photonics" }, + { "CPQ", "Compaq Computer Company" }, + { "CPT", "cPATH" }, + { "CPX", "Powermatic Data Systems" }, + { "CRA", "CRALTECH ELECTRONICA, S.L." }, + { "CRC", "CONRAC GmbH" }, + { "CRD", "Cardinal Technical Inc" }, + { "CRE", "Creative Labs Inc" }, + { "CRH", "Contemporary Research Corp." }, + { "CRI", "Crio Inc." }, + { "CRL", "Creative Logic" }, + { "CRM", "CORSAIR MEMORY Inc." }, + { "CRN", "Cornerstone Imaging" }, + { "CRO", "Extraordinary Technologies PTY Limited" }, + { "CRQ", "Cirque Corporation" }, + { "CRS", "Crescendo Communication Inc" }, + { "CRV", "Cerevo Inc." }, + { "CRW", "Cammegh Limited" }, + { "CRX", "Cyrix Corporation" }, + { "CSB", "Transtex SA" }, + { "CSC", "Crystal Semiconductor" }, + { "CSD", "Cresta Systems Inc" }, + { "CSE", "Concept Solutions & Engineering" }, + { "CSI", "Cabletron System Inc" }, + { "CSL", "Cloudium Systems Ltd." }, + { "CSM", "Cosmic Engineering Inc." }, + { "CSO", "California Institute of Technology" }, + { "CSS", "CSS Laboratories" }, + { "CST", "CSTI Inc" }, + { "CTA", "CoSystems Inc" }, + { "CTC", "CTC Communication Development Company Ltd" }, + { "CTE", "Chunghwa Telecom Co., Ltd." }, + { "CTL", "Creative Technology Ltd" }, + { "CTM", "Computerm Corporation" }, + { "CTN", "Computone Products" }, + { "CTP", "Computer Technology Corporation" }, + { "CTR", "Control4 Corporation" }, + { "CTS", "Comtec Systems Co., Ltd." }, + { "CTX", "Creatix Polymedia GmbH" }, + { "CUB", "Cubix Corporation" }, + { "CUK", "Calibre UK Ltd" }, + { "CVA", "Covia Inc." }, + { "CVI", "Colorado Video, Inc." }, + { "CVP", "Chromatec Video Products Ltd" }, + { "CVS", "Clarity Visual Systems" }, + { "CWC", "Curtiss-Wright Controls, Inc." }, + { "CWR", "Connectware Inc" }, + { "CXT", "Conexant Systems" }, + { "CYB", "CyberVision" }, + { "CYC", "Cylink Corporation" }, + { "CYD", "Cyclades Corporation" }, + { "CYL", "Cyberlabs" }, + { "CYP", "CYPRESS SEMICONDUCTOR CORPORATION" }, + { "CYT", "Cytechinfo Inc" }, + { "CYV", "Cyviz AS" }, + { "CYW", "Cyberware" }, + { "CYX", "Cyrix Corporation" }, + { "CZC", "Shenzhen ChuangZhiCheng Technology Co., Ltd." }, + { "CZE", "Carl Zeiss AG" }, + { "DAC", "Digital Acoustics Corporation" }, + { "DAE", "Digatron Industrie Elektronik GmbH" }, + { "DAI", "DAIS SET Ltd." }, + { "DAK", "Daktronics" }, + { "DAL", "Digital Audio Labs Inc" }, + { "DAN", "Danelec Marine A/S" }, + { "DAS", "DAVIS AS" }, + { "DAT", "Datel Inc" }, + { "DAU", "Daou Tech Inc" }, + { "DAV", "Davicom Semiconductor Inc" }, + { "DAW", "DA2 Technologies Inc" }, + { "DAX", "Data Apex Ltd" }, + { "DBD", "Diebold Inc." }, + { "DBI", "DigiBoard Inc" }, + { "DBK", "Databook Inc" }, + { "DBL", "Doble Engineering Company" }, + { "DBN", "DB Networks Inc" }, + { "DCA", "Digital Communications Association" }, + { "DCC", "Dale Computer Corporation" }, + { "DCD", "Datacast LLC" }, + { "DCE", "dSPACE GmbH" }, + { "DCI", "Concepts Inc" }, + { "DCL", "Dynamic Controls Ltd" }, + { "DCM", "DCM Data Products" }, + { "DCO", "Dialogue Technology Corporation" }, + { "DCR", "Decros Ltd" }, + { "DCS", "Diamond Computer Systems Inc" }, + { "DCT", "Dancall Telecom A/S" }, + { "DCV", "Datatronics Technology Inc" }, + { "DDA", "DA2 Technologies Corporation" }, + { "DDD", "Danka Data Devices" }, + { "DDE", "Datasat Digital Entertainment" }, + { "DDI", "Data Display AG" }, + { "DDS", "Barco, N.V." }, + { "DDT", "Datadesk Technologies Inc" }, + { "DDV", "Delta Information Systems, Inc" }, + { "DEC", "Digital Equipment Corporation" }, + { "DEI", "Deico Electronics" }, + { "DEL", "Dell Inc." }, + { "DEN", "Densitron Computers Ltd" }, + { "DEX", "idex displays" }, + { "DFI", "DFI" }, + { "DFK", "SharkTec A/S" }, + { "DFT", "DEI Holdings dba Definitive Technology" }, + { "DGA", "Digiital Arts Inc" }, + { "DGC", "Data General Corporation" }, + { "DGI", "DIGI International" }, + { "DGK", "DugoTech Co., LTD" }, + { "DGP", "Digicorp European sales S.A." }, + { "DGS", "Diagsoft Inc" }, + { "DGT", "Dearborn Group Technology" }, + { "DHD", "Dension Audio Systems" }, + { "DHP", "DH Print" }, + { "DHQ", "Quadram" }, + { "DHT", "Projectavision Inc" }, + { "DIA", "Diadem" }, + { "DIG", "Digicom S.p.A." }, + { "DII", "Dataq Instruments Inc" }, + { "DIM", "dPict Imaging, Inc." }, + { "DIN", "Daintelecom Co., Ltd" }, + { "DIS", "Diseda S.A." }, + { "DIT", "Dragon Information Technology" }, + { "DJE", "Capstone Visual Product Development" }, + { "DJP", "Maygay Machines, Ltd" }, + { "DKY", "Datakey Inc" }, + { "DLB", "Dolby Laboratories Inc." }, + { "DLC", "Diamond Lane Comm. Corporation" }, + { "DLG", "Digital-Logic GmbH" }, + { "DLK", "D-Link Systems Inc" }, + { "DLL", "Dell Inc" }, + { "DLO", "Shenzhen Dlodlo Technologies Co., Ltd." }, + { "DLT", "Digitelec Informatique Park Cadera" }, + { "DMB", "Digicom Systems Inc" }, + { "DMC", "Dune Microsystems Corporation" }, + { "DMM", "Dimond Multimedia Systems Inc" }, + { "DMN", "Dimension Engineering LLC" }, + { "DMO", "Data Modul AG" }, + { "DMP", "D&M Holdings Inc, Professional Business Company" }, + { "DMS", "DOME imaging systems" }, + { "DMT", "Distributed Management Task Force, Inc. (DMTF)" }, + { "DMV", "NDS Ltd" }, + { "DNA", "DNA Enterprises, Inc." }, + { "DNG", "Apache Micro Peripherals Inc" }, + { "DNI", "Deterministic Networks Inc." }, + { "DNT", "Dr. Neuhous Telekommunikation GmbH" }, + { "DNV", "DiCon" }, + { "DOL", "Dolman Technologies Group Inc" }, + { "DOM", "Dome Imaging Systems" }, + { "DON", "DENON, Ltd." }, + { "DOT", "Dotronic Mikroelektronik GmbH" }, + { "DPA", "DigiTalk Pro AV" }, + { "DPC", "Delta Electronics Inc" }, + { "DPH", "Delphi Automotive LLP" }, + { "DPI", "DocuPoint" }, + { "DPL", "Digital Projection Limited" }, + { "DPM", "ADPM Synthesis sas" }, + { "DPN", "Shanghai Lexiang Technology Limited" }, + { "DPS", "Digital Processing Systems" }, + { "DPT", "DPT" }, + { "DPX", "DpiX, Inc." }, + { "DQB", "Datacube Inc" }, + { "DRB", "Dr. Bott KG" }, + { "DRC", "Data Ray Corp." }, + { "DRD", "DIGITAL REFLECTION INC." }, + { "DRI", "Data Race Inc" }, + { "DRS", "DRS Defense Solutions, LLC" }, + { "DSA", "Display Solution AG" }, + { "DSD", "DS Multimedia Pte Ltd" }, + { "DSG", "Disguise Technologies" }, + { "DSI", "Digitan Systems Inc" }, + { "DSJ", "VR Technology Holdings Limited" }, + { "DSM", "DSM Digital Services GmbH" }, + { "DSP", "Domain Technology Inc" }, + { "DTA", "DELTATEC" }, + { "DTC", "DTC Tech Corporation" }, + { "DTE", "Dimension Technologies, Inc." }, + { "DTI", "Diversified Technology, Inc." }, + { "DTK", "Dynax Electronics (HK) Ltd" }, + { "DTL", "e-Net Inc" }, + { "DTN", "Datang Telephone Co" }, + { "DTO", "Deutsche Thomson OHG" }, + { "DTT", "Design & Test Technology, Inc." }, + { "DTX", "Data Translation" }, + { "DUA", "Dosch & Amand GmbH & Company KG" }, + { "DUN", "NCR Corporation" }, + { "DVD", "Dictaphone Corporation" }, + { "DVL", "Devolo AG" }, + { "DVS", "Digital Video System" }, + { "DVT", "Data Video" }, + { "DWE", "Daewoo Electronics Company Ltd" }, + { "DXC", "Digipronix Control Systems" }, + { "DXD", "DECIMATOR DESIGN PTY LTD" }, + { "DXL", "Dextera Labs Inc" }, + { "DXP", "Data Expert Corporation" }, + { "DXS", "Signet" }, + { "DYC", "Dycam Inc" }, + { "DYM", "Dymo-CoStar Corporation" }, + { "DYN", "Askey Computer Corporation" }, + { "DYX", "Dynax Electronics (HK) Ltd" }, + { "EAG", "ELTEC Elektronik AG" }, + { "EAS", "Evans and Sutherland Computer" }, + { "EBH", "Data Price Informatica" }, + { "EBS", "EBS Euchner Büro- und Schulsysteme GmbH" }, + { "EBT", "HUALONG TECHNOLOGY CO., LTD" }, + { "ECA", "Electro Cam Corp." }, + { "ECC", "ESSential Comm. Corporation" }, + { "ECH", "EchoStar Corporation" }, + { "ECI", "Enciris Technologies" }, + { "ECK", "Eugene Chukhlomin Sole Proprietorship, d.b.a." }, + { "ECL", "Excel Company Ltd" }, + { "ECM", "E-Cmos Tech Corporation" }, + { "ECO", "Echo Speech Corporation" }, + { "ECP", "Elecom Company Ltd" }, + { "ECS", "Elitegroup Computer Systems Company Ltd" }, + { "ECT", "Enciris Technologies" }, + { "EDC", "e.Digital Corporation" }, + { "EDG", "Electronic-Design GmbH" }, + { "EDI", "Edimax Tech. Company Ltd" }, + { "EDM", "EDMI" }, + { "EDT", "Emerging Display Technologies Corp" }, + { "EEE", "ET&T Technology Company Ltd" }, + { "EEH", "EEH Datalink GmbH" }, + { "EEP", "E.E.P.D. GmbH" }, + { "EES", "EE Solutions, Inc." }, + { "EGA", "Elgato Systems LLC" }, + { "EGD", "EIZO GmbH Display Technologies" }, + { "EGL", "Eagle Technology" }, + { "EGN", "Egenera, Inc." }, + { "EGO", "Ergo Electronics" }, + { "EHJ", "Epson Research" }, + { "EHN", "Enhansoft" }, + { "EIC", "Eicon Technology Corporation" }, + { "EIN", "Elegant Invention" }, + { "EKA", "MagTek Inc." }, + { "EKC", "Eastman Kodak Company" }, + { "EKS", "EKSEN YAZILIM" }, + { "ELA", "ELAD srl" }, + { "ELC", "Electro Scientific Ind" }, + { "ELD", "Express Luck, Inc." }, + { "ELE", "Elecom Company Ltd" }, + { "ELG", "Elmeg GmbH Kommunikationstechnik" }, + { "ELI", "Edsun Laboratories" }, + { "ELL", "Electrosonic Ltd" }, + { "ELM", "Elmic Systems Inc" }, + { "ELO", "Elo TouchSystems Inc" }, + { "ELS", "ELSA GmbH" }, + { "ELT", "Element Labs, Inc." }, + { "ELU", "Express Industrial, Ltd." }, + { "ELX", "Elonex PLC" }, + { "EMB", "Embedded computing inc ltd" }, + { "EMC", "eMicro Corporation" }, + { "EMD", "Embrionix Design Inc." }, + { "EME", "EMiNE TECHNOLOGY COMPANY, LTD." }, + { "EMG", "EMG Consultants Inc" }, + { "EMI", "Ex Machina Inc" }, + { "EMK", "Emcore Corporation" }, + { "EMO", "ELMO COMPANY, LIMITED" }, + { "EMU", "Emulex Corporation" }, + { "ENC", "Eizo Nanao Corporation" }, + { "END", "ENIDAN Technologies Ltd" }, + { "ENE", "ENE Technology Inc." }, + { "ENI", "Efficient Networks" }, + { "ENS", "Ensoniq Corporation" }, + { "ENT", "Enterprise Comm. & Computing Inc" }, + { "EON", "Eon Instrumentation, Inc." }, + { "EPC", "Empac" }, + { "EPH", "Epiphan Systems Inc." }, + { "EPI", "Envision Peripherals, Inc" }, + { "EPN", "EPiCON Inc." }, + { "EPS", "KEPS" }, + { "EQP", "Equipe Electronics Ltd." }, + { "EQX", "Equinox Systems Inc" }, + { "ERG", "Ergo System" }, + { "ERI", "Ericsson Mobile Communications AB" }, + { "ERN", "Ericsson, Inc." }, + { "ERP", "Euraplan GmbH" }, + { "ERS", "Eizo Rugged Solutions" }, + { "ERT", "Escort Insturments Corporation" }, + { "ESA", "Elbit Systems of America" }, + { "ESB", "Esterline Belgium BVBA" }, + { "ESC", "Eden Sistemas de Computacao S/A" }, + { "ESD", "Ensemble Designs, Inc" }, + { "ESG", "ELCON Systemtechnik GmbH" }, + { "ESI", "Extended Systems, Inc." }, + { "ESK", "ES&S" }, + { "ESL", "Esterline Technologies" }, + { "ESN", "eSATURNUS" }, + { "ESS", "ESS Technology Inc" }, + { "EST", "Embedded Solution Technology" }, + { "ESY", "E-Systems Inc" }, + { "ETC", "Everton Technology Company Ltd" }, + { "ETD", "ELAN MICROELECTRONICS CORPORATION" }, + { "ETH", "Etherboot Project" }, + { "ETI", "Eclipse Tech Inc" }, + { "ETK", "eTEK Labs Inc." }, + { "ETL", "Evertz Microsystems Ltd." }, + { "ETS", "Electronic Trade Solutions Ltd" }, + { "ETT", "E-Tech Inc" }, + { "EUT", "Ericsson Mobile Networks B.V." }, + { "EVE", "Advanced Micro Peripherals Ltd" }, + { "EVI", "eviateg GmbH" }, + { "EVX", "Everex" }, + { "EXA", "Exabyte" }, + { "EXC", "Excession Audio" }, + { "EXI", "Exide Electronics" }, + { "EXN", "RGB Systems, Inc. dba Extron Electronics" }, + { "EXP", "Data Export Corporation" }, + { "EXR", "Explorer Inc." }, + { "EXT", "Exatech Computadores & Servicos Ltda" }, + { "EXX", "Exxact GmbH" }, + { "EXY", "Exterity Ltd" }, + { "EYE", "eyevis GmbH" }, + { "EYF", "eyefactive Gmbh" }, + { "EZE", "EzE Technologies" }, + { "EZP", "Storm Technology" }, + { "FAN", "Fantalooks Co., Ltd." }, + { "FAR", "Farallon Computing" }, + { "FBI", "Interface Corporation" }, + { "FCB", "Furukawa Electric Company Ltd" }, + { "FCG", "First International Computer Ltd" }, + { "FCS", "Focus Enhancements, Inc." }, + { "FDC", "Future Domain" }, + { "FDD", "Forth Dimension Displays Ltd" }, + { "FDI", "Future Designs, Inc." }, + { "FDT", "Fujitsu Display Technologies Corp." }, + { "FDX", "Findex, Inc." }, + { "FEC", "FURUNO ELECTRIC CO., LTD." }, + { "FEL", "Fellowes & Questec" }, + { "FEN", "Fen Systems Ltd." }, + { "FER", "Ferranti Int'L" }, + { "FFC", "FUJIFILM Corporation" }, + { "FFI", "Fairfield Industries" }, + { "FGD", "Lisa Draexlmaier GmbH" }, + { "FGL", "Fujitsu General Limited." }, + { "FHL", "FHLP" }, + { "FIC", "Formosa Industrial Computing Inc" }, + { "FIL", "Forefront Int'l Ltd" }, + { "FIN", "Finecom Co., Ltd." }, + { "FIR", "Chaplet Systems Inc" }, + { "FIS", "FLY-IT Simulators" }, + { "FIT", "Feature Integration Technology Inc." }, + { "FJC", "Fujitsu Takamisawa Component Limited" }, + { "FJS", "Fujitsu Spain" }, + { "FJT", "F.J. Tieman BV" }, + { "FLE", "ADTI Media, Inc" }, + { "FLI", "Faroudja Laboratories" }, + { "FLY", "Butterfly Communications" }, + { "FMA", "Fast Multimedia AG" }, + { "FMC", "Ford Microelectronics Inc" }, + { "FMI", "Fellowes, Inc." }, + { "FML", "Fujitsu Microelect Ltd" }, + { "FMZ", "Formoza-Altair" }, + { "FNC", "Fanuc LTD" }, + { "FNI", "Funai Electric Co., Ltd." }, + { "FOA", "FOR-A Company Limited" }, + { "FOK", "Fokus Technologies GmbH" }, + { "FOS", "Foss Tecator" }, + { "FOV", "FOVE INC" }, + { "FOX", "HON HAI PRECISON IND.CO.,LTD." }, + { "FPC", "Fingerprint Cards AB" }, + { "FPE", "Fujitsu Peripherals Ltd" }, + { "FPS", "Deltec Corporation" }, + { "FPX", "Cirel Systemes" }, + { "FRC", "Force Computers" }, + { "FRD", "Freedom Scientific BLV" }, + { "FRE", "Forvus Research Inc" }, + { "FRI", "Fibernet Research Inc" }, + { "FRO", "FARO Technologies" }, + { "FRS", "South Mountain Technologies, LTD" }, + { "FSC", "Future Systems Consulting KK" }, + { "FSI", "Fore Systems Inc" }, + { "FST", "Modesto PC Inc" }, + { "FTC", "Futuretouch Corporation" }, + { "FTE", "Frontline Test Equipment Inc." }, + { "FTG", "FTG Data Systems" }, + { "FTI", "FastPoint Technologies, Inc." }, + { "FTL", "FUJITSU TEN LIMITED" }, + { "FTN", "Fountain Technologies Inc" }, + { "FTR", "Mediasonic" }, + { "FTS", "FocalTech Systems Co., Ltd." }, + { "FTW", "MindTribe Product Engineering, Inc." }, + { "FUJ", "Fujitsu Ltd" }, + { "FUN", "sisel muhendislik" }, + { "FUS", "Fujitsu Siemens Computers GmbH" }, + { "FVC", "First Virtual Corporation" }, + { "FVX", "C-C-C Group Plc" }, + { "FWA", "Attero Tech, LLC" }, + { "FWR", "Flat Connections Inc" }, + { "FXX", "Fuji Xerox" }, + { "FZC", "Founder Group Shenzhen Co." }, + { "FZI", "FZI Forschungszentrum Informatik" }, + { "GAC", "GreenArrays, Inc." }, + { "GAG", "Gage Applied Sciences Inc" }, + { "GAL", "Galil Motion Control" }, + { "GAU", "Gaudi Co., Ltd." }, + { "GBT", "GIGA-BYTE TECHNOLOGY CO., LTD." }, + { "GCC", "GCC Technologies Inc" }, + { "GCI", "Gateway Comm. Inc" }, + { "GCS", "Grey Cell Systems Ltd" }, + { "GDC", "General Datacom" }, + { "GDI", "G. Diehl ISDN GmbH" }, + { "GDS", "GDS" }, + { "GDT", "Vortex Computersysteme GmbH" }, + { "GEC", "Gechic Corporation" }, + { "GED", "General Dynamics C4 Systems" }, + { "GEF", "GE Fanuc Embedded Systems" }, + { "GEH", "Abaco Systems, Inc." }, + { "GEM", "Gem Plus" }, + { "GEN", "Genesys ATE Inc" }, + { "GEO", "GEO Sense" }, + { "GER", "GERMANEERS GmbH" }, + { "GES", "GES Singapore Pte Ltd" }, + { "GET", "Getac Technology Corporation" }, + { "GFM", "GFMesstechnik GmbH" }, + { "GFN", "Gefen Inc." }, + { "GGL", "Google Inc." }, + { "GGT", "G2TOUCH KOREA" }, + { "GIC", "General Inst. Corporation" }, + { "GIM", "Guillemont International" }, + { "GIP", "GI Provision Ltd" }, + { "GIS", "AT&T Global Info Solutions" }, + { "GJN", "Grand Junction Networks" }, + { "GLD", "Goldmund - Digital Audio SA" }, + { "GLE", "AD electronics" }, + { "GLM", "Genesys Logic" }, + { "GLS", "Gadget Labs LLC" }, + { "GMK", "GMK Electronic Design GmbH" }, + { "GML", "General Information Systems" }, + { "GMM", "GMM Research Inc" }, + { "GMN", "GEMINI 2000 Ltd" }, + { "GMX", "GMX Inc" }, + { "GND", "Gennum Corporation" }, + { "GNN", "GN Nettest Inc" }, + { "GNZ", "Gunze Ltd" }, + { "GOE", "GOEPEL electronic GmbH" }, + { "GPR", "GoPro, Inc." }, + { "GRA", "Graphica Computer" }, + { "GRE", "GOLD RAIN ENTERPRISES CORP." }, + { "GRH", "Granch Ltd" }, + { "GRM", "Garmin International" }, + { "GRV", "Advanced Gravis" }, + { "GRY", "Robert Gray Company" }, + { "GSB", "NIPPONDENCHI CO,.LTD" }, + { "GSC", "General Standards Corporation" }, + { "GSM", "LG Electronics" }, + { "GSN", "Grandstream Networks, Inc." }, + { "GST", "Graphic SystemTechnology" }, + { "GSY", "Grossenbacher Systeme AG" }, + { "GTC", "Graphtec Corporation" }, + { "GTI", "Goldtouch" }, + { "GTK", "G-Tech Corporation" }, + { "GTM", "Garnet System Company Ltd" }, + { "GTS", "Geotest Marvin Test Systems Inc" }, + { "GTT", "General Touch Technology Co., Ltd." }, + { "GUD", "Guntermann & Drunck GmbH" }, + { "GUZ", "Guzik Technical Enterprises" }, + { "GVC", "GVC Corporation" }, + { "GVL", "Global Village Communication" }, + { "GWI", "GW Instruments" }, + { "GWK", "Gateworks Corporation" }, + { "GWY", "Gateway 2000" }, + { "GZE", "GUNZE Limited" }, + { "HAE", "Haider electronics" }, + { "HAI", "Haivision Systems Inc." }, + { "HAL", "Halberthal" }, + { "HAN", "Hanchang System Corporation" }, + { "HAR", "Harris Corporation" }, + { "HAY", "Hayes Microcomputer Products Inc" }, + { "HCA", "DAT" }, + { "HCE", "Hitachi Consumer Electronics Co., Ltd" }, + { "HCL", "HCL America Inc" }, + { "HCM", "HCL Peripherals" }, + { "HCP", "Hitachi Computer Products Inc" }, + { "HCW", "Hauppauge Computer Works Inc" }, + { "HDC", "HardCom Elektronik & Datateknik" }, + { "HDI", "HD-INFO d.o.o." }, + { "HDV", "Holografika kft." }, + { "HEC", "Hisense Electric Co., Ltd." }, + { "HEL", "Hitachi Micro Systems Europe Ltd" }, + { "HER", "Ascom Business Systems" }, + { "HET", "HETEC Datensysteme GmbH" }, + { "HHC", "HIRAKAWA HEWTECH CORP." }, + { "HHI", "Fraunhofer Heinrich-Hertz-Institute" }, + { "HIB", "Hibino Corporation" }, + { "HIC", "Hitachi Information Technology Co., Ltd." }, + { "HII", "Harman International Industries, Inc" }, + { "HIK", "Hikom Co., Ltd." }, + { "HIL", "Hilevel Technology" }, + { "HIQ", "Kaohsiung Opto Electronics Americas, Inc." }, + { "HIS", "Hope Industrial Systems, Inc." }, + { "HIT", "Hitachi America Ltd" }, + { "HJI", "Harris & Jeffries Inc" }, + { "HKA", "HONKO MFG. CO., LTD." }, + { "HKC", "HKC OVERSEAS LIMITED" }, + { "HKG", "Josef Heim KG" }, + { "HLG", "China Hualu Group Co., Ltd." }, + { "HMC", "Hualon Microelectric Corporation" }, + { "HMK", "hmk Daten-System-Technik BmbH" }, + { "HMX", "HUMAX Co., Ltd." }, + { "HNS", "Hughes Network Systems" }, + { "HOB", "HOB Electronic GmbH" }, + { "HOE", "Hosiden Corporation" }, + { "HOL", "Holoeye Photonics AG" }, + { "HON", "Sonitronix" }, + { "HPA", "Zytor Communications" }, + { "HPC", "Hewlett-Packard Co." }, + { "HPD", "Hewlett Packard" }, + { "HPE", "Hewlett Packard Enterprise" }, + { "HPI", "Headplay, Inc." }, + { "HPK", "HAMAMATSU PHOTONICS K.K." }, + { "HPN", "HP Inc." }, + { "HPQ", "Hewlett-Packard Co." }, + { "HPR", "H.P.R. Electronics GmbH" }, + { "HRC", "Hercules" }, + { "HRE", "Qingdao Haier Electronics Co., Ltd." }, + { "HRI", "Hall Research" }, + { "HRL", "Herolab GmbH" }, + { "HRS", "Harris Semiconductor" }, + { "HRT", "HERCULES" }, + { "HSC", "Hagiwara Sys-Com Company Ltd" }, + { "HSD", "HannStar Display Corp" }, + { "HSM", "AT&T Microelectronics" }, + { "HSP", "HannStar Display Corp" }, + { "HST", "Horsent Technology Co., Ltd." }, + { "HTC", "Hitachi Ltd" }, + { "HTI", "Hampshire Company, Inc." }, + { "HTK", "Holtek Microelectronics Inc" }, + { "HTL", "HTBLuVA Mödling" }, + { "HTR", "Shenzhen ZhuoYi HengTong Computer Technology Limited" }, + { "HTX", "Hitex Systementwicklung GmbH" }, + { "HUB", "GAI-Tronics, A Hubbell Company" }, + { "HUK", "Hoffmann + Krippner GmbH" }, + { "HUM", "IMP Electronics Ltd." }, + { "HVR", "HTC Corportation" }, + { "HWA", "Harris Canada Inc" }, + { "HWC", "DBA Hans Wedemeyer" }, + { "HWD", "Highwater Designs Ltd" }, + { "HWP", "Hewlett Packard" }, + { "HWV", "Huawei Technologies Co., Inc." }, + { "HXM", "Hexium Ltd." }, + { "HYC", "Hypercope Gmbh Aachen" }, + { "HYD", "Hydis Technologies.Co.,LTD" }, + { "HYL", "Shanghai Chai Ming Huang Info&Tech Co, Ltd" }, + { "HYO", "HYC CO., LTD." }, + { "HYP", "Hyphen Ltd" }, + { "HYR", "Hypertec Pty Ltd" }, + { "HYT", "Heng Yu Technology (HK) Limited" }, + { "HYV", "Hynix Semiconductor" }, + { "IAD", "IAdea Corporation" }, + { "IAF", "Institut f r angewandte Funksystemtechnik GmbH" }, + { "IAI", "Integration Associates, Inc." }, + { "IAT", "IAT Germany GmbH" }, + { "IBC", "Integrated Business Systems" }, + { "IBI", "INBINE.CO.LTD" }, + { "IBM", "IBM Brasil" }, + { "IBP", "IBP Instruments GmbH" }, + { "IBR", "IBR GmbH" }, + { "ICA", "ICA Inc" }, + { "ICC", "BICC Data Networks Ltd" }, + { "ICD", "ICD Inc" }, + { "ICE", "IC Ensemble" }, + { "ICI", "Infotek Communication Inc" }, + { "ICM", "Intracom SA" }, + { "ICN", "Sanyo Icon" }, + { "ICO", "Intel Corp" }, + { "ICP", "ICP Electronics, Inc./iEi Technology Corp." }, + { "ICR", "Icron" }, + { "ICS", "Integrated Circuit Systems" }, + { "ICV", "Inside Contactless" }, + { "ICX", "ICCC A/S" }, + { "IDC", "International Datacasting Corporation" }, + { "IDE", "IDE Associates" }, + { "IDK", "IDK Corporation" }, + { "IDN", "Idneo Technologies" }, + { "IDO", "IDEO Product Development" }, + { "IDP", "Integrated Device Technology, Inc." }, + { "IDS", "Interdigital Sistemas de Informacao" }, + { "IDT", "International Display Technology" }, + { "IDX", "IDEXX Labs" }, + { "IEC", "Interlace Engineering Corporation" }, + { "IEE", "IEE" }, + { "IEI", "Interlink Electronics" }, + { "IFS", "In Focus Systems Inc" }, + { "IFT", "Informtech" }, + { "IFX", "Infineon Technologies AG" }, + { "IFZ", "Infinite Z" }, + { "IGC", "Intergate Pty Ltd" }, + { "IGM", "IGM Communi" }, + { "IHE", "InHand Electronics" }, + { "IIC", "ISIC Innoscan Industrial Computers A/S" }, + { "III", "Intelligent Instrumentation" }, + { "IIN", "IINFRA Co., Ltd" }, + { "IIT", "Informatik Information Technologies" }, + { "IKE", "Ikegami Tsushinki Co. Ltd." }, + { "IKS", "Ikos Systems Inc" }, + { "ILC", "Image Logic Corporation" }, + { "ILS", "Innotech Corporation" }, + { "IMA", "Imagraph" }, + { "IMB", "ART s.r.l." }, + { "IMC", "IMC Networks" }, + { "IMD", "ImasDe Canarias S.A." }, + { "IME", "Imagraph" }, + { "IMF", "Immersive Audio Technologies France" }, + { "IMG", "IMAGENICS Co., Ltd." }, + { "IMI", "International Microsystems Inc" }, + { "IMM", "Immersion Corporation" }, + { "IMN", "Impossible Production" }, + { "IMP", "Impinj" }, + { "IMT", "Inmax Technology Corporation" }, + { "INA", "Inventec Corporation" }, + { "INC", "Home Row Inc" }, + { "IND", "ILC" }, + { "INE", "Inventec Electronics (M) Sdn. Bhd." }, + { "INF", "Inframetrics Inc" }, + { "ING", "Integraph Corporation" }, + { "INI", "Initio Corporation" }, + { "INK", "Indtek Co., Ltd." }, + { "INL", "InnoLux Display Corporation" }, + { "INM", "InnoMedia Inc" }, + { "INN", "Innovent Systems, Inc." }, + { "INO", "Innolab Pte Ltd" }, + { "INP", "Interphase Corporation" }, + { "INS", "Ines GmbH" }, + { "INT", "Interphase Corporation" }, + { "INU", "Inovatec S.p.A." }, + { "INV", "Inviso, Inc." }, + { "INX", "Communications Supply Corporation (A division of WESCO)" }, + { "INZ", "Best Buy" }, + { "IOA", "CRE Technology Corporation" }, + { "IOD", "I-O Data Device Inc" }, + { "IOM", "Iomega" }, + { "ION", "Inside Out Networks" }, + { "IOS", "i-O Display System" }, + { "IOT", "I/OTech Inc" }, + { "IPC", "IPC Corporation" }, + { "IPD", "Industrial Products Design, Inc." }, + { "IPI", "Intelligent Platform Management Interface (IPMI) forum (Intel, HP, NEC, Dell)" }, + { "IPM", "IPM Industria Politecnica Meridionale SpA" }, + { "IPN", "Performance Technologies" }, + { "IPP", "IP Power Technologies GmbH" }, + { "IPQ", "IP3 Technology Ltd." }, + { "IPR", "Ithaca Peripherals" }, + { "IPS", "IPS, Inc. (Intellectual Property Solutions, Inc.)" }, + { "IPT", "International Power Technologies" }, + { "IPW", "IPWireless, Inc" }, + { "IQI", "IneoQuest Technologies, Inc" }, + { "IQT", "IMAGEQUEST Co., Ltd" }, + { "IRD", "Irdata" }, + { "ISA", "Symbol Technologies" }, + { "ISC", "Id3 Semiconductors" }, + { "ISG", "Insignia Solutions Inc" }, + { "ISI", "Interface Solutions" }, + { "ISL", "Isolation Systems" }, + { "ISM", "Image Stream Medical" }, + { "ISP", "IntreSource Systems Pte Ltd" }, + { "ISR", "INSIS Co., LTD." }, + { "ISS", "ISS Inc" }, + { "IST", "Intersolve Technologies" }, + { "ISY", "International Integrated Systems,Inc.(IISI)" }, + { "ITA", "Itausa Export North America" }, + { "ITC", "Intercom Inc" }, + { "ITD", "Internet Technology Corporation" }, + { "ITE", "Integrated Tech Express Inc" }, + { "ITI", "VanErum Group" }, + { "ITK", "ITK Telekommunikation AG" }, + { "ITL", "Inter-Tel" }, + { "ITM", "ITM inc." }, + { "ITN", "The NTI Group" }, + { "ITP", "IT-PRO Consulting und Systemhaus GmbH" }, + { "ITR", "Infotronic America, Inc." }, + { "ITS", "IDTECH" }, + { "ITT", "I&T Telecom." }, + { "ITX", "integrated Technology Express Inc" }, + { "IUC", "ICSL" }, + { "IVI", "Intervoice Inc" }, + { "IVM", "Iiyama North America" }, + { "IVR", "Inlife-Handnet Co., Ltd." }, + { "IVS", "Intevac Photonics Inc." }, + { "IWR", "Icuiti Corporation" }, + { "IWX", "Intelliworxx, Inc." }, + { "IXD", "Intertex Data AB" }, + { "IXN", "Shenzhen Inet Mobile Internet Technology Co., LTD" }, + { "JAC", "Astec Inc" }, + { "JAE", "Japan Aviation Electronics Industry, Limited" }, + { "JAS", "Janz Automationssysteme AG" }, + { "JAT", "Jaton Corporation" }, + { "JAZ", "Carrera Computer Inc" }, + { "JCE", "Jace Tech Inc" }, + { "JDI", "Japan Display Inc." }, + { "JDL", "Japan Digital Laboratory Co.,Ltd." }, + { "JEM", "Japan E.M.Solutions Co., Ltd." }, + { "JEN", "N-Vision" }, + { "JET", "JET POWER TECHNOLOGY CO., LTD." }, + { "JFX", "Jones Futurex Inc" }, + { "JGD", "University College" }, + { "JIC", "Jaeik Information & Communication Co., Ltd." }, + { "JKC", "JVC KENWOOD Corporation" }, + { "JMT", "Micro Technical Company Ltd" }, + { "JPC", "JPC Technology Limited" }, + { "JPW", "Wallis Hamilton Industries" }, + { "JQE", "CNet Technical Inc" }, + { "JSD", "JS DigiTech, Inc" }, + { "JSI", "Jupiter Systems, Inc." }, + { "JSK", "SANKEN ELECTRIC CO., LTD" }, + { "JTS", "JS Motorsports" }, + { "JTY", "jetway security micro,inc" }, + { "JUK", "Janich & Klass Computertechnik GmbH" }, + { "JUP", "Jupiter Systems" }, + { "JVC", "JVC" }, + { "JWD", "Video International Inc." }, + { "JWL", "Jewell Instruments, LLC" }, + { "JWS", "JWSpencer & Co." }, + { "JWY", "Jetway Information Co., Ltd" }, + { "KAR", "Karna" }, + { "KBI", "Kidboard Inc" }, + { "KBL", "Kobil Systems GmbH" }, + { "KCD", "Chunichi Denshi Co.,LTD." }, + { "KCL", "Keycorp Ltd" }, + { "KDE", "KDE" }, + { "KDK", "Kodiak Tech" }, + { "KDM", "Korea Data Systems Co., Ltd." }, + { "KDS", "KDS USA" }, + { "KDT", "KDDI Technology Corporation" }, + { "KEC", "Kyushu Electronics Systems Inc" }, + { "KEM", "Kontron Embedded Modules GmbH" }, + { "KES", "Kesa Corporation" }, + { "KEU", "Kontron Europe GmbH" }, + { "KEY", "Key Tech Inc" }, + { "KFC", "SCD Tech" }, + { "KFE", "Komatsu Forest" }, + { "KFX", "Kofax Image Products" }, + { "KGI", "Klipsch Group, Inc" }, + { "KGL", "KEISOKU GIKEN Co.,Ltd." }, + { "KIO", "Kionix, Inc." }, + { "KIS", "KiSS Technology A/S" }, + { "KMC", "Mitsumi Company Ltd" }, + { "KME", "KIMIN Electronics Co., Ltd." }, + { "KML", "Kensington Microware Ltd" }, + { "KMR", "Kramer Electronics Ltd. International" }, + { "KNC", "Konica corporation" }, + { "KNX", "Nutech Marketing PTL" }, + { "KOB", "Kobil Systems GmbH" }, + { "KOD", "Eastman Kodak Company" }, + { "KOE", "KOLTER ELECTRONIC" }, + { "KOL", "Kollmorgen Motion Technologies Group" }, + { "KOM", "Kontron GmbH" }, + { "KOU", "KOUZIRO Co.,Ltd." }, + { "KOW", "KOWA Company,LTD." }, + { "KPC", "King Phoenix Company" }, + { "KPT", "TPK Holding Co., Ltd" }, + { "KRL", "Krell Industries Inc." }, + { "KRM", "Kroma Telecom" }, + { "KRY", "Kroy LLC" }, + { "KSC", "Kinetic Systems Corporation" }, + { "KSG", "KUPA China Shenzhen Micro Technology Co., Ltd. Gold Institute" }, + { "KSL", "Karn Solutions Ltd." }, + { "KSX", "King Tester Corporation" }, + { "KTC", "Kingston Tech Corporation" }, + { "KTD", "Takahata Electronics Co.,Ltd." }, + { "KTE", "K-Tech" }, + { "KTG", "Kayser-Threde GmbH" }, + { "KTI", "Konica Technical Inc" }, + { "KTK", "Key Tronic Corporation" }, + { "KTN", "Katron Tech Inc" }, + { "KTS", "Kyokko Communication System Co., Ltd." }, + { "KUR", "Kurta Corporation" }, + { "KVA", "Kvaser AB" }, + { "KVX", "KeyView" }, + { "KWD", "Kenwood Corporation" }, + { "KYC", "Kyocera Corporation" }, + { "KYE", "KYE Syst Corporation" }, + { "KYK", "Samsung Electronics America Inc" }, + { "KYN", "KEYENCE CORPORATION" }, + { "KZI", "K-Zone International co. Ltd." }, + { "KZN", "K-Zone International" }, + { "LAB", "ACT Labs Ltd" }, + { "LAC", "LaCie" }, + { "LAF", "Microline" }, + { "LAG", "Laguna Systems" }, + { "LAN", "Sodeman Lancom Inc" }, + { "LAS", "LASAT Comm. A/S" }, + { "LAV", "Lava Computer MFG Inc" }, + { "LBO", "Lubosoft" }, + { "LCC", "LCI" }, + { "LCD", "Toshiba Matsushita Display Technology Co., Ltd" }, + { "LCE", "La Commande Electronique" }, + { "LCI", "Lite-On Communication Inc" }, + { "LCM", "Latitude Comm." }, + { "LCN", "LEXICON" }, + { "LCS", "Longshine Electronics Company" }, + { "LCT", "Labcal Technologies" }, + { "LDN", "Laserdyne Technologies" }, + { "LDT", "LogiDataTech Electronic GmbH" }, + { "LEC", "Lectron Company Ltd" }, + { "LED", "Long Engineering Design Inc" }, + { "LEG", "Legerity, Inc" }, + { "LEN", "Lenovo Group Limited" }, + { "LEO", "First International Computer Inc" }, + { "LEX", "Lexical Ltd" }, + { "LGC", "Logic Ltd" }, + { "LGI", "Logitech Inc" }, + { "LGS", "LG Semicom Company Ltd" }, + { "LGX", "Lasergraphics, Inc." }, + { "LHA", "Lars Haagh ApS" }, + { "LHC", "Beihai Century Joint Innovation Technology Co.,Ltd" }, + { "LHE", "Lung Hwa Electronics Company Ltd" }, + { "LHT", "Lighthouse Technologies Limited" }, + { "LIN", "Lenovo Beijing Co. Ltd." }, + { "LIP", "Linked IP GmbH" }, + { "LIT", "Lithics Silicon Technology" }, + { "LJX", "Datalogic Corporation" }, + { "LKM", "Likom Technology Sdn. Bhd." }, + { "LLL", "L-3 Communications" }, + { "LMG", "Lucent Technologies" }, + { "LMI", "Lexmark Int'l Inc" }, + { "LMP", "Leda Media Products" }, + { "LMT", "Laser Master" }, + { "LND", "Land Computer Company Ltd" }, + { "LNK", "Link Tech Inc" }, + { "LNR", "Linear Systems Ltd." }, + { "LNT", "LANETCO International" }, + { "LNV", "Lenovo" }, + { "LNX", "The Linux Foundation" }, + { "LOC", "Locamation B.V." }, + { "LOE", "Loewe Opta GmbH" }, + { "LOG", "Logicode Technology Inc" }, + { "LOL", "Litelogic Operations Ltd" }, + { "LPE", "El-PUSK Co., Ltd." }, + { "LPI", "Design Technology" }, + { "LPL", "LG Philips" }, + { "LSC", "LifeSize Communications" }, + { "LSD", "Intersil Corporation" }, + { "LSI", "Loughborough Sound Images" }, + { "LSJ", "LSI Japan Company Ltd" }, + { "LSL", "Logical Solutions" }, + { "LSP", "Lightspace Technologies" }, + { "LSY", "LSI Systems Inc" }, + { "LTC", "Labtec Inc" }, + { "LTI", "Jongshine Tech Inc" }, + { "LTK", "Lucidity Technology Company Ltd" }, + { "LTN", "Litronic Inc" }, + { "LTS", "LTS Scale LLC" }, + { "LTV", "Leitch Technology International Inc." }, + { "LTW", "Lightware, Inc" }, + { "LUC", "Lucent Technologies" }, + { "LUM", "Lumagen, Inc." }, + { "LUX", "Luxxell Research Inc" }, + { "LVI", "LVI Low Vision International AB" }, + { "LWC", "Labway Corporation" }, + { "LWR", "Lightware Visual Engineering" }, + { "LWW", "Lanier Worldwide" }, + { "LXC", "LXCO Technologies AG" }, + { "LXN", "Luxeon" }, + { "LXS", "ELEA CardWare" }, + { "LZX", "Lightwell Company Ltd" }, + { "MAC", "MAC System Company Ltd" }, + { "MAD", "Xedia Corporation" }, + { "MAE", "Maestro Pty Ltd" }, + { "MAG", "MAG InnoVision" }, + { "MAI", "Mutoh America Inc" }, + { "MAL", "Meridian Audio Ltd" }, + { "MAN", "LGIC" }, + { "MAS", "Mass Inc." }, + { "MAT", "Matsushita Electric Ind. Company Ltd" }, + { "MAX", "Rogen Tech Distribution Inc" }, + { "MAY", "Maynard Electronics" }, + { "MAZ", "MAZeT GmbH" }, + { "MBC", "MBC" }, + { "MBD", "Microbus PLC" }, + { "MBM", "Marshall Electronics" }, + { "MBV", "Moreton Bay" }, + { "MCA", "American Nuclear Systems Inc" }, + { "MCC", "Micro Industries" }, + { "MCD", "McDATA Corporation" }, + { "MCE", "Metz-Werke GmbH & Co KG" }, + { "MCG", "Motorola Computer Group" }, + { "MCI", "Micronics Computers" }, + { "MCJ", "Medicaroid Corporation" }, + { "MCL", "Motorola Communications Israel" }, + { "MCM", "Metricom Inc" }, + { "MCN", "Micron Electronics Inc" }, + { "MCO", "Motion Computing Inc." }, + { "MCP", "Magni Systems Inc" }, + { "MCQ", "Mat's Computers" }, + { "MCR", "Marina Communicaitons" }, + { "MCS", "Micro Computer Systems" }, + { "MCT", "Microtec" }, + { "MCX", "Millson Custom Solutions Inc." }, + { "MDA", "Media4 Inc" }, + { "MDC", "Midori Electronics" }, + { "MDD", "MODIS" }, + { "MDF", "MILDEF AB" }, + { "MDG", "Madge Networks" }, + { "MDI", "Micro Design Inc" }, + { "MDK", "Mediatek Corporation" }, + { "MDO", "Panasonic" }, + { "MDR", "Medar Inc" }, + { "MDS", "Micro Display Systems Inc" }, + { "MDT", "Magus Data Tech" }, + { "MDV", "MET Development Inc" }, + { "MDX", "MicroDatec GmbH" }, + { "MDY", "Microdyne Inc" }, + { "MEC", "Mega System Technologies Inc" }, + { "MED", "Messeltronik Dresden GmbH" }, + { "MEE", "Mitsubishi Electric Engineering Co., Ltd." }, + { "MEG", "Abeam Tech Ltd." }, + { "MEI", "Panasonic Industry Company" }, + { "MEJ", "Mac-Eight Co., LTD." }, + { "MEK", "Mediaedge Corporation" }, + { "MEL", "Mitsubishi Electric Corporation" }, + { "MEN", "MEN Mikroelectronik Nueruberg GmbH" }, + { "MEP", "Meld Technology" }, + { "MEQ", "Matelect Ltd." }, + { "MET", "Metheus Corporation" }, + { "MEU", "MPL AG, Elektronik-Unternehmen" }, + { "MEX", "MSC Vertriebs GmbH" }, + { "MFG", "MicroField Graphics Inc" }, + { "MFI", "Micro Firmware" }, + { "MFR", "MediaFire Corp." }, + { "MGA", "Mega System Technologies, Inc." }, + { "MGC", "Mentor Graphics Corporation" }, + { "MGE", "Schneider Electric S.A." }, + { "MGL", "M-G Technology Ltd" }, + { "MGT", "Megatech R & D Company" }, + { "MHQ", "Moxa Inc." }, + { "MIC", "Micom Communications Inc" }, + { "MID", "miro Displays" }, + { "MII", "Mitec Inc" }, + { "MIL", "Marconi Instruments Ltd" }, + { "MIM", "Mimio – A Newell Rubbermaid Company" }, + { "MIN", "Minicom Digital Signage" }, + { "MIP", "micronpc.com" }, + { "MIR", "Miro Computer Prod." }, + { "MIS", "Modular Industrial Solutions Inc" }, + { "MIT", "MCM Industrial Technology GmbH" }, + { "MIV", "MicroImage Video Systems" }, + { "MJI", "MARANTZ JAPAN, INC." }, + { "MJS", "MJS Designs" }, + { "MKC", "Media Tek Inc." }, + { "MKS", "MK Seiko Co., Ltd." }, + { "MKT", "MICROTEK Inc." }, + { "MKV", "Trtheim Technology" }, + { "MLC", "MILCOTS" }, + { "MLD", "Deep Video Imaging Ltd" }, + { "MLG", "Micrologica AG" }, + { "MLI", "McIntosh Laboratory Inc." }, + { "MLL", "Millogic Ltd." }, + { "MLM", "Millennium Engineering Inc" }, + { "MLN", "Mark Levinson" }, + { "MLP", "Magic Leap" }, + { "MLS", "Milestone EPE" }, + { "MLT", "Wanlida Group Co., Ltd." }, + { "MLX", "Mylex Corporation" }, + { "MMA", "Micromedia AG" }, + { "MMD", "Micromed Biotecnologia Ltd" }, + { "MMF", "Minnesota Mining and Manufacturing" }, + { "MMI", "Multimax" }, + { "MMM", "Electronic Measurements" }, + { "MMN", "MiniMan Inc" }, + { "MMS", "MMS Electronics" }, + { "MMT", "MIMO Monitors" }, + { "MNC", "Mini Micro Methods Ltd" }, + { "MNI", "Marseille, Inc." }, + { "MNL", "Monorail Inc" }, + { "MNP", "Microcom" }, + { "MOC", "Matrix Orbital Corporation" }, + { "MOD", "Modular Technology" }, + { "MOM", "Momentum Data Systems" }, + { "MOS", "Moses Corporation" }, + { "MOT", "Motorola UDS" }, + { "MPC", "M-Pact Inc" }, + { "MPI", "Mediatrix Peripherals Inc" }, + { "MPJ", "Microlab" }, + { "MPL", "Maple Research Inst. Company Ltd" }, + { "MPN", "Mainpine Limited" }, + { "MPS", "mps Software GmbH" }, + { "MPV", "Megapixel Visual Realty" }, + { "MPX", "Micropix Technologies, Ltd." }, + { "MQP", "MultiQ Products AB" }, + { "MRA", "Miranda Technologies Inc" }, + { "MRC", "Marconi Simulation & Ty-Coch Way Training" }, + { "MRD", "MicroDisplay Corporation" }, + { "MRK", "Maruko & Company Ltd" }, + { "MRL", "Miratel" }, + { "MRO", "Medikro Oy" }, + { "MRT", "Merging Technologies" }, + { "MSA", "Micro Systemation AB" }, + { "MSC", "Mouse Systems Corporation" }, + { "MSD", "Datenerfassungs- und Informationssysteme" }, + { "MSF", "M-Systems Flash Disk Pioneers" }, + { "MSG", "MSI GmbH" }, + { "MSH", "Microsoft" }, + { "MSI", "Microstep" }, + { "MSK", "Megasoft Inc" }, + { "MSL", "MicroSlate Inc." }, + { "MSM", "Advanced Digital Systems" }, + { "MSP", "Mistral Solutions [P] Ltd." }, + { "MSR", "MASPRO DENKOH Corp." }, + { "MST", "MS Telematica" }, + { "MSU", "motorola" }, + { "MSV", "Mosgi Corporation" }, + { "MSX", "Micomsoft Co., Ltd." }, + { "MSY", "MicroTouch Systems Inc" }, + { "MTA", "Meta Watch Ltd" }, + { "MTB", "Media Technologies Ltd." }, + { "MTC", "Mars-Tech Corporation" }, + { "MTD", "MindTech Display Co. Ltd" }, + { "MTE", "MediaTec GmbH" }, + { "MTH", "Micro-Tech Hearing Instruments" }, + { "MTI", "MaxCom Technical Inc" }, + { "MTJ", "MicroTechnica Co.,Ltd." }, + { "MTK", "Microtek International Inc." }, + { "MTL", "Mitel Corporation" }, + { "MTM", "Motium" }, + { "MTN", "Mtron Storage Technology Co., Ltd." }, + { "MTR", "Mitron computer Inc" }, + { "MTS", "Multi-Tech Systems" }, + { "MTU", "Mark of the Unicorn Inc" }, + { "MTX", "Matrox" }, + { "MUD", "Multi-Dimension Institute" }, + { "MUK", "Mainpine Limited" }, + { "MVD", "Microvitec PLC" }, + { "MVI", "Media Vision Inc" }, + { "MVM", "SOBO VISION" }, + { "MVN", "Meta Company" }, + { "MVR", "MediCapture, Inc." }, + { "MVS", "Microvision" }, + { "MVX", "COM 1" }, + { "MWI", "Multiwave Innovation Pte Ltd" }, + { "MWR", "mware" }, + { "MWY", "Microway Inc" }, + { "MXD", "MaxData Computer GmbH & Co.KG" }, + { "MXI", "Macronix Inc" }, + { "MXL", "Hitachi Maxell, Ltd." }, + { "MXP", "Maxpeed Corporation" }, + { "MXT", "Maxtech Corporation" }, + { "MXV", "MaxVision Corporation" }, + { "MYA", "Monydata" }, + { "MYR", "Myriad Solutions Ltd" }, + { "MYX", "Micronyx Inc" }, + { "NAC", "Ncast Corporation" }, + { "NAD", "NAD Electronics" }, + { "NAK", "Nakano Engineering Co.,Ltd." }, + { "NAL", "Network Alchemy" }, + { "NAT", "NaturalPoint Inc." }, + { "NAV", "Navigation Corporation" }, + { "NAX", "Naxos Tecnologia" }, + { "NBL", "N*Able Technologies Inc" }, + { "NBS", "National Key Lab. on ISN" }, + { "NBT", "NingBo Bestwinning Technology CO., Ltd" }, + { "NCA", "Nixdorf Company" }, + { "NCC", "NCR Corporation" }, + { "NCE", "Norcent Technology, Inc." }, + { "NCI", "NewCom Inc" }, + { "NCL", "NetComm Ltd" }, + { "NCP", "Najing CEC Panda FPD Technology CO. ltd" }, + { "NCR", "NCR Electronics" }, + { "NCS", "Northgate Computer Systems" }, + { "NCT", "NEC CustomTechnica, Ltd." }, + { "NDC", "National DataComm Corporaiton" }, + { "NDF", "NDF Special Light Products B.V." }, + { "NDI", "National Display Systems" }, + { "NDK", "Naitoh Densei CO., LTD." }, + { "NDL", "Network Designers" }, + { "NDS", "Nokia Data" }, + { "NEC", "NEC Corporation" }, + { "NEO", "NEO TELECOM CO.,LTD." }, + { "NES", "INNES" }, + { "NET", "Mettler Toledo" }, + { "NEU", "NEUROTEC - EMPRESA DE PESQUISA E DESENVOLVIMENTO EM BIOMEDICINA" }, + { "NEX", "Nexgen Mediatech Inc.," }, + { "NFC", "BTC Korea Co., Ltd" }, + { "NFS", "Number Five Software" }, + { "NGC", "Network General" }, + { "NGS", "A D S Exports" }, + { "NHT", "Vinci Labs" }, + { "NIC", "National Instruments Corporation" }, + { "NIS", "Nissei Electric Company" }, + { "NIT", "Network Info Technology" }, + { "NIX", "Seanix Technology Inc" }, + { "NLC", "Next Level Communications" }, + { "NME", "Navico, Inc." }, + { "NMP", "Nokia Mobile Phones" }, + { "NMS", "Natural Micro System" }, + { "NMV", "NEC-Mitsubishi Electric Visual Systems Corporation" }, + { "NMX", "Neomagic" }, + { "NNC", "NNC" }, + { "NOD", "3NOD Digital Technology Co. Ltd." }, + { "NOE", "NordicEye AB" }, + { "NOI", "North Invent A/S" }, + { "NOK", "Nokia Display Products" }, + { "NOR", "Norand Corporation" }, + { "NOT", "Not Limited Inc" }, + { "NPA", "Arvanics" }, + { "NPI", "Network Peripherals Inc" }, + { "NRI", "Noritake Itron Corporation" }, + { "NRL", "U.S. Naval Research Lab" }, + { "NRT", "Beijing Northern Radiantelecom Co." }, + { "NRV", "Taugagreining hf" }, + { "NSA", "NeuroSky, Inc." }, + { "NSC", "National Semiconductor Corporation" }, + { "NSI", "NISSEI ELECTRIC CO.,LTD" }, + { "NSP", "Nspire System Inc." }, + { "NSS", "Newport Systems Solutions" }, + { "NST", "Network Security Technology Co" }, + { "NTC", "NeoTech S.R.L" }, + { "NTI", "New Tech Int'l Company" }, + { "NTK", "NewTek" }, + { "NTL", "National Transcomm. Ltd" }, + { "NTN", "Nuvoton Technology Corporation" }, + { "NTR", "N-trig Innovative Technologies, Inc." }, + { "NTS", "Nits Technology Inc." }, + { "NTT", "NTT Advanced Technology Corporation" }, + { "NTW", "Networth Inc" }, + { "NTX", "Netaccess Inc" }, + { "NUG", "NU Technology, Inc." }, + { "NUI", "NU Inc." }, + { "NVC", "NetVision Corporation" }, + { "NVD", "Nvidia" }, + { "NVI", "NuVision US, Inc." }, + { "NVL", "Novell Inc" }, + { "NVT", "Navatek Engineering Corporation" }, + { "NWC", "NW Computer Engineering" }, + { "NWL", "Newline Interactive Inc." }, + { "NWP", "NovaWeb Technologies Inc" }, + { "NWS", "Newisys, Inc." }, + { "NXC", "NextCom K.K." }, + { "NXG", "Nexgen" }, + { "NXP", "NXP Semiconductors bv." }, + { "NXQ", "Nexiq Technologies, Inc." }, + { "NXS", "Technology Nexus Secure Open Systems AB" }, + { "NXT", "NZXT (PNP same EDID)_" }, + { "NYC", "Nakayo Relecommunications, Inc." }, + { "OAK", "Oak Tech Inc" }, + { "OAS", "Oasys Technology Company" }, + { "OBS", "Optibase Technologies" }, + { "OCD", "Macraigor Systems Inc" }, + { "OCN", "Olfan" }, + { "OCS", "Open Connect Solutions" }, + { "ODM", "ODME Inc." }, + { "ODR", "Odrac" }, + { "OEC", "ORION ELECTRIC CO.,LTD" }, + { "OEI", "Optum Engineering Inc." }, + { "OHW", "M-Labs Limited" }, + { "OIC", "Option Industrial Computers" }, + { "OIM", "Option International" }, + { "OIN", "Option International" }, + { "OKI", "OKI Electric Industrial Company Ltd" }, + { "OLC", "Olicom A/S" }, + { "OLD", "Olidata S.p.A." }, + { "OLI", "Olivetti" }, + { "OLT", "Olitec S.A." }, + { "OLV", "Olitec S.A." }, + { "OLY", "OLYMPUS CORPORATION" }, + { "OMC", "OBJIX Multimedia Corporation" }, + { "OMN", "Omnitel" }, + { "OMR", "Omron Corporation" }, + { "ONE", "Oneac Corporation" }, + { "ONK", "ONKYO Corporation" }, + { "ONL", "OnLive, Inc" }, + { "ONS", "On Systems Inc" }, + { "ONW", "OPEN Networks Ltd" }, + { "ONX", "SOMELEC Z.I. Du Vert Galanta" }, + { "OOS", "OSRAM" }, + { "OPC", "Opcode Inc" }, + { "OPI", "D.N.S. Corporation" }, + { "OPP", "OPPO Digital, Inc." }, + { "OPT", "OPTi Inc" }, + { "OPV", "Optivision Inc" }, + { "OQI", "Oksori Company Ltd" }, + { "ORG", "ORGA Kartensysteme GmbH" }, + { "ORI", "OSR Open Systems Resources, Inc." }, + { "ORN", "ORION ELECTRIC CO., LTD." }, + { "OSA", "OSAKA Micro Computer, Inc." }, + { "OSD", "Optical Systems Design Pty Ltd" }, + { "OSI", "Open Stack, Inc." }, + { "OSP", "OPTI-UPS Corporation" }, + { "OSR", "Oksori Company Ltd" }, + { "OTB", "outsidetheboxstuff.com" }, + { "OTI", "Orchid Technology" }, + { "OTK", "OmniTek" }, + { "OTM", "Optoma Corporation" }, + { "OTT", "OPTO22, Inc." }, + { "OUK", "OUK Company Ltd" }, + { "OVR", "Oculus VR, Inc." }, + { "OWL", "Mediacom Technologies Pte Ltd" }, + { "OXU", "Oxus Research S.A." }, + { "OYO", "Shadow Systems" }, + { "OZC", "OZ Corporation" }, + { "OZO", "Tribe Computer Works Inc" }, + { "PAC", "Pacific Avionics Corporation" }, + { "PAD", "Promotion and Display Technology Ltd." }, + { "PAK", "Many CNC System Co., Ltd." }, + { "PAM", "Peter Antesberger Messtechnik" }, + { "PAN", "The Panda Project" }, + { "PAR", "Parallan Comp Inc" }, + { "PBI", "Pitney Bowes" }, + { "PBL", "Packard Bell Electronics" }, + { "PBN", "Packard Bell NEC" }, + { "PBV", "Pitney Bowes" }, + { "PCA", "Philips BU Add On Card" }, + { "PCB", "OCTAL S.A." }, + { "PCC", "PowerCom Technology Company Ltd" }, + { "PCG", "First Industrial Computer Inc" }, + { "PCI", "Pioneer Computer Inc" }, + { "PCK", "PCBANK21" }, + { "PCL", "pentel.co.,ltd" }, + { "PCM", "PCM Systems Corporation" }, + { "PCO", "Performance Concepts Inc.," }, + { "PCP", "Procomp USA Inc" }, + { "PCS", "TOSHIBA PERSONAL COMPUTER SYSTEM CORPRATION" }, + { "PCT", "PC-Tel Inc" }, + { "PCW", "Pacific CommWare Inc" }, + { "PCX", "PC Xperten" }, + { "PDM", "Psion Dacom Plc." }, + { "PDN", "AT&T Paradyne" }, + { "PDR", "Pure Data Inc" }, + { "PDS", "PD Systems International Ltd" }, + { "PDT", "PDTS - Prozessdatentechnik und Systeme" }, + { "PDV", "Prodrive B.V." }, + { "PEC", "POTRANS Electrical Corp." }, + { "PEG", "Pegatron Corporation" }, + { "PEI", "PEI Electronics Inc" }, + { "PEL", "Primax Electric Ltd" }, + { "PEN", "Interactive Computer Products Inc" }, + { "PEP", "Peppercon AG" }, + { "PER", "Perceptive Signal Technologies" }, + { "PET", "Practical Electronic Tools" }, + { "PFT", "Telia ProSoft AB" }, + { "PGI", "PACSGEAR, Inc." }, + { "PGM", "Paradigm Advanced Research Centre" }, + { "PGP", "propagamma kommunikation" }, + { "PGS", "Princeton Graphic Systems" }, + { "PHC", "Pijnenburg Beheer N.V." }, + { "PHE", "Philips Medical Systems Boeblingen GmbH" }, + { "PHI", "DO NOT USE - PHI" }, + { "PHL", "Philips Consumer Electronics Company" }, + { "PHO", "Photonics Systems Inc." }, + { "PHS", "Philips Communication Systems" }, + { "PHY", "Phylon Communications" }, + { "PIC", "Picturall Ltd." }, + { "PIE", "Pacific Image Electronics Company Ltd" }, + { "PIM", "Prism, LLC" }, + { "PIO", "Pioneer Electronic Corporation" }, + { "PIS", "TECNART CO.,LTD." }, + { "PIX", "Pixie Tech Inc" }, + { "PJA", "Projecta" }, + { "PJD", "Projectiondesign AS" }, + { "PJT", "Pan Jit International Inc." }, + { "PKA", "Acco UK Ltd." }, + { "PLC", "Pro-Log Corporation" }, + { "PLF", "Panasonic Avionics Corporation" }, + { "PLM", "PROLINK Microsystems Corp." }, + { "PLT", "PT Hartono Istana Teknologi" }, + { "PLV", "PLUS Vision Corp." }, + { "PLX", "Parallax Graphics" }, + { "PLY", "Polycom Inc." }, + { "PMC", "PMC Consumer Electronics Ltd" }, + { "PMD", "TDK USA Corporation" }, + { "PMM", "Point Multimedia System" }, + { "PMS", "Pabian Embedded Systems" }, + { "PMT", "Promate Electronic Co., Ltd." }, + { "PMX", "Photomatrix" }, + { "PNG", "Microsoft" }, + { "PNL", "Panelview, Inc." }, + { "PNP", "Microsoft" }, + { "PNR", "Planar Systems, Inc." }, + { "PNS", "PanaScope" }, + { "PNT", "HOYA Corporation PENTAX Lifecare Division" }, + { "PNX", "Phoenix Technologies, Ltd." }, + { "POL", "PolyComp (PTY) Ltd." }, + { "PON", "Perpetual Technologies, LLC" }, + { "POR", "Portalis LC" }, + { "POS", "Positivo Tecnologia S.A." }, + { "POT", "Parrot" }, + { "PPC", "Phoenixtec Power Company Ltd" }, + { "PPD", "MEPhI" }, + { "PPI", "Practical Peripherals" }, + { "PPM", "Clinton Electronics Corp." }, + { "PPP", "Purup Prepress AS" }, + { "PPR", "PicPro" }, + { "PPX", "Perceptive Pixel Inc." }, + { "PQI", "Pixel Qi" }, + { "PRA", "PRO/AUTOMATION" }, + { "PRC", "PerComm" }, + { "PRD", "Praim S.R.L." }, + { "PRF", "Schneider Electric Japan Holdings, Ltd." }, + { "PRG", "The Phoenix Research Group Inc" }, + { "PRI", "Priva Hortimation BV" }, + { "PRM", "Prometheus" }, + { "PRO", "Proteon" }, + { "PRP", "UEFI Forum" }, + { "PRS", "Leutron Vision" }, + { "PRT", "Parade Technologies, Ltd." }, + { "PRX", "Proxima Corporation" }, + { "PSA", "Advanced Signal Processing Technologies" }, + { "PSC", "Philips Semiconductors" }, + { "PSD", "Peus-Systems GmbH" }, + { "PSE", "Practical Solutions Pte., Ltd." }, + { "PSI", "PSI-Perceptive Solutions Inc" }, + { "PSL", "Perle Systems Limited" }, + { "PSM", "Prosum" }, + { "PST", "Global Data SA" }, + { "PSY", "Prodea Systems Inc." }, + { "PTA", "PAR Tech Inc." }, + { "PTC", "PS Technology Corporation" }, + { "PTG", "Cipher Systems Inc" }, + { "PTH", "Pathlight Technology Inc" }, + { "PTI", "Promise Technology Inc" }, + { "PTL", "Pantel Inc" }, + { "PTS", "Plain Tree Systems Inc" }, + { "PTW", "DO NOT USE - PTW" }, + { "PUL", "Pulse-Eight Ltd" }, + { "PVC", "DO NOT USE - PVC" }, + { "PVG", "Proview Global Co., Ltd" }, + { "PVI", "Prime view international Co., Ltd" }, + { "PVM", "Penta Studiotechnik GmbH" }, + { "PVN", "Pixel Vision" }, + { "PVP", "Klos Technologies, Inc." }, + { "PVR", "Pimax Tech. CO., LTD" }, + { "PXC", "Phoenix Contact" }, + { "PXE", "PIXELA CORPORATION" }, + { "PXL", "The Moving Pixel Company" }, + { "PXM", "Proxim Inc" }, + { "PXN", "PixelNext Inc" }, + { "QCC", "QuakeCom Company Ltd" }, + { "QCH", "Metronics Inc" }, + { "QCI", "Quanta Computer Inc" }, + { "QCK", "Quick Corporation" }, + { "QCL", "Quadrant Components Inc" }, + { "QCP", "Qualcomm Inc" }, + { "QDI", "Quantum Data Incorporated" }, + { "QDL", "QD Laser, Inc." }, + { "QDM", "Quadram" }, + { "QDS", "Quanta Display Inc." }, + { "QFF", "Padix Co., Inc." }, + { "QFI", "Quickflex, Inc" }, + { "QLC", "Q-Logic" }, + { "QQQ", "Chuomusen Co., Ltd." }, + { "QSC", "QSC, LLC" }, + { "QSI", "Quantum Solutions, Inc." }, + { "QTD", "Quantum 3D Inc" }, + { "QTH", "Questech Ltd" }, + { "QTI", "Quicknet Technologies Inc" }, + { "QTM", "Quantum" }, + { "QTR", "Qtronix Corporation" }, + { "QUA", "Quatographic AG" }, + { "QUE", "Questra Consulting" }, + { "QVU", "Quartics" }, + { "RAC", "Racore Computer Products Inc" }, + { "RAD", "Radisys Corporation" }, + { "RAI", "Rockwell Automation/Intecolor" }, + { "RAN", "Rancho Tech Inc" }, + { "RAR", "Raritan, Inc." }, + { "RAS", "RAScom Inc" }, + { "RAT", "Rent-A-Tech" }, + { "RAY", "Raylar Design, Inc." }, + { "RCE", "Parc d'Activite des Bellevues" }, + { "RCH", "Reach Technology Inc" }, + { "RCI", "RC International" }, + { "RCN", "Radio Consult SRL" }, + { "RCO", "Rockwell Collins" }, + { "RDI", "Rainbow Displays, Inc." }, + { "RDM", "Tremon Enterprises Company Ltd" }, + { "RDN", "RADIODATA GmbH" }, + { "RDS", "Radius Inc" }, + { "REA", "Real D" }, + { "REC", "ReCom" }, + { "RED", "Research Electronics Development Inc" }, + { "REF", "Reflectivity, Inc." }, + { "REH", "Rehan Electronics Ltd." }, + { "REL", "Reliance Electric Ind Corporation" }, + { "REM", "SCI Systems Inc." }, + { "REN", "Renesas Technology Corp." }, + { "RES", "ResMed Pty Ltd" }, + { "RET", "Resonance Technology, Inc." }, + { "REV", "Revolution Display, Inc." }, + { "REX", "RATOC Systems, Inc." }, + { "RFI", "RAFI GmbH & Co. KG" }, + { "RFX", "Redfox Technologies Inc." }, + { "RGB", "RGB Spectrum" }, + { "RGL", "Robertson Geologging Ltd" }, + { "RHD", "RightHand Technologies" }, + { "RHM", "Rohm Company Ltd" }, + { "RHT", "Red Hat, Inc." }, + { "RIC", "RICOH COMPANY, LTD." }, + { "RII", "Racal Interlan Inc" }, + { "RIO", "Rios Systems Company Ltd" }, + { "RIT", "Ritech Inc" }, + { "RIV", "Rivulet Communications" }, + { "RJA", "Roland Corporation" }, + { "RJS", "Advanced Engineering" }, + { "RKC", "Reakin Technolohy Corporation" }, + { "RLD", "MEPCO" }, + { "RLN", "RadioLAN Inc" }, + { "RMC", "Raritan Computer, Inc" }, + { "RMP", "Research Machines" }, + { "RMS", "Shenzhen Ramos Digital Technology Co., Ltd" }, + { "RMT", "Roper Mobile" }, + { "RNB", "Rainbow Technologies" }, + { "ROB", "Robust Electronics GmbH" }, + { "ROH", "Rohm Co., Ltd." }, + { "ROK", "Rockwell International" }, + { "ROP", "Roper International Ltd" }, + { "ROS", "Rohde & Schwarz" }, + { "RPI", "RoomPro Technologies" }, + { "RPT", "R.P.T.Intergroups" }, + { "RRI", "Radicom Research Inc" }, + { "RSC", "PhotoTelesis" }, + { "RSH", "ADC-Centre" }, + { "RSI", "Rampage Systems Inc" }, + { "RSN", "Radiospire Networks, Inc." }, + { "RSQ", "R Squared" }, + { "RSR", "Zhong Shan City Richsound Electronic Industrial Ltd." }, + { "RSS", "Rockwell Semiconductor Systems" }, + { "RSV", "Ross Video Ltd" }, + { "RSX", "Rapid Tech Corporation" }, + { "RTC", "Relia Technologies" }, + { "RTI", "Rancho Tech Inc" }, + { "RTK", "DO NOT USE - RTK" }, + { "RTL", "Realtek Semiconductor Company Ltd" }, + { "RTS", "Raintree Systems" }, + { "RUN", "RUNCO International" }, + { "RUP", "Ups Manufactoring s.r.l." }, + { "RVC", "RSI Systems Inc" }, + { "RVI", "Realvision Inc" }, + { "RVL", "Reveal Computer Prod" }, + { "RWC", "Red Wing Corporation" }, + { "RXT", "Tectona SoftSolutions (P) Ltd.," }, + { "RZR", "Razer Taiwan Co. Ltd." }, + { "RZS", "Rozsnyó, s.r.o." }, + { "SAA", "Sanritz Automation Co.,Ltd." }, + { "SAE", "Saab Aerotech" }, + { "SAG", "Sedlbauer" }, + { "SAI", "Sage Inc" }, + { "SAK", "Saitek Ltd" }, + { "SAM", "Samsung Electric Company" }, + { "SAN", "Sanyo Electric Co.,Ltd." }, + { "SAS", "Stores Automated Systems Inc" }, + { "SAT", "Shuttle Tech" }, + { "SBC", "Shanghai Bell Telephone Equip Mfg Co" }, + { "SBD", "Softbed - Consulting & Development Ltd" }, + { "SBI", "SMART Technologies Inc." }, + { "SBS", "SBS-or Industrial Computers GmbH" }, + { "SBT", "Senseboard Technologies AB" }, + { "SCB", "SeeCubic B.V." }, + { "SCC", "SORD Computer Corporation" }, + { "SCD", "Sanyo Electric Company Ltd" }, + { "SCE", "Sun Corporation" }, + { "SCH", "Schlumberger Cards" }, + { "SCI", "System Craft" }, + { "SCL", "Sigmacom Co., Ltd." }, + { "SCM", "SCM Microsystems Inc" }, + { "SCN", "Scanport, Inc." }, + { "SCO", "SORCUS Computer GmbH" }, + { "SCP", "Scriptel Corporation" }, + { "SCR", "Systran Corporation" }, + { "SCS", "Nanomach Anstalt" }, + { "SCT", "Smart Card Technology" }, + { "SCX", "Socionext Inc." }, + { "SDA", "SAT (Societe Anonyme)" }, + { "SDD", "Intrada-SDD Ltd" }, + { "SDE", "Sherwood Digital Electronics Corporation" }, + { "SDF", "SODIFF E&T CO., Ltd." }, + { "SDH", "Communications Specialies, Inc." }, + { "SDI", "Samtron Displays Inc" }, + { "SDK", "SAIT-Devlonics" }, + { "SDR", "SDR Systems" }, + { "SDS", "SunRiver Data System" }, + { "SDT", "Siemens AG" }, + { "SDX", "SDX Business Systems Ltd" }, + { "SEA", "Seanix Technology Inc." }, + { "SEB", "system elektronik GmbH" }, + { "SEC", "Seiko Epson Corporation" }, + { "SEE", "SeeColor Corporation" }, + { "SEG", "DO NOT USE - SEG" }, + { "SEI", "Seitz & Associates Inc" }, + { "SEL", "Way2Call Communications" }, + { "SEM", "Samsung Electronics Company Ltd" }, + { "SEN", "Sencore" }, + { "SEO", "SEOS Ltd" }, + { "SEP", "SEP Eletronica Ltda." }, + { "SER", "Sony Ericsson Mobile Communications Inc." }, + { "SES", "Session Control LLC" }, + { "SET", "SendTek Corporation" }, + { "SFM", "TORNADO Company" }, + { "SFT", "Mikroforum Ring 3" }, + { "SGC", "Spectragraphics Corporation" }, + { "SGD", "Sigma Designs, Inc." }, + { "SGE", "Kansai Electric Company Ltd" }, + { "SGI", "Scan Group Ltd" }, + { "SGL", "Super Gate Technology Company Ltd" }, + { "SGM", "SAGEM" }, + { "SGO", "Logos Design A/S" }, + { "SGT", "Stargate Technology" }, + { "SGW", "Shanghai Guowei Science and Technology Co., Ltd." }, + { "SGX", "Silicon Graphics Inc" }, + { "SGZ", "Systec Computer GmbH" }, + { "SHC", "ShibaSoku Co., Ltd." }, + { "SHG", "Soft & Hardware development Goldammer GmbH" }, + { "SHI", "Jiangsu Shinco Electronic Group Co., Ltd" }, + { "SHP", "Sharp Corporation" }, + { "SHR", "Digital Discovery" }, + { "SHT", "Shin Ho Tech" }, + { "SIA", "SIEMENS AG" }, + { "SIB", "Sanyo Electric Company Ltd" }, + { "SIC", "Sysmate Corporation" }, + { "SID", "Seiko Instruments Information Devices Inc" }, + { "SIE", "Siemens" }, + { "SIG", "Sigma Designs Inc" }, + { "SII", "Silicon Image, Inc." }, + { "SIL", "Silicon Laboratories, Inc" }, + { "SIM", "S3 Inc" }, + { "SIN", "Singular Technology Co., Ltd." }, + { "SIR", "Sirius Technologies Pty Ltd" }, + { "SIS", "Silicon Integrated Systems Corporation" }, + { "SIT", "Sitintel" }, + { "SIU", "Seiko Instruments USA Inc" }, + { "SIX", "Zuniq Data Corporation" }, + { "SJE", "Sejin Electron Inc" }, + { "SKD", "Schneider & Koch" }, + { "SKI", "LLC SKTB “SKIT”" }, + { "SKM", "Guangzhou Teclast Information Technology Limited" }, + { "SKT", "Samsung Electro-Mechanics Company Ltd" }, + { "SKW", "Skyworth" }, + { "SKY", "SKYDATA S.P.A." }, + { "SLA", "Systeme Lauer GmbH&Co KG" }, + { "SLB", "Shlumberger Ltd" }, + { "SLC", "Syslogic Datentechnik AG" }, + { "SLF", "StarLeaf" }, + { "SLH", "Silicon Library Inc." }, + { "SLI", "Symbios Logic Inc" }, + { "SLK", "Silitek Corporation" }, + { "SLM", "Solomon Technology Corporation" }, + { "SLR", "Schlumberger Technology Corporate" }, + { "SLS", "Schnick-Schnack-Systems GmbH" }, + { "SLT", "Salt Internatioinal Corp." }, + { "SLX", "Specialix" }, + { "SMA", "SMART Modular Technologies" }, + { "SMB", "Schlumberger" }, + { "SMC", "Standard Microsystems Corporation" }, + { "SME", "Sysmate Company" }, + { "SMI", "SpaceLabs Medical Inc" }, + { "SMK", "SMK CORPORATION" }, + { "SML", "Sumitomo Metal Industries, Ltd." }, + { "SMM", "Shark Multimedia Inc" }, + { "SMO", "STMicroelectronics" }, + { "SMP", "Simple Computing" }, + { "SMR", "B.& V. s.r.l." }, + { "SMS", "Silicom Multimedia Systems Inc" }, + { "SMT", "Silcom Manufacturing Tech Inc" }, + { "SNC", "Sentronic International Corp." }, + { "SNI", "Siemens Microdesign GmbH" }, + { "SNK", "S&K Electronics" }, + { "SNN", "SUNNY ELEKTRONIK" }, + { "SNO", "SINOSUN TECHNOLOGY CO., LTD" }, + { "SNP", "Siemens Nixdorf Info Systems" }, + { "SNS", "Cirtech (UK) Ltd" }, + { "SNT", "SuperNet Inc" }, + { "SNV", "SONOVE GmbH" }, + { "SNW", "Snell & Wilcox" }, + { "SNX", "Sonix Comm. Ltd" }, + { "SNY", "Sony" }, + { "SOC", "Santec Corporation" }, + { "SOI", "Silicon Optix Corporation" }, + { "SOL", "Solitron Technologies Inc" }, + { "SON", "Sony" }, + { "SOR", "Sorcus Computer GmbH" }, + { "SOT", "Sotec Company Ltd" }, + { "SOY", "SOYO Group, Inc" }, + { "SPC", "SpinCore Technologies, Inc" }, + { "SPE", "SPEA Software AG" }, + { "SPH", "G&W Instruments GmbH" }, + { "SPI", "SPACE-I Co., Ltd." }, + { "SPK", "SpeakerCraft" }, + { "SPL", "Smart Silicon Systems Pty Ltd" }, + { "SPN", "Sapience Corporation" }, + { "SPR", "pmns GmbH" }, + { "SPS", "Synopsys Inc" }, + { "SPT", "Sceptre Tech Inc" }, + { "SPU", "SIM2 Multimedia S.P.A." }, + { "SPX", "Simplex Time Recorder Co." }, + { "SQT", "Sequent Computer Systems Inc" }, + { "SRC", "Integrated Tech Express Inc" }, + { "SRD", "Setred" }, + { "SRF", "Surf Communication Solutions Ltd" }, + { "SRG", "Intuitive Surgical, Inc." }, + { "SRS", "SR-Systems e.K." }, + { "SRT", "SeeReal Technologies GmbH" }, + { "SSC", "Sierra Semiconductor Inc" }, + { "SSD", "FlightSafety International" }, + { "SSE", "Samsung Electronic Co." }, + { "SSI", "S-S Technology Inc" }, + { "SSJ", "Sankyo Seiki Mfg.co., Ltd" }, + { "SSL", "Shenzhen South-Top Computer Co., Ltd." }, + { "SSP", "Spectrum Signal Proecessing Inc" }, + { "SSS", "S3 Inc" }, + { "SST", "SystemSoft Corporation" }, + { "STA", "ST Electronics Systems Assembly Pte Ltd" }, + { "STB", "STB Systems Inc" }, + { "STC", "STAC Electronics" }, + { "STD", "STD Computer Inc" }, + { "STE", "SII Ido-Tsushin Inc" }, + { "STF", "Starflight Electronics" }, + { "STG", "StereoGraphics Corp." }, + { "STH", "Semtech Corporation" }, + { "STI", "Smart Tech Inc" }, + { "STK", "SANTAK CORP." }, + { "STL", "SigmaTel Inc" }, + { "STM", "SGS Thomson Microelectronics" }, + { "STN", "Samsung Electronics America" }, + { "STO", "Stollmann E+V GmbH" }, + { "STP", "StreamPlay Ltd" }, + { "STQ", "Synthetel Corporation" }, + { "STR", "Starlight Networks Inc" }, + { "STS", "SITECSYSTEM CO., LTD." }, + { "STT", "Star Paging Telecom Tech (Shenzhen) Co. Ltd." }, + { "STU", "Sentelic Corporation" }, + { "STW", "Starwin Inc." }, + { "STX", "ST-Ericsson" }, + { "STY", "SDS Technologies" }, + { "SUB", "Subspace Comm. Inc" }, + { "SUM", "Summagraphics Corporation" }, + { "SUN", "Sun Electronics Corporation" }, + { "SUP", "Supra Corporation" }, + { "SUR", "Surenam Computer Corporation" }, + { "SVA", "SGEG" }, + { "SVC", "Intellix Corp." }, + { "SVD", "SVD Computer" }, + { "SVI", "Sun Microsystems" }, + { "SVR", "Sensics, Inc." }, + { "SVS", "SVSI" }, + { "SVT", "SEVIT Co., Ltd." }, + { "SWC", "Software Café" }, + { "SWI", "Sierra Wireless Inc." }, + { "SWL", "Sharedware Ltd" }, + { "SWO", "Guangzhou Shirui Electronics Co., Ltd." }, + { "SWS", "Static" }, + { "SWT", "Software Technologies Group,Inc." }, + { "SXB", "Syntax-Brillian" }, + { "SXD", "Silex technology, Inc." }, + { "SXG", "SELEX GALILEO" }, + { "SXI", "Silex Inside" }, + { "SXL", "SolutionInside" }, + { "SXT", "SHARP TAKAYA ELECTRONIC INDUSTRY CO.,LTD." }, + { "SYC", "Sysmic" }, + { "SYE", "SY Electronics Ltd" }, + { "SYK", "Stryker Communications" }, + { "SYL", "Sylvania Computer Products" }, + { "SYM", "Symicron Computer Communications Ltd." }, + { "SYN", "Synaptics Inc" }, + { "SYP", "SYPRO Co Ltd" }, + { "SYS", "Sysgration Ltd" }, + { "SYT", "Seyeon Tech Company Ltd" }, + { "SYV", "SYVAX Inc" }, + { "SYX", "Prime Systems, Inc." }, + { "SZM", "Shenzhen MTC Co., Ltd" }, + { "TAA", "Tandberg" }, + { "TAB", "Todos Data System AB" }, + { "TAG", "Teles AG" }, + { "TAI", "Toshiba America Info Systems Inc" }, + { "TAM", "Tamura Seisakusyo Ltd" }, + { "TAS", "Taskit Rechnertechnik GmbH" }, + { "TAT", "Teleliaison Inc" }, + { "TAV", "Thales Avionics" }, + { "TAX", "Taxan (Europe) Ltd" }, + { "TBB", "Triple S Engineering Inc" }, + { "TBC", "Turbo Communication, Inc" }, + { "TBS", "Turtle Beach System" }, + { "TCC", "Tandon Corporation" }, + { "TCD", "Taicom Data Systems Co., Ltd." }, + { "TCE", "Century Corporation" }, + { "TCF", "Televic Conference" }, + { "TCH", "Interaction Systems, Inc" }, + { "TCI", "Tulip Computers Int'l B.V." }, + { "TCJ", "TEAC America Inc" }, + { "TCL", "Technical Concepts Ltd" }, + { "TCM", "3Com Corporation" }, + { "TCN", "Tecnetics (PTY) Ltd" }, + { "TCO", "Thomas-Conrad Corporation" }, + { "TCR", "Thomson Consumer Electronics" }, + { "TCS", "Tatung Company of America Inc" }, + { "TCT", "Telecom Technology Centre Co. Ltd." }, + { "TCX", "FREEMARS Heavy Industries" }, + { "TDC", "Teradici" }, + { "TDD", "Tandberg Data Display AS" }, + { "TDG", "Six15 Technologies" }, + { "TDM", "Tandem Computer Europe Inc" }, + { "TDP", "3D Perception" }, + { "TDS", "Tri-Data Systems Inc" }, + { "TDT", "TDT" }, + { "TDV", "TDVision Systems, Inc." }, + { "TDY", "Tandy Electronics" }, + { "TEA", "TEAC System Corporation" }, + { "TEC", "Tecmar Inc" }, + { "TEK", "Tektronix Inc" }, + { "TEL", "Promotion and Display Technology Ltd." }, + { "TEN", "Tencent" }, + { "TER", "TerraTec Electronic GmbH" }, + { "TET", "TETRADYNE CO., LTD." }, + { "TEV", "Televés, S.A." }, + { "TEZ", "Tech Source Inc." }, + { "TGC", "Toshiba Global Commerce Solutions, Inc." }, + { "TGI", "TriGem Computer Inc" }, + { "TGM", "TriGem Computer,Inc." }, + { "TGS", "Torus Systems Ltd" }, + { "TGV", "Grass Valley Germany GmbH" }, + { "TGW", "TECHNOGYM S.p.A." }, + { "THN", "Thundercom Holdings Sdn. Bhd." }, + { "TIC", "Trigem KinfoComm" }, + { "TIL", "Technical Illusions Inc." }, + { "TIP", "TIPTEL AG" }, + { "TIV", "OOO Technoinvest" }, + { "TIX", "Tixi.Com GmbH" }, + { "TKC", "Taiko Electric Works.LTD" }, + { "TKG", "Tek Gear" }, + { "TKN", "Teknor Microsystem Inc" }, + { "TKO", "TouchKo, Inc." }, + { "TKS", "TimeKeeping Systems, Inc." }, + { "TLA", "Ferrari Electronic GmbH" }, + { "TLD", "Telindus" }, + { "TLE", "Zhejiang Tianle Digital Electric Co., Ltd." }, + { "TLF", "Teleforce.,co,ltd" }, + { "TLI", "TOSHIBA TELI CORPORATION" }, + { "TLK", "Telelink AG" }, + { "TLL", "Thinklogical" }, + { "TLN", "Techlogix Networx" }, + { "TLS", "Teleste Educational OY" }, + { "TLT", "Dai Telecom S.p.A." }, + { "TLV", "S3 Inc" }, + { "TLX", "Telxon Corporation" }, + { "TMC", "Techmedia Computer Systems Corporation" }, + { "TME", "AT&T Microelectronics" }, + { "TMI", "Texas Microsystem" }, + { "TMM", "Time Management, Inc." }, + { "TMO", "Terumo Corporation" }, + { "TMR", "Taicom International Inc" }, + { "TMS", "Trident Microsystems Ltd" }, + { "TMT", "T-Metrics Inc." }, + { "TMX", "Thermotrex Corporation" }, + { "TNC", "TNC Industrial Company Ltd" }, + { "TNJ", "DO NOT USE - TNJ" }, + { "TNM", "TECNIMAGEN SA" }, + { "TNY", "Tennyson Tech Pty Ltd" }, + { "TOE", "TOEI Electronics Co., Ltd." }, + { "TOG", "The OPEN Group" }, + { "TOL", "TCL Corporation" }, + { "TOM", "Ceton Corporation" }, + { "TON", "TONNA" }, + { "TOP", "Orion Communications Co., Ltd." }, + { "TOS", "Dynabook Inc." }, + { "TOU", "Touchstone Technology" }, + { "TPC", "Touch Panel Systems Corporation" }, + { "TPD", "Times (Shanghai) Computer Co., Ltd." }, + { "TPE", "Technology Power Enterprises Inc" }, + { "TPJ", "Junnila" }, + { "TPK", "TOPRE CORPORATION" }, + { "TPR", "Topro Technology Inc" }, + { "TPS", "Teleprocessing Systeme GmbH" }, + { "TPT", "Thruput Ltd" }, + { "TPV", "Top Victory Electronics ( Fujian ) Company Ltd" }, + { "TPZ", "Ypoaz Systems Inc" }, + { "TRA", "TriTech Microelectronics International" }, + { "TRB", "Triumph Board a.s." }, + { "TRC", "Trioc AB" }, + { "TRD", "Trident Microsystem Inc" }, + { "TRE", "Tremetrics" }, + { "TRI", "Tricord Systems" }, + { "TRL", "Royal Information" }, + { "TRM", "Tekram Technology Company Ltd" }, + { "TRN", "Datacommunicatie Tron B.V." }, + { "TRP", "TRAPEZE GROUP" }, + { "TRS", "Torus Systems Ltd" }, + { "TRT", "Tritec Electronic AG" }, + { "TRU", "Aashima Technology B.V." }, + { "TRV", "Trivisio Prototyping GmbH" }, + { "TRX", "Trex Enterprises" }, + { "TSB", "Toshiba America Info Systems Inc" }, + { "TSC", "Sanyo Electric Company Ltd" }, + { "TSD", "TechniSat Digital GmbH" }, + { "TSE", "Tottori Sanyo Electric" }, + { "TSF", "Racal-Airtech Software Forge Ltd" }, + { "TSG", "The Software Group Ltd" }, + { "TSH", "ELAN MICROELECTRONICS CORPORATION" }, + { "TSI", "TeleVideo Systems" }, + { "TSL", "Tottori SANYO Electric Co., Ltd." }, + { "TSP", "U.S. Navy" }, + { "TST", "Transtream Inc" }, + { "TSV", "TRANSVIDEO" }, + { "TSW", "VRSHOW Technology Limited" }, + { "TSY", "TouchSystems" }, + { "TTA", "Topson Technology Co., Ltd." }, + { "TTB", "National Semiconductor Japan Ltd" }, + { "TTC", "Telecommunications Techniques Corporation" }, + { "TTE", "TTE, Inc." }, + { "TTI", "Trenton Terminals Inc" }, + { "TTK", "Totoku Electric Company Ltd" }, + { "TTL", "2-Tel B.V" }, + { "TTP", "Toshiba Corporation" }, + { "TTS", "TechnoTrend Systemtechnik GmbH" }, + { "TTX", "Taitex Corporation" }, + { "TTY", "TRIDELITY Display Solutions GmbH" }, + { "TUA", "T+A elektroakustik GmbH" }, + { "TUT", "Tut Systems" }, + { "TVD", "Tecnovision" }, + { "TVI", "Truevision" }, + { "TVL", "Total Vision LTD" }, + { "TVM", "Taiwan Video & Monitor Corporation" }, + { "TVO", "TV One Ltd" }, + { "TVR", "TV Interactive Corporation" }, + { "TVS", "TVS Electronics Limited" }, + { "TVV", "TV1 GmbH" }, + { "TWA", "Tidewater Association" }, + { "TWE", "Kontron Electronik" }, + { "TWH", "Twinhead International Corporation" }, + { "TWI", "Easytel oy" }, + { "TWK", "TOWITOKO electronics GmbH" }, + { "TWX", "TEKWorx Limited" }, + { "TXL", "Trixel Ltd" }, + { "TXN", "Texas Insturments" }, + { "TXT", "Textron Defense System" }, + { "TYN", "Tyan Computer Corporation" }, + { "UAS", "Ultima Associates Pte Ltd" }, + { "UBI", "Ungermann-Bass Inc" }, + { "UBL", "Ubinetics Ltd." }, + { "UBU", "Canonical Ltd." }, + { "UDN", "Uniden Corporation" }, + { "UEC", "Ultima Electronics Corporation" }, + { "UEG", "Elitegroup Computer Systems Company Ltd" }, + { "UEI", "Universal Electronics Inc" }, + { "UET", "Universal Empowering Technologies" }, + { "UFG", "UNIGRAF-USA" }, + { "UFO", "UFO Systems Inc" }, + { "UHB", "XOCECO" }, + { "UIC", "Uniform Industrial Corporation" }, + { "UJR", "Ueda Japan Radio Co., Ltd." }, + { "ULT", "Ultra Network Tech" }, + { "UMC", "United Microelectr Corporation" }, + { "UMG", "Umezawa Giken Co.,Ltd" }, + { "UMM", "Universal Multimedia" }, + { "UMT", "UltiMachine" }, + { "UNA", "Unisys DSD" }, + { "UNB", "Unisys Corporation" }, + { "UNC", "Unisys Corporation" }, + { "UND", "Unisys Corporation" }, + { "UNE", "Unisys Corporation" }, + { "UNF", "Unisys Corporation" }, + { "UNI", "Uniform Industry Corp." }, + { "UNM", "Unisys Corporation" }, + { "UNO", "Unisys Corporation" }, + { "UNP", "Unitop" }, + { "UNS", "Unisys Corporation" }, + { "UNT", "Unisys Corporation" }, + { "UNY", "Unicate" }, + { "UPP", "UPPI" }, + { "UPS", "Systems Enhancement" }, + { "URD", "Video Computer S.p.A." }, + { "USA", "Utimaco Safeware AG" }, + { "USD", "U.S. Digital Corporation" }, + { "USE", "U. S. Electronics Inc." }, + { "USI", "Universal Scientific Industrial Co., Ltd." }, + { "USR", "U.S. Robotics Inc" }, + { "UTC", "Unicompute Technology Co., Ltd." }, + { "UTD", "Up to Date Tech" }, + { "UWC", "Uniwill Computer Corp." }, + { "VAD", "Vaddio, LLC" }, + { "VAI", "VAIO Corporation" }, + { "VAL", "Valence Computing Corporation" }, + { "VAR", "Varian Australia Pty Ltd" }, + { "VAT", "VADATECH INC" }, + { "VBR", "VBrick Systems Inc." }, + { "VBT", "Valley Board Ltda" }, + { "VCC", "Virtual Computer Corporation" }, + { "VCI", "VistaCom Inc" }, + { "VCJ", "Victor Company of Japan, Limited" }, + { "VCM", "Vector Magnetics, LLC" }, + { "VCX", "VCONEX" }, + { "VDA", "Victor Data Systems" }, + { "VDC", "VDC Display Systems" }, + { "VDM", "Vadem" }, + { "VDO", "Video & Display Oriented Corporation" }, + { "VDS", "Vidisys GmbH & Company" }, + { "VDT", "Viditec, Inc." }, + { "VEC", "Vector Informatik GmbH" }, + { "VEK", "Vektrex" }, + { "VES", "Vestel Elektronik Sanayi ve Ticaret A. S." }, + { "VFI", "VeriFone Inc" }, + { "VHI", "Macrocad Development Inc." }, + { "VIA", "VIA Tech Inc" }, + { "VIB", "Tatung UK Ltd" }, + { "VIC", "Victron B.V." }, + { "VID", "Ingram Macrotron Germany" }, + { "VIK", "Viking Connectors" }, + { "VIM", "Via Mons Ltd." }, + { "VIN", "Vine Micros Ltd" }, + { "VIR", "Visual Interface, Inc" }, + { "VIS", "Visioneer" }, + { "VIT", "Visitech AS" }, + { "VIZ", "VIZIO, Inc" }, + { "VLB", "ValleyBoard Ltda." }, + { "VLC", "VersaLogic Corporation" }, + { "VLK", "Vislink International Ltd" }, + { "VLM", "LENOVO BEIJING CO. LTD." }, + { "VLT", "VideoLan Technologies" }, + { "VLV", "Valve Corporation" }, + { "VMI", "Vermont Microsystems" }, + { "VML", "Vine Micros Limited" }, + { "VMW", "VMware Inc.," }, + { "VNC", "Vinca Corporation" }, + { "VOB", "MaxData Computer AG" }, + { "VPI", "Video Products Inc" }, + { "VPR", "Best Buy" }, + { "VPX", "VPixx Technologies Inc." }, + { "VQ@", "Vision Quest" }, + { "VRC", "Virtual Resources Corporation" }, + { "VRG", "VRgineers, Inc." }, + { "VRM", "VRmagic Holding AG" }, + { "VRS", "VRstudios, Inc." }, + { "VRT", "Varjo Technologies" }, + { "VSC", "ViewSonic Corporation" }, + { "VSD", "3M" }, + { "VSI", "VideoServer" }, + { "VSN", "Ingram Macrotron" }, + { "VSP", "Vision Systems GmbH" }, + { "VSR", "V-Star Electronics Inc." }, + { "VTB", "Videotechnik Breithaupt" }, + { "VTC", "VTel Corporation" }, + { "VTG", "Voice Technologies Group Inc" }, + { "VTI", "VLSI Tech Inc" }, + { "VTK", "Viewteck Co., Ltd." }, + { "VTL", "Vivid Technology Pte Ltd" }, + { "VTM", "Miltope Corporation" }, + { "VTN", "VIDEOTRON CORP." }, + { "VTS", "VTech Computers Ltd" }, + { "VTV", "VATIV Technologies" }, + { "VTX", "Vestax Corporation" }, + { "VUT", "Vutrix (UK) Ltd" }, + { "VWB", "Vweb Corp." }, + { "WAC", "Wacom Tech" }, + { "WAL", "Wave Access" }, + { "WAN", "DO NOT USE - WAN" }, + { "WAV", "Wavephore" }, + { "WBN", "MicroSoftWare" }, + { "WBS", "WB Systemtechnik GmbH" }, + { "WCI", "Wisecom Inc" }, + { "WCS", "Woodwind Communications Systems Inc" }, + { "WDC", "Western Digital" }, + { "WDE", "Westinghouse Digital Electronics" }, + { "WEB", "WebGear Inc" }, + { "WEC", "Winbond Electronics Corporation" }, + { "WEL", "W-DEV" }, + { "WEY", "WEY Design AG" }, + { "WHI", "Whistle Communications" }, + { "WII", "Innoware Inc" }, + { "WIL", "WIPRO Information Technology Ltd" }, + { "WIN", "Wintop Technology Inc" }, + { "WIP", "Wipro Infotech" }, + { "WKH", "Uni-Take Int'l Inc." }, + { "WLD", "Wildfire Communications Inc" }, + { "WLF", "WOLF Advanced Technology" }, + { "WML", "Wolfson Microelectronics Ltd" }, + { "WMO", "Westermo Teleindustri AB" }, + { "WMT", "Winmate Communication Inc" }, + { "WNI", "WillNet Inc." }, + { "WNV", "Winnov L.P." }, + { "WNX", "Diebold Nixdorf Systems GmbH" }, + { "WPA", "Matsushita Communication Industrial Co., Ltd." }, + { "WPI", "Wearnes Peripherals International (Pte) Ltd" }, + { "WRC", "WiNRADiO Communications" }, + { "WSC", "CIS Technology Inc" }, + { "WSP", "Wireless And Smart Products Inc." }, + { "WST", "Wistron Corporation" }, + { "WTC", "ACC Microelectronics" }, + { "WTI", "WorkStation Tech" }, + { "WTK", "Wearnes Thakral Pte" }, + { "WTS", "Restek Electric Company Ltd" }, + { "WVM", "Wave Systems Corporation" }, + { "WVV", "WolfVision GmbH" }, + { "WWP", "Wipotec Wiege- und Positioniersysteme GmbH" }, + { "WWV", "World Wide Video, Inc." }, + { "WXT", "Woxter Technology Co. Ltd" }, + { "WYR", "WyreStorm Technologies LLC" }, + { "WYS", "Wyse Technology" }, + { "WYT", "Wooyoung Image & Information Co.,Ltd." }, + { "XAC", "XAC Automation Corp" }, + { "XAD", "Alpha Data" }, + { "XDM", "XDM Ltd." }, + { "XER", "DO NOT USE - XER" }, + { "XES", "Extreme Engineering Solutions, Inc." }, + { "XFG", "Jan Strapko - FOTO" }, + { "XFO", "EXFO Electro Optical Engineering" }, + { "XIN", "Xinex Networks Inc" }, + { "XIO", "Xiotech Corporation" }, + { "XIR", "Xirocm Inc" }, + { "XIT", "Xitel Pty ltd" }, + { "XLX", "Xilinx, Inc." }, + { "XMM", "C3PO S.L." }, + { "XNT", "XN Technologies, Inc." }, + { "XOC", "DO NOT USE - XOC" }, + { "XQU", "SHANGHAI SVA-DAV ELECTRONICS CO., LTD" }, + { "XRC", "Xircom Inc" }, + { "XRO", "XORO ELECTRONICS (CHENGDU) LIMITED" }, + { "XSN", "Xscreen AS" }, + { "XST", "XS Technologies Inc" }, + { "XSY", "XSYS" }, + { "XTD", "Icuiti Corporation" }, + { "XTE", "X2E GmbH" }, + { "XTL", "Crystal Computer" }, + { "XTN", "X-10 (USA) Inc" }, + { "XYC", "Xycotec Computer GmbH" }, + { "XYE", "Shenzhen Zhuona Technology Co., Ltd." }, + { "YED", "Y-E Data Inc" }, + { "YHQ", "Yokogawa Electric Corporation" }, + { "YHW", "Exacom SA" }, + { "YMH", "Yamaha Corporation" }, + { "YOW", "American Biometric Company" }, + { "ZAN", "Zandar Technologies plc" }, + { "ZAX", "Zefiro Acoustics" }, + { "ZAZ", "ZeeVee, Inc." }, + { "ZBR", "Zebra Technologies International, LLC" }, + { "ZBX", "Zebax Technologies" }, + { "ZCT", "ZeitControl cardsystems GmbH" }, + { "ZDS", "Zenith Data Systems" }, + { "ZEN", "ZENIC Inc." }, + { "ZGT", "Zenith Data Systems" }, + { "ZIC", "Nationz Technologies Inc." }, + { "ZMC", "HangZhou ZMCHIVIN" }, + { "ZMT", "Zalman Tech Co., Ltd." }, + { "ZMZ", "Z Microsystems" }, + { "ZNI", "Zetinet Inc" }, + { "ZNX", "Znyx Adv. Systems" }, + { "ZOW", "Zowie Intertainment, Inc" }, + { "ZRN", "Zoran Corporation" }, + { "ZSE", "Zenith Data Systems" }, + { "ZTC", "ZyDAS Technology Corporation" }, + { "ZTE", "ZTE Corporation" }, + { "ZTI", "Zoom Telephonics Inc" }, + { "ZTM", "ZT Group Int'l Inc." }, + { "ZTT", "Z3 Technology" }, + { "ZWE", "Shenzhen Zowee Technology Co., LTD" }, + { "ZYD", "Zydacron Inc" }, + { "ZYP", "Zypcom Inc" }, + { "ZYT", "Zytex Computers" }, + { "ZYX", "Zyxel" }, + { "ZZZ", "Boca Research Inc" }, +}; + +QT_END_NAMESPACE + +#endif // QEDIDVENDORTABLE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qemulationpaintengine_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qemulationpaintengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..85f0580fbb2ea9943afe329d77f58190a36b3301 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qemulationpaintengine_p.h @@ -0,0 +1,71 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QEMULATIONPAINTENGINE_P_H +#define QEMULATIONPAINTENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + + +class QEmulationPaintEngine : public QPaintEngineEx +{ +public: + QEmulationPaintEngine(QPaintEngineEx *engine); + + bool begin(QPaintDevice *pdev) override; + bool end() override; + + Type type() const override; + QPainterState *createState(QPainterState *orig) const override; + + void fill(const QVectorPath &path, const QBrush &brush) override; + void stroke(const QVectorPath &path, const QPen &pen) override; + void clip(const QVectorPath &path, Qt::ClipOperation op) override; + + void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; + void drawTextItem(const QPointF &p, const QTextItem &textItem) override; + void drawStaticTextItem(QStaticTextItem *item) override; + void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override; + void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags) override; + + void clipEnabledChanged() override; + void penChanged() override; + void brushChanged() override; + void brushOriginChanged() override; + void opacityChanged() override; + void compositionModeChanged() override; + void renderHintsChanged() override; + void transformChanged() override; + + void setState(QPainterState *s) override; + + void beginNativePainting() override; + void endNativePainting() override; + + uint flags() const override { return QPaintEngineEx::IsEmulationEngine | QPaintEngineEx::DoNotEmulate; } + + inline QPainterState *state() { return (QPainterState *)QPaintEngine::state; } + inline const QPainterState *state() const { return (const QPainterState *)QPaintEngine::state; } + + QPaintEngineEx *real_engine; +private: + void fillBGRect(const QRectF &r); +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qevent_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qevent_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5d5f98baf6f714c707c047936e10dde55d45d9bb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qevent_p.h @@ -0,0 +1,70 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QEVENT_P_H +#define QEVENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QPointingDevice; + +class Q_GUI_EXPORT QMutableTouchEvent : public QTouchEvent +{ +public: + QMutableTouchEvent(QEvent::Type eventType = QEvent::TouchBegin, + const QPointingDevice *device = nullptr, + Qt::KeyboardModifiers modifiers = Qt::NoModifier, + const QList &touchPoints = QList()) : + QTouchEvent(eventType, device, modifiers, touchPoints) { } + ~QMutableTouchEvent() override; + + static QMutableTouchEvent *from(QTouchEvent *e) { return static_cast(e); } + + static QMutableTouchEvent &from(QTouchEvent &e) { return static_cast(e); } + + void setTarget(QObject *target) { m_target = target; } + + void addPoint(const QEventPoint &point); +}; + +class Q_GUI_EXPORT QMutableSinglePointEvent : public QSinglePointEvent +{ +public: + QMutableSinglePointEvent(const QSinglePointEvent &other) : QSinglePointEvent(other) {} + QMutableSinglePointEvent(Type type = QEvent::None, const QPointingDevice *device = nullptr, const QEventPoint &point = QEventPoint(), + Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = Qt::NoButton, + Qt::KeyboardModifiers modifiers = Qt::NoModifier, + Qt::MouseEventSource source = Qt::MouseEventSynthesizedByQt) : + QSinglePointEvent(type, device, point, button, buttons, modifiers, source) { } + ~QMutableSinglePointEvent() override; + + static QMutableSinglePointEvent *from(QSinglePointEvent *e) { return static_cast(e); } + + static QMutableSinglePointEvent &from(QSinglePointEvent &e) { return static_cast(e); } + + void setSource(Qt::MouseEventSource s) { m_source = s; } + + bool isDoubleClick() { return m_doubleClick; } + + void setDoubleClick(bool d = true) { m_doubleClick = d; } +}; + +QT_END_NAMESPACE + +#endif // QEVENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qeventpoint_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qeventpoint_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7d62ab305ebc126410e6237042c0f47c18dbb14b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qeventpoint_p.h @@ -0,0 +1,141 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QEVENTPOINT_P_H +#define QEVENTPOINT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcPointerVel); +Q_DECLARE_LOGGING_CATEGORY(lcEPDetach); + +class QPointingDevice; + +class QEventPointPrivate : public QSharedData +{ +public: + QEventPointPrivate(int id, const QPointingDevice *device) + : device(device), pointId(id) { } + + QEventPointPrivate(int pointId, QEventPoint::State state, const QPointF &scenePosition, const QPointF &globalPosition) + : scenePos(scenePosition), globalPos(globalPosition), pointId(pointId), state(state) + { + if (state == QEventPoint::State::Released) + pressure = 0; + } + inline bool operator==(const QEventPointPrivate &other) const + { + return device == other.device + && window == other.window + && target == other.target + && pos == other.pos + && scenePos == other.scenePos + && globalPos == other.globalPos + && globalPressPos == other.globalPressPos + && globalGrabPos == other.globalGrabPos + && globalLastPos == other.globalLastPos + && pressure == other.pressure + && rotation == other.rotation + && ellipseDiameters == other.ellipseDiameters + && velocity == other.velocity + && timestamp == other.timestamp + && lastTimestamp == other.lastTimestamp + && pressTimestamp == other.pressTimestamp + && uniqueId == other.uniqueId + && pointId == other.pointId + && state == other.state; + } + + const QPointingDevice *device = nullptr; + QPointer window; + QPointer target; + QPointF pos, scenePos, globalPos, + globalPressPos, globalGrabPos, globalLastPos; + qreal pressure = 1; + qreal rotation = 0; + QSizeF ellipseDiameters = QSizeF(0, 0); + QVector2D velocity; + ulong timestamp = 0; + ulong lastTimestamp = 0; + ulong pressTimestamp = 0; + QPointingDeviceUniqueId uniqueId; + int pointId = -1; + QEventPoint::State state = QEventPoint::State::Unknown; + bool accept = false; +}; + +// Private subclasses to allow accessing and modifying protected variables. +// These should NOT hold any extra state. + +class QMutableEventPoint +{ +public: + static QEventPoint withTimeStamp(ulong timestamp, int pointId, QEventPoint::State state, + QPointF position, QPointF scenePosition, QPointF globalPosition) + { + QEventPoint p(pointId, state, scenePosition, globalPosition); + p.d->timestamp = timestamp; + p.d->pos = position; + return p; + } + + static Q_GUI_EXPORT void update(const QEventPoint &from, QEventPoint &to); + + static Q_GUI_EXPORT void detach(QEventPoint &p); + +#define TRIVIAL_SETTER(type, field, Field) \ + static void set##Field (QEventPoint &p, type arg) { p.d->field = std::move(arg); } \ + /* end */ + + TRIVIAL_SETTER(int, pointId, Id) + TRIVIAL_SETTER(const QPointingDevice *, device, Device) + + // not trivial: + static Q_GUI_EXPORT void setTimestamp(QEventPoint &p, ulong t); + + TRIVIAL_SETTER(ulong, pressTimestamp, PressTimestamp) + TRIVIAL_SETTER(QEventPoint::State, state, State) + TRIVIAL_SETTER(QPointingDeviceUniqueId, uniqueId, UniqueId) + TRIVIAL_SETTER(QPointF, pos, Position) + TRIVIAL_SETTER(QPointF, scenePos, ScenePosition) + TRIVIAL_SETTER(QPointF, globalPos, GlobalPosition) + + TRIVIAL_SETTER(QPointF, globalPressPos, GlobalPressPosition) + TRIVIAL_SETTER(QPointF, globalGrabPos, GlobalGrabPosition) + TRIVIAL_SETTER(QPointF, globalLastPos, GlobalLastPosition) + TRIVIAL_SETTER(QSizeF, ellipseDiameters, EllipseDiameters) + TRIVIAL_SETTER(qreal, pressure, Pressure) + TRIVIAL_SETTER(qreal, rotation, Rotation) + TRIVIAL_SETTER(QVector2D, velocity, Velocity) + + static QWindow *window(const QEventPoint &p) { return p.d->window.data(); } + + TRIVIAL_SETTER(QWindow *, window, Window) + + static QObject *target(const QEventPoint &p) { return p.d->target.data(); } + + TRIVIAL_SETTER(QObject *, target, Target) + +#undef TRIVIAL_SETTER +}; + +QT_END_NAMESPACE + +#endif // QEVENTPOINT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfileinfogatherer_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfileinfogatherer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..202c4fe0b5970baab61e7d19450c283b6805b9ca --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfileinfogatherer_p.h @@ -0,0 +1,201 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFILEINFOGATHERER_H +#define QFILEINFOGATHERER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include +#include +#if QT_CONFIG(filesystemwatcher) +#include +#endif +#include +#include +#include +#include +#include + +#include +#include + +#include + +QT_REQUIRE_CONFIG(filesystemmodel); + +QT_BEGIN_NAMESPACE + +class QExtendedInformation { +public: + enum Type { Dir, File, System }; + + QExtendedInformation() {} + QExtendedInformation(const QFileInfo &info) : mFileInfo(info) {} + + inline bool isDir() { return type() == Dir; } + inline bool isFile() { return type() == File; } + inline bool isSystem() { return type() == System; } + + bool operator ==(const QExtendedInformation &fileInfo) const { + return mFileInfo == fileInfo.mFileInfo + && displayType == fileInfo.displayType + && permissions() == fileInfo.permissions() + && lastModified(QTimeZone::UTC) == fileInfo.lastModified(QTimeZone::UTC); + } + +#ifndef QT_NO_FSFILEENGINE + bool isCaseSensitive() const { + auto *fiPriv = QFileInfoPrivate::get(const_cast(&mFileInfo)); + return qt_isCaseSensitive(fiPriv->fileEntry, fiPriv->metaData); + } +#endif + + QFile::Permissions permissions() const { + return mFileInfo.permissions(); + } + + Type type() const { + if (mFileInfo.isDir()) { + return QExtendedInformation::Dir; + } + if (mFileInfo.isFile()) { + return QExtendedInformation::File; + } + if (!mFileInfo.exists() && mFileInfo.isSymLink()) { + return QExtendedInformation::System; + } + return QExtendedInformation::System; + } + + bool isSymLink(bool ignoreNtfsSymLinks = false) const + { + if (ignoreNtfsSymLinks) { +#ifdef Q_OS_WIN + return !mFileInfo.suffix().compare(QLatin1StringView("lnk"), Qt::CaseInsensitive); +#endif + } + return mFileInfo.isSymLink(); + } + + bool isHidden() const { + return mFileInfo.isHidden(); + } + + QFileInfo fileInfo() const { + return mFileInfo; + } + + QDateTime lastModified(const QTimeZone &tz) const { + return mFileInfo.lastModified(tz); + } + + qint64 size() const { + qint64 size = -1; + if (type() == QExtendedInformation::Dir) + size = 0; + if (type() == QExtendedInformation::File) + size = mFileInfo.size(); + if (!mFileInfo.exists() && !mFileInfo.isSymLink()) + size = -1; + return size; + } + + QString displayType; + QIcon icon; + +private : + QFileInfo mFileInfo; +}; + +class QFileIconProvider; + +class Q_GUI_EXPORT QFileInfoGatherer : public QThread +{ +Q_OBJECT + +Q_SIGNALS: + void updates(const QString &directory, const QList> &updates); + void newListOfFiles(const QString &directory, const QStringList &listOfFiles) const; + void nameResolved(const QString &fileName, const QString &resolvedName) const; + void directoryLoaded(const QString &path); + +public: + explicit QFileInfoGatherer(QObject *parent = nullptr); + ~QFileInfoGatherer(); + + QStringList watchedFiles() const; + QStringList watchedDirectories() const; + void watchPaths(const QStringList &paths); + void unwatchPaths(const QStringList &paths); + + bool isWatching() const; + void setWatching(bool v); + + // only callable from this->thread(): + void clear(); + void removePath(const QString &path); + QExtendedInformation getInfo(const QFileInfo &info) const; + QAbstractFileIconProvider *iconProvider() const; + bool resolveSymlinks() const; + + void requestAbort(); + +public Q_SLOTS: + void list(const QString &directoryPath); + void fetchExtendedInformation(const QString &path, const QStringList &files); + void updateFile(const QString &path); + void setResolveSymlinks(bool enable); + void setIconProvider(QAbstractFileIconProvider *provider); + +private Q_SLOTS: + void driveAdded(); + void driveRemoved(); + +protected: + bool event(QEvent *event) override; + +private: + void run() override; + // called by run(): + void getFileInfos(const QString &path, const QStringList &files); + void fetch(const QFileInfo &info, QElapsedTimer &base, bool &firstTime, + QList> &updatedFiles, const QString &path); + +private: + void createWatcher(); + + mutable QMutex mutex; + // begin protected by mutex + QWaitCondition condition; + QStack path; + QStack files; + // end protected by mutex + +#if QT_CONFIG(filesystemwatcher) + QFileSystemWatcher *m_watcher = nullptr; +#endif + QAbstractFileIconProvider *m_iconProvider; // not accessed by run() + QAbstractFileIconProvider defaultProvider; +#ifdef Q_OS_WIN + bool m_resolveSymlinks = true; // not accessed by run() +#endif +#if QT_CONFIG(filesystemwatcher) + bool m_watching = true; +#endif +}; + +QT_END_NAMESPACE +#endif // QFILEINFOGATHERER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfilesystemmodel_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfilesystemmodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..673e87213cd8bd53ca1b6b3c7a52e1d114a6a714 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfilesystemmodel_p.h @@ -0,0 +1,308 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFILESYSTEMMODEL_P_H +#define QFILESYSTEMMODEL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qfilesystemmodel.h" + +#include +#include +#include "qfileinfogatherer_p.h" +#include +#include +#include +#include +#include +#include + +#include + +QT_REQUIRE_CONFIG(filesystemmodel); + +QT_BEGIN_NAMESPACE + +class ExtendedInformation; +class QFileSystemModelPrivate; +class QFileIconProvider; + +#if defined(Q_OS_WIN) +class QFileSystemModelNodePathKey : public QString +{ +public: + QFileSystemModelNodePathKey() {} + QFileSystemModelNodePathKey(const QString &other) : QString(other) {} + QFileSystemModelNodePathKey(const QFileSystemModelNodePathKey &other) : QString(other) {} + bool operator==(const QFileSystemModelNodePathKey &other) const { return !compare(other, Qt::CaseInsensitive); } +}; + +Q_DECLARE_TYPEINFO(QFileSystemModelNodePathKey, Q_RELOCATABLE_TYPE); + +inline size_t qHash(const QFileSystemModelNodePathKey &key, size_t seed = 0) +{ + return qHash(key.toCaseFolded(), seed); +} +#else // Q_OS_WIN +typedef QString QFileSystemModelNodePathKey; +#endif + +class Q_GUI_EXPORT QFileSystemModelPrivate : public QAbstractItemModelPrivate +{ + Q_DECLARE_PUBLIC(QFileSystemModel) + +public: + enum { + NameColumn, + SizeColumn, + TypeColumn, + TimeColumn, + NumColumns = 4 + }; + + class QFileSystemNode + { + public: + Q_DISABLE_COPY_MOVE(QFileSystemNode) + + explicit QFileSystemNode(const QString &filename = QString(), QFileSystemNode *p = nullptr) + : fileName(filename), parent(p) {} + ~QFileSystemNode() { + qDeleteAll(children); + delete info; + } + + QString fileName; +#if defined(Q_OS_WIN) + QString volumeName; +#endif + + inline qint64 size() const { if (info && !info->isDir()) return info->size(); return 0; } + inline QString type() const { if (info) return info->displayType; return QLatin1StringView(""); } + inline QDateTime lastModified(const QTimeZone &tz) const { return info ? info->lastModified(tz) : QDateTime(); } + inline QFile::Permissions permissions() const { if (info) return info->permissions(); return { }; } + inline bool isReadable() const { return ((permissions() & QFile::ReadUser) != 0); } + inline bool isWritable() const { return ((permissions() & QFile::WriteUser) != 0); } + inline bool isExecutable() const { return ((permissions() & QFile::ExeUser) != 0); } + inline bool isDir() const { + if (info) + return info->isDir(); + if (children.size() > 0) + return true; + return false; + } + inline QFileInfo fileInfo() const { if (info) return info->fileInfo(); return QFileInfo(); } + inline bool isFile() const { if (info) return info->isFile(); return true; } + inline bool isSystem() const { if (info) return info->isSystem(); return true; } + inline bool isHidden() const { if (info) return info->isHidden(); return false; } + inline bool isSymLink(bool ignoreNtfsSymLinks = false) const { return info && info->isSymLink(ignoreNtfsSymLinks); } + inline bool caseSensitive() const { if (info) return info->isCaseSensitive(); return false; } + inline QIcon icon() const { if (info) return info->icon; return QIcon(); } + + inline bool operator <(const QFileSystemNode &node) const { + if (caseSensitive() || node.caseSensitive()) + return fileName < node.fileName; + return QString::compare(fileName, node.fileName, Qt::CaseInsensitive) < 0; + } + inline bool operator >(const QString &name) const { + if (caseSensitive()) + return fileName > name; + return QString::compare(fileName, name, Qt::CaseInsensitive) > 0; + } + inline bool operator <(const QString &name) const { + if (caseSensitive()) + return fileName < name; + return QString::compare(fileName, name, Qt::CaseInsensitive) < 0; + } + inline bool operator !=(const QExtendedInformation &fileInfo) const { + return !operator==(fileInfo); + } + bool operator ==(const QString &name) const { + if (caseSensitive()) + return fileName == name; + return QString::compare(fileName, name, Qt::CaseInsensitive) == 0; + } + bool operator ==(const QExtendedInformation &fileInfo) const { + return info && (*info == fileInfo); + } + + inline bool hasInformation() const { return info != nullptr; } + + void populate(const QExtendedInformation &fileInfo) { + if (!info) + info = new QExtendedInformation(fileInfo.fileInfo()); + (*info) = fileInfo; + } + + // children shouldn't normally be accessed directly, use node() + inline int visibleLocation(const QString &childName) { + return visibleChildren.indexOf(childName); + } + void updateIcon(QAbstractFileIconProvider *iconProvider, const QString &path) { + if (!iconProvider) + return; + + if (info) + info->icon = iconProvider->icon(QFileInfo(path)); + + for (QFileSystemNode *child : std::as_const(children)) { + //On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/) + if (!path.isEmpty()) { + if (path.endsWith(u'/')) + child->updateIcon(iconProvider, path + child->fileName); + else + child->updateIcon(iconProvider, path + u'/' + child->fileName); + } else + child->updateIcon(iconProvider, child->fileName); + } + } + + void retranslateStrings(QAbstractFileIconProvider *iconProvider, const QString &path) { + if (!iconProvider) + return; + + if (info) + info->displayType = iconProvider->type(QFileInfo(path)); + for (QFileSystemNode *child : std::as_const(children)) { + //On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/) + if (!path.isEmpty()) { + if (path.endsWith(u'/')) + child->retranslateStrings(iconProvider, path + child->fileName); + else + child->retranslateStrings(iconProvider, path + u'/' + child->fileName); + } else + child->retranslateStrings(iconProvider, child->fileName); + } + } + + QHash children; + QList visibleChildren; + QExtendedInformation *info = nullptr; + QFileSystemNode *parent; + int dirtyChildrenIndex = -1; + bool populatedChildren = false; + bool isVisible = false; + }; + + QFileSystemModelPrivate(); + ~QFileSystemModelPrivate(); + void init(); + /* + \internal + + Return true if index which is owned by node is hidden by the filter. + */ + inline bool isHiddenByFilter(QFileSystemNode *indexNode, const QModelIndex &index) const + { + return (indexNode != &root && !index.isValid()); + } + QFileSystemNode *node(const QModelIndex &index) const; + QFileSystemNode *node(const QString &path, bool fetch = true) const; + inline QModelIndex index(const QString &path, int column = 0) { return index(node(path), column); } + QModelIndex index(const QFileSystemNode *node, int column = 0) const; + bool filtersAcceptsNode(const QFileSystemNode *node) const; + bool passNameFilters(const QFileSystemNode *node) const; + void removeNode(QFileSystemNode *parentNode, const QString &name); + QFileSystemNode* addNode(QFileSystemNode *parentNode, const QString &fileName, const QFileInfo &info); + void addVisibleFiles(QFileSystemNode *parentNode, const QStringList &newFiles); + void removeVisibleFile(QFileSystemNode *parentNode, int visibleLocation); + void sortChildren(int column, const QModelIndex &parent); + + inline int translateVisibleLocation(QFileSystemNode *parent, int row) const { + if (sortOrder != Qt::AscendingOrder) { + if (parent->dirtyChildrenIndex == -1) + return parent->visibleChildren.size() - row - 1; + + if (row < parent->dirtyChildrenIndex) + return parent->dirtyChildrenIndex - row - 1; + } + + return row; + } + + inline static QString myComputer() { + // ### TODO We should query the system to find out what the string should be + // XP == "My Computer", + // Vista == "Computer", + // OS X == "Computer" (sometime user generated) "Benjamin's PowerBook G4" +#ifdef Q_OS_WIN + return QFileSystemModel::tr("My Computer"); +#else + return QFileSystemModel::tr("Computer"); +#endif + } + + inline void delayedSort() { + if (!delayedSortTimer.isActive()) + delayedSortTimer.start(0); + } + + QIcon icon(const QModelIndex &index) const; + QString name(const QModelIndex &index) const; + QString displayName(const QModelIndex &index) const; + QString filePath(const QModelIndex &index) const; + QString size(const QModelIndex &index) const; + static QString size(qint64 bytes); + QString type(const QModelIndex &index) const; + QString time(const QModelIndex &index) const; + + void directoryChanged(const QString &directory, const QStringList &list); + void performDelayedSort(); + void fileSystemChanged(const QString &path, const QList> &); + void resolvedName(const QString &fileName, const QString &resolvedName); + + QDir rootDir; +#if QT_CONFIG(filesystemwatcher) +# ifdef Q_OS_WIN + QStringList unwatchPathsAt(const QModelIndex &); + void watchPaths(const QStringList &paths) { fileInfoGatherer->watchPaths(paths); } +# endif // Q_OS_WIN + std::unique_ptr fileInfoGatherer; +#endif // filesystemwatcher + QTimer delayedSortTimer; + QHash bypassFilters; +#if QT_CONFIG(regularexpression) + QStringList nameFilters; + std::vector nameFiltersRegexps; + void rebuildNameFilterRegexps(); +#endif + QHash resolvedSymLinks; + + QFileSystemNode root; + + struct Fetching { + QString dir; + QString file; + const QFileSystemNode *node; + }; + QList toFetch; + + QBasicTimer fetchingTimer; + + QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs; + int sortColumn = 0; + Qt::SortOrder sortOrder = Qt::AscendingOrder; + bool forceSort = true; + bool readOnly = true; + bool setRootPath = false; + bool nameFilterDisables = true; // false on windows, true on mac and unix + // This flag is an optimization for QFileDialog. It enables a sort which is + // not recursive, meaning we sort only what we see. + bool disableRecursiveSort = false; +}; +Q_DECLARE_TYPEINFO(QFileSystemModelPrivate::Fetching, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfixed_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfixed_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5e12db36dcf30a79a572d96ebfed791831275c10 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfixed_p.h @@ -0,0 +1,196 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFIXED_P_H +#define QFIXED_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtCore/qdebug.h" +#include "QtCore/qpoint.h" +#include "QtCore/qnumeric.h" +#include "QtCore/qsize.h" + +QT_BEGIN_NAMESPACE + +struct QFixed { +private: + constexpr QFixed(int val, int) : val(val) {} // 2nd int is just a dummy for disambiguation +public: + constexpr QFixed() : val(0) {} + constexpr QFixed(int i) : val(i * 64) {} + constexpr QFixed(long i) : val(i * 64) {} + constexpr QFixed(long long i) : val(i * 64) {} + + constexpr static QFixed fromReal(qreal r) { return fromFixed((int)(r*qreal(64))); } + constexpr static QFixed fromFixed(int fixed) { return QFixed(fixed,0); } // uses private ctor + + constexpr inline int value() const { return val; } + inline void setValue(int value) { val = value; } + + constexpr inline int toInt() const { return (((val)+32) & -64)>>6; } + constexpr inline qreal toReal() const { return ((qreal)val)/(qreal)64; } + + constexpr inline int truncate() const { return val>>6; } + constexpr inline QFixed round() const { return fromFixed(((val)+32) & -64); } + constexpr inline QFixed floor() const { return fromFixed((val) & -64); } + constexpr inline QFixed ceil() const { return fromFixed((val+63) & -64); } + + constexpr inline QFixed operator+(int i) const { return fromFixed(val + i * 64); } + constexpr inline QFixed operator+(uint i) const { return fromFixed((val + (i<<6))); } + constexpr inline QFixed operator+(QFixed other) const { return fromFixed((val + other.val)); } + inline QFixed &operator+=(int i) { val += i * 64; return *this; } + inline QFixed &operator+=(uint i) { val += (i<<6); return *this; } + inline QFixed &operator+=(QFixed other) { val += other.val; return *this; } + constexpr inline QFixed operator-(int i) const { return fromFixed(val - i * 64); } + constexpr inline QFixed operator-(uint i) const { return fromFixed((val - (i<<6))); } + constexpr inline QFixed operator-(QFixed other) const { return fromFixed((val - other.val)); } + inline QFixed &operator-=(int i) { val -= i * 64; return *this; } + inline QFixed &operator-=(uint i) { val -= (i<<6); return *this; } + inline QFixed &operator-=(QFixed other) { val -= other.val; return *this; } + constexpr inline QFixed operator-() const { return fromFixed(-val); } + +#define REL_OP(op) \ + friend constexpr bool operator op(QFixed lhs, QFixed rhs) noexcept \ + { return lhs.val op rhs.val; } + REL_OP(==) + REL_OP(!=) + REL_OP(< ) + REL_OP(> ) + REL_OP(<=) + REL_OP(>=) +#undef REL_OP + + constexpr inline bool operator!() const { return !val; } + + inline QFixed &operator/=(int x) { val /= x; return *this; } + inline QFixed &operator/=(QFixed o) { + if (o.val == 0) { + val = 0x7FFFFFFFL; + } else { + bool neg = false; + qint64 a = val; + qint64 b = o.val; + if (a < 0) { a = -a; neg = true; } + if (b < 0) { b = -b; neg = !neg; } + + int res = (int)(((a << 6) + (b >> 1)) / b); + + val = (neg ? -res : res); + } + return *this; + } + constexpr inline QFixed operator/(int d) const { return fromFixed(val/d); } + inline QFixed operator/(QFixed b) const { QFixed f = *this; return (f /= b); } + inline QFixed operator>>(int d) const { QFixed f = *this; f.val >>= d; return f; } + inline QFixed &operator*=(int i) { val *= i; return *this; } + inline QFixed &operator*=(uint i) { val *= i; return *this; } + inline QFixed &operator*=(QFixed o) { + bool neg = false; + qint64 a = val; + qint64 b = o.val; + if (a < 0) { a = -a; neg = true; } + if (b < 0) { b = -b; neg = !neg; } + + int res = (int)((a * b + 0x20L) >> 6); + val = neg ? -res : res; + return *this; + } + constexpr inline QFixed operator*(int i) const { return fromFixed(val * i); } + constexpr inline QFixed operator*(uint i) const { return fromFixed(val * i); } + inline QFixed operator*(QFixed o) const { QFixed f = *this; return (f *= o); } + +private: + constexpr QFixed(qreal i) : val((int)(i*qreal(64))) {} + constexpr inline QFixed operator+(qreal i) const { return fromFixed((val + (int)(i*qreal(64)))); } + inline QFixed &operator+=(qreal i) { val += (int)(i*64); return *this; } + constexpr inline QFixed operator-(qreal i) const { return fromFixed((val - (int)(i*qreal(64)))); } + inline QFixed &operator-=(qreal i) { val -= (int)(i*64); return *this; } + inline QFixed &operator/=(qreal r) { val = (int)(val/r); return *this; } + constexpr inline QFixed operator/(qreal d) const { return fromFixed((int)(val/d)); } + inline QFixed &operator*=(qreal d) { val = (int) (val*d); return *this; } + constexpr inline QFixed operator*(qreal d) const { return fromFixed((int) (val*d)); } + int val; +}; +Q_DECLARE_TYPEINFO(QFixed, Q_PRIMITIVE_TYPE); + +#define QFIXED_MAX (INT_MAX/256) + +constexpr inline int qRound(QFixed f) { return f.toInt(); } +constexpr inline int qFloor(QFixed f) { return f.floor().truncate(); } + +constexpr inline QFixed operator*(int i, QFixed d) { return d*i; } +constexpr inline QFixed operator+(int i, QFixed d) { return d+i; } +constexpr inline QFixed operator-(int i, QFixed d) { return -(d-i); } +constexpr inline QFixed operator*(uint i, QFixed d) { return d*i; } +constexpr inline QFixed operator+(uint i, QFixed d) { return d+i; } +constexpr inline QFixed operator-(uint i, QFixed d) { return -(d-i); } +// constexpr inline QFixed operator*(qreal d, QFixed d2) { return d2*d; } + +inline bool qAddOverflow(QFixed v1, QFixed v2, QFixed *r) +{ + int val; + bool result = qAddOverflow(v1.value(), v2.value(), &val); + r->setValue(val); + return result; +} + +inline bool qMulOverflow(QFixed v1, QFixed v2, QFixed *r) +{ + int val; + bool result = qMulOverflow(v1.value(), v2.value(), &val); + r->setValue(val); + return result; +} + +#ifndef QT_NO_DEBUG_STREAM +inline QDebug &operator<<(QDebug &dbg, QFixed f) +{ return dbg << f.toReal(); } +#endif + +struct QFixedPoint { + QFixed x; + QFixed y; + constexpr inline QFixedPoint() {} + constexpr inline QFixedPoint(QFixed _x, QFixed _y) : x(_x), y(_y) {} + constexpr QPointF toPointF() const { return QPointF(x.toReal(), y.toReal()); } + constexpr static QFixedPoint fromPointF(const QPointF &p) { + return QFixedPoint(QFixed::fromReal(p.x()), QFixed::fromReal(p.y())); + } + constexpr inline bool operator==(const QFixedPoint &other) const + { + return x == other.x && y == other.y; + } +}; +Q_DECLARE_TYPEINFO(QFixedPoint, Q_PRIMITIVE_TYPE); + +constexpr inline QFixedPoint operator-(const QFixedPoint &p1, const QFixedPoint &p2) +{ return QFixedPoint(p1.x - p2.x, p1.y - p2.y); } +constexpr inline QFixedPoint operator+(const QFixedPoint &p1, const QFixedPoint &p2) +{ return QFixedPoint(p1.x + p2.x, p1.y + p2.y); } + +struct QFixedSize { + QFixed width; + QFixed height; + constexpr QFixedSize() {} + constexpr QFixedSize(QFixed _width, QFixed _height) : width(_width), height(_height) {} + constexpr QSizeF toSizeF() const { return QSizeF(width.toReal(), height.toReal()); } + constexpr static QFixedSize fromSizeF(const QSizeF &s) { + return QFixedSize(QFixed::fromReal(s.width()), QFixed::fromReal(s.height())); + } +}; +Q_DECLARE_TYPEINFO(QFixedSize, Q_PRIMITIVE_TYPE); + +QT_END_NAMESPACE + +#endif // QTEXTENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfont_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfont_p.h new file mode 100644 index 0000000000000000000000000000000000000000..380bc962e8cc3b9344cb8e7f54fa42e4d30b446c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfont_p.h @@ -0,0 +1,304 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFONT_P_H +#define QFONT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtGui/qfont.h" +#include "QtCore/qmap.h" +#include "QtCore/qhash.h" +#include "QtCore/qobject.h" +#include "QtCore/qstringlist.h" +#include +#include "private/qfixed_p.h" + +QT_BEGIN_NAMESPACE + +// forwards +class QFontCache; +class QFontEngine; + +#define QFONT_WEIGHT_MIN 1 +#define QFONT_WEIGHT_MAX 1000 + +struct QFontDef +{ + inline QFontDef() + : pointSize(-1.0), + pixelSize(-1), + styleStrategy(QFont::PreferDefault), + stretch(QFont::AnyStretch), + style(QFont::StyleNormal), + hintingPreference(QFont::PreferDefaultHinting), + styleHint(QFont::AnyStyle), + weight(QFont::Normal), + fixedPitch(false), + ignorePitch(true), + fixedPitchComputed(0), + reserved(0) + { + } + + QStringList families; + QString styleName; + + QStringList fallBackFamilies; + QMap variableAxisValues; + + qreal pointSize; + qreal pixelSize; + + // Note: Variable ordering matters to make sure no variable overlaps two 32-bit registers. + uint styleStrategy : 16; + uint stretch : 12; // 0-4000 + uint style : 2; + uint hintingPreference : 2; + + uint styleHint : 8; + uint weight : 10; // 1-1000 + uint fixedPitch : 1; + uint ignorePitch : 1; + uint fixedPitchComputed : 1; // for Mac OS X only + uint reserved : 11; // for future extensions + + bool exactMatch(const QFontDef &other) const; + bool operator==(const QFontDef &other) const + { + return pixelSize == other.pixelSize + && weight == other.weight + && style == other.style + && stretch == other.stretch + && styleHint == other.styleHint + && styleStrategy == other.styleStrategy + && ignorePitch == other.ignorePitch && fixedPitch == other.fixedPitch + && families == other.families + && styleName == other.styleName + && hintingPreference == other.hintingPreference + && variableAxisValues == other.variableAxisValues + ; + } + inline bool operator<(const QFontDef &other) const + { + if (pixelSize != other.pixelSize) return pixelSize < other.pixelSize; + if (weight != other.weight) return weight < other.weight; + if (style != other.style) return style < other.style; + if (stretch != other.stretch) return stretch < other.stretch; + if (styleHint != other.styleHint) return styleHint < other.styleHint; + if (styleStrategy != other.styleStrategy) return styleStrategy < other.styleStrategy; + if (families != other.families) return families < other.families; + if (styleName != other.styleName) + return styleName < other.styleName; + if (hintingPreference != other.hintingPreference) return hintingPreference < other.hintingPreference; + + + if (ignorePitch != other.ignorePitch) return ignorePitch < other.ignorePitch; + if (fixedPitch != other.fixedPitch) return fixedPitch < other.fixedPitch; + if (variableAxisValues != other.variableAxisValues) { + if (variableAxisValues.size() != other.variableAxisValues.size()) + return variableAxisValues.size() < other.variableAxisValues.size(); + + { + auto it = variableAxisValues.constBegin(); + auto jt = other.variableAxisValues.constBegin(); + for (; it != variableAxisValues.constEnd(); ++it, ++jt) { + if (it.key() != jt.key()) + return jt.key() < it.key(); + if (it.value() != jt.value()) + return jt.value() < it.value(); + } + } + } + + return false; + } +}; + +inline size_t qHash(const QFontDef &fd, size_t seed = 0) noexcept +{ + return qHashMulti(seed, + qRound64(fd.pixelSize*10000), // use only 4 fractional digits + fd.weight, + fd.style, + fd.stretch, + fd.styleHint, + fd.styleStrategy, + fd.ignorePitch, + fd.fixedPitch, + fd.families, + fd.styleName, + fd.hintingPreference, + fd.variableAxisValues.keys(), + fd.variableAxisValues.values()); +} + +class QFontEngineData +{ +public: + QFontEngineData(); + ~QFontEngineData(); + + QAtomicInt ref; + const int fontCacheId; + + QFontEngine *engines[QChar::ScriptCount]; + +private: + Q_DISABLE_COPY_MOVE(QFontEngineData) +}; + + +class Q_GUI_EXPORT QFontPrivate +{ +public: + + QFontPrivate(); + QFontPrivate(const QFontPrivate &other); + ~QFontPrivate(); + + QFontEngine *engineForScript(int script) const; + void alterCharForCapitalization(QChar &c) const; + + QAtomicInt ref; + QFontDef request; + mutable QFontEngineData *engineData; + int dpi; + + uint underline : 1; + uint overline : 1; + uint strikeOut : 1; + uint kerning : 1; + uint capital : 3; + bool letterSpacingIsAbsolute : 1; + + QFixed letterSpacing; + QFixed wordSpacing; + QHash features; + + mutable QFontPrivate *scFont; + QFont smallCapsFont() const { return QFont(smallCapsFontPrivate()); } + QFontPrivate *smallCapsFontPrivate() const; + + static QFontPrivate *get(const QFont &font) + { + return font.d.data(); + } + + void resolve(uint mask, const QFontPrivate *other); + + static void detachButKeepEngineData(QFont *font); + + void setFeature(QFont::Tag tag, quint32 value); + void unsetFeature(QFont::Tag tag); + + void setVariableAxis(QFont::Tag tag, float value); + void unsetVariableAxis(QFont::Tag tag); + bool hasVariableAxis(QFont::Tag tag, float value) const; + +private: + QFontPrivate &operator=(const QFontPrivate &) { return *this; } +}; + + +class Q_GUI_EXPORT QFontCache : public QObject +{ +public: + // note: these static functions work on a per-thread basis + static QFontCache *instance(); + static void cleanup(); + + QFontCache(); + ~QFontCache(); + + int id() const { return m_id; } + + void clear(); + + struct Key { + Key() : script(0), multi(0) { } + Key(const QFontDef &d, uchar c, bool m = 0) + : def(d), script(c), multi(m) { } + + QFontDef def; + uchar script; + uchar multi: 1; + + inline bool operator<(const Key &other) const + { + if (script != other.script) return script < other.script; + if (multi != other.multi) return multi < other.multi; + if (multi && def.fallBackFamilies.size() != other.def.fallBackFamilies.size()) + return def.fallBackFamilies.size() < other.def.fallBackFamilies.size(); + return def < other.def; + } + inline bool operator==(const Key &other) const + { + return script == other.script + && multi == other.multi + && (!multi || def.fallBackFamilies == other.def.fallBackFamilies) + && def == other.def; + } + }; + + // QFontEngineData cache + typedef QMap EngineDataCache; + EngineDataCache engineDataCache; + + QFontEngineData *findEngineData(const QFontDef &def) const; + void insertEngineData(const QFontDef &def, QFontEngineData *engineData); + + // QFontEngine cache + struct Engine { + Engine() : data(nullptr), timestamp(0), hits(0) { } + Engine(QFontEngine *d) : data(d), timestamp(0), hits(0) { } + + QFontEngine *data; + uint timestamp; + uint hits; + }; + + typedef QMultiMap EngineCache; + EngineCache engineCache; + QHash engineCacheCount; + + QFontEngine *findEngine(const Key &key); + + void updateHitCountAndTimeStamp(Engine &value); + void insertEngine(const Key &key, QFontEngine *engine, bool insertMulti = false); + +private: + void increaseCost(uint cost); + void decreaseCost(uint cost); + void timerEvent(QTimerEvent *event) override; + void decreaseCache(); + + static const uint min_cost; + uint total_cost, max_cost; + uint current_timestamp; + bool fast; + const bool autoClean; + int timer_id; + const int m_id; +}; + +Q_GUI_EXPORT int qt_defaultDpiX(); +Q_GUI_EXPORT int qt_defaultDpiY(); +Q_GUI_EXPORT int qt_defaultDpi(); + +Q_GUI_EXPORT int qt_legacyToOpenTypeWeight(int weight); +Q_GUI_EXPORT int qt_openTypeToLegacyWeight(int weight); + +QT_END_NAMESPACE + +#endif // QFONT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontdatabase_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontdatabase_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b1bc10dd8a40b1cbda00acfe566aa2c22e9f4be5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontdatabase_p.h @@ -0,0 +1,270 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFONTDATABASE_P_H +#define QFONTDATABASE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +struct QtFontDesc; + +struct QtFontFallbacksCacheKey +{ + QString family; + QFont::Style style; + QFont::StyleHint styleHint; + QChar::Script script; +}; + +inline bool operator==(const QtFontFallbacksCacheKey &lhs, const QtFontFallbacksCacheKey &rhs) noexcept +{ + return lhs.script == rhs.script && + lhs.styleHint == rhs.styleHint && + lhs.style == rhs.style && + lhs.family == rhs.family; +} + +inline bool operator!=(const QtFontFallbacksCacheKey &lhs, const QtFontFallbacksCacheKey &rhs) noexcept +{ + return !operator==(lhs, rhs); +} + +inline size_t qHash(const QtFontFallbacksCacheKey &key, size_t seed = 0) noexcept +{ + QtPrivate::QHashCombine hash; + seed = hash(seed, key.family); + seed = hash(seed, int(key.style)); + seed = hash(seed, int(key.styleHint)); + seed = hash(seed, int(key.script)); + return seed; +} + +struct Q_GUI_EXPORT QtFontSize +{ + void *handle; + unsigned short pixelSize : 16; +}; + +struct Q_GUI_EXPORT QtFontStyle +{ + struct Key + { + Key(const QString &styleString); + + Key() + : style(QFont::StyleNormal) + , weight(QFont::Normal) + , stretch(0) + {} + + Key(const Key &o) + : style(o.style) + , weight(o.weight) + , stretch(o.stretch) + {} + + uint style : 2; + uint weight : 10; + signed int stretch : 12; + + bool operator==(const Key &other) const noexcept + { + return (style == other.style && weight == other.weight && + (stretch == 0 || other.stretch == 0 || stretch == other.stretch)); + } + + bool operator!=(const Key &other) const noexcept + { + return !operator==(other); + } + }; + + QtFontStyle(const Key &k) + : key(k) + , bitmapScalable(false) + , smoothScalable(false) + , count(0) + , pixelSizes(nullptr) + { + } + + ~QtFontStyle(); + + QtFontSize *pixelSize(unsigned short size, bool = false); + + Key key; + bool bitmapScalable : 1; + bool smoothScalable : 1; + signed int count : 30; + QtFontSize *pixelSizes; + QString styleName; + bool antialiased; +}; + +struct Q_GUI_EXPORT QtFontFoundry +{ + QtFontFoundry(const QString &n) + : name(n) + , count(0) + , styles(nullptr) + {} + + ~QtFontFoundry() + { + while (count--) + delete styles[count]; + free(styles); + } + + QString name; + int count; + QtFontStyle **styles; + QtFontStyle *style(const QtFontStyle::Key &, const QString & = QString(), bool = false); +}; + +struct Q_GUI_EXPORT QtFontFamily +{ + enum WritingSystemStatus { + Unknown = 0, + Supported = 1, + UnsupportedFT = 2, + Unsupported = UnsupportedFT + }; + + QtFontFamily(const QString &n) + : + populated(false), + fixedPitch(false), + name(n), count(0), foundries(nullptr) + { + memset(writingSystems, 0, sizeof(writingSystems)); + } + ~QtFontFamily() { + while (count--) + delete foundries[count]; + free(foundries); + } + + bool populated : 1; + bool fixedPitch : 1; + + QString name; + QStringList aliases; + int count; + QtFontFoundry **foundries; + + unsigned char writingSystems[QFontDatabase::WritingSystemsCount]; + + bool matchesFamilyName(const QString &familyName) const; + QtFontFoundry *foundry(const QString &f, bool = false); + + bool ensurePopulated(); +}; + +class Q_GUI_EXPORT QFontDatabasePrivate +{ +public: + QFontDatabasePrivate() + : count(0) + , families(nullptr) + , fallbacksCache(64) + { } + + ~QFontDatabasePrivate() { + clearFamilies(); + } + + void clearFamilies(); + + enum FamilyRequestFlags { + RequestFamily = 0, + EnsureCreated, + EnsurePopulated + }; + + QtFontFamily *family(const QString &f, FamilyRequestFlags flags = EnsurePopulated); + + int count; + QtFontFamily **families; + bool populated = false; + + QHash applicationFallbackFontFamilies; + + QCache fallbacksCache; + struct ApplicationFont { + QString fileName; + + // Note: The data may be implicitly shared throughout the + // font database and platform font database, so be careful + // to never detach when accessing this member! + QByteArray data; + + bool isNull() const { return fileName.isEmpty(); } + bool isPopulated() const { return !properties.isEmpty(); } + + struct Properties { + QString familyName; + QString styleName; + int weight = 0; + QFont::Style style = QFont::StyleNormal; + int stretch = QFont::Unstretched; + }; + + QList properties; + }; + QList applicationFonts; + int addAppFont(const QByteArray &fontData, const QString &fileName); + bool isApplicationFont(const QString &fileName); + + static QFontDatabasePrivate *instance(); + + static void parseFontName(const QString &name, QString &foundry, QString &family); + static QString resolveFontFamilyAlias(const QString &family); + static QFontEngine *findFont(const QFontDef &request, + int script /* QChar::Script */, + bool preferScriptOverFamily = false); + static void load(const QFontPrivate *d, int script /* QChar::Script */); + static QFontDatabasePrivate *ensureFontDatabase(); + + void invalidate(); + +private: + static int match(int script, const QFontDef &request, const QString &family_name, + const QString &foundry_name, QtFontDesc *desc, const QList &blacklistedFamilies, + unsigned int *resultingScore = nullptr); + + static unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, + const QtFontFamily *family, const QString &foundry_name, + QtFontStyle::Key styleKey, int pixelSize, char pitch, + QtFontDesc *desc, const QString &styleName = QString()); + + static QFontEngine *loadSingleEngine(int script, const QFontDef &request, + QtFontFamily *family, QtFontFoundry *foundry, + QtFontStyle *style, QtFontSize *size); + + static QFontEngine *loadEngine(int script, const QFontDef &request, + QtFontFamily *family, QtFontFoundry *foundry, + QtFontStyle *style, QtFontSize *size); + +}; +Q_DECLARE_TYPEINFO(QFontDatabasePrivate::ApplicationFont, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + +#endif // QFONTDATABASE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontengine_ft_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontengine_ft_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f5ae0d0a8ce7f2db65694329914646484343231d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontengine_ft_p.h @@ -0,0 +1,353 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QFONTENGINE_FT_P_H +#define QFONTENGINE_FT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qfontengine_p.h" + +#ifndef QT_NO_FREETYPE + +#include +#include FT_FREETYPE_H +#include FT_MULTIPLE_MASTERS_H + + +#ifndef Q_OS_WIN +#include +#endif + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QFontEngineFTRawFont; +class QFontconfigDatabase; + +/* + * This class represents one font file on disk (like Arial.ttf) and is shared between all the font engines + * that show this font file (at different pixel sizes). + */ +class Q_GUI_EXPORT QFreetypeFace +{ +public: + void computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing, QFixed *scalableBitmapScaleFactor); + QFontEngine::Properties properties() const; + bool getSfntTable(uint tag, uchar *buffer, uint *length) const; + + static QFreetypeFace *getFace(const QFontEngine::FaceId &face_id, + const QByteArray &fontData = QByteArray()); + void release(const QFontEngine::FaceId &face_id); + + static int getFaceIndexByStyleName(const QString &faceFileName, const QString &styleName); + + // locks the struct for usage. Any read/write operations require locking. + void lock() + { + _lock.lock(); + } + void unlock() + { + _lock.unlock(); + } + + FT_Face face; + FT_MM_Var *mm_var; + int xsize; // 26.6 + int ysize; // 26.6 + FT_Matrix matrix; + FT_CharMap unicode_map; + FT_CharMap symbol_map; + + enum { cmapCacheSize = 0x200 }; + glyph_t cmapCache[cmapCacheSize]; + + int fsType() const; + + int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints); + + bool isScalableBitmap() const; + + static void addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoint &point, QPainterPath *path, FT_Fixed x_scale, FT_Fixed y_scale); + static void addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path); + +private: + friend class QFontEngineFT; + friend class QtFreetypeData; + QFreetypeFace() = default; + ~QFreetypeFace() {} + void cleanup(); + QAtomicInt ref; + QRecursiveMutex _lock; + QByteArray fontData; + + QFontEngine::Holder hbFace; +}; + +class Q_GUI_EXPORT QFontEngineFT : public QFontEngine +{ +public: + struct GlyphInfo { + int linearAdvance; + unsigned short width; + unsigned short height; + short x; + short y; + short xOff; + short yOff; + }; + + struct GlyphAndSubPixelPosition + { + GlyphAndSubPixelPosition(glyph_t g, const QFixedPoint spp) : glyph(g), subPixelPosition(spp) {} + + bool operator==(const GlyphAndSubPixelPosition &other) const + { + return glyph == other.glyph && subPixelPosition == other.subPixelPosition; + } + + glyph_t glyph; + QFixedPoint subPixelPosition; + }; + + struct QGlyphSet + { + QGlyphSet(); + ~QGlyphSet(); + FT_Matrix transformationMatrix; + bool outline_drawing; + + void removeGlyphFromCache(glyph_t index, const QFixedPoint &subPixelPosition); + void clear(); + inline bool useFastGlyphData(glyph_t index, const QFixedPoint &subPixelPosition) const { + return (index < 256 && subPixelPosition.x == 0 && subPixelPosition.y == 0); + } + inline Glyph *getGlyph(glyph_t index, + const QFixedPoint &subPixelPositionX = QFixedPoint()) const; + void setGlyph(glyph_t index, const QFixedPoint &spp, Glyph *glyph); + + inline bool isGlyphMissing(glyph_t index) const { return missing_glyphs.contains(index); } + inline void setGlyphMissing(glyph_t index) const { missing_glyphs.insert(index); } +private: + Q_DISABLE_COPY(QGlyphSet); + mutable QHash glyph_data; // maps from glyph index to glyph data + mutable QSet missing_glyphs; + mutable Glyph *fast_glyph_data[256]; // for fast lookup of glyphs < 256 + mutable int fast_glyph_count; + }; + + QFontEngine::FaceId faceId() const override; + QFontEngine::Properties properties() const override; + QFixed emSquareSize() const override; + bool supportsHorizontalSubPixelPositions() const override + { + return default_hint_style == HintLight || + default_hint_style == HintNone; + } + + bool supportsVerticalSubPixelPositions() const override + { + return supportsHorizontalSubPixelPositions(); + } + + bool getSfntTableData(uint tag, uchar *buffer, uint *length) const override; + int synthesized() const override; + + void initializeHeightMetrics() const override; + QFixed capHeight() const override; + QFixed xHeight() const override; + QFixed averageCharWidth() const override; + + qreal maxCharWidth() const override; + QFixed lineThickness() const override; + QFixed underlinePosition() const override; + + glyph_t glyphIndex(uint ucs4) const override; + void doKerning(QGlyphLayout *, ShaperFlags) const override; + + void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) override; + + bool supportsTransformation(const QTransform &transform) const override; + + void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, + QPainterPath *path, QTextItem::RenderFlags flags) override; + void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, + QPainterPath *path, QTextItem::RenderFlags flags) override; + + int stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const override; + + glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) override; + glyph_metrics_t boundingBox(glyph_t glyph) override; + glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix) override; + + void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags flags) const override; + QImage alphaMapForGlyph(glyph_t g) override { return alphaMapForGlyph(g, QFixedPoint()); } + QImage alphaMapForGlyph(glyph_t, const QFixedPoint &) override; + QImage alphaMapForGlyph(glyph_t glyph, const QFixedPoint &subPixelPosition, const QTransform &t) override; + QImage alphaRGBMapForGlyph(glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t) override; + QImage bitmapForGlyph(glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t, const QColor &color) override; + glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, + const QFixedPoint &subPixelPosition, + const QTransform &matrix, + QFontEngine::GlyphFormat format) override; + Glyph *glyphData(glyph_t glyph, + const QFixedPoint &subPixelPosition, + GlyphFormat neededFormat, + const QTransform &t) override; + bool hasInternalCaching() const override { return cacheEnabled; } + bool expectsGammaCorrectedBlending() const override; + + void removeGlyphFromCache(glyph_t glyph) override; + int glyphMargin(QFontEngine::GlyphFormat /* format */) override { return 0; } + + int glyphCount() const override; + + enum Scaling { + Scaled, + Unscaled + }; + FT_Face lockFace(Scaling scale = Scaled) const; + void unlockFace() const; + + FT_Face non_locked_face() const; + + inline bool drawAntialiased() const { return antialias; } + inline bool invalid() const { return xsize == 0 && ysize == 0; } + inline bool isBitmapFont() const { return defaultFormat == Format_Mono; } + inline bool isScalableBitmap() const { return freetype->isScalableBitmap(); } + + inline Glyph *loadGlyph(uint glyph, + const QFixedPoint &subPixelPosition, + GlyphFormat format = Format_None, + bool fetchMetricsOnly = false, + bool disableOutlineDrawing = false) const + { return loadGlyph(cacheEnabled ? &defaultGlyphSet : nullptr, glyph, subPixelPosition, format, fetchMetricsOnly, disableOutlineDrawing); } + Glyph *loadGlyph(QGlyphSet *set, + uint glyph, + const QFixedPoint &subPixelPosition, + GlyphFormat = Format_None, + bool fetchMetricsOnly = false, + bool disableOutlineDrawing = false) const; + Glyph *loadGlyphFor(glyph_t g, + const QFixedPoint &subPixelPosition, + GlyphFormat format, + const QTransform &t, + bool fetchBoundingBox = false, + bool disableOutlineDrawing = false); + + QGlyphSet *loadGlyphSet(const QTransform &matrix); + + QFontEngineFT(const QFontDef &fd); + virtual ~QFontEngineFT(); + + bool init(FaceId faceId, bool antiaalias, GlyphFormat defaultFormat = Format_None, + const QByteArray &fontData = QByteArray()); + bool init(FaceId faceId, bool antialias, GlyphFormat format, + QFreetypeFace *freetypeFace); + + int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints) override; + + void setQtDefaultHintStyle(QFont::HintingPreference hintingPreference); + void setDefaultHintStyle(HintStyle style) override; + + QFontEngine *cloneWithSize(qreal pixelSize) const override; + Qt::HANDLE handle() const override; + bool initFromFontEngine(const QFontEngineFT *fontEngine); + + HintStyle defaultHintStyle() const { return default_hint_style; } + + static QFontEngineFT *create(const QFontDef &fontDef, FaceId faceId, const QByteArray &fontData = QByteArray()); + static QFontEngineFT *create(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference, const QMap &variableAxisValue); + +protected: + + QFreetypeFace *freetype; + mutable int default_load_flags; + HintStyle default_hint_style; + bool antialias; + bool transform; + bool embolden; + bool obliquen; + SubpixelAntialiasingType subpixelType; + int lcdFilterType; + bool embeddedbitmap; + bool cacheEnabled; + bool forceAutoHint; + bool stemDarkeningDriver; + +private: + friend class QFontEngineFTRawFont; + friend class QFontconfigDatabase; + friend class QFreeTypeFontDatabase; + friend class QFontEngineMultiFontConfig; + + int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const; + bool shouldUseDesignMetrics(ShaperFlags flags) const; + QFixed scaledBitmapMetrics(QFixed m) const; + glyph_metrics_t scaledBitmapMetrics(const glyph_metrics_t &m, const QTransform &matrix) const; + + GlyphFormat defaultFormat; + FT_Matrix matrix; + + struct TransformedGlyphSets { + enum { nSets = 10 }; + QGlyphSet *sets[nSets]; + + QGlyphSet *findSet(const QTransform &matrix, const QFontDef &fontDef); + TransformedGlyphSets() { std::fill(&sets[0], &sets[nSets], nullptr); } + ~TransformedGlyphSets() { qDeleteAll(&sets[0], &sets[nSets]); } + private: + void moveToFront(int i); + Q_DISABLE_COPY(TransformedGlyphSets); + }; + TransformedGlyphSets transformedGlyphSets; + mutable QGlyphSet defaultGlyphSet; + + QFontEngine::FaceId face_id; + + int xsize; + int ysize; + + QFixed line_thickness; + QFixed underline_position; + + FT_Size_Metrics metrics; + mutable bool kerning_pairs_loaded; + QFixed scalableBitmapScaleFactor; +}; + + +inline size_t qHash(const QFontEngineFT::GlyphAndSubPixelPosition &g, size_t seed = 0) +{ + return qHashMulti(seed, + g.glyph, + g.subPixelPosition.x.value(), + g.subPixelPosition.y.value()); +} + +inline QFontEngineFT::Glyph *QFontEngineFT::QGlyphSet::getGlyph(glyph_t index, + const QFixedPoint &subPixelPosition) const +{ + if (useFastGlyphData(index, subPixelPosition)) + return fast_glyph_data[index]; + return glyph_data.value(GlyphAndSubPixelPosition(index, subPixelPosition)); +} + +Q_GUI_EXPORT FT_Library qt_getFreetype(); + +QT_END_NAMESPACE + +#endif // QT_NO_FREETYPE + +#endif // QFONTENGINE_FT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontengine_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..073ea1b11e1602468d24dc36c53f806f9489534c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontengine_p.h @@ -0,0 +1,511 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFONTENGINE_P_H +#define QFONTENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtCore/qatomic.h" +#include +#include +#include "private/qtextengine_p.h" +#include "private/qfont_p.h" + +QT_BEGIN_NAMESPACE + +class QPainterPath; +class QFontEngineGlyphCache; + +struct QGlyphLayout; + +// ### this only used in getPointInOutline(), refactor it and then remove these magic numbers +enum HB_Compat_Error { + Err_Ok = 0x0000, + Err_Not_Covered = 0xFFFF, + Err_Invalid_Argument = 0x1A66, + Err_Invalid_SubTable_Format = 0x157F, + Err_Invalid_SubTable = 0x1570 +}; + +typedef void (*qt_destroy_func_t) (void *user_data); +typedef bool (*qt_get_font_table_func_t) (void *user_data, uint tag, uchar *buffer, uint *length); + +class Q_GUI_EXPORT QFontEngine +{ +public: + enum Type { + Box, + Multi, + + // MS Windows types + Win, + + // Apple Mac OS types + Mac, + + // QWS types + Freetype, + QPF1, + QPF2, + Proxy, + + DirectWrite, + + TestFontEngine = 0x1000 + }; + + enum GlyphFormat { + Format_None, + Format_Render = Format_None, + Format_Mono, + Format_A8, + Format_A32, + Format_ARGB + }; + + enum ShaperFlag { + DesignMetrics = 0x0002, + GlyphIndicesOnly = 0x0004, + FullStringFallback = 0x008 + }; + Q_DECLARE_FLAGS(ShaperFlags, ShaperFlag) + + /* Used with the Freetype font engine. */ + struct Glyph { + Glyph() = default; + ~Glyph() { delete [] data; } + short linearAdvance = 0; + unsigned short width = 0; + unsigned short height = 0; + short x = 0; + short y = 0; + short advance = 0; + signed char format = 0; + uchar *data = nullptr; + private: + Q_DISABLE_COPY(Glyph) + }; + + virtual ~QFontEngine(); + + inline Type type() const { return m_type; } + + // all of these are in unscaled metrics if the engine supports uncsaled metrics, + // otherwise in design metrics + struct Properties { + QByteArray postscriptName; + QByteArray copyright; + QRectF boundingBox; + QFixed emSquare; + QFixed ascent; + QFixed descent; + QFixed leading; + QFixed italicAngle; + QFixed capHeight; + QFixed lineWidth; + }; + virtual Properties properties() const; + virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics); + QByteArray getSfntTable(uint tag) const; + virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const; + + struct FaceId { + FaceId() : index(0), instanceIndex(-1), encoding(0) {} + QByteArray filename; + QByteArray uuid; + int index; + int instanceIndex; + int encoding; + QMap variableAxes; + }; + virtual FaceId faceId() const { return FaceId(); } + enum SynthesizedFlags { + SynthesizedItalic = 0x1, + SynthesizedBold = 0x2, + SynthesizedStretch = 0x4 + }; + virtual int synthesized() const { return 0; } + inline bool supportsSubPixelPositions() const + { + return supportsHorizontalSubPixelPositions() || supportsVerticalSubPixelPositions(); + } + virtual bool supportsHorizontalSubPixelPositions() const { return false; } + virtual bool supportsVerticalSubPixelPositions() const { return false; } + virtual QFixedPoint subPixelPositionFor(const QFixedPoint &position) const; + QFixed subPixelPositionForX(QFixed x) const + { + return subPixelPositionFor(QFixedPoint(x, 0)).x; + } + + bool preferTypoLineMetrics() const; + bool isColorFont() const { return glyphFormat == Format_ARGB; } + static bool isIgnorableChar(char32_t ucs4) + { + return ucs4 == QChar::LineSeparator + || ucs4 == QChar::LineFeed + || ucs4 == QChar::CarriageReturn + || ucs4 == QChar::ParagraphSeparator + || QChar::category(ucs4) == QChar::Other_Control; + } + + virtual QFixed emSquareSize() const { return ascent(); } + + /* returns 0 as glyph index for non existent glyphs */ + virtual glyph_t glyphIndex(uint ucs4) const = 0; + virtual int stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const = 0; + virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const {} + virtual void doKerning(QGlyphLayout *, ShaperFlags) const; + + virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, + QPainterPath *path, QTextItem::RenderFlags flags); + + void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, + QVarLengthArray &glyphs_out, QVarLengthArray &positions); + + virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags); + void addBitmapFontToPath(qreal x, qreal y, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags); + /** + * Create a qimage with the alpha values for the glyph. + * Returns an image indexed_8 with index values ranging from 0=fully transparent to 255=opaque + */ + // ### Refactor this into a smaller and more flexible API. + virtual QImage alphaMapForGlyph(glyph_t); + virtual QImage alphaMapForGlyph(glyph_t glyph, const QFixedPoint &subPixelPosition); + virtual QImage alphaMapForGlyph(glyph_t, const QTransform &t); + virtual QImage alphaMapForGlyph(glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t); + virtual QImage alphaRGBMapForGlyph(glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t); + virtual QImage bitmapForGlyph(glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t, const QColor &color = QColor()); + QImage renderedPathForGlyph(glyph_t glyph, const QColor &color); + virtual Glyph *glyphData(glyph_t glyph, const QFixedPoint &subPixelPosition, GlyphFormat neededFormat, const QTransform &t); + virtual bool hasInternalCaching() const { return false; } + + virtual glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, const QFixedPoint &/*subPixelPosition*/, const QTransform &matrix, GlyphFormat /*format*/) + { + return boundingBox(glyph, matrix); + } + + virtual void removeGlyphFromCache(glyph_t); + + virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs); + virtual glyph_metrics_t boundingBox(glyph_t glyph) = 0; + virtual glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix); + glyph_metrics_t tightBoundingBox(const QGlyphLayout &glyphs); + + virtual QFixed ascent() const; + virtual QFixed capHeight() const = 0; + virtual QFixed descent() const; + virtual QFixed leading() const; + virtual QFixed xHeight() const; + virtual QFixed averageCharWidth() const; + + virtual QFixed lineThickness() const; + virtual QFixed underlinePosition() const; + + virtual qreal maxCharWidth() const = 0; + virtual qreal minLeftBearing() const; + virtual qreal minRightBearing() const; + + virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = nullptr, qreal *rightBearing = nullptr); + + inline bool canRender(uint ucs4) const { return glyphIndex(ucs4) != 0; } + virtual bool canRender(const QChar *str, int len) const; + + virtual bool supportsTransformation(const QTransform &transform) const; + + virtual int glyphCount() const; + virtual int glyphMargin(GlyphFormat format) { return format == Format_A32 ? 2 : 0; } + + virtual QFontEngine *cloneWithSize(qreal /*pixelSize*/) const { return nullptr; } + + virtual Qt::HANDLE handle() const; + + void *harfbuzzFont() const; + void *harfbuzzFace() const; + bool supportsScript(QChar::Script script) const; + + inline static bool scriptRequiresOpenType(QChar::Script script) + { + return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala) + || script == QChar::Script_Khmer || script == QChar::Script_Nko); + } + + virtual int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints); + + void clearGlyphCache(const void *key); + void setGlyphCache(const void *key, QFontEngineGlyphCache *data); + QFontEngineGlyphCache *glyphCache(const void *key, GlyphFormat format, const QTransform &transform, const QColor &color = QColor()) const; + + static const uchar *getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize); + static quint32 getTrueTypeGlyphIndex(const uchar *cmap, int cmapSize, uint unicode); + + static QByteArray convertToPostscriptFontFamilyName(const QByteArray &fontFamily); + + virtual bool hasUnreliableGlyphOutline() const; + virtual bool expectsGammaCorrectedBlending() const; + + enum HintStyle { + HintNone, + HintLight, + HintMedium, + HintFull + }; + virtual void setDefaultHintStyle(HintStyle) { } + + enum SubpixelAntialiasingType { + Subpixel_None, + Subpixel_RGB, + Subpixel_BGR, + Subpixel_VRGB, + Subpixel_VBGR + }; + +private: + const Type m_type; + +public: + QAtomicInt ref; + QFontDef fontDef; + + class Holder { // replace by std::unique_ptr once available + void *ptr; + qt_destroy_func_t destroy_func; + public: + Holder() : ptr(nullptr), destroy_func(nullptr) {} + explicit Holder(void *p, qt_destroy_func_t d) : ptr(p), destroy_func(d) {} + ~Holder() { if (ptr && destroy_func) destroy_func(ptr); } + Holder(Holder &&other) noexcept + : ptr(std::exchange(other.ptr, nullptr)), + destroy_func(std::exchange(other.destroy_func, nullptr)) + { + } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(Holder) + + void swap(Holder &other) noexcept + { + qSwap(ptr, other.ptr); + qSwap(destroy_func, other.destroy_func); + } + + void *get() const noexcept { return ptr; } + void *release() noexcept { + void *result = ptr; + ptr = nullptr; + destroy_func = nullptr; + return result; + } + void reset() noexcept { Holder().swap(*this); } + qt_destroy_func_t get_deleter() const noexcept { return destroy_func; } + + bool operator!() const noexcept { return !ptr; } + }; + + mutable Holder font_; // \ NOTE: Declared before m_glyphCaches, so font_, face_ + mutable Holder face_; // / are destroyed _after_ m_glyphCaches is destroyed. + + struct FaceData { + void *user_data; + qt_get_font_table_func_t get_font_table; + } faceData; + + uint cache_cost; // amount of mem used in bytes by the font + uint fsType : 16; + bool symbol; + bool isSmoothlyScalable; + struct KernPair { + uint left_right; + QFixed adjust; + + inline bool operator<(const KernPair &other) const + { + return left_right < other.left_right; + } + }; + QList kerning_pairs; + void loadKerningPairs(QFixed scalingFactor); + + GlyphFormat glyphFormat; + int m_subPixelPositionCount; // Number of positions within a single pixel for this cache + +protected: + explicit QFontEngine(Type type); + + QFixed firstLeftBearing(const QGlyphLayout &glyphs); + QFixed lastRightBearing(const QGlyphLayout &glyphs); + + QFixed calculatedCapHeight() const; + + mutable QFixed m_ascent; + mutable QFixed m_descent; + mutable QFixed m_leading; + mutable bool m_heightMetricsQueried; + + virtual void initializeHeightMetrics() const; + bool processHheaTable() const; + bool processOS2Table() const; + +private: + struct GlyphCacheEntry { + GlyphCacheEntry(); + GlyphCacheEntry(const GlyphCacheEntry &); + ~GlyphCacheEntry(); + + GlyphCacheEntry &operator=(const GlyphCacheEntry &); + + QExplicitlySharedDataPointer cache; + bool operator==(const GlyphCacheEntry &other) const { return cache == other.cache; } + }; + typedef std::list GlyphCaches; + mutable QHash m_glyphCaches; + +private: + mutable qreal m_minLeftBearing; + mutable qreal m_minRightBearing; +}; +Q_DECLARE_TYPEINFO(QFontEngine::KernPair, Q_PRIMITIVE_TYPE); + +Q_DECLARE_OPERATORS_FOR_FLAGS(QFontEngine::ShaperFlags) + +inline bool operator ==(const QFontEngine::FaceId &f1, const QFontEngine::FaceId &f2) +{ + return f1.index == f2.index + && f1.encoding == f2.encoding + && f1.filename == f2.filename + && f1.uuid == f2.uuid + && f1.instanceIndex == f2.instanceIndex + && f1.variableAxes == f2.variableAxes; +} + +inline size_t qHash(const QFontEngine::FaceId &f, size_t seed = 0) + noexcept(noexcept(qHash(f.filename))) +{ + return qHashMulti(seed, f.filename, f.uuid, f.index, f.instanceIndex, f.encoding, f.variableAxes.keys(), f.variableAxes.values()); +} + + +class QGlyph; + + + +class QFontEngineBox : public QFontEngine +{ +public: + QFontEngineBox(int size); + ~QFontEngineBox(); + + virtual glyph_t glyphIndex(uint ucs4) const override; + virtual int stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const override; + virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const override; + + void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si); + virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags) override; + + virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) override; + virtual glyph_metrics_t boundingBox(glyph_t glyph) override; + virtual QFontEngine *cloneWithSize(qreal pixelSize) const override; + + virtual QFixed ascent() const override; + virtual QFixed capHeight() const override; + virtual QFixed descent() const override; + virtual QFixed leading() const override; + virtual qreal maxCharWidth() const override; + virtual qreal minLeftBearing() const override { return 0; } + virtual qreal minRightBearing() const override { return 0; } + virtual QImage alphaMapForGlyph(glyph_t) override; + + virtual bool canRender(const QChar *string, int len) const override; + + inline int size() const { return _size; } + +protected: + explicit QFontEngineBox(Type type, int size); + +private: + friend class QFontPrivate; + int _size; +}; + +class Q_GUI_EXPORT QFontEngineMulti : public QFontEngine +{ +public: + explicit QFontEngineMulti(QFontEngine *engine, int script, const QStringList &fallbackFamilies = QStringList()); + ~QFontEngineMulti(); + + virtual glyph_t glyphIndex(uint ucs4) const override; + virtual int stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const override; + + virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) override; + virtual glyph_metrics_t boundingBox(glyph_t glyph) override; + + virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const override; + virtual void doKerning(QGlyphLayout *, ShaperFlags) const override; + virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags) override; + virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = nullptr, qreal *rightBearing = nullptr) override; + + virtual QFixed ascent() const override; + virtual QFixed capHeight() const override; + virtual QFixed descent() const override; + virtual QFixed leading() const override; + virtual QFixed xHeight() const override; + virtual QFixed averageCharWidth() const override; + virtual QImage alphaMapForGlyph(glyph_t) override; + virtual QImage alphaMapForGlyph(glyph_t glyph, const QFixedPoint &subPixelPosition) override; + virtual QImage alphaMapForGlyph(glyph_t, const QTransform &t) override; + virtual QImage alphaMapForGlyph(glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t) override; + virtual QImage alphaRGBMapForGlyph(glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t) override; + + virtual QFixed lineThickness() const override; + virtual QFixed underlinePosition() const override; + virtual qreal maxCharWidth() const override; + virtual qreal minLeftBearing() const override; + virtual qreal minRightBearing() const override; + + virtual bool canRender(const QChar *string, int len) const override; + + inline int fallbackFamilyCount() const { return m_fallbackFamilies.size(); } + inline QString fallbackFamilyAt(int at) const { return m_fallbackFamilies.at(at); } + + void setFallbackFamiliesList(const QStringList &fallbackFamilies); + + static uchar highByte(glyph_t glyph); // Used for determining engine + + inline QFontEngine *engine(int at) const + { Q_ASSERT(at < m_engines.size()); return m_engines.at(at); } + + void ensureEngineAt(int at); + + static QFontEngine *createMultiFontEngine(QFontEngine *fe, int script); + +protected: + virtual void ensureFallbackFamiliesQueried(); + virtual bool shouldLoadFontEngineForCharacter(int at, uint ucs4) const; + virtual QFontEngine *loadEngine(int at); + +private: + QList m_engines; + QStringList m_fallbackFamilies; + const int m_script; + bool m_fallbackFamiliesQueried; +}; + +class QTestFontEngine : public QFontEngineBox +{ +public: + QTestFontEngine(int size); +}; + +QT_END_NAMESPACE + + + +#endif // QFONTENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontengineglyphcache_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontengineglyphcache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e4c9db79e3fae3aaab3c0222a76a8d18c46aeff4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontengineglyphcache_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFONTENGINEGLYPHCACHE_P_H +#define QFONTENGINEGLYPHCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include "QtCore/qatomic.h" +#include +#include "private/qfont_p.h" +#include "private/qfontengine_p.h" + + + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QFontEngineGlyphCache: public QSharedData +{ +public: + QFontEngineGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix, const QColor &color = QColor()) + : m_format(format) + , m_transform(matrix) + , m_color(color) + { + Q_ASSERT(m_format != QFontEngine::Format_None); + } + + virtual ~QFontEngineGlyphCache(); + + QFontEngine::GlyphFormat glyphFormat() const { return m_format; } + const QTransform &transform() const { return m_transform; } + const QColor &color() const { return m_color; } + + QFontEngine::GlyphFormat m_format; + QTransform m_transform; + QColor m_color; +}; +typedef QHash > GlyphPointerHash; +typedef QHash > GlyphIntHash; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontsubset_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontsubset_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e41b9db80e4b838c39141dbf728bdce461029fad --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfontsubset_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFONTSUBSET_P_H +#define QFONTSUBSET_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "private/qfontengine_p.h" + +QT_BEGIN_NAMESPACE + +class QFontSubset +{ +public: + explicit QFontSubset(QFontEngine *fe, uint obj_id = 0) + : object_id(obj_id), noEmbed(false), fontEngine(fe), downloaded_glyphs(0), standard_font(false) + { + fontEngine->ref.ref(); +#ifndef QT_NO_PDF + addGlyph(0); +#endif + } + ~QFontSubset() { + if (!fontEngine->ref.deref()) + delete fontEngine; + } + + QByteArray toTruetype() const; +#ifndef QT_NO_PDF + QByteArray widthArray() const; + QByteArray createToUnicodeMap() const; + QList getReverseMap() const; + + static QByteArray glyphName(unsigned short unicode, bool symbol); + + qsizetype addGlyph(uint index); +#endif + const uint object_id; + bool noEmbed; + QFontEngine *fontEngine; + QList glyph_indices; + mutable int downloaded_glyphs; + mutable bool standard_font; + qsizetype nGlyphs() const { return glyph_indices.size(); } + mutable QFixed emSquare; + mutable QList widths; +}; + +QT_END_NAMESPACE + +#endif // QFONTSUBSET_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfragmentmap_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfragmentmap_p.h new file mode 100644 index 0000000000000000000000000000000000000000..87529ebc311c7cb575ac5dd37384efc7c1d96c51 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfragmentmap_p.h @@ -0,0 +1,849 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFRAGMENTMAP_P_H +#define QFRAGMENTMAP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + + +template +class QFragment +{ +public: + quint32 parent; + quint32 left; + quint32 right; + quint32 color; + quint32 size_left_array[N]; + quint32 size_array[N]; + enum {size_array_max = N }; +}; + +template +class QFragmentMapData +{ + enum Color { Red, Black }; +public: + QFragmentMapData(); + ~QFragmentMapData(); + + void init(); + + class Header + { + public: + quint32 root; // this relies on being at the same position as parent in the fragment struct + quint32 tag; + quint32 freelist; + quint32 node_count; + quint32 allocated; + }; + + + enum {fragmentSize = sizeof(Fragment) }; + + + int length(uint field = 0) const; + + + inline Fragment *fragment(uint index) { + return (fragments + index); + } + inline const Fragment *fragment(uint index) const { + return (fragments + index); + } + + + inline Fragment &F(uint index) { return fragments[index] ; } + inline const Fragment &F(uint index) const { return fragments[index] ; } + + inline bool isRoot(uint index) const { + return !fragment(index)->parent; + } + + inline uint position(uint node, uint field = 0) const { + Q_ASSERT(field < Fragment::size_array_max); + const Fragment *f = fragment(node); + uint offset = f->size_left_array[field]; + while (f->parent) { + uint p = f->parent; + f = fragment(p); + if (f->right == node) + offset += f->size_left_array[field] + f->size_array[field]; + node = p; + } + return offset; + } + inline uint sizeRight(uint node, uint field = 0) const { + Q_ASSERT(field < Fragment::size_array_max); + uint sr = 0; + const Fragment *f = fragment(node); + node = f->right; + while (node) { + f = fragment(node); + sr += f->size_left_array[field] + f->size_array[field]; + node = f->right; + } + return sr; + } + inline uint sizeLeft(uint node, uint field = 0) const { + Q_ASSERT(field < Fragment::size_array_max); + return fragment(node)->size_left_array[field]; + } + + + inline uint size(uint node, uint field = 0) const { + Q_ASSERT(field < Fragment::size_array_max); + return fragment(node)->size_array[field]; + } + + inline void setSize(uint node, int new_size, uint field = 0) { + Q_ASSERT(field < Fragment::size_array_max); + Fragment *f = fragment(node); + int diff = new_size - f->size_array[field]; + f->size_array[field] = new_size; + while (f->parent) { + uint p = f->parent; + f = fragment(p); + if (f->left == node) + f->size_left_array[field] += diff; + node = p; + } + } + + + uint findNode(int k, uint field = 0) const; + + uint insert_single(int key, uint length); + uint erase_single(uint f); + + uint minimum(uint n) const { + while (n && fragment(n)->left) + n = fragment(n)->left; + return n; + } + + uint maximum(uint n) const { + while (n && fragment(n)->right) + n = fragment(n)->right; + return n; + } + + uint next(uint n) const; + uint previous(uint n) const; + + inline uint root() const { + Q_ASSERT(!head->root || !fragment(head->root)->parent); + return head->root; + } + inline void setRoot(uint new_root) { + Q_ASSERT(!head->root || !fragment(new_root)->parent); + head->root = new_root; + } + + inline bool isValid(uint n) const { + return n > 0 && n != head->freelist; + } + + union { + Header *head; + Fragment *fragments; + }; + +private: + + void rotateLeft(uint x); + void rotateRight(uint x); + void rebalance(uint x); + void removeAndRebalance(uint z); + + uint createFragment(); + void freeFragment(uint f); + +}; + +template +QFragmentMapData::QFragmentMapData() + : fragments(nullptr) +{ + init(); +} + +template +void QFragmentMapData::init() +{ + // the following code will realloc an existing fragment or create a new one. + // it will also ignore errors when shrinking an existing fragment. + Fragment *newFragments = (Fragment *)realloc(fragments, 64*fragmentSize); + if (newFragments) { + fragments = newFragments; + head->allocated = 64; + } + Q_CHECK_PTR(fragments); + + head->tag = (((quint32)'p') << 24) | (((quint32)'m') << 16) | (((quint32)'a') << 8) | 'p'; //TAG('p', 'm', 'a', 'p'); + head->root = 0; + head->freelist = 1; + head->node_count = 0; + // mark all items to the right as unused + F(head->freelist).right = 0; +} + +template +QFragmentMapData::~QFragmentMapData() +{ + free(fragments); +} + +template +uint QFragmentMapData::createFragment() +{ + Q_ASSERT(head->freelist <= head->allocated); + + uint freePos = head->freelist; + if (freePos == head->allocated) { + // need to create some free space + auto blockInfo = qCalculateGrowingBlockSize(freePos + 1, fragmentSize); + Fragment *newFragments = (Fragment *)realloc(fragments, blockInfo.size); + Q_CHECK_PTR(newFragments); + fragments = newFragments; + head->allocated = quint32(blockInfo.elementCount); + F(freePos).right = 0; + } + + uint nextPos = F(freePos).right; + if (!nextPos) { + nextPos = freePos+1; + if (nextPos < head->allocated) + F(nextPos).right = 0; + } + + head->freelist = nextPos; + + ++head->node_count; + + return freePos; +} + +template +void QFragmentMapData::freeFragment(uint i) +{ + F(i).right = head->freelist; + head->freelist = i; + + --head->node_count; +} + + +template +uint QFragmentMapData::next(uint n) const { + Q_ASSERT(n); + if (F(n).right) { + n = F(n).right; + while (F(n).left) + n = F(n).left; + } else { + uint y = F(n).parent; + while (F(n).parent && n == F(y).right) { + n = y; + y = F(y).parent; + } + n = y; + } + return n; +} + +template +uint QFragmentMapData::previous(uint n) const { + if (!n) + return maximum(root()); + + if (F(n).left) { + n = F(n).left; + while (F(n).right) + n = F(n).right; + } else { + uint y = F(n).parent; + while (F(n).parent && n == F(y).left) { + n = y; + y = F(y).parent; + } + n = y; + } + return n; +} + + +/* + x y + \ / \ + y --> x b + / \ \ + a b a +*/ +template +void QFragmentMapData::rotateLeft(uint x) +{ + uint p = F(x).parent; + uint y = F(x).right; + + + if (y) { + F(x).right = F(y).left; + if (F(y).left) + F(F(y).left).parent = x; + F(y).left = x; + F(y).parent = p; + } else { + F(x).right = 0; + } + if (!p) { + Q_ASSERT(head->root == x); + head->root = y; + } + else if (x == F(p).left) + F(p).left = y; + else + F(p).right = y; + F(x).parent = y; + for (uint field = 0; field < Fragment::size_array_max; ++field) + F(y).size_left_array[field] += F(x).size_left_array[field] + F(x).size_array[field]; +} + + +/* + x y + / / \ + y --> a x + / \ / + a b b +*/ +template +void QFragmentMapData::rotateRight(uint x) +{ + uint y = F(x).left; + uint p = F(x).parent; + + if (y) { + F(x).left = F(y).right; + if (F(y).right) + F(F(y).right).parent = x; + F(y).right = x; + F(y).parent = p; + } else { + F(x).left = 0; + } + if (!p) { + Q_ASSERT(head->root == x); + head->root = y; + } + else if (x == F(p).right) + F(p).right = y; + else + F(p).left = y; + F(x).parent = y; + for (uint field = 0; field < Fragment::size_array_max; ++field) + F(x).size_left_array[field] -= F(y).size_left_array[field] + F(y).size_array[field]; +} + + +template +void QFragmentMapData::rebalance(uint x) +{ + F(x).color = Red; + + while (F(x).parent && F(F(x).parent).color == Red) { + uint p = F(x).parent; + uint pp = F(p).parent; + Q_ASSERT(pp); + if (p == F(pp).left) { + uint y = F(pp).right; + if (y && F(y).color == Red) { + F(p).color = Black; + F(y).color = Black; + F(pp).color = Red; + x = pp; + } else { + if (x == F(p).right) { + x = p; + rotateLeft(x); + p = F(x).parent; + pp = F(p).parent; + } + F(p).color = Black; + if (pp) { + F(pp).color = Red; + rotateRight(pp); + } + } + } else { + uint y = F(pp).left; + if (y && F(y).color == Red) { + F(p).color = Black; + F(y).color = Black; + F(pp).color = Red; + x = pp; + } else { + if (x == F(p).left) { + x = p; + rotateRight(x); + p = F(x).parent; + pp = F(p).parent; + } + F(p).color = Black; + if (pp) { + F(pp).color = Red; + rotateLeft(pp); + } + } + } + } + F(root()).color = Black; +} + + +template +uint QFragmentMapData::erase_single(uint z) +{ + uint w = previous(z); + uint y = z; + uint x; + uint p; + + if (!F(y).left) { + x = F(y).right; + } else if (!F(y).right) { + x = F(y).left; + } else { + y = F(y).right; + while (F(y).left) + y = F(y).left; + x = F(y).right; + } + + if (y != z) { + F(F(z).left).parent = y; + F(y).left = F(z).left; + for (uint field = 0; field < Fragment::size_array_max; ++field) + F(y).size_left_array[field] = F(z).size_left_array[field]; + if (y != F(z).right) { + /* + z y + / \ / \ + a b a b + / / + ... --> ... + / / + y x + / \ + 0 x + */ + p = F(y).parent; + if (x) + F(x).parent = p; + F(p).left = x; + F(y).right = F(z).right; + F(F(z).right).parent = y; + uint n = p; + while (n != y) { + for (uint field = 0; field < Fragment::size_array_max; ++field) + F(n).size_left_array[field] -= F(y).size_array[field]; + n = F(n).parent; + } + } else { + /* + z y + / \ / \ + a y --> a x + / \ + 0 x + */ + p = y; + } + uint zp = F(z).parent; + if (!zp) { + Q_ASSERT(head->root == z); + head->root = y; + } else if (F(zp).left == z) { + F(zp).left = y; + for (uint field = 0; field < Fragment::size_array_max; ++field) + F(zp).size_left_array[field] -= F(z).size_array[field]; + } else { + F(zp).right = y; + } + F(y).parent = zp; + // Swap the colors + uint c = F(y).color; + F(y).color = F(z).color; + F(z).color = c; + y = z; + } else { + /* + p p p p + / / \ \ + z --> x z --> x + | | + x x + */ + p = F(z).parent; + if (x) + F(x).parent = p; + if (!p) { + Q_ASSERT(head->root == z); + head->root = x; + } else if (F(p).left == z) { + F(p).left = x; + for (uint field = 0; field < Fragment::size_array_max; ++field) + F(p).size_left_array[field] -= F(z).size_array[field]; + } else { + F(p).right = x; + } + } + uint n = z; + while (F(n).parent) { + uint p = F(n).parent; + if (F(p).left == n) { + for (uint field = 0; field < Fragment::size_array_max; ++field) + F(p).size_left_array[field] -= F(z).size_array[field]; + } + n = p; + } + + freeFragment(z); + + + if (F(y).color != Red) { + while (F(x).parent && (x == 0 || F(x).color == Black)) { + if (x == F(p).left) { + uint w = F(p).right; + if (F(w).color == Red) { + F(w).color = Black; + F(p).color = Red; + rotateLeft(p); + w = F(p).right; + } + if ((F(w).left == 0 || F(F(w).left).color == Black) && + (F(w).right == 0 || F(F(w).right).color == Black)) { + F(w).color = Red; + x = p; + p = F(x).parent; + } else { + if (F(w).right == 0 || F(F(w).right).color == Black) { + if (F(w).left) + F(F(w).left).color = Black; + F(w).color = Red; + rotateRight(F(p).right); + w = F(p).right; + } + F(w).color = F(p).color; + F(p).color = Black; + if (F(w).right) + F(F(w).right).color = Black; + rotateLeft(p); + break; + } + } else { + uint w = F(p).left; + if (F(w).color == Red) { + F(w).color = Black; + F(p).color = Red; + rotateRight(p); + w = F(p).left; + } + if ((F(w).right == 0 || F(F(w).right).color == Black) && + (F(w).left == 0 || F(F(w).left).color == Black)) { + F(w).color = Red; + x = p; + p = F(x).parent; + } else { + if (F(w).left == 0 || F(F(w).left).color == Black) { + if (F(w).right) + F(F(w).right).color = Black; + F(w).color = Red; + rotateLeft(F(p).left); + w = F(p).left; + } + F(w).color = F(p).color; + F(p).color = Black; + if (F(w).left) + F(F(w).left).color = Black; + rotateRight(p); + break; + } + } + } + if (x) + F(x).color = Black; + } + + return w; +} + +template +uint QFragmentMapData::findNode(int k, uint field) const +{ + Q_ASSERT(field < Fragment::size_array_max); + uint x = root(); + + uint s = k; + while (x) { + if (sizeLeft(x, field) <= s) { + if (s < sizeLeft(x, field) + size(x, field)) + return x; + s -= sizeLeft(x, field) + size(x, field); + x = F(x).right; + } else { + x = F(x).left; + } + } + return 0; +} + +template +uint QFragmentMapData::insert_single(int key, uint length) +{ + Q_ASSERT(!findNode(key) || (int)this->position(findNode(key)) == key); + + uint z = createFragment(); + + F(z).left = 0; + F(z).right = 0; + F(z).size_array[0] = length; + for (uint field = 1; field < Fragment::size_array_max; ++field) + F(z).size_array[field] = 1; + for (uint field = 0; field < Fragment::size_array_max; ++field) + F(z).size_left_array[field] = 0; + + uint y = 0; + uint x = root(); + + Q_ASSERT(!x || F(x).parent == 0); + + uint s = key; + bool right = false; + while (x) { + y = x; + if (s <= F(x).size_left_array[0]) { + x = F(x).left; + right = false; + } else { + s -= F(x).size_left_array[0] + F(x).size_array[0]; + x = F(x).right; + right = true; + } + } + + F(z).parent = y; + if (!y) { + head->root = z; + } else if (!right) { + F(y).left = z; + for (uint field = 0; field < Fragment::size_array_max; ++field) + F(y).size_left_array[field] = F(z).size_array[field]; + } else { + F(y).right = z; + } + while (y && F(y).parent) { + uint p = F(y).parent; + if (F(p).left == y) { + for (uint field = 0; field < Fragment::size_array_max; ++field) + F(p).size_left_array[field] += F(z).size_array[field]; + } + y = p; + } + rebalance(z); + + return z; +} + + +template +int QFragmentMapData::length(uint field) const { + uint root = this->root(); + return root ? sizeLeft(root, field) + size(root, field) + sizeRight(root, field) : 0; +} + + +template // NOTE: must inherit QFragment +class QFragmentMap +{ +public: + class Iterator + { + public: + QFragmentMap *pt; + quint32 n; + + Iterator() : pt(0), n(0) {} + Iterator(QFragmentMap *p, int node) : pt(p), n(node) {} + Iterator(const Iterator& it) : pt(it.pt), n(it.n) {} + + inline bool atEnd() const { return !n; } + + bool operator==(const Iterator& it) const { return pt == it.pt && n == it.n; } + bool operator!=(const Iterator& it) const { return pt != it.pt || n != it.n; } + bool operator<(const Iterator &it) const { return position() < it.position(); } + + Fragment *operator*() { Q_ASSERT(!atEnd()); return pt->fragment(n); } + const Fragment *operator*() const { Q_ASSERT(!atEnd()); return pt->fragment(n); } + Fragment *operator->() { Q_ASSERT(!atEnd()); return pt->fragment(n); } + const Fragment *operator->() const { Q_ASSERT(!atEnd()); return pt->fragment(n); } + + int position() const { Q_ASSERT(!atEnd()); return pt->data.position(n); } + const Fragment *value() const { Q_ASSERT(!atEnd()); return pt->fragment(n); } + Fragment *value() { Q_ASSERT(!atEnd()); return pt->fragment(n); } + + Iterator& operator++() { + n = pt->data.next(n); + return *this; + } + Iterator& operator--() { + n = pt->data.previous(n); + return *this; + } + + }; + + + class ConstIterator + { + public: + const QFragmentMap *pt; + quint32 n; + + /** + * Functions + */ + ConstIterator() : pt(0), n(0) {} + ConstIterator(const QFragmentMap *p, int node) : pt(p), n(node) {} + ConstIterator(const ConstIterator& it) : pt(it.pt), n(it.n) {} + ConstIterator(const Iterator& it) : pt(it.pt), n(it.n) {} + + inline bool atEnd() const { return !n; } + + bool operator==(const ConstIterator& it) const { return pt == it.pt && n == it.n; } + bool operator!=(const ConstIterator& it) const { return pt != it.pt || n != it.n; } + bool operator<(const ConstIterator &it) const { return position() < it.position(); } + + const Fragment *operator*() const { Q_ASSERT(!atEnd()); return pt->fragment(n); } + const Fragment *operator->() const { Q_ASSERT(!atEnd()); return pt->fragment(n); } + + int position() const { Q_ASSERT(!atEnd()); return pt->data.position(n); } + int size() const { Q_ASSERT(!atEnd()); return pt->data.size(n); } + const Fragment *value() const { Q_ASSERT(!atEnd()); return pt->fragment(n); } + + ConstIterator& operator++() { + n = pt->data.next(n); + return *this; + } + ConstIterator& operator--() { + n = pt->data.previous(n); + return *this; + } + }; + + + QFragmentMap() {} + ~QFragmentMap() + { + if (!data.fragments) + return; // in case of out-of-memory, we won't have fragments + for (Iterator it = begin(); !it.atEnd(); ++it) + it.value()->free(); + } + + inline void clear() { + for (Iterator it = begin(); !it.atEnd(); ++it) + it.value()->free(); + data.init(); + } + + inline Iterator begin() { return Iterator(this, data.minimum(data.root())); } + inline Iterator end() { return Iterator(this, 0); } + inline ConstIterator begin() const { return ConstIterator(this, data.minimum(data.root())); } + inline ConstIterator end() const { return ConstIterator(this, 0); } + + inline ConstIterator last() const { return ConstIterator(this, data.maximum(data.root())); } + + inline bool isEmpty() const { return data.head->node_count == 0; } + inline int numNodes() const { return data.head->node_count; } + int length(uint field = 0) const { return data.length(field); } + + Iterator find(int k, uint field = 0) { return Iterator(this, data.findNode(k, field)); } + ConstIterator find(int k, uint field = 0) const { return ConstIterator(this, data.findNode(k, field)); } + + uint findNode(int k, uint field = 0) const { return data.findNode(k, field); } + + uint insert_single(int key, uint length) + { + uint f = data.insert_single(key, length); + if (f != 0) { + Fragment *frag = fragment(f); + Q_ASSERT(frag); + frag->initialize(); + } + return f; + } + uint erase_single(uint f) + { + if (f != 0) { + Fragment *frag = fragment(f); + Q_ASSERT(frag); + frag->free(); + } + return data.erase_single(f); + } + + inline Fragment *fragment(uint index) { + Q_ASSERT(index != 0); + return data.fragment(index); + } + inline const Fragment *fragment(uint index) const { + Q_ASSERT(index != 0); + return data.fragment(index); + } + inline uint position(uint node, uint field = 0) const { return data.position(node, field); } + inline bool isValid(uint n) const { return data.isValid(n); } + inline uint next(uint n) const { return data.next(n); } + inline uint previous(uint n) const { return data.previous(n); } + inline uint size(uint node, uint field = 0) const { return data.size(node, field); } + inline void setSize(uint node, int new_size, uint field = 0) + { data.setSize(node, new_size, field); + if (node != 0 && field == 0) { + Fragment *frag = fragment(node); + Q_ASSERT(frag); + frag->invalidate(); + } + } + + inline int firstNode() const { return data.minimum(data.root()); } + +private: + friend class Iterator; + friend class ConstIterator; + + QFragmentMapData data; + + QFragmentMap(const QFragmentMap& m); + QFragmentMap& operator= (const QFragmentMap& m); +}; + +QT_END_NAMESPACE + +#endif // QFRAGMENTMAP_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfreetypefontdatabase_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfreetypefontdatabase_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cd48a10ec71debf49ae2210931b3b96f6c1b8097 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qfreetypefontdatabase_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFREETYPEFONTDATABASE_H +#define QFREETYPEFONTDATABASE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +struct FontFile +{ + QString fileName; + int indexValue; + int instanceIndex = -1; + + // Note: The data may be implicitly shared throughout the + // font database and platform font database, so be careful + // to never detach when accessing this member! + const QByteArray data; +}; + +class Q_GUI_EXPORT QFreeTypeFontDatabase : public QPlatformFontDatabase +{ +public: + void populateFontDatabase() override; + QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override; + QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override; + QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *applicationFont = nullptr) override; + void releaseHandle(void *handle) override; + bool supportsVariableApplicationFonts() const override; + + static void addNamedInstancesForFace(void *face, int faceIndex, + const QString &family, const QString &styleName, + QFont::Weight weight, QFont::Stretch stretch, + QFont::Style style, bool fixedPitch, + const QSupportedWritingSystems &writingSystems, + const QByteArray &fileName, const QByteArray &fontData); + + static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file, QFontDatabasePrivate::ApplicationFont *applicationFont = nullptr); +}; + +QT_END_NAMESPACE + +#endif // QFREETYPEFONTDATABASE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qglyphrun_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qglyphrun_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9d50150282eebb3c957df23d975822546ec7bc54 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qglyphrun_p.h @@ -0,0 +1,88 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QGLYPHRUN_P_H +#define QGLYPHRUN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include "qglyphrun.h" +#include "qrawfont.h" + +#include + +#if !defined(QT_NO_RAWFONT) + +QT_BEGIN_NAMESPACE + +class QGlyphRunPrivate: public QSharedData +{ +public: + QGlyphRunPrivate() + : glyphIndexData(glyphIndexes.constData()) + , glyphIndexDataSize(0) + , glyphPositionData(glyphPositions.constData()) + , glyphPositionDataSize(0) + , textRangeStart(-1) + , textRangeEnd(-1) + { + } + + QGlyphRunPrivate(const QGlyphRunPrivate &other) + : QSharedData(other) + , glyphIndexes(other.glyphIndexes) + , glyphPositions(other.glyphPositions) + , stringIndexes(other.stringIndexes) + , rawFont(other.rawFont) + , boundingRect(other.boundingRect) + , sourceString(other.sourceString) + , flags(other.flags) + , glyphIndexData(other.glyphIndexData) + , glyphIndexDataSize(other.glyphIndexDataSize) + , glyphPositionData(other.glyphPositionData) + , glyphPositionDataSize(other.glyphPositionDataSize) + , textRangeStart(other.textRangeStart) + , textRangeEnd(other.textRangeEnd) + { + } + + QList glyphIndexes; + QList glyphPositions; + QList stringIndexes; + QRawFont rawFont; + QRectF boundingRect; + QString sourceString; + + QGlyphRun::GlyphRunFlags flags; + + const quint32 *glyphIndexData; + int glyphIndexDataSize; + + const QPointF *glyphPositionData; + int glyphPositionDataSize; + + int textRangeStart; + int textRangeEnd; + + static QGlyphRunPrivate *get(const QGlyphRun &glyphRun) + { + return glyphRun.d.data(); + } +}; + +QT_END_NAMESPACE + +#endif // QT_NO_RAWFONT + +#endif // QGLYPHRUN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qgrayraster_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qgrayraster_p.h new file mode 100644 index 0000000000000000000000000000000000000000..592dd46c66979be5472aa53e135e2a09b4836603 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qgrayraster_p.h @@ -0,0 +1,67 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +/***************************************************************************/ +/* */ +/* qgrayraster_p.h, derived from ftgrays.h */ +/* */ +/* FreeType smooth renderer declaration */ +/* */ +/* Copyright 1996-2001 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, ../../3rdparty/freetype/docs/FTL.TXT. By continuing to use, */ +/* modify, or distribute this file you indicate that you have read */ +/* the license and understand and accept it fully. */ +/***************************************************************************/ + + +#ifndef __FTGRAYS_H__ +#define __FTGRAYS_H__ + +/* +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +*/ + +#ifdef __cplusplus + extern "C" { +#endif + + +#include + + /*************************************************************************/ + /* */ + /* To make ftgrays.h independent from configuration files we check */ + /* whether QT_FT_EXPORT_VAR has been defined already. */ + /* */ + /* On some systems and compilers (Win32 mostly), an extra keyword is */ + /* necessary to compile the library as a DLL. */ + /* */ +#ifndef QT_FT_EXPORT_VAR +#define QT_FT_EXPORT_VAR( x ) extern x +#endif + +/* Minimum buffer size for raster object, that accounts + for TWorker and TCell sizes.*/ +#define MINIMUM_POOL_SIZE 8192 + + QT_FT_EXPORT_VAR( const QT_FT_Raster_Funcs ) qt_ft_grays_raster; + + +#ifdef __cplusplus + } +#endif + +#endif /* __FTGRAYS_H__ */ + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qgridlayoutengine_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qgridlayoutengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f566281406f4d607f6ad17beaef70fe0dccfe781 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qgridlayoutengine_p.h @@ -0,0 +1,461 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QGRIDLAYOUTENGINE_P_H +#define QGRIDLAYOUTENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the graphics view layout classes. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "qlayoutpolicy_p.h" +#include "qabstractlayoutstyleinfo_p.h" + +// #define QGRIDLAYOUTENGINE_DEBUG + +QT_BEGIN_NAMESPACE + +class QStyle; +class QWidget; + +// ### deal with Descent in a similar way +enum { + MinimumSize = Qt::MinimumSize, + PreferredSize = Qt::PreferredSize, + MaximumSize = Qt::MaximumSize, + NSizes +}; + +// do not reorder +enum LayoutSide { + Left, + Top, + Right, + Bottom +}; + +enum { + NoConstraint, + HorizontalConstraint, // Width depends on the height + VerticalConstraint, // Height depends on the width + UnknownConstraint, // need to update cache + UnfeasibleConstraint // not feasible, it be has some items with Vertical and others with Horizontal constraints +}; + +/* + Minimal container to store Qt::Orientation-discriminated values. + + The salient feature is the indexing operator, which takes + Qt::Orientation (and assumes it's passed only Qt::Horizontal or Qt::Vertical). +*/ +template +class QHVContainer { + T m_data[2]; + + static_assert(Qt::Horizontal == 0x1); + static_assert(Qt::Vertical == 0x2); + static constexpr int map(Qt::Orientation o) noexcept + { + return int(o) - 1; + } + static constexpr int mapOther(Qt::Orientation o) noexcept + { + return 2 - int(o); + } +public: + constexpr QHVContainer(const T &h, const T &v) + noexcept(std::is_nothrow_copy_constructible_v) + : m_data{h, v} {} + QHVContainer() = default; + + constexpr T &operator[](Qt::Orientation o) noexcept { return m_data[map(o)]; } + constexpr const T &operator[](Qt::Orientation o) const noexcept { return m_data[map(o)]; } + + constexpr T &other(Qt::Orientation o) noexcept { return m_data[mapOther(o)]; } + constexpr const T &other(Qt::Orientation o) const noexcept { return m_data[mapOther(o)]; } + + constexpr void transpose() noexcept { qSwap(m_data[0], m_data[1]); } + constexpr QHVContainer transposed() const + noexcept(std::is_nothrow_copy_constructible_v) + { return {m_data[1], m_data[0]}; } +}; + +template +class QLayoutParameter +{ +public: + enum State { Default, User, Cached }; + + inline QLayoutParameter() : q_value(T()), q_state(Default) {} + inline QLayoutParameter(T value, State state = Default) : q_value(value), q_state(state) {} + + inline void setUserValue(T value) { + q_value = value; + q_state = User; + } + inline void setCachedValue(T value) const { + if (q_state != User) { + q_value = value; + q_state = Cached; + } + } + inline T value() const { return q_value; } + inline T value(T defaultValue) const { return isUser() ? q_value : defaultValue; } + inline bool isDefault() const { return q_state == Default; } + inline bool isUser() const { return q_state == User; } + inline bool isCached() const { return q_state == Cached; } + +private: + mutable T q_value; + mutable State q_state; +}; + +class QStretchParameter : public QLayoutParameter +{ +public: + QStretchParameter() : QLayoutParameter(-1) {} + +}; + +class Q_GUI_EXPORT QGridLayoutBox +{ +public: + inline QGridLayoutBox() + : q_minimumSize(0), q_preferredSize(0), q_maximumSize(FLT_MAX), + q_minimumDescent(-1), q_minimumAscent(-1) {} + + void add(const QGridLayoutBox &other, int stretch, qreal spacing); + void combine(const QGridLayoutBox &other); + void normalize(); + +#ifdef QGRIDLAYOUTENGINE_DEBUG + void dump(int indent = 0) const; +#endif + // This code could use the union-struct-array trick, but a compiler + // bug prevents this from working. + qreal q_minimumSize; + qreal q_preferredSize; + qreal q_maximumSize; + qreal q_minimumDescent; + qreal q_minimumAscent; + inline qreal &q_sizes(int which) + { + return const_cast(static_cast(this)->q_sizes(which)); + } + inline const qreal &q_sizes(int which) const + { + switch (which) { + case Qt::MinimumSize: + return q_minimumSize; + case Qt::PreferredSize: + return q_preferredSize; + case Qt::MaximumSize: + return q_maximumSize; + case Qt::MinimumDescent: + return q_minimumDescent; + case (Qt::MinimumDescent + 1): + return q_minimumAscent; + default: + Q_UNREACHABLE(); + } + } +}; +Q_DECLARE_TYPEINFO(QGridLayoutBox, Q_RELOCATABLE_TYPE); // cannot be Q_PRIMITIVE_TYPE, as q_maximumSize, say, is != 0 + +bool operator==(const QGridLayoutBox &box1, const QGridLayoutBox &box2); +inline bool operator!=(const QGridLayoutBox &box1, const QGridLayoutBox &box2) + { return !operator==(box1, box2); } + +class QGridLayoutMultiCellData +{ +public: + inline QGridLayoutMultiCellData() : q_stretch(-1) {} + + QGridLayoutBox q_box; + int q_stretch; +}; + +typedef QMap, QGridLayoutMultiCellData> MultiCellMap; + +class QGridLayoutRowInfo; + +class QGridLayoutRowData +{ +public: + void reset(int count); + void distributeMultiCells(const QGridLayoutRowInfo &rowInfo, bool snapToPixelGrid); + void calculateGeometries(int start, int end, qreal targetSize, qreal *positions, qreal *sizes, + qreal *descents, const QGridLayoutBox &totalBox, + const QGridLayoutRowInfo &rowInfo, bool snapToPixelGrid); + QGridLayoutBox totalBox(int start, int end) const; + void stealBox(int start, int end, int which, qreal *positions, qreal *sizes); + +#ifdef QGRIDLAYOUTENGINE_DEBUG + void dump(int indent = 0) const; +#endif + + QBitArray ignore; // ### rename q_ + QList boxes; + MultiCellMap multiCellMap; + QList stretches; + QList spacings; + bool hasIgnoreFlag; +}; + +class QGridLayoutRowInfo +{ +public: + inline QGridLayoutRowInfo() : count(0) {} + + void insertOrRemoveRows(int row, int delta); + +#ifdef QGRIDLAYOUTENGINE_DEBUG + void dump(int indent = 0) const; +#endif + + int count; + QList stretches; + QList> spacings; + QList alignments; + QList boxes; +}; + + +class Q_GUI_EXPORT QGridLayoutItem +{ +public: + QGridLayoutItem(int row, int column, int rowSpan = 1, int columnSpan = 1, + Qt::Alignment alignment = { }); + virtual ~QGridLayoutItem() {} + + inline int firstRow() const { return q_firstRows[Qt::Vertical]; } + inline int firstColumn() const { return q_firstRows[Qt::Horizontal]; } + inline int rowSpan() const { return q_rowSpans[Qt::Vertical]; } + inline int columnSpan() const { return q_rowSpans[Qt::Horizontal]; } + inline int lastRow() const { return firstRow() + rowSpan() - 1; } + inline int lastColumn() const { return firstColumn() + columnSpan() - 1; } + + int firstRow(Qt::Orientation orientation) const; + int firstColumn(Qt::Orientation orientation) const; + int lastRow(Qt::Orientation orientation) const; + int lastColumn(Qt::Orientation orientation) const; + int rowSpan(Qt::Orientation orientation) const; + int columnSpan(Qt::Orientation orientation) const; + void setFirstRow(int row, Qt::Orientation orientation = Qt::Vertical); + void setRowSpan(int rowSpan, Qt::Orientation orientation = Qt::Vertical); + + int stretchFactor(Qt::Orientation orientation) const; + void setStretchFactor(int stretch, Qt::Orientation orientation); + + inline Qt::Alignment alignment() const { return q_alignment; } + inline void setAlignment(Qt::Alignment alignment) { q_alignment = alignment; } + + virtual QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const = 0; + virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const = 0; + virtual bool isEmpty() const { return false; } + + virtual void setGeometry(const QRectF &rect) = 0; + /* + returns true if the size policy returns true for either hasHeightForWidth() + or hasWidthForHeight() + */ + virtual bool hasDynamicConstraint() const { return false; } + virtual Qt::Orientation dynamicConstraintOrientation() const { return Qt::Horizontal; } + + + virtual QLayoutPolicy::ControlTypes controlTypes(LayoutSide side) const; + + inline virtual QString toString() const { return QDebug::toString(this); } + + QRectF geometryWithin(qreal x, qreal y, qreal width, qreal height, qreal rowDescent, Qt::Alignment align, bool snapToPixelGrid) const; + QGridLayoutBox box(Qt::Orientation orientation, bool snapToPixelGrid, qreal constraint = -1.0) const; + + + void transpose(); + void insertOrRemoveRows(int row, int delta, Qt::Orientation orientation = Qt::Vertical); + QSizeF effectiveMaxSize(const QSizeF &constraint) const; + +#ifdef QGRIDLAYOUTENGINE_DEBUG + void dump(int indent = 0) const; +#endif + +private: + QHVContainer q_firstRows; + QHVContainer q_rowSpans; + QHVContainer q_stretches; + Qt::Alignment q_alignment; + +}; + +class Q_GUI_EXPORT QGridLayoutEngine +{ +public: + QGridLayoutEngine(Qt::Alignment defaultAlignment = { }, bool snapToPixelGrid = false); + inline ~QGridLayoutEngine() { qDeleteAll(q_items); } + + int rowCount(Qt::Orientation orientation) const; + int columnCount(Qt::Orientation orientation) const; + inline int rowCount() const { return q_infos[Qt::Vertical].count; } + inline int columnCount() const { return q_infos[Qt::Horizontal].count; } + // returns the number of items inserted, which may be less than (rowCount * columnCount) + int itemCount() const; + QGridLayoutItem *itemAt(int index) const; + + int effectiveFirstRow(Qt::Orientation orientation = Qt::Vertical) const; + int effectiveLastRow(Qt::Orientation orientation = Qt::Vertical) const; + + void setSpacing(qreal spacing, Qt::Orientations orientations); + qreal spacing(Qt::Orientation orientation, const QAbstractLayoutStyleInfo *styleInfo) const; + // ### setSpacingAfterRow(), spacingAfterRow() + void setRowSpacing(int row, qreal spacing, Qt::Orientation orientation = Qt::Vertical); + qreal rowSpacing(int row, Qt::Orientation orientation = Qt::Vertical) const; + + void setRowStretchFactor(int row, int stretch, Qt::Orientation orientation = Qt::Vertical); + int rowStretchFactor(int row, Qt::Orientation orientation = Qt::Vertical) const; + + void setRowSizeHint(Qt::SizeHint which, int row, qreal size, + Qt::Orientation orientation = Qt::Vertical); + qreal rowSizeHint(Qt::SizeHint which, int row, + Qt::Orientation orientation = Qt::Vertical) const; + + bool uniformCellWidths() const; + void setUniformCellWidths(bool uniformCellWidths); + + bool uniformCellHeights() const; + void setUniformCellHeights(bool uniformCellHeights); + + void setRowAlignment(int row, Qt::Alignment alignment, Qt::Orientation orientation); + Qt::Alignment rowAlignment(int row, Qt::Orientation orientation) const; + + Qt::Alignment effectiveAlignment(const QGridLayoutItem *layoutItem) const; + + + void insertItem(QGridLayoutItem *item, int index); + void addItem(QGridLayoutItem *item); + void removeItem(QGridLayoutItem *item); + void deleteItems() + { + const QList oldItems = q_items; + q_items.clear(); // q_items are used as input when the grid is regenerated in removeRows + // The following calls to removeRows are suboptimal + int rows = rowCount(Qt::Vertical); + removeRows(0, rows, Qt::Vertical); + rows = rowCount(Qt::Horizontal); + removeRows(0, rows, Qt::Horizontal); + qDeleteAll(oldItems); + } + + QGridLayoutItem *itemAt(int row, int column, Qt::Orientation orientation = Qt::Vertical) const; + inline void insertRow(int row, Qt::Orientation orientation = Qt::Vertical) + { insertOrRemoveRows(row, +1, orientation); } + inline void removeRows(int row, int count, Qt::Orientation orientation) + { insertOrRemoveRows(row, -count, orientation); } + + void invalidate(); + void setGeometries(const QRectF &contentsGeometry, const QAbstractLayoutStyleInfo *styleInfo); + QRectF cellRect(const QRectF &contentsGeometry, int row, int column, int rowSpan, int columnSpan, + const QAbstractLayoutStyleInfo *styleInfo) const; + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint, + const QAbstractLayoutStyleInfo *styleInfo) const; + + // heightForWidth / widthForHeight support + QSizeF dynamicallyConstrainedSizeHint(Qt::SizeHint which, const QSizeF &constraint) const; + bool ensureDynamicConstraint() const; + bool hasDynamicConstraint() const; + Qt::Orientation constraintOrientation() const; + + + QLayoutPolicy::ControlTypes controlTypes(LayoutSide side) const; + void transpose(); + void setVisualDirection(Qt::LayoutDirection direction); + Qt::LayoutDirection visualDirection() const; +#ifdef QGRIDLAYOUTENGINE_DEBUG + void dump(int indent = 0) const; +#endif + +private: + static int grossRoundUp(int n) { return ((n + 2) | 0x3) - 2; } + + void maybeExpandGrid(int row, int column, Qt::Orientation orientation = Qt::Vertical); + void regenerateGrid(); + inline int internalGridRowCount() const { return grossRoundUp(rowCount()); } + inline int internalGridColumnCount() const { return grossRoundUp(columnCount()); } + void setItemAt(int row, int column, QGridLayoutItem *item); + void insertOrRemoveRows(int row, int delta, Qt::Orientation orientation = Qt::Vertical); + void fillRowData(QGridLayoutRowData *rowData, + const qreal *colPositions, const qreal *colSizes, + Qt::Orientation orientation, + const QAbstractLayoutStyleInfo *styleInfo) const; + void ensureEffectiveFirstAndLastRows() const; + void ensureColumnAndRowData(QGridLayoutRowData *rowData, QGridLayoutBox *totalBox, + const qreal *colPositions, const qreal *colSizes, + Qt::Orientation orientation, + const QAbstractLayoutStyleInfo *styleInfo) const; + + void ensureGeometries(const QSizeF &size, const QAbstractLayoutStyleInfo *styleInfo) const; +protected: + QList q_items; +private: + // User input + QList q_grid; + QHVContainer> q_defaultSpacings; + QHVContainer q_infos; + Qt::LayoutDirection m_visualDirection; + + // Configuration + Qt::Alignment m_defaultAlignment; + unsigned m_snapToPixelGrid : 1; + unsigned m_uniformCellWidths : 1; + unsigned m_uniformCellHeights : 1; + + // Lazily computed from the above user input + mutable QHVContainer q_cachedEffectiveFirstRows; + mutable QHVContainer q_cachedEffectiveLastRows; + mutable quint8 q_cachedConstraintOrientation : 3; + + // this is useful to cache + mutable QHVContainer q_totalBoxes; + enum { + NotCached = -2, // Cache is empty. Happens when the engine is invalidated. + CachedWithNoConstraint = -1 // cache has a totalBox without any HFW/WFH constraints. + // >= 0 // cache has a totalBox with this specific constraint. + }; + mutable QHVContainer q_totalBoxCachedConstraints; // holds the constraint used for the cached totalBox + + // Layout item input + mutable QGridLayoutRowData q_columnData; + mutable QGridLayoutRowData q_rowData; + + // Output + mutable QSizeF q_cachedSize; + mutable QList q_xx; + mutable QList q_yy; + mutable QList q_widths; + mutable QList q_heights; + mutable QList q_descents; + + friend class QGridLayoutItem; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qguiapplication_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qguiapplication_p.h new file mode 100644 index 0000000000000000000000000000000000000000..010084801d2cf3e584620b239be5aff5307ef975 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qguiapplication_p.h @@ -0,0 +1,450 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QGUIAPPLICATION_P_H +#define QGUIAPPLICATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#if QT_CONFIG(shortcut) +# include "private/qshortcutmap_p.h" +#endif + +#include + +#include + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcPopup) +Q_DECLARE_LOGGING_CATEGORY(lcVirtualKeyboard) + +class QColorTrcLut; +class QPlatformIntegration; +class QPlatformTheme; +class QPlatformDragQtResponse; +#if QT_CONFIG(draganddrop) +class QDrag; +#endif // QT_CONFIG(draganddrop) +class QInputDeviceManager; +#ifndef QT_NO_ACTION +class QActionPrivate; +#endif +#if QT_CONFIG(shortcut) +class QShortcutPrivate; +#endif + +class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate +{ + Q_DECLARE_PUBLIC(QGuiApplication) +public: + QGuiApplicationPrivate(int &argc, char **argv); + ~QGuiApplicationPrivate(); + + void init(); + + void createPlatformIntegration(); + void createEventDispatcher() override; + void eventDispatcherReady() override; + + virtual void notifyLayoutDirectionChange(); + virtual void notifyActiveWindowChange(QWindow *previous); + +#if QT_CONFIG(commandlineparser) + void addQtOptions(QList *options) override; +#endif + bool canQuitAutomatically() override; + void quit() override; + + void maybeLastWindowClosed(); + bool lastWindowClosed() const; + static bool quitOnLastWindowClosed; + + static void captureGlobalModifierState(QEvent *e); + static Qt::KeyboardModifiers modifier_buttons; + static Qt::MouseButtons mouse_buttons; + + static QPlatformIntegration *platform_integration; + + static QPlatformIntegration *platformIntegration() + { return platform_integration; } + + static QPlatformTheme *platform_theme; + + static QPlatformTheme *platformTheme() + { return platform_theme; } + + static QAbstractEventDispatcher *qt_qpa_core_dispatcher() + { + if (QCoreApplication::instance()) + return QCoreApplication::instance()->d_func()->threadData.loadRelaxed()->eventDispatcher.loadRelaxed(); + else + return nullptr; + } + + static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e); + static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e); + static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e); + static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e); + + static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e); + + static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e); + + static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e); + static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e); + + static void processFocusWindowEvent(QWindowSystemInterfacePrivate::FocusWindowEvent *e); + + static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e); + static void processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e); + static void processWindowDevicePixelRatioChangedEvent(QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent *e); + + static void processSafeAreaMarginsChangedEvent(QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *e); + + static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e); + + static void processApplicationTermination(QWindowSystemInterfacePrivate::WindowSystemEvent *e); + + static void updateFilteredScreenOrientation(QScreen *screen); + static void processScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e); + static void processScreenGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e); + static void processScreenLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e); + static void processScreenRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e); + static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce); + + static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e); + static void processPaintEvent(QWindowSystemInterfacePrivate::PaintEvent *e); + + static void processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e); + + static void processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e); + static void processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e); + static void processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e); + +#ifndef QT_NO_GESTURES + static void processGestureEvent(QWindowSystemInterfacePrivate::GestureEvent *e); +#endif + + static void processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e); +#ifndef QT_NO_CONTEXTMENU + static void processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e); +#endif + +#if QT_CONFIG(draganddrop) + static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData, + const QPoint &p, Qt::DropActions supportedActions, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); + static QPlatformDropQtResponse processDrop(QWindow *w, const QMimeData *dropData, + const QPoint &p, Qt::DropActions supportedActions, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); +#endif + + static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result); + + static bool sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event); + + static bool maybeForwardEventToVirtualKeyboard(QEvent *e); + static bool isUsingVirtualKeyboard(); + + static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment) + { + if (!(alignment & Qt::AlignHorizontal_Mask)) + alignment |= Qt::AlignLeft; + if (!(alignment & Qt::AlignAbsolute) && (alignment & (Qt::AlignLeft | Qt::AlignRight))) { + if (direction == Qt::RightToLeft) + alignment ^= (Qt::AlignLeft | Qt::AlignRight); + alignment |= Qt::AlignAbsolute; + } + return alignment; + } + + QPixmap getPixmapCursor(Qt::CursorShape cshape); + + void _q_updateFocusObject(QObject *object); + + static QGuiApplicationPrivate *instance() { return self; } + + static QIcon *app_icon; + static QString *platform_name; + static QString *displayName; + static QString *desktopFileName; + + QWindowList modalWindowList; + static void showModalWindow(QWindow *window); + static void hideModalWindow(QWindow *window); + static void updateBlockedStatus(QWindow *window); + + virtual Qt::WindowModality defaultModality() const; + virtual bool windowNeverBlocked(QWindow *window) const; + bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = nullptr) const; + static qsizetype popupCount() { return QGuiApplicationPrivate::popup_list.size(); } + static QWindow *activePopupWindow(); + static void activatePopup(QWindow *popup); + static bool closePopup(QWindow *popup); + static bool closeAllPopups(); + + static Qt::MouseButton mousePressButton; + static struct QLastCursorPosition { + constexpr inline QLastCursorPosition() noexcept : thePoint(qt_inf(), qt_inf()) {} + constexpr inline Q_IMPLICIT QLastCursorPosition(QPointF p) noexcept : thePoint(p) {} + constexpr inline Q_IMPLICIT operator QPointF() const noexcept { return thePoint; } + constexpr inline qreal x() const noexcept{ return thePoint.x(); } + constexpr inline qreal y() const noexcept{ return thePoint.y(); } + Q_GUI_EXPORT QPoint toPoint() const noexcept; + + constexpr void reset() noexcept { *this = QLastCursorPosition{}; } + + // QGuiApplicationPrivate::lastCursorPosition is used for mouse-move detection + // but even QPointF's qFuzzCompare on doubles is too precise, and causes move-noise + // e.g. on macOS (see QTBUG-111170). So we specialize the equality operators here + // to use single-point precision. + friend constexpr bool operator==(const QLastCursorPosition &p1, const QPointF &p2) noexcept + { + return qFuzzyCompare(float(p1.x()), float(p2.x())) + && qFuzzyCompare(float(p1.y()), float(p2.y())); + } + friend constexpr bool operator!=(const QLastCursorPosition &p1, const QPointF &p2) noexcept + { + return !(p1 == p2); + } + friend constexpr bool operator==(const QPointF &p1, const QLastCursorPosition &p2) noexcept + { + return p2 == p1; + } + friend constexpr bool operator!=(const QPointF &p1, const QLastCursorPosition &p2) noexcept + { + return !(p2 == p1); + } + + private: + QPointF thePoint; + } lastCursorPosition; + static QWindow *currentMouseWindow; + static QWindow *currentMousePressWindow; + static Qt::ApplicationState applicationState; + static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy; + static QPointer currentDragWindow; + + // TODO remove this: QPointingDevice can store what we need directly + struct TabletPointData { + TabletPointData(qint64 devId = 0) : deviceId(devId), state(Qt::NoButton), target(nullptr) {} + qint64 deviceId; + Qt::MouseButtons state; + QWindow *target; + }; + static QList tabletDevicePoints; + static TabletPointData &tabletDevicePoint(qint64 deviceId); + +#ifndef QT_NO_CLIPBOARD + static QClipboard *qt_clipboard; +#endif + + static QPalette *app_pal; + + static QWindowList window_list; + static QWindowList popup_list; + static const QWindow *active_popup_on_press; + static QWindow *focus_window; + +#ifndef QT_NO_CURSOR + QList cursor_list; +#endif + static QList screen_list; + + static QFont *app_font; + + static QString styleOverride; + static QStyleHints *styleHints; + static bool obey_desktop_settings; + static bool popup_closed_on_press; + QInputMethod *inputMethod; + + QString firstWindowTitle; + QIcon forcedWindowIcon; + + static QList generic_plugin_list; +#if QT_CONFIG(shortcut) + QShortcutMap shortcutMap; +#endif + +#ifndef QT_NO_SESSIONMANAGER + QSessionManager *session_manager; + bool is_session_restored; + bool is_saving_session; + void commitData(); + void saveState(); +#endif + + QEvent::Type lastTouchType; + struct SynthesizedMouseData { + SynthesizedMouseData(const QPointF &p, const QPointF &sp, QWindow *w) + : pos(p), screenPos(sp), window(w) { } + QPointF pos; + QPointF screenPos; + QPointer window; + }; + QHash synthesizedMousePoints; + + static QInputDeviceManager *inputDeviceManager(); + + const QColorTrcLut *colorProfileForA8Text(); + const QColorTrcLut *colorProfileForA32Text(); + + // hook reimplemented in QApplication to apply the QStyle function on the QIcon + virtual QPixmap applyQIconStyleHelper(QIcon::Mode, const QPixmap &basePixmap) const { return basePixmap; } + + virtual void notifyWindowIconChanged(); + + static void applyWindowGeometrySpecificationTo(QWindow *window); + + static void setApplicationState(Qt::ApplicationState state, bool forcePropagate = false); + + static void resetCachedDevicePixelRatio(); + +#ifndef QT_NO_ACTION + virtual QActionPrivate *createActionPrivate() const; +#endif +#ifndef QT_NO_SHORTCUT + virtual QShortcutPrivate *createShortcutPrivate() const; +#endif + + static void updatePalette(); + + static QEvent::Type contextMenuEventType(); + +protected: + virtual void handleThemeChanged(); + + static bool setPalette(const QPalette &palette); + virtual QPalette basePalette() const; + virtual void handlePaletteChanged(const char *className = nullptr); + +#if QT_CONFIG(draganddrop) + virtual void notifyDragStarted(const QDrag *); +#endif // QT_CONFIG(draganddrop) + +private: + static void clearPalette(); + + friend class QDragManager; + friend class QWindowPrivate; + + static QGuiApplicationPrivate *self; + static int m_fakeMouseSourcePointId; +#ifdef Q_OS_WIN + std::shared_ptr m_a8ColorProfile; +#endif + std::shared_ptr m_a32ColorProfile; + + bool ownGlobalShareContext; + + static QInputDeviceManager *m_inputDeviceManager; + + // Cache the maximum device pixel ratio, to iterate through the screen list + // only the first time it's required, or when devices are added or removed. + static qreal m_maxDevicePixelRatio; +}; + +// ----------------- QNativeInterface ----------------- + +class QWindowsMimeConverter; + +namespace QNativeInterface::Private { + +#if defined(Q_OS_WIN) || defined(Q_QDOC) + + +struct Q_GUI_EXPORT QWindowsApplication +{ + QT_DECLARE_NATIVE_INTERFACE(QWindowsApplication, 1, QGuiApplication) + + enum WindowActivationBehavior { + DefaultActivateWindow, + AlwaysActivateWindow + }; + + enum TouchWindowTouchType { + NormalTouch = 0x00000000, + FineTouch = 0x00000001, + WantPalmTouch = 0x00000002 + }; + + Q_DECLARE_FLAGS(TouchWindowTouchTypes, TouchWindowTouchType) + + enum DarkModeHandlingFlag { + DarkModeWindowFrames = 0x1, + DarkModeStyle = 0x2 + }; + + Q_DECLARE_FLAGS(DarkModeHandling, DarkModeHandlingFlag) + + virtual void setTouchWindowTouchType(TouchWindowTouchTypes type) = 0; + virtual TouchWindowTouchTypes touchWindowTouchType() const = 0; + + virtual WindowActivationBehavior windowActivationBehavior() const = 0; + virtual void setWindowActivationBehavior(WindowActivationBehavior behavior) = 0; + + virtual void setHasBorderInFullScreenDefault(bool border) = 0; + + virtual bool isTabletMode() const = 0; + + virtual bool isWinTabEnabled() const = 0; + virtual bool setWinTabEnabled(bool enabled) = 0; + + virtual DarkModeHandling darkModeHandling() const = 0; + virtual void setDarkModeHandling(DarkModeHandling handling) = 0; + + virtual void registerMime(QWindowsMimeConverter *mime) = 0; + virtual void unregisterMime(QWindowsMimeConverter *mime) = 0; + + virtual int registerMimeType(const QString &mime) = 0; + + virtual HWND createMessageWindow(const QString &classNameTemplate, + const QString &windowName, + QFunctionPointer eventProc = nullptr) const = 0; + + virtual bool asyncExpose() const = 0; // internal, used by Active Qt + virtual void setAsyncExpose(bool value) = 0; + + virtual QVariant gpu() const = 0; // internal, used by qtdiag + virtual QVariant gpuList() const = 0; + + virtual void populateLightSystemPalette(QPalette &pal) const = 0; +}; +#endif // Q_OS_WIN + +} // QNativeInterface::Private + +#if defined(Q_OS_WIN) +Q_DECLARE_OPERATORS_FOR_FLAGS(QNativeInterface::Private::QWindowsApplication::TouchWindowTouchTypes) +Q_DECLARE_OPERATORS_FOR_FLAGS(QNativeInterface::Private::QWindowsApplication::DarkModeHandling) +#endif + +QT_END_NAMESPACE + +#endif // QGUIAPPLICATION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qharfbuzzng_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qharfbuzzng_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9b35b6492ddf55563ab9d16b85c51c1607df8d9d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qharfbuzzng_p.h @@ -0,0 +1,60 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2013 Konstantin Ritt +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHARFBUZZNG_P_H +#define QHARFBUZZNG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_REQUIRE_CONFIG(harfbuzz); + +#include + +#if defined(QT_BUILD_GUI_LIB) +# include +#else +// a minimal set of HB types required for Qt libs other than Gui + +typedef struct hb_face_t hb_face_t; +typedef struct hb_font_t hb_font_t; + +#endif // QT_BUILD_GUI_LIB + +QT_BEGIN_NAMESPACE + +class QFontEngine; + +#if defined(QT_BUILD_GUI_LIB) + +// Unicode + +hb_script_t hb_qt_script_to_script(QChar::Script script); +QChar::Script hb_qt_script_from_script(hb_script_t script); + +hb_unicode_funcs_t *hb_qt_get_unicode_funcs(); + +#endif // QT_BUILD_GUI_LIB + +// Font + +Q_GUI_EXPORT hb_face_t *hb_qt_face_get_for_engine(QFontEngine *fe); +Q_GUI_EXPORT hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe); + +Q_GUI_EXPORT void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value); +Q_GUI_EXPORT uint hb_qt_font_get_use_design_metrics(hb_font_t *font); + +QT_END_NAMESPACE + +#endif // QHARFBUZZNG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qhexstring_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qhexstring_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0750226eedac49589de829b56c0d2a78568211c0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qhexstring_p.h @@ -0,0 +1,60 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include +#include +#include +#include +#include + +#ifndef QHEXSTRING_P_H +#define QHEXSTRING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +// internal helper. Converts an integer value to a unique string token +template + struct HexString +{ + inline HexString(const T t) + : val(t) + {} + + inline void write(QChar *&dest) const + { + const char16_t hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + const char *c = reinterpret_cast(&val); + for (uint i = 0; i < sizeof(T); ++i) { + *dest++ = hexChars[*c & 0xf]; + *dest++ = hexChars[(*c & 0xf0) >> 4]; + ++c; + } + } + const T val; +}; + +// specialization to enable fast concatenating of our string tokens to a string +template + struct QConcatenable > +{ + typedef HexString type; + enum { ExactSize = true }; + static int size(const HexString &) { return sizeof(T) * 2; } + static inline void appendTo(const HexString &str, QChar *&out) { str.write(out); } + typedef QString ConvertTo; +}; + +QT_END_NAMESPACE + +#endif // QHEXSTRING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qhighdpiscaling_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qhighdpiscaling_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9725c49c29b8951b8318822561dba258f33cb0aa --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qhighdpiscaling_p.h @@ -0,0 +1,389 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHIGHDPISCALING_P_H +#define QHIGHDPISCALING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcHighDpi); + +class QScreen; +class QPlatformScreen; +typedef QPair QDpi; + +#ifndef QT_NO_HIGHDPISCALING +class Q_GUI_EXPORT QHighDpiScaling { + Q_GADGET +public: + enum class DpiAdjustmentPolicy { + Unset, + Enabled, + Disabled, + UpOnly + }; + Q_ENUM(DpiAdjustmentPolicy) + + QHighDpiScaling() = delete; + ~QHighDpiScaling() = delete; + QHighDpiScaling(const QHighDpiScaling &) = delete; + QHighDpiScaling &operator=(const QHighDpiScaling &) = delete; + QHighDpiScaling(QHighDpiScaling &&) = delete; + QHighDpiScaling &operator=(QHighDpiScaling &&) = delete; + + static void initHighDpiScaling(); + static void updateHighDpiScaling(); + static void setGlobalFactor(qreal factor); + static void setScreenFactor(QScreen *screen, qreal factor); + + static bool isActive() { return m_active; } + + struct Point { + enum Kind { + Invalid, + DeviceIndependent, + Native + }; + Kind kind; + QPoint point; + }; + + struct ScaleAndOrigin + { + qreal factor; + QPoint origin; + }; + + static ScaleAndOrigin scaleAndOrigin(const QPlatformScreen *platformScreen, Point position = Point{ Point::Invalid, QPoint() }); + static ScaleAndOrigin scaleAndOrigin(const QScreen *screen, Point position = Point{ Point::Invalid, QPoint() }); + static ScaleAndOrigin scaleAndOrigin(const QWindow *platformScreen, Point position = Point{ Point::Invalid, QPoint() }); + + template + static qreal factor(C *context) { + return scaleAndOrigin(context).factor; + } + + static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen); + static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen); + static QDpi logicalDpi(const QScreen *screen); + static qreal roundScaleFactor(qreal rawFactor); + +private: + struct ScreenFactor { + ScreenFactor(QString name, qreal factor) + :name(name), factor(factor) { } + QString name; + qreal factor; + }; + + static qreal rawScaleFactor(const QPlatformScreen *screen); + static QDpi effectiveLogicalDpi(const QPlatformScreen *screen, qreal rawFactor, qreal roundedFactor); + static qreal screenSubfactor(const QPlatformScreen *screen); + static QScreen *screenForPosition(Point position, QScreen *guess); + static QVector parseScreenScaleFactorsSpec(const QStringView &screenScaleFactors); + + static qreal m_factor; + static bool m_active; + static bool m_usePlatformPluginDpi; + static bool m_platformPluginDpiScalingActive; + static bool m_globalScalingActive; + static bool m_screenFactorSet; + static bool m_usePhysicalDpi; + static QVector m_screenFactors; + static DpiAdjustmentPolicy m_dpiAdjustmentPolicy; + static QHash m_namedScreenScaleFactors; + +#ifndef QT_NO_DEBUG_STREAM + friend Q_GUI_EXPORT QDebug operator<<(QDebug, const ScreenFactor &); +#endif +}; + +namespace QHighDpi { + +inline qreal scale(qreal value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) +{ + return value * scaleFactor; +} + +inline QSize scale(const QSize &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) +{ + return value * scaleFactor; +} + +inline QSizeF scale(const QSizeF &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) +{ + return value * scaleFactor; +} + +inline QVector2D scale(const QVector2D &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) +{ + return value * float(scaleFactor); +} + +inline QPointF scale(const QPointF &pos, qreal scaleFactor, QPointF origin = QPointF(0, 0)) +{ + return (pos - origin) * scaleFactor + origin; +} + +inline QPoint scale(const QPoint &pos, qreal scaleFactor, QPoint origin = QPoint(0, 0)) +{ + return (pos - origin) * scaleFactor + origin; +} + +inline QRect scale(const QRect &rect, qreal scaleFactor, QPoint origin = QPoint(0, 0)) +{ + return QRect(scale(rect.topLeft(), scaleFactor, origin), scale(rect.size(), scaleFactor)); +} + +inline QRectF scale(const QRectF &rect, qreal scaleFactor, QPoint origin = QPoint(0, 0)) +{ + return QRectF(scale(rect.topLeft(), scaleFactor, origin), scale(rect.size(), scaleFactor)); +} + +inline QMargins scale(const QMargins &margins, qreal scaleFactor, QPoint origin = QPoint(0, 0)) +{ + Q_UNUSED(origin); + return QMargins(qRound(qreal(margins.left()) * scaleFactor), qRound(qreal(margins.top()) * scaleFactor), + qRound(qreal(margins.right()) * scaleFactor), qRound(qreal(margins.bottom()) * scaleFactor)); +} + +template +QList scale(const QList &list, qreal scaleFactor, QPoint origin = QPoint(0, 0)) +{ + if (qFuzzyCompare(scaleFactor, qreal(1))) + return list; + + QList scaled; + scaled.reserve(list.size()); + for (const T &item : list) + scaled.append(scale(item, scaleFactor, origin)); + return scaled; +} + +inline QRegion scale(const QRegion ®ion, qreal scaleFactor, QPoint origin = QPoint(0, 0)) +{ + if (qFuzzyCompare(scaleFactor, qreal(1))) + return region; + + QRegion scaled = region.translated(-origin); + scaled = QTransform::fromScale(scaleFactor, scaleFactor).map(scaled); + return scaled.translated(origin); +} + +template +inline QHighDpiScaling::Point position(T, QHighDpiScaling::Point::Kind) { + return QHighDpiScaling::Point{ QHighDpiScaling::Point::Invalid, QPoint() }; +} +inline QHighDpiScaling::Point position(QPoint point, QHighDpiScaling::Point::Kind kind) { + return QHighDpiScaling::Point{ kind, point }; +} +inline QHighDpiScaling::Point position(QPointF point, QHighDpiScaling::Point::Kind kind) { + return QHighDpiScaling::Point{ kind, point.toPoint() }; +} +inline QHighDpiScaling::Point position(QRect rect, QHighDpiScaling::Point::Kind kind) { + return QHighDpiScaling::Point{ kind, rect.topLeft() }; +} +inline QHighDpiScaling::Point position(QRectF rect, QHighDpiScaling::Point::Kind kind) { + return QHighDpiScaling::Point{ kind, rect.topLeft().toPoint() }; +} + +template +T fromNativePixels(const T &value, const C *context) +{ + QHighDpiScaling::ScaleAndOrigin so = QHighDpiScaling::scaleAndOrigin(context); + return scale(value, qreal(1) / so.factor, so.origin); +} + +template +T toNativePixels(const T &value, const C *context) +{ + QHighDpiScaling::ScaleAndOrigin so = QHighDpiScaling::scaleAndOrigin(context); + return scale(value, so.factor, so.origin); +} + +template +T fromNativeLocalPosition(const T &value, const C *context) +{ + return scale(value, qreal(1) / QHighDpiScaling::factor(context)); +} + +template +T toNativeLocalPosition(const T &value, const C *context) +{ + return scale(value, QHighDpiScaling::factor(context)); +} + +template +T fromNativeGlobalPosition(const T &value, const C *context) +{ + QHighDpiScaling::ScaleAndOrigin so = + QHighDpiScaling::scaleAndOrigin(context, position(value, QHighDpiScaling::Point::Native)); + return scale(value, qreal(1) / so.factor, so.origin); +} + +template +T toNativeGlobalPosition(const T &value, const C *context) +{ + QHighDpiScaling::ScaleAndOrigin so = + QHighDpiScaling::scaleAndOrigin(context, position(value, QHighDpiScaling::Point::DeviceIndependent)); + return scale(value, so.factor, so.origin); +} + +template +T fromNativeWindowGeometry(const T &value, const C *context) +{ + QHighDpiScaling::ScaleAndOrigin so = QHighDpiScaling::scaleAndOrigin(context); + QPoint effectiveOrigin = (context && context->isTopLevel()) ? so.origin : QPoint(0,0); + return scale(value, qreal(1) / so.factor, effectiveOrigin); +} + +template +T toNativeWindowGeometry(const T &value, const C *context) +{ + QHighDpiScaling::ScaleAndOrigin so = QHighDpiScaling::scaleAndOrigin(context); + QPoint effectiveOrigin = (context && context->isTopLevel()) ? so.origin : QPoint(0,0); + return scale(value, so.factor, effectiveOrigin); +} + +template +inline T fromNative(const T &value, qreal scaleFactor, QPoint origin = QPoint(0, 0)) +{ + return scale(value, qreal(1) / scaleFactor, origin); +} + +template +inline T toNative(const T &value, qreal scaleFactor, QPoint origin = QPoint(0, 0)) +{ + return scale(value, scaleFactor, origin); +} + +inline QRect fromNative(const QRect &rect, const QScreen *screen, const QPoint &screenOrigin) +{ + return scale(rect, qreal(1) / QHighDpiScaling::factor(screen), screenOrigin); +} + +inline QRect fromNativeScreenGeometry(const QRect &nativeScreenGeometry, const QScreen *screen) +{ + return QRect(nativeScreenGeometry.topLeft(), + scale(nativeScreenGeometry.size(), qreal(1) / QHighDpiScaling::factor(screen))); +} + +inline QRegion fromNativeLocalRegion(const QRegion &pixelRegion, const QWindow *window) +{ + return scale(pixelRegion, qreal(1) / QHighDpiScaling::factor(window)); +} + +// When mapping expose events to Qt rects: round top/left towards the origin and +// bottom/right away from the origin, making sure that we cover the whole window. +inline QRegion fromNativeLocalExposedRegion(const QRegion &pixelRegion, const QWindow *window) +{ + if (!QHighDpiScaling::isActive()) + return pixelRegion; + + const qreal scaleFactor = QHighDpiScaling::factor(window); + QRegion pointRegion; + for (const QRectF rect: pixelRegion) + pointRegion += QRectF(rect.topLeft() / scaleFactor, rect.size() / scaleFactor).toAlignedRect(); + + return pointRegion; +} + +inline QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *window) +{ + return scale(pointRegion, QHighDpiScaling::factor(window)); +} + +} // namespace QHighDpi +#else // QT_NO_HIGHDPISCALING +class Q_GUI_EXPORT QHighDpiScaling { +public: + static inline void initHighDpiScaling() {} + static inline void updateHighDpiScaling() {} + static inline void setGlobalFactor(qreal) {} + static inline void setScreenFactor(QScreen *, qreal) {} + + struct ScaleAndOrigin + { + qreal factor; + QPoint origin; + }; + static ScaleAndOrigin scaleAndOrigin(const QPlatformScreen *platformScreen, QPoint *nativePosition = nullptr); + static ScaleAndOrigin scaleAndOrigin(const QScreen *screen, QPoint *nativePosition = nullptr); + static ScaleAndOrigin scaleAndOrigin(const QWindow *platformScreen, QPoint *nativePosition = nullptr); + + static inline bool isActive() { return false; } + static inline qreal factor(const QWindow *) { return 1.0; } + static inline qreal factor(const QScreen *) { return 1.0; } + static inline qreal factor(const QPlatformScreen *) { return 1.0; } + static inline QPoint origin(const QScreen *) { return QPoint(); } + static inline QPoint origin(const QPlatformScreen *) { return QPoint(); } + static inline QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *) { return pos; } + static inline QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *) { return pos; } + static inline QPointF mapPositionToGlobal(const QPointF &pos, const QPoint &, const QWindow *) { return pos; } + static inline QPointF mapPositionFromGlobal(const QPointF &pos, const QPoint &, const QWindow *) { return pos; } + static inline QDpi logicalDpi(const QScreen *) { return QDpi(-1,-1); } +}; + +namespace QHighDpi { + template inline + T scale(const T &value, ...) { return value; } + + template inline + T toNative(const T &value, ...) { return value; } + template inline + T fromNative(const T &value, ...) { return value; } + + template inline + T fromNativeLocalPosition(const T &value, ...) { return value; } + template inline + T toNativeLocalPosition(const T &value, ...) { return value; } + template inline + T fromNativeGlobalPosition(const T &value, const C *) { return value; } + template inline + T toNativeGlobalPosition(const T &value, const C *) { return value; } + template inline + T fromNativeWindowGeometry(const T &value, const C *) { return value; } + template inline + T toNativeWindowGeometry(const T &value, const C *) { return value; } + + template inline + T fromNativeLocalRegion(const T &value, ...) { return value; } + template inline + T fromNativeLocalExposedRegion(const T &value, ...) { return value; } + template inline + T toNativeLocalRegion(const T &value, ...) { return value; } + + template inline + T fromNativeScreenGeometry(const T &value, ...) { return value; } + + template inline + T toNativePixels(const T &value, const U*) {return value;} + template inline + T fromNativePixels(const T &value, const U*) {return value;} +} +#endif // QT_NO_HIGHDPISCALING +QT_END_NAMESPACE + +#endif // QHIGHDPISCALING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qicc_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qicc_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9daf1b3dc64be7ddb02b3ab84794038a5cd23233 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qicc_p.h @@ -0,0 +1,35 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QICC_P_H +#define QICC_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QColorSpace; + +namespace QIcc { + +bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace); +QByteArray toIccProfile(const QColorSpace &space); + +} + +QT_END_NAMESPACE + +#endif // QICC_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qicon_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qicon_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3c3a4c9c1af60976333b008f10cc3ead7bd5175f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qicon_p.h @@ -0,0 +1,119 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QICON_P_H +#define QICON_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +#ifndef QT_NO_ICON +QT_BEGIN_NAMESPACE + +class QIconPrivate +{ +public: + explicit QIconPrivate(QIconEngine *e); + + ~QIconPrivate() { + delete engine; + } + + static qreal pixmapDevicePixelRatio(qreal displayDevicePixelRatio, const QSize &requestedSize, const QSize &actualSize); + + QIconEngine *engine; + + QAtomicInt ref; + int serialNum; + int detach_no; + bool is_mask; + + static void clearIconCache(); +}; + + +struct QPixmapIconEngineEntry +{ + QPixmapIconEngineEntry() = default; + QPixmapIconEngineEntry(const QPixmap &pm, QIcon::Mode m, QIcon::State s) + : pixmap(pm), size(pm.size()), mode(m), state(s) {} + QPixmapIconEngineEntry(const QString &file, const QSize &sz, QIcon::Mode m, QIcon::State s) + : fileName(file), size(sz), mode(m), state(s) {} + QPixmapIconEngineEntry(const QString &file, const QImage &image, QIcon::Mode m, QIcon::State s); + QPixmap pixmap; + QString fileName; + QSize size; + QIcon::Mode mode = QIcon::Normal; + QIcon::State state = QIcon::Off; +}; +Q_DECLARE_TYPEINFO(QPixmapIconEngineEntry, Q_RELOCATABLE_TYPE); + +inline QPixmapIconEngineEntry::QPixmapIconEngineEntry(const QString &file, const QImage &image, QIcon::Mode m, QIcon::State s) + : fileName(file), size(image.size()), mode(m), state(s) +{ + pixmap.convertFromImage(image); +} + +class Q_GUI_EXPORT QPixmapIconEngine : public QIconEngine { +public: + QPixmapIconEngine(); + QPixmapIconEngine(const QPixmapIconEngine &); + ~QPixmapIconEngine(); + void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override; + QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override; + QPixmapIconEngineEntry *bestMatch(const QSize &size, qreal scale, QIcon::Mode mode, QIcon::State state); + QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override; + QList availableSizes(QIcon::Mode mode, QIcon::State state) override; + void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state) override; + void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state) override; + bool isNull() override; + + QString key() const override; + QIconEngine *clone() const override; + bool read(QDataStream &in) override; + bool write(QDataStream &out) const override; + + static inline QSize adjustSize(const QSize &expectedSize, QSize size) + { + if (!size.isNull() && (size.width() > expectedSize.width() || size.height() > expectedSize.height())) + size.scale(expectedSize, Qt::KeepAspectRatio); + return size; + } + +private: + void removePixmapEntry(QPixmapIconEngineEntry *pe) + { + auto idx = pixmaps.size(); + while (--idx >= 0) { + if (pe == &pixmaps.at(idx)) { + pixmaps.remove(idx); + return; + } + } + } + QPixmapIconEngineEntry *tryMatch(const QSize &size, qreal scale, QIcon::Mode mode, QIcon::State state); + QList pixmaps; + + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QIcon &icon); + friend class QIconThemeEngine; +}; + +QT_END_NAMESPACE +#endif //QT_NO_ICON +#endif // QICON_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qiconengine_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qiconengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a8e2487b2be45713e6197ee63cd7a1b533c0bfe7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qiconengine_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QICONENGINE_P_H +#define QICONENGINE_P_H + +#include + +#ifndef QT_NO_ICON +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QIconEngine; + +class QProxyIconEngine : public QIconEngine +{ +public: + void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; + QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override; + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override; + + void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state) override; + void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state) override; + + QString key() const override; + QIconEngine *clone() const override; + bool read(QDataStream &in) override; + bool write(QDataStream &out) const override; + + QList availableSizes(QIcon::Mode mode = QIcon::Normal, + QIcon::State state = QIcon::Off) override; + + QString iconName() override; + bool isNull() override; + QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override; + + void virtual_hook(int id, void *data) override; +protected: + virtual QIconEngine *proxiedEngine() const = 0; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_ICON + +#endif // QICONENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qiconloader_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qiconloader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9edc0ca5ac21180f26de958103f176163a2d15ab --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qiconloader_p.h @@ -0,0 +1,219 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QICONLOADER_P_H +#define QICONLOADER_P_H + +#include + +#ifndef QT_NO_ICON +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QIconLoader; + +struct QIconDirInfo +{ + enum Type { Fixed, Scalable, Threshold, Fallback }; + enum Context { UnknownContext, Applications, MimeTypes }; + QIconDirInfo(const QString &_path = QString()) : + path(_path), + size(0), + maxSize(0), + minSize(0), + threshold(0), + scale(1), + type(Threshold), + context(UnknownContext) {} + QString path; + short size; + short maxSize; + short minSize; + short threshold; + short scale; + Type type; + Context context; +}; +Q_DECLARE_TYPEINFO(QIconDirInfo, Q_RELOCATABLE_TYPE); + +class QIconLoaderEngineEntry + { +public: + virtual ~QIconLoaderEngineEntry() {} + virtual QPixmap pixmap(const QSize &size, + QIcon::Mode mode, + QIcon::State state, + qreal scale) = 0; + QString filename; + QIconDirInfo dir; +}; + +struct ScalableEntry : public QIconLoaderEngineEntry +{ + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override; + QIcon svgIcon; +}; + +struct PixmapEntry : public QIconLoaderEngineEntry +{ + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override; + QPixmap basePixmap; +}; + +using QThemeIconEntries = std::vector>; + +struct QThemeIconInfo +{ + QThemeIconEntries entries; + QString iconName; +}; + +class QThemeIconEngine : public QProxyIconEngine +{ +public: + QThemeIconEngine(const QString& iconName = QString()); + QIconEngine *clone() const override; + bool read(QDataStream &in) override; + bool write(QDataStream &out) const override; + +protected: + QIconEngine *proxiedEngine() const override; + +private: + QThemeIconEngine(const QThemeIconEngine &other); + QString key() const override; + + QString m_iconName; + mutable uint m_themeKey = 0; + + mutable std::unique_ptr m_proxiedEngine; +}; + +class QIconLoaderEngine : public QIconEngine +{ +public: + QIconLoaderEngine(const QString& iconName = QString()); + ~QIconLoaderEngine(); + + void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override; + QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override; + QIconEngine *clone() const override; + + QString iconName() override; + bool isNull() override; + QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override; + QList availableSizes(QIcon::Mode mode, QIcon::State state) override; + + Q_GUI_EXPORT static QIconLoaderEngineEntry *entryForSize(const QThemeIconInfo &info, const QSize &size, int scale = 1); + +private: + Q_DISABLE_COPY(QIconLoaderEngine) + + QString key() const override; + bool hasIcon() const; + + QString m_iconName; + QThemeIconInfo m_info; + + friend class QIconLoader; +}; + +class QIconCacheGtkReader; + +class QIconTheme +{ +public: + QIconTheme(const QString &name); + QIconTheme() : m_valid(false) {} + QStringList parents() const; + QList keyList() { return m_keyList; } + QStringList contentDirs() { return m_contentDirs; } + bool isValid() { return m_valid; } +private: + QStringList m_contentDirs; + QList m_keyList; + QStringList m_parents; + bool m_valid; +public: + QList> m_gtkCaches; +}; + +class QIconEnginePlugin; + +class Q_GUI_EXPORT QIconLoader +{ +public: + QIconLoader(); + QThemeIconInfo loadIcon(const QString &iconName) const; + uint themeKey() const { return m_themeKey; } + + QString themeName() const; + void setThemeName(const QString &themeName); + QString fallbackThemeName() const; + void setFallbackThemeName(const QString &themeName); + QIconTheme theme() { return themeList.value(themeName()); } + void setThemeSearchPath(const QStringList &searchPaths); + QStringList themeSearchPaths() const; + void setFallbackSearchPaths(const QStringList &searchPaths); + QStringList fallbackSearchPaths() const; + QIconDirInfo dirInfo(int dirindex); + static QIconLoader *instance(); + void updateSystemTheme(); + void invalidateKey(); + void ensureInitialized(); + bool hasUserTheme() const { return !m_userTheme.isEmpty(); } + + QIconEngine *iconEngine(const QString &iconName) const; + +private: + enum DashRule { FallBack, NoFallBack }; + QThemeIconInfo findIconHelper(const QString &themeName, + const QString &iconName, + QStringList &visited, + DashRule rule) const; + QThemeIconInfo lookupFallbackIcon(const QString &iconName) const; + + uint m_themeKey; + mutable std::optional m_factory; + bool m_supportsSvg; + bool m_initialized; + + mutable QString m_userTheme; + mutable QString m_userFallbackTheme; + mutable QString m_systemTheme; + mutable QStringList m_iconDirs; + mutable QHash themeList; + mutable QStringList m_fallbackDirs; + mutable QString m_iconName; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_ICON + +#endif // QICONLOADER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimage_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimage_p.h new file mode 100644 index 0000000000000000000000000000000000000000..207a202e4e40dd69ff2c339e1eac5b04fc2fc442 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimage_p.h @@ -0,0 +1,573 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QIMAGE_P_H +#define QIMAGE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include +#include + + +QT_BEGIN_NAMESPACE + +class QImageWriter; + +struct Q_GUI_EXPORT QImageData { // internal image data + QImageData(); + ~QImageData(); + static QImageData *create(const QSize &size, QImage::Format format); + static QImageData *create(uchar *data, int w, int h, qsizetype bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr); + + static QImageData *get(QImage &img) noexcept { return img.d; } + static const QImageData *get(const QImage &img) noexcept { return img.d; } + + QAtomicInt ref; + + int width; + int height; + int depth; + qsizetype nbytes; // number of bytes data + qreal devicePixelRatio; + QList colortable; + uchar *data; + QImage::Format format; + qsizetype bytes_per_line; + int ser_no; // serial number + int detach_no; + + qreal dpmx; // dots per meter X (or 0) + qreal dpmy; // dots per meter Y (or 0) + QPoint offset; // offset in pixels + + uint own_data : 1; + uint ro_data : 1; + uint has_alpha_clut : 1; + uint is_cached : 1; + + QImageCleanupFunction cleanupFunction; + void* cleanupInfo; + + bool checkForAlphaPixels() const; + + // Convert the image in-place, minimizing memory reallocation + // Return false if the conversion cannot be done in-place. + bool convertInPlace(QImage::Format newFormat, Qt::ImageConversionFlags); + + QMap text; + + bool doImageIO(const QImage *image, QImageWriter* io, int quality) const; + + QPaintEngine *paintEngine; + + QColorSpace colorSpace; + + struct ImageSizeParameters { + qsizetype bytesPerLine; + qsizetype totalSize; + bool isValid() const { return bytesPerLine > 0 && totalSize > 0; } + }; + static ImageSizeParameters calculateImageParameters(qsizetype width, qsizetype height, qsizetype depth); +}; + +inline QImageData::ImageSizeParameters +QImageData::calculateImageParameters(qsizetype width, qsizetype height, qsizetype depth) +{ + ImageSizeParameters invalid = { -1, -1 }; + if (height <= 0) + return invalid; + + // calculate the size, taking care of overflows + qsizetype bytes_per_line; + if (qMulOverflow(width, depth, &bytes_per_line)) + return invalid; + if (qAddOverflow(bytes_per_line, qsizetype(31), &bytes_per_line)) + return invalid; + // bytes per scanline (must be multiple of 4) + bytes_per_line = (bytes_per_line >> 5) << 2; // can't overflow + + qsizetype total_size; + if (qMulOverflow(height, bytes_per_line, &total_size)) + return invalid; + qsizetype dummy; + if (qMulOverflow(height, qsizetype(sizeof(uchar *)), &dummy)) + return invalid; // why is this here? + // Disallow images where width * depth calculations might overflow + if (width > (INT_MAX - 31) / depth) + return invalid; + + return { bytes_per_line, total_size }; +} + +typedef void (*Image_Converter)(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); +typedef bool (*InPlace_Image_Converter)(QImageData *data, Qt::ImageConversionFlags); + +extern Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormats]; +extern InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QImage::NImageFormats]; + +void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); +void convert_generic_over_rgb64(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); +bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags); +bool convert_generic_inplace_over_rgb64(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags); +#if QT_CONFIG(raster_fp) +void convert_generic_over_rgba32f(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); +bool convert_generic_inplace_over_rgba32f(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags); +#endif + +void dither_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags, bool fromalpha); + +const uchar *qt_get_bitflip_array(); +Q_GUI_EXPORT void qGamma_correct_back_to_linear_cs(QImage *image); + +#if defined(_M_ARM) && defined(_MSC_VER) // QTBUG-42038 +#pragma optimize("", off) +#endif +inline int qt_depthForFormat(QImage::Format format) +{ + int depth = 0; + switch(format) { + case QImage::Format_Invalid: + case QImage::NImageFormats: + Q_UNREACHABLE(); + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + depth = 1; + break; + case QImage::Format_Indexed8: + case QImage::Format_Alpha8: + case QImage::Format_Grayscale8: + depth = 8; + break; + case QImage::Format_RGB32: + case QImage::Format_ARGB32: + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_RGBX8888: + case QImage::Format_RGBA8888: + case QImage::Format_RGBA8888_Premultiplied: + case QImage::Format_BGR30: + case QImage::Format_A2BGR30_Premultiplied: + case QImage::Format_RGB30: + case QImage::Format_A2RGB30_Premultiplied: + depth = 32; + break; + case QImage::Format_RGB555: + case QImage::Format_RGB16: + case QImage::Format_RGB444: + case QImage::Format_ARGB4444_Premultiplied: + case QImage::Format_Grayscale16: + depth = 16; + break; + case QImage::Format_RGB666: + case QImage::Format_ARGB6666_Premultiplied: + case QImage::Format_ARGB8565_Premultiplied: + case QImage::Format_ARGB8555_Premultiplied: + case QImage::Format_RGB888: + case QImage::Format_BGR888: + depth = 24; + break; + case QImage::Format_RGBX64: + case QImage::Format_RGBA64: + case QImage::Format_RGBA64_Premultiplied: + case QImage::Format_RGBX16FPx4: + case QImage::Format_RGBA16FPx4: + case QImage::Format_RGBA16FPx4_Premultiplied: + depth = 64; + break; + case QImage::Format_RGBX32FPx4: + case QImage::Format_RGBA32FPx4: + case QImage::Format_RGBA32FPx4_Premultiplied: + depth = 128; + break; + case QImage::Format_CMYK8888: + depth = 32; + break; + } + return depth; +} + +#if defined(_M_ARM) && defined(_MSC_VER) +#pragma optimize("", on) +#endif + +inline QImage::Format qt_opaqueVersion(QImage::Format format) +{ + switch (format) { + case QImage::Format_ARGB8565_Premultiplied: + return QImage::Format_RGB16; + case QImage::Format_ARGB8555_Premultiplied: + return QImage::Format_RGB555; + case QImage::Format_ARGB6666_Premultiplied: + return QImage::Format_RGB666; + case QImage::Format_ARGB4444_Premultiplied: + return QImage::Format_RGB444; + case QImage::Format_RGBA8888: + case QImage::Format_RGBA8888_Premultiplied: + return QImage::Format_RGBX8888; + case QImage::Format_A2BGR30_Premultiplied: + return QImage::Format_BGR30; + case QImage::Format_A2RGB30_Premultiplied: + return QImage::Format_RGB30; + case QImage::Format_RGBA64: + case QImage::Format_RGBA64_Premultiplied: + return QImage::Format_RGBX64; + case QImage::Format_RGBA16FPx4: + case QImage::Format_RGBA16FPx4_Premultiplied: + return QImage::Format_RGBX16FPx4; + case QImage::Format_RGBA32FPx4: + case QImage::Format_RGBA32FPx4_Premultiplied: + return QImage::Format_RGBX32FPx4; + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_ARGB32: + return QImage::Format_RGB32; + case QImage::Format_RGB16: + case QImage::Format_RGB32: + case QImage::Format_RGB444: + case QImage::Format_RGB555: + case QImage::Format_RGB666: + case QImage::Format_RGB888: + case QImage::Format_BGR888: + case QImage::Format_RGBX8888: + case QImage::Format_BGR30: + case QImage::Format_RGB30: + case QImage::Format_RGBX64: + case QImage::Format_RGBX16FPx4: + case QImage::Format_RGBX32FPx4: + case QImage::Format_Grayscale8: + case QImage::Format_Grayscale16: + case QImage::Format_CMYK8888: + return format; + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + case QImage::Format_Indexed8: + case QImage::Format_Alpha8: + case QImage::Format_Invalid: + case QImage::NImageFormats: + break; + } + return QImage::Format_RGB32; +} + +inline QImage::Format qt_alphaVersion(QImage::Format format) +{ + switch (format) { + case QImage::Format_RGB32: + case QImage::Format_ARGB32: + return QImage::Format_ARGB32_Premultiplied; + case QImage::Format_RGB16: + return QImage::Format_ARGB8565_Premultiplied; + case QImage::Format_RGB555: + return QImage::Format_ARGB8555_Premultiplied; + case QImage::Format_RGB666: + return QImage::Format_ARGB6666_Premultiplied; + case QImage::Format_RGB444: + return QImage::Format_ARGB4444_Premultiplied; + case QImage::Format_RGBX8888: + case QImage::Format_RGBA8888: + return QImage::Format_RGBA8888_Premultiplied; + case QImage::Format_BGR30: + return QImage::Format_A2BGR30_Premultiplied; + case QImage::Format_RGB30: + return QImage::Format_A2RGB30_Premultiplied; + case QImage::Format_RGBX64: + case QImage::Format_RGBA64: + case QImage::Format_Grayscale16: + return QImage::Format_RGBA64_Premultiplied; + case QImage::Format_RGBX16FPx4: + case QImage::Format_RGBA16FPx4: + return QImage::Format_RGBA16FPx4_Premultiplied; + case QImage::Format_RGBX32FPx4: + case QImage::Format_RGBA32FPx4: + return QImage::Format_RGBA32FPx4_Premultiplied; + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_ARGB8565_Premultiplied: + case QImage::Format_ARGB8555_Premultiplied: + case QImage::Format_ARGB6666_Premultiplied: + case QImage::Format_ARGB4444_Premultiplied: + case QImage::Format_RGBA8888_Premultiplied: + case QImage::Format_A2BGR30_Premultiplied: + case QImage::Format_A2RGB30_Premultiplied: + case QImage::Format_RGBA64_Premultiplied: + case QImage::Format_RGBA16FPx4_Premultiplied: + case QImage::Format_RGBA32FPx4_Premultiplied: + return format; + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + case QImage::Format_Indexed8: + case QImage::Format_RGB888: + case QImage::Format_BGR888: + case QImage::Format_Alpha8: + case QImage::Format_Grayscale8: + case QImage::Format_Invalid: + case QImage::Format_CMYK8888: + case QImage::NImageFormats: + break; + } + return QImage::Format_ARGB32_Premultiplied; +} + +// Returns an opaque version that is compatible with format +inline QImage::Format qt_maybeDataCompatibleOpaqueVersion(QImage::Format format) +{ + switch (format) { + case QImage::Format_ARGB6666_Premultiplied: + return QImage::Format_RGB666; + case QImage::Format_ARGB4444_Premultiplied: + return QImage::Format_RGB444; + case QImage::Format_RGBA8888: + case QImage::Format_RGBA8888_Premultiplied: + return QImage::Format_RGBX8888; + case QImage::Format_A2BGR30_Premultiplied: + return QImage::Format_BGR30; + case QImage::Format_A2RGB30_Premultiplied: + return QImage::Format_RGB30; + case QImage::Format_RGBA64: + case QImage::Format_RGBA64_Premultiplied: + return QImage::Format_RGBX64; + case QImage::Format_RGBA16FPx4: + case QImage::Format_RGBA16FPx4_Premultiplied: + return QImage::Format_RGBX16FPx4; + case QImage::Format_RGBA32FPx4: + case QImage::Format_RGBA32FPx4_Premultiplied: + return QImage::Format_RGBX32FPx4; + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_ARGB32: + return QImage::Format_RGB32; + case QImage::Format_RGB16: + case QImage::Format_RGB32: + case QImage::Format_RGB444: + case QImage::Format_RGB555: + case QImage::Format_RGB666: + case QImage::Format_RGB888: + case QImage::Format_BGR888: + case QImage::Format_RGBX8888: + case QImage::Format_BGR30: + case QImage::Format_RGB30: + case QImage::Format_RGBX64: + case QImage::Format_RGBX16FPx4: + case QImage::Format_RGBX32FPx4: + case QImage::Format_Grayscale8: + case QImage::Format_Grayscale16: + case QImage::Format_CMYK8888: + return format; // Already opaque + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + case QImage::Format_Indexed8: + case QImage::Format_ARGB8565_Premultiplied: + case QImage::Format_ARGB8555_Premultiplied: + case QImage::Format_Alpha8: + case QImage::Format_Invalid: + case QImage::NImageFormats: + break; + } + return format; // No compatible opaque versions +} + +constexpr QImage::Format qt_toUnpremultipliedFormat(QImage::Format format) +{ + // Assumes input is already a premultiplied format with an unpremultiplied counterpart + // This abuses the fact unpremultiplied formats are always before their premultiplied counterparts. + return static_cast(qToUnderlying(format) - 1); +} + +constexpr QImage::Format qt_toPremultipliedFormat(QImage::Format format) +{ + // Assumes input is already an unpremultiplied format + // This abuses the fact unpremultiplied formats are always before their premultiplied counterparts. + return static_cast(qToUnderlying(format) + 1); +} + +inline bool qt_highColorPrecision(QImage::Format format, bool opaque = false) +{ + // Formats with higher color precision than ARGB32_Premultiplied. + switch (format) { + case QImage::Format_ARGB32: + case QImage::Format_RGBA8888: + return !opaque; + case QImage::Format_BGR30: + case QImage::Format_RGB30: + case QImage::Format_A2BGR30_Premultiplied: + case QImage::Format_A2RGB30_Premultiplied: + case QImage::Format_RGBX64: + case QImage::Format_RGBA64: + case QImage::Format_RGBA64_Premultiplied: + case QImage::Format_Grayscale16: + case QImage::Format_RGBX16FPx4: + case QImage::Format_RGBA16FPx4: + case QImage::Format_RGBA16FPx4_Premultiplied: + case QImage::Format_RGBX32FPx4: + case QImage::Format_RGBA32FPx4: + case QImage::Format_RGBA32FPx4_Premultiplied: + return true; + default: + break; + } + return false; +} + +inline bool qt_fpColorPrecision(QImage::Format format) +{ + switch (format) { + case QImage::Format_RGBX16FPx4: + case QImage::Format_RGBA16FPx4: + case QImage::Format_RGBA16FPx4_Premultiplied: + case QImage::Format_RGBX32FPx4: + case QImage::Format_RGBA32FPx4: + case QImage::Format_RGBA32FPx4_Premultiplied: + return true; + default: + break; + } + return false; +} + +inline QColorSpace::ColorModel qt_csColorData(QPixelFormat::ColorModel format) +{ + switch (format) { + case QPixelFormat::ColorModel::RGB: + case QPixelFormat::ColorModel::BGR: + case QPixelFormat::ColorModel::Indexed: + return QColorSpace::ColorModel::Rgb; + case QPixelFormat::ColorModel::Alpha: + return QColorSpace::ColorModel::Undefined; // No valid colors + case QPixelFormat::ColorModel::Grayscale: + return QColorSpace::ColorModel::Gray; + case QPixelFormat::ColorModel::CMYK: + return QColorSpace::ColorModel::Cmyk; + default: + break; + } + return QColorSpace::ColorModel::Undefined; +} + +inline bool qt_compatibleColorModelBase(QPixelFormat::ColorModel data, QColorSpace::ColorModel cs) +{ + QColorSpace::ColorModel dataCs = qt_csColorData(data); + + if (data == QPixelFormat::ColorModel::Alpha) + return true; // Alpha data has no colors and can be handled by any color space + + if (cs == QColorSpace::ColorModel::Undefined || dataCs == QColorSpace::ColorModel::Undefined) + return false; + + return (dataCs == cs); // Matching color models +} + +inline bool qt_compatibleColorModelSource(QPixelFormat::ColorModel data, QColorSpace::ColorModel cs) +{ + if (qt_compatibleColorModelBase(data, cs)) + return true; + + if (data == QPixelFormat::ColorModel::Grayscale && cs == QColorSpace::ColorModel::Rgb) + return true; // Can apply Rgb CS to Gray input data + + return false; +} + +inline bool qt_compatibleColorModelTarget(QPixelFormat::ColorModel data, QColorSpace::ColorModel cs, QColorSpace::TransformModel tm) +{ + if (qt_compatibleColorModelBase(data, cs)) + return true; + + if (data == QPixelFormat::ColorModel::Grayscale && tm == QColorSpace::TransformModel::ThreeComponentMatrix) + return true; // Can apply three-component matrix CS to gray output + + return false; +} + +inline QImage::Format qt_maybeDataCompatibleAlphaVersion(QImage::Format format) +{ + switch (format) { + case QImage::Format_RGB32: + return QImage::Format_ARGB32_Premultiplied; + case QImage::Format_RGB666: + return QImage::Format_ARGB6666_Premultiplied; + case QImage::Format_RGB444: + return QImage::Format_ARGB4444_Premultiplied; + case QImage::Format_RGBX8888: + return QImage::Format_RGBA8888_Premultiplied; + case QImage::Format_BGR30: + return QImage::Format_A2BGR30_Premultiplied; + case QImage::Format_RGB30: + return QImage::Format_A2RGB30_Premultiplied; + case QImage::Format_RGBX64: + return QImage::Format_RGBA64_Premultiplied; + case QImage::Format_RGBX16FPx4: + return QImage::Format_RGBA16FPx4_Premultiplied; + case QImage::Format_RGBX32FPx4: + return QImage::Format_RGBA32FPx4_Premultiplied; + case QImage::Format_ARGB32: + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_ARGB8565_Premultiplied: + case QImage::Format_ARGB8555_Premultiplied: + case QImage::Format_ARGB6666_Premultiplied: + case QImage::Format_ARGB4444_Premultiplied: + case QImage::Format_RGBA8888: + case QImage::Format_RGBA8888_Premultiplied: + case QImage::Format_A2BGR30_Premultiplied: + case QImage::Format_A2RGB30_Premultiplied: + case QImage::Format_Alpha8: + case QImage::Format_RGBA64: + case QImage::Format_RGBA64_Premultiplied: + case QImage::Format_RGBA16FPx4: + case QImage::Format_RGBA16FPx4_Premultiplied: + case QImage::Format_RGBA32FPx4: + case QImage::Format_RGBA32FPx4_Premultiplied: + return format; // Already alpha versions + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + case QImage::Format_Indexed8: + case QImage::Format_RGB16: + case QImage::Format_RGB555: + case QImage::Format_RGB888: + case QImage::Format_BGR888: + case QImage::Format_Grayscale8: + case QImage::Format_Grayscale16: + case QImage::Format_CMYK8888: + case QImage::Format_Invalid: + case QImage::NImageFormats: + break; + } + return format; // No data-compatible alpha version +} + +inline QImage::Format qt_opaqueVersionForPainting(QImage::Format format) +{ + QImage::Format toFormat = qt_opaqueVersion(format); + // If we are switching depth anyway upgrade to RGB32 + if (qt_depthForFormat(format) != qt_depthForFormat(toFormat) && qt_depthForFormat(toFormat) <= 32) + toFormat = QImage::Format_RGB32; + return toFormat; +} + +inline QImage::Format qt_alphaVersionForPainting(QImage::Format format) +{ + QImage::Format toFormat = qt_alphaVersion(format); +#if defined(__ARM_NEON__) || defined(__SSE2__) + // If we are switching depth anyway and we have optimized ARGB32PM routines, upgrade to that. + if (qt_depthForFormat(format) != qt_depthForFormat(toFormat) && qt_depthForFormat(toFormat) <= 32) + toFormat = QImage::Format_ARGB32_Premultiplied; +#endif + return toFormat; +} + +Q_GUI_EXPORT QMap qt_getImageText(const QImage &image, const QString &description); +Q_GUI_EXPORT QMap qt_getImageTextFromDescription(const QString &description); + +QT_END_NAMESPACE + +#endif // QIMAGE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimagepixmapcleanuphooks_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimagepixmapcleanuphooks_p.h new file mode 100644 index 0000000000000000000000000000000000000000..adbf703050cc7912ddb722bcf3ed8ee436bce80b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimagepixmapcleanuphooks_p.h @@ -0,0 +1,66 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QIMAGEPIXMAP_CLEANUPHOOKS_P_H +#define QIMAGEPIXMAP_CLEANUPHOOKS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +typedef void (*_qt_image_cleanup_hook_64)(qint64); +typedef void (*_qt_pixmap_cleanup_hook_pmd)(QPlatformPixmap*); + + +class QImagePixmapCleanupHooks; + +class Q_GUI_EXPORT QImagePixmapCleanupHooks +{ +public: + static QImagePixmapCleanupHooks *instance(); + + static void enableCleanupHooks(const QImage &image); + static void enableCleanupHooks(const QPixmap &pixmap); + static void enableCleanupHooks(QPlatformPixmap *handle); + + static bool isImageCached(const QImage &image); + static bool isPixmapCached(const QPixmap &pixmap); + + // Gets called when a pixmap data is about to be modified: + void addPlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd); + + // Gets called when a pixmap data is about to be destroyed: + void addPlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd); + + // Gets called when an image is about to be modified or destroyed: + void addImageHook(_qt_image_cleanup_hook_64); + + void removePlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd); + void removePlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd); + void removeImageHook(_qt_image_cleanup_hook_64); + + static void executePlatformPixmapModificationHooks(QPlatformPixmap*); + static void executePlatformPixmapDestructionHooks(QPlatformPixmap*); + static void executeImageHooks(qint64 key); + +private: + QList<_qt_image_cleanup_hook_64> imageHooks; + QList<_qt_pixmap_cleanup_hook_pmd> pixmapModificationHooks; + QList<_qt_pixmap_cleanup_hook_pmd> pixmapDestructionHooks; +}; + +QT_END_NAMESPACE + +#endif // QIMAGEPIXMAP_CLEANUPHOOKS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimagereaderwriterhelpers_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimagereaderwriterhelpers_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b921bed9b1ed51c9b77416d94c25aec80304d407 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimagereaderwriterhelpers_p.h @@ -0,0 +1,103 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QIMAGEREADERWRITERHELPERS_P_H +#define QIMAGEREADERWRITERHELPERS_P_H + +#include +#include +#include "qimageiohandler.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QFactoryLoader; + +namespace QImageReaderWriterHelpers { + +enum _qt_BuiltInFormatType { +#ifndef QT_NO_IMAGEFORMAT_PNG + _qt_PngFormat, +#endif +#ifndef QT_NO_IMAGEFORMAT_BMP + _qt_BmpFormat, +#endif +#ifndef QT_NO_IMAGEFORMAT_PPM + _qt_PpmFormat, + _qt_PgmFormat, + _qt_PbmFormat, +#endif +#ifndef QT_NO_IMAGEFORMAT_XBM + _qt_XbmFormat, +#endif +#ifndef QT_NO_IMAGEFORMAT_XPM + _qt_XpmFormat, +#endif + _qt_NumFormats, + _qt_NoFormat = -1 +}; + +#if !defined(QT_NO_IMAGEFORMAT_PPM) +# define MAX_MT_SIZE 20 +#elif !defined(QT_NO_IMAGEFORMAT_XBM) || !defined(QT_NO_IMAGEFORMAT_XPM) +# define MAX_MT_SIZE 10 +#else +# define MAX_MT_SIZE 4 +#endif + +struct _qt_BuiltInFormatStruct +{ + char extension[4]; + char mimeType[MAX_MT_SIZE]; +}; + +#undef MAX_MT_SIZE + +static const _qt_BuiltInFormatStruct _qt_BuiltInFormats[] = { +#ifndef QT_NO_IMAGEFORMAT_PNG + {"png", "png"}, +#endif +#ifndef QT_NO_IMAGEFORMAT_BMP + {"bmp", "bmp"}, +#endif +#ifndef QT_NO_IMAGEFORMAT_PPM + {"ppm", "x-portable-pixmap"}, + {"pgm", "x-portable-graymap"}, + {"pbm", "x-portable-bitmap"}, +#endif +#ifndef QT_NO_IMAGEFORMAT_XBM + {"xbm", "x-xbitmap"}, +#endif +#ifndef QT_NO_IMAGEFORMAT_XPM + {"xpm", "x-xpixmap"}, +#endif +}; +static_assert(_qt_NumFormats == sizeof _qt_BuiltInFormats / sizeof *_qt_BuiltInFormats); + +#ifndef QT_NO_IMAGEFORMATPLUGIN +QSharedPointer pluginLoader(); +#endif + +enum Capability { + CanRead, + CanWrite +}; +QList supportedImageFormats(Capability cap); +QList supportedMimeTypes(Capability cap); +QList imageFormatsForMimeType(QByteArrayView mimeType, Capability cap); + +} + +QT_END_NAMESPACE + +#endif // QIMAGEREADERWRITERHELPERS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimagescale_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimagescale_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8181cec3e982e85cddd557ea11ca7e27a93b9873 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qimagescale_p.h @@ -0,0 +1,41 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QIMAGESCALE_P_H +#define QIMAGESCALE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +/* + This version accepts only supported formats. +*/ +QImage qSmoothScaleImage(const QImage &img, int w, int h); + +namespace QImageScale { + struct QImageScaleInfo { + int *xpoints{nullptr}; + const unsigned int **ypoints{nullptr}; + int *xapoints{nullptr}; + int *yapoints{nullptr}; + int xup_yup{0}; + int sh = 0; + int sw = 0; + }; +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputcontrol_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputcontrol_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7cffe6b5c1606301fac0414feba169af338656ed --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputcontrol_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QINPUTCONTROL_P_H +#define QINPUTCONTROL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QKeyEvent; +class Q_GUI_EXPORT QInputControl : public QObject +{ + Q_OBJECT +public: + enum Type { + LineEdit, + TextEdit + }; + + explicit QInputControl(Type type, QObject *parent = nullptr); + + bool isAcceptableInput(const QKeyEvent *event) const; + static bool isCommonTextEditShortcut(const QKeyEvent *ke); + +protected: + explicit QInputControl(Type type, QObjectPrivate &dd, QObject *parent = nullptr); + +private: + const Type m_type; +}; + +QT_END_NAMESPACE + +#endif // QINPUTCONTROL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputdevice_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputdevice_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0a29be2a14f6a980b2b7d133c61fcbcea648e095 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputdevice_p.h @@ -0,0 +1,81 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QINPUTDEVICE_P_H +#define QINPUTDEVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include "private/qobject_p.h" + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QInputDevicePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QInputDevice) +public: + QInputDevicePrivate(const QString &name, qint64 winSysId, QInputDevice::DeviceType type, + QInputDevice::Capabilities caps = QInputDevice::Capability::None, + const QString &seatName = QString()) + : name(name), seatName(seatName), systemId(winSysId), capabilities(caps), + deviceType(type) + { + // if the platform doesn't provide device IDs, make one up, + // but try to avoid clashing with OS-provided 32-bit IDs + static qint64 nextId = qint64(1) << 33; + if (!systemId) + systemId = nextId++; + } + ~QInputDevicePrivate() override; + + QString name; + QString seatName; + QString busId; + QRect availableVirtualGeometry; + void *qqExtra = nullptr; // Qt Quick can store arbitrary device-specific data here + qint64 systemId = 0; + QInputDevice::Capabilities capabilities = QInputDevice::Capability::None; + QInputDevice::DeviceType deviceType = QInputDevice::DeviceType::Unknown; + bool pointingDeviceType = false; + + static void registerDevice(const QInputDevice *dev); + static void unregisterDevice(const QInputDevice *dev); + static bool isRegistered(const QInputDevice *dev); + static const QInputDevice *fromId(qint64 systemId); + + void setAvailableVirtualGeometry(QRect a) + { + if (a == availableVirtualGeometry) + return; + + availableVirtualGeometry = a; + capabilities |= QInputDevice::Capability::NormalizedPosition; + Q_Q(QInputDevice); + Q_EMIT q->availableVirtualGeometryChanged(availableVirtualGeometry); + } + + inline static QInputDevicePrivate *get(QInputDevice *q) + { + return static_cast(QObjectPrivate::get(q)); + } + + inline static const QInputDevicePrivate *get(const QInputDevice *q) + { + return static_cast(QObjectPrivate::get(q)); + } +}; + +QT_END_NAMESPACE + +#endif // QINPUTDEVICE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputdevicemanager_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputdevicemanager_p.h new file mode 100644 index 0000000000000000000000000000000000000000..88837b62b1ea3ac04e578195532e78daa03d2488 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputdevicemanager_p.h @@ -0,0 +1,61 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QINPUTDEVICEMANAGER_P_H +#define QINPUTDEVICEMANAGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QInputDeviceManagerPrivate; + +class Q_GUI_EXPORT QInputDeviceManager : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QInputDeviceManager) + +public: + enum DeviceType { + DeviceTypeUnknown, + DeviceTypePointer, + DeviceTypeKeyboard, + DeviceTypeTouch, + DeviceTypeTablet, + + NumDeviceTypes + }; + + explicit QInputDeviceManager(QObject *parent = nullptr); + ~QInputDeviceManager() override; + + int deviceCount(DeviceType type) const; + + void setCursorPos(const QPoint &pos); + + Qt::KeyboardModifiers keyboardModifiers() const; + void setKeyboardModifiers(Qt::KeyboardModifiers mods); + +Q_SIGNALS: + void deviceListChanged(QInputDeviceManager::DeviceType type); + void cursorPositionChangeRequested(const QPoint &pos); +}; + +QT_END_NAMESPACE + +QT_DECL_METATYPE_EXTERN_TAGGED(QInputDeviceManager::DeviceType, + QInputDeviceManager__DeviceType, Q_GUI_EXPORT) + +#endif // QINPUTDEVICEMANAGER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputdevicemanager_p_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputdevicemanager_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2bd54a29a9b77177ab4ebe38c261b1b4d7c0f2c5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputdevicemanager_p_p.h @@ -0,0 +1,43 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QINPUTDEVICEMANAGER_P_P_H +#define QINPUTDEVICEMANAGER_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include "qinputdevicemanager_p.h" + +#include + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QInputDeviceManagerPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QInputDeviceManager) + +public: + static QInputDeviceManagerPrivate *get(QInputDeviceManager *mgr) { return mgr->d_func(); } + + int deviceCount(QInputDeviceManager::DeviceType type) const; + void setDeviceCount(QInputDeviceManager::DeviceType type, int count); + + std::array m_deviceCount = {}; + + Qt::KeyboardModifiers keyboardModifiers; +}; + +QT_END_NAMESPACE + +#endif // QINPUTDEVICEMANAGER_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputmethod_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputmethod_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e7870bf5479c99b91d7d0374b88f8802f49c51dc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinputmethod_p.h @@ -0,0 +1,56 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QINPUTMETHOD_P_H +#define QINPUTMETHOD_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QInputMethodPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QInputMethod) + +public: + inline QInputMethodPrivate() : testContext(nullptr) + {} + QPlatformInputContext *platformInputContext() const + { + return testContext ? testContext : QGuiApplicationPrivate::platformIntegration()->inputContext(); + } + static inline QInputMethodPrivate *get(QInputMethod *inputMethod) + { + return inputMethod->d_func(); + } + + void _q_connectFocusObject(); + void _q_checkFocusObject(QObject *object); + static bool objectAcceptsInputMethod(QObject *object); + + QTransform inputItemTransform; + QRectF inputRectangle; + QPlatformInputContext *testContext; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinternalmimedata_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinternalmimedata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..75166acaae087849d31961b618ed5927702af509 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qinternalmimedata_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QINTERNALMIMEDATA_P_H +#define QINTERNALMIMEDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QEventLoop; +class QMouseEvent; +class QPlatformDrag; + +class Q_GUI_EXPORT QInternalMimeData : public QMimeData +{ + Q_OBJECT +public: + QInternalMimeData(); + ~QInternalMimeData(); + + bool hasFormat(const QString &mimeType) const override; + QStringList formats() const override; + static bool canReadData(const QString &mimeType); + + + static QStringList formatsHelper(const QMimeData *data); + static bool hasFormatHelper(const QString &mimeType, const QMimeData *data); + static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data); + +protected: + QVariant retrieveData(const QString &mimeType, QMetaType type) const override; + + virtual bool hasFormat_sys(const QString &mimeType) const = 0; + virtual QStringList formats_sys() const = 0; + virtual QVariant retrieveData_sys(const QString &mimeType, QMetaType type) const = 0; +}; + +QT_END_NAMESPACE + +#endif // QINTERNALMIMEDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qkeymapper_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qkeymapper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..13ae6a60fc4f60770de947050efecd79c33b33a4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qkeymapper_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QKEYMAPPER_P_H +#define QKEYMAPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QKeyMapper : public QObject +{ + Q_OBJECT +public: + explicit QKeyMapper(); + ~QKeyMapper(); + + static QKeyMapper *instance(); + static QList possibleKeys(const QKeyEvent *e); + + QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QKeyMapper) + +private: + Q_DISABLE_COPY_MOVE(QKeyMapper) +}; + +// ----------------- QNativeInterface ----------------- + +namespace QNativeInterface::Private { + +#if QT_CONFIG(evdev) || defined(Q_QDOC) +struct Q_GUI_EXPORT QEvdevKeyMapper +{ + QT_DECLARE_NATIVE_INTERFACE(QEvdevKeyMapper, 1, QKeyMapper) + virtual void loadKeymap(const QString &filename) = 0; + virtual void switchLang() = 0; +}; +#endif + +} // QNativeInterface::Private + + +QT_END_NAMESPACE + +#endif // QKEYMAPPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qkeysequence_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qkeysequence_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9264fd440e7236bbe73d02ef433d118b19c4b1ae --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qkeysequence_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QKEYSEQUENCE_P_H +#define QKEYSEQUENCE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qkeysequence.h" + +#include + +QT_REQUIRE_CONFIG(shortcut); + +QT_BEGIN_NAMESPACE + +struct QKeyBinding +{ + QKeySequence::StandardKey standardKey; + uchar priority; + QKeyCombination shortcut; + uint platform; +}; + +class QKeySequencePrivate +{ +public: + static constexpr int MaxKeyCount = 4 ; // also used in QKeySequenceEdit + constexpr QKeySequencePrivate() : ref(1), key{} {} + inline QKeySequencePrivate(const QKeySequencePrivate ©) : ref(1) + { + std::copy(copy.key, copy.key + MaxKeyCount, + QT_MAKE_CHECKED_ARRAY_ITERATOR(key, MaxKeyCount)); + } + QAtomicInt ref; + int key[MaxKeyCount]; + static QString encodeString(QKeyCombination keyCombination, QKeySequence::SequenceFormat format); + // used in dbusmenu + Q_GUI_EXPORT static QString keyName(Qt::Key key, QKeySequence::SequenceFormat format); + static QKeyCombination decodeString(QString accel, QKeySequence::SequenceFormat format); +}; + +QT_END_NAMESPACE + +#endif //QKEYSEQUENCE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qktxhandler_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qktxhandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0673366cc0f666696550947182246eafc34658b2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qktxhandler_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QKTXHANDLER_H +#define QKTXHANDLER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtexturefilehandler_p.h" + +#include + +QT_BEGIN_NAMESPACE + +struct KTXHeader; + +class QKtxHandler : public QTextureFileHandler +{ +public: + using QTextureFileHandler::QTextureFileHandler; + ~QKtxHandler() override; + + static bool canRead(const QByteArray &suffix, const QByteArray &block); + + QTextureFileData read() override; + +private: + bool checkHeader(const KTXHeader &header); + std::optional> decodeKeyValues(QByteArrayView view) const; + quint32 decode(quint32 val) const; + + bool inverseEndian = false; +}; + +QT_END_NAMESPACE + +#endif // QKTXHANDLER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qlayoutpolicy_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qlayoutpolicy_p.h new file mode 100644 index 0000000000000000000000000000000000000000..20537f3663e0f08e084c159f7a1ef06c0a74f476 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qlayoutpolicy_p.h @@ -0,0 +1,160 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QLAYOUTPOLICY_H +#define QLAYOUTPOLICY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#ifndef QT_NO_DATASTREAM +# include +#endif + +QT_BEGIN_NAMESPACE + + +class QVariant; + +class QLayoutPolicy +{ + Q_GADGET_EXPORT(Q_GUI_EXPORT) + +public: + enum PolicyFlag { + GrowFlag = 1, + ExpandFlag = 2, + ShrinkFlag = 4, + IgnoreFlag = 8 + }; + Q_DECLARE_FLAGS(Policy, PolicyFlag) + Q_FLAG(Policy) + + static constexpr inline Policy Fixed = {}; + static constexpr inline Policy Minimum = GrowFlag; + static constexpr inline Policy Maximum = ShrinkFlag; + static constexpr inline Policy Preferred = Minimum | Maximum; + static constexpr inline Policy MinimumExpanding = Minimum | ExpandFlag; + static constexpr inline Policy Expanding = Preferred | ExpandFlag; + static constexpr inline Policy Ignored = Preferred | IgnoreFlag; + + enum ControlType { + DefaultType = 0x00000001, + ButtonBox = 0x00000002, + CheckBox = 0x00000004, + ComboBox = 0x00000008, + Frame = 0x00000010, + GroupBox = 0x00000020, + Label = 0x00000040, + Line = 0x00000080, + LineEdit = 0x00000100, + PushButton = 0x00000200, + RadioButton = 0x00000400, + Slider = 0x00000800, + SpinBox = 0x00001000, + TabWidget = 0x00002000, + ToolButton = 0x00004000 + }; + Q_DECLARE_FLAGS(ControlTypes, ControlType) + + QLayoutPolicy() : data(0) { } + + QLayoutPolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) + : data(0) { + bits.horPolicy = horizontal; + bits.verPolicy = vertical; + setControlType(type); + } + Policy horizontalPolicy() const { return static_cast(bits.horPolicy); } + Policy verticalPolicy() const { return static_cast(bits.verPolicy); } + Q_GUI_EXPORT ControlType controlType() const; + + void setHorizontalPolicy(Policy d) { bits.horPolicy = d; } + void setVerticalPolicy(Policy d) { bits.verPolicy = d; } + Q_GUI_EXPORT void setControlType(ControlType type); + + Qt::Orientations expandingDirections() const { + Qt::Orientations result; + if (verticalPolicy() & ExpandFlag) + result |= Qt::Vertical; + if (horizontalPolicy() & ExpandFlag) + result |= Qt::Horizontal; + return result; + } + + void setHeightForWidth(bool b) { bits.hfw = b; } + bool hasHeightForWidth() const { return bits.hfw; } + void setWidthForHeight(bool b) { bits.wfh = b; } + bool hasWidthForHeight() const { return bits.wfh; } + + bool operator==(const QLayoutPolicy& s) const { return data == s.data; } + bool operator!=(const QLayoutPolicy& s) const { return data != s.data; } + + int horizontalStretch() const { return static_cast(bits.horStretch); } + int verticalStretch() const { return static_cast(bits.verStretch); } + void setHorizontalStretch(int stretchFactor) { bits.horStretch = static_cast(qBound(0, stretchFactor, 255)); } + void setVerticalStretch(int stretchFactor) { bits.verStretch = static_cast(qBound(0, stretchFactor, 255)); } + + inline void transpose(); + + +private: +#ifndef QT_NO_DATASTREAM + friend QDataStream &operator<<(QDataStream &, const QLayoutPolicy &); + friend QDataStream &operator>>(QDataStream &, QLayoutPolicy &); +#endif + QLayoutPolicy(int i) : data(i) { } + + union { + struct { + quint32 horStretch : 8; + quint32 verStretch : 8; + quint32 horPolicy : 4; + quint32 verPolicy : 4; + quint32 ctype : 5; + quint32 hfw : 1; + quint32 wfh : 1; + quint32 padding : 1; // feel free to use + } bits; + quint32 data; + }; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QLayoutPolicy::Policy) +Q_DECLARE_OPERATORS_FOR_FLAGS(QLayoutPolicy::ControlTypes) + +#ifndef QT_NO_DATASTREAM +QDataStream &operator<<(QDataStream &, const QLayoutPolicy &); +QDataStream &operator>>(QDataStream &, QLayoutPolicy &); +#endif + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QLayoutPolicy &); +#endif + +inline void QLayoutPolicy::transpose() { + Policy hData = horizontalPolicy(); + Policy vData = verticalPolicy(); + int hStretch = horizontalStretch(); + int vStretch = verticalStretch(); + setHorizontalPolicy(vData); + setVerticalPolicy(hData); + setHorizontalStretch(vStretch); + setVerticalStretch(hStretch); +} + +QT_END_NAMESPACE + +#endif // QLAYOUTPOLICY_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qmath_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qmath_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f419e12b4bd19c53be1c2371358b8c0093d5dbfc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qmath_p.h @@ -0,0 +1,43 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMATH_P_H +#define QMATH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +static const qreal Q_PI = qreal(M_PI); // pi +static const qreal Q_MM_PER_INCH = 25.4; + +inline QRect qt_mapFillRect(const QRectF &rect, const QTransform &xf) +{ + // Only for xf <= scaling or 90 degree rotations + Q_ASSERT(xf.type() <= QTransform::TxScale + || (xf.type() == QTransform::TxRotate && qFuzzyIsNull(xf.m11()) && qFuzzyIsNull(xf.m22()))); + // Transform the corners instead of the rect to avoid hitting numerical accuracy limit + // when transforming topleft and size separately and adding afterwards, + // as that can sometimes be slightly off around the .5 point, leading to wrong rounding + QPoint pt1 = xf.map(rect.topLeft()).toPoint(); + QPoint pt2 = xf.map(rect.bottomRight()).toPoint(); + // Normalize and adjust for the QRect vs. QRectF bottomright + return QRect::span(pt1, pt2).adjusted(0, 0, -1, -1); +} + +QT_END_NAMESPACE + +#endif // QMATH_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qmemrotate_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qmemrotate_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2ea249db97141f5281b4a81263b2bca797b6c988 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qmemrotate_p.h @@ -0,0 +1,38 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMEMROTATE_P_H +#define QMEMROTATE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +#define QT_DECL_MEMROTATE(type) \ + void Q_GUI_EXPORT qt_memrotate90(const type*, int, int, int, type*, int); \ + void Q_GUI_EXPORT qt_memrotate180(const type*, int, int, int, type*, int); \ + void Q_GUI_EXPORT qt_memrotate270(const type*, int, int, int, type*, int) + +QT_DECL_MEMROTATE(quint32); +QT_DECL_MEMROTATE(quint16); +QT_DECL_MEMROTATE(quint24); +QT_DECL_MEMROTATE(quint8); +QT_DECL_MEMROTATE(quint64); + +#undef QT_DECL_MEMROTATE + +QT_END_NAMESPACE + +#endif // QMEMROTATE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qoffscreensurface_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qoffscreensurface_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7d4ff2a9d920612ded51bed060cd60712c9c8014 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qoffscreensurface_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOFFSCREENSURFACE_P_H +#define QOFFSCREENSURFACE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qplatformoffscreensurface.h" + +#include + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QOffscreenSurfacePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QOffscreenSurface) + +public: + QOffscreenSurfacePrivate() + : QObjectPrivate() + , surfaceType(QSurface::OpenGLSurface) + , platformOffscreenSurface(nullptr) + , offscreenWindow(nullptr) + , requestedFormat(QSurfaceFormat::defaultFormat()) + , screen(nullptr) + , size(1, 1) + { + } + + ~QOffscreenSurfacePrivate() + { + } + + static QOffscreenSurfacePrivate *get(QOffscreenSurface *surface) + { + return surface ? surface->d_func() : nullptr; + } + + QSurface::SurfaceType surfaceType; + QPlatformOffscreenSurface *platformOffscreenSurface; + QWindow *offscreenWindow; + QSurfaceFormat requestedFormat; + QScreen *screen; + QSize size; +}; + +QT_END_NAMESPACE + +#endif // QOFFSCREENSURFACE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopengl_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopengl_p.h new file mode 100644 index 0000000000000000000000000000000000000000..52c8cb377da7adfb1a60fdd8f967ac72ad35a89f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopengl_p.h @@ -0,0 +1,107 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGL_P_H +#define QOPENGL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QJsonDocument; + +class Q_GUI_EXPORT QOpenGLExtensionMatcher +{ +public: + QOpenGLExtensionMatcher(); + + bool match(const QByteArray &extension) const + { + return m_extensions.contains(extension); + } + + QSet extensions() const { return m_extensions; } + +private: + QSet m_extensions; +}; + +class Q_GUI_EXPORT QOpenGLConfig +{ +public: + struct Q_GUI_EXPORT Gpu { + Gpu() : vendorId(0), deviceId(0) {} + bool isValid() const { return deviceId || !glVendor.isEmpty(); } + bool equals(const Gpu &other) const { + return vendorId == other.vendorId && deviceId == other.deviceId && driverVersion == other.driverVersion + && driverDescription == other.driverDescription && glVendor == other.glVendor; + } + + uint vendorId; + uint deviceId; + QVersionNumber driverVersion; + QByteArray driverDescription; + QByteArray glVendor; + + static Gpu fromDevice(uint vendorId, uint deviceId, QVersionNumber driverVersion, const QByteArray &driverDescription) { + Gpu gpu; + gpu.vendorId = vendorId; + gpu.deviceId = deviceId; + gpu.driverVersion = driverVersion; + gpu.driverDescription = driverDescription; + return gpu; + } + + static Gpu fromGLVendor(const QByteArray &glVendor) { + Gpu gpu; + gpu.glVendor = glVendor; + return gpu; + } + + static Gpu fromContext(); + }; + + static QSet gpuFeatures(const Gpu &gpu, + const QString &osName, const QVersionNumber &kernelVersion, const QString &osVersion, + const QJsonDocument &doc); + static QSet gpuFeatures(const Gpu &gpu, + const QString &osName, const QVersionNumber &kernelVersion, const QString &osVersion, + const QString &fileName); + static QSet gpuFeatures(const Gpu &gpu, const QJsonDocument &doc); + static QSet gpuFeatures(const Gpu &gpu, const QString &fileName); +}; + +inline bool operator==(const QOpenGLConfig::Gpu &a, const QOpenGLConfig::Gpu &b) +{ + return a.equals(b); +} + +inline bool operator!=(const QOpenGLConfig::Gpu &a, const QOpenGLConfig::Gpu &b) +{ + return !a.equals(b); +} + +inline size_t qHash(const QOpenGLConfig::Gpu &gpu, size_t seed = 0) +{ + return (qHash(gpu.vendorId) + qHash(gpu.deviceId) + qHash(gpu.driverVersion)) ^ seed; +} + +QT_END_NAMESPACE + +#endif // QOPENGL_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopenglcontext_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopenglcontext_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4dff81e17b32521f437f8536dec489cf6b5f19f1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopenglcontext_p.h @@ -0,0 +1,266 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGLCONTEXT_P_H +#define QOPENGLCONTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#ifndef QT_NO_OPENGL + +#include +#include "qopenglcontext.h" +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + + +class QOpenGLFunctions; +class QOpenGLContext; +class QOpenGLFramebufferObject; +class QOpenGLMultiGroupSharedResource; + +class Q_GUI_EXPORT QOpenGLSharedResource +{ +public: + QOpenGLSharedResource(QOpenGLContextGroup *group); + virtual ~QOpenGLSharedResource() = 0; + + QOpenGLContextGroup *group() const { return m_group; } + + // schedule the resource for deletion at an appropriate time + void free(); + +protected: + // the resource's share group no longer exists, invalidate the resource + virtual void invalidateResource() = 0; + + // a valid context in the group is current, free the resource + virtual void freeResource(QOpenGLContext *context) = 0; + +private: + QOpenGLContextGroup *m_group; + + friend class QOpenGLContextGroup; + friend class QOpenGLContextGroupPrivate; + friend class QOpenGLMultiGroupSharedResource; + + Q_DISABLE_COPY_MOVE(QOpenGLSharedResource) +}; + +class Q_GUI_EXPORT QOpenGLSharedResourceGuard : public QOpenGLSharedResource +{ +public: + typedef void (*FreeResourceFunc)(QOpenGLFunctions *functions, GLuint id); + QOpenGLSharedResourceGuard(QOpenGLContext *context, GLuint id, FreeResourceFunc func) + : QOpenGLSharedResource(context->shareGroup()) + , m_id(id) + , m_func(func) + { + } + ~QOpenGLSharedResourceGuard() override; + + GLuint id() const { return m_id; } + +protected: + void invalidateResource() override + { + m_id = 0; + } + + void freeResource(QOpenGLContext *context) override; + +private: + GLuint m_id; + FreeResourceFunc m_func; +}; + +class Q_GUI_EXPORT QOpenGLContextGroupPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QOpenGLContextGroup) +public: + QOpenGLContextGroupPrivate() + : m_context(nullptr) + , m_refs(0) + { + } + ~QOpenGLContextGroupPrivate() override; + + void addContext(QOpenGLContext *ctx); + void removeContext(QOpenGLContext *ctx); + + void cleanup(); + + void deletePendingResources(QOpenGLContext *ctx); + + QOpenGLContext *m_context; + + QList m_shares; + QRecursiveMutex m_mutex; + + QHash m_resources; + QAtomicInt m_refs; + + QList m_sharedResources; + QList m_pendingDeletion; +}; + +class Q_GUI_EXPORT QOpenGLMultiGroupSharedResource +{ +public: + QOpenGLMultiGroupSharedResource(); + ~QOpenGLMultiGroupSharedResource(); + + void insert(QOpenGLContext *context, QOpenGLSharedResource *value); + void cleanup(QOpenGLContextGroup *group, QOpenGLSharedResource *value); + + QOpenGLSharedResource *value(QOpenGLContext *context); + + QList resources() const; + + template + T *value(QOpenGLContext *context) { + QOpenGLContextGroup *group = context->shareGroup(); + // Have to use our own mutex here, not the group's, since + // m_groups has to be protected too against any concurrent access. + QMutexLocker locker(&m_mutex); + T *resource = static_cast(group->d_func()->m_resources.value(this, nullptr)); + if (!resource) { + resource = new T(context); + insert(context, resource); + } + return resource; + } + +private: + QAtomicInt active; + QList m_groups; + QRecursiveMutex m_mutex; +}; + +class QPaintEngineEx; +class QOpenGLFunctions; +class QOpenGLTextureHelper; +class QOpenGLVertexArrayObjectHelper; + +class Q_GUI_EXPORT QOpenGLContextVersionFunctionHelper +{ +public: + virtual ~QOpenGLContextVersionFunctionHelper(); +}; + +class Q_GUI_EXPORT QOpenGLContextPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QOpenGLContext) +public: + QOpenGLContextPrivate() + : platformGLContext(nullptr) + , shareContext(nullptr) + , shareGroup(nullptr) + , screen(nullptr) + , surface(nullptr) + , functions(nullptr) + , textureFunctions(nullptr) + , versionFunctions(nullptr) + , vaoHelper(nullptr) + , vaoHelperDestroyCallback(nullptr) + , max_texture_size(-1) + , workaround_brokenFBOReadBack(false) + , workaround_brokenTexSubImage(false) + , workaround_missingPrecisionQualifiers(false) + , active_engine(nullptr) + , qgl_current_fbo_invalid(false) + , qgl_current_fbo(nullptr) + , defaultFboRedirect(0) + { + requestedFormat = QSurfaceFormat::defaultFormat(); + } + + ~QOpenGLContextPrivate() override; + + void adopt(QPlatformOpenGLContext *); + + QSurfaceFormat requestedFormat; + QPlatformOpenGLContext *platformGLContext; + QOpenGLContext *shareContext; + QOpenGLContextGroup *shareGroup; + QScreen *screen; + QSurface *surface; + QOpenGLFunctions *functions; + mutable QSet extensionNames; + QOpenGLTextureHelper* textureFunctions; + std::function textureFunctionsDestroyCallback; + QOpenGLContextVersionFunctionHelper *versionFunctions; + QOpenGLVertexArrayObjectHelper *vaoHelper; + using QOpenGLVertexArrayObjectHelperDestroyCallback_t = void (*)(QOpenGLVertexArrayObjectHelper *); + QOpenGLVertexArrayObjectHelperDestroyCallback_t vaoHelperDestroyCallback; + + GLint max_texture_size; + + bool workaround_brokenFBOReadBack; + bool workaround_brokenTexSubImage; + bool workaround_missingPrecisionQualifiers; + + QPaintEngineEx *active_engine; + + bool qgl_current_fbo_invalid; + + // Set and unset in QOpenGLFramebufferObject::bind()/unbind(). + // (Only meaningful for QOGLFBO since an FBO might be bound by other means) + // Saves us from querying the driver for the current FBO in most paths. + QOpenGLFramebufferObject *qgl_current_fbo; + + GLuint defaultFboRedirect; + + static QOpenGLContext *setCurrentContext(QOpenGLContext *context); + + int maxTextureSize(); + + static QOpenGLContextPrivate *get(QOpenGLContext *context) + { + return context ? context->d_func() : nullptr; + } + +#if !defined(QT_NO_DEBUG) + static bool toggleMakeCurrentTracker(QOpenGLContext *context, bool value) + { + QMutexLocker locker(&makeCurrentTrackerMutex); + bool old = makeCurrentTracker.value(context, false); + makeCurrentTracker.insert(context, value); + return old; + } + static void cleanMakeCurrentTracker(QOpenGLContext *context) + { + QMutexLocker locker(&makeCurrentTrackerMutex); + makeCurrentTracker.remove(context); + } + static QHash makeCurrentTracker; + static QMutex makeCurrentTrackerMutex; +#endif + + void _q_screenDestroyed(QObject *object); +}; + +Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context); +Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); + +QT_END_NAMESPACE + +#endif // QT_NO_OPENGL +#endif // QOPENGLCONTEXT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopenglextensions_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopenglextensions_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b9490e3891cc52faab1b52461de53842040ef5e6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopenglextensions_p.h @@ -0,0 +1,122 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGL_EXTENSIONS_P_H +#define QOPENGL_EXTENSIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Qt OpenGL classes. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qopenglextrafunctions.h" + +QT_BEGIN_NAMESPACE + +class QOpenGLExtensionsPrivate; + +class Q_GUI_EXPORT QOpenGLExtensions : public QOpenGLExtraFunctions +{ + Q_DECLARE_PRIVATE(QOpenGLExtensions) +public: + QOpenGLExtensions(); + QOpenGLExtensions(QOpenGLContext *context); + ~QOpenGLExtensions() {} + + enum OpenGLExtension { + TextureRectangle = 0x00000001, + GenerateMipmap = 0x00000002, + TextureCompression = 0x00000004, + MirroredRepeat = 0x00000008, + FramebufferMultisample = 0x00000010, + StencilTwoSide = 0x00000020, + StencilWrap = 0x00000040, + PackedDepthStencil = 0x00000080, + NVFloatBuffer = 0x00000100, + PixelBufferObject = 0x00000200, + FramebufferBlit = 0x00000400, + BGRATextureFormat = 0x00000800, + DDSTextureCompression = 0x00001000, + ETC1TextureCompression = 0x00002000, + PVRTCTextureCompression = 0x00004000, + ElementIndexUint = 0x00008000, + Depth24 = 0x00010000, + SRGBFrameBuffer = 0x00020000, + MapBuffer = 0x00040000, + GeometryShaders = 0x00080000, + MapBufferRange = 0x00100000, + Sized8Formats = 0x00200000, + DiscardFramebuffer = 0x00400000, + Sized16Formats = 0x00800000, + TextureSwizzle = 0x01000000, + StandardDerivatives = 0x02000000, + ASTCTextureCompression = 0x04000000, + ETC2TextureCompression = 0x08000000, + HalfFloatVertex = 0x10000000, + MultiView = 0x20000000, + MultiViewExtended = 0x40000000 + }; + Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension) + + OpenGLExtensions openGLExtensions(); + bool hasOpenGLExtension(QOpenGLExtensions::OpenGLExtension extension) const; + + GLvoid *glMapBuffer(GLenum target, GLenum access); + void glGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data); + + void flushShared(); + void discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments); + + QOpenGLExtensionsPrivate *d() const; + +private: + static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != nullptr; } +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLExtensions::OpenGLExtensions) + +class QOpenGLExtensionsPrivate : public QOpenGLExtraFunctionsPrivate +{ +public: + explicit QOpenGLExtensionsPrivate(QOpenGLContext *ctx); + + GLvoid* (QOPENGLF_APIENTRYP MapBuffer)(GLenum target, GLenum access); + void (QOPENGLF_APIENTRYP GetBufferSubData)(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data); + void (QOPENGLF_APIENTRYP DiscardFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum *attachments); + + bool flushVendorChecked; + bool flushIsSufficientToSyncContexts; +}; + +inline QOpenGLExtensionsPrivate *QOpenGLExtensions::d() const +{ + return static_cast(d_ptr); +} + +inline GLvoid *QOpenGLExtensions::glMapBuffer(GLenum target, GLenum access) +{ + Q_D(QOpenGLExtensions); + Q_ASSERT(QOpenGLExtensions::isInitialized(d)); + GLvoid *result = d->MapBuffer(target, access); + Q_OPENGL_FUNCTIONS_DEBUG + return result; +} + +inline void QOpenGLExtensions::glGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data) +{ + Q_D(QOpenGLExtensions); + Q_ASSERT(QOpenGLExtensions::isInitialized(d)); + d->GetBufferSubData(target, offset, size, data); + Q_OPENGL_FUNCTIONS_DEBUG +} + +QT_END_NAMESPACE + +#endif // QOPENGL_EXTENSIONS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopenglprogrambinarycache_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopenglprogrambinarycache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7284c2e1e2076627675d3e4db714a547bfc37935 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qopenglprogrambinarycache_p.h @@ -0,0 +1,113 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGLPROGRAMBINARYCACHE_P_H +#define QOPENGLPROGRAMBINARYCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +// These classes are also used by the OpenGL backend of QRhi. They must +// therefore stay independent from QOpenGLShader(Program). Must rely only on +// QOpenGLContext/Functions. + +Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcOpenGLProgramDiskCache, Q_GUI_EXPORT) + +class Q_GUI_EXPORT QOpenGLProgramBinaryCache +{ +public: + struct Q_GUI_EXPORT ShaderDesc { + ShaderDesc() { } + ShaderDesc(QShader::Stage stage, const QByteArray &source = QByteArray()) + : stage(stage), source(source) + { } + QShader::Stage stage; + QByteArray source; + }; + struct Q_GUI_EXPORT ProgramDesc { + QList shaders; + QByteArray cacheKey() const; + }; + + QOpenGLProgramBinaryCache(); + + bool load(const QByteArray &cacheKey, uint programId); + void save(const QByteArray &cacheKey, uint programId); + +private: + QString cacheFileName(const QByteArray &cacheKey) const; + bool verifyHeader(const QByteArray &buf) const; + bool setProgramBinary(uint programId, uint blobFormat, const void *p, uint blobSize); + + QString m_globalCacheDir; + QString m_localCacheDir; + QString m_currentCacheDir; + bool m_cacheWritable; + struct MemCacheEntry { + MemCacheEntry(const void *p, int size, uint format) + : blob(reinterpret_cast(p), size), + format(format) + { } + QByteArray blob; + uint format; + }; + QCache m_memCache; +#if QT_CONFIG(opengles2) + void (QOPENGLF_APIENTRYP programBinaryOES)(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); + void (QOPENGLF_APIENTRYP getProgramBinaryOES)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); + void initializeProgramBinaryOES(QOpenGLContext *context); + bool m_programBinaryOESInitialized = false; +#endif + QMutex m_mutex; +}; + +// While unlikely, one application can in theory use contexts with different versions +// or profiles. Therefore any version- or extension-specific checks must be done on a +// per-context basis, not just once per process. QOpenGLSharedResource enables this, +// although it's once-per-sharing-context-group, not per-context. Still, this should +// be good enough in practice. +class Q_GUI_EXPORT QOpenGLProgramBinarySupportCheck : public QOpenGLSharedResource +{ +public: + QOpenGLProgramBinarySupportCheck(QOpenGLContext *context); + void invalidateResource() override { } + void freeResource(QOpenGLContext *) override { } + + bool isSupported() const { return m_supported; } + +private: + bool m_supported; +}; + +class QOpenGLProgramBinarySupportCheckWrapper +{ +public: + QOpenGLProgramBinarySupportCheck *get(QOpenGLContext *context) + { + return m_resource.value(context); + } + +private: + QOpenGLMultiGroupSharedResource m_resource; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qoutlinemapper_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qoutlinemapper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fbfab0744ce5d659ea802d72c890d4813c862250 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qoutlinemapper_p.h @@ -0,0 +1,185 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOUTLINEMAPPER_P_H +#define QOUTLINEMAPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +#include +#include + +#define QT_FT_BEGIN_HEADER +#define QT_FT_END_HEADER + +#include +#include +#include "qpaintengineex_p.h" + +QT_BEGIN_NAMESPACE + +// These limitations comes from qrasterizer.cpp, qcosmeticstroker.cpp, and qgrayraster.c. +// Any higher and rasterization of shapes will produce incorrect results. +#if Q_PROCESSOR_WORDSIZE == 8 +constexpr int QT_RASTER_COORD_LIMIT = ((1<<23) - 1); // F24dot8 in qgrayraster.c +#else +constexpr int QT_RASTER_COORD_LIMIT = ((1<<15) - 1); // F16dot16 in qrasterizer.cpp and qcosmeticstroker.cpp +#endif +//#define QT_DEBUG_CONVERT + +Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); + +/******************************************************************************** + * class QOutlineMapper + * + * Used to map between QPainterPath and the QT_FT_Outline structure used by the + * freetype scanconverter. + * + * The outline mapper uses a path iterator to get points from the path, + * so that it is possible to transform the points as they are converted. The + * callback can be a noop, translate or full-fledged xform. (Tests indicated + * that using a C callback was low cost). + */ +class QOutlineMapper +{ +public: + QOutlineMapper() : + m_element_types(0), + m_elements(0), + m_points(0), + m_tags(0), + m_contours(0), + m_in_clip_elements(false) + { + } + + /*! + Sets up the matrix to be used for conversion. This also + sets up the qt_path_iterator function that is used as a callback + to get points. + */ + void setMatrix(const QTransform &m) + { + m_transform = m; + + qreal scale; + qt_scaleForTransform(m, &scale); + m_curve_threshold = scale == 0 ? qreal(0.25) : (qreal(0.25) / scale); + } + + void setClipRect(QRect clipRect); + + void beginOutline(Qt::FillRule fillRule) + { +#ifdef QT_DEBUG_CONVERT + printf("QOutlineMapper::beginOutline rule=%d\n", fillRule); +#endif + m_valid = true; + m_elements.reset(); + m_element_types.reset(); + m_points.reset(); + m_tags.reset(); + m_contours.reset(); + m_outline.flags = fillRule == Qt::WindingFill + ? QT_FT_OUTLINE_NONE + : QT_FT_OUTLINE_EVEN_ODD_FILL; + m_subpath_start = 0; + } + + void endOutline(); + + void clipElements(const QPointF *points, const QPainterPath::ElementType *types, int count); + + void convertElements(const QPointF *points, const QPainterPath::ElementType *types, int count); + + inline void moveTo(const QPointF &pt) { +#ifdef QT_DEBUG_CONVERT + printf("QOutlineMapper::moveTo() (%f, %f)\n", pt.x(), pt.y()); +#endif + closeSubpath(); + m_subpath_start = m_elements.size(); + m_elements << pt; + m_element_types << QPainterPath::MoveToElement; + } + + inline void lineTo(const QPointF &pt) { +#ifdef QT_DEBUG_CONVERT + printf("QOutlineMapper::lineTo() (%f, %f)\n", pt.x(), pt.y()); +#endif + m_elements.add(pt); + m_element_types << QPainterPath::LineToElement; + } + + void curveTo(const QPointF &cp1, const QPointF &cp2, const QPointF &ep); + + inline void closeSubpath() { + int element_count = m_elements.size(); + if (element_count > 0) { + if (m_elements.at(element_count-1) != m_elements.at(m_subpath_start)) { +#ifdef QT_DEBUG_CONVERT + printf(" - implicitly closing\n"); +#endif + // Put the object on the stack to avoid the odd case where + // lineTo reallocs the databuffer and the QPointF & will + // be invalidated. + QPointF pt = m_elements.at(m_subpath_start); + + // only do lineTo if we have element_type array... + if (m_element_types.size()) + lineTo(pt); + else + m_elements << pt; + + } + } + } + + QT_FT_Outline *outline() { + if (m_valid) + return &m_outline; + return nullptr; + } + + QT_FT_Outline *convertPath(const QPainterPath &path); + QT_FT_Outline *convertPath(const QVectorPath &path); + + inline QPainterPath::ElementType *elementTypes() const { return m_element_types.size() == 0 ? nullptr : m_element_types.data(); } + +public: + QDataBuffer m_element_types; + QDataBuffer m_elements; + QDataBuffer m_points; + QDataBuffer m_tags; + QDataBuffer m_contours; + + QRect m_clip_rect; + QRectF m_clip_trigger_rect; + QRectF controlPointRect; // only valid after endOutline() + + QT_FT_Outline m_outline; + + int m_subpath_start; + + QTransform m_transform; + + qreal m_curve_threshold; + + bool m_valid; + bool m_in_clip_elements; +}; + +QT_END_NAMESPACE + +#endif // QOUTLINEMAPPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpagedpaintdevice_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpagedpaintdevice_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e34fe412ed36af96fa81c80951384dcf8fa3bd2c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpagedpaintdevice_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAGEDPAINTDEVICE_P_H +#define QPAGEDPAINTDEVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QPagedPaintDevicePrivate +{ +public: + QPagedPaintDevicePrivate() + : pageOrderAscending(true), + printSelectionOnly(false) + { + } + + virtual ~QPagedPaintDevicePrivate(); + + + virtual bool setPageLayout(const QPageLayout &newPageLayout) = 0; + + virtual bool setPageSize(const QPageSize &pageSize) = 0; + + virtual bool setPageOrientation(QPageLayout::Orientation orientation) = 0; + + virtual bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) = 0; + + virtual QPageLayout pageLayout() const = 0; + + static inline QPagedPaintDevicePrivate *get(QPagedPaintDevice *pd) { return pd->d; } + + // These are currently required to keep QPrinter functionality working in QTextDocument::print() + QPageRanges pageRanges; + bool pageOrderAscending; + bool printSelectionOnly; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpageranges_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpageranges_p.h new file mode 100644 index 0000000000000000000000000000000000000000..72c6a83db6530bbfabcbd0ab57f120c5b735dab1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpageranges_p.h @@ -0,0 +1,33 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAGERANGES_P_H +#define QPAGERANGES_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#include + +QT_BEGIN_NAMESPACE + +class QPageRangesPrivate : public QSharedData +{ +public: + void mergeIntervals(); + + QList intervals; +}; + +QT_END_NAMESPACE + +#endif // QPAGERANGES_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintdevicewindow_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintdevicewindow_p.h new file mode 100644 index 0000000000000000000000000000000000000000..69fcee1f50875e2100c2c8d9df546e5a93ba9edf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintdevicewindow_p.h @@ -0,0 +1,97 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAINTDEVICEWINDOW_P_H +#define QPAINTDEVICEWINDOW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QPaintDeviceWindowPrivate : public QWindowPrivate +{ + Q_DECLARE_PUBLIC(QPaintDeviceWindow) + +public: + QPaintDeviceWindowPrivate(); + ~QPaintDeviceWindowPrivate() override; + + virtual void handleResizeEvent() {} + + virtual void beginPaint(const QRegion ®ion) + { + Q_UNUSED(region); + } + + virtual void endPaint() + { + } + + virtual void flush(const QRegion ®ion) + { + Q_UNUSED(region); + } + + bool paint(const QRegion ®ion) + { + Q_Q(QPaintDeviceWindow); + QRegion toPaint = region & dirtyRegion; + if (toPaint.isEmpty()) + return false; + + // Clear the region now. The overridden functions may call update(). + dirtyRegion -= toPaint; + + beginPaint(toPaint); + + QPaintEvent paintEvent(toPaint); + q->paintEvent(&paintEvent); + + endPaint(); + + return true; + } + + void doFlush(const QRegion ®ion) + { + QRegion toFlush = region; + if (paint(toFlush)) + flush(toFlush); + } + + void handleUpdateEvent() + { + if (dirtyRegion.isEmpty()) + return; + doFlush(dirtyRegion); + } + + void markWindowAsDirty() + { + Q_Q(QPaintDeviceWindow); + dirtyRegion = QRect(QPoint(0, 0), q->size()); + } + +private: + QRegion dirtyRegion; +}; + + +QT_END_NAMESPACE + +#endif //QPAINTDEVICEWINDOW_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_blitter_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_blitter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0cd195d18a96f4f45ad186504cdcf79534b51815 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_blitter_p.h @@ -0,0 +1,81 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAINTENGINE_BLITTER_P_H +#define QPAINTENGINE_BLITTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "private/qpaintengine_raster_p.h" + +#ifndef QT_NO_BLITTABLE +QT_BEGIN_NAMESPACE + +class QBlitterPaintEnginePrivate; +class QBlittablePlatformPixmap; +class QBlittable; + +class Q_GUI_EXPORT QBlitterPaintEngine : public QRasterPaintEngine +{ + Q_DECLARE_PRIVATE(QBlitterPaintEngine) +public: + QBlitterPaintEngine(QBlittablePlatformPixmap *p); + + virtual QPaintEngine::Type type() const override + { return Blitter; } + + virtual bool begin(QPaintDevice *pdev) override; + virtual bool end() override; + + // Call down into QBlittable + void fill(const QVectorPath &path, const QBrush &brush) override; + void fillRect(const QRectF &rect, const QBrush &brush) override; + void fillRect(const QRectF &rect, const QColor &color) override; + void drawRects(const QRect *rects, int rectCount) override; + void drawRects(const QRectF *rects, int rectCount) override; + void drawPixmap(const QPointF &p, const QPixmap &pm) override; + void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; + + // State tracking + void setState(QPainterState *s) override; + virtual void clipEnabledChanged() override; + virtual void penChanged() override; + virtual void brushChanged() override; + virtual void opacityChanged() override; + virtual void compositionModeChanged() override; + virtual void renderHintsChanged() override; + virtual void transformChanged() override; + + // Override to lock the QBlittable before using raster + void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; + void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override; + void fillPath(const QPainterPath &path, QSpanData *fillData) override; + void fillPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; + void drawEllipse(const QRectF &rect) override; + void drawImage(const QPointF &p, const QImage &img) override; + void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, + Qt::ImageConversionFlags flags = Qt::AutoColor) override; + void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr) override; + void drawTextItem(const QPointF &p, const QTextItem &textItem) override; + void drawPoints(const QPointF *points, int pointCount) override; + void drawPoints(const QPoint *points, int pointCount) override; + void stroke(const QVectorPath &path, const QPen &pen) override; + void drawStaticTextItem(QStaticTextItem *) override; + bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, + QFontEngine *fontEngine) override; +}; + +QT_END_NAMESPACE +#endif //QT_NO_BLITTABLE +#endif // QPAINTENGINE_BLITTER_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5052654599eaa342006d4493af4107b6d182ddf4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_p.h @@ -0,0 +1,111 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAINTENGINE_P_H +#define QPAINTENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtGui/qpainter.h" +#include "QtGui/qpaintengine.h" +#include "QtGui/qregion.h" +#include "private/qobject_p.h" + +QT_BEGIN_NAMESPACE + +class QPaintDevice; + +class Q_GUI_EXPORT QPaintEnginePrivate +{ + Q_DECLARE_PUBLIC(QPaintEngine) +public: + QPaintEnginePrivate() : pdev(nullptr), q_ptr(nullptr), currentClipDevice(nullptr), hasSystemTransform(0), + hasSystemViewport(0) {} + virtual ~QPaintEnginePrivate(); + + QPaintDevice *pdev; + QPaintEngine *q_ptr; + QRegion baseSystemClip; + QRegion systemClip; + QRect systemRect; + QRegion systemViewport; + QTransform systemTransform; + QPaintDevice *currentClipDevice; + uint hasSystemTransform : 1; + uint hasSystemViewport : 1; + + inline void updateSystemClip() + { + systemClip = baseSystemClip; + if (systemClip.isEmpty()) + return; + + if (hasSystemTransform) { + if (systemTransform.type() <= QTransform::TxTranslate) + systemClip.translate(qRound(systemTransform.dx()), qRound(systemTransform.dy())); + else + systemClip = systemTransform.map(systemClip); + } + + // Make sure we're inside the viewport. + if (hasSystemViewport) { + systemClip &= systemViewport; + if (systemClip.isEmpty()) { + // We don't want to paint without system clip, so set it to 1 pixel :) + systemClip = QRect(systemViewport.boundingRect().topLeft(), QSize(1, 1)); + } + } + } + + inline void setSystemTransform(const QTransform &xform) + { + systemTransform = xform; + hasSystemTransform = !xform.isIdentity(); + updateSystemClip(); + if (q_ptr->state) + systemStateChanged(); + } + + inline void setSystemViewport(const QRegion ®ion) + { + systemViewport = region; + hasSystemViewport = !systemViewport.isEmpty(); + updateSystemClip(); + if (q_ptr->state) + systemStateChanged(); + } + + inline void setSystemTransformAndViewport(const QTransform &xform, const QRegion ®ion) + { + systemTransform = xform; + hasSystemTransform = !xform.isIdentity(); + systemViewport = region; + hasSystemViewport = !systemViewport.isEmpty(); + updateSystemClip(); + if (q_ptr->state) + systemStateChanged(); + } + + virtual void systemStateChanged() { } + + void drawBoxTextItem(const QPointF &p, const QTextItemInt &ti); + + static QPaintEnginePrivate *get(QPaintEngine *paintEngine) { return paintEngine->d_func(); } + + virtual QPaintEngine *aggregateEngine() { return nullptr; } + virtual Qt::HANDLE nativeHandle() { return nullptr; } +}; + +QT_END_NAMESPACE + +#endif // QPAINTENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_pic_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_pic_p.h new file mode 100644 index 0000000000000000000000000000000000000000..99a95ffdccd06dfd4f6deedcd9d3b8a8cc1aebb9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_pic_p.h @@ -0,0 +1,79 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAINTENGINE_PIC_P_H +#define QPAINTENGINE_PIC_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +#ifndef QT_NO_PICTURE + +QT_BEGIN_NAMESPACE + +class QPicturePaintEnginePrivate; +class QBuffer; + +class QPicturePaintEngine : public QPaintEngine +{ + Q_DECLARE_PRIVATE(QPicturePaintEngine) +public: + QPicturePaintEngine(); + ~QPicturePaintEngine(); + + bool begin(QPaintDevice *pdev) override; + bool end() override; + + void updateState(const QPaintEngineState &state) override; + + void updatePen(const QPen &pen); + void updateBrush(const QBrush &brush); + void updateBrushOrigin(const QPointF &origin); + void updateFont(const QFont &font); + void updateBackground(Qt::BGMode bgmode, const QBrush &bgBrush); + void updateMatrix(const QTransform &matrix); + void updateClipRegion(const QRegion ®ion, Qt::ClipOperation op); + void updateClipPath(const QPainterPath &path, Qt::ClipOperation op); + void updateRenderHints(QPainter::RenderHints hints); + void updateCompositionMode(QPainter::CompositionMode cmode); + void updateClipEnabled(bool enabled); + void updateOpacity(qreal opacity); + + void drawEllipse(const QRectF &rect) override; + void drawPath(const QPainterPath &path) override; + void drawPolygon(const QPointF *points, int numPoints, PolygonDrawMode mode) override; + using QPaintEngine::drawPolygon; + + void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; + void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override; + void drawImage(const QRectF &r, const QImage &image, const QRectF &sr, + Qt::ImageConversionFlags flags = Qt::AutoColor) override; + void drawTextItem(const QPointF &p, const QTextItem &ti) override; + + Type type() const override { return Picture; } + +protected: + QPicturePaintEngine(QPaintEnginePrivate &dptr); + +private: + Q_DISABLE_COPY_MOVE(QPicturePaintEngine) + + void writeCmdLength(int pos, const QRectF &r, bool corr); +}; + +QT_END_NAMESPACE + +#endif // QT_NO_PICTURE + +#endif // QPAINTENGINE_PIC_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_raster_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_raster_p.h new file mode 100644 index 0000000000000000000000000000000000000000..12a65a04a3015f10421d7a9b01eeabc229f314a3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengine_raster_p.h @@ -0,0 +1,449 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAINTENGINE_RASTER_P_H +#define QPAINTENGINE_RASTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "private/qpaintengineex_p.h" +#include "QtGui/qpainterpath.h" +#include "private/qdatabuffer_p.h" +#include "private/qdrawhelper_p.h" +#include "private/qpaintengine_p.h" +#include "private/qrasterizer_p.h" +#include "private/qstroker_p.h" +#include "private/qpainter_p.h" +#include "private/qtextureglyphcache_p.h" +#include "private/qoutlinemapper_p.h" + +#include + +QT_BEGIN_NAMESPACE + +class QOutlineMapper; +class QRasterPaintEnginePrivate; +class QRasterBuffer; +class QClipData; + +class QRasterPaintEngineState : public QPainterState +{ +public: + QRasterPaintEngineState(QRasterPaintEngineState &other); + QRasterPaintEngineState(); + ~QRasterPaintEngineState(); + + + QPen lastPen; + QSpanData penData; + QStrokerOps *stroker; + uint strokeFlags; + + QBrush lastBrush; + QSpanData brushData; + uint fillFlags; + + uint pixmapFlags; + int intOpacity; + + qreal txscale; + + QClipData *clip; +// QRect clipRect; +// QRegion clipRegion; + +// QPainter::RenderHints hints; +// QPainter::CompositionMode compositionMode; + + uint dirty; + + struct Flags { + uint has_clip_ownership : 1; // should delete the clip member.. + uint fast_pen : 1; // cosmetic 1-width pens, using midpoint drawlines + uint non_complex_pen : 1; // can use rasterizer, rather than stroker + uint antialiased : 1; + uint bilinear : 1; + uint fast_text : 1; + uint tx_noshear : 1; + uint fast_images : 1; + uint cosmetic_brush : 1; + }; + + union { + Flags flags; + uint flag_bits; + }; +}; + + + + +/******************************************************************************* + * QRasterPaintEngine + */ +class Q_GUI_EXPORT QRasterPaintEngine : public QPaintEngineEx +{ + Q_DECLARE_PRIVATE(QRasterPaintEngine) +public: + + QRasterPaintEngine(QPaintDevice *device); + ~QRasterPaintEngine(); + bool begin(QPaintDevice *device) override; + bool end() override; + + void penChanged() override; + void brushChanged() override; + void brushOriginChanged() override; + void opacityChanged() override; + void compositionModeChanged() override; + void renderHintsChanged() override; + void transformChanged() override; + void clipEnabledChanged() override; + + void setState(QPainterState *s) override; + QPainterState *createState(QPainterState *orig) const override; + inline QRasterPaintEngineState *state() { + return static_cast(QPaintEngineEx::state()); + } + inline const QRasterPaintEngineState *state() const { + return static_cast(QPaintEngineEx::state()); + } + + void updateBrush(const QBrush &brush); + void updatePen(const QPen &pen); + + void updateMatrix(const QTransform &matrix); + + virtual void fillPath(const QPainterPath &path, QSpanData *fillData); + virtual void fillPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode); + + void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; + void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override; + + void drawEllipse(const QRectF &rect) override; + + void fillRect(const QRectF &rect, const QBrush &brush) override; + void fillRect(const QRectF &rect, const QColor &color) override; + + void drawRects(const QRect *rects, int rectCount) override; + void drawRects(const QRectF *rects, int rectCount) override; + + void drawPixmap(const QPointF &p, const QPixmap &pm) override; + void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; + void drawImage(const QPointF &p, const QImage &img) override; + void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, + Qt::ImageConversionFlags flags = Qt::AutoColor) override; + void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr) override; + void drawTextItem(const QPointF &p, const QTextItem &textItem) override; + + void drawLines(const QLine *line, int lineCount) override; + void drawLines(const QLineF *line, int lineCount) override; + + void drawPoints(const QPointF *points, int pointCount) override; + void drawPoints(const QPoint *points, int pointCount) override; + + void stroke(const QVectorPath &path, const QPen &pen) override; + void fill(const QVectorPath &path, const QBrush &brush) override; + + void clip(const QVectorPath &path, Qt::ClipOperation op) override; + void clip(const QRect &rect, Qt::ClipOperation op) override; + void clip(const QRegion ®ion, Qt::ClipOperation op) override; + inline const QClipData *clipData() const; + + void drawStaticTextItem(QStaticTextItem *textItem) override; + virtual bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, + QFontEngine *fontEngine); + + enum ClipType { + RectClip, + ComplexClip + }; + ClipType clipType() const; + QRectF clipBoundingRect() const; + +#ifdef Q_OS_WIN + void setDC(HDC hdc); + HDC getDC() const; + void releaseDC(HDC hdc) const; + static bool clearTypeFontsEnabled(); +#endif + + QRasterBuffer *rasterBuffer(); + void alphaPenBlt(const void* src, int bpl, int depth, int rx,int ry,int w,int h, bool useGammaCorrection); + + Type type() const override { return Raster; } + + QPoint coordinateOffset() const override; + + bool requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const override; + bool shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const override; + +protected: + QRasterPaintEngine(QRasterPaintEnginePrivate &d, QPaintDevice *); +private: + friend struct QSpanData; + friend class QBlitterPaintEngine; + friend class QBlitterPaintEnginePrivate; + void init(); + + void fillRect(const QRectF &rect, QSpanData *data); + void drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fill); + + bool setClipRectInDeviceCoords(const QRect &r, Qt::ClipOperation op); + + QRect toNormalizedFillRect(const QRectF &rect); + + inline void ensureBrush(const QBrush &brush) { + if (!qbrush_fast_equals(state()->lastBrush, brush) || state()->fillFlags) + updateBrush(brush); + } + inline void ensureBrush() { ensureBrush(state()->brush); } + + inline void ensurePen(const QPen &pen) { + if (!qpen_fast_equals(state()->lastPen, pen) || (pen.style() != Qt::NoPen && state()->strokeFlags)) + updatePen(pen); + } + inline void ensurePen() { ensurePen(state()->pen); } + + void updateOutlineMapper(); + inline void ensureOutlineMapper(); + + void updateRasterState(); + inline void ensureRasterState() { + if (state()->dirty) + updateRasterState(); + } +}; + + +/******************************************************************************* + * QRasterPaintEnginePrivate + */ +class QRasterPaintEnginePrivate : public QPaintEngineExPrivate +{ + Q_DECLARE_PUBLIC(QRasterPaintEngine) +public: + QRasterPaintEnginePrivate(); + + void rasterizeLine_dashed(QLineF line, qreal width, + int *dashIndex, qreal *dashOffset, bool *inDash); + void rasterize(QT_FT_Outline *outline, ProcessSpans callback, QSpanData *spanData, QRasterBuffer *rasterBuffer); + void rasterize(QT_FT_Outline *outline, ProcessSpans callback, void *userData, QRasterBuffer *rasterBuffer); + void updateMatrixData(QSpanData *spanData, const QBrush &brush, const QTransform &brushMatrix); + void updateClipping(); + + void systemStateChanged() override; + + void drawImage(const QPointF &pt, const QImage &img, SrcOverBlendFunc func, + const QRect &clip, int alpha, const QRect &sr = QRect()); + void blitImage(const QPointF &pt, const QImage &img, + const QRect &clip, const QRect &sr = QRect()); + + QTransform brushMatrix() const { + Q_Q(const QRasterPaintEngine); + const QRasterPaintEngineState *s = q->state(); + QTransform m(s->matrix); + m.translate(s->brushOrigin.x(), s->brushOrigin.y()); + return m; + } + + bool isUnclipped_normalized(const QRect &rect) const; + bool isUnclipped(const QRect &rect, int penWidth) const; + bool isUnclipped(const QRectF &rect, int penWidth) const; + ProcessSpans getPenFunc(const QRectF &rect, const QSpanData *data) const; + ProcessSpans getBrushFunc(const QRect &rect, const QSpanData *data) const; + ProcessSpans getBrushFunc(const QRectF &rect, const QSpanData *data) const; + + inline const QClipData *clip() const; + + void initializeRasterizer(QSpanData *data); + + void recalculateFastImages(); + bool canUseFastImageBlending(QPainter::CompositionMode mode, const QImage &image) const; + bool canUseImageBlitting(QPainter::CompositionMode mode, const QImage &image, const QPointF &pt, const QRectF &sr) const; + + QPaintDevice *device; + QScopedPointer outlineMapper; + QScopedPointer rasterBuffer; + +#if defined (Q_OS_WIN) + HDC hdc; +#endif + + QRect deviceRect; + QRect deviceRectUnclipped; + + QStroker basicStroker; + QScopedPointer dashStroker; + + QScopedPointer grayRaster; + + QDataBuffer cachedLines; + QSpanData image_filler; + QSpanData image_filler_xform; + QSpanData solid_color_filler; + + + QFontEngine::GlyphFormat glyphCacheFormat; + + QScopedPointer baseClip; + + int deviceDepth; + + uint mono_surface : 1; + uint outlinemapper_xform_dirty : 1; + + QScopedPointer rasterizer; +}; + + +class QClipData { +public: + QClipData(int height); + ~QClipData(); + + int clipSpanHeight; + struct ClipLine { + int count; + QT_FT_Span *spans; + } *m_clipLines; + + void initialize(); + + inline ClipLine *clipLines() { + if (!m_clipLines) + initialize(); + return m_clipLines; + } + + inline QT_FT_Span *spans() { + if (!m_spans) + initialize(); + return m_spans; + } + + int allocated; + int count; + QT_FT_Span *m_spans; + int xmin, xmax, ymin, ymax; + + QRect clipRect; + QRegion clipRegion; + + uint enabled : 1; + uint hasRectClip : 1; + uint hasRegionClip : 1; + + void appendSpan(int x, int length, int y, int coverage); + void appendSpans(const QT_FT_Span *s, int num); + + // ### Should optimize and actually kill the QSpans if the rect is + // ### a subset of The current region. Thus the "fast" clipspan + // ### callback can be used + void setClipRect(const QRect &rect); + void setClipRegion(const QRegion ®ion); + void fixup(); +}; + +inline void QClipData::appendSpan(int x, int length, int y, int coverage) +{ + Q_ASSERT(m_spans); // initialize() has to be called prior to adding spans.. + + if (count == allocated) { + allocated *= 2; + m_spans = (QT_FT_Span *)realloc(m_spans, allocated*sizeof(QT_FT_Span)); + } + m_spans[count].x = x; + m_spans[count].len = length; + m_spans[count].y = y; + m_spans[count].coverage = coverage; + ++count; +} + +inline void QClipData::appendSpans(const QT_FT_Span *s, int num) +{ + Q_ASSERT(m_spans); + + if (count + num > allocated) { + do { + allocated *= 2; + } while (count + num > allocated); + m_spans = (QT_FT_Span *)realloc(m_spans, allocated*sizeof(QT_FT_Span)); + } + memcpy(m_spans+count, s, num*sizeof(QT_FT_Span)); + count += num; +} + +/******************************************************************************* + * QRasterBuffer + */ +class QRasterBuffer +{ +public: + QRasterBuffer() : m_width(0), m_height(0), m_buffer(nullptr) { init(); } + + ~QRasterBuffer(); + + void init(); + + QImage::Format prepare(QImage *image); + + uchar *scanLine(int y) { Q_ASSERT(y>=0); Q_ASSERT(y + int stride() { return static_cast(bytes_per_line / sizeof(T)); } + + uchar *buffer() const { return m_buffer; } + + bool monoDestinationWithClut; + QRgb destColor0; + QRgb destColor1; + + QPainter::CompositionMode compositionMode; + QImage::Format format; + QColorSpace colorSpace; + QImage colorizeBitmap(const QImage &image, const QColor &color); + +private: + int m_width; + int m_height; + qsizetype bytes_per_line; + int bytes_per_pixel; + uchar *m_buffer; +}; + +inline void QRasterPaintEngine::ensureOutlineMapper() { + if (d_func()->outlinemapper_xform_dirty) + updateOutlineMapper(); +} + +inline const QClipData *QRasterPaintEnginePrivate::clip() const { + Q_Q(const QRasterPaintEngine); + if (q->state() && q->state()->clip && q->state()->clip->enabled) + return q->state()->clip; + return baseClip.data(); +} + +inline const QClipData *QRasterPaintEngine::clipData() const { + Q_D(const QRasterPaintEngine); + if (state() && state()->clip && state()->clip->enabled) + return state()->clip; + return d->baseClip.data(); +} + +QT_END_NAMESPACE +#endif // QPAINTENGINE_RASTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengineex_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengineex_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f97fa95a06df2da1012de97bc3f7e3f490d9d542 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpaintengineex_p.h @@ -0,0 +1,147 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAINTENGINEEX_P_H +#define QPAINTENGINEEX_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +#include +#include +#include +#include + + +QT_BEGIN_NAMESPACE + + +class QPainterState; +class QPaintEngineExPrivate; +class QStaticTextItem; +struct StrokeHandler; + +#ifndef QT_NO_DEBUG_STREAM +QDebug Q_GUI_EXPORT &operator<<(QDebug &, const QVectorPath &path); +#endif + +class Q_GUI_EXPORT QPaintEngineEx : public QPaintEngine +{ + Q_DECLARE_PRIVATE(QPaintEngineEx) +public: + QPaintEngineEx(); + + virtual QPainterState *createState(QPainterState *orig) const; + + virtual void draw(const QVectorPath &path); + virtual void fill(const QVectorPath &path, const QBrush &brush) = 0; + virtual void stroke(const QVectorPath &path, const QPen &pen); + + virtual void clip(const QVectorPath &path, Qt::ClipOperation op) = 0; + virtual void clip(const QRect &rect, Qt::ClipOperation op); + virtual void clip(const QRegion ®ion, Qt::ClipOperation op); + virtual void clip(const QPainterPath &path, Qt::ClipOperation op); + + virtual void clipEnabledChanged() = 0; + virtual void penChanged() = 0; + virtual void brushChanged() = 0; + virtual void brushOriginChanged() = 0; + virtual void opacityChanged() = 0; + virtual void compositionModeChanged() = 0; + virtual void renderHintsChanged() = 0; + virtual void transformChanged() = 0; + + virtual void fillRect(const QRectF &rect, const QBrush &brush); + virtual void fillRect(const QRectF &rect, const QColor &color); + + virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode); + + virtual void drawRects(const QRect *rects, int rectCount) override; + virtual void drawRects(const QRectF *rects, int rectCount) override; + + virtual void drawLines(const QLine *lines, int lineCount) override; + virtual void drawLines(const QLineF *lines, int lineCount) override; + + virtual void drawEllipse(const QRectF &r) override; + virtual void drawEllipse(const QRect &r) override; + + virtual void drawPath(const QPainterPath &path) override; + + virtual void drawPoints(const QPointF *points, int pointCount) override; + virtual void drawPoints(const QPoint *points, int pointCount) override; + + virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; + virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override; + + virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override = 0; + virtual void drawPixmap(const QPointF &pos, const QPixmap &pm); + + virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, + Qt::ImageConversionFlags flags = Qt::AutoColor) override = 0; + virtual void drawImage(const QPointF &pos, const QImage &image); + + virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override; + + virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, + QFlags hints); + + virtual void updateState(const QPaintEngineState &state) override; + + virtual void drawStaticTextItem(QStaticTextItem *); + + virtual void setState(QPainterState *s); + inline QPainterState *state() { return static_cast(QPaintEngine::state); } + inline const QPainterState *state() const { return static_cast(QPaintEngine::state); } + + virtual void sync() {} + + virtual void beginNativePainting() {} + virtual void endNativePainting() {} + + // These flags are needed in the implementation of paint buffers. + enum Flags + { + DoNotEmulate = 0x01, // If set, QPainter will not wrap this engine in an emulation engine. + IsEmulationEngine = 0x02 // If set, this object is a QEmulationEngine. + }; + virtual uint flags() const {return 0;} + virtual bool requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const; + virtual bool shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const; + +protected: + QPaintEngineEx(QPaintEngineExPrivate &data); +}; + +class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate +{ + Q_DECLARE_PUBLIC(QPaintEngineEx) +public: + QPaintEngineExPrivate(); + ~QPaintEngineExPrivate(); + + void replayClipOperations(); + bool hasClipOperations() const; + + QStroker stroker; + QDashStroker dasher; + StrokeHandler *strokeHandler; + QStrokerOps *activeStroker; + QPen strokerPen; + + QRect exDeviceRect; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpainter_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpainter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6d19fe3fa935d839f0a73e939a8e9d023e3ee844 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpainter_p.h @@ -0,0 +1,254 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAINTER_P_H +#define QPAINTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include "QtGui/qbrush.h" +#include "QtGui/qcolorspace.h" +#include "QtGui/qcolortransform.h" +#include "QtGui/qfont.h" +#include "QtGui/qpen.h" +#include "QtGui/qregion.h" +#include "QtGui/qpainter.h" +#include "QtGui/qpainterpath.h" +#include "QtGui/qpaintengine.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QPaintEngine; +class QEmulationPaintEngine; +class QPaintEngineEx; +struct QFixedPoint; + +struct QTLWExtra; + +struct DataPtrContainer { + void *ptr; +}; + +inline const void *data_ptr(const QTransform &t) { return (const DataPtrContainer *) &t; } +inline bool qtransform_fast_equals(const QTransform &a, const QTransform &b) { return data_ptr(a) == data_ptr(b); } + +// QPen inline functions... +inline QPen::DataPtr &data_ptr(const QPen &p) { return const_cast(p).data_ptr(); } +inline bool qpen_fast_equals(const QPen &a, const QPen &b) { return data_ptr(a) == data_ptr(b); } +inline QBrush qpen_brush(const QPen &p) { return data_ptr(p)->brush; } +inline qreal qpen_widthf(const QPen &p) { return data_ptr(p)->width; } +inline Qt::PenStyle qpen_style(const QPen &p) { return data_ptr(p)->style; } +inline Qt::PenCapStyle qpen_capStyle(const QPen &p) { return data_ptr(p)->capStyle; } +inline Qt::PenJoinStyle qpen_joinStyle(const QPen &p) { return data_ptr(p)->joinStyle; } + +// QBrush inline functions... +inline QBrush::DataPtr &data_ptr(const QBrush &p) { return const_cast(p).data_ptr(); } +inline bool qbrush_fast_equals(const QBrush &a, const QBrush &b) { return data_ptr(a) == data_ptr(b); } +inline Qt::BrushStyle qbrush_style(const QBrush &b) { return data_ptr(b)->style; } +inline const QColor &qbrush_color(const QBrush &b) { return data_ptr(b)->color; } +inline bool qbrush_has_transform(const QBrush &b) { return data_ptr(b)->transform.type() > QTransform::TxNone; } + +class QPainterClipInfo +{ +public: + QPainterClipInfo() { } // for QList, don't use + enum ClipType { RegionClip, PathClip, RectClip, RectFClip }; + + QPainterClipInfo(const QPainterPath &p, Qt::ClipOperation op, const QTransform &m) : + clipType(PathClip), matrix(m), operation(op), path(p) { } + + QPainterClipInfo(const QRegion &r, Qt::ClipOperation op, const QTransform &m) : + clipType(RegionClip), matrix(m), operation(op), region(r) { } + + QPainterClipInfo(const QRect &r, Qt::ClipOperation op, const QTransform &m) : + clipType(RectClip), matrix(m), operation(op), rect(r) { } + + QPainterClipInfo(const QRectF &r, Qt::ClipOperation op, const QTransform &m) : + clipType(RectFClip), matrix(m), operation(op), rectf(r) { } + + ClipType clipType; + QTransform matrix; + Qt::ClipOperation operation; + QPainterPath path; + QRegion region; + QRect rect; + QRectF rectf; + + // ### +// union { +// QRegionData *d; +// QPainterPathPrivate *pathData; + +// struct { +// int x, y, w, h; +// } rectData; +// struct { +// qreal x, y, w, h; +// } rectFData; +// }; + +}; + +Q_DECLARE_TYPEINFO(QPainterClipInfo, Q_RELOCATABLE_TYPE); + +class Q_GUI_EXPORT QPainterState : public QPaintEngineState +{ +public: + QPainterState(); + QPainterState(const QPainterState *s); + virtual ~QPainterState(); + void init(QPainter *p); + + QPointF brushOrigin; + QFont font; + QFont deviceFont; + QPen pen; + QBrush brush; + QBrush bgBrush = Qt::white; // background brush + QRegion clipRegion; + QPainterPath clipPath; + Qt::ClipOperation clipOperation = Qt::NoClip; + QPainter::RenderHints renderHints; + QList clipInfo; // ### Make me smaller and faster to copy around... + QTransform worldMatrix; // World transformation matrix, not window and viewport + QTransform matrix; // Complete transformation matrix, + QTransform redirectionMatrix; + int wx = 0, wy = 0, ww = 0, wh = 0; // window rectangle + int vx = 0, vy = 0, vw = 0, vh = 0; // viewport rectangle + qreal opacity = 1; + + uint WxF:1; // World transformation + uint VxF:1; // View transformation + uint clipEnabled:1; + + Qt::BGMode bgMode = Qt::TransparentMode; + QPainter *painter = nullptr; + Qt::LayoutDirection layoutDirection; + QPainter::CompositionMode composition_mode = QPainter::CompositionMode_SourceOver; + uint emulationSpecifier = 0; + uint changeFlags = 0; +}; + +struct QPainterDummyState +{ + QFont font; + QPen pen; + QBrush brush; + QTransform transform; +}; + +class QRawFont; +class QPainterPrivate +{ + Q_DECLARE_PUBLIC(QPainter) +public: + explicit QPainterPrivate(QPainter *painter); + ~QPainterPrivate(); + + QPainter *q_ptr; + // Allocate space for 4 d-pointers (enough for up to 4 sub-sequent + // redirections within the same paintEvent(), which should be enough + // in 99% of all cases). E.g: A renders B which renders C which renders D. + static constexpr qsizetype NDPtrs = 4; + QVarLengthArray d_ptrs; + + std::unique_ptr state; + template + struct SmallStack : std::stack> { + void clear() { this->c.clear(); } + }; + SmallStack> savedStates; + + mutable std::unique_ptr dummyState; + + QTransform invMatrix; + uint txinv:1; + uint inDestructor : 1; + uint refcount = 1; + + enum DrawOperation { StrokeDraw = 0x1, + FillDraw = 0x2, + StrokeAndFillDraw = 0x3 + }; + + QPainterDummyState *fakeState() const { + if (!dummyState) + dummyState = std::make_unique(); + return dummyState.get(); + } + + void updateEmulationSpecifier(QPainterState *s); + void updateStateImpl(QPainterState *state); + void updateState(QPainterState *state); + void updateState(std::unique_ptr &state) { updateState(state.get()); } + + void draw_helper(const QPainterPath &path, DrawOperation operation = StrokeAndFillDraw); + void drawStretchedGradient(const QPainterPath &path, DrawOperation operation); + void drawOpaqueBackground(const QPainterPath &path, DrawOperation operation); + void drawTextItem(const QPointF &p, const QTextItem &_ti, QTextEngine *textEngine); + +#if !defined(QT_NO_RAWFONT) + void drawGlyphs(const QPointF &decorationPosition, const quint32 *glyphArray, QFixedPoint *positionArray, int glyphCount, + QFontEngine *fontEngine, bool overline = false, bool underline = false, + bool strikeOut = false); +#endif + + void updateMatrix(); + void updateInvMatrix(); + + void checkEmulation(); + + static QPainterPrivate *get(QPainter *painter) + { + return painter->d_ptr.get(); + } + + QTransform viewTransform() const; + qreal effectiveDevicePixelRatio() const; + QTransform hidpiScaleTransform() const; + static bool attachPainterPrivate(QPainter *q, QPaintDevice *pdev); + void detachPainterPrivate(QPainter *q); + void initFrom(const QPaintDevice *device); + + QPaintDevice *device = nullptr; + QPaintDevice *original_device = nullptr; + QPaintDevice *helper_device = nullptr; + + struct QPaintEngineDestructor { + void operator()(QPaintEngine *pe) const noexcept + { + if (pe && pe->autoDestruct()) + delete pe; + } + }; + std::unique_ptr engine; + + std::unique_ptr emulationEngine; + QPaintEngineEx *extended = nullptr; + QBrush colorBrush; // for fill with solid color +}; + +Q_GUI_EXPORT void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation); + +QString qt_generate_brush_key(const QBrush &brush); + + +QT_END_NAMESPACE + +#endif // QPAINTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpainterpath_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpainterpath_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f061cb2c6a131aa09d09c8d7e4aef7c40e58573a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpainterpath_p.h @@ -0,0 +1,289 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAINTERPATH_P_H +#define QPAINTERPATH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtGui/qpainterpath.h" +#include "QtGui/qregion.h" +#include "QtCore/qlist.h" +#include "QtCore/qshareddata.h" +#include "QtCore/qvarlengtharray.h" + +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QPolygonF; +class QVectorPathConverter; + +class QVectorPathConverter +{ +public: + QVectorPathConverter(const QList &path, uint fillRule, bool convex) + : pathData(path, fillRule, convex), + path(pathData.points.data(), path.size(), pathData.elements.data(), pathData.flags) + { + } + + const QVectorPath &vectorPath() { + return path; + } + + struct QVectorPathData { + QVectorPathData(const QList &path, uint fillRule, bool convex) + : elements(path.size()), points(path.size() * 2), flags(0) + { + int ptsPos = 0; + bool isLines = true; + for (int i=0; i elements; + QVarLengthArray points; + uint flags; + }; + + QVectorPathData pathData; + QVectorPath path; + +private: + Q_DISABLE_COPY_MOVE(QVectorPathConverter) +}; + +class QPainterPathPrivate : public QSharedData +{ +public: + friend class QPainterPath; + friend class QPainterPathStroker; + friend class QPainterPathStrokerPrivate; + friend class QTransform; + friend class QVectorPath; + friend struct QPainterPathPrivateDeleter; +#ifndef QT_NO_DATASTREAM + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &); + friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &); +#endif + + QPainterPathPrivate() noexcept + : QSharedData(), + cStart(0), + fillRule(Qt::OddEvenFill), + require_moveTo(false), + dirtyBounds(false), + dirtyControlBounds(false), + convex(false), + pathConverter(nullptr) + { + } + + QPainterPathPrivate(QPointF startPoint) + : QSharedData(), + elements{ { startPoint.x(), startPoint.y(), QPainterPath::MoveToElement } }, + cStart(0), + fillRule(Qt::OddEvenFill), + bounds(startPoint, QSizeF(0, 0)), + controlBounds(startPoint, QSizeF(0, 0)), + require_moveTo(false), + dirtyBounds(false), + dirtyControlBounds(false), + convex(false), + pathConverter(nullptr) + { + } + + QPainterPathPrivate(const QPainterPathPrivate &other) noexcept + : QSharedData(other), + elements(other.elements), + cStart(other.cStart), + fillRule(other.fillRule), + bounds(other.bounds), + controlBounds(other.controlBounds), + require_moveTo(false), + dirtyBounds(other.dirtyBounds), + dirtyControlBounds(other.dirtyControlBounds), + convex(other.convex), + pathConverter(nullptr) + { + } + + QPainterPathPrivate &operator=(const QPainterPathPrivate &) = delete; + ~QPainterPathPrivate() = default; + + inline bool isClosed() const; + inline void close(); + inline void maybeMoveTo(); + inline void clear(); + + const QVectorPath &vectorPath() { + if (!pathConverter) + pathConverter.reset(new QVectorPathConverter(elements, fillRule, convex)); + return pathConverter->path; + } + +private: + QList elements; + + int cStart; + Qt::FillRule fillRule; + + QRectF bounds; + QRectF controlBounds; + + uint require_moveTo : 1; + uint dirtyBounds : 1; + uint dirtyControlBounds : 1; + uint convex : 1; + + std::unique_ptr pathConverter; +}; + +class QPainterPathStrokerPrivate +{ +public: + QPainterPathStrokerPrivate(); + + QStroker stroker; + QList dashPattern; + qreal dashOffset; +}; + +inline const QPainterPath QVectorPath::convertToPainterPath() const +{ + QPainterPath path; + path.ensureData(); + QPainterPathPrivate *data = path.d_func(); + data->elements.reserve(m_count); + int index = 0; + data->elements[0].x = m_points[index++]; + data->elements[0].y = m_points[index++]; + + if (m_elements) { + data->elements[0].type = m_elements[0]; + for (int i=1; ielements << element; + } + } else { + data->elements[0].type = QPainterPath::MoveToElement; + for (int i=1; ielements << element; + } + } + + if (m_hints & OddEvenFill) + data->fillRule = Qt::OddEvenFill; + else + data->fillRule = Qt::WindingFill; + return path; +} + +void Q_GUI_EXPORT qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length, + QPointF* startPoint, QPointF *endPoint); + +inline bool QPainterPathPrivate::isClosed() const +{ + const QPainterPath::Element &first = elements.at(cStart); + const QPainterPath::Element &last = elements.last(); + return first.x == last.x && first.y == last.y; +} + +inline void QPainterPathPrivate::close() +{ + Q_ASSERT(ref.loadRelaxed() == 1); + require_moveTo = true; + const QPainterPath::Element &first = elements.at(cStart); + QPainterPath::Element &last = elements.last(); + if (first.x != last.x || first.y != last.y) { + if (qFuzzyCompare(first.x, last.x) && qFuzzyCompare(first.y, last.y)) { + last.x = first.x; + last.y = first.y; + } else { + QPainterPath::Element e = { first.x, first.y, QPainterPath::LineToElement }; + elements << e; + } + } +} + +inline void QPainterPathPrivate::maybeMoveTo() +{ + if (require_moveTo) { + QPainterPath::Element e = elements.last(); + e.type = QPainterPath::MoveToElement; + elements.append(e); + require_moveTo = false; + } +} + +inline void QPainterPathPrivate::clear() +{ + Q_ASSERT(ref.loadRelaxed() == 1); + + elements.clear(); + + cStart = 0; + bounds = {}; + controlBounds = {}; + + require_moveTo = false; + dirtyBounds = false; + dirtyControlBounds = false; + convex = false; + + pathConverter.reset(); +} +#define KAPPA qreal(0.5522847498) + + +QT_END_NAMESPACE + +#endif // QPAINTERPATH_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpalette_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpalette_p.h new file mode 100644 index 0000000000000000000000000000000000000000..507af0bf3322f70f5f175d07aa3ffa09a25a64c4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpalette_p.h @@ -0,0 +1,77 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPALETTE_P_H +#define QPALETTE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qpalette.h" + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QPalettePrivate +{ +public: + class Data : public QSharedData { + public: + // Every instance of Data has to have a unique serial number, even + // if it gets created by copying another - we wouldn't create a copy + // in the first place if the serial number should be the same! + Data(const Data &other) + : QSharedData(other) + { + for (int grp = 0; grp < int(QPalette::NColorGroups); grp++) { + for (int role = 0; role < int(QPalette::NColorRoles); role++) + br[grp][role] = other.br[grp][role]; + } + } + Data() = default; + + QBrush br[QPalette::NColorGroups][QPalette::NColorRoles]; + const int ser_no = qt_palette_count++; + }; + + QPalettePrivate(const QExplicitlySharedDataPointer &data) + : ref(1), data(data) + { } + QPalettePrivate() + : QPalettePrivate(QExplicitlySharedDataPointer(new Data)) + { } + + static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup) + { + // Exclude NoRole; that bit is used for Accent + return (qToUnderlying(QPalette::NColorRoles) - 1) * qToUnderlying(colorGroup); + } + + static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup, + QPalette::ColorRole colorRole) + { + // Map Accent into NoRole for resolving purposes + if (colorRole == QPalette::Accent) + colorRole = QPalette::NoRole; + + return colorRole + colorRoleOffset(colorGroup); + } + + QAtomicInt ref; + QPalette::ResolveMask resolveMask = {0}; + static inline int qt_palette_count = 0; + static inline int qt_palette_private_count = 0; + int detach_no = ++qt_palette_private_count; + QExplicitlySharedDataPointer data; +}; + +QT_END_NAMESPACE + +#endif // QPALETTE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpathclipper_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpathclipper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f45d0cbf59996bb55f87f6eb0cf9e7043e8a6cb4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpathclipper_p.h @@ -0,0 +1,454 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPATHCLIPPER_P_H +#define QPATHCLIPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + + +class QWingedEdge; + +class Q_GUI_EXPORT QPathClipper +{ +public: + enum Operation { + BoolAnd, + BoolOr, + BoolSub, + Simplify + }; +public: + QPathClipper(const QPainterPath &subject, + const QPainterPath &clip); + + QPainterPath clip(Operation op = BoolAnd); + + bool intersect(); + bool contains(); + + static bool pathToRect(const QPainterPath &path, QRectF *rect = nullptr); + static QPainterPath intersect(const QPainterPath &path, const QRectF &rect); + +private: + Q_DISABLE_COPY_MOVE(QPathClipper) + + enum ClipperMode { + ClipMode, // do the full clip + CheckMode // for contains/intersects (only interested in whether the result path is non-empty) + }; + + bool handleCrossingEdges(QWingedEdge &list, qreal y, ClipperMode mode); + bool doClip(QWingedEdge &list, ClipperMode mode); + + QPainterPath subjectPath; + QPainterPath clipPath; + Operation op; + + int aMask; + int bMask; +}; + +struct QPathVertex +{ +public: + QPathVertex(const QPointF &p = QPointF(), int e = -1); + operator QPointF() const; + + int edge; + + qreal x; + qreal y; +}; +Q_DECLARE_TYPEINFO(QPathVertex, Q_PRIMITIVE_TYPE); + +class QPathEdge +{ +public: + enum Traversal { + RightTraversal, + LeftTraversal + }; + + enum Direction { + Forward, + Backward + }; + + enum Type { + Line, + Curve + }; + + explicit QPathEdge(int a = -1, int b = -1); + + mutable int flag; + + int windingA; + int windingB; + + int first; + int second; + + double angle; + double invAngle; + + int next(Traversal traversal, Direction direction) const; + + void setNext(Traversal traversal, Direction direction, int next); + void setNext(Direction direction, int next); + + Direction directionTo(int vertex) const; + int vertex(Direction direction) const; + +private: + int m_next[2][2] = { { -1, -1 }, { -1, -1 } }; +}; +Q_DECLARE_TYPEINFO(QPathEdge, Q_PRIMITIVE_TYPE); + +class QPathSegments +{ +public: + struct Intersection { + qreal t; + int vertex; + int next; + + bool operator<(const Intersection &o) const { + return t < o.t; + } + }; + friend class QTypeInfo; + + struct Segment { + Segment(int pathId, int vertexA, int vertexB) + : path(pathId) + , va(vertexA) + , vb(vertexB) + , intersection(-1) + { + } + + int path; + + // vertices + int va; + int vb; + + // intersection index + int intersection; + + QRectF bounds; + }; + friend class QTypeInfo; + + + QPathSegments(int reserve); + + void setPath(const QPainterPath &path); + void addPath(const QPainterPath &path); + + int intersections() const; + int segments() const; + int points() const; + + const Segment &segmentAt(int index) const; + const QLineF lineAt(int index) const; + const QRectF &elementBounds(int index) const; + int pathId(int index) const; + + const QPointF &pointAt(int vertex) const; + int addPoint(const QPointF &point); + + const Intersection *intersectionAt(int index) const; + void addIntersection(int index, const Intersection &intersection); + + void mergePoints(); + +private: + QDataBuffer m_points; + QDataBuffer m_segments; + QDataBuffer m_intersections; + + int m_pathId; +}; +Q_DECLARE_TYPEINFO(QPathSegments::Intersection, Q_PRIMITIVE_TYPE); +Q_DECLARE_TYPEINFO(QPathSegments::Segment, Q_PRIMITIVE_TYPE); + +class Q_AUTOTEST_EXPORT QWingedEdge +{ +public: + struct TraversalStatus + { + int edge; + QPathEdge::Traversal traversal; + QPathEdge::Direction direction; + + void flipDirection(); + void flipTraversal(); + + void flip(); + }; + + QWingedEdge(); + QWingedEdge(const QPainterPath &subject, const QPainterPath &clip); + + void simplify(); + QPainterPath toPath() const; + + int edgeCount() const; + + QPathEdge *edge(int edge); + const QPathEdge *edge(int edge) const; + + int vertexCount() const; + + int addVertex(const QPointF &p); + + QPathVertex *vertex(int vertex); + const QPathVertex *vertex(int vertex) const; + + TraversalStatus next(const TraversalStatus &status) const; + + int addEdge(const QPointF &a, const QPointF &b); + int addEdge(int vertexA, int vertexB); + + bool isInside(qreal x, qreal y) const; + + static QPathEdge::Traversal flip(QPathEdge::Traversal traversal); + static QPathEdge::Direction flip(QPathEdge::Direction direction); + +private: + void intersectAndAdd(); + + void printNode(int i, FILE *handle); + + void removeEdge(int ei); + + int insert(const QPathVertex &vertex); + TraversalStatus findInsertStatus(int vertex, int edge) const; + + qreal delta(int vertex, int a, int b) const; + + QDataBuffer m_edges; + QDataBuffer m_vertices; + + QList m_splitPoints; + + QPathSegments m_segments; +}; + +inline QPathEdge::QPathEdge(int a, int b) + : flag(0) + , windingA(0) + , windingB(0) + , first(a) + , second(b) + , angle(0) + , invAngle(0) +{ +} + +inline int QPathEdge::next(Traversal traversal, Direction direction) const +{ + return m_next[int(traversal)][int(direction)]; +} + +inline void QPathEdge::setNext(Traversal traversal, Direction direction, int next) +{ + m_next[int(traversal)][int(direction)] = next; +} + +inline void QPathEdge::setNext(Direction direction, int next) +{ + m_next[0][int(direction)] = next; + m_next[1][int(direction)] = next; +} + +inline QPathEdge::Direction QPathEdge::directionTo(int vertex) const +{ + return first == vertex ? Backward : Forward; +} + +inline int QPathEdge::vertex(Direction direction) const +{ + return direction == Backward ? first : second; +} + +inline QPathVertex::QPathVertex(const QPointF &p, int e) + : edge(e) + , x(p.x()) + , y(p.y()) +{ +} + +inline QPathVertex::operator QPointF() const +{ + return QPointF(x, y); +} + +inline QPathSegments::QPathSegments(int reserve) : + m_points(reserve), + m_segments(reserve), + m_intersections(reserve), + m_pathId(0) +{ +} + +inline int QPathSegments::segments() const +{ + return m_segments.size(); +} + +inline int QPathSegments::points() const +{ + return m_points.size(); +} + +inline const QPointF &QPathSegments::pointAt(int i) const +{ + return m_points.at(i); +} + +inline int QPathSegments::addPoint(const QPointF &point) +{ + m_points << point; + return m_points.size() - 1; +} + +inline const QPathSegments::Segment &QPathSegments::segmentAt(int index) const +{ + return m_segments.at(index); +} + +inline const QLineF QPathSegments::lineAt(int index) const +{ + const Segment &segment = m_segments.at(index); + return QLineF(m_points.at(segment.va), m_points.at(segment.vb)); +} + +inline const QRectF &QPathSegments::elementBounds(int index) const +{ + return m_segments.at(index).bounds; +} + +inline int QPathSegments::pathId(int index) const +{ + return m_segments.at(index).path; +} + +inline const QPathSegments::Intersection *QPathSegments::intersectionAt(int index) const +{ + const int intersection = m_segments.at(index).intersection; + if (intersection < 0) + return nullptr; + else + return &m_intersections.at(intersection); +} + +inline int QPathSegments::intersections() const +{ + return m_intersections.size(); +} + +inline void QPathSegments::addIntersection(int index, const Intersection &intersection) +{ + m_intersections << intersection; + + Segment &segment = m_segments.at(index); + if (segment.intersection < 0) { + segment.intersection = m_intersections.size() - 1; + } else { + Intersection *isect = &m_intersections.at(segment.intersection); + + while (isect->next != 0) + isect += isect->next; + + isect->next = (m_intersections.size() - 1) - (isect - m_intersections.data()); + } +} + +inline int QWingedEdge::edgeCount() const +{ + return m_edges.size(); +} + +inline QPathEdge *QWingedEdge::edge(int edge) +{ + return edge < 0 ? nullptr : &m_edges.at(edge); +} + +inline const QPathEdge *QWingedEdge::edge(int edge) const +{ + return edge < 0 ? nullptr : &m_edges.at(edge); +} + +inline int QWingedEdge::vertexCount() const +{ + return m_vertices.size(); +} + +inline int QWingedEdge::addVertex(const QPointF &p) +{ + m_vertices << p; + return m_vertices.size() - 1; +} + +inline QPathVertex *QWingedEdge::vertex(int vertex) +{ + return vertex < 0 ? nullptr : &m_vertices.at(vertex); +} + +inline const QPathVertex *QWingedEdge::vertex(int vertex) const +{ + return vertex < 0 ? nullptr : &m_vertices.at(vertex); +} + +inline QPathEdge::Traversal QWingedEdge::flip(QPathEdge::Traversal traversal) +{ + return traversal == QPathEdge::RightTraversal ? QPathEdge::LeftTraversal : QPathEdge::RightTraversal; +} + +inline void QWingedEdge::TraversalStatus::flipTraversal() +{ + traversal = QWingedEdge::flip(traversal); +} + +inline QPathEdge::Direction QWingedEdge::flip(QPathEdge::Direction direction) +{ + return direction == QPathEdge::Forward ? QPathEdge::Backward : QPathEdge::Forward; +} + +inline void QWingedEdge::TraversalStatus::flipDirection() +{ + direction = QWingedEdge::flip(direction); +} + +inline void QWingedEdge::TraversalStatus::flip() +{ + flipDirection(); + flipTraversal(); +} + +QT_END_NAMESPACE + +#endif // QPATHCLIPPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpathsimplifier_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpathsimplifier_p.h new file mode 100644 index 0000000000000000000000000000000000000000..af235f10b36b014259ab1e81f1aac16767f20b3d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpathsimplifier_p.h @@ -0,0 +1,31 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPATHSIMPLIFIER_P_H +#define QPATHSIMPLIFIER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +// The returned vertices are in 8:8 fixed point format. The path is assumed to be in the range (-128, 128)x(-128, 128). +void qSimplifyPath(const QVectorPath &path, QDataBuffer &vertices, QDataBuffer &indices, const QTransform &matrix = QTransform()); +void qSimplifyPath(const QPainterPath &path, QDataBuffer &vertices, QDataBuffer &indices, const QTransform &matrix = QTransform()); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpdf_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpdf_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a6aa67bf456676058ded3075051a60270c90d37a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpdf_p.h @@ -0,0 +1,371 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPDF_P_H +#define QPDF_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#ifndef QT_NO_PDF + +#include "QtCore/qlist.h" +#include "QtCore/qstring.h" +#include "QtCore/quuid.h" +#include "private/qfontengine_p.h" +#include "private/qfontsubset_p.h" +#include "private/qpaintengine_p.h" +#include "private/qstroker_p.h" +#include "qpagelayout.h" +#include "qpdfoutputintent.h" + +QT_BEGIN_NAMESPACE + +const char *qt_real_to_string(qreal val, char *buf); +const char *qt_int_to_string(int val, char *buf); + +namespace QPdf { + + class ByteStream + { + public: + // fileBacking means that ByteStream will buffer the contents on disk + // if the size exceeds a certain threshold. In this case, if a byte + // array was passed in, its contents may no longer correspond to the + // ByteStream contents. + explicit ByteStream(bool fileBacking = false); + explicit ByteStream(QByteArray *ba, bool fileBacking = false); + ~ByteStream(); + ByteStream &operator <<(char chr); + ByteStream &operator <<(const char *str); + ByteStream &operator <<(const QByteArray &str); + ByteStream &operator <<(const ByteStream &src); + ByteStream &operator <<(qreal val); + ByteStream &operator <<(int val); + ByteStream &operator <<(uint val) { return (*this << int(val)); } + ByteStream &operator <<(qint64 val) { return (*this << int(val)); } + ByteStream &operator <<(const QPointF &p); + // Note that the stream may be invalidated by calls that insert data. + QIODevice *stream(); + void clear(); + + static inline int maxMemorySize() { return 100000000; } + static inline int chunkSize() { return 10000000; } + + private: + void prepareBuffer(); + + private: + QIODevice *dev; + QByteArray ba; + bool fileBackingEnabled; + bool fileBackingActive; + bool handleDirty; + }; + + enum PathFlags { + ClipPath, + FillPath, + StrokePath, + FillAndStrokePath + }; + QByteArray generatePath(const QPainterPath &path, const QTransform &matrix, PathFlags flags); + QByteArray generateMatrix(const QTransform &matrix); + QByteArray generateDashes(const QPen &pen); + QByteArray patternForBrush(const QBrush &b); + + struct Stroker { + Stroker(); + void setPen(const QPen &pen, QPainter::RenderHints hints); + void strokePath(const QPainterPath &path); + ByteStream *stream; + bool first; + QTransform matrix; + bool cosmeticPen; + private: + QStroker basicStroker; + QDashStroker dashStroker; + QStrokerOps *stroker; + }; + + QByteArray ascii85Encode(const QByteArray &input); + + const char *toHex(ushort u, char *buffer); + const char *toHex(uchar u, char *buffer); + +} + + +class QPdfPage : public QPdf::ByteStream +{ +public: + QPdfPage(); + + QList images; + QList graphicStates; + QList patterns; + QList fonts; + QList annotations; + + void streamImage(int w, int h, uint object); + + QSize pageSize; +private: +}; + +class QPdfWriter; +class QPdfEnginePrivate; + +class Q_GUI_EXPORT QPdfEngine : public QPaintEngine +{ + Q_DECLARE_PRIVATE(QPdfEngine) + friend class QPdfWriter; +public: + // keep in sync with QPagedPaintDevice::PdfVersion and QPdfEnginePrivate::writeHeader()::mapping! + enum PdfVersion + { + Version_1_4, + Version_A1b, + Version_1_6, + Version_X4, + }; + + QPdfEngine(); + explicit QPdfEngine(QPdfEnginePrivate &d); + ~QPdfEngine() {} + + void setOutputFilename(const QString &filename); + + void setResolution(int resolution); + int resolution() const; + + void setPdfVersion(PdfVersion version); + + void setDocumentXmpMetadata(const QByteArray &xmpMetadata); + QByteArray documentXmpMetadata() const; + + void addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType); + + // keep in sync with QPdfWriter + enum class ColorModel + { + RGB, + Grayscale, + CMYK, + Auto, + }; + + ColorModel colorModel() const; + void setColorModel(ColorModel model); + + // reimplementations QPaintEngine + bool begin(QPaintDevice *pdev) override; + bool end() override; + + void drawPoints(const QPointF *points, int pointCount) override; + void drawLines(const QLineF *lines, int lineCount) override; + void drawRects(const QRectF *rects, int rectCount) override; + void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; + void drawPath (const QPainterPath & path) override; + + void drawTextItem(const QPointF &p, const QTextItem &textItem) override; + + void drawPixmap (const QRectF & rectangle, const QPixmap & pixmap, const QRectF & sr) override; + void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, + Qt::ImageConversionFlags flags = Qt::AutoColor) override; + void drawTiledPixmap (const QRectF & rectangle, const QPixmap & pixmap, const QPointF & point) override; + + void drawHyperlink(const QRectF &r, const QUrl &url); + + void updateState(const QPaintEngineState &state) override; + + int metric(QPaintDevice::PaintDeviceMetric metricType) const; + Type type() const override; + // end reimplementations QPaintEngine + + // Printer stuff... + bool newPage(); + + // Page layout stuff + void setPageLayout(const QPageLayout &pageLayout); + void setPageSize(const QPageSize &pageSize); + void setPageOrientation(QPageLayout::Orientation orientation); + void setPageMargins(const QMarginsF &margins, QPageLayout::Unit units = QPageLayout::Point); + + QPageLayout pageLayout() const; + + void setPen(); + void setBrush(); + void setupGraphicsState(QPaintEngine::DirtyFlags flags); + +private: + void updateClipPath(const QPainterPath & path, Qt::ClipOperation op); +}; + +class Q_GUI_EXPORT QPdfEnginePrivate : public QPaintEnginePrivate +{ + Q_DECLARE_PUBLIC(QPdfEngine) +public: + QPdfEnginePrivate(); + ~QPdfEnginePrivate(); + + inline uint requestObject() { return currentObject++; } + + void writeHeader(); + void writeTail(); + + int addImage(const QImage &image, bool *bitmap, bool lossless, qint64 serial_no); + int addConstantAlphaObject(int brushAlpha, int penAlpha = 255); + int addBrushPattern(const QTransform &matrix, bool *specifyColor, int *gStateObject); + + void drawTextItem(const QPointF &p, const QTextItemInt &ti); + + QTransform pageMatrix() const; + + void newPage(); + + int currentObject; + + QPdfPage* currentPage; + QPdf::Stroker stroker; + + QPointF brushOrigin; + QBrush brush; + QPen pen; + QList clips; + bool clipEnabled; + bool allClipped; + bool hasPen; + bool hasBrush; + bool simplePen; + bool needsTransform; + qreal opacity; + QPdfEngine::PdfVersion pdfVersion; + QPdfEngine::ColorModel colorModel; + + QHash fonts; + + QPaintDevice *pdev; + + // the device the output is in the end streamed to. + QIODevice *outDevice; + bool ownsDevice; + + // printer options + QString outputFileName; + QString title; + QString creator; + QUuid documentId = QUuid::createUuid(); + bool embedFonts; + int resolution; + QPdfOutputIntent outputIntent; + + // Page layout: size, orientation and margins + QPageLayout m_pageLayout; + +private: + int gradientBrush(const QBrush &b, const QTransform &matrix, int *gStateObject); + int generateGradientShader(const QGradient *gradient, const QTransform &matrix, bool alpha = false); + int generateLinearGradientShader(const QLinearGradient *lg, const QTransform &matrix, bool alpha); + int generateRadialGradientShader(const QRadialGradient *gradient, const QTransform &matrix, bool alpha); + struct ShadingFunctionResult + { + int function; + QPdfEngine::ColorModel colorModel; + void writeColorSpace(QPdf::ByteStream *stream) const; + }; + ShadingFunctionResult createShadingFunction(const QGradient *gradient, int from, int to, bool reflect, bool alpha); + + enum class ColorDomain { + Stroking, + NonStroking, + NonStrokingPattern, + }; + + QPdfEngine::ColorModel colorModelForColor(const QColor &color) const; + void writeColor(ColorDomain domain, const QColor &color); + void writeInfo(const QDateTime &date); + int writeXmpDocumentMetaData(const QDateTime &date); + int writeOutputIntent(); + void writePageRoot(); + void writeDestsRoot(); + void writeAttachmentRoot(); + void writeNamesRoot(); + void writeFonts(); + void embedFont(QFontSubset *font); + qreal calcUserUnit() const; + + QList xrefPositions; + QDataStream* stream; + int streampos; + + enum class WriteImageOption + { + Monochrome, + Grayscale, + RGB, + CMYK, + }; + + int writeImage(const QByteArray &data, int width, int height, WriteImageOption option, + int maskObject, int softMaskObject, bool dct = false, bool isMono = false); + void writePage(); + + int addXrefEntry(int object, bool printostr = true); + void printString(QStringView string); + void xprintf(const char* fmt, ...); + inline void write(QByteArrayView data) { + stream->writeRawData(data.constData(), data.size()); + streampos += data.size(); + } + + int writeCompressed(const char *src, int len); + inline int writeCompressed(const QByteArray &data) { return writeCompressed(data.constData(), data.size()); } + int writeCompressed(QIODevice *dev); + + struct AttachmentInfo + { + AttachmentInfo (const QString &fileName, const QByteArray &data, const QString &mimeType) + : fileName(fileName), data(data), mimeType(mimeType) {} + QString fileName; + QByteArray data; + QString mimeType; + }; + + struct DestInfo + { + QString anchor; + uint pageObj; + QPointF coords; + }; + + // various PDF objects + int pageRoot, namesRoot, destsRoot, attachmentsRoot, catalog, info; + int graphicsState; + int patternColorSpaceRGB; + int patternColorSpaceGrayscale; + int patternColorSpaceCMYK; + QList pages; + QHash imageCache; + QHash, uint > alphaCache; + QList destCache; + QList fileCache; + QByteArray xmpDocumentMetadata; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_PDF + +#endif // QPDF_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpen_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpen_p.h new file mode 100644 index 0000000000000000000000000000000000000000..31e00a1b007587ee6add6a5f3e27eed54b7bb8bc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpen_p.h @@ -0,0 +1,41 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPEN_P_H +#define QPEN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QPenPrivate : public QSharedData +{ +public: + QPenPrivate(const QBrush &brush, qreal width, Qt::PenStyle, Qt::PenCapStyle, + Qt::PenJoinStyle _joinStyle); + qreal width; + QBrush brush; + Qt::PenStyle style; + Qt::PenCapStyle capStyle; + Qt::PenJoinStyle joinStyle; + mutable QList dashPattern; + qreal dashOffset; + qreal miterLimit; + uint cosmetic : 1; +}; + +QT_END_NAMESPACE + +#endif // QPEN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpicture_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpicture_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1a36773ed5a2cd022bafd6d20bdf18da8196c5f4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpicture_p.h @@ -0,0 +1,133 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPICTURE_P_H +#define QPICTURE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtCore/qatomic.h" +#include "QtCore/qbuffer.h" +#include "QtCore/qlist.h" +#include "QtCore/qobjectdefs.h" +#include "QtCore/qrect.h" +#include "QtGui/qpicture.h" +#include "QtGui/qpixmap.h" +#include "QtGui/qpen.h" +#include "QtGui/qbrush.h" +#include "private/qobject_p.h" + +QT_BEGIN_NAMESPACE + +class QPaintEngine; + +extern const char *qt_mfhdr_tag; + +class QPicturePrivate +{ + friend class QPicturePaintEngine; + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPicture &r); + friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &s, QPicture &r); + +public: + enum PaintCommand { + PdcNOP = 0, // + PdcDrawPoint = 1, // point + PdcDrawFirst = PdcDrawPoint, + PdcMoveTo = 2, // point + PdcLineTo = 3, // point + PdcDrawLine = 4, // point,point + PdcDrawRect = 5, // rect + PdcDrawRoundRect = 6, // rect,ival,ival + PdcDrawEllipse = 7, // rect + PdcDrawArc = 8, // rect,ival,ival + PdcDrawPie = 9, // rect,ival,ival + PdcDrawChord = 10, // rect,ival,ival + PdcDrawLineSegments = 11, // ptarr + PdcDrawPolyline = 12, // ptarr + PdcDrawPolygon = 13, // ptarr,ival + PdcDrawCubicBezier = 14, // ptarr + PdcDrawText = 15, // point,str + PdcDrawTextFormatted = 16, // rect,ival,str + PdcDrawPixmap = 17, // rect,pixmap + PdcDrawImage = 18, // rect,image + PdcDrawText2 = 19, // point,str + PdcDrawText2Formatted = 20, // rect,ival,str + PdcDrawTextItem = 21, // pos,text,font,flags + PdcDrawLast = PdcDrawTextItem, + PdcDrawPoints = 22, // ptarr,ival,ival + PdcDrawWinFocusRect = 23, // rect,color + PdcDrawTiledPixmap = 24, // rect,pixmap,point + PdcDrawPath = 25, // path + + // no painting commands below PdcDrawLast. + + PdcBegin = 30, // + PdcEnd = 31, // + PdcSave = 32, // + PdcRestore = 33, // + PdcSetdev = 34, // device - PRIVATE + PdcSetBkColor = 40, // color + PdcSetBkMode = 41, // ival + PdcSetROP = 42, // ival + PdcSetBrushOrigin = 43, // point + PdcSetFont = 45, // font + PdcSetPen = 46, // pen + PdcSetBrush = 47, // brush + PdcSetTabStops = 48, // ival + PdcSetTabArray = 49, // ival,ivec + PdcSetUnit = 50, // ival + PdcSetVXform = 51, // ival + PdcSetWindow = 52, // rect + PdcSetViewport = 53, // rect + PdcSetWXform = 54, // ival + PdcSetWMatrix = 55, // matrix,ival + PdcSaveWMatrix = 56, + PdcRestoreWMatrix = 57, + PdcSetClip = 60, // ival + PdcSetClipRegion = 61, // rgn + PdcSetClipPath = 62, // path + PdcSetRenderHint = 63, // ival + PdcSetCompositionMode = 64, // ival + PdcSetClipEnabled = 65, // bool + PdcSetOpacity = 66, // qreal + + PdcReservedStart = 0, // codes 0-199 are reserved + PdcReservedStop = 199 // for Qt + }; + + QPicturePrivate(); + QPicturePrivate(const QPicturePrivate &other); + QAtomicInt ref; + + bool checkFormat(); + void resetFormat(); + + QBuffer pictb; + int trecs; + bool formatOk; + int formatMajor; + int formatMinor; + QRect brect; + QRect override_rect; + QScopedPointer paintEngine; + bool in_memory_only; + QList image_list; + QList pixmap_list; + QList brush_list; + QList pen_list; +}; + +QT_END_NAMESPACE + +#endif // QPICTURE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixellayout_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixellayout_p.h new file mode 100644 index 0000000000000000000000000000000000000000..840f6180c88077446ec530e56ae492704925c052 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixellayout_p.h @@ -0,0 +1,335 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPIXELLAYOUT_P_H +#define QPIXELLAYOUT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +enum QtPixelOrder { + PixelOrderRGB, + PixelOrderBGR +}; + +template inline uint qConvertArgb32ToA2rgb30(QRgb); + +template inline uint qConvertRgb32ToRgb30(QRgb); + +template inline QRgb qConvertA2rgb30ToArgb32(uint c); + +// A combined unpremultiply and premultiply with new simplified alpha. +// Needed when alpha loses precision relative to other colors during conversion (ARGB32 -> A2RGB30). +template +inline QRgb qRepremultiply(QRgb p) +{ + const uint alpha = qAlpha(p); + if (alpha == 255 || alpha == 0) + return p; + p = qUnpremultiply(p); + constexpr uint mult = 255 / (255 >> Shift); + const uint newAlpha = mult * (alpha >> Shift); + p = (p & ~0xff000000) | (newAlpha<<24); + return qPremultiply(p); +} + +template +inline QRgba64 qRepremultiply(QRgba64 p) +{ + const uint alpha = p.alpha(); + if (alpha == 65535 || alpha == 0) + return p; + p = p.unpremultiplied(); + constexpr uint mult = 65535 / (65535 >> Shift); + p.setAlpha(mult * (alpha >> Shift)); + return p.premultiplied(); +} + +template<> +inline uint qConvertArgb32ToA2rgb30(QRgb c) +{ + c = qRepremultiply<6>(c); + return (c & 0xc0000000) + | (((c << 22) & 0x3fc00000) | ((c << 14) & 0x00300000)) + | (((c << 4) & 0x000ff000) | ((c >> 4) & 0x00000c00)) + | (((c >> 14) & 0x000003fc) | ((c >> 22) & 0x00000003)); +} + +template<> +inline uint qConvertArgb32ToA2rgb30(QRgb c) +{ + c = qRepremultiply<6>(c); + return (c & 0xc0000000) + | (((c << 6) & 0x3fc00000) | ((c >> 2) & 0x00300000)) + | (((c << 4) & 0x000ff000) | ((c >> 4) & 0x00000c00)) + | (((c << 2) & 0x000003fc) | ((c >> 6) & 0x00000003)); +} + +template<> +inline uint qConvertRgb32ToRgb30(QRgb c) +{ + return 0xc0000000 + | (((c << 22) & 0x3fc00000) | ((c << 14) & 0x00300000)) + | (((c << 4) & 0x000ff000) | ((c >> 4) & 0x00000c00)) + | (((c >> 14) & 0x000003fc) | ((c >> 22) & 0x00000003)); +} + +template<> +inline uint qConvertRgb32ToRgb30(QRgb c) +{ + return 0xc0000000 + | (((c << 6) & 0x3fc00000) | ((c >> 2) & 0x00300000)) + | (((c << 4) & 0x000ff000) | ((c >> 4) & 0x00000c00)) + | (((c << 2) & 0x000003fc) | ((c >> 6) & 0x00000003)); +} + +template<> +inline QRgb qConvertA2rgb30ToArgb32(uint c) +{ + uint a = c >> 30; + a |= a << 2; + a |= a << 4; + return (a << 24) + | ((c << 14) & 0x00ff0000) + | ((c >> 4) & 0x0000ff00) + | ((c >> 22) & 0x000000ff); +} + +template<> +inline QRgb qConvertA2rgb30ToArgb32(uint c) +{ + uint a = c >> 30; + a |= a << 2; + a |= a << 4; + return (a << 24) + | ((c >> 6) & 0x00ff0000) + | ((c >> 4) & 0x0000ff00) + | ((c >> 2) & 0x000000ff); +} + +template inline QRgba64 qConvertA2rgb30ToRgb64(uint rgb); + +template<> +inline QRgba64 qConvertA2rgb30ToRgb64(uint rgb) +{ + quint16 alpha = rgb >> 30; + quint16 blue = (rgb >> 20) & 0x3ff; + quint16 green = (rgb >> 10) & 0x3ff; + quint16 red = rgb & 0x3ff; + // Expand the range. + alpha |= (alpha << 2); + alpha |= (alpha << 4); + alpha |= (alpha << 8); + red = (red << 6) | (red >> 4); + green = (green << 6) | (green >> 4); + blue = (blue << 6) | (blue >> 4); + return qRgba64(red, green, blue, alpha); +} + +template<> +inline QRgba64 qConvertA2rgb30ToRgb64(uint rgb) +{ + quint16 alpha = rgb >> 30; + quint16 red = (rgb >> 20) & 0x3ff; + quint16 green = (rgb >> 10) & 0x3ff; + quint16 blue = rgb & 0x3ff; + // Expand the range. + alpha |= (alpha << 2); + alpha |= (alpha << 4); + alpha |= (alpha << 8); + red = (red << 6) | (red >> 4); + green = (green << 6) | (green >> 4); + blue = (blue << 6) | (blue >> 4); + return qRgba64(red, green, blue, alpha); +} + +template inline unsigned int qConvertRgb64ToRgb30(QRgba64); + +template<> +inline unsigned int qConvertRgb64ToRgb30(QRgba64 c) +{ + c = qRepremultiply<14>(c); + const uint a = c.alpha() >> 14; + const uint r = c.red() >> 6; + const uint g = c.green() >> 6; + const uint b = c.blue() >> 6; + return (a << 30) | (b << 20) | (g << 10) | r; +} + +template<> +inline unsigned int qConvertRgb64ToRgb30(QRgba64 c) +{ + c = qRepremultiply<14>(c); + const uint a = c.alpha() >> 14; + const uint r = c.red() >> 6; + const uint g = c.green() >> 6; + const uint b = c.blue() >> 6; + return (a << 30) | (r << 20) | (g << 10) | b; +} + +inline constexpr QRgbaFloat16 qConvertRgb64ToRgbaF16(QRgba64 c) +{ + return QRgbaFloat16::fromRgba64(c.red(), c.green(), c.blue(), c.alpha()); +} + +inline constexpr QRgbaFloat32 qConvertRgb64ToRgbaF32(QRgba64 c) +{ + return QRgbaFloat32::fromRgba64(c.red(), c.green(), c.blue(), c.alpha()); +} + +inline uint qRgbSwapRgb30(uint c) +{ + const uint ag = c & 0xc00ffc00; + const uint rb = c & 0x3ff003ff; + return ag | (rb << 20) | (rb >> 20); +} + +#if Q_BYTE_ORDER == Q_BIG_ENDIAN +static inline quint32 RGBA2ARGB(quint32 x) { + quint32 rgb = x >> 8; + quint32 a = x << 24; + return a | rgb; +} + +static inline quint32 ARGB2RGBA(quint32 x) { + quint32 rgb = x << 8; + quint32 a = x >> 24; + return a | rgb; +} +#else +static inline quint32 RGBA2ARGB(quint32 x) { + // RGBA8888 is ABGR32 on little endian. + quint32 ag = x & 0xff00ff00; + quint32 rg = x & 0x00ff00ff; + return ag | (rg << 16) | (rg >> 16); +} + +static inline quint32 ARGB2RGBA(quint32 x) { + return RGBA2ARGB(x); +} +#endif + +// We manually unalias the variables to make sure the compiler +// fully optimizes both aliased and unaliased cases. +#define UNALIASED_CONVERSION_LOOP(buffer, src, count, conversion) \ + if (src == buffer) { \ + for (int i = 0; i < count; ++i) \ + buffer[i] = conversion(buffer[i]); \ + } else { \ + for (int i = 0; i < count; ++i) \ + buffer[i] = conversion(src[i]); \ + } + + +inline const uint *qt_convertARGB32ToARGB32PM(uint *buffer, const uint *src, int count) +{ + UNALIASED_CONVERSION_LOOP(buffer, src, count, qPremultiply); + return buffer; +} + +inline const uint *qt_convertRGBA8888ToARGB32PM(uint *buffer, const uint *src, int count) +{ + UNALIASED_CONVERSION_LOOP(buffer, src, count, [](uint s) { return qPremultiply(RGBA2ARGB(s));}); + return buffer; +} + +template void qt_convertRGBA64ToARGB32(uint *dst, const QRgba64 *src, int count); + +struct QDitherInfo { + int x; + int y; +}; + +typedef const uint *(QT_FASTCALL *FetchAndConvertPixelsFunc)(uint *buffer, const uchar *src, + int index, int count, + const QList *clut, + QDitherInfo *dither); +typedef void(QT_FASTCALL *ConvertAndStorePixelsFunc)(uchar *dest, const uint *src, int index, + int count, const QList *clut, + QDitherInfo *dither); + +typedef const QRgba64 *(QT_FASTCALL *FetchAndConvertPixelsFunc64)(QRgba64 *buffer, const uchar *src, + int index, int count, + const QList *clut, + QDitherInfo *dither); +typedef void(QT_FASTCALL *ConvertAndStorePixelsFunc64)(uchar *dest, const QRgba64 *src, int index, + int count, const QList *clut, + QDitherInfo *dither); + +typedef const QRgbaFloat32 *(QT_FASTCALL *FetchAndConvertPixelsFuncFP)(QRgbaFloat32 *buffer, const uchar *src, int index, int count, + const QList *clut, QDitherInfo *dither); +typedef void (QT_FASTCALL *ConvertAndStorePixelsFuncFP)(uchar *dest, const QRgbaFloat32 *src, int index, int count, + const QList *clut, QDitherInfo *dither); +typedef void (QT_FASTCALL *ConvertFunc)(uint *buffer, int count, const QList *clut); +typedef void (QT_FASTCALL *Convert64Func)(QRgba64 *buffer, int count); +typedef void (QT_FASTCALL *ConvertFPFunc)(QRgbaFloat32 *buffer, int count); +typedef void (QT_FASTCALL *Convert64ToFPFunc)(QRgbaFloat32 *buffer, const quint64 *src, int count); + +typedef const QRgba64 *(QT_FASTCALL *ConvertTo64Func)(QRgba64 *buffer, const uint *src, int count, + const QList *clut, QDitherInfo *dither); +typedef const QRgbaFloat32 *(QT_FASTCALL *ConvertToFPFunc)(QRgbaFloat32 *buffer, const uint *src, int count, + const QList *clut, QDitherInfo *dither); +typedef void (QT_FASTCALL *RbSwapFunc)(uchar *dst, const uchar *src, int count); + +typedef void (*MemRotateFunc)(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl); + +struct QPixelLayout +{ + // Bits per pixel + enum BPP { + BPPNone, + BPP1MSB, + BPP1LSB, + BPP8, + BPP16, + BPP24, + BPP32, + BPP64, + BPP16FPx4, + BPP32FPx4, + BPPCount + }; + + bool hasAlphaChannel; + bool premultiplied; + BPP bpp; + RbSwapFunc rbSwap; + ConvertFunc convertToARGB32PM; + ConvertTo64Func convertToRGBA64PM; + FetchAndConvertPixelsFunc fetchToARGB32PM; + FetchAndConvertPixelsFunc64 fetchToRGBA64PM; + ConvertAndStorePixelsFunc storeFromARGB32PM; + ConvertAndStorePixelsFunc storeFromRGB32; +}; + +extern ConvertAndStorePixelsFunc64 qStoreFromRGBA64PM[QImage::NImageFormats]; + +#if QT_CONFIG(raster_fp) +extern ConvertToFPFunc qConvertToRGBA32F[]; +extern FetchAndConvertPixelsFuncFP qFetchToRGBA32F[]; +extern ConvertAndStorePixelsFuncFP qStoreFromRGBA32F[]; +#endif + +extern QPixelLayout qPixelLayouts[]; + +extern MemRotateFunc qMemRotateFunctions[QPixelLayout::BPPCount][3]; + +QT_END_NAMESPACE + +#endif // QPIXELLAYOUT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmap_blitter_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmap_blitter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c6dcb93dd4e7498294f5645a079446dde765e3ac --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmap_blitter_p.h @@ -0,0 +1,176 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPIXMAP_BLITTER_P_H +#define QPIXMAP_BLITTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#ifndef QT_NO_BLITTABLE +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QBlittablePlatformPixmap : public QPlatformPixmap +{ +// Q_DECLARE_PRIVATE(QBlittablePlatformPixmap) +public: + QBlittablePlatformPixmap(); + ~QBlittablePlatformPixmap(); + + virtual QBlittable *createBlittable(const QSize &size, bool alpha) const = 0; + QBlittable *blittable() const; + void setBlittable(QBlittable *blittable); + + void resize(int width, int height) override; + int metric(QPaintDevice::PaintDeviceMetric metric) const override; + void fill(const QColor &color) override; + QImage *buffer() override; + QImage toImage() const override; + bool hasAlphaChannel() const override; + void fromImage(const QImage &image, Qt::ImageConversionFlags flags) override; + qreal devicePixelRatio() const override; + void setDevicePixelRatio(qreal scaleFactor) override; + + QPaintEngine *paintEngine() const override; + + void markRasterOverlay(const QRectF &); + void markRasterOverlay(const QPointF &, const QTextItem &); + void markRasterOverlay(const QVectorPath &); + void markRasterOverlay(const QPainterPath &); + void markRasterOverlay(const QRect *rects, int rectCount); + void markRasterOverlay(const QRectF *rects, int rectCount); + void markRasterOverlay(const QPointF *points, int pointCount); + void markRasterOverlay(const QPoint *points, int pointCount); + void unmarkRasterOverlay(const QRectF &); + +#ifdef QT_BLITTER_RASTEROVERLAY + void mergeOverlay(); + void unmergeOverlay(); + QImage *overlay(); + +#endif //QT_BLITTER_RASTEROVERLAY +protected: + QScopedPointer m_engine; + QScopedPointer m_blittable; + bool m_alpha; + qreal m_devicePixelRatio; + +#ifdef QT_BLITTER_RASTEROVERLAY + QImage *m_rasterOverlay; + QImage *m_unmergedCopy; + QColor m_overlayColor; + + void markRasterOverlayImpl(const QRectF &); + void unmarkRasterOverlayImpl(const QRectF &); + QRectF clipAndTransformRect(const QRectF &) const; +#endif //QT_BLITTER_RASTEROVERLAY + +}; + +inline void QBlittablePlatformPixmap::markRasterOverlay(const QRectF &rect) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + markRasterOverlayImpl(rect); +#else + Q_UNUSED(rect); +#endif +} + +inline void QBlittablePlatformPixmap::markRasterOverlay(const QVectorPath &path) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + markRasterOverlayImpl(path.convertToPainterPath().boundingRect()); +#else + Q_UNUSED(path); +#endif +} + +inline void QBlittablePlatformPixmap::markRasterOverlay(const QPointF &pos, const QTextItem &ti) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + QFontMetricsF fm(ti.font()); + QRectF rect = fm.tightBoundingRect(ti.text()); + rect.moveBottomLeft(pos); + markRasterOverlay(rect); +#else + Q_UNUSED(pos); + Q_UNUSED(ti); +#endif +} + +inline void QBlittablePlatformPixmap::markRasterOverlay(const QRect *rects, int rectCount) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + for (int i = 0; i < rectCount; i++) { + markRasterOverlay(rects[i]); + } +#else + Q_UNUSED(rects); + Q_UNUSED(rectCount); +#endif +} +inline void QBlittablePlatformPixmap::markRasterOverlay(const QRectF *rects, int rectCount) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + for (int i = 0; i < rectCount; i++) { + markRasterOverlay(rects[i]); + } +#else + Q_UNUSED(rects); + Q_UNUSED(rectCount); +#endif +} + +inline void QBlittablePlatformPixmap::markRasterOverlay(const QPointF *points, int pointCount) +{ +#ifdef QT_BLITTER_RASTEROVERLAY +#error "not ported yet" +#else + Q_UNUSED(points); + Q_UNUSED(pointCount); +#endif +} + +inline void QBlittablePlatformPixmap::markRasterOverlay(const QPoint *points, int pointCount) +{ +#ifdef QT_BLITTER_RASTEROVERLAY +#error "not ported yet" +#else + Q_UNUSED(points); + Q_UNUSED(pointCount); +#endif +} + +inline void QBlittablePlatformPixmap::markRasterOverlay(const QPainterPath& path) +{ +#ifdef QT_BLITTER_RASTEROVERLAY +#error "not ported yet" +#else + Q_UNUSED(path); +#endif +} + +inline void QBlittablePlatformPixmap::unmarkRasterOverlay(const QRectF &rect) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + unmarkRasterOverlayImpl(rect); +#else + Q_UNUSED(rect); +#endif +} + +QT_END_NAMESPACE +#endif // QT_NO_BLITTABLE +#endif // QPIXMAP_BLITTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmap_raster_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmap_raster_p.h new file mode 100644 index 0000000000000000000000000000000000000000..90ef1a639da8460db398d8b1f62544bbefbfc37f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmap_raster_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPIXMAP_RASTER_P_H +#define QPIXMAP_RASTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QRasterPlatformPixmap : public QPlatformPixmap +{ +public: + QRasterPlatformPixmap(PixelType type); + ~QRasterPlatformPixmap(); + + QPlatformPixmap *createCompatiblePlatformPixmap() const override; + + void resize(int width, int height) override; + bool fromData(const uchar *buffer, uint len, const char *format, Qt::ImageConversionFlags flags) override; + void fromImage(const QImage &image, Qt::ImageConversionFlags flags) override; + void fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags) override; + void fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) override; + + void copy(const QPlatformPixmap *data, const QRect &rect) override; + bool scroll(int dx, int dy, const QRect &rect) override; + void fill(const QColor &color) override; + bool hasAlphaChannel() const override; + QImage toImage() const override; + QImage toImage(const QRect &rect) const override; + QPaintEngine* paintEngine() const override; + QImage* buffer() override; + qreal devicePixelRatio() const override; + void setDevicePixelRatio(qreal scaleFactor) override; + + +protected: + int metric(QPaintDevice::PaintDeviceMetric metric) const override; + void createPixmapForImage(QImage sourceImage, Qt::ImageConversionFlags flags); + void setImage(const QImage &image); + QImage image; + static QImage::Format systemNativeFormat(); + +private: + friend class QPixmap; + friend class QBitmap; + friend class QPixmapCacheEntry; + friend class QRasterPaintEngine; +}; + +QT_END_NAMESPACE + +#endif // QPIXMAP_RASTER_P_H + + diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmap_win_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmap_win_p.h new file mode 100644 index 0000000000000000000000000000000000000000..88a88d2ef5fa5563f8f83513ddbdb0c809b7f672 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmap_win_p.h @@ -0,0 +1,38 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPIXMAP_WIN_P_H +#define QPIXMAP_WIN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QBitmap; +class QImage; +class QPixmap; + +Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap); +Q_GUI_EXPORT HBITMAP qt_imageToWinHBITMAP(const QImage &imageIn, int hbitmapFormat = 0); +Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0); +Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0); +Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0); +Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &p); +Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h); +Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon); + +QT_END_NAMESPACE + +#endif // QPIXMAP_WIN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmapcache_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmapcache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7b78a277d3091a3c23e12d353d447fa3219a8319 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpixmapcache_p.h @@ -0,0 +1,63 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPIXMAPCACHE_P_H +#define QPIXMAPCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qpixmapcache.h" +#include "qpaintengine.h" +#include +#include +#include "qcache.h" + +QT_BEGIN_NAMESPACE + +class QPixmapCache::KeyData +{ +public: + KeyData() : isValid(true), key(0), ref(1) {} + KeyData(const KeyData &other) + : isValid(other.isValid), key(other.key), ref(1) {} + ~KeyData() {} + + QString stringKey; + bool isValid; + int key; + int ref; +}; + +// XXX: hw: is this a general concept we need to abstract? +class QPixmapCacheEntry : public QPixmap +{ +public: + QPixmapCacheEntry(const QPixmapCache::Key &key, const QPixmap &pix) : QPixmap(pix), key(key) + { + QPlatformPixmap *pd = handle(); + if (pd && pd->classId() == QPlatformPixmap::RasterClass) { + QRasterPlatformPixmap *d = static_cast(pd); + if (!d->image.isNull() && d->image.d->paintEngine + && !d->image.d->paintEngine->isActive()) + { + delete d->image.d->paintEngine; + d->image.d->paintEngine = nullptr; + } + } + } + ~QPixmapCacheEntry(); + QPixmapCache::Key key; +}; + +QT_END_NAMESPACE + +#endif // QPIXMAPCACHE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpkmhandler_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpkmhandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f21fd3983c5b8539c5da3562c20e4269a96b7ff8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpkmhandler_p.h @@ -0,0 +1,35 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPKMHANDLER_H +#define QPKMHANDLER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtexturefilehandler_p.h" + +QT_BEGIN_NAMESPACE + +class QPkmHandler : public QTextureFileHandler +{ +public: + using QTextureFileHandler::QTextureFileHandler; + ~QPkmHandler() override; + + static bool canRead(const QByteArray &suffix, const QByteArray &block); + + QTextureFileData read() override; +}; + +QT_END_NAMESPACE + +#endif // QPKMHANDLER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpnghandler_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpnghandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..297cf6464789e5e5a9997206b3f0e15280ddce56 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpnghandler_p.h @@ -0,0 +1,49 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPNGHANDLER_P_H +#define QPNGHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtGui/qimageiohandler.h" + +#ifndef QT_NO_IMAGEFORMAT_PNG + +QT_BEGIN_NAMESPACE + +class QPngHandlerPrivate; +class QPngHandler : public QImageIOHandler +{ +public: + QPngHandler(); + ~QPngHandler(); + + bool canRead() const override; + bool read(QImage *image) override; + bool write(const QImage &image) override; + + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant &value) override; + bool supportsOption(ImageOption option) const override; + + static bool canRead(QIODevice *device); + +private: + QPngHandlerPrivate *d; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_IMAGEFORMAT_PNG +#endif // QPNGHANDLER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpointingdevice_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpointingdevice_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3b5f42853dabd37359f6642dffc23f0aef34f97d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qpointingdevice_p.h @@ -0,0 +1,112 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPOINTINGDEVICE_P_H +#define QPOINTINGDEVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcPointerGrab); + +class Q_GUI_EXPORT QPointingDevicePrivate : public QInputDevicePrivate +{ + Q_DECLARE_PUBLIC(QPointingDevice) +public: + QPointingDevicePrivate(const QString &name, qint64 id, QInputDevice::DeviceType type, + QPointingDevice::PointerType pType, QPointingDevice::Capabilities caps, + int maxPoints, int buttonCount, + const QString &seatName = QString(), + QPointingDeviceUniqueId uniqueId = QPointingDeviceUniqueId()) + : QInputDevicePrivate(name, id, type, caps, seatName), + uniqueId(uniqueId), + maximumTouchPoints(qint8(maxPoints)), buttonCount(qint8(buttonCount)), + pointerType(pType) + { + pointingDeviceType = true; + activePoints.reserve(maxPoints); + } + ~QPointingDevicePrivate() override; + + void sendTouchCancelEvent(QTouchEvent *cancelEvent); + + /*! \internal + This struct (stored in activePoints) holds persistent state between event deliveries. + */ + struct EventPointData { + QEventPoint eventPoint; + QPointer exclusiveGrabber; + QPointer exclusiveGrabberContext; // extra info about where the grab happened + QList > passiveGrabbers; + QList > passiveGrabbersContext; // parallel list: extra info about where the grabs happened + }; + EventPointData *queryPointById(int id) const; + EventPointData *pointById(int id) const; + void removePointById(int id); + QObject *firstActiveTarget() const; + QWindow *firstActiveWindow() const; + + QObject *firstPointExclusiveGrabber() const; + void setExclusiveGrabber(const QPointerEvent *event, const QEventPoint &point, QObject *exclusiveGrabber); + bool removeExclusiveGrabber(const QPointerEvent *event, const QObject *grabber); + bool addPassiveGrabber(const QPointerEvent *event, const QEventPoint &point, QObject *grabber); + static bool setPassiveGrabberContext(EventPointData *epd, QObject *grabber, QObject *context); + bool removePassiveGrabber(const QPointerEvent *event, const QEventPoint &point, QObject *grabber); + void clearPassiveGrabbers(const QPointerEvent *event, const QEventPoint &point); + void removeGrabber(QObject *grabber, bool cancel = false); + + using EventPointMap = QVarLengthFlatMap; + mutable EventPointMap activePoints; + + QPointingDeviceUniqueId uniqueId; + quint32 toolId = 0; // only for Wacom tablets + qint8 maximumTouchPoints = 0; + qint8 buttonCount = 0; + QPointingDevice::PointerType pointerType = QPointingDevice::PointerType::Unknown; + bool toolProximity = false; // only for Wacom tablets + + inline static QPointingDevicePrivate *get(QPointingDevice *q) + { + return static_cast(QObjectPrivate::get(q)); + } + + inline static const QPointingDevicePrivate *get(const QPointingDevice *q) + { + return static_cast(QObjectPrivate::get(q)); + } + + static const QPointingDevice *tabletDevice(QInputDevice::DeviceType deviceType, + QPointingDevice::PointerType pointerType, + QPointingDeviceUniqueId uniqueId); + + static const QPointingDevice *queryTabletDevice(QInputDevice::DeviceType deviceType, + QPointingDevice::PointerType pointerType, + QPointingDeviceUniqueId uniqueId, + QInputDevice::Capabilities capabilities = QInputDevice::Capability::None, + qint64 systemId = 0); + + static const QPointingDevice *pointingDeviceById(qint64 systemId); +}; + +QT_END_NAMESPACE + +#endif // QPOINTINGDEVICE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qppmhandler_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qppmhandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..02de0767b8be4b8211840a87707232b3dc4b21c6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qppmhandler_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPPMHANDLER_P_H +#define QPPMHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtGui/qimageiohandler.h" + +#ifndef QT_NO_IMAGEFORMAT_PPM + +QT_BEGIN_NAMESPACE + +class QByteArray; +class QPpmHandler : public QImageIOHandler +{ +public: + QPpmHandler(); + bool canRead() const override; + bool read(QImage *image) override; + bool write(const QImage &image) override; + + static bool canRead(QIODevice *device, QByteArray *subType = nullptr); + + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant &value) override; + bool supportsOption(ImageOption option) const override; + +private: + bool readHeader(); + enum State { + Ready, + ReadHeader, + Error + }; + State state; + char type; + int width; + int height; + int mcc; + mutable QByteArray subType; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_IMAGEFORMAT_PPM + +#endif // QPPMHANDLER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrasterdefs_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrasterdefs_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0e9225db72104c5ab4833844d1c1323d548e7c51 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrasterdefs_p.h @@ -0,0 +1,1241 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +/***************************************************************************/ +/* */ +/* ftimage.h */ +/* */ +/* FreeType glyph image formats and default raster interface */ +/* (specification). */ +/* */ +/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + /*************************************************************************/ + /* */ + /* Note: A `raster' is simply a scan-line converter, used to render */ + /* QT_FT_Outlines into QT_FT_Bitmaps. */ + /* */ + /*************************************************************************/ + + +#ifndef __QT_FTIMAGE_H__ +#define __QT_FTIMAGE_H__ + +/* +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +*/ + +QT_FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /*
*/ + /* basic_types */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Pos */ + /* */ + /* */ + /* The type QT_FT_Pos is a 32-bit integer used to store vectorial */ + /* coordinates. Depending on the context, these can represent */ + /* distances in integer font units, or 16,16, or 26.6 fixed float */ + /* pixel coordinates. */ + /* */ + typedef signed int QT_FT_Pos; + + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Vector */ + /* */ + /* */ + /* A simple structure used to store a 2D vector; coordinates are of */ + /* the QT_FT_Pos type. */ + /* */ + /* */ + /* x :: The horizontal coordinate. */ + /* y :: The vertical coordinate. */ + /* */ + typedef struct QT_FT_Vector_ + { + QT_FT_Pos x; + QT_FT_Pos y; + + } QT_FT_Vector; + + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_BBox */ + /* */ + /* */ + /* A structure used to hold an outline's bounding box, i.e., the */ + /* coordinates of its extrema in the horizontal and vertical */ + /* directions. */ + /* */ + /* */ + /* xMin :: The horizontal minimum (left-most). */ + /* */ + /* yMin :: The vertical minimum (bottom-most). */ + /* */ + /* xMax :: The horizontal maximum (right-most). */ + /* */ + /* yMax :: The vertical maximum (top-most). */ + /* */ + typedef struct QT_FT_BBox_ + { + QT_FT_Pos xMin, yMin; + QT_FT_Pos xMax, yMax; + + } QT_FT_BBox; + + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Pixel_Mode */ + /* */ + /* */ + /* An enumeration type used to describe the format of pixels in a */ + /* given bitmap. Note that additional formats may be added in the */ + /* future. */ + /* */ + /* */ + /* QT_FT_PIXEL_MODE_NONE :: */ + /* Value 0 is reserved. */ + /* */ + /* QT_FT_PIXEL_MODE_MONO :: */ + /* A monochrome bitmap, using 1 bit per pixel. Note that pixels */ + /* are stored in most-significant order (MSB), which means that */ + /* the left-most pixel in a byte has value 128. */ + /* */ + /* QT_FT_PIXEL_MODE_GRAY :: */ + /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ + /* images. Each pixel is stored in one byte. Note that the number */ + /* of value "gray" levels is stored in the `num_bytes' field of */ + /* the @QT_FT_Bitmap structure (it generally is 256). */ + /* */ + /* QT_FT_PIXEL_MODE_GRAY2 :: */ + /* A 2-bit/pixel bitmap, used to represent embedded anti-aliased */ + /* bitmaps in font files according to the OpenType specification. */ + /* We haven't found a single font using this format, however. */ + /* */ + /* QT_FT_PIXEL_MODE_GRAY4 :: */ + /* A 4-bit/pixel bitmap, used to represent embedded anti-aliased */ + /* bitmaps in font files according to the OpenType specification. */ + /* We haven't found a single font using this format, however. */ + /* */ + /* QT_FT_PIXEL_MODE_LCD :: */ + /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */ + /* images used for display on LCD displays; the bitmap's width is */ + /* three times wider than the original glyph image. See also */ + /* @QT_FT_RENDER_MODE_LCD. */ + /* */ + /* QT_FT_PIXEL_MODE_LCD_V :: */ + /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */ + /* images used for display on rotated LCD displays; the bitmap's */ + /* height is three times taller than the original glyph image. */ + /* See also @QT_FT_RENDER_MODE_LCD_V. */ + /* */ + typedef enum QT_FT_Pixel_Mode_ + { + QT_FT_PIXEL_MODE_NONE = 0, + QT_FT_PIXEL_MODE_MONO, + QT_FT_PIXEL_MODE_GRAY, + QT_FT_PIXEL_MODE_GRAY2, + QT_FT_PIXEL_MODE_GRAY4, + QT_FT_PIXEL_MODE_LCD, + QT_FT_PIXEL_MODE_LCD_V, + + QT_FT_PIXEL_MODE_MAX /* do not remove */ + + } QT_FT_Pixel_Mode; + + + /*************************************************************************/ + /* */ + /* */ + /* qt_ft_pixel_mode_xxx */ + /* */ + /* */ + /* A list of deprecated constants. Use the corresponding */ + /* @QT_FT_Pixel_Mode values instead. */ + /* */ + /* */ + /* qt_ft_pixel_mode_none :: see @QT_FT_PIXEL_MODE_NONE */ + /* qt_ft_pixel_mode_mono :: see @QT_FT_PIXEL_MODE_MONO */ + /* qt_ft_pixel_mode_grays :: see @QT_FT_PIXEL_MODE_GRAY */ + /* qt_ft_pixel_mode_pal2 :: see @QT_FT_PIXEL_MODE_GRAY2 */ + /* qt_ft_pixel_mode_pal4 :: see @QT_FT_PIXEL_MODE_GRAY4 */ + /* */ +#define qt_ft_pixel_mode_none QT_FT_PIXEL_MODE_NONE +#define qt_ft_pixel_mode_mono QT_FT_PIXEL_MODE_MONO +#define qt_ft_pixel_mode_grays QT_FT_PIXEL_MODE_GRAY +#define qt_ft_pixel_mode_pal2 QT_FT_PIXEL_MODE_GRAY2 +#define qt_ft_pixel_mode_pal4 QT_FT_PIXEL_MODE_GRAY4 + + /* */ + +#if 0 + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Palette_Mode */ + /* */ + /* */ + /* THIS TYPE IS DEPRECATED. DO NOT USE IT! */ + /* */ + /* An enumeration type used to describe the format of a bitmap */ + /* palette, used with qt_ft_pixel_mode_pal4 and qt_ft_pixel_mode_pal8. */ + /* */ + /* */ + /* qt_ft_palette_mode_rgb :: The palette is an array of 3-bytes RGB */ + /* records. */ + /* */ + /* qt_ft_palette_mode_rgba :: The palette is an array of 4-bytes RGBA */ + /* records. */ + /* */ + /* */ + /* As qt_ft_pixel_mode_pal2, pal4 and pal8 are currently unused by */ + /* FreeType, these types are not handled by the library itself. */ + /* */ + typedef enum QT_FT_Palette_Mode_ + { + qt_ft_palette_mode_rgb = 0, + qt_ft_palette_mode_rgba, + + qt_ft_palettte_mode_max /* do not remove */ + + } QT_FT_Palette_Mode; + + /* */ + +#endif + + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Bitmap */ + /* */ + /* */ + /* A structure used to describe a bitmap or pixmap to the raster. */ + /* Note that we now manage pixmaps of various depths through the */ + /* `pixel_mode' field. */ + /* */ + /* */ + /* rows :: The number of bitmap rows. */ + /* */ + /* width :: The number of pixels in bitmap row. */ + /* */ + /* pitch :: The pitch's absolute value is the number of bytes */ + /* taken by one bitmap row, including padding. */ + /* However, the pitch is positive when the bitmap has */ + /* a `down' flow, and negative when it has an `up' */ + /* flow. In all cases, the pitch is an offset to add */ + /* to a bitmap pointer in order to go down one row. */ + /* */ + /* buffer :: A typeless pointer to the bitmap buffer. This */ + /* value should be aligned on 32-bit boundaries in */ + /* most cases. */ + /* */ + /* num_grays :: This field is only used with */ + /* `QT_FT_PIXEL_MODE_GRAY'; it gives the number of gray */ + /* levels used in the bitmap. */ + /* */ + /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */ + /* See @QT_FT_Pixel_Mode for possible values. */ + /* */ + /* palette_mode :: This field is only used with paletted pixel modes; */ + /* it indicates how the palette is stored. */ + /* */ + /* palette :: A typeless pointer to the bitmap palette; only */ + /* used for paletted pixel modes. */ + /* */ + /* */ + /* For now, the only pixel mode supported by FreeType are mono and */ + /* grays. However, drivers might be added in the future to support */ + /* more `colorful' options. */ + /* */ + /* When using pixel modes pal2, pal4 and pal8 with a void `palette' */ + /* field, a gray pixmap with respectively 4, 16, and 256 levels of */ + /* gray is assumed. This, in order to be compatible with some */ + /* embedded bitmap formats defined in the TrueType specification. */ + /* */ + /* Note that no font was found presenting such embedded bitmaps, so */ + /* this is currently completely unhandled by the library. */ + /* */ + typedef struct QT_FT_Bitmap_ + { + int rows; + int width; + int pitch; + unsigned char* buffer; + short num_grays; + char pixel_mode; + char palette_mode; + void* palette; + + } QT_FT_Bitmap; + + + /*************************************************************************/ + /* */ + /*
*/ + /* outline_processing */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Outline */ + /* */ + /* */ + /* This structure is used to describe an outline to the scan-line */ + /* converter. */ + /* */ + /* */ + /* n_contours :: The number of contours in the outline. */ + /* */ + /* n_points :: The number of points in the outline. */ + /* */ + /* points :: A pointer to an array of `n_points' QT_FT_Vector */ + /* elements, giving the outline's point coordinates. */ + /* */ + /* tags :: A pointer to an array of `n_points' chars, giving */ + /* each outline point's type. If bit 0 is unset, the */ + /* point is `off' the curve, i.e. a Bezier control */ + /* point, while it is `on' when set. */ + /* */ + /* Bit 1 is meaningful for `off' points only. If set, */ + /* it indicates a third-order Bezier arc control point; */ + /* and a second-order control point if unset. */ + /* */ + /* contours :: An array of `n_contours' shorts, giving the end */ + /* point of each contour within the outline. For */ + /* example, the first contour is defined by the points */ + /* `0' to `contours[0]', the second one is defined by */ + /* the points `contours[0]+1' to `contours[1]', etc. */ + /* */ + /* flags :: A set of bit flags used to characterize the outline */ + /* and give hints to the scan-converter and hinter on */ + /* how to convert/grid-fit it. See QT_FT_Outline_Flags. */ + /* */ + typedef struct QT_FT_Outline_ + { + int n_contours; /* number of contours in glyph */ + int n_points; /* number of points in the glyph */ + + QT_FT_Vector* points; /* the outline's points */ + char* tags; /* the points flags */ + int* contours; /* the contour end points */ + + int flags; /* outline masks */ + + } QT_FT_Outline; + + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_OUTLINE_FLAGS */ + /* */ + /* */ + /* A list of bit-field constants use for the flags in an outline's */ + /* `flags' field. */ + /* */ + /* */ + /* QT_FT_OUTLINE_NONE :: Value 0 is reserved. */ + /* */ + /* QT_FT_OUTLINE_OWNER :: If set, this flag indicates that the */ + /* outline's field arrays (i.e. */ + /* `points', `flags' & `contours') are */ + /* `owned' by the outline object, and */ + /* should thus be freed when it is */ + /* destroyed. */ + /* */ + /* QT_FT_OUTLINE_EVEN_ODD_FILL :: By default, outlines are filled using */ + /* the non-zero winding rule. If set to */ + /* 1, the outline will be filled using */ + /* the even-odd fill rule (only works */ + /* with the smooth raster). */ + /* */ + /* QT_FT_OUTLINE_REVERSE_FILL :: By default, outside contours of an */ + /* outline are oriented in clock-wise */ + /* direction, as defined in the TrueType */ + /* specification. This flag is set if */ + /* the outline uses the opposite */ + /* direction (typically for Type 1 */ + /* fonts). This flag is ignored by the */ + /* scan-converter. However, it is very */ + /* important for the auto-hinter. */ + /* */ + /* QT_FT_OUTLINE_IGNORE_DROPOUTS :: By default, the scan converter will */ + /* try to detect drop-outs in an outline */ + /* and correct the glyph bitmap to */ + /* ensure consistent shape continuity. */ + /* If set, this flag hints the scan-line */ + /* converter to ignore such cases. */ + /* */ + /* QT_FT_OUTLINE_HIGH_PRECISION :: This flag indicates that the */ + /* scan-line converter should try to */ + /* convert this outline to bitmaps with */ + /* the highest possible quality. It is */ + /* typically set for small character */ + /* sizes. Note that this is only a */ + /* hint, that might be completely */ + /* ignored by a given scan-converter. */ + /* */ + /* QT_FT_OUTLINE_SINGLE_PASS :: This flag is set to force a given */ + /* scan-converter to only use a single */ + /* pass over the outline to render a */ + /* bitmap glyph image. Normally, it is */ + /* set for very large character sizes. */ + /* It is only a hint, that might be */ + /* completely ignored by a given */ + /* scan-converter. */ + /* */ +#define QT_FT_OUTLINE_NONE 0x0 +#define QT_FT_OUTLINE_OWNER 0x1 +#define QT_FT_OUTLINE_EVEN_ODD_FILL 0x2 +#define QT_FT_OUTLINE_REVERSE_FILL 0x4 +#define QT_FT_OUTLINE_IGNORE_DROPOUTS 0x8 + +#define QT_FT_OUTLINE_HIGH_PRECISION 0x100 +#define QT_FT_OUTLINE_SINGLE_PASS 0x200 + + + /************************************************************************* + * + * @enum: + * qt_ft_outline_flags + * + * @description: + * These constants are deprecated. Please use the corresponding + * @QT_FT_OUTLINE_FLAGS values. + * + * @values: + * qt_ft_outline_none :: See @QT_FT_OUTLINE_NONE. + * qt_ft_outline_owner :: See @QT_FT_OUTLINE_OWNER. + * qt_ft_outline_even_odd_fill :: See @QT_FT_OUTLINE_EVEN_ODD_FILL. + * qt_ft_outline_reverse_fill :: See @QT_FT_OUTLINE_REVERSE_FILL. + * qt_ft_outline_ignore_dropouts :: See @QT_FT_OUTLINE_IGNORE_DROPOUTS. + * qt_ft_outline_high_precision :: See @QT_FT_OUTLINE_HIGH_PRECISION. + * qt_ft_outline_single_pass :: See @QT_FT_OUTLINE_SINGLE_PASS. + */ +#define qt_ft_outline_none QT_FT_OUTLINE_NONE +#define qt_ft_outline_owner QT_FT_OUTLINE_OWNER +#define qt_ft_outline_even_odd_fill QT_FT_OUTLINE_EVEN_ODD_FILL +#define qt_ft_outline_reverse_fill QT_FT_OUTLINE_REVERSE_FILL +#define qt_ft_outline_ignore_dropouts QT_FT_OUTLINE_IGNORE_DROPOUTS +#define qt_ft_outline_high_precision QT_FT_OUTLINE_HIGH_PRECISION +#define qt_ft_outline_single_pass QT_FT_OUTLINE_SINGLE_PASS + + /* */ + +#define QT_FT_CURVE_TAG( flag ) ( flag & 3 ) + +#define QT_FT_CURVE_TAG_ON 1 +#define QT_FT_CURVE_TAG_CONIC 0 +#define QT_FT_CURVE_TAG_CUBIC 2 + +#define QT_FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ +#define QT_FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ + +#define QT_FT_CURVE_TAG_TOUCH_BOTH ( QT_FT_CURVE_TAG_TOUCH_X | \ + QT_FT_CURVE_TAG_TOUCH_Y ) + +#define QT_FT_Curve_Tag_On QT_FT_CURVE_TAG_ON +#define QT_FT_Curve_Tag_Conic QT_FT_CURVE_TAG_CONIC +#define QT_FT_Curve_Tag_Cubic QT_FT_CURVE_TAG_CUBIC +#define QT_FT_Curve_Tag_Touch_X QT_FT_CURVE_TAG_TOUCH_X +#define QT_FT_Curve_Tag_Touch_Y QT_FT_CURVE_TAG_TOUCH_Y + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Outline_MoveToFunc */ + /* */ + /* */ + /* A function pointer type used to describe the signature of a `move */ + /* to' function during outline walking/decomposition. */ + /* */ + /* A `move to' is emitted to start a new contour in an outline. */ + /* */ + /* */ + /* to :: A pointer to the target point of the `move to'. */ + /* */ + /* user :: A typeless pointer which is passed from the caller of the */ + /* decomposition function. */ + /* */ + /* */ + /* Error code. 0 means success. */ + /* */ + typedef int + (*QT_FT_Outline_MoveToFunc)( QT_FT_Vector* to, + void* user ); + +#define QT_FT_Outline_MoveTo_Func QT_FT_Outline_MoveToFunc + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Outline_LineToFunc */ + /* */ + /* */ + /* A function pointer type used to describe the signature of a `line */ + /* to' function during outline walking/decomposition. */ + /* */ + /* A `line to' is emitted to indicate a segment in the outline. */ + /* */ + /* */ + /* to :: A pointer to the target point of the `line to'. */ + /* */ + /* user :: A typeless pointer which is passed from the caller of the */ + /* decomposition function. */ + /* */ + /* */ + /* Error code. 0 means success. */ + /* */ + typedef int + (*QT_FT_Outline_LineToFunc)( QT_FT_Vector* to, + void* user ); + +#define QT_FT_Outline_LineTo_Func QT_FT_Outline_LineToFunc + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Outline_ConicToFunc */ + /* */ + /* */ + /* A function pointer type use to describe the signature of a `conic */ + /* to' function during outline walking/decomposition. */ + /* */ + /* A `conic to' is emitted to indicate a second-order Bezier arc in */ + /* the outline. */ + /* */ + /* */ + /* control :: An intermediate control point between the last position */ + /* and the new target in `to'. */ + /* */ + /* to :: A pointer to the target end point of the conic arc. */ + /* */ + /* user :: A typeless pointer which is passed from the caller of */ + /* the decomposition function. */ + /* */ + /* */ + /* Error code. 0 means success. */ + /* */ + typedef int + (*QT_FT_Outline_ConicToFunc)( QT_FT_Vector* control, + QT_FT_Vector* to, + void* user ); + +#define QT_FT_Outline_ConicTo_Func QT_FT_Outline_ConicToFunc + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Outline_CubicToFunc */ + /* */ + /* */ + /* A function pointer type used to describe the signature of a `cubic */ + /* to' function during outline walking/decomposition. */ + /* */ + /* A `cubic to' is emitted to indicate a third-order Bezier arc. */ + /* */ + /* */ + /* control1 :: A pointer to the first Bezier control point. */ + /* */ + /* control2 :: A pointer to the second Bezier control point. */ + /* */ + /* to :: A pointer to the target end point. */ + /* */ + /* user :: A typeless pointer which is passed from the caller of */ + /* the decomposition function. */ + /* */ + /* */ + /* Error code. 0 means success. */ + /* */ + typedef int + (*QT_FT_Outline_CubicToFunc)( QT_FT_Vector* control1, + QT_FT_Vector* control2, + QT_FT_Vector* to, + void* user ); + +#define QT_FT_Outline_CubicTo_Func QT_FT_Outline_CubicToFunc + + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Outline_Funcs */ + /* */ + /* */ + /* A structure to hold various function pointers used during outline */ + /* decomposition in order to emit segments, conic, and cubic Beziers, */ + /* as well as `move to' and `close to' operations. */ + /* */ + /* */ + /* move_to :: The `move to' emitter. */ + /* */ + /* line_to :: The segment emitter. */ + /* */ + /* conic_to :: The second-order Bezier arc emitter. */ + /* */ + /* cubic_to :: The third-order Bezier arc emitter. */ + /* */ + /* shift :: The shift that is applied to coordinates before they */ + /* are sent to the emitter. */ + /* */ + /* delta :: The delta that is applied to coordinates before they */ + /* are sent to the emitter, but after the shift. */ + /* */ + /* */ + /* The point coordinates sent to the emitters are the transformed */ + /* version of the original coordinates (this is important for high */ + /* accuracy during scan-conversion). The transformation is simple: */ + /* */ + /* x' = (x << shift) - delta */ + /* y' = (x << shift) - delta */ + /* */ + /* Set the value of `shift' and `delta' to 0 to get the original */ + /* point coordinates. */ + /* */ + typedef struct QT_FT_Outline_Funcs_ + { + QT_FT_Outline_MoveToFunc move_to; + QT_FT_Outline_LineToFunc line_to; + QT_FT_Outline_ConicToFunc conic_to; + QT_FT_Outline_CubicToFunc cubic_to; + + int shift; + QT_FT_Pos delta; + + } QT_FT_Outline_Funcs; + + + /*************************************************************************/ + /* */ + /*
*/ + /* basic_types */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_IMAGE_TAG */ + /* */ + /* */ + /* This macro converts four letter tags into an unsigned long. */ + /* */ + /* */ + /* Since many 16bit compilers don't like 32bit enumerations, you */ + /* should redefine this macro in case of problems to something like */ + /* this: */ + /* */ + /* #define QT_FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */ + /* */ + /* to get a simple enumeration without assigning special numbers. */ + /* */ +#ifndef QT_FT_IMAGE_TAG +#define QT_FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ + value = ( ( (unsigned long)_x1 << 24 ) | \ + ( (unsigned long)_x2 << 16 ) | \ + ( (unsigned long)_x3 << 8 ) | \ + (unsigned long)_x4 ) +#endif /* QT_FT_IMAGE_TAG */ + + + /*************************************************************************/ + /* */ + /* */ + /* QT_FT_Glyph_Format */ + /* */ + /* */ + /* An enumeration type used to describe the format of a given glyph */ + /* image. Note that this version of FreeType only supports two image */ + /* formats, even though future font drivers will be able to register */ + /* their own format. */ + /* */ + /* */ + /* QT_FT_GLYPH_FORMAT_NONE :: */ + /* The value 0 is reserved and does describe a glyph format. */ + /* */ + /* QT_FT_GLYPH_FORMAT_COMPOSITE :: */ + /* The glyph image is a composite of several other images. This */ + /* format is _only_ used with @QT_FT_LOAD_NO_RECURSE, and is used to */ + /* report compound glyphs (like accented characters). */ + /* */ + /* QT_FT_GLYPH_FORMAT_BITMAP :: */ + /* The glyph image is a bitmap, and can be described as an */ + /* @QT_FT_Bitmap. You generally need to access the `bitmap' field of */ + /* the @QT_FT_GlyphSlotRec structure to read it. */ + /* */ + /* QT_FT_GLYPH_FORMAT_OUTLINE :: */ + /* The glyph image is a vertorial outline made of line segments */ + /* and Bezier arcs; it can be described as an @QT_FT_Outline; you */ + /* generally want to access the `outline' field of the */ + /* @QT_FT_GlyphSlotRec structure to read it. */ + /* */ + /* QT_FT_GLYPH_FORMAT_PLOTTER :: */ + /* The glyph image is a vectorial path with no inside/outside */ + /* contours. Some Type 1 fonts, like those in the Hershey family, */ + /* contain glyphs in this format. These are described as */ + /* @QT_FT_Outline, but FreeType isn't currently capable of rendering */ + /* them correctly. */ + /* */ + typedef enum QT_FT_Glyph_Format_ + { + QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), + + QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), + QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), + QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), + QT_FT_IMAGE_TAG( QT_FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ) + + } QT_FT_Glyph_Format; + + + /*************************************************************************/ + /* */ + /* */ + /* qt_ft_glyph_format_xxx */ + /* */ + /* */ + /* A list of decprecated constants. Use the corresponding */ + /* @QT_FT_Glyph_Format values instead. */ + /* */ + /* */ + /* qt_ft_glyph_format_none :: see @QT_FT_GLYPH_FORMAT_NONE */ + /* qt_ft_glyph_format_composite :: see @QT_FT_GLYPH_FORMAT_COMPOSITE */ + /* qt_ft_glyph_format_bitmap :: see @QT_FT_GLYPH_FORMAT_BITMAP */ + /* qt_ft_glyph_format_outline :: see @QT_FT_GLYPH_FORMAT_OUTLINE */ + /* qt_ft_glyph_format_plotter :: see @QT_FT_GLYPH_FORMAT_PLOTTER */ + /* */ +#define qt_ft_glyph_format_none QT_FT_GLYPH_FORMAT_NONE +#define qt_ft_glyph_format_composite QT_FT_GLYPH_FORMAT_COMPOSITE +#define qt_ft_glyph_format_bitmap QT_FT_GLYPH_FORMAT_BITMAP +#define qt_ft_glyph_format_outline QT_FT_GLYPH_FORMAT_OUTLINE +#define qt_ft_glyph_format_plotter QT_FT_GLYPH_FORMAT_PLOTTER + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** R A S T E R D E F I N I T I O N S *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* A raster is a scan converter, in charge of rendering an outline into */ + /* a a bitmap. This section contains the public API for rasters. */ + /* */ + /* Note that in FreeType 2, all rasters are now encapsulated within */ + /* specific modules called `renderers'. See `freetype/ftrender.h' for */ + /* more details on renderers. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /*
*/ + /* raster */ + /* */ + /* */ + /* Scanline converter */ + /* */ + /* <Abstract> */ + /* How vectorial outlines are converted into bitmaps and pixmaps. */ + /* */ + /* <Description> */ + /* This section contains technical definitions. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Type> */ + /* QT_FT_Raster */ + /* */ + /* <Description> */ + /* A handle (pointer) to a raster object. Each object can be used */ + /* independently to convert an outline into a bitmap or pixmap. */ + /* */ + typedef struct TRaster_ *QT_FT_Raster; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* QT_FT_Span */ + /* */ + /* <Description> */ + /* A structure used to model a single span of gray (or black) pixels */ + /* when rendering a monochrome or anti-aliased bitmap. */ + /* */ + /* <Fields> */ + /* x :: The span's horizontal start position. */ + /* */ + /* len :: The span's length in pixels. */ + /* */ + /* coverage :: The span color/coverage, ranging from 0 (background) */ + /* to 255 (foreground). Only used for anti-aliased */ + /* rendering. */ + /* */ + /* <Note> */ + /* This structure is used by the span drawing callback type named */ + /* QT_FT_SpanFunc which takes the y-coordinate of the span as a */ + /* a parameter. */ + /* */ + /* The coverage value is always between 0 and 255, even if the number */ + /* of gray levels have been set through QT_FT_Set_Gray_Levels(). */ + /* */ + typedef struct QT_FT_Span_ + { + int x; + int len; + int y; + unsigned char coverage; + } QT_FT_Span; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* QT_FT_SpanFunc */ + /* */ + /* <Description> */ + /* A function used as a call-back by the anti-aliased renderer in */ + /* order to let client applications draw themselves the gray pixel */ + /* spans on each scan line. */ + /* */ + /* <Input> */ + /* y :: The scanline's y-coordinate. */ + /* */ + /* count :: The number of spans to draw on this scanline. */ + /* */ + /* spans :: A table of `count' spans to draw on the scanline. */ + /* */ + /* user :: User-supplied data that is passed to the callback. */ + /* */ + /* <Note> */ + /* This callback allows client applications to directly render the */ + /* gray spans of the anti-aliased bitmap to any kind of surfaces. */ + /* */ + /* This can be used to write anti-aliased outlines directly to a */ + /* given background bitmap, and even perform translucency. */ + /* */ + /* Note that the `count' field cannot be greater than a fixed value */ + /* defined by the QT_FT_MAX_GRAY_SPANS configuration macro in */ + /* ftoption.h. By default, this value is set to 32, which means that */ + /* if there are more than 32 spans on a given scanline, the callback */ + /* will be called several times with the same `y' parameter in order */ + /* to draw all callbacks. */ + /* */ + /* Otherwise, the callback is only called once per scan-line, and */ + /* only for those scanlines that do have `gray' pixels on them. */ + /* */ + typedef void + (*QT_FT_SpanFunc)(int count, + const QT_FT_Span* spans, + void* worker); + +#define QT_FT_Raster_Span_Func QT_FT_SpanFunc + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* QT_FT_Raster_BitTest_Func */ + /* */ + /* <Description> */ + /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */ + /* */ + /* A function used as a call-back by the monochrome scan-converter */ + /* to test whether a given target pixel is already set to the drawing */ + /* `color'. These tests are crucial to implement drop-out control */ + /* per-se the TrueType spec. */ + /* */ + /* <Input> */ + /* y :: The pixel's y-coordinate. */ + /* */ + /* x :: The pixel's x-coordinate. */ + /* */ + /* user :: User-supplied data that is passed to the callback. */ + /* */ + /* <Return> */ + /* 1 if the pixel is `set', 0 otherwise. */ + /* */ + typedef int + (*QT_FT_Raster_BitTest_Func)( int y, + int x, + void* user ); + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* QT_FT_Raster_BitSet_Func */ + /* */ + /* <Description> */ + /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */ + /* */ + /* A function used as a call-back by the monochrome scan-converter */ + /* to set an individual target pixel. This is crucial to implement */ + /* drop-out control according to the TrueType specification. */ + /* */ + /* <Input> */ + /* y :: The pixel's y-coordinate. */ + /* */ + /* x :: The pixel's x-coordinate. */ + /* */ + /* user :: User-supplied data that is passed to the callback. */ + /* */ + /* <Return> */ + /* 1 if the pixel is `set', 0 otherwise. */ + /* */ + typedef void + (*QT_FT_Raster_BitSet_Func)( int y, + int x, + void* user ); + + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* QT_FT_RASTER_FLAG_XXX */ + /* */ + /* <Description> */ + /* A list of bit flag constants as used in the `flags' field of a */ + /* @QT_FT_Raster_Params structure. */ + /* */ + /* <Values> */ + /* QT_FT_RASTER_FLAG_DEFAULT :: This value is 0. */ + /* */ + /* QT_FT_RASTER_FLAG_AA :: This flag is set to indicate that an */ + /* anti-aliased glyph image should be */ + /* generated. Otherwise, it will be */ + /* monochrome (1-bit). */ + /* */ + /* QT_FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */ + /* rendering. In this mode, client */ + /* applications must provide their own span */ + /* callback. This lets them directly */ + /* draw or compose over an existing bitmap. */ + /* If this bit is not set, the target */ + /* pixmap's buffer _must_ be zeroed before */ + /* rendering. */ + /* */ + /* Note that for now, direct rendering is */ + /* only possible with anti-aliased glyphs. */ + /* */ + /* QT_FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ + /* rendering mode. If set, the output will */ + /* be clipped to a box specified in the */ + /* "clip_box" field of the QT_FT_Raster_Params */ + /* structure. */ + /* */ + /* Note that by default, the glyph bitmap */ + /* is clipped to the target pixmap, except */ + /* in direct rendering mode where all spans */ + /* are generated if no clipping box is set. */ + /* */ +#define QT_FT_RASTER_FLAG_DEFAULT 0x0 +#define QT_FT_RASTER_FLAG_AA 0x1 +#define QT_FT_RASTER_FLAG_DIRECT 0x2 +#define QT_FT_RASTER_FLAG_CLIP 0x4 + + /* deprecated */ +#define qt_ft_raster_flag_default QT_FT_RASTER_FLAG_DEFAULT +#define qt_ft_raster_flag_aa QT_FT_RASTER_FLAG_AA +#define qt_ft_raster_flag_direct QT_FT_RASTER_FLAG_DIRECT +#define qt_ft_raster_flag_clip QT_FT_RASTER_FLAG_CLIP + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* QT_FT_Raster_Params */ + /* */ + /* <Description> */ + /* A structure to hold the arguments used by a raster's render */ + /* function. */ + /* */ + /* <Fields> */ + /* target :: The target bitmap. */ + /* */ + /* source :: A pointer to the source glyph image (e.g. an */ + /* QT_FT_Outline). */ + /* */ + /* flags :: The rendering flags. */ + /* */ + /* gray_spans :: The gray span drawing callback. */ + /* */ + /* black_spans :: The black span drawing callback. */ + /* */ + /* bit_test :: The bit test callback. UNIMPLEMENTED! */ + /* */ + /* bit_set :: The bit set callback. UNIMPLEMENTED! */ + /* */ + /* user :: User-supplied data that is passed to each drawing */ + /* callback. */ + /* */ + /* clip_box :: An optional clipping box. It is only used in */ + /* direct rendering mode. Note that coordinates here */ + /* should be expressed in _integer_ pixels (and not in */ + /* 26.6 fixed-point units). */ + /* */ + /* <Note> */ + /* An anti-aliased glyph bitmap is drawn if the QT_FT_RASTER_FLAG_AA bit */ + /* flag is set in the `flags' field, otherwise a monochrome bitmap */ + /* will be generated. */ + /* */ + /* If the QT_FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ + /* raster will call the `gray_spans' callback to draw gray pixel */ + /* spans, in the case of an aa glyph bitmap, it will call */ + /* `black_spans', and `bit_test' and `bit_set' in the case of a */ + /* monochrome bitmap. This allows direct composition over a */ + /* pre-existing bitmap through user-provided callbacks to perform the */ + /* span drawing/composition. */ + /* */ + /* Note that the `bit_test' and `bit_set' callbacks are required when */ + /* rendering a monochrome bitmap, as they are crucial to implement */ + /* correct drop-out control as defined in the TrueType specification. */ + /* */ + typedef struct QT_FT_Raster_Params_ + { + QT_FT_Bitmap* target; + void* source; + int flags; + QT_FT_SpanFunc gray_spans; + QT_FT_SpanFunc black_spans; + QT_FT_Raster_BitTest_Func bit_test; /* doesn't work! */ + QT_FT_Raster_BitSet_Func bit_set; /* doesn't work! */ + void* user; + QT_FT_BBox clip_box; + int skip_spans; + + } QT_FT_Raster_Params; + + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* QT_FT_Raster_NewFunc */ + /* */ + /* <Description> */ + /* A function used to create a new raster object. */ + /* */ + /* <Input> */ + /* memory :: A handle to the memory allocator. */ + /* */ + /* <Output> */ + /* raster :: A handle to the new raster object. */ + /* */ + /* <Return> */ + /* Error code. 0 means success. */ + /* */ + /* <Note> */ + /* The `memory' parameter is a typeless pointer in order to avoid */ + /* un-wanted dependencies on the rest of the FreeType code. In */ + /* practice, it is a QT_FT_Memory, i.e., a handle to the standard */ + /* FreeType memory allocator. However, this field can be completely */ + /* ignored by a given raster implementation. */ + /* */ + typedef int + (*QT_FT_Raster_NewFunc)( QT_FT_Raster* raster ); + +#define QT_FT_Raster_New_Func QT_FT_Raster_NewFunc + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* QT_FT_Raster_DoneFunc */ + /* */ + /* <Description> */ + /* A function used to destroy a given raster object. */ + /* */ + /* <Input> */ + /* raster :: A handle to the raster object. */ + /* */ + typedef void + (*QT_FT_Raster_DoneFunc)( QT_FT_Raster raster ); + +#define QT_FT_Raster_Done_Func QT_FT_Raster_DoneFunc + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* QT_FT_Raster_ResetFunc */ + /* */ + /* <Description> */ + /* FreeType provides an area of memory called the `render pool', */ + /* available to all registered rasters. This pool can be freely used */ + /* during a given scan-conversion but is shared by all rasters. Its */ + /* content is thus transient. */ + /* */ + /* This function is called each time the render pool changes, or just */ + /* after a new raster object is created. */ + /* */ + /* <Input> */ + /* raster :: A handle to the new raster object. */ + /* */ + /* pool_base :: The address in memory of the render pool. */ + /* */ + /* pool_size :: The size in bytes of the render pool. */ + /* */ + /* <Note> */ + /* Rasters can ignore the render pool and rely on dynamic memory */ + /* allocation if they want to (a handle to the memory allocator is */ + /* passed to the raster constructor). However, this is not */ + /* recommended for efficiency purposes. */ + /* */ + typedef void + (*QT_FT_Raster_ResetFunc)( QT_FT_Raster raster, + unsigned char* pool_base, + unsigned long pool_size ); + +#define QT_FT_Raster_Reset_Func QT_FT_Raster_ResetFunc + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* QT_FT_Raster_SetModeFunc */ + /* */ + /* <Description> */ + /* This function is a generic facility to change modes or attributes */ + /* in a given raster. This can be used for debugging purposes, or */ + /* simply to allow implementation-specific `features' in a given */ + /* raster module. */ + /* */ + /* <Input> */ + /* raster :: A handle to the new raster object. */ + /* */ + /* mode :: A 4-byte tag used to name the mode or property. */ + /* */ + /* args :: A pointer to the new mode/property to use. */ + /* */ + typedef int + (*QT_FT_Raster_SetModeFunc)( QT_FT_Raster raster, + unsigned long mode, + void* args ); + +#define QT_FT_Raster_Set_Mode_Func QT_FT_Raster_SetModeFunc + + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* QT_FT_Raster_RenderFunc */ + /* */ + /* <Description> */ + /* Invokes a given raster to scan-convert a given glyph image into a */ + /* target bitmap. */ + /* */ + /* <Input> */ + /* raster :: A handle to the raster object. */ + /* */ + /* params :: A pointer to a QT_FT_Raster_Params structure used to store */ + /* the rendering parameters. */ + /* */ + /* <Return> */ + /* Error code. 0 means success. */ + /* */ + /* <Note> */ + /* The exact format of the source image depends on the raster's glyph */ + /* format defined in its QT_FT_Raster_Funcs structure. It can be an */ + /* QT_FT_Outline or anything else in order to support a large array of */ + /* glyph formats. */ + /* */ + /* Note also that the render function can fail and return a */ + /* QT_FT_Err_Unimplemented_Feature error code if the raster used does */ + /* not support direct composition. */ + /* */ + /* XXX: For now, the standard raster doesn't support direct */ + /* composition but this should change for the final release (see */ + /* the files demos/src/ftgrays.c and demos/src/ftgrays2.c for */ + /* examples of distinct implementations which support direct */ + /* composition). */ + /* */ + typedef int + (*QT_FT_Raster_RenderFunc)( QT_FT_Raster raster, + QT_FT_Raster_Params* params ); + +#define QT_FT_Raster_Render_Func QT_FT_Raster_RenderFunc + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* QT_FT_Raster_Funcs */ + /* */ + /* <Description> */ + /* A structure used to describe a given raster class to the library. */ + /* */ + /* <Fields> */ + /* glyph_format :: The supported glyph format for this raster. */ + /* */ + /* raster_new :: The raster constructor. */ + /* */ + /* raster_reset :: Used to reset the render pool within the raster. */ + /* */ + /* raster_render :: A function to render a glyph into a given bitmap. */ + /* */ + /* raster_done :: The raster destructor. */ + /* */ + typedef struct QT_FT_Raster_Funcs_ + { + QT_FT_Glyph_Format glyph_format; + QT_FT_Raster_NewFunc raster_new; + QT_FT_Raster_ResetFunc raster_reset; + QT_FT_Raster_SetModeFunc raster_set_mode; + QT_FT_Raster_RenderFunc raster_render; + QT_FT_Raster_DoneFunc raster_done; + + } QT_FT_Raster_Funcs; + + + /* */ + + +QT_FT_END_HEADER + +#endif /* __FTIMAGE_H__ */ + + +/* END */ diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrasterizer_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrasterizer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..406c3f73e23873cc85b4ec81c3e7a4bf9e38654d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrasterizer_p.h @@ -0,0 +1,54 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRASTERIZER_P_H +#define QRASTERIZER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qpainter.h" + +#include <private/qdrawhelper_p.h> +#include <private/qrasterdefs_p.h> + +QT_BEGIN_NAMESPACE + +struct QSpanData; +class QRasterBuffer; +class QRasterizerPrivate; + +class +QRasterizer +{ +public: + QRasterizer(); + ~QRasterizer(); + + void setAntialiased(bool antialiased); + void setClipRect(const QRect &clipRect); + + void initialize(ProcessSpans blend, void *data); + + void rasterize(const QT_FT_Outline *outline, Qt::FillRule fillRule); + void rasterize(const QPainterPath &path, Qt::FillRule fillRule); + + // width should be in units of |a-b| + void rasterizeLine(const QPointF &a, const QPointF &b, qreal width, bool squareCap = false); + +private: + QRasterizerPrivate *d; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrawfont_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrawfont_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d3cc9bc5904246524ddd5123fa7fa01b657a6157 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrawfont_p.h @@ -0,0 +1,118 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRAWFONTPRIVATE_P_H +#define QRAWFONTPRIVATE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "qrawfont.h" + +#include "qfontengine_p.h" +#include <QtCore/qthread.h> +#include <QtCore/qthreadstorage.h> + +#if !defined(QT_NO_RAWFONT) + +QT_BEGIN_NAMESPACE + +namespace { class CustomFontFileLoader; } +class Q_GUI_EXPORT QRawFontPrivate +{ +public: + QRawFontPrivate() + : fontEngine(nullptr) + , hintingPreference(QFont::PreferDefaultHinting) + , thread(nullptr) + {} + + QRawFontPrivate(const QRawFontPrivate &other) + : fontEngine(other.fontEngine) + , hintingPreference(other.hintingPreference) + , thread(other.thread) + { +#ifndef QT_NO_DEBUG + Q_ASSERT(fontEngine == nullptr || thread == QThread::currentThread()); +#endif + if (fontEngine != nullptr) + fontEngine->ref.ref(); + } + + ~QRawFontPrivate() + { +#ifndef QT_NO_DEBUG + Q_ASSERT(ref.loadRelaxed() == 0); +#endif + cleanUp(); + } + + inline void cleanUp() + { + setFontEngine(nullptr); + hintingPreference = QFont::PreferDefaultHinting; + } + + inline bool isValid() const + { +#ifndef QT_NO_DEBUG + Q_ASSERT(fontEngine == nullptr || thread == QThread::currentThread()); +#endif + return fontEngine != nullptr; + } + + inline void setFontEngine(QFontEngine *engine) + { +#ifndef QT_NO_DEBUG + Q_ASSERT(fontEngine == nullptr || thread == QThread::currentThread()); +#endif + if (fontEngine == engine) + return; + + if (fontEngine != nullptr) { + if (!fontEngine->ref.deref()) + delete fontEngine; +#ifndef QT_NO_DEBUG + thread = nullptr; +#endif + } + + fontEngine = engine; + + if (fontEngine != nullptr) { + fontEngine->ref.ref(); +#ifndef QT_NO_DEBUG + thread = QThread::currentThread(); + Q_ASSERT(thread); +#endif + } + } + + void loadFromData(const QByteArray &fontData, + qreal pixelSize, + QFont::HintingPreference hintingPreference); + + static QRawFontPrivate *get(const QRawFont &font) { return font.d.data(); } + + QFontEngine *fontEngine; + QFont::HintingPreference hintingPreference; + QAtomicInt ref; + +private: + QThread *thread; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_RAWFONT + +#endif // QRAWFONTPRIVATE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrbtree_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrbtree_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3ac7ae4a1da943d7c512a100448ff3ed9ca01327 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrbtree_p.h @@ -0,0 +1,535 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRBTREE_P_H +#define QRBTREE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> + +QT_BEGIN_NAMESPACE + +template <class T> +struct QRBTree +{ + struct Node + { + inline Node() : parent(nullptr), left(nullptr), right(nullptr), red(true) { } + inline ~Node() {if (left) delete left; if (right) delete right;} + T data; + Node *parent; + Node *left; + Node *right; + bool red; + }; + + inline QRBTree() : root(nullptr), freeList(nullptr) { } + inline ~QRBTree(); + + inline void clear(); + + void attachBefore(Node *parent, Node *child); + void attachAfter(Node *parent, Node *child); + + inline Node *front(Node *node) const; + inline Node *back(Node *node) const; + Node *next(Node *node) const; + Node *previous(Node *node) const; + + inline void deleteNode(Node *&node); + inline Node *newNode(); + + // Return 1 if 'left' comes after 'right', 0 if equal, and -1 otherwise. + // 'left' and 'right' cannot be null. + int order(Node *left, Node *right); + inline bool validate() const; + +private: + void rotateLeft(Node *node); + void rotateRight(Node *node); + void update(Node *node); + + inline void attachLeft(Node *parent, Node *child); + inline void attachRight(Node *parent, Node *child); + + int blackDepth(Node *top) const; + bool checkRedBlackProperty(Node *top) const; + + void swapNodes(Node *n1, Node *n2); + void detach(Node *node); + + // 'node' must be black. rebalance will reduce the depth of black nodes by one in the sibling tree. + void rebalance(Node *node); + +public: + Node *root; +private: + Node *freeList; +}; + +template <class T> +inline QRBTree<T>::~QRBTree() +{ + clear(); + while (freeList) { + // Avoid recursively calling the destructor, as this list may become large. + Node *next = freeList->right; + freeList->right = nullptr; + delete freeList; + freeList = next; + } +} + +template <class T> +inline void QRBTree<T>::clear() +{ + if (root) + delete root; + root = nullptr; +} + +template <class T> +void QRBTree<T>::rotateLeft(Node *node) +{ + // | | // + // N B // + // / \ / \ // + // A B ---> N D // + // / \ / \ // + // C D A C // + + Node *&ref = (node->parent ? (node == node->parent->left ? node->parent->left : node->parent->right) : root); + ref = node->right; + node->right->parent = node->parent; + + // : // + // N // + // / :| // + // A B // + // / \ // + // C D // + + node->right = ref->left; + if (ref->left) + ref->left->parent = node; + + // : | // + // N B // + // / \ : \ // + // A C D // + + ref->left = node; + node->parent = ref; + + // | // + // B // + // / \ // + // N D // + // / \ // + // A C // +} + +template <class T> +void QRBTree<T>::rotateRight(Node *node) +{ + // | | // + // N A // + // / \ / \ // + // A B ---> C N // + // / \ / \ // + // C D D B // + + Node *&ref = (node->parent ? (node == node->parent->left ? node->parent->left : node->parent->right) : root); + ref = node->left; + node->left->parent = node->parent; + + node->left = ref->right; + if (ref->right) + ref->right->parent = node; + + ref->right = node; + node->parent = ref; +} + +template <class T> +void QRBTree<T>::update(Node *node) // call this after inserting a node +{ + for (;;) { + Node *parent = node->parent; + + // if the node is the root, color it black + if (!parent) { + node->red = false; + return; + } + + // if the parent is black, the node can be left red + if (!parent->red) + return; + + // at this point, the parent is red and cannot be the root + Node *grandpa = parent->parent; + Q_ASSERT(grandpa); + + Node *uncle = (parent == grandpa->left ? grandpa->right : grandpa->left); + if (uncle && uncle->red) { + // grandpa's black, parent and uncle are red. + // let parent and uncle be black, grandpa red and recursively update grandpa. + Q_ASSERT(!grandpa->red); + parent->red = false; + uncle->red = false; + grandpa->red = true; + node = grandpa; + continue; + } + + // at this point, uncle is black + if (node == parent->right && parent == grandpa->left) + rotateLeft(node = parent); + else if (node == parent->left && parent == grandpa->right) + rotateRight(node = parent); + parent = node->parent; + + if (parent == grandpa->left) { + rotateRight(grandpa); + parent->red = false; + grandpa->red = true; + } else { + rotateLeft(grandpa); + parent->red = false; + grandpa->red = true; + } + return; + } +} + +template <class T> +inline void QRBTree<T>::attachLeft(Node *parent, Node *child) +{ + Q_ASSERT(!parent->left); + parent->left = child; + child->parent = parent; + update(child); +} + +template <class T> +inline void QRBTree<T>::attachRight(Node *parent, Node *child) +{ + Q_ASSERT(!parent->right); + parent->right = child; + child->parent = parent; + update(child); +} + +template <class T> +void QRBTree<T>::attachBefore(Node *parent, Node *child) +{ + if (!root) + update(root = child); + else if (!parent) + attachRight(back(root), child); + else if (parent->left) + attachRight(back(parent->left), child); + else + attachLeft(parent, child); +} + +template <class T> +void QRBTree<T>::attachAfter(Node *parent, Node *child) +{ + if (!root) + update(root = child); + else if (!parent) + attachLeft(front(root), child); + else if (parent->right) + attachLeft(front(parent->right), child); + else + attachRight(parent, child); +} + +template <class T> +void QRBTree<T>::swapNodes(Node *n1, Node *n2) +{ + // Since iterators must not be invalidated, it is not sufficient to only swap the data. + if (n1->parent == n2) { + n1->parent = n2->parent; + n2->parent = n1; + } else if (n2->parent == n1) { + n2->parent = n1->parent; + n1->parent = n2; + } else { + qSwap(n1->parent, n2->parent); + } + + qSwap(n1->left, n2->left); + qSwap(n1->right, n2->right); + qSwap(n1->red, n2->red); + + if (n1->parent) { + if (n1->parent->left == n2) + n1->parent->left = n1; + else + n1->parent->right = n1; + } else { + root = n1; + } + + if (n2->parent) { + if (n2->parent->left == n1) + n2->parent->left = n2; + else + n2->parent->right = n2; + } else { + root = n2; + } + + if (n1->left) + n1->left->parent = n1; + if (n1->right) + n1->right->parent = n1; + + if (n2->left) + n2->left->parent = n2; + if (n2->right) + n2->right->parent = n2; +} + +template <class T> +void QRBTree<T>::detach(Node *node) // call this before removing a node. +{ + if (node->right) + swapNodes(node, front(node->right)); + + Node *child = (node->left ? node->left : node->right); + + if (!node->red) { + if (child && child->red) + child->red = false; + else + rebalance(node); + } + + Node *&ref = (node->parent ? (node == node->parent->left ? node->parent->left : node->parent->right) : root); + ref = child; + if (child) + child->parent = node->parent; + node->left = node->right = node->parent = nullptr; +} + +// 'node' must be black. rebalance will reduce the depth of black nodes by one in the sibling tree. +template <class T> +void QRBTree<T>::rebalance(Node *node) +{ + Q_ASSERT(!node->red); + for (;;) { + if (!node->parent) + return; + + // at this point, node is not a parent, it is black, thus it must have a sibling. + Node *sibling = (node == node->parent->left ? node->parent->right : node->parent->left); + Q_ASSERT(sibling); + + if (sibling->red) { + sibling->red = false; + node->parent->red = true; + if (node == node->parent->left) + rotateLeft(node->parent); + else + rotateRight(node->parent); + sibling = (node == node->parent->left ? node->parent->right : node->parent->left); + Q_ASSERT(sibling); + } + + // at this point, the sibling is black. + Q_ASSERT(!sibling->red); + + if ((!sibling->left || !sibling->left->red) && (!sibling->right || !sibling->right->red)) { + bool parentWasRed = node->parent->red; + sibling->red = true; + node->parent->red = false; + if (parentWasRed) + return; + node = node->parent; + continue; + } + + // at this point, at least one of the sibling's children is red. + + if (node == node->parent->left) { + if (!sibling->right || !sibling->right->red) { + Q_ASSERT(sibling->left); + sibling->red = true; + sibling->left->red = false; + rotateRight(sibling); + + sibling = sibling->parent; + Q_ASSERT(sibling); + } + sibling->red = node->parent->red; + node->parent->red = false; + + Q_ASSERT(sibling->right->red); + sibling->right->red = false; + rotateLeft(node->parent); + } else { + if (!sibling->left || !sibling->left->red) { + Q_ASSERT(sibling->right); + sibling->red = true; + sibling->right->red = false; + rotateLeft(sibling); + + sibling = sibling->parent; + Q_ASSERT(sibling); + } + sibling->red = node->parent->red; + node->parent->red = false; + + Q_ASSERT(sibling->left->red); + sibling->left->red = false; + rotateRight(node->parent); + } + return; + } +} + +template <class T> +inline typename QRBTree<T>::Node *QRBTree<T>::front(Node *node) const +{ + while (node->left) + node = node->left; + return node; +} + +template <class T> +inline typename QRBTree<T>::Node *QRBTree<T>::back(Node *node) const +{ + while (node->right) + node = node->right; + return node; +} + +template <class T> +typename QRBTree<T>::Node *QRBTree<T>::next(Node *node) const +{ + if (node->right) + return front(node->right); + while (node->parent && node == node->parent->right) + node = node->parent; + return node->parent; +} + +template <class T> +typename QRBTree<T>::Node *QRBTree<T>::previous(Node *node) const +{ + if (node->left) + return back(node->left); + while (node->parent && node == node->parent->left) + node = node->parent; + return node->parent; +} + +template <class T> +int QRBTree<T>::blackDepth(Node *top) const +{ + if (!top) + return 0; + int leftDepth = blackDepth(top->left); + int rightDepth = blackDepth(top->right); + if (leftDepth != rightDepth) + return -1; + if (!top->red) + ++leftDepth; + return leftDepth; +} + +template <class T> +bool QRBTree<T>::checkRedBlackProperty(Node *top) const +{ + if (!top) + return true; + if (top->left && !checkRedBlackProperty(top->left)) + return false; + if (top->right && !checkRedBlackProperty(top->right)) + return false; + return !(top->red && ((top->left && top->left->red) || (top->right && top->right->red))); +} + +template <class T> +inline bool QRBTree<T>::validate() const +{ + return checkRedBlackProperty(root) && blackDepth(root) != -1; +} + +template <class T> +inline void QRBTree<T>::deleteNode(Node *&node) +{ + Q_ASSERT(node); + detach(node); + node->right = freeList; + freeList = node; + node = nullptr; +} + +template <class T> +inline typename QRBTree<T>::Node *QRBTree<T>::newNode() +{ + if (freeList) { + Node *node = freeList; + freeList = freeList->right; + node->parent = node->left = node->right = nullptr; + node->red = true; + return node; + } + return new Node; +} + +// Return 1 if 'left' comes after 'right', 0 if equal, and -1 otherwise. +// 'left' and 'right' cannot be null. +template <class T> +int QRBTree<T>::order(Node *left, Node *right) +{ + Q_ASSERT(left && right); + if (left == right) + return 0; + + QList<Node *> leftAncestors; + QList<Node *> rightAncestors; + while (left) { + leftAncestors.push_back(left); + left = left->parent; + } + while (right) { + rightAncestors.push_back(right); + right = right->parent; + } + Q_ASSERT(leftAncestors.back() == root && rightAncestors.back() == root); + + while (!leftAncestors.empty() && !rightAncestors.empty() && leftAncestors.back() == rightAncestors.back()) { + leftAncestors.pop_back(); + rightAncestors.pop_back(); + } + + if (!leftAncestors.empty()) + return (leftAncestors.back() == leftAncestors.back()->parent->left ? -1 : 1); + + if (!rightAncestors.empty()) + return (rightAncestors.back() == rightAncestors.back()->parent->right ? -1 : 1); + + // The code should never reach this point. + Q_ASSERT(!leftAncestors.empty() || !rightAncestors.empty()); + return 0; +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrgba64_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrgba64_p.h new file mode 100644 index 0000000000000000000000000000000000000000..231bbe83a29d1658e744d2aaf09d4856384a485a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrgba64_p.h @@ -0,0 +1,355 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRGBA64_P_H +#define QRGBA64_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qrgba64.h" +#include "qdrawhelper_p.h" + +#include <QtCore/private/qsimd_p.h> +#include <QtGui/private/qtguiglobal_p.h> + +QT_BEGIN_NAMESPACE + +inline QRgba64 combineAlpha256(QRgba64 rgba64, uint alpha256) +{ + return QRgba64::fromRgba64(rgba64.red(), rgba64.green(), rgba64.blue(), (rgba64.alpha() * alpha256) >> 8); +} + +#if defined(__SSE2__) +static inline __m128i Q_DECL_VECTORCALL multiplyAlpha65535(__m128i rgba64, __m128i va) +{ + __m128i vs = rgba64; + vs = _mm_unpacklo_epi16(_mm_mullo_epi16(vs, va), _mm_mulhi_epu16(vs, va)); + vs = _mm_add_epi32(vs, _mm_srli_epi32(vs, 16)); + vs = _mm_add_epi32(vs, _mm_set1_epi32(0x8000)); + vs = _mm_srai_epi32(vs, 16); + vs = _mm_packs_epi32(vs, vs); + return vs; +} +static inline __m128i Q_DECL_VECTORCALL multiplyAlpha65535(__m128i rgba64, uint alpha65535) +{ + const __m128i va = _mm_shufflelo_epi16(_mm_cvtsi32_si128(alpha65535), _MM_SHUFFLE(0, 0, 0, 0)); + return multiplyAlpha65535(rgba64, va); +} +#elif defined(__ARM_NEON__) +static inline uint16x4_t multiplyAlpha65535(uint16x4_t rgba64, uint16x4_t alpha65535) +{ + uint32x4_t vs32 = vmull_u16(rgba64, alpha65535); // vs = vs * alpha + vs32 = vsraq_n_u32(vs32, vs32, 16); // vs = vs + (vs >> 16) + return vrshrn_n_u32(vs32, 16); // vs = (vs + 0x8000) >> 16 +} +static inline uint16x4_t multiplyAlpha65535(uint16x4_t rgba64, uint alpha65535) +{ + uint32x4_t vs32 = vmull_n_u16(rgba64, alpha65535); // vs = vs * alpha + vs32 = vsraq_n_u32(vs32, vs32, 16); // vs = vs + (vs >> 16) + return vrshrn_n_u32(vs32, 16); // vs = (vs + 0x8000) >> 16 +} +#endif + +static inline QRgba64 multiplyAlpha65535(QRgba64 rgba64, uint alpha65535) +{ +#if defined(__SSE2__) + const __m128i v = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&rgba64)); + const __m128i vr = multiplyAlpha65535(v, alpha65535); + QRgba64 r; + _mm_storel_epi64(reinterpret_cast<__m128i *>(&r), vr); + return r; +#elif defined(__ARM_NEON__) + const uint16x4_t v = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&rgba64))); + const uint16x4_t vr = multiplyAlpha65535(v, alpha65535); + QRgba64 r; + vst1_u64(reinterpret_cast<uint64_t *>(&r), vreinterpret_u64_u16(vr)); + return r; +#else + return QRgba64::fromRgba64(qt_div_65535(rgba64.red() * alpha65535), + qt_div_65535(rgba64.green() * alpha65535), + qt_div_65535(rgba64.blue() * alpha65535), + qt_div_65535(rgba64.alpha() * alpha65535)); +#endif +} + +#if defined(__SSE2__) || defined(__ARM_NEON__) +template<typename T> +static inline T Q_DECL_VECTORCALL multiplyAlpha255(T rgba64, uint alpha255) +{ + return multiplyAlpha65535(rgba64, alpha255 * 257); +} +#else +template<typename T> +static inline T multiplyAlpha255(T rgba64, uint alpha255) +{ + return QRgba64::fromRgba64(qt_div_255(rgba64.red() * alpha255), + qt_div_255(rgba64.green() * alpha255), + qt_div_255(rgba64.blue() * alpha255), + qt_div_255(rgba64.alpha() * alpha255)); +} +#endif + +#if defined __SSE2__ +static inline __m128i Q_DECL_VECTORCALL interpolate255(__m128i x, uint alpha1, __m128i y, uint alpha2) +{ + return _mm_add_epi16(multiplyAlpha255(x, alpha1), multiplyAlpha255(y, alpha2)); +} +#endif + +#if defined __ARM_NEON__ +inline uint16x4_t interpolate255(uint16x4_t x, uint alpha1, uint16x4_t y, uint alpha2) +{ + return vadd_u16(multiplyAlpha255(x, alpha1), multiplyAlpha255(y, alpha2)); +} +#endif + +static inline QRgba64 interpolate255(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2) +{ +#if defined(__SSE2__) + const __m128i vx = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&x)); + const __m128i vy = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&y)); + const __m128i vr = interpolate255(vx, alpha1, vy, alpha2); + QRgba64 r; + _mm_storel_epi64(reinterpret_cast<__m128i *>(&r), vr); + return r; +#elif defined(__ARM_NEON__) + const uint16x4_t vx = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&x))); + const uint16x4_t vy = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&y))); + const uint16x4_t vr = interpolate255(vx, alpha1, vy, alpha2); + QRgba64 r; + vst1_u64(reinterpret_cast<uint64_t *>(&r), vreinterpret_u64_u16(vr)); + return r; +#else + return QRgba64::fromRgba64(multiplyAlpha255(x, alpha1) + multiplyAlpha255(y, alpha2)); +#endif +} + +#if defined __SSE2__ +static inline __m128i Q_DECL_VECTORCALL interpolate65535(__m128i x, uint alpha1, __m128i y, uint alpha2) +{ + return _mm_add_epi16(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2)); +} + +static inline __m128i Q_DECL_VECTORCALL interpolate65535(__m128i x, __m128i alpha1, __m128i y, __m128i alpha2) +{ + return _mm_add_epi16(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2)); +} +#endif + +#if defined __ARM_NEON__ +inline uint16x4_t interpolate65535(uint16x4_t x, uint alpha1, uint16x4_t y, uint alpha2) +{ + return vadd_u16(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2)); +} +inline uint16x4_t interpolate65535(uint16x4_t x, uint16x4_t alpha1, uint16x4_t y, uint16x4_t alpha2) +{ + return vadd_u16(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2)); +} +#endif + +static inline QRgba64 interpolate65535(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2) +{ +#if defined(__SSE2__) + const __m128i vx = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&x)); + const __m128i vy = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&y)); + const __m128i vr = interpolate65535(vx, alpha1, vy, alpha2); + QRgba64 r; + _mm_storel_epi64(reinterpret_cast<__m128i *>(&r), vr); + return r; +#elif defined(__ARM_NEON__) + const uint16x4_t vx = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&x))); + const uint16x4_t vy = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&y))); + const uint16x4_t vr = interpolate65535(vx, alpha1, vy, alpha2); + QRgba64 r; + vst1_u64(reinterpret_cast<uint64_t *>(&r), vreinterpret_u64_u16(vr)); + return r; +#else + return QRgba64::fromRgba64(multiplyAlpha65535(x, alpha1) + multiplyAlpha65535(y, alpha2)); +#endif +} + +static inline QRgba64 addWithSaturation(QRgba64 a, QRgba64 b) +{ +#if defined(__SSE2__) + const __m128i va = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&a)); + const __m128i vb = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&b)); + const __m128i vr = _mm_adds_epu16(va, vb); + QRgba64 r; + _mm_storel_epi64(reinterpret_cast<__m128i *>(&r), vr); + return r; +#elif defined(__ARM_NEON__) + const uint16x4_t va = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&a))); + const uint16x4_t vb = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&b))); + QRgba64 r; + vst1_u64(reinterpret_cast<uint64_t *>(&r), vreinterpret_u64_u16(vqadd_u16(va, vb))); + return r; +#else + + return QRgba64::fromRgba64(qMin(a.red() + b.red(), 65535), + qMin(a.green() + b.green(), 65535), + qMin(a.blue() + b.blue(), 65535), + qMin(a.alpha() + b.alpha(), 65535)); +#endif +} + +#if QT_COMPILER_SUPPORTS_HERE(SSE2) +QT_FUNCTION_TARGET(SSE2) +static inline uint Q_DECL_VECTORCALL toArgb32(__m128i v) +{ + v = _mm_unpacklo_epi16(v, _mm_setzero_si128()); + v = _mm_add_epi32(v, _mm_set1_epi32(128)); + v = _mm_sub_epi32(v, _mm_srli_epi32(v, 8)); + v = _mm_srli_epi32(v, 8); + v = _mm_packs_epi32(v, v); + v = _mm_packus_epi16(v, v); + return _mm_cvtsi128_si32(v); +} +#elif defined __ARM_NEON__ +static inline uint toArgb32(uint16x4_t v) +{ + v = vsub_u16(v, vrshr_n_u16(v, 8)); + v = vrshr_n_u16(v, 8); + uint8x8_t v8 = vmovn_u16(vcombine_u16(v, v)); + return vget_lane_u32(vreinterpret_u32_u8(v8), 0); +} +#endif + +static inline uint toArgb32(QRgba64 rgba64) +{ +#if defined __SSE2__ + __m128i v = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&rgba64)); + v = _mm_shufflelo_epi16(v, _MM_SHUFFLE(3, 0, 1, 2)); + return toArgb32(v); +#elif defined __ARM_NEON__ + uint16x4_t v = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&rgba64))); +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + const uint8x8_t shuffleMask = qvset_n_u8(4, 5, 2, 3, 0, 1, 6, 7); + v = vreinterpret_u16_u8(vtbl1_u8(vreinterpret_u8_u16(v), shuffleMask)); +#else + v = vext_u16(v, v, 3); +#endif + return toArgb32(v); +#else + return rgba64.toArgb32(); +#endif +} + +static inline uint toRgba8888(QRgba64 rgba64) +{ +#if defined __SSE2__ + __m128i v = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&rgba64)); + return toArgb32(v); +#elif defined __ARM_NEON__ + uint16x4_t v = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&rgba64))); + return toArgb32(v); +#else + return ARGB2RGBA(toArgb32(rgba64)); +#endif +} + +static inline QRgba64 rgbBlend(QRgba64 d, QRgba64 s, uint rgbAlpha) +{ + QRgba64 blend; +#if defined(__SSE2__) + __m128i vd = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&d)); + __m128i vs = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&s)); + __m128i va = _mm_cvtsi32_si128(rgbAlpha); + va = _mm_unpacklo_epi8(va, va); + va = _mm_shufflelo_epi16(va, _MM_SHUFFLE(3, 0, 1, 2)); + __m128i vb = _mm_xor_si128(_mm_set1_epi16(-1), va); + + vs = _mm_unpacklo_epi16(_mm_mullo_epi16(vs, va), _mm_mulhi_epu16(vs, va)); + vd = _mm_unpacklo_epi16(_mm_mullo_epi16(vd, vb), _mm_mulhi_epu16(vd, vb)); + vd = _mm_add_epi32(vd, vs); + vd = _mm_add_epi32(vd, _mm_srli_epi32(vd, 16)); + vd = _mm_add_epi32(vd, _mm_set1_epi32(0x8000)); + vd = _mm_srai_epi32(vd, 16); + vd = _mm_packs_epi32(vd, vd); + + _mm_storel_epi64(reinterpret_cast<__m128i *>(&blend), vd); +#elif defined(__ARM_NEON__) + uint16x4_t vd = vreinterpret_u16_u64(vmov_n_u64(d)); + uint16x4_t vs = vreinterpret_u16_u64(vmov_n_u64(s)); + uint8x8_t va8 = vreinterpret_u8_u32(vmov_n_u32(ARGB2RGBA(rgbAlpha))); + uint16x4_t va = vreinterpret_u16_u8(vzip_u8(va8, va8).val[0]); + uint16x4_t vb = veor_u16(vdup_n_u16(0xffff), va); + + uint32x4_t vs32 = vmull_u16(vs, va); + uint32x4_t vd32 = vmull_u16(vd, vb); + vd32 = vaddq_u32(vd32, vs32); + vd32 = vsraq_n_u32(vd32, vd32, 16); + vd = vrshrn_n_u32(vd32, 16); + vst1_u64(reinterpret_cast<uint64_t *>(&blend), vreinterpret_u64_u16(vd)); +#else + const int mr = qRed(rgbAlpha); + const int mg = qGreen(rgbAlpha); + const int mb = qBlue(rgbAlpha); + blend = qRgba64(qt_div_255(s.red() * mr + d.red() * (255 - mr)), + qt_div_255(s.green() * mg + d.green() * (255 - mg)), + qt_div_255(s.blue() * mb + d.blue() * (255 - mb)), + s.alpha()); +#endif + return blend; +} + +static inline void blend_pixel(QRgba64 &dst, QRgba64 src) +{ + if (src.isOpaque()) + dst = src; + else if (!src.isTransparent()) { +#if defined(__SSE2__) + const __m128i vd = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&dst)); + const __m128i vs = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&src)); + const __m128i via = _mm_xor_si128(_mm_set1_epi16(-1), _mm_shufflelo_epi16(vs, _MM_SHUFFLE(3, 3, 3, 3))); + const __m128i vr = _mm_add_epi16(vs, multiplyAlpha65535(vd, via)); + _mm_storel_epi64(reinterpret_cast<__m128i *>(&dst), vr); +#elif defined(__ARM_NEON__) + const uint16x4_t vd = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&dst))); + const uint16x4_t vs = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&src))); + const uint16x4_t via = veor_u16(vdup_n_u16(0xffff), vdup_lane_u16(vs, 3)); + const uint16x4_t vr = vadd_u16(vs, multiplyAlpha65535(vd, via)); + vst1_u64(reinterpret_cast<uint64_t *>(&dst), vreinterpret_u64_u16(vr)); +#else + dst = src + multiplyAlpha65535(dst, 65535 - src.alpha()); +#endif + } +} + +static inline void blend_pixel(QRgba64 &dst, QRgba64 src, const int const_alpha) +{ + if (const_alpha == 255) + return blend_pixel(dst, src); + if (!src.isTransparent()) { +#if defined(__SSE2__) + const __m128i vd = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&dst)); + __m128i vs = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&src)); + vs = multiplyAlpha255(vs, const_alpha); + const __m128i via = _mm_xor_si128(_mm_set1_epi16(-1), _mm_shufflelo_epi16(vs, _MM_SHUFFLE(3, 3, 3, 3))); + const __m128i vr = _mm_add_epi16(vs, multiplyAlpha65535(vd, via)); + _mm_storel_epi64(reinterpret_cast<__m128i *>(&dst), vr); +#elif defined(__ARM_NEON__) + const uint16x4_t vd = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&dst))); + uint16x4_t vs = vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(&src))); + vs = multiplyAlpha255(vs, const_alpha); + const uint16x4_t via = veor_u16(vdup_n_u16(0xffff), vdup_lane_u16(vs, 3)); + const uint16x4_t vr = vadd_u16(vs, multiplyAlpha65535(vd, via)); + vst1_u64(reinterpret_cast<uint64_t *>(&dst), vreinterpret_u64_u16(vr)); +#else + src = multiplyAlpha255(src, const_alpha); + dst = src + multiplyAlpha65535(dst, 65535 - src.alpha()); +#endif + } +} + +QT_END_NAMESPACE + +#endif // QRGBA64_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhi_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhi_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0056028c39bad4059bb13a1c51aec0d823db20e7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhi_p.h @@ -0,0 +1,828 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRHI_P_H +#define QRHI_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <rhi/qrhi.h> +#include <QBitArray> +#include <QAtomicInt> +#include <QElapsedTimer> +#include <QLoggingCategory> +#include <QtCore/qset.h> +#include <QtCore/qvarlengtharray.h> + +QT_BEGIN_NAMESPACE + +#define QRHI_RES(t, x) static_cast<t *>(x) +#define QRHI_RES_RHI(t) t *rhiD = static_cast<t *>(m_rhi) + +Q_DECLARE_LOGGING_CATEGORY(QRHI_LOG_INFO) + +class QRhiImplementation +{ +public: + virtual ~QRhiImplementation(); + + virtual bool create(QRhi::Flags flags) = 0; + virtual void destroy() = 0; + + virtual QRhiGraphicsPipeline *createGraphicsPipeline() = 0; + virtual QRhiComputePipeline *createComputePipeline() = 0; + virtual QRhiShaderResourceBindings *createShaderResourceBindings() = 0; + virtual QRhiBuffer *createBuffer(QRhiBuffer::Type type, + QRhiBuffer::UsageFlags usage, + quint32 size) = 0; + virtual QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type, + const QSize &pixelSize, + int sampleCount, + QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint) = 0; + virtual QRhiTexture *createTexture(QRhiTexture::Format format, + const QSize &pixelSize, + int depth, + int arraySize, + int sampleCount, + QRhiTexture::Flags flags) = 0; + virtual QRhiSampler *createSampler(QRhiSampler::Filter magFilter, + QRhiSampler::Filter minFilter, + QRhiSampler::Filter mipmapMode, + QRhiSampler:: AddressMode u, + QRhiSampler::AddressMode v, + QRhiSampler::AddressMode w) = 0; + + virtual QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, + QRhiTextureRenderTarget::Flags flags) = 0; + + virtual QRhiSwapChain *createSwapChain() = 0; + virtual QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) = 0; + virtual QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) = 0; + virtual QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) = 0; + virtual QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) = 0; + virtual QRhi::FrameOpResult finish() = 0; + + virtual void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) = 0; + + virtual void beginPass(QRhiCommandBuffer *cb, + QRhiRenderTarget *rt, + const QColor &colorClearValue, + const QRhiDepthStencilClearValue &depthStencilClearValue, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) = 0; + virtual void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) = 0; + + virtual void setGraphicsPipeline(QRhiCommandBuffer *cb, + QRhiGraphicsPipeline *ps) = 0; + + virtual void setShaderResources(QRhiCommandBuffer *cb, + QRhiShaderResourceBindings *srb, + int dynamicOffsetCount, + const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) = 0; + + virtual void setVertexInput(QRhiCommandBuffer *cb, + int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, + QRhiBuffer *indexBuf, quint32 indexOffset, + QRhiCommandBuffer::IndexFormat indexFormat) = 0; + + virtual void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) = 0; + virtual void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) = 0; + virtual void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) = 0; + virtual void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) = 0; + + virtual void draw(QRhiCommandBuffer *cb, quint32 vertexCount, + quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) = 0; + virtual void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, + quint32 instanceCount, quint32 firstIndex, + qint32 vertexOffset, quint32 firstInstance) = 0; + + virtual void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) = 0; + virtual void debugMarkEnd(QRhiCommandBuffer *cb) = 0; + virtual void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) = 0; + + virtual void beginComputePass(QRhiCommandBuffer *cb, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) = 0; + virtual void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) = 0; + virtual void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) = 0; + virtual void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) = 0; + + virtual const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) = 0; + virtual void beginExternal(QRhiCommandBuffer *cb) = 0; + virtual void endExternal(QRhiCommandBuffer *cb) = 0; + virtual double lastCompletedGpuTime(QRhiCommandBuffer *cb) = 0; + + virtual QList<int> supportedSampleCounts() const = 0; + virtual int ubufAlignment() const = 0; + virtual bool isYUpInFramebuffer() const = 0; + virtual bool isYUpInNDC() const = 0; + virtual bool isClipDepthZeroToOne() const = 0; + virtual QMatrix4x4 clipSpaceCorrMatrix() const = 0; + virtual bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const = 0; + virtual bool isFeatureSupported(QRhi::Feature feature) const = 0; + virtual int resourceLimit(QRhi::ResourceLimit limit) const = 0; + virtual const QRhiNativeHandles *nativeHandles() = 0; + virtual QRhiDriverInfo driverInfo() const = 0; + virtual QRhiStats statistics() = 0; + virtual bool makeThreadLocalNativeContextCurrent() = 0; + virtual void releaseCachedResources() = 0; + virtual bool isDeviceLost() const = 0; + + virtual QByteArray pipelineCacheData() = 0; + virtual void setPipelineCacheData(const QByteArray &data) = 0; + + void prepareForCreate(QRhi *rhi, QRhi::Implementation impl, QRhi::Flags flags); + + bool isCompressedFormat(QRhiTexture::Format format) const; + void compressedFormatInfo(QRhiTexture::Format format, const QSize &size, + quint32 *bpl, quint32 *byteSize, + QSize *blockDim) const; + void textureFormatInfo(QRhiTexture::Format format, const QSize &size, + quint32 *bpl, quint32 *byteSize, quint32 *bytesPerPixel) const; + bool isStencilSupportingFormat(QRhiTexture::Format format) const; + + void registerResource(QRhiResource *res, bool ownsNativeResources = true) + { + // The ownsNativeResources is relevant for the (graphics resource) leak + // check in ~QRhiImplementation; when false, the registration's sole + // purpose is to automatically null out the resource's m_rhi pointer in + // case the rhi goes away first. (which should not happen in + // well-written applications but we try to be graceful) + resources.insert(res, ownsNativeResources); + } + + void unregisterResource(QRhiResource *res) + { + resources.remove(res); + } + + void addDeleteLater(QRhiResource *res) + { + if (inFrame) + pendingDeleteResources.insert(res); + else + delete res; + } + + void addCleanupCallback(const QRhi::CleanupCallback &callback) + { + cleanupCallbacks.append(callback); + } + + void addCleanupCallback(const void *key, const QRhi::CleanupCallback &callback) + { + keyedCleanupCallbacks[key] = callback; + } + + void removeCleanupCallback(const void *key) + { + keyedCleanupCallbacks.remove(key); + } + + bool sanityCheckGraphicsPipeline(QRhiGraphicsPipeline *ps); + bool sanityCheckShaderResourceBindings(QRhiShaderResourceBindings *srb); + void updateLayoutDesc(QRhiShaderResourceBindings *srb); + + quint32 pipelineCacheRhiId() const + { + const quint32 ver = (QT_VERSION_MAJOR << 16) | (QT_VERSION_MINOR << 8) | (QT_VERSION_PATCH); + return (quint32(implType) << 24) | ver; + } + + void pipelineCreationStart() + { + pipelineCreationTimer.start(); + } + + void pipelineCreationEnd() + { + accumulatedPipelineCreationTime += pipelineCreationTimer.elapsed(); + } + + qint64 totalPipelineCreationTime() const + { + return accumulatedPipelineCreationTime; + } + + QRhiVertexInputAttribute::Format shaderDescVariableFormatToVertexInputFormat(QShaderDescription::VariableType type) const; + quint32 byteSizePerVertexForVertexInputFormat(QRhiVertexInputAttribute::Format format) const; + + static const QRhiShaderResourceBinding::Data *shaderResourceBindingData(const QRhiShaderResourceBinding &binding) + { + return &binding.d; + } + + static QRhiShaderResourceBinding::Data *shaderResourceBindingData(QRhiShaderResourceBinding &binding) + { + return &binding.d; + } + + static bool sortedBindingLessThan(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) + { + return a.d.binding < b.d.binding; + } + + int effectiveSampleCount(int sampleCount) const; + + QRhi *q; + + static const int MAX_SHADER_CACHE_ENTRIES = 128; + + bool debugMarkers = false; + int currentFrameSlot = 0; // for vk, mtl, and similar. unused by gl and d3d11. + bool inFrame = false; + +private: + QRhi::Implementation implType; + QThread *implThread; + QVarLengthArray<QRhiResourceUpdateBatch *, 4> resUpdPool; + quint64 resUpdPoolMap = 0; + int lastResUpdIdx = -1; + QHash<QRhiResource *, bool> resources; + QSet<QRhiResource *> pendingDeleteResources; + QVarLengthArray<QRhi::CleanupCallback, 4> cleanupCallbacks; + QHash<const void *, QRhi::CleanupCallback> keyedCleanupCallbacks; + QElapsedTimer pipelineCreationTimer; + qint64 accumulatedPipelineCreationTime = 0; + static bool rubLogEnabled; + + friend class QRhi; + friend class QRhiResourceUpdateBatchPrivate; + friend class QRhiBufferData; +}; + +enum QRhiTargetRectBoundMode +{ + UnBounded, + Bounded +}; + +template<QRhiTargetRectBoundMode boundingMode, typename T, size_t N> +bool qrhi_toTopLeftRenderTargetRect(const QSize &outputSize, const std::array<T, N> &r, + T *x, T *y, T *w, T *h) +{ + // x,y are bottom-left in QRhiScissor and QRhiViewport but top-left in + // Vulkan/Metal/D3D. Our input is an OpenGL-style scissor rect where both + // negative x or y, and partly or completely out of bounds rects are + // allowed. The only thing the input here cannot have is a negative width + // or height. We must handle all other input gracefully, clamping to a zero + // width or height rect in the worst case, and ensuring the resulting rect + // is inside the rendertarget's bounds because some APIs' validation/debug + // layers are allergic to out of bounds scissor rects. + + const T outputWidth = outputSize.width(); + const T outputHeight = outputSize.height(); + const T inputWidth = r[2]; + const T inputHeight = r[3]; + + if (inputWidth < 0 || inputHeight < 0) + return false; + + *x = r[0]; + *y = outputHeight - (r[1] + inputHeight); + *w = inputWidth; + *h = inputHeight; + + if (boundingMode == Bounded) { + const T widthOffset = *x < 0 ? -*x : 0; + const T heightOffset = *y < 0 ? -*y : 0; + *w = *x < outputWidth ? qMax<T>(0, inputWidth - widthOffset) : 0; + *h = *y < outputHeight ? qMax<T>(0, inputHeight - heightOffset) : 0; + + if (outputWidth > 0) + *x = qBound<T>(0, *x, outputWidth - 1); + if (outputHeight > 0) + *y = qBound<T>(0, *y, outputHeight - 1); + + if (*x + *w > outputWidth) + *w = qMax<T>(0, outputWidth - *x); + if (*y + *h > outputHeight) + *h = qMax<T>(0, outputHeight - *y); + } + return true; +} + +struct QRhiBufferDataPrivate +{ + Q_DISABLE_COPY_MOVE(QRhiBufferDataPrivate) + QRhiBufferDataPrivate() { } + ~QRhiBufferDataPrivate() { delete[] largeData; } + int ref = 1; + quint32 size = 0; + quint32 largeAlloc = 0; + char *largeData = nullptr; + static constexpr quint32 SMALL_DATA_SIZE = 1024; + char data[SMALL_DATA_SIZE]; +}; + +// no detach-with-contents, no atomic refcount, no shrink +class QRhiBufferData +{ +public: + QRhiBufferData() = default; + ~QRhiBufferData() + { + if (d && !--d->ref) + delete d; + } + QRhiBufferData(const QRhiBufferData &other) + : d(other.d) + { + if (d) + d->ref += 1; + } + QRhiBufferData &operator=(const QRhiBufferData &other) + { + if (d == other.d) + return *this; + if (other.d) + other.d->ref += 1; + if (d && !--d->ref) + delete d; + d = other.d; + return *this; + } + const char *constData() const + { + return d ? (d->size <= QRhiBufferDataPrivate::SMALL_DATA_SIZE ? d->data : d->largeData) : nullptr; + } + quint32 size() const + { + return d ? d->size : 0; + } + quint32 largeAlloc() const + { + return d ? d->largeAlloc : 0; + } + void assign(const char *s, quint32 size) + { + if (!d) { + d = new QRhiBufferDataPrivate; + } else if (d->ref != 1) { + if (QRhiImplementation::rubLogEnabled) + qDebug("[rub] QRhiBufferData %p/%p new backing due to no-copy detach, ref was %d", this, d, d->ref); + d->ref -= 1; + d = new QRhiBufferDataPrivate; + } + d->size = size; + if (size <= QRhiBufferDataPrivate::SMALL_DATA_SIZE) { + memcpy(d->data, s, size); + } else { + if (d->largeAlloc < size) { + if (QRhiImplementation::rubLogEnabled) + qDebug("[rub] QRhiBufferData %p/%p new large data allocation %u -> %u", this, d, d->largeAlloc, size); + delete[] d->largeData; + d->largeAlloc = size; + d->largeData = new char[size]; + } + memcpy(d->largeData, s, size); + } + } +private: + QRhiBufferDataPrivate *d = nullptr; +}; + +Q_DECLARE_TYPEINFO(QRhiBufferData, Q_RELOCATABLE_TYPE); + +class QRhiResourceUpdateBatchPrivate +{ +public: + struct BufferOp { + enum Type { + DynamicUpdate, + StaticUpload, + Read + }; + Type type; + QRhiBuffer *buf; + quint32 offset; + QRhiBufferData data; + quint32 readSize; + QRhiReadbackResult *result; + + static BufferOp dynamicUpdate(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data) + { + BufferOp op = {}; + op.type = DynamicUpdate; + op.buf = buf; + op.offset = offset; + const int effectiveSize = size ? size : buf->size(); + op.data.assign(reinterpret_cast<const char *>(data), effectiveSize); + return op; + } + + static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data) + { + op->type = DynamicUpdate; + op->buf = buf; + op->offset = offset; + const int effectiveSize = size ? size : buf->size(); + op->data.assign(reinterpret_cast<const char *>(data), effectiveSize); + } + + static BufferOp staticUpload(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data) + { + BufferOp op = {}; + op.type = StaticUpload; + op.buf = buf; + op.offset = offset; + const int effectiveSize = size ? size : buf->size(); + op.data.assign(reinterpret_cast<const char *>(data), effectiveSize); + return op; + } + + static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data) + { + op->type = StaticUpload; + op->buf = buf; + op->offset = offset; + const int effectiveSize = size ? size : buf->size(); + op->data.assign(reinterpret_cast<const char *>(data), effectiveSize); + } + + static BufferOp read(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result) + { + BufferOp op = {}; + op.type = Read; + op.buf = buf; + op.offset = offset; + op.readSize = size; + op.result = result; + return op; + } + }; + + struct TextureOp { + enum Type { + Upload, + Copy, + Read, + GenMips + }; + Type type; + QRhiTexture *dst; + // Specifying multiple uploads for a subresource must be supported. + // In the backend this can then end up, where applicable, as a + // single, batched copy operation with only one set of barriers. + // This helps when doing for example glyph cache fills. + using MipLevelUploadList = std::array<QVector<QRhiTextureSubresourceUploadDescription>, QRhi::MAX_MIP_LEVELS>; + QVarLengthArray<MipLevelUploadList, 6> subresDesc; + QRhiTexture *src; + QRhiTextureCopyDescription desc; + QRhiReadbackDescription rb; + QRhiReadbackResult *result; + + static TextureOp upload(QRhiTexture *tex, const QRhiTextureUploadDescription &desc) + { + TextureOp op = {}; + op.type = Upload; + op.dst = tex; + int maxLayer = -1; + for (auto it = desc.cbeginEntries(), itEnd = desc.cendEntries(); it != itEnd; ++it) { + if (it->layer() > maxLayer) + maxLayer = it->layer(); + } + op.subresDesc.resize(maxLayer + 1); + for (auto it = desc.cbeginEntries(), itEnd = desc.cendEntries(); it != itEnd; ++it) + op.subresDesc[it->layer()][it->level()].append(it->description()); + return op; + } + + static TextureOp copy(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc) + { + TextureOp op = {}; + op.type = Copy; + op.dst = dst; + op.src = src; + op.desc = desc; + return op; + } + + static TextureOp read(const QRhiReadbackDescription &rb, QRhiReadbackResult *result) + { + TextureOp op = {}; + op.type = Read; + op.rb = rb; + op.result = result; + return op; + } + + static TextureOp genMips(QRhiTexture *tex) + { + TextureOp op = {}; + op.type = GenMips; + op.dst = tex; + return op; + } + }; + + int activeBufferOpCount = 0; // this is the real number of used elements in bufferOps, not bufferOps.count() + static const int BUFFER_OPS_STATIC_ALLOC = 64; + QVarLengthArray<BufferOp, BUFFER_OPS_STATIC_ALLOC> bufferOps; + + int activeTextureOpCount = 0; // this is the real number of used elements in textureOps, not textureOps.count() + static const int TEXTURE_OPS_STATIC_ALLOC = 32; + QVarLengthArray<TextureOp, TEXTURE_OPS_STATIC_ALLOC> textureOps; + + QRhiResourceUpdateBatch *q = nullptr; + QRhiImplementation *rhi = nullptr; + int poolIndex = -1; + + void free(); + void merge(QRhiResourceUpdateBatchPrivate *other); + bool hasOptimalCapacity() const; + void trimOpLists(); + + static QRhiResourceUpdateBatchPrivate *get(QRhiResourceUpdateBatch *b) { return b->d; } +}; + +template<typename T> +struct QRhiBatchedBindings +{ + void feed(int binding, T resource) { // binding must be strictly increasing + if (curBinding == -1 || binding > curBinding + 1) { + finish(); + curBatch.startBinding = binding; + curBatch.resources.clear(); + curBatch.resources.append(resource); + } else { + Q_ASSERT(binding == curBinding + 1); + curBatch.resources.append(resource); + } + curBinding = binding; + } + + bool finish() { + if (!curBatch.resources.isEmpty()) + batches.append(curBatch); + return !batches.isEmpty(); + } + + void clear() { + batches.clear(); + curBatch.resources.clear(); + curBinding = -1; + } + + struct Batch { + uint startBinding; + QVarLengthArray<T, 4> resources; + + bool operator==(const Batch &other) const + { + return startBinding == other.startBinding && resources == other.resources; + } + + bool operator!=(const Batch &other) const + { + return !operator==(other); + } + }; + + QVarLengthArray<Batch, 4> batches; // sorted by startBinding + + bool operator==(const QRhiBatchedBindings<T> &other) const + { + return batches == other.batches; + } + + bool operator!=(const QRhiBatchedBindings<T> &other) const + { + return !operator==(other); + } + +private: + Batch curBatch; + int curBinding = -1; +}; + +class QRhiGlobalObjectIdGenerator +{ +public: +#ifdef Q_ATOMIC_INT64_IS_SUPPORTED + using Type = quint64; +#else + using Type = quint32; +#endif + static Type newId(); +}; + +class QRhiPassResourceTracker +{ +public: + bool isEmpty() const; + void reset(); + + struct UsageState { + int layout; + int access; + int stage; + }; + + enum BufferStage { + BufVertexInputStage, + BufVertexStage, + BufTCStage, + BufTEStage, + BufFragmentStage, + BufComputeStage, + BufGeometryStage + }; + + enum BufferAccess { + BufVertexInput, + BufIndexRead, + BufUniformRead, + BufStorageLoad, + BufStorageStore, + BufStorageLoadStore + }; + + void registerBuffer(QRhiBuffer *buf, int slot, BufferAccess *access, BufferStage *stage, + const UsageState &state); + + enum TextureStage { + TexVertexStage, + TexTCStage, + TexTEStage, + TexFragmentStage, + TexColorOutputStage, + TexDepthOutputStage, + TexComputeStage, + TexGeometryStage + }; + + enum TextureAccess { + TexSample, + TexColorOutput, + TexDepthOutput, + TexStorageLoad, + TexStorageStore, + TexStorageLoadStore + }; + + void registerTexture(QRhiTexture *tex, TextureAccess *access, TextureStage *stage, + const UsageState &state); + + struct Buffer { + int slot; + BufferAccess access; + BufferStage stage; + UsageState stateAtPassBegin; + }; + + using BufferIterator = QHash<QRhiBuffer *, Buffer>::const_iterator; + BufferIterator cbeginBuffers() const { return m_buffers.cbegin(); } + BufferIterator cendBuffers() const { return m_buffers.cend(); } + + struct Texture { + TextureAccess access; + TextureStage stage; + UsageState stateAtPassBegin; + }; + + using TextureIterator = QHash<QRhiTexture *, Texture>::const_iterator; + TextureIterator cbeginTextures() const { return m_textures.cbegin(); } + TextureIterator cendTextures() const { return m_textures.cend(); } + + static BufferStage toPassTrackerBufferStage(QRhiShaderResourceBinding::StageFlags stages); + static TextureStage toPassTrackerTextureStage(QRhiShaderResourceBinding::StageFlags stages); + +private: + QHash<QRhiBuffer *, Buffer> m_buffers; + QHash<QRhiTexture *, Texture> m_textures; +}; + +Q_DECLARE_TYPEINFO(QRhiPassResourceTracker::Buffer, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QRhiPassResourceTracker::Texture, Q_RELOCATABLE_TYPE); + +template<typename T, int GROW = 1024> +class QRhiBackendCommandList +{ +public: + QRhiBackendCommandList() = default; + ~QRhiBackendCommandList() { delete[] v; } + inline void reset() { p = 0; } + inline bool isEmpty() const { return p == 0; } + inline T &get() { + if (p == a) { + a += GROW; + T *nv = new T[a]; + if (v) { + memcpy(nv, v, p * sizeof(T)); + delete[] v; + } + v = nv; + } + return v[p++]; + } + inline void unget() { --p; } + inline T *cbegin() const { return v; } + inline T *cend() const { return v + p; } + inline T *begin() { return v; } + inline T *end() { return v + p; } +private: + Q_DISABLE_COPY(QRhiBackendCommandList) + T *v = nullptr; + int a = 0; + int p = 0; +}; + +struct QRhiRenderTargetAttachmentTracker +{ + struct ResId { quint64 id; uint generation; }; + using ResIdList = QVarLengthArray<ResId, 8 * 2 + 1>; // color, resolve, ds + + template<typename TexType, typename RenderBufferType> + static void updateResIdList(const QRhiTextureRenderTargetDescription &desc, ResIdList *dst); + + template<typename TexType, typename RenderBufferType> + static bool isUpToDate(const QRhiTextureRenderTargetDescription &desc, const ResIdList ¤tResIdList); +}; + +inline bool operator==(const QRhiRenderTargetAttachmentTracker::ResId &a, const QRhiRenderTargetAttachmentTracker::ResId &b) +{ + return a.id == b.id && a.generation == b.generation; +} + +inline bool operator!=(const QRhiRenderTargetAttachmentTracker::ResId &a, const QRhiRenderTargetAttachmentTracker::ResId &b) +{ + return !(a == b); +} + +template<typename TexType, typename RenderBufferType> +void QRhiRenderTargetAttachmentTracker::updateResIdList(const QRhiTextureRenderTargetDescription &desc, ResIdList *dst) +{ + const bool hasDepthStencil = desc.depthStencilBuffer() || desc.depthTexture(); + dst->resize(desc.colorAttachmentCount() * 2 + (hasDepthStencil ? 1 : 0)); + int n = 0; + for (auto it = desc.cbeginColorAttachments(), itEnd = desc.cendColorAttachments(); it != itEnd; ++it, ++n) { + const QRhiColorAttachment &colorAtt(*it); + if (colorAtt.texture()) { + TexType *texD = QRHI_RES(TexType, colorAtt.texture()); + (*dst)[n] = { texD->globalResourceId(), texD->generation }; + } else if (colorAtt.renderBuffer()) { + RenderBufferType *rbD = QRHI_RES(RenderBufferType, colorAtt.renderBuffer()); + (*dst)[n] = { rbD->globalResourceId(), rbD->generation }; + } else { + (*dst)[n] = { 0, 0 }; + } + ++n; + if (colorAtt.resolveTexture()) { + TexType *texD = QRHI_RES(TexType, colorAtt.resolveTexture()); + (*dst)[n] = { texD->globalResourceId(), texD->generation }; + } else { + (*dst)[n] = { 0, 0 }; + } + } + if (hasDepthStencil) { + if (desc.depthTexture()) { + TexType *depthTexD = QRHI_RES(TexType, desc.depthTexture()); + (*dst)[n] = { depthTexD->globalResourceId(), depthTexD->generation }; + } else if (desc.depthStencilBuffer()) { + RenderBufferType *depthRbD = QRHI_RES(RenderBufferType, desc.depthStencilBuffer()); + (*dst)[n] = { depthRbD->globalResourceId(), depthRbD->generation }; + } else { + (*dst)[n] = { 0, 0 }; + } + } +} + +template<typename TexType, typename RenderBufferType> +bool QRhiRenderTargetAttachmentTracker::isUpToDate(const QRhiTextureRenderTargetDescription &desc, const ResIdList ¤tResIdList) +{ + // Just as setShaderResources() recognizes if an srb's referenced + // resources have been rebuilt (got a create() since the srb's + // create()), we should do the same for the textures and renderbuffers + // referenced from the rendertarget. It is not uncommon that a texture + // or ds buffer gets resized due to following a window size in some + // form, which involves a create() on them. It is then nice if the + // render target auto-rebuilds in beginPass(). + + ResIdList resIdList; + updateResIdList<TexType, RenderBufferType>(desc, &resIdList); + return resIdList == currentResIdList; +} + +template<typename T> +inline T *qrhi_objectFromProxyData(QRhiSwapChainProxyData *pd, QWindow *window, QRhi::Implementation impl, uint objectIndex) +{ + Q_ASSERT(objectIndex < std::size(pd->reserved)); + if (!pd->reserved[objectIndex]) // // was not set, no other choice, do it here, whatever thread this is + *pd = QRhi::updateSwapChainProxyData(impl, window); + return static_cast<T *>(pd->reserved[objectIndex]); +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhid3d11_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhid3d11_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d7a201165f104fa34922549d1649e413b6dc1c82 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhid3d11_p.h @@ -0,0 +1,868 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRHID3D11_P_H +#define QRHID3D11_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qrhi_p.h" +#include <rhi/qshaderdescription.h> +#include <QWindow> + +#include <d3d11_1.h> +#include <dxgi1_6.h> +#include <dcomp.h> + +QT_BEGIN_NAMESPACE + +class QRhiD3D11; + +struct QD3D11Buffer : public QRhiBuffer +{ + QD3D11Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size); + ~QD3D11Buffer(); + void destroy() override; + bool create() override; + QRhiBuffer::NativeBuffer nativeBuffer() override; + char *beginFullDynamicBufferUpdateForCurrentFrame() override; + void endFullDynamicBufferUpdateForCurrentFrame() override; + + ID3D11UnorderedAccessView *unorderedAccessView(quint32 offset); + + ID3D11Buffer *buffer = nullptr; + char *dynBuf = nullptr; + bool hasPendingDynamicUpdates = false; + QHash<quint32, ID3D11UnorderedAccessView *> uavs; + uint generation = 0; + friend class QRhiD3D11; +}; + +struct QD3D11RenderBuffer : public QRhiRenderBuffer +{ + QD3D11RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, + int sampleCount, QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint); + ~QD3D11RenderBuffer(); + void destroy() override; + bool create() override; + QRhiTexture::Format backingFormat() const override; + + ID3D11Texture2D *tex = nullptr; + ID3D11DepthStencilView *dsv = nullptr; + ID3D11RenderTargetView *rtv = nullptr; + DXGI_FORMAT dxgiFormat; + DXGI_SAMPLE_DESC sampleDesc; + uint generation = 0; + friend class QRhiD3D11; +}; + +struct QD3D11Texture : public QRhiTexture +{ + QD3D11Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, + int arraySize, int sampleCount, Flags flags); + ~QD3D11Texture(); + void destroy() override; + bool create() override; + bool createFrom(NativeTexture src) override; + NativeTexture nativeTexture() override; + + bool prepareCreate(QSize *adjustedSize = nullptr); + bool finishCreate(); + ID3D11UnorderedAccessView *unorderedAccessViewForLevel(int level); + ID3D11Resource *textureResource() const + { + if (tex) + return tex; + else if (tex1D) + return tex1D; + return tex3D; + } + + ID3D11Texture2D *tex = nullptr; + ID3D11Texture3D *tex3D = nullptr; + ID3D11Texture1D *tex1D = nullptr; + bool owns = true; + ID3D11ShaderResourceView *srv = nullptr; + DXGI_FORMAT dxgiFormat; + uint mipLevelCount = 0; + DXGI_SAMPLE_DESC sampleDesc; + ID3D11UnorderedAccessView *perLevelViews[QRhi::MAX_MIP_LEVELS]; + uint generation = 0; + friend class QRhiD3D11; +}; + +struct QD3D11Sampler : public QRhiSampler +{ + QD3D11Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, + AddressMode u, AddressMode v, AddressMode w); + ~QD3D11Sampler(); + void destroy() override; + bool create() override; + + ID3D11SamplerState *samplerState = nullptr; + uint generation = 0; + friend class QRhiD3D11; +}; + +struct QD3D11RenderPassDescriptor : public QRhiRenderPassDescriptor +{ + QD3D11RenderPassDescriptor(QRhiImplementation *rhi); + ~QD3D11RenderPassDescriptor(); + void destroy() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() const override; + QVector<quint32> serializedFormat() const override; +}; + +struct QD3D11RenderTargetData +{ + QD3D11RenderTargetData(QRhiImplementation *) + { + for (int i = 0; i < MAX_COLOR_ATTACHMENTS; ++i) + rtv[i] = nullptr; + } + + QD3D11RenderPassDescriptor *rp = nullptr; + QSize pixelSize; + float dpr = 1; + int sampleCount = 1; + int colorAttCount = 0; + int dsAttCount = 0; + + static const int MAX_COLOR_ATTACHMENTS = 8; + ID3D11RenderTargetView *rtv[MAX_COLOR_ATTACHMENTS]; + ID3D11DepthStencilView *dsv = nullptr; + + QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList; +}; + +struct QD3D11SwapChainRenderTarget : public QRhiSwapChainRenderTarget +{ + QD3D11SwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain); + ~QD3D11SwapChainRenderTarget(); + void destroy() override; + + QSize pixelSize() const override; + float devicePixelRatio() const override; + int sampleCount() const override; + + QD3D11RenderTargetData d; +}; + +struct QD3D11TextureRenderTarget : public QRhiTextureRenderTarget +{ + QD3D11TextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags); + ~QD3D11TextureRenderTarget(); + void destroy() override; + + QSize pixelSize() const override; + float devicePixelRatio() const override; + int sampleCount() const override; + + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; + bool create() override; + + QD3D11RenderTargetData d; + bool ownsRtv[QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS]; + ID3D11RenderTargetView *rtv[QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS]; + bool ownsDsv = false; + ID3D11DepthStencilView *dsv = nullptr; + friend class QRhiD3D11; +}; + +struct QD3D11ShaderResourceBindings : public QRhiShaderResourceBindings +{ + QD3D11ShaderResourceBindings(QRhiImplementation *rhi); + ~QD3D11ShaderResourceBindings(); + void destroy() override; + bool create() override; + void updateResources(UpdateFlags flags) override; + + bool hasDynamicOffset = false; + QVarLengthArray<QRhiShaderResourceBinding, 8> sortedBindings; + uint generation = 0; + + // Keep track of the generation number of each referenced QRhi* to be able + // to detect that the batched bindings are out of date. + struct BoundUniformBufferData { + quint64 id; + uint generation; + }; + struct BoundSampledTextureData { + int count; + struct { + quint64 texId; + uint texGeneration; + quint64 samplerId; + uint samplerGeneration; + } d[QRhiShaderResourceBinding::Data::MAX_TEX_SAMPLER_ARRAY_SIZE]; + }; + struct BoundStorageImageData { + quint64 id; + uint generation; + }; + struct BoundStorageBufferData { + quint64 id; + uint generation; + }; + struct BoundResourceData { + union { + BoundUniformBufferData ubuf; + BoundSampledTextureData stex; + BoundStorageImageData simage; + BoundStorageBufferData sbuf; + }; + }; + QVarLengthArray<BoundResourceData, 8> boundResourceData; + + struct StageUniformBufferBatches { + bool present = false; + QRhiBatchedBindings<ID3D11Buffer *> ubufs; + QRhiBatchedBindings<UINT> ubuforigbindings; + QRhiBatchedBindings<UINT> ubufoffsets; + QRhiBatchedBindings<UINT> ubufsizes; + void finish() { + present = ubufs.finish(); + ubuforigbindings.finish(); + ubufoffsets.finish(); + ubufsizes.finish(); + } + void clear() { + ubufs.clear(); + ubuforigbindings.clear(); + ubufoffsets.clear(); + ubufsizes.clear(); + } + }; + + struct StageSamplerBatches { + bool present = false; + QRhiBatchedBindings<ID3D11SamplerState *> samplers; + QRhiBatchedBindings<ID3D11ShaderResourceView *> shaderresources; + void finish() { + present = samplers.finish(); + shaderresources.finish(); + } + void clear() { + samplers.clear(); + shaderresources.clear(); + } + }; + + struct StageUavBatches { + bool present = false; + QRhiBatchedBindings<ID3D11UnorderedAccessView *> uavs; + void finish() { + present = uavs.finish(); + } + void clear() { + uavs.clear(); + } + }; + + StageUniformBufferBatches vsUniformBufferBatches; + StageUniformBufferBatches hsUniformBufferBatches; + StageUniformBufferBatches dsUniformBufferBatches; + StageUniformBufferBatches gsUniformBufferBatches; + StageUniformBufferBatches fsUniformBufferBatches; + StageUniformBufferBatches csUniformBufferBatches; + + StageSamplerBatches vsSamplerBatches; + StageSamplerBatches hsSamplerBatches; + StageSamplerBatches dsSamplerBatches; + StageSamplerBatches gsSamplerBatches; + StageSamplerBatches fsSamplerBatches; + StageSamplerBatches csSamplerBatches; + + StageUavBatches csUavBatches; + + friend class QRhiD3D11; +}; + +Q_DECLARE_TYPEINFO(QD3D11ShaderResourceBindings::BoundResourceData, Q_RELOCATABLE_TYPE); + +struct QD3D11GraphicsPipeline : public QRhiGraphicsPipeline +{ + QD3D11GraphicsPipeline(QRhiImplementation *rhi); + ~QD3D11GraphicsPipeline(); + void destroy() override; + bool create() override; + + ID3D11DepthStencilState *dsState = nullptr; + ID3D11BlendState *blendState = nullptr; + struct { + ID3D11VertexShader *shader = nullptr; + QShader::NativeResourceBindingMap nativeResourceBindingMap; + } vs; + struct { + ID3D11HullShader *shader = nullptr; + QShader::NativeResourceBindingMap nativeResourceBindingMap; + } hs; + struct { + ID3D11DomainShader *shader = nullptr; + QShader::NativeResourceBindingMap nativeResourceBindingMap; + } ds; + struct { + ID3D11GeometryShader *shader = nullptr; + QShader::NativeResourceBindingMap nativeResourceBindingMap; + } gs; + struct { + ID3D11PixelShader *shader = nullptr; + QShader::NativeResourceBindingMap nativeResourceBindingMap; + } fs; + ID3D11InputLayout *inputLayout = nullptr; + D3D11_PRIMITIVE_TOPOLOGY d3dTopology = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + ID3D11RasterizerState *rastState = nullptr; + uint generation = 0; + friend class QRhiD3D11; +}; + +struct QD3D11ComputePipeline : public QRhiComputePipeline +{ + QD3D11ComputePipeline(QRhiImplementation *rhi); + ~QD3D11ComputePipeline(); + void destroy() override; + bool create() override; + + struct { + ID3D11ComputeShader *shader = nullptr; + QShader::NativeResourceBindingMap nativeResourceBindingMap; + } cs; + uint generation = 0; + friend class QRhiD3D11; +}; + +struct QD3D11SwapChain; + +struct QD3D11CommandBuffer : public QRhiCommandBuffer +{ + QD3D11CommandBuffer(QRhiImplementation *rhi); + ~QD3D11CommandBuffer(); + void destroy() override; + + // these must be kept at a reasonably low value otherwise sizeof Command explodes + static const int MAX_DYNAMIC_OFFSET_COUNT = 8; + static const int MAX_VERTEX_BUFFER_BINDING_COUNT = 8; + + struct Command { + enum Cmd { + BeginFrame, + EndFrame, + ResetShaderResources, + SetRenderTarget, + Clear, + Viewport, + Scissor, + BindVertexBuffers, + BindIndexBuffer, + BindGraphicsPipeline, + BindShaderResources, + StencilRef, + BlendConstants, + Draw, + DrawIndexed, + UpdateSubRes, + CopySubRes, + ResolveSubRes, + GenMip, + DebugMarkBegin, + DebugMarkEnd, + DebugMarkMsg, + BindComputePipeline, + Dispatch + }; + enum ClearFlag { Color = 1, Depth = 2, Stencil = 4 }; + Cmd cmd; + + // QRhi*/QD3D11* references should be kept at minimum (so no + // QRhiTexture/Buffer/etc. pointers). + union Args { + struct { + ID3D11Query *tsQuery; + ID3D11Query *tsDisjointQuery; + QD3D11RenderTargetData *swapchainData; + } beginFrame; + struct { + ID3D11Query *tsQuery; + ID3D11Query *tsDisjointQuery; + } endFrame; + struct { + QRhiRenderTarget *rt; + } setRenderTarget; + struct { + QRhiRenderTarget *rt; + int mask; + float c[4]; + float d; + quint32 s; + } clear; + struct { + float x, y, w, h; + float d0, d1; + } viewport; + struct { + int x, y, w, h; + } scissor; + struct { + int startSlot; + int slotCount; + ID3D11Buffer *buffers[MAX_VERTEX_BUFFER_BINDING_COUNT]; + UINT offsets[MAX_VERTEX_BUFFER_BINDING_COUNT]; + UINT strides[MAX_VERTEX_BUFFER_BINDING_COUNT]; + } bindVertexBuffers; + struct { + ID3D11Buffer *buffer; + quint32 offset; + DXGI_FORMAT format; + } bindIndexBuffer; + struct { + QD3D11GraphicsPipeline *ps; + } bindGraphicsPipeline; + struct { + QD3D11ShaderResourceBindings *srb; + bool offsetOnlyChange; + int dynamicOffsetCount; + uint dynamicOffsetPairs[MAX_DYNAMIC_OFFSET_COUNT * 2]; // binding, offsetInConstants + } bindShaderResources; + struct { + QD3D11GraphicsPipeline *ps; + quint32 ref; + } stencilRef; + struct { + QD3D11GraphicsPipeline *ps; + float c[4]; + } blendConstants; + struct { + QD3D11GraphicsPipeline *ps; + quint32 vertexCount; + quint32 instanceCount; + quint32 firstVertex; + quint32 firstInstance; + } draw; + struct { + QD3D11GraphicsPipeline *ps; + quint32 indexCount; + quint32 instanceCount; + quint32 firstIndex; + qint32 vertexOffset; + quint32 firstInstance; + } drawIndexed; + struct { + ID3D11Resource *dst; + UINT dstSubRes; + bool hasDstBox; + D3D11_BOX dstBox; + const void *src; // must come from retain*() + UINT srcRowPitch; + } updateSubRes; + struct { + ID3D11Resource *dst; + UINT dstSubRes; + UINT dstX; + UINT dstY; + UINT dstZ; + ID3D11Resource *src; + UINT srcSubRes; + bool hasSrcBox; + D3D11_BOX srcBox; + } copySubRes; + struct { + ID3D11Resource *dst; + UINT dstSubRes; + ID3D11Resource *src; + UINT srcSubRes; + DXGI_FORMAT format; + } resolveSubRes; + struct { + ID3D11ShaderResourceView *srv; + } genMip; + struct { + char s[64]; + } debugMark; + struct { + QD3D11ComputePipeline *ps; + } bindComputePipeline; + struct { + UINT x; + UINT y; + UINT z; + } dispatch; + } args; + }; + + enum PassType { + NoPass, + RenderPass, + ComputePass + }; + + QRhiBackendCommandList<Command> commands; + PassType recordingPass; + double lastGpuTime = 0; + QRhiRenderTarget *currentTarget; + QRhiGraphicsPipeline *currentGraphicsPipeline; + QRhiComputePipeline *currentComputePipeline; + uint currentPipelineGeneration; + QRhiShaderResourceBindings *currentGraphicsSrb; + QRhiShaderResourceBindings *currentComputeSrb; + uint currentSrbGeneration; + ID3D11Buffer *currentIndexBuffer; + quint32 currentIndexOffset; + DXGI_FORMAT currentIndexFormat; + ID3D11Buffer *currentVertexBuffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; + quint32 currentVertexOffsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; + + QVarLengthArray<QByteArray, 4> dataRetainPool; + QVarLengthArray<QRhiBufferData, 4> bufferDataRetainPool; + QVarLengthArray<QImage, 4> imageRetainPool; + + // relies heavily on implicit sharing (no copies of the actual data will be made) + const uchar *retainData(const QByteArray &data) { + dataRetainPool.append(data); + return reinterpret_cast<const uchar *>(dataRetainPool.last().constData()); + } + const uchar *retainBufferData(const QRhiBufferData &data) { + bufferDataRetainPool.append(data); + return reinterpret_cast<const uchar *>(bufferDataRetainPool.last().constData()); + } + const uchar *retainImage(const QImage &image) { + imageRetainPool.append(image); + return imageRetainPool.last().constBits(); + } + void resetCommands() { + commands.reset(); + dataRetainPool.clear(); + bufferDataRetainPool.clear(); + imageRetainPool.clear(); + } + void resetState() { + recordingPass = NoPass; + // do not zero lastGpuTime + currentTarget = nullptr; + resetCommands(); + resetCachedState(); + } + void resetCachedState() { + currentGraphicsPipeline = nullptr; + currentComputePipeline = nullptr; + currentPipelineGeneration = 0; + currentGraphicsSrb = nullptr; + currentComputeSrb = nullptr; + currentSrbGeneration = 0; + currentIndexBuffer = nullptr; + currentIndexOffset = 0; + currentIndexFormat = DXGI_FORMAT_R16_UINT; + memset(currentVertexBuffers, 0, sizeof(currentVertexBuffers)); + memset(currentVertexOffsets, 0, sizeof(currentVertexOffsets)); + } +}; + +struct QD3D11SwapChainTimestamps +{ + static const int TIMESTAMP_PAIRS = 2; + + bool active[TIMESTAMP_PAIRS] = {}; + ID3D11Query *disjointQuery[TIMESTAMP_PAIRS] = {}; + ID3D11Query *query[TIMESTAMP_PAIRS * 2] = {}; + + bool prepare(QRhiD3D11 *rhiD); + void destroy(); + bool tryQueryTimestamps(int idx, ID3D11DeviceContext *context, double *elapsedSec); +}; + +struct QD3D11SwapChain : public QRhiSwapChain +{ + QD3D11SwapChain(QRhiImplementation *rhi); + ~QD3D11SwapChain(); + void destroy() override; + + QRhiCommandBuffer *currentFrameCommandBuffer() override; + QRhiRenderTarget *currentFrameRenderTarget() override; + QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer) override; + + QSize surfacePixelSize() override; + bool isFormatSupported(Format f) override; + QRhiSwapChainHdrInfo hdrInfo() override; + + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; + bool createOrResize() override; + + void releaseBuffers(); + bool newColorBuffer(const QSize &size, DXGI_FORMAT format, DXGI_SAMPLE_DESC sampleDesc, + ID3D11Texture2D **tex, ID3D11RenderTargetView **rtv) const; + + QWindow *window = nullptr; + QSize pixelSize; + QD3D11SwapChainRenderTarget rt; + QD3D11SwapChainRenderTarget rtRight; + QD3D11CommandBuffer cb; + DXGI_FORMAT colorFormat; + DXGI_FORMAT srgbAdjustedColorFormat; + IDXGISwapChain *swapChain = nullptr; + UINT swapChainFlags = 0; + ID3D11Texture2D *backBufferTex; + ID3D11RenderTargetView *backBufferRtv; + ID3D11RenderTargetView *backBufferRtvRight = nullptr; + static const int BUFFER_COUNT = 2; + ID3D11Texture2D *msaaTex[BUFFER_COUNT]; + ID3D11RenderTargetView *msaaRtv[BUFFER_COUNT]; + DXGI_SAMPLE_DESC sampleDesc; + int currentFrameSlot = 0; + int frameCount = 0; + QD3D11RenderBuffer *ds = nullptr; + UINT swapInterval = 1; + IDCompositionTarget *dcompTarget = nullptr; + IDCompositionVisual *dcompVisual = nullptr; + QD3D11SwapChainTimestamps timestamps; + int currentTimestampPairIndex = 0; + HANDLE frameLatencyWaitableObject = nullptr; +}; + +class QRhiD3D11 : public QRhiImplementation +{ +public: + QRhiD3D11(QRhiD3D11InitParams *params, QRhiD3D11NativeHandles *importDevice = nullptr); + + bool create(QRhi::Flags flags) override; + void destroy() override; + + QRhiGraphicsPipeline *createGraphicsPipeline() override; + QRhiComputePipeline *createComputePipeline() override; + QRhiShaderResourceBindings *createShaderResourceBindings() override; + QRhiBuffer *createBuffer(QRhiBuffer::Type type, + QRhiBuffer::UsageFlags usage, + quint32 size) override; + QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type, + const QSize &pixelSize, + int sampleCount, + QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint) override; + QRhiTexture *createTexture(QRhiTexture::Format format, + const QSize &pixelSize, + int depth, + int arraySize, + int sampleCount, + QRhiTexture::Flags flags) override; + QRhiSampler *createSampler(QRhiSampler::Filter magFilter, + QRhiSampler::Filter minFilter, + QRhiSampler::Filter mipmapMode, + QRhiSampler:: AddressMode u, + QRhiSampler::AddressMode v, + QRhiSampler::AddressMode w) override; + + QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, + QRhiTextureRenderTarget::Flags flags) override; + + QRhiSwapChain *createSwapChain() override; + QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override; + QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override; + QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override; + QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override; + QRhi::FrameOpResult finish() override; + + void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + + void beginPass(QRhiCommandBuffer *cb, + QRhiRenderTarget *rt, + const QColor &colorClearValue, + const QRhiDepthStencilClearValue &depthStencilClearValue, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) override; + void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + + void setGraphicsPipeline(QRhiCommandBuffer *cb, + QRhiGraphicsPipeline *ps) override; + + void setShaderResources(QRhiCommandBuffer *cb, + QRhiShaderResourceBindings *srb, + int dynamicOffsetCount, + const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override; + + void setVertexInput(QRhiCommandBuffer *cb, + int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, + QRhiBuffer *indexBuf, quint32 indexOffset, + QRhiCommandBuffer::IndexFormat indexFormat) override; + + void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override; + void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override; + void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override; + void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override; + + void draw(QRhiCommandBuffer *cb, quint32 vertexCount, + quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override; + + void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, + quint32 instanceCount, quint32 firstIndex, + qint32 vertexOffset, quint32 firstInstance) override; + + void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override; + void debugMarkEnd(QRhiCommandBuffer *cb) override; + void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override; + + void beginComputePass(QRhiCommandBuffer *cb, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) override; + void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override; + void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override; + + const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) override; + void beginExternal(QRhiCommandBuffer *cb) override; + void endExternal(QRhiCommandBuffer *cb) override; + double lastCompletedGpuTime(QRhiCommandBuffer *cb) override; + + QList<int> supportedSampleCounts() const override; + int ubufAlignment() const override; + bool isYUpInFramebuffer() const override; + bool isYUpInNDC() const override; + bool isClipDepthZeroToOne() const override; + QMatrix4x4 clipSpaceCorrMatrix() const override; + bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override; + bool isFeatureSupported(QRhi::Feature feature) const override; + int resourceLimit(QRhi::ResourceLimit limit) const override; + const QRhiNativeHandles *nativeHandles() override; + QRhiDriverInfo driverInfo() const override; + QRhiStats statistics() override; + bool makeThreadLocalNativeContextCurrent() override; + void releaseCachedResources() override; + bool isDeviceLost() const override; + + QByteArray pipelineCacheData() override; + void setPipelineCacheData(const QByteArray &data) override; + + void enqueueSubresUpload(QD3D11Texture *texD, QD3D11CommandBuffer *cbD, + int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc); + void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates); + void updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD, + const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[]); + void executeBufferHostWrites(QD3D11Buffer *bufD); + void bindShaderResources(QD3D11ShaderResourceBindings *srbD, + const uint *dynOfsPairs, int dynOfsPairCount, + bool offsetOnlyChange); + void resetShaderResources(); + void executeCommandBuffer(QD3D11CommandBuffer *cbD); + DXGI_SAMPLE_DESC effectiveSampleDesc(int sampleCount) const; + void finishActiveReadbacks(); + void reportLiveObjects(ID3D11Device *device); + void clearShaderCache(); + QByteArray compileHlslShaderSource(const QShader &shader, QShader::Variant shaderVariant, uint flags, + QString *error, QShaderKey *usedShaderKey); + bool ensureDirectCompositionDevice(); + + QRhi::Flags rhiFlags; + bool debugLayer = false; + UINT maxFrameLatency = 2; // 1-3, use 2 to keep CPU-GPU parallelism while reducing lag compared to tripple buffering + bool importedDeviceAndContext = false; + ID3D11Device *dev = nullptr; + ID3D11DeviceContext1 *context = nullptr; + D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL(0); + LUID adapterLuid = {}; + ID3DUserDefinedAnnotation *annotations = nullptr; + IDXGIAdapter1 *activeAdapter = nullptr; + IDXGIFactory1 *dxgiFactory = nullptr; + IDCompositionDevice *dcompDevice = nullptr; + bool supportsAllowTearing = false; + bool useLegacySwapchainModel = false; + bool deviceLost = false; + QRhiD3D11NativeHandles nativeHandlesStruct; + QRhiDriverInfo driverInfoStruct; + + struct { + int vsHighestActiveVertexBufferBinding = -1; + bool vsHasIndexBufferBound = false; + int vsHighestActiveSrvBinding = -1; + int hsHighestActiveSrvBinding = -1; + int dsHighestActiveSrvBinding = -1; + int gsHighestActiveSrvBinding = -1; + int fsHighestActiveSrvBinding = -1; + int csHighestActiveSrvBinding = -1; + int csHighestActiveUavBinding = -1; + QD3D11SwapChain *currentSwapChain = nullptr; + } contextState; + + struct OffscreenFrame { + OffscreenFrame(QRhiImplementation *rhi) : cbWrapper(rhi) { } + bool active = false; + QD3D11CommandBuffer cbWrapper; + ID3D11Query *tsQueries[2] = {}; + ID3D11Query *tsDisjointQuery = nullptr; + } ofr; + + struct TextureReadback { + QRhiReadbackDescription desc; + QRhiReadbackResult *result; + ID3D11Texture2D *stagingTex; + quint32 byteSize; + quint32 bpl; + QSize pixelSize; + QRhiTexture::Format format; + }; + QVarLengthArray<TextureReadback, 2> activeTextureReadbacks; + struct BufferReadback { + QRhiReadbackResult *result; + quint32 byteSize; + ID3D11Buffer *stagingBuf; + }; + QVarLengthArray<BufferReadback, 2> activeBufferReadbacks; + + struct Shader { + Shader() = default; + Shader(IUnknown *s, const QByteArray &bytecode, const QShader::NativeResourceBindingMap &rbm) + : s(s), bytecode(bytecode), nativeResourceBindingMap(rbm) { } + IUnknown *s; + QByteArray bytecode; + QShader::NativeResourceBindingMap nativeResourceBindingMap; + }; + QHash<QRhiShaderStage, Shader> m_shaderCache; + + // This is what gets exposed as the "pipeline cache", not that that concept + // applies anyway. Here we are just storing the DX bytecode for a shader so + // we can skip the HLSL->DXBC compilation when the QShader has HLSL source + // code and the same shader source has already been compiled before. + // m_shaderCache seemingly does the same, but this here does not care about + // the ID3D11*Shader, this is just about the bytecode and about allowing + // the data to be serialized to persistent storage and then reloaded in + // future runs of the app, or when creating another QRhi, etc. + struct BytecodeCacheKey { + QByteArray sourceHash; + QByteArray target; + QByteArray entryPoint; + uint compileFlags; + }; + QHash<BytecodeCacheKey, QByteArray> m_bytecodeCache; +}; + +Q_DECLARE_TYPEINFO(QRhiD3D11::TextureReadback, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QRhiD3D11::BufferReadback, Q_RELOCATABLE_TYPE); + +inline bool operator==(const QRhiD3D11::BytecodeCacheKey &a, const QRhiD3D11::BytecodeCacheKey &b) noexcept +{ + return a.sourceHash == b.sourceHash + && a.target == b.target + && a.entryPoint == b.entryPoint + && a.compileFlags == b.compileFlags; +} + +inline bool operator!=(const QRhiD3D11::BytecodeCacheKey &a, const QRhiD3D11::BytecodeCacheKey &b) noexcept +{ + return !(a == b); +} + +inline size_t qHash(const QRhiD3D11::BytecodeCacheKey &k, size_t seed = 0) noexcept +{ + return qHash(k.sourceHash, seed) ^ qHash(k.target) ^ qHash(k.entryPoint) ^ k.compileFlags; +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhid3d12_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhid3d12_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fee3977929134f52db3dfc30798999ce2957231e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhid3d12_p.h @@ -0,0 +1,1250 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRHID3D12_P_H +#define QRHID3D12_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qrhi_p.h" +#include <QWindow> +#include <QBitArray> + +#include <optional> +#include <array> + +#include <d3d12.h> +#include <d3d12sdklayers.h> +#include <dxgi1_6.h> +#include <dcomp.h> + +#include "D3D12MemAlloc.h" + +// ID3D12Device2 and ID3D12GraphicsCommandList1 and types and enums introduced +// with those are hard requirements now. These should be declared in any +// moderately recent d3d12.h, but if it is an SDK from before Windows 10 +// version 1703 then these types could be missing. In the absence of other +// options, handle this by skipping all the code and making QRhi::create() fail +// in such builds. +#ifdef __ID3D12Device2_INTERFACE_DEFINED__ +#define QRHI_D3D12_AVAILABLE + +QT_BEGIN_NAMESPACE + +static const int QD3D12_FRAMES_IN_FLIGHT = 2; + +class QRhiD3D12; + +struct QD3D12Descriptor +{ + D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle = {}; + D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle = {}; + + bool isValid() const { return cpuHandle.ptr != 0; } +}; + +struct QD3D12ReleaseQueue; + +struct QD3D12DescriptorHeap +{ + bool isValid() const { return heap && capacity; } + bool create(ID3D12Device *device, + quint32 descriptorCount, + D3D12_DESCRIPTOR_HEAP_TYPE heapType, + D3D12_DESCRIPTOR_HEAP_FLAGS heapFlags); + void createWithExisting(const QD3D12DescriptorHeap &other, + quint32 offsetInDescriptors, + quint32 descriptorCount); + void destroy(); + void destroyWithDeferredRelease(QD3D12ReleaseQueue *releaseQueue); + + QD3D12Descriptor get(quint32 count); + QD3D12Descriptor at(quint32 index) const; + quint32 remainingCapacity() const { return capacity - head; } + + QD3D12Descriptor incremented(const QD3D12Descriptor &descriptor, quint32 offsetInDescriptors) const + { + D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle = descriptor.cpuHandle; + cpuHandle.ptr += offsetInDescriptors * descriptorByteSize; + D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle = descriptor.gpuHandle; + if (gpuHandle.ptr) + gpuHandle.ptr += offsetInDescriptors * descriptorByteSize; + return { cpuHandle, gpuHandle }; + } + + ID3D12DescriptorHeap *heap = nullptr; + quint32 capacity = 0; + QD3D12Descriptor heapStart; + quint32 head = 0; + quint32 descriptorByteSize = 0; + D3D12_DESCRIPTOR_HEAP_TYPE heapType; + D3D12_DESCRIPTOR_HEAP_FLAGS heapFlags; +}; + +struct QD3D12CpuDescriptorPool +{ + bool isValid() const { return !heaps.isEmpty(); } + bool create(ID3D12Device *device, D3D12_DESCRIPTOR_HEAP_TYPE heapType, const char *debugName = ""); + void destroy(); + + QD3D12Descriptor allocate(quint32 count); + void release(const QD3D12Descriptor &descriptor, quint32 count); + + static const int DESCRIPTORS_PER_HEAP = 256; + + struct HeapWithMap { + QD3D12DescriptorHeap heap; + QBitArray map; + static HeapWithMap init(const QD3D12DescriptorHeap &heap, quint32 descriptorCount) { + HeapWithMap result; + result.heap = heap; + result.map.resize(descriptorCount); + return result; + } + }; + + ID3D12Device *device; + quint32 descriptorByteSize; + QVector<HeapWithMap> heaps; + const char *debugName; +}; + +struct QD3D12QueryHeap +{ + bool isValid() const { return heap && capacity; } + bool create(ID3D12Device *device, + quint32 queryCount, + D3D12_QUERY_HEAP_TYPE heapType); + void destroy(); + + ID3D12QueryHeap *heap = nullptr; + quint32 capacity = 0; +}; + +struct QD3D12StagingArea +{ + static const quint32 ALIGNMENT = D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT; // 512 so good enough both for cb and texdata + + struct Allocation { + quint8 *p = nullptr; + D3D12_GPU_VIRTUAL_ADDRESS gpuAddr = 0; + ID3D12Resource *buffer = nullptr; + quint32 bufferOffset = 0; + bool isValid() const { return p != nullptr; } + }; + + bool isValid() const { return allocation && mem.isValid(); } + bool create(QRhiD3D12 *rhi, quint32 capacity, D3D12_HEAP_TYPE heapType); + void destroy(); + void destroyWithDeferredRelease(QD3D12ReleaseQueue *releaseQueue); + + Allocation get(quint32 byteSize); + + quint32 remainingCapacity() const + { + return capacity - head; + } + + static quint32 allocSizeForArray(quint32 size, int count = 1) + { + return count * ((size + ALIGNMENT - 1) & ~(ALIGNMENT - 1)); + } + + Allocation mem; + ID3D12Resource *resource = nullptr; + D3D12MA::Allocation *allocation = nullptr; + quint32 head; + quint32 capacity; +}; + +struct QD3D12ObjectHandle +{ + quint32 index = 0; + quint32 generation = 0; + + // the default, null handle is guaranteed to give ObjectPool::isValid() == false + bool isNull() const { return index == 0 && generation == 0; } +}; + +inline bool operator==(const QD3D12ObjectHandle &a, const QD3D12ObjectHandle &b) noexcept +{ + return a.index == b.index && a.generation == b.generation; +} + +inline bool operator!=(const QD3D12ObjectHandle &a, const QD3D12ObjectHandle &b) noexcept +{ + return !(a == b); +} + +template<typename T> +struct QD3D12ObjectPool +{ + void create(const char *debugName = "") + { + this->debugName = debugName; + Q_ASSERT(data.isEmpty()); + data.append(Data()); // index 0 is always invalid + } + + void destroy() { + int leakCount = 0; // will nicely destroy everything here, but warn about it if enabled + for (Data &d : data) { + if (d.object.has_value()) { + leakCount += 1; + d.object->releaseResources(); + } + } + data.clear(); +#ifndef QT_NO_DEBUG + // debug builds: just do it always + static bool leakCheck = true; +#else + // release builds: opt-in + static bool leakCheck = qEnvironmentVariableIntValue("QT_RHI_LEAK_CHECK"); +#endif + if (leakCheck) { + if (leakCount > 0) { + qWarning("QD3D12ObjectPool::destroy(): Pool %p '%s' had %d unreleased objects", + this, debugName, leakCount); + } + } + } + + bool isValid(const QD3D12ObjectHandle &handle) const + { + return handle.index > 0 + && handle.index < quint32(data.count()) + && handle.generation > 0 + && handle.generation == data[handle.index].generation + && data[handle.index].object.has_value(); + } + + T lookup(const QD3D12ObjectHandle &handle) const + { + return isValid(handle) ? *data[handle.index].object : T(); + } + + const T *lookupRef(const QD3D12ObjectHandle &handle) const + { + return isValid(handle) ? &*data[handle.index].object : nullptr; + } + + T *lookupRef(const QD3D12ObjectHandle &handle) + { + return isValid(handle) ? &*data[handle.index].object : nullptr; + } + + QD3D12ObjectHandle add(const T &object) + { + Q_ASSERT(!data.isEmpty()); + const quint32 count = quint32(data.count()); + quint32 index = 1; // index 0 is always invalid + for (; index < count; ++index) { + if (!data[index].object.has_value()) + break; + } + if (index < count) { + data[index].object = object; + quint32 &generation = data[index].generation; + generation += 1u; + return { index, generation }; + } else { + data.append({ object, 1 }); + return { count, 1 }; + } + } + + void remove(const QD3D12ObjectHandle &handle) + { + if (T *object = lookupRef(handle)) { + object->releaseResources(); + data[handle.index].object.reset(); + } + } + + const char *debugName; + struct Data { + std::optional<T> object; + quint32 generation = 0; + }; + QVector<Data> data; +}; + +struct QD3D12Resource +{ + ID3D12Resource *resource; + D3D12_RESOURCE_STATES state; + D3D12_RESOURCE_DESC desc; + D3D12MA::Allocation *allocation; + void *cpuMapPtr; + enum { UavUsageRead = 0x01, UavUsageWrite = 0x02 }; + int uavUsage; + bool owns; + + // note that this assumes the allocation (if there is one) and the resource + // are separately releaseable, see D3D12MemAlloc docs + static QD3D12ObjectHandle addToPool(QD3D12ObjectPool<QD3D12Resource> *pool, + ID3D12Resource *resource, + D3D12_RESOURCE_STATES state, + D3D12MA::Allocation *allocation = nullptr, + void *cpuMapPtr = nullptr) + { + Q_ASSERT(resource); + return pool->add({ resource, state, resource->GetDesc(), allocation, cpuMapPtr, 0, true }); + } + + // for QRhiTexture::createFrom() where the ID3D12Resource is not owned by us + static QD3D12ObjectHandle addNonOwningToPool(QD3D12ObjectPool<QD3D12Resource> *pool, + ID3D12Resource *resource, + D3D12_RESOURCE_STATES state) + { + Q_ASSERT(resource); + return pool->add({ resource, state, resource->GetDesc(), nullptr, nullptr, 0, false }); + } + + void releaseResources() + { + if (owns) { + // order matters: resource first, then the allocation + resource->Release(); + if (allocation) + allocation->Release(); + } + } +}; + +struct QD3D12Pipeline +{ + enum Type { + Graphics, + Compute + }; + Type type; + ID3D12PipelineState *pso; + + static QD3D12ObjectHandle addToPool(QD3D12ObjectPool<QD3D12Pipeline> *pool, + Type type, + ID3D12PipelineState *pso) + { + return pool->add({ type, pso }); + } + + void releaseResources() + { + pso->Release(); + } +}; + +struct QD3D12RootSignature +{ + ID3D12RootSignature *rootSig; + + static QD3D12ObjectHandle addToPool(QD3D12ObjectPool<QD3D12RootSignature> *pool, + ID3D12RootSignature *rootSig) + { + return pool->add({ rootSig }); + } + + void releaseResources() + { + rootSig->Release(); + } +}; + +struct QD3D12ReleaseQueue +{ + void create(QD3D12ObjectPool<QD3D12Resource> *resourcePool, + QD3D12ObjectPool<QD3D12Pipeline> *pipelinePool, + QD3D12ObjectPool<QD3D12RootSignature> *rootSignaturePool) + { + this->resourcePool = resourcePool; + this->pipelinePool = pipelinePool; + this->rootSignaturePool = rootSignaturePool; + } + + void deferredReleaseResource(const QD3D12ObjectHandle &handle); + void deferredReleaseResourceWithViews(const QD3D12ObjectHandle &handle, + QD3D12CpuDescriptorPool *pool, + const QD3D12Descriptor &viewsStart, + int viewCount); + void deferredReleasePipeline(const QD3D12ObjectHandle &handle); + void deferredReleaseRootSignature(const QD3D12ObjectHandle &handle); + void deferredReleaseCallback(std::function<void(void*)> callback, void *userData); + void deferredReleaseResourceAndAllocation(ID3D12Resource *resource, + D3D12MA::Allocation *allocation); + void deferredReleaseDescriptorHeap(ID3D12DescriptorHeap *heap); + void deferredReleaseViews(QD3D12CpuDescriptorPool *pool, + const QD3D12Descriptor &viewsStart, + int viewCount); + + void activatePendingDeferredReleaseRequests(int frameSlot); + void executeDeferredReleases(int frameSlot, bool forced = false); + void releaseAll(); + + struct DeferredReleaseEntry { + enum Type { + Resource, + Pipeline, + RootSignature, + Callback, + ResourceAndAllocation, + DescriptorHeap, + Views + }; + Type type = Resource; + std::optional<int> frameSlotToBeReleasedIn; + QD3D12ObjectHandle handle; + QD3D12CpuDescriptorPool *poolForViews = nullptr; + QD3D12Descriptor viewsStart; + int viewCount = 0; + std::function<void(void*)> callback = nullptr; + void *callbackUserData = nullptr; + QPair<ID3D12Resource *, D3D12MA::Allocation *> resourceAndAllocation = {}; + ID3D12DescriptorHeap *descriptorHeap = nullptr; + }; + QVector<DeferredReleaseEntry> queue; + QD3D12ObjectPool<QD3D12Resource> *resourcePool = nullptr; + QD3D12ObjectPool<QD3D12Pipeline> *pipelinePool = nullptr; + QD3D12ObjectPool<QD3D12RootSignature> *rootSignaturePool = nullptr; +}; + +struct QD3D12CommandBuffer; + +struct QD3D12ResourceBarrierGenerator +{ + static const int PREALLOC = 16; + + void create(QD3D12ObjectPool<QD3D12Resource> *resourcePool) + { + this->resourcePool = resourcePool; + } + + void addTransitionBarrier(const QD3D12ObjectHandle &resourceHandle, D3D12_RESOURCE_STATES stateAfter); + void enqueueBufferedTransitionBarriers(QD3D12CommandBuffer *cbD); + void enqueueSubresourceTransitionBarrier(QD3D12CommandBuffer *cbD, + const QD3D12ObjectHandle &resourceHandle, + UINT subresource, + D3D12_RESOURCE_STATES stateBefore, + D3D12_RESOURCE_STATES stateAfter); + void enqueueUavBarrier(QD3D12CommandBuffer *cbD, const QD3D12ObjectHandle &resourceHandle); + + struct TransitionResourceBarrier { + QD3D12ObjectHandle resourceHandle; + D3D12_RESOURCE_STATES stateBefore; + D3D12_RESOURCE_STATES stateAfter; + }; + QVarLengthArray<TransitionResourceBarrier, PREALLOC> transitionResourceBarriers; + QD3D12ObjectPool<QD3D12Resource> *resourcePool = nullptr; +}; + +struct QD3D12ShaderBytecodeCache +{ + struct Shader { + Shader() = default; + Shader(const QByteArray &bytecode, const QShader::NativeResourceBindingMap &rbm) + : bytecode(bytecode), nativeResourceBindingMap(rbm) + { } + QByteArray bytecode; + QShader::NativeResourceBindingMap nativeResourceBindingMap; + }; + + QHash<QRhiShaderStage, Shader> data; + + void insertWithCapacityLimit(const QRhiShaderStage &key, const Shader &s); +}; + +struct QD3D12ShaderVisibleDescriptorHeap +{ + bool create(ID3D12Device *device, D3D12_DESCRIPTOR_HEAP_TYPE type, quint32 perFrameDescriptorCount); + void destroy(); + void destroyWithDeferredRelease(QD3D12ReleaseQueue *releaseQueue); + + QD3D12DescriptorHeap heap; + QD3D12DescriptorHeap perFrameHeapSlice[QD3D12_FRAMES_IN_FLIGHT]; +}; + +// wrap foreign struct so we can legally supply equality operators and qHash: +struct Q_D3D12_SAMPLER_DESC +{ + D3D12_SAMPLER_DESC desc; + + friend bool operator==(const Q_D3D12_SAMPLER_DESC &lhs, const Q_D3D12_SAMPLER_DESC &rhs) noexcept + { + return lhs.desc.Filter == rhs.desc.Filter + && lhs.desc.AddressU == rhs.desc.AddressU + && lhs.desc.AddressV == rhs.desc.AddressV + && lhs.desc.AddressW == rhs.desc.AddressW + && lhs.desc.MipLODBias == rhs.desc.MipLODBias + && lhs.desc.MaxAnisotropy == rhs.desc.MaxAnisotropy + && lhs.desc.ComparisonFunc == rhs.desc.ComparisonFunc + // BorderColor is never used, skip it + && lhs.desc.MinLOD == rhs.desc.MinLOD + && lhs.desc.MaxLOD == rhs.desc.MaxLOD; + } + + friend bool operator!=(const Q_D3D12_SAMPLER_DESC &lhs, const Q_D3D12_SAMPLER_DESC &rhs) noexcept + { + return !(lhs == rhs); + } + + friend size_t qHash(const Q_D3D12_SAMPLER_DESC &key, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, key.desc.Filter); + seed = hash(seed, key.desc.AddressU); + seed = hash(seed, key.desc.AddressV); + seed = hash(seed, key.desc.AddressW); + seed = hash(seed, key.desc.MipLODBias); + seed = hash(seed, key.desc.MaxAnisotropy); + seed = hash(seed, key.desc.ComparisonFunc); + // BorderColor is never used, skip it + seed = hash(seed, key.desc.MinLOD); + seed = hash(seed, key.desc.MaxLOD); + return seed; + } +}; + +struct QD3D12SamplerManager +{ + const quint32 MAX_SAMPLERS = 512; + + bool create(ID3D12Device *device); + void destroy(); + + QD3D12Descriptor getShaderVisibleDescriptor(const D3D12_SAMPLER_DESC &desc); + + ID3D12Device *device = nullptr; + QD3D12ShaderVisibleDescriptorHeap shaderVisibleSamplerHeap; + QHash<Q_D3D12_SAMPLER_DESC, QD3D12Descriptor> gpuMap; +}; + +enum QD3D12Stage { VS = 0, HS, DS, GS, PS, CS }; + +static inline QD3D12Stage qd3d12_stage(QRhiShaderStage::Type type) +{ + switch (type) { + case QRhiShaderStage::Vertex: + return VS; + case QRhiShaderStage::TessellationControl: + return HS; + case QRhiShaderStage::TessellationEvaluation: + return DS; + case QRhiShaderStage::Geometry: + return GS; + case QRhiShaderStage::Fragment: + return PS; + case QRhiShaderStage::Compute: + return CS; + } + Q_UNREACHABLE_RETURN(VS); +} + +static inline D3D12_SHADER_VISIBILITY qd3d12_stageToVisibility(QD3D12Stage s) +{ + switch (s) { + case VS: + return D3D12_SHADER_VISIBILITY_VERTEX; + case HS: + return D3D12_SHADER_VISIBILITY_HULL; + case DS: + return D3D12_SHADER_VISIBILITY_DOMAIN; + case GS: + return D3D12_SHADER_VISIBILITY_GEOMETRY; + case PS: + return D3D12_SHADER_VISIBILITY_PIXEL; + case CS: + return D3D12_SHADER_VISIBILITY_ALL; + } + Q_UNREACHABLE_RETURN(D3D12_SHADER_VISIBILITY_ALL); +} + +static inline QRhiShaderResourceBinding::StageFlag qd3d12_stageToSrb(QD3D12Stage s) +{ + switch (s) { + case VS: + return QRhiShaderResourceBinding::VertexStage; + case HS: + return QRhiShaderResourceBinding::TessellationControlStage; + case DS: + return QRhiShaderResourceBinding::TessellationEvaluationStage; + case GS: + return QRhiShaderResourceBinding::GeometryStage; + case PS: + return QRhiShaderResourceBinding::FragmentStage; + case CS: + return QRhiShaderResourceBinding::ComputeStage; + } + Q_UNREACHABLE_RETURN(QRhiShaderResourceBinding::VertexStage); +} + +struct QD3D12ShaderStageData +{ + bool valid = false; // to allow simple arrays where unused stages are indicated by !valid + QD3D12Stage stage = VS; + QShader::NativeResourceBindingMap nativeResourceBindingMap; +}; + +struct QD3D12ShaderResourceBindings; + +struct QD3D12ShaderResourceVisitor +{ + enum StorageOp { Load = 0, Store, LoadStore }; + + QD3D12ShaderResourceVisitor(const QD3D12ShaderResourceBindings *srb, + const QD3D12ShaderStageData *stageData, + int stageCount) + : srb(srb), + stageData(stageData), + stageCount(stageCount) + { + } + + std::function<void(QD3D12Stage, const QRhiShaderResourceBinding::Data::UniformBufferData &, int, int)> uniformBuffer = nullptr; + std::function<void(QD3D12Stage, const QRhiShaderResourceBinding::TextureAndSampler &, int)> texture = nullptr; + std::function<void(QD3D12Stage, const QRhiShaderResourceBinding::TextureAndSampler &, int)> sampler = nullptr; + std::function<void(QD3D12Stage, const QRhiShaderResourceBinding::Data::StorageImageData &, StorageOp, int)> storageImage = nullptr; + std::function<void(QD3D12Stage, const QRhiShaderResourceBinding::Data::StorageBufferData &, StorageOp, int)> storageBuffer = nullptr; + + void visit(); + + const QD3D12ShaderResourceBindings *srb; + const QD3D12ShaderStageData *stageData; + int stageCount; +}; + +struct QD3D12Readback +{ + // common + int frameSlot = -1; + QRhiReadbackResult *result = nullptr; + QD3D12StagingArea staging; + quint32 byteSize = 0; + // textures + quint32 bytesPerLine = 0; + QSize pixelSize; + QRhiTexture::Format format = QRhiTexture::UnknownFormat; + quint32 stagingRowPitch = 0; +}; + +struct QD3D12MipmapGenerator +{ + bool create(QRhiD3D12 *rhiD); + void destroy(); + void generate(QD3D12CommandBuffer *cbD, const QD3D12ObjectHandle &textureHandle); + + QRhiD3D12 *rhiD; + QD3D12ObjectHandle rootSigHandle; + QD3D12ObjectHandle pipelineHandle; +}; + +struct QD3D12MemoryAllocator +{ + bool create(ID3D12Device *device, IDXGIAdapter1 *adapter); + void destroy(); + + HRESULT createResource(D3D12_HEAP_TYPE heapType, + const D3D12_RESOURCE_DESC *resourceDesc, + D3D12_RESOURCE_STATES initialState, + const D3D12_CLEAR_VALUE *optimizedClearValue, + D3D12MA::Allocation **maybeAllocation, + REFIID riidResource, + void **ppvResource); + + void getBudget(D3D12MA::Budget *localBudget, D3D12MA::Budget *nonLocalBudget); + + bool isUsingD3D12MA() const { return allocator != nullptr; } + + ID3D12Device *device = nullptr; + D3D12MA::Allocator *allocator = nullptr; +}; + +struct QD3D12Buffer : public QRhiBuffer +{ + QD3D12Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size); + ~QD3D12Buffer(); + + void destroy() override; + bool create() override; + QRhiBuffer::NativeBuffer nativeBuffer() override; + char *beginFullDynamicBufferUpdateForCurrentFrame() override; + void endFullDynamicBufferUpdateForCurrentFrame() override; + + void executeHostWritesForFrameSlot(int frameSlot); + + QD3D12ObjectHandle handles[QD3D12_FRAMES_IN_FLIGHT] = {}; + struct HostWrite { + quint32 offset; + QRhiBufferData data; + }; + QVarLengthArray<HostWrite, 16> pendingHostWrites[QD3D12_FRAMES_IN_FLIGHT]; + friend class QRhiD3D12; + friend struct QD3D12CommandBuffer; +}; + +struct QD3D12RenderBuffer : public QRhiRenderBuffer +{ + QD3D12RenderBuffer(QRhiImplementation *rhi, + Type type, + const QSize &pixelSize, + int sampleCount, + Flags flags, + QRhiTexture::Format backingFormatHint); + ~QD3D12RenderBuffer(); + void destroy() override; + bool create() override; + QRhiTexture::Format backingFormat() const override; + + static const DXGI_FORMAT DS_FORMAT = DXGI_FORMAT_D24_UNORM_S8_UINT; + + QD3D12ObjectHandle handle; + QD3D12Descriptor rtv; + QD3D12Descriptor dsv; + DXGI_FORMAT dxgiFormat; + DXGI_SAMPLE_DESC sampleDesc; + uint generation = 0; + friend class QRhiD3D12; +}; + +struct QD3D12Texture : public QRhiTexture +{ + QD3D12Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, + int arraySize, int sampleCount, Flags flags); + ~QD3D12Texture(); + void destroy() override; + bool create() override; + bool createFrom(NativeTexture src) override; + NativeTexture nativeTexture() override; + void setNativeLayout(int layout) override; + + bool prepareCreate(QSize *adjustedSize = nullptr); + bool finishCreate(); + + QD3D12ObjectHandle handle; + QD3D12Descriptor srv; + DXGI_FORMAT dxgiFormat; + DXGI_FORMAT srvFormat; + DXGI_FORMAT rtFormat; // RTV/DSV/UAV + uint mipLevelCount; + DXGI_SAMPLE_DESC sampleDesc; + uint generation = 0; + friend class QRhiD3D12; + friend struct QD3D12CommandBuffer; +}; + +struct QD3D12Sampler : public QRhiSampler +{ + QD3D12Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, + AddressMode u, AddressMode v, AddressMode w); + ~QD3D12Sampler(); + void destroy() override; + bool create() override; + + QD3D12Descriptor lookupOrCreateShaderVisibleDescriptor(); + + D3D12_SAMPLER_DESC desc = {}; + QD3D12Descriptor shaderVisibleDescriptor; +}; + +struct QD3D12RenderPassDescriptor : public QRhiRenderPassDescriptor +{ + QD3D12RenderPassDescriptor(QRhiImplementation *rhi); + ~QD3D12RenderPassDescriptor(); + void destroy() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() const override; + QVector<quint32> serializedFormat() const override; + + void updateSerializedFormat(); + + static const int MAX_COLOR_ATTACHMENTS = 8; + int colorAttachmentCount = 0; + bool hasDepthStencil = false; + int colorFormat[MAX_COLOR_ATTACHMENTS]; + int dsFormat; + QVector<quint32> serializedFormatData; +}; + +struct QD3D12RenderTargetData +{ + QD3D12RenderTargetData(QRhiImplementation *) { } + + QD3D12RenderPassDescriptor *rp = nullptr; + QSize pixelSize; + float dpr = 1; + int sampleCount = 1; + int colorAttCount = 0; + int dsAttCount = 0; + QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList; + static const int MAX_COLOR_ATTACHMENTS = QD3D12RenderPassDescriptor::MAX_COLOR_ATTACHMENTS; + D3D12_CPU_DESCRIPTOR_HANDLE rtv[MAX_COLOR_ATTACHMENTS]; + D3D12_CPU_DESCRIPTOR_HANDLE dsv; +}; + +struct QD3D12SwapChainRenderTarget : public QRhiSwapChainRenderTarget +{ + QD3D12SwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain); + ~QD3D12SwapChainRenderTarget(); + void destroy() override; + + QSize pixelSize() const override; + float devicePixelRatio() const override; + int sampleCount() const override; + + QD3D12RenderTargetData d; +}; + +struct QD3D12TextureRenderTarget : public QRhiTextureRenderTarget +{ + QD3D12TextureRenderTarget(QRhiImplementation *rhi, + const QRhiTextureRenderTargetDescription &desc, + Flags flags); + ~QD3D12TextureRenderTarget(); + void destroy() override; + + QSize pixelSize() const override; + float devicePixelRatio() const override; + int sampleCount() const override; + + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; + bool create() override; + + QD3D12RenderTargetData d; + bool ownsRtv[QD3D12RenderTargetData::MAX_COLOR_ATTACHMENTS]; + QD3D12Descriptor rtv[QD3D12RenderTargetData::MAX_COLOR_ATTACHMENTS]; + bool ownsDsv = false; + QD3D12Descriptor dsv; + friend class QRhiD3D12; +}; + +struct QD3D12ShaderResourceBindings : public QRhiShaderResourceBindings +{ + QD3D12ShaderResourceBindings(QRhiImplementation *rhi); + ~QD3D12ShaderResourceBindings(); + void destroy() override; + bool create() override; + void updateResources(UpdateFlags flags) override; + + QD3D12ObjectHandle createRootSignature(const QD3D12ShaderStageData *stageData, int stageCount); + + struct VisitorData { + QVarLengthArray<D3D12_ROOT_PARAMETER1, 2> cbParams[6]; + + D3D12_ROOT_PARAMETER1 srvTables[6] = {}; + QVarLengthArray<D3D12_DESCRIPTOR_RANGE1, 4> srvRanges[6]; + quint32 currentSrvRangeOffset[6] = {}; + + QVarLengthArray<D3D12_ROOT_PARAMETER1, 4> samplerTables[6]; + std::array<D3D12_DESCRIPTOR_RANGE1, 16> samplerRanges[6] = {}; + int samplerRangeHeads[6] = {}; + + D3D12_ROOT_PARAMETER1 uavTables[6] = {}; + QVarLengthArray<D3D12_DESCRIPTOR_RANGE1, 4> uavRanges[6]; + quint32 currentUavRangeOffset[6] = {}; + } visitorData; + + + void visitUniformBuffer(QD3D12Stage s, + const QRhiShaderResourceBinding::Data::UniformBufferData &d, + int shaderRegister, + int binding); + void visitTexture(QD3D12Stage s, + const QRhiShaderResourceBinding::TextureAndSampler &d, + int shaderRegister); + void visitSampler(QD3D12Stage s, + const QRhiShaderResourceBinding::TextureAndSampler &d, + int shaderRegister); + void visitStorageBuffer(QD3D12Stage s, + const QRhiShaderResourceBinding::Data::StorageBufferData &d, + QD3D12ShaderResourceVisitor::StorageOp op, + int shaderRegister); + void visitStorageImage(QD3D12Stage s, + const QRhiShaderResourceBinding::Data::StorageImageData &d, + QD3D12ShaderResourceVisitor::StorageOp op, + int shaderRegister); + + bool hasDynamicOffset = false; + uint generation = 0; + + friend class QRhiD3D12; + friend struct QD3D12ShaderResourceVisitor; +}; + +struct QD3D12GraphicsPipeline : public QRhiGraphicsPipeline +{ + QD3D12GraphicsPipeline(QRhiImplementation *rhi); + ~QD3D12GraphicsPipeline(); + void destroy() override; + bool create() override; + + QD3D12ObjectHandle handle; + QD3D12ObjectHandle rootSigHandle; + std::array<QD3D12ShaderStageData, 5> stageData; + D3D12_PRIMITIVE_TOPOLOGY topology; + UINT viewInstanceMask = 0; + uint generation = 0; + friend class QRhiD3D12; +}; + +struct QD3D12ComputePipeline : public QRhiComputePipeline +{ + QD3D12ComputePipeline(QRhiImplementation *rhi); + ~QD3D12ComputePipeline(); + void destroy() override; + bool create() override; + + QD3D12ObjectHandle handle; + QD3D12ObjectHandle rootSigHandle; + QD3D12ShaderStageData stageData; + uint generation = 0; + friend class QRhiD3D12; +}; + +struct QD3D12CommandBuffer : public QRhiCommandBuffer +{ + QD3D12CommandBuffer(QRhiImplementation *rhi); + ~QD3D12CommandBuffer(); + void destroy() override; + + const QRhiNativeHandles *nativeHandles(); + + ID3D12GraphicsCommandList1 *cmdList = nullptr; // not owned + QRhiD3D12CommandBufferNativeHandles nativeHandlesStruct; + + enum PassType { + NoPass, + RenderPass, + ComputePass + }; + + void resetState() + { + recordingPass = NoPass; + currentTarget = nullptr; + + resetPerPassState(); + } + + void resetPerPassState() + { + currentGraphicsPipeline = nullptr; + currentComputePipeline = nullptr; + currentPipelineGeneration = 0; + currentGraphicsSrb = nullptr; + currentComputeSrb = nullptr; + currentSrbGeneration = 0; + currentIndexBuffer = {}; + currentIndexOffset = 0; + currentIndexFormat = DXGI_FORMAT_R16_UINT; + currentVertexBuffers = {}; + currentVertexOffsets = {}; + } + + // per-frame + PassType recordingPass; + QRhiRenderTarget *currentTarget; + + // per-pass + QD3D12GraphicsPipeline *currentGraphicsPipeline; + QD3D12ComputePipeline *currentComputePipeline; + uint currentPipelineGeneration; + QRhiShaderResourceBindings *currentGraphicsSrb; + QRhiShaderResourceBindings *currentComputeSrb; + uint currentSrbGeneration; + QD3D12ObjectHandle currentIndexBuffer; + quint32 currentIndexOffset; + DXGI_FORMAT currentIndexFormat; + std::array<QD3D12ObjectHandle, D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> currentVertexBuffers; + std::array<quint32, D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> currentVertexOffsets; + + // global + double lastGpuTime = 0; + + // per-setShaderResources + struct VisitorData { + QVarLengthArray<QPair<QD3D12ObjectHandle, quint32>, 4> cbufs[6]; + QVarLengthArray<QD3D12Descriptor, 8> srvs[6]; + QVarLengthArray<QD3D12Descriptor, 8> samplers[6]; + QVarLengthArray<QPair<QD3D12ObjectHandle, D3D12_UNORDERED_ACCESS_VIEW_DESC>, 4> uavs[6]; + } visitorData; + + void visitUniformBuffer(QD3D12Stage s, + const QRhiShaderResourceBinding::Data::UniformBufferData &d, + int shaderRegister, + int binding, + int dynamicOffsetCount, + const QRhiCommandBuffer::DynamicOffset *dynamicOffsets); + void visitTexture(QD3D12Stage s, + const QRhiShaderResourceBinding::TextureAndSampler &d, + int shaderRegister); + void visitSampler(QD3D12Stage s, + const QRhiShaderResourceBinding::TextureAndSampler &d, + int shaderRegister); + void visitStorageBuffer(QD3D12Stage s, + const QRhiShaderResourceBinding::Data::StorageBufferData &d, + QD3D12ShaderResourceVisitor::StorageOp op, + int shaderRegister); + void visitStorageImage(QD3D12Stage s, + const QRhiShaderResourceBinding::Data::StorageImageData &d, + QD3D12ShaderResourceVisitor::StorageOp op, + int shaderRegister); +}; + +struct QD3D12SwapChain : public QRhiSwapChain +{ + QD3D12SwapChain(QRhiImplementation *rhi); + ~QD3D12SwapChain(); + void destroy() override; + + QRhiCommandBuffer *currentFrameCommandBuffer() override; + QRhiRenderTarget *currentFrameRenderTarget() override; + QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer) override; + + QSize surfacePixelSize() override; + bool isFormatSupported(Format f) override; + QRhiSwapChainHdrInfo hdrInfo() override; + + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; + bool createOrResize() override; + + void releaseBuffers(); + void waitCommandCompletionForFrameSlot(int frameSlot); + void addCommandCompletionSignalForCurrentFrameSlot(); + void chooseFormats(); + + QWindow *window = nullptr; + IDXGISwapChain1 *sourceSwapChain1 = nullptr; + IDXGISwapChain3 *swapChain = nullptr; + QSize pixelSize; + UINT swapInterval = 1; + UINT swapChainFlags = 0; + BOOL stereo = false; + DXGI_FORMAT colorFormat; + DXGI_FORMAT srgbAdjustedColorFormat; + DXGI_COLOR_SPACE_TYPE hdrColorSpace; + IDCompositionTarget *dcompTarget = nullptr; + IDCompositionVisual *dcompVisual = nullptr; + static const UINT BUFFER_COUNT = 3; + QD3D12ObjectHandle colorBuffers[BUFFER_COUNT]; + QD3D12Descriptor rtvs[BUFFER_COUNT]; + QD3D12Descriptor rtvsRight[BUFFER_COUNT]; + DXGI_SAMPLE_DESC sampleDesc; + QD3D12ObjectHandle msaaBuffers[BUFFER_COUNT]; + QD3D12Descriptor msaaRtvs[BUFFER_COUNT]; + QD3D12RenderBuffer *ds = nullptr; + UINT currentBackBufferIndex = 0; + QD3D12SwapChainRenderTarget rtWrapper; + QD3D12SwapChainRenderTarget rtWrapperRight; + QD3D12CommandBuffer cbWrapper; + HANDLE frameLatencyWaitableObject = nullptr; + + struct FrameResources { + ID3D12Fence *fence = nullptr; + HANDLE fenceEvent = nullptr; + UINT64 fenceCounter = 0; + ID3D12GraphicsCommandList1 *cmdList = nullptr; + } frameRes[QD3D12_FRAMES_IN_FLIGHT]; + + int currentFrameSlot = 0; // index in frameRes +}; + +template<typename T, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type> +struct alignas(void*) QD3D12PipelineStateSubObject +{ + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE type = Type; + T object = {}; +}; + +class QRhiD3D12 : public QRhiImplementation +{ +public: + // 16MB * QD3D12_FRAMES_IN_FLIGHT; buffer and texture upload staging data that + // gets no space from this will get their own temporary staging areas. + static const quint32 SMALL_STAGING_AREA_BYTES_PER_FRAME = 16 * 1024 * 1024; + + static const quint32 SHADER_VISIBLE_CBV_SRV_UAV_HEAP_PER_FRAME_START_SIZE = 16384; + + QRhiD3D12(QRhiD3D12InitParams *params, QRhiD3D12NativeHandles *importDevice = nullptr); + + bool create(QRhi::Flags flags) override; + void destroy() override; + + QRhiGraphicsPipeline *createGraphicsPipeline() override; + QRhiComputePipeline *createComputePipeline() override; + QRhiShaderResourceBindings *createShaderResourceBindings() override; + QRhiBuffer *createBuffer(QRhiBuffer::Type type, + QRhiBuffer::UsageFlags usage, + quint32 size) override; + QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type, + const QSize &pixelSize, + int sampleCount, + QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint) override; + QRhiTexture *createTexture(QRhiTexture::Format format, + const QSize &pixelSize, + int depth, + int arraySize, + int sampleCount, + QRhiTexture::Flags flags) override; + QRhiSampler *createSampler(QRhiSampler::Filter magFilter, + QRhiSampler::Filter minFilter, + QRhiSampler::Filter mipmapMode, + QRhiSampler:: AddressMode u, + QRhiSampler::AddressMode v, + QRhiSampler::AddressMode w) override; + + QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, + QRhiTextureRenderTarget::Flags flags) override; + + QRhiSwapChain *createSwapChain() override; + QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override; + QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override; + QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override; + QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override; + QRhi::FrameOpResult finish() override; + + void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + + void beginPass(QRhiCommandBuffer *cb, + QRhiRenderTarget *rt, + const QColor &colorClearValue, + const QRhiDepthStencilClearValue &depthStencilClearValue, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) override; + void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + + void setGraphicsPipeline(QRhiCommandBuffer *cb, + QRhiGraphicsPipeline *ps) override; + + void setShaderResources(QRhiCommandBuffer *cb, + QRhiShaderResourceBindings *srb, + int dynamicOffsetCount, + const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override; + + void setVertexInput(QRhiCommandBuffer *cb, + int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, + QRhiBuffer *indexBuf, quint32 indexOffset, + QRhiCommandBuffer::IndexFormat indexFormat) override; + + void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override; + void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override; + void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override; + void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override; + + void draw(QRhiCommandBuffer *cb, quint32 vertexCount, + quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override; + + void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, + quint32 instanceCount, quint32 firstIndex, + qint32 vertexOffset, quint32 firstInstance) override; + + void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override; + void debugMarkEnd(QRhiCommandBuffer *cb) override; + void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override; + + void beginComputePass(QRhiCommandBuffer *cb, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) override; + void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override; + void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override; + + const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) override; + void beginExternal(QRhiCommandBuffer *cb) override; + void endExternal(QRhiCommandBuffer *cb) override; + double lastCompletedGpuTime(QRhiCommandBuffer *cb) override; + + QList<int> supportedSampleCounts() const override; + int ubufAlignment() const override; + bool isYUpInFramebuffer() const override; + bool isYUpInNDC() const override; + bool isClipDepthZeroToOne() const override; + QMatrix4x4 clipSpaceCorrMatrix() const override; + bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override; + bool isFeatureSupported(QRhi::Feature feature) const override; + int resourceLimit(QRhi::ResourceLimit limit) const override; + const QRhiNativeHandles *nativeHandles() override; + QRhiDriverInfo driverInfo() const override; + QRhiStats statistics() override; + bool makeThreadLocalNativeContextCurrent() override; + void releaseCachedResources() override; + bool isDeviceLost() const override; + + QByteArray pipelineCacheData() override; + void setPipelineCacheData(const QByteArray &data) override; + + void waitGpu(); + DXGI_SAMPLE_DESC effectiveSampleDesc(int sampleCount, DXGI_FORMAT format) const; + bool ensureDirectCompositionDevice(); + bool startCommandListForCurrentFrameSlot(ID3D12GraphicsCommandList1 **cmdList); + void enqueueResourceUpdates(QD3D12CommandBuffer *cbD, QRhiResourceUpdateBatch *resourceUpdates); + void finishActiveReadbacks(bool forced = false); + bool ensureShaderVisibleDescriptorHeapCapacity(QD3D12ShaderVisibleDescriptorHeap *h, + D3D12_DESCRIPTOR_HEAP_TYPE type, + int frameSlot, + quint32 neededDescriptorCount, + bool *gotNew); + void bindShaderVisibleHeaps(QD3D12CommandBuffer *cbD); + + bool debugLayer = false; + UINT maxFrameLatency = 2; // 1-3, use 2 to keep CPU-GPU parallelism while reducing lag compared to tripple buffering + ID3D12Device2 *dev = nullptr; + D3D_FEATURE_LEVEL minimumFeatureLevel = D3D_FEATURE_LEVEL(0); + LUID adapterLuid = {}; + bool importedDevice = false; + bool importedCommandQueue = false; + QRhi::Flags rhiFlags; + IDXGIFactory2 *dxgiFactory = nullptr; + bool supportsAllowTearing = false; + IDXGIAdapter1 *activeAdapter = nullptr; + QRhiDriverInfo driverInfoStruct; + QRhiD3D12NativeHandles nativeHandlesStruct; + bool deviceLost = false; + ID3D12CommandQueue *cmdQueue = nullptr; + ID3D12Fence *fullFence = nullptr; + HANDLE fullFenceEvent = nullptr; + UINT64 fullFenceCounter = 0; + ID3D12CommandAllocator *cmdAllocators[QD3D12_FRAMES_IN_FLIGHT] = {}; + QD3D12MemoryAllocator vma; + QD3D12CpuDescriptorPool rtvPool; + QD3D12CpuDescriptorPool dsvPool; + QD3D12CpuDescriptorPool cbvSrvUavPool; + QD3D12ObjectPool<QD3D12Resource> resourcePool; + QD3D12ObjectPool<QD3D12Pipeline> pipelinePool; + QD3D12ObjectPool<QD3D12RootSignature> rootSignaturePool; + QD3D12ReleaseQueue releaseQueue; + QD3D12ResourceBarrierGenerator barrierGen; + QD3D12SamplerManager samplerMgr; + QD3D12MipmapGenerator mipmapGen; + QD3D12StagingArea smallStagingAreas[QD3D12_FRAMES_IN_FLIGHT]; + QD3D12ShaderVisibleDescriptorHeap shaderVisibleCbvSrvUavHeap; + UINT64 timestampTicksPerSecond = 0; + QD3D12QueryHeap timestampQueryHeap; + QD3D12StagingArea timestampReadbackArea; + IDCompositionDevice *dcompDevice = nullptr; + QD3D12SwapChain *currentSwapChain = nullptr; + QSet<QD3D12SwapChain *> swapchains; + QD3D12ShaderBytecodeCache shaderBytecodeCache; + QVarLengthArray<QD3D12Readback, 4> activeReadbacks; + bool offscreenActive = false; + QD3D12CommandBuffer *offscreenCb[QD3D12_FRAMES_IN_FLIGHT] = {}; + + struct { + bool multiView = false; + bool textureViewFormat = false; + } caps; +}; + +QT_END_NAMESPACE + +#endif // __ID3D12Device2_INTERFACE_DEFINED__ + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhid3dhelpers_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhid3dhelpers_p.h new file mode 100644 index 0000000000000000000000000000000000000000..62e3e65c95b0bfb63906c9a031448baa34692a97 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhid3dhelpers_p.h @@ -0,0 +1,53 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRHID3DHELPERS_P_H +#define QRHID3DHELPERS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <rhi/qrhi.h> + +#include <QtGui/qwindow.h> + +#include <dxgi1_6.h> +#include <dcomp.h> +#include <d3dcompiler.h> + +#if __has_include(<dxcapi.h>) +#include <dxcapi.h> +#define QRHI_D3D12_HAS_DXC +#endif + +QT_BEGIN_NAMESPACE + +namespace QRhiD3D { + +bool output6ForWindow(QWindow *w, IDXGIAdapter1 *adapter, IDXGIOutput6 **result); +bool outputDesc1ForWindow(QWindow *w, IDXGIAdapter1 *adapter, DXGI_OUTPUT_DESC1 *result); +float sdrWhiteLevelInNits(const DXGI_OUTPUT_DESC1 &outputDesc); + +pD3DCompile resolveD3DCompile(); + +IDCompositionDevice *createDirectCompositionDevice(); + +#ifdef QRHI_D3D12_HAS_DXC +std::pair<IDxcCompiler *, IDxcLibrary *> createDxcCompiler(); +#endif + +void fillDriverInfo(QRhiDriverInfo *info, const DXGI_ADAPTER_DESC1 &desc); + +} // namespace + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhigles2_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhigles2_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d32a5579ca3221d4491137b8b47b41cd1912de2b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhigles2_p.h @@ -0,0 +1,1160 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRHIGLES2_P_H +#define QRHIGLES2_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qrhi_p.h" +#include <rhi/qshaderdescription.h> +#include <qopengl.h> +#include <QByteArray> +#include <QWindow> +#include <QPointer> +#include <QtCore/private/qduplicatetracker_p.h> +#include <optional> + +QT_BEGIN_NAMESPACE + +class QOpenGLExtensions; +class QRhiGles2; + +struct QGles2Buffer : public QRhiBuffer +{ + QGles2Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size); + ~QGles2Buffer(); + void destroy() override; + bool create() override; + QRhiBuffer::NativeBuffer nativeBuffer() override; + char *beginFullDynamicBufferUpdateForCurrentFrame() override; + void endFullDynamicBufferUpdateForCurrentFrame() override; + void fullDynamicBufferUpdateForCurrentFrame(const void *data, quint32 size) override; + + quint32 nonZeroSize = 0; + GLuint buffer = 0; + GLenum targetForDataOps; + QByteArray data; + enum Access { + AccessNone, + AccessVertex, + AccessIndex, + AccessUniform, + AccessStorageRead, + AccessStorageWrite, + AccessStorageReadWrite, + AccessUpdate + }; + struct UsageState { + Access access; + }; + UsageState usageState; + friend class QRhiGles2; +}; + +struct QGles2RenderBuffer : public QRhiRenderBuffer +{ + QGles2RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, + int sampleCount, QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint); + ~QGles2RenderBuffer(); + void destroy() override; + bool create() override; + bool createFrom(NativeRenderBuffer src) override; + QRhiTexture::Format backingFormat() const override; + + GLuint renderbuffer = 0; + GLuint stencilRenderbuffer = 0; // when packed depth-stencil not supported + int samples; + bool owns = true; + uint generation = 0; + friend class QRhiGles2; +}; + +struct QGles2SamplerData +{ + GLenum glminfilter = 0; + GLenum glmagfilter = 0; + GLenum glwraps = 0; + GLenum glwrapt = 0; + GLenum glwrapr = 0; + GLenum gltexcomparefunc = 0; +}; + +inline bool operator==(const QGles2SamplerData &a, const QGles2SamplerData &b) +{ + return a.glminfilter == b.glminfilter + && a.glmagfilter == b.glmagfilter + && a.glwraps == b.glwraps + && a.glwrapt == b.glwrapt + && a.glwrapr == b.glwrapr + && a.gltexcomparefunc == b.gltexcomparefunc; +} + +inline bool operator!=(const QGles2SamplerData &a, const QGles2SamplerData &b) +{ + return !(a == b); +} + +struct QGles2Texture : public QRhiTexture +{ + QGles2Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, + int arraySize, int sampleCount, Flags flags); + ~QGles2Texture(); + void destroy() override; + bool create() override; + bool createFrom(NativeTexture src) override; + NativeTexture nativeTexture() override; + + bool prepareCreate(QSize *adjustedSize = nullptr); + + GLuint texture = 0; + bool owns = true; + GLenum target; + GLenum glintformat; + GLenum glsizedintformat; + GLenum glformat; + GLenum gltype; + QGles2SamplerData samplerState; + bool specified = false; + bool zeroInitialized = false; + int mipLevelCount = 0; + + enum Access { + AccessNone, + AccessSample, + AccessFramebuffer, + AccessStorageRead, + AccessStorageWrite, + AccessStorageReadWrite, + AccessUpdate, + AccessRead + }; + struct UsageState { + Access access; + }; + UsageState usageState; + + uint generation = 0; + friend class QRhiGles2; +}; + +struct QGles2Sampler : public QRhiSampler +{ + QGles2Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, + AddressMode u, AddressMode v, AddressMode w); + ~QGles2Sampler(); + void destroy() override; + bool create() override; + + QGles2SamplerData d; + uint generation = 0; + friend class QRhiGles2; +}; + +struct QGles2RenderPassDescriptor : public QRhiRenderPassDescriptor +{ + QGles2RenderPassDescriptor(QRhiImplementation *rhi); + ~QGles2RenderPassDescriptor(); + void destroy() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() const override; + QVector<quint32> serializedFormat() const override; +}; + +struct QGles2RenderTargetData +{ + QGles2RenderTargetData(QRhiImplementation *) { } + + bool isValid() const { return rp != nullptr; } + + QGles2RenderPassDescriptor *rp = nullptr; + QSize pixelSize; + float dpr = 1; + int sampleCount = 1; + int colorAttCount = 0; + int dsAttCount = 0; + bool srgbUpdateAndBlend = false; + QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList; + std::optional<QRhiSwapChain::StereoTargetBuffer> stereoTarget; +}; + +struct QGles2SwapChainRenderTarget : public QRhiSwapChainRenderTarget +{ + QGles2SwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain); + ~QGles2SwapChainRenderTarget(); + void destroy() override; + + QSize pixelSize() const override; + float devicePixelRatio() const override; + int sampleCount() const override; + + QGles2RenderTargetData d; +}; + +struct QGles2TextureRenderTarget : public QRhiTextureRenderTarget +{ + QGles2TextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags); + ~QGles2TextureRenderTarget(); + void destroy() override; + + QSize pixelSize() const override; + float devicePixelRatio() const override; + int sampleCount() const override; + + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; + bool create() override; + + QGles2RenderTargetData d; + GLuint framebuffer = 0; + GLuint nonMsaaThrowawayDepthTexture = 0; + friend class QRhiGles2; +}; + +struct QGles2ShaderResourceBindings : public QRhiShaderResourceBindings +{ + QGles2ShaderResourceBindings(QRhiImplementation *rhi); + ~QGles2ShaderResourceBindings(); + void destroy() override; + bool create() override; + void updateResources(UpdateFlags flags) override; + + bool hasDynamicOffset = false; + uint generation = 0; + friend class QRhiGles2; +}; + +struct QGles2UniformDescription +{ + QShaderDescription::VariableType type; + int glslLocation; + int binding; + quint32 offset; + quint32 size; + int arrayDim; +}; + +Q_DECLARE_TYPEINFO(QGles2UniformDescription, Q_RELOCATABLE_TYPE); + +struct QGles2SamplerDescription +{ + int glslLocation; + int combinedBinding; + int tbinding; + int sbinding; +}; + +Q_DECLARE_TYPEINFO(QGles2SamplerDescription, Q_RELOCATABLE_TYPE); + +using QGles2UniformDescriptionVector = QVarLengthArray<QGles2UniformDescription, 8>; +using QGles2SamplerDescriptionVector = QVarLengthArray<QGles2SamplerDescription, 4>; + +struct QGles2UniformState +{ + static constexpr int MAX_TRACKED_LOCATION = 1023; + int componentCount; + float v[4]; +}; + +struct QGles2GraphicsPipeline : public QRhiGraphicsPipeline +{ + QGles2GraphicsPipeline(QRhiImplementation *rhi); + ~QGles2GraphicsPipeline(); + void destroy() override; + bool create() override; + + GLuint program = 0; + GLenum drawMode = GL_TRIANGLES; + QGles2UniformDescriptionVector uniforms; + QGles2SamplerDescriptionVector samplers; + QGles2UniformState uniformState[QGles2UniformState::MAX_TRACKED_LOCATION + 1]; + QRhiShaderResourceBindings *currentSrb = nullptr; + uint currentSrbGeneration = 0; + uint generation = 0; + friend class QRhiGles2; +}; + +struct QGles2ComputePipeline : public QRhiComputePipeline +{ + QGles2ComputePipeline(QRhiImplementation *rhi); + ~QGles2ComputePipeline(); + void destroy() override; + bool create() override; + + GLuint program = 0; + QGles2UniformDescriptionVector uniforms; + QGles2SamplerDescriptionVector samplers; + QGles2UniformState uniformState[QGles2UniformState::MAX_TRACKED_LOCATION + 1]; + QRhiShaderResourceBindings *currentSrb = nullptr; + uint currentSrbGeneration = 0; + uint generation = 0; + friend class QRhiGles2; +}; + +struct QGles2CommandBuffer : public QRhiCommandBuffer +{ + QGles2CommandBuffer(QRhiImplementation *rhi); + ~QGles2CommandBuffer(); + void destroy() override; + + // keep at a reasonably low value otherwise sizeof Command explodes + static const int MAX_DYNAMIC_OFFSET_COUNT = 8; + + struct Command { + enum Cmd { + BeginFrame, + EndFrame, + ResetFrame, + Viewport, + Scissor, + BlendConstants, + StencilRef, + BindVertexBuffer, + BindIndexBuffer, + Draw, + DrawIndexed, + BindGraphicsPipeline, + BindShaderResources, + BindFramebuffer, + Clear, + BufferSubData, + GetBufferSubData, + CopyTex, + ReadPixels, + SubImage, + CompressedImage, + CompressedSubImage, + BlitFromRenderbuffer, + BlitFromTexture, + GenMip, + BindComputePipeline, + Dispatch, + BarriersForPass, + Barrier, + InvalidateFramebuffer + }; + Cmd cmd; + + // QRhi*/QGles2* references should be kept at minimum (so no + // QRhiTexture/Buffer/etc. pointers). + union Args { + struct { + GLuint timestampQuery; + } beginFrame; + struct { + GLuint timestampQuery; + } endFrame; + struct { + float x, y, w, h; + float d0, d1; + } viewport; + struct { + int x, y, w, h; + } scissor; + struct { + float r, g, b, a; + } blendConstants; + struct { + quint32 ref; + QRhiGraphicsPipeline *ps; + } stencilRef; + struct { + QRhiGraphicsPipeline *ps; + GLuint buffer; + quint32 offset; + int binding; + } bindVertexBuffer; + struct { + GLuint buffer; + quint32 offset; + GLenum type; + } bindIndexBuffer; + struct { + QRhiGraphicsPipeline *ps; + quint32 vertexCount; + quint32 firstVertex; + quint32 instanceCount; + quint32 baseInstance; + } draw; + struct { + QRhiGraphicsPipeline *ps; + quint32 indexCount; + quint32 firstIndex; + quint32 instanceCount; + quint32 baseInstance; + qint32 baseVertex; + } drawIndexed; + struct { + QRhiGraphicsPipeline *ps; + } bindGraphicsPipeline; + struct { + QRhiGraphicsPipeline *maybeGraphicsPs; + QRhiComputePipeline *maybeComputePs; + QRhiShaderResourceBindings *srb; + int dynamicOffsetCount; + uint dynamicOffsetPairs[MAX_DYNAMIC_OFFSET_COUNT * 2]; // binding, offset + } bindShaderResources; + struct { + GLbitfield mask; + float c[4]; + float d; + quint32 s; + } clear; + struct { + GLuint fbo; + bool srgb; + int colorAttCount; + bool stereo; + QRhiSwapChain::StereoTargetBuffer stereoTarget; + } bindFramebuffer; + struct { + GLenum target; + GLuint buffer; + int offset; + int size; + const void *data; // must come from retainData() + } bufferSubData; + struct { + QRhiReadbackResult *result; + GLenum target; + GLuint buffer; + int offset; + int size; + } getBufferSubData; + struct { + GLenum srcTarget; + GLenum srcFaceTarget; + GLuint srcTexture; + int srcLevel; + int srcX; + int srcY; + int srcZ; + GLenum dstTarget; + GLuint dstTexture; + GLenum dstFaceTarget; + int dstLevel; + int dstX; + int dstY; + int dstZ; + int w; + int h; + } copyTex; + struct { + QRhiReadbackResult *result; + GLuint texture; + int w; + int h; + QRhiTexture::Format format; + GLenum readTarget; + int level; + int slice3D; + } readPixels; + struct { + GLenum target; + GLuint texture; + GLenum faceTarget; + int level; + int dx; + int dy; + int dz; + int w; + int h; + GLenum glformat; + GLenum gltype; + int rowStartAlign; + int rowLength; + const void *data; // must come from retainImage() + } subImage; + struct { + GLenum target; + GLuint texture; + GLenum faceTarget; + int level; + GLenum glintformat; + int w; + int h; + int depth; + int size; + const void *data; // must come from retainData() + } compressedImage; + struct { + GLenum target; + GLuint texture; + GLenum faceTarget; + int level; + int dx; + int dy; + int dz; + int w; + int h; + GLenum glintformat; + int size; + const void *data; // must come from retainData() + } compressedSubImage; + struct { + GLuint renderbuffer; + int w; + int h; + GLenum target; + GLuint dstTexture; + int dstLevel; + int dstLayer; + bool isDepthStencil; + } blitFromRenderbuffer; + struct { + GLenum srcTarget; + GLuint srcTexture; + int srcLevel; + int srcLayer; + int w; + int h; + GLenum dstTarget; + GLuint dstTexture; + int dstLevel; + int dstLayer; + bool isDepthStencil; + } blitFromTexture; + struct { + GLenum target; + GLuint texture; + } genMip; + struct { + QRhiComputePipeline *ps; + } bindComputePipeline; + struct { + GLuint x; + GLuint y; + GLuint z; + } dispatch; + struct { + int trackerIndex; + } barriersForPass; + struct { + GLbitfield barriers; + } barrier; + struct { + int attCount; + GLenum att[3]; + } invalidateFramebuffer; + } args; + }; + + enum PassType { + NoPass, + RenderPass, + ComputePass + }; + + QRhiBackendCommandList<Command> commands; + QVarLengthArray<QRhiPassResourceTracker, 8> passResTrackers; + int currentPassResTrackerIndex; + + PassType recordingPass; + bool passNeedsResourceTracking; + double lastGpuTime = 0; + QRhiRenderTarget *currentTarget; + QRhiGraphicsPipeline *currentGraphicsPipeline; + QRhiComputePipeline *currentComputePipeline; + uint currentPipelineGeneration; + QRhiShaderResourceBindings *currentGraphicsSrb; + QRhiShaderResourceBindings *currentComputeSrb; + uint currentSrbGeneration; + + struct GraphicsPassState { + bool valid = false; + bool scissor; + bool cullFace; + GLenum cullMode; + GLenum frontFace; + bool blendEnabled; + struct ColorMask { bool r, g, b, a; } colorMask; + struct Blend { + GLenum srcColor; + GLenum dstColor; + GLenum srcAlpha; + GLenum dstAlpha; + GLenum opColor; + GLenum opAlpha; + } blend; + bool depthTest; + bool depthWrite; + GLenum depthFunc; + bool stencilTest; + GLuint stencilReadMask; + GLuint stencilWriteMask; + struct StencilFace { + GLenum func; + GLenum failOp; + GLenum zfailOp; + GLenum zpassOp; + } stencil[2]; // front, back + bool polyOffsetFill; + float polyOffsetFactor; + float polyOffsetUnits; + float lineWidth; + int cpCount; + GLenum polygonMode; + void reset() { valid = false; } + struct { + // not part of QRhiGraphicsPipeline but used by setGraphicsPipeline() + GLint stencilRef = 0; + } dynamic; + } graphicsPassState; + + struct ComputePassState { + enum Access { + Read = 0x01, + Write = 0x02 + }; + QHash<QRhiResource *, QPair<int, bool> > writtenResources; + void reset() { + writtenResources.clear(); + } + } computePassState; + + struct TextureUnitState { + void *ps; + uint psGeneration; + uint texture; + } textureUnitState[16]; + + QVarLengthArray<QByteArray, 4> dataRetainPool; + QVarLengthArray<QRhiBufferData, 4> bufferDataRetainPool; + QVarLengthArray<QImage, 4> imageRetainPool; + + // relies heavily on implicit sharing (no copies of the actual data will be made) + const void *retainData(const QByteArray &data) { + dataRetainPool.append(data); + return dataRetainPool.last().constData(); + } + const uchar *retainBufferData(const QRhiBufferData &data) { + bufferDataRetainPool.append(data); + return reinterpret_cast<const uchar *>(bufferDataRetainPool.last().constData()); + } + const void *retainImage(const QImage &image) { + imageRetainPool.append(image); + return imageRetainPool.last().constBits(); + } + void resetCommands() { + commands.reset(); + dataRetainPool.clear(); + bufferDataRetainPool.clear(); + imageRetainPool.clear(); + + passResTrackers.clear(); + currentPassResTrackerIndex = -1; + } + void resetState() { + recordingPass = NoPass; + passNeedsResourceTracking = true; + // do not zero lastGpuTime + currentTarget = nullptr; + resetCommands(); + resetCachedState(); + } + void resetCachedState() { + currentGraphicsPipeline = nullptr; + currentComputePipeline = nullptr; + currentPipelineGeneration = 0; + currentGraphicsSrb = nullptr; + currentComputeSrb = nullptr; + currentSrbGeneration = 0; + graphicsPassState.reset(); + computePassState.reset(); + memset(textureUnitState, 0, sizeof(textureUnitState)); + } +}; + +inline bool operator==(const QGles2CommandBuffer::GraphicsPassState::StencilFace &a, + const QGles2CommandBuffer::GraphicsPassState::StencilFace &b) +{ + return a.func == b.func + && a.failOp == b.failOp + && a.zfailOp == b.zfailOp + && a.zpassOp == b.zpassOp; +} + +inline bool operator!=(const QGles2CommandBuffer::GraphicsPassState::StencilFace &a, + const QGles2CommandBuffer::GraphicsPassState::StencilFace &b) +{ + return !(a == b); +} + +inline bool operator==(const QGles2CommandBuffer::GraphicsPassState::ColorMask &a, + const QGles2CommandBuffer::GraphicsPassState::ColorMask &b) +{ + return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; +} + +inline bool operator!=(const QGles2CommandBuffer::GraphicsPassState::ColorMask &a, + const QGles2CommandBuffer::GraphicsPassState::ColorMask &b) +{ + return !(a == b); +} + +inline bool operator==(const QGles2CommandBuffer::GraphicsPassState::Blend &a, + const QGles2CommandBuffer::GraphicsPassState::Blend &b) +{ + return a.srcColor == b.srcColor + && a.dstColor == b.dstColor + && a.srcAlpha == b.srcAlpha + && a.dstAlpha == b.dstAlpha + && a.opColor == b.opColor + && a.opAlpha == b.opAlpha; +} + +inline bool operator!=(const QGles2CommandBuffer::GraphicsPassState::Blend &a, + const QGles2CommandBuffer::GraphicsPassState::Blend &b) +{ + return !(a == b); +} + +struct QGles2SwapChainTimestamps +{ + static const int TIMESTAMP_PAIRS = 2; + + bool active[TIMESTAMP_PAIRS] = {}; + GLuint query[TIMESTAMP_PAIRS * 2] = {}; + + void prepare(QRhiGles2 *rhiD); + void destroy(QRhiGles2 *rhiD); + bool tryQueryTimestamps(int pairIndex, QRhiGles2 *rhiD, double *elapsedSec); +}; + +struct QGles2SwapChain : public QRhiSwapChain +{ + QGles2SwapChain(QRhiImplementation *rhi); + ~QGles2SwapChain(); + void destroy() override; + + QRhiCommandBuffer *currentFrameCommandBuffer() override; + QRhiRenderTarget *currentFrameRenderTarget() override; + QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer) override; + + QSize surfacePixelSize() override; + bool isFormatSupported(Format f) override; + + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; + bool createOrResize() override; + + void initSwapChainRenderTarget(QGles2SwapChainRenderTarget *rt); + + QSurface *surface = nullptr; + QSize pixelSize; + QGles2SwapChainRenderTarget rt; + QGles2SwapChainRenderTarget rtLeft; + QGles2SwapChainRenderTarget rtRight; + QGles2CommandBuffer cb; + int frameCount = 0; + QGles2SwapChainTimestamps timestamps; + int currentTimestampPairIndex = 0; +}; + +class QRhiGles2 : public QRhiImplementation +{ +public: + QRhiGles2(QRhiGles2InitParams *params, QRhiGles2NativeHandles *importDevice = nullptr); + + bool create(QRhi::Flags flags) override; + void destroy() override; + + QRhiGraphicsPipeline *createGraphicsPipeline() override; + QRhiComputePipeline *createComputePipeline() override; + QRhiShaderResourceBindings *createShaderResourceBindings() override; + QRhiBuffer *createBuffer(QRhiBuffer::Type type, + QRhiBuffer::UsageFlags usage, + quint32 size) override; + QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type, + const QSize &pixelSize, + int sampleCount, + QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint) override; + QRhiTexture *createTexture(QRhiTexture::Format format, + const QSize &pixelSize, + int depth, + int arraySize, + int sampleCount, + QRhiTexture::Flags flags) override; + QRhiSampler *createSampler(QRhiSampler::Filter magFilter, + QRhiSampler::Filter minFilter, + QRhiSampler::Filter mipmapMode, + QRhiSampler:: AddressMode u, + QRhiSampler::AddressMode v, + QRhiSampler::AddressMode w) override; + + QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, + QRhiTextureRenderTarget::Flags flags) override; + + QRhiSwapChain *createSwapChain() override; + QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override; + QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override; + QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override; + QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override; + QRhi::FrameOpResult finish() override; + + void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + + void beginPass(QRhiCommandBuffer *cb, + QRhiRenderTarget *rt, + const QColor &colorClearValue, + const QRhiDepthStencilClearValue &depthStencilClearValue, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) override; + void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + + void setGraphicsPipeline(QRhiCommandBuffer *cb, + QRhiGraphicsPipeline *ps) override; + + void setShaderResources(QRhiCommandBuffer *cb, + QRhiShaderResourceBindings *srb, + int dynamicOffsetCount, + const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override; + + void setVertexInput(QRhiCommandBuffer *cb, + int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, + QRhiBuffer *indexBuf, quint32 indexOffset, + QRhiCommandBuffer::IndexFormat indexFormat) override; + + void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override; + void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override; + void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override; + void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override; + + void draw(QRhiCommandBuffer *cb, quint32 vertexCount, + quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override; + + void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, + quint32 instanceCount, quint32 firstIndex, + qint32 vertexOffset, quint32 firstInstance) override; + + void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override; + void debugMarkEnd(QRhiCommandBuffer *cb) override; + void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override; + + void beginComputePass(QRhiCommandBuffer *cb, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) override; + void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override; + void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override; + + const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) override; + void beginExternal(QRhiCommandBuffer *cb) override; + void endExternal(QRhiCommandBuffer *cb) override; + double lastCompletedGpuTime(QRhiCommandBuffer *cb) override; + + QList<int> supportedSampleCounts() const override; + int ubufAlignment() const override; + bool isYUpInFramebuffer() const override; + bool isYUpInNDC() const override; + bool isClipDepthZeroToOne() const override; + QMatrix4x4 clipSpaceCorrMatrix() const override; + bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override; + bool isFeatureSupported(QRhi::Feature feature) const override; + int resourceLimit(QRhi::ResourceLimit limit) const override; + const QRhiNativeHandles *nativeHandles() override; + QRhiDriverInfo driverInfo() const override; + QRhiStats statistics() override; + bool makeThreadLocalNativeContextCurrent() override; + void releaseCachedResources() override; + bool isDeviceLost() const override; + + QByteArray pipelineCacheData() override; + void setPipelineCacheData(const QByteArray &data) override; + + bool ensureContext(QSurface *surface = nullptr) const; + QSurface *evaluateFallbackSurface() const; + void executeDeferredReleases(); + void trackedBufferBarrier(QGles2CommandBuffer *cbD, QGles2Buffer *bufD, QGles2Buffer::Access access); + void trackedImageBarrier(QGles2CommandBuffer *cbD, QGles2Texture *texD, QGles2Texture::Access access); + void enqueueSubresUpload(QGles2Texture *texD, QGles2CommandBuffer *cbD, + int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc); + void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates); + void trackedRegisterBuffer(QRhiPassResourceTracker *passResTracker, + QGles2Buffer *bufD, + QRhiPassResourceTracker::BufferAccess access, + QRhiPassResourceTracker::BufferStage stage); + void trackedRegisterTexture(QRhiPassResourceTracker *passResTracker, + QGles2Texture *texD, + QRhiPassResourceTracker::TextureAccess access, + QRhiPassResourceTracker::TextureStage stage); + void executeCommandBuffer(QRhiCommandBuffer *cb); + void executeBindGraphicsPipeline(QGles2CommandBuffer *cbD, QGles2GraphicsPipeline *psD); + void bindCombinedSampler(QGles2CommandBuffer *cbD, QGles2Texture *texD, QGles2Sampler *samplerD, + void *ps, uint psGeneration, int glslLocation, + int *texUnit, bool *activeTexUnitAltered); + void bindShaderResources(QGles2CommandBuffer *cbD, + QRhiGraphicsPipeline *maybeGraphicsPs, QRhiComputePipeline *maybeComputePs, + QRhiShaderResourceBindings *srb, + const uint *dynOfsPairs, int dynOfsCount); + QGles2RenderTargetData *enqueueBindFramebuffer(QRhiRenderTarget *rt, QGles2CommandBuffer *cbD, + bool *wantsColorClear = nullptr, bool *wantsDsClear = nullptr); + void enqueueBarriersForPass(QGles2CommandBuffer *cbD); + QByteArray shaderSource(const QRhiShaderStage &shaderStage, QShaderVersion *shaderVersion); + bool compileShader(GLuint program, const QRhiShaderStage &shaderStage, QShaderVersion *shaderVersion); + bool linkProgram(GLuint program); + using ActiveUniformLocationTracker = QDuplicateTracker<int, 32>; + void registerUniformIfActive(const QShaderDescription::BlockVariable &var, + const QByteArray &namePrefix, int binding, int baseOffset, + GLuint program, + ActiveUniformLocationTracker *activeUniformLocations, + QGles2UniformDescriptionVector *dst); + void gatherUniforms(GLuint program, const QShaderDescription::UniformBlock &ub, + ActiveUniformLocationTracker *activeUniformLocations, QGles2UniformDescriptionVector *dst); + void gatherSamplers(GLuint program, const QShaderDescription::InOutVariable &v, + QGles2SamplerDescriptionVector *dst); + void gatherGeneratedSamplers(GLuint program, + const QShader::SeparateToCombinedImageSamplerMapping &mapping, + QGles2SamplerDescriptionVector *dst); + void sanityCheckVertexFragmentInterface(const QShaderDescription &vsDesc, const QShaderDescription &fsDesc); + bool isProgramBinaryDiskCacheEnabled() const; + + enum ProgramCacheResult { + ProgramCacheHit, + ProgramCacheMiss, + ProgramCacheError + }; + ProgramCacheResult tryLoadFromDiskOrPipelineCache(const QRhiShaderStage *stages, + int stageCount, + GLuint program, + const QVector<QShaderDescription::InOutVariable> &inputVars, + QByteArray *cacheKey); + void trySaveToDiskCache(GLuint program, const QByteArray &cacheKey); + void trySaveToPipelineCache(GLuint program, const QByteArray &cacheKey, bool force = false); + + QRhi::Flags rhiFlags; + QOpenGLContext *ctx = nullptr; + bool importedContext = false; + QSurfaceFormat requestedFormat; + QSurface *fallbackSurface = nullptr; + QPointer<QWindow> maybeWindow = nullptr; + QOpenGLContext *maybeShareContext = nullptr; + mutable bool needsMakeCurrentDueToSwap = false; + QOpenGLExtensions *f = nullptr; + void (QOPENGLF_APIENTRYP glPolygonMode) (GLenum, GLenum) = nullptr; + void(QOPENGLF_APIENTRYP glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, + const void *) = nullptr; + void(QOPENGLF_APIENTRYP glTexStorage1D)(GLenum, GLint, GLenum, GLsizei) = nullptr; + void(QOPENGLF_APIENTRYP glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, + const GLvoid *) = nullptr; + void(QOPENGLF_APIENTRYP glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, + GLsizei) = nullptr; + void(QOPENGLF_APIENTRYP glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, + const GLvoid *) = nullptr; + void(QOPENGLF_APIENTRYP glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, + GLsizei, const GLvoid *) = nullptr; + void(QOPENGLF_APIENTRYP glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, + GLint) = nullptr; + void(QOPENGLF_APIENTRYP glFramebufferTextureMultiviewOVR)(GLenum, GLenum, GLuint, GLint, + GLint, GLsizei) = nullptr; + void (QOPENGLF_APIENTRYP glQueryCounter)(GLuint, GLenum) = nullptr; + void (QOPENGLF_APIENTRYP glGetQueryObjectui64v)(GLuint, GLenum, quint64 *) = nullptr; + void (QOPENGLF_APIENTRYP glObjectLabel)(GLenum, GLuint, GLsizei, const GLchar *) = nullptr; + void (QOPENGLF_APIENTRYP glFramebufferTexture2DMultisampleEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) = nullptr; + void (QOPENGLF_APIENTRYP glFramebufferTextureMultisampleMultiviewOVR)(GLenum, GLenum, GLuint, GLint, GLsizei, GLint, GLsizei) = nullptr; + uint vao = 0; + struct Caps { + Caps() + : ctxMajor(2), + ctxMinor(0), + maxTextureSize(2048), + maxDrawBuffers(4), + maxSamples(16), + maxTextureArraySize(0), + maxThreadGroupsPerDimension(0), + maxThreadsPerThreadGroup(0), + maxThreadGroupsX(0), + maxThreadGroupsY(0), + maxThreadGroupsZ(0), + maxUniformVectors(4096), + maxVertexInputs(8), + maxVertexOutputs(8), + msaaRenderBuffer(false), + multisampledTexture(false), + npotTextureFull(true), + gles(false), + fixedIndexPrimitiveRestart(false), + bgraExternalFormat(false), + bgraInternalFormat(false), + r8Format(false), + r16Format(false), + floatFormats(false), + rgb10Formats(false), + depthTexture(false), + packedDepthStencil(false), + needsDepthStencilCombinedAttach(false), + srgbWriteControl(false), + coreProfile(false), + uniformBuffers(false), + elementIndexUint(false), + depth24(false), + rgba8Format(false), + instancing(false), + baseVertex(false), + compute(false), + textureCompareMode(false), + properMapBuffer(false), + nonBaseLevelFramebufferTexture(false), + texelFetch(false), + intAttributes(true), + screenSpaceDerivatives(false), + programBinary(false), + texture3D(false), + tessellation(false), + geometryShader(false), + texture1D(false), + hasDrawBuffersFunc(false), + halfAttributes(false), + multiView(false), + timestamps(false), + objectLabel(false), + glesMultisampleRenderToTexture(false), + glesMultiviewMultisampleRenderToTexture(false), + unpackRowLength(false) + { } + int ctxMajor; + int ctxMinor; + int maxTextureSize; + int maxDrawBuffers; + int maxSamples; + int maxTextureArraySize; + int maxThreadGroupsPerDimension; + int maxThreadsPerThreadGroup; + int maxThreadGroupsX; + int maxThreadGroupsY; + int maxThreadGroupsZ; + int maxUniformVectors; + int maxVertexInputs; + int maxVertexOutputs; + // Multisample fb and blit are supported (GLES 3.0 or OpenGL 3.x). Not + // the same as multisample textures! + uint msaaRenderBuffer : 1; + uint multisampledTexture : 1; + uint npotTextureFull : 1; + uint gles : 1; + uint fixedIndexPrimitiveRestart : 1; + uint bgraExternalFormat : 1; + uint bgraInternalFormat : 1; + uint r8Format : 1; + uint r16Format : 1; + uint floatFormats : 1; + uint rgb10Formats : 1; + uint depthTexture : 1; + uint packedDepthStencil : 1; + uint needsDepthStencilCombinedAttach : 1; + uint srgbWriteControl : 1; + uint coreProfile : 1; + uint uniformBuffers : 1; + uint elementIndexUint : 1; + uint depth24 : 1; + uint rgba8Format : 1; + uint instancing : 1; + uint baseVertex : 1; + uint compute : 1; + uint textureCompareMode : 1; + uint properMapBuffer : 1; + uint nonBaseLevelFramebufferTexture : 1; + uint texelFetch : 1; + uint intAttributes : 1; + uint screenSpaceDerivatives : 1; + uint programBinary : 1; + uint texture3D : 1; + uint tessellation : 1; + uint geometryShader : 1; + uint texture1D : 1; + uint hasDrawBuffersFunc : 1; + uint halfAttributes : 1; + uint multiView : 1; + uint timestamps : 1; + uint objectLabel : 1; + uint glesMultisampleRenderToTexture : 1; + uint glesMultiviewMultisampleRenderToTexture : 1; + uint unpackRowLength : 1; + } caps; + QGles2SwapChain *currentSwapChain = nullptr; + QSet<GLint> supportedCompressedFormats; + mutable QList<int> supportedSampleCountList; + QRhiGles2NativeHandles nativeHandlesStruct; + QRhiDriverInfo driverInfoStruct; + mutable bool contextLost = false; + + struct DeferredReleaseEntry { + enum Type { + Buffer, + Pipeline, + Texture, + RenderBuffer, + TextureRenderTarget + }; + Type type; + union { + struct { + GLuint buffer; + } buffer; + struct { + GLuint program; + } pipeline; + struct { + GLuint texture; + } texture; + struct { + GLuint renderbuffer; + GLuint renderbuffer2; + } renderbuffer; + struct { + GLuint framebuffer; + GLuint nonMsaaThrowawayDepthTexture; + } textureRenderTarget; + }; + }; + QList<DeferredReleaseEntry> releaseQueue; + + struct OffscreenFrame { + OffscreenFrame(QRhiImplementation *rhi) : cbWrapper(rhi) { } + bool active = false; + QGles2CommandBuffer cbWrapper; + GLuint tsQueries[2] = {}; + } ofr; + + QHash<QRhiShaderStage, uint> m_shaderCache; + + struct PipelineCacheData { + quint32 format; + QByteArray data; + }; + QHash<QByteArray, PipelineCacheData> m_pipelineCache; + + struct Scratch { + union data32_t { + float f; + qint32 i; + }; + QVarLengthArray<data32_t, 128> packedArray; + struct SeparateTexture { + QGles2Texture *texture; + int binding; + int elem; + }; + QVarLengthArray<SeparateTexture, 8> separateTextureBindings; + struct SeparateSampler { + QGles2Sampler *sampler; + int binding; + }; + QVarLengthArray<SeparateSampler, 4> separateSamplerBindings; + } m_scratch; +}; + +Q_DECLARE_TYPEINFO(QRhiGles2::DeferredReleaseEntry, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhinull_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhinull_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bd5eae6509d0b52cdf49c1678a57282e48e46f12 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhinull_p.h @@ -0,0 +1,295 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRHINULL_P_H +#define QRHINULL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qrhi_p.h" + +QT_BEGIN_NAMESPACE + +struct QNullBuffer : public QRhiBuffer +{ + QNullBuffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size); + ~QNullBuffer(); + void destroy() override; + bool create() override; + char *beginFullDynamicBufferUpdateForCurrentFrame() override; + + char *data = nullptr; +}; + +struct QNullRenderBuffer : public QRhiRenderBuffer +{ + QNullRenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, + int sampleCount, QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint); + ~QNullRenderBuffer(); + void destroy() override; + bool create() override; + QRhiTexture::Format backingFormat() const override; + + bool valid = false; + uint generation = 0; +}; + +struct QNullTexture : public QRhiTexture +{ + QNullTexture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, + int arraySize, int sampleCount, Flags flags); + ~QNullTexture(); + void destroy() override; + bool create() override; + bool createFrom(NativeTexture src) override; + + bool valid = false; + QVarLengthArray<std::array<QImage, QRhi::MAX_MIP_LEVELS>, 6> image; + uint generation = 0; +}; + +struct QNullSampler : public QRhiSampler +{ + QNullSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, + AddressMode u, AddressMode v, AddressMode w); + ~QNullSampler(); + void destroy() override; + bool create() override; +}; + +struct QNullRenderPassDescriptor : public QRhiRenderPassDescriptor +{ + QNullRenderPassDescriptor(QRhiImplementation *rhi); + ~QNullRenderPassDescriptor(); + void destroy() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() const override; + QVector<quint32> serializedFormat() const override; +}; + +struct QNullRenderTargetData +{ + QNullRenderTargetData(QRhiImplementation *) { } + + QNullRenderPassDescriptor *rp = nullptr; + QSize pixelSize; + float dpr = 1; + QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList; +}; + +struct QNullSwapChainRenderTarget : public QRhiSwapChainRenderTarget +{ + QNullSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain); + ~QNullSwapChainRenderTarget(); + void destroy() override; + + QSize pixelSize() const override; + float devicePixelRatio() const override; + int sampleCount() const override; + + QNullRenderTargetData d; +}; + +struct QNullTextureRenderTarget : public QRhiTextureRenderTarget +{ + QNullTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags); + ~QNullTextureRenderTarget(); + void destroy() override; + + QSize pixelSize() const override; + float devicePixelRatio() const override; + int sampleCount() const override; + + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; + bool create() override; + + QNullRenderTargetData d; +}; + +struct QNullShaderResourceBindings : public QRhiShaderResourceBindings +{ + QNullShaderResourceBindings(QRhiImplementation *rhi); + ~QNullShaderResourceBindings(); + void destroy() override; + bool create() override; + void updateResources(UpdateFlags flags) override; +}; + +struct QNullGraphicsPipeline : public QRhiGraphicsPipeline +{ + QNullGraphicsPipeline(QRhiImplementation *rhi); + ~QNullGraphicsPipeline(); + void destroy() override; + bool create() override; +}; + +struct QNullComputePipeline : public QRhiComputePipeline +{ + QNullComputePipeline(QRhiImplementation *rhi); + ~QNullComputePipeline(); + void destroy() override; + bool create() override; +}; + +struct QNullCommandBuffer : public QRhiCommandBuffer +{ + QNullCommandBuffer(QRhiImplementation *rhi); + ~QNullCommandBuffer(); + void destroy() override; +}; + +struct QNullSwapChain : public QRhiSwapChain +{ + QNullSwapChain(QRhiImplementation *rhi); + ~QNullSwapChain(); + void destroy() override; + + QRhiCommandBuffer *currentFrameCommandBuffer() override; + QRhiRenderTarget *currentFrameRenderTarget() override; + + QSize surfacePixelSize() override; + bool isFormatSupported(Format f) override; + + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; + bool createOrResize() override; + + QWindow *window = nullptr; + QNullSwapChainRenderTarget rt; + QNullCommandBuffer cb; + int frameCount = 0; +}; + +class QRhiNull : public QRhiImplementation +{ +public: + QRhiNull(QRhiNullInitParams *params); + + bool create(QRhi::Flags flags) override; + void destroy() override; + + QRhiGraphicsPipeline *createGraphicsPipeline() override; + QRhiComputePipeline *createComputePipeline() override; + QRhiShaderResourceBindings *createShaderResourceBindings() override; + QRhiBuffer *createBuffer(QRhiBuffer::Type type, + QRhiBuffer::UsageFlags usage, + quint32 size) override; + QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type, + const QSize &pixelSize, + int sampleCount, + QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint) override; + QRhiTexture *createTexture(QRhiTexture::Format format, + const QSize &pixelSize, + int depth, + int arraySize, + int sampleCount, + QRhiTexture::Flags flags) override; + QRhiSampler *createSampler(QRhiSampler::Filter magFilter, + QRhiSampler::Filter minFilter, + QRhiSampler::Filter mipmapMode, + QRhiSampler:: AddressMode u, + QRhiSampler::AddressMode v, + QRhiSampler::AddressMode w) override; + + QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, + QRhiTextureRenderTarget::Flags flags) override; + + QRhiSwapChain *createSwapChain() override; + QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override; + QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override; + QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override; + QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override; + QRhi::FrameOpResult finish() override; + + void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + + void beginPass(QRhiCommandBuffer *cb, + QRhiRenderTarget *rt, + const QColor &colorClearValue, + const QRhiDepthStencilClearValue &depthStencilClearValue, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) override; + void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + + void setGraphicsPipeline(QRhiCommandBuffer *cb, + QRhiGraphicsPipeline *ps) override; + + void setShaderResources(QRhiCommandBuffer *cb, + QRhiShaderResourceBindings *srb, + int dynamicOffsetCount, + const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override; + + void setVertexInput(QRhiCommandBuffer *cb, + int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, + QRhiBuffer *indexBuf, quint32 indexOffset, + QRhiCommandBuffer::IndexFormat indexFormat) override; + + void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override; + void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override; + void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override; + void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override; + + void draw(QRhiCommandBuffer *cb, quint32 vertexCount, + quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override; + + void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, + quint32 instanceCount, quint32 firstIndex, + qint32 vertexOffset, quint32 firstInstance) override; + + void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override; + void debugMarkEnd(QRhiCommandBuffer *cb) override; + void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override; + + void beginComputePass(QRhiCommandBuffer *cb, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) override; + void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override; + void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override; + + const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) override; + void beginExternal(QRhiCommandBuffer *cb) override; + void endExternal(QRhiCommandBuffer *cb) override; + double lastCompletedGpuTime(QRhiCommandBuffer *cb) override; + + QList<int> supportedSampleCounts() const override; + int ubufAlignment() const override; + bool isYUpInFramebuffer() const override; + bool isYUpInNDC() const override; + bool isClipDepthZeroToOne() const override; + QMatrix4x4 clipSpaceCorrMatrix() const override; + bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override; + bool isFeatureSupported(QRhi::Feature feature) const override; + int resourceLimit(QRhi::ResourceLimit limit) const override; + const QRhiNativeHandles *nativeHandles() override; + QRhiDriverInfo driverInfo() const override; + QRhiStats statistics() override; + bool makeThreadLocalNativeContextCurrent() override; + void releaseCachedResources() override; + bool isDeviceLost() const override; + + QByteArray pipelineCacheData() override; + void setPipelineCacheData(const QByteArray &data) override; + + void simulateTextureUpload(const QRhiResourceUpdateBatchPrivate::TextureOp &u); + void simulateTextureCopy(const QRhiResourceUpdateBatchPrivate::TextureOp &u); + void simulateTextureGenMips(const QRhiResourceUpdateBatchPrivate::TextureOp &u); + + QRhiNullNativeHandles nativeHandlesStruct; + QRhiSwapChain *currentSwapChain = nullptr; + QNullCommandBuffer offscreenCommandBuffer; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhivulkan_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhivulkan_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f380c08145d2db373b643901725437fe0789593e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qrhivulkan_p.h @@ -0,0 +1,1039 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRHIVULKAN_P_H +#define QRHIVULKAN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qrhi_p.h" + +QT_BEGIN_NAMESPACE + +class QVulkanFunctions; +class QVulkanDeviceFunctions; + +static const int QVK_FRAMES_IN_FLIGHT = 2; + +static const int QVK_DESC_SETS_PER_POOL = 128; +static const int QVK_UNIFORM_BUFFERS_PER_POOL = 256; +static const int QVK_COMBINED_IMAGE_SAMPLERS_PER_POOL = 256; +static const int QVK_STORAGE_BUFFERS_PER_POOL = 128; +static const int QVK_STORAGE_IMAGES_PER_POOL = 128; + +static const int QVK_MAX_ACTIVE_TIMESTAMP_PAIRS = 16; + +// no vk_mem_alloc.h available here, void* is good enough +typedef void * QVkAlloc; +typedef void * QVkAllocator; + +struct QVkBuffer : public QRhiBuffer +{ + QVkBuffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size); + ~QVkBuffer(); + void destroy() override; + bool create() override; + QRhiBuffer::NativeBuffer nativeBuffer() override; + char *beginFullDynamicBufferUpdateForCurrentFrame() override; + void endFullDynamicBufferUpdateForCurrentFrame() override; + + VkBuffer buffers[QVK_FRAMES_IN_FLIGHT]; + QVkAlloc allocations[QVK_FRAMES_IN_FLIGHT]; + struct DynamicUpdate { + quint32 offset; + QRhiBufferData data; + }; + QVarLengthArray<DynamicUpdate, 16> pendingDynamicUpdates[QVK_FRAMES_IN_FLIGHT]; + VkBuffer stagingBuffers[QVK_FRAMES_IN_FLIGHT]; + QVkAlloc stagingAllocations[QVK_FRAMES_IN_FLIGHT]; + struct UsageState { + VkAccessFlags access = 0; + VkPipelineStageFlags stage = 0; + }; + UsageState usageState[QVK_FRAMES_IN_FLIGHT]; + int lastActiveFrameSlot = -1; + uint generation = 0; + friend class QRhiVulkan; +}; + +Q_DECLARE_TYPEINFO(QVkBuffer::DynamicUpdate, Q_RELOCATABLE_TYPE); + +struct QVkTexture; + +struct QVkRenderBuffer : public QRhiRenderBuffer +{ + QVkRenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, + int sampleCount, Flags flags, + QRhiTexture::Format backingFormatHint); + ~QVkRenderBuffer(); + void destroy() override; + bool create() override; + QRhiTexture::Format backingFormat() const override; + + VkDeviceMemory memory = VK_NULL_HANDLE; + VkImage image = VK_NULL_HANDLE; + VkImageView imageView = VK_NULL_HANDLE; + VkSampleCountFlagBits samples; + QVkTexture *backingTexture = nullptr; + VkFormat vkformat; + int lastActiveFrameSlot = -1; + uint generation = 0; + friend class QRhiVulkan; +}; + +struct QVkTexture : public QRhiTexture +{ + QVkTexture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, + int arraySize, int sampleCount, Flags flags); + ~QVkTexture(); + void destroy() override; + bool create() override; + bool createFrom(NativeTexture src) override; + NativeTexture nativeTexture() override; + void setNativeLayout(int layout) override; + + bool prepareCreate(QSize *adjustedSize = nullptr); + bool finishCreate(); + VkImageView perLevelImageViewForLoadStore(int level); + + VkImage image = VK_NULL_HANDLE; + VkImageView imageView = VK_NULL_HANDLE; + QVkAlloc imageAlloc = nullptr; + VkBuffer stagingBuffers[QVK_FRAMES_IN_FLIGHT]; + QVkAlloc stagingAllocations[QVK_FRAMES_IN_FLIGHT]; + VkImageView perLevelImageViews[QRhi::MAX_MIP_LEVELS]; + bool owns = true; + struct UsageState { + // no tracking of subresource layouts (some operations can keep + // subresources in different layouts for some time, but that does not + // need to be kept track of) + VkImageLayout layout; + VkAccessFlags access; + VkPipelineStageFlags stage; + }; + UsageState usageState; + VkFormat vkformat; + uint mipLevelCount = 0; + VkSampleCountFlagBits samples; + VkFormat viewFormat; + VkFormat viewFormatForSampling; + int lastActiveFrameSlot = -1; + uint generation = 0; + friend class QRhiVulkan; +}; + +struct QVkSampler : public QRhiSampler +{ + QVkSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, + AddressMode u, AddressMode v, AddressMode w); + ~QVkSampler(); + void destroy() override; + bool create() override; + + VkSampler sampler = VK_NULL_HANDLE; + int lastActiveFrameSlot = -1; + uint generation = 0; + friend class QRhiVulkan; +}; + +struct QVkRenderPassDescriptor : public QRhiRenderPassDescriptor +{ + QVkRenderPassDescriptor(QRhiImplementation *rhi); + ~QVkRenderPassDescriptor(); + void destroy() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() const override; + QVector<quint32> serializedFormat() const override; + const QRhiNativeHandles *nativeHandles() override; + + void updateSerializedFormat(); + + VkRenderPass rp = VK_NULL_HANDLE; + bool ownsRp = false; + QVarLengthArray<VkAttachmentDescription, 8> attDescs; + QVarLengthArray<VkAttachmentReference, 8> colorRefs; + QVarLengthArray<VkAttachmentReference, 8> resolveRefs; + QVarLengthArray<VkSubpassDependency, 2> subpassDeps; + bool hasDepthStencil = false; + bool hasDepthStencilResolve = false; + uint32_t multiViewCount = 0; + VkAttachmentReference dsRef; + VkAttachmentReference dsResolveRef; + QVector<quint32> serializedFormatData; + QRhiVulkanRenderPassNativeHandles nativeHandlesStruct; + int lastActiveFrameSlot = -1; +}; + +struct QVkRenderTargetData +{ + VkFramebuffer fb = VK_NULL_HANDLE; + QVkRenderPassDescriptor *rp = nullptr; + QSize pixelSize; + float dpr = 1; + int sampleCount = 1; + int colorAttCount = 0; + int dsAttCount = 0; + int resolveAttCount = 0; + int dsResolveAttCount = 0; + int multiViewCount = 0; + QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList; + static const int MAX_COLOR_ATTACHMENTS = 8; +}; + +struct QVkSwapChainRenderTarget : public QRhiSwapChainRenderTarget +{ + QVkSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain); + ~QVkSwapChainRenderTarget(); + void destroy() override; + + QSize pixelSize() const override; + float devicePixelRatio() const override; + int sampleCount() const override; + + QVkRenderTargetData d; +}; + +struct QVkTextureRenderTarget : public QRhiTextureRenderTarget +{ + QVkTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags); + ~QVkTextureRenderTarget(); + void destroy() override; + + QSize pixelSize() const override; + float devicePixelRatio() const override; + int sampleCount() const override; + + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; + bool create() override; + + QVkRenderTargetData d; + VkImageView rtv[QVkRenderTargetData::MAX_COLOR_ATTACHMENTS]; + VkImageView dsv = VK_NULL_HANDLE; + VkImageView resrtv[QVkRenderTargetData::MAX_COLOR_ATTACHMENTS]; + VkImageView resdsv = VK_NULL_HANDLE; + int lastActiveFrameSlot = -1; + friend class QRhiVulkan; +}; + +struct QVkShaderResourceBindings : public QRhiShaderResourceBindings +{ + QVkShaderResourceBindings(QRhiImplementation *rhi); + ~QVkShaderResourceBindings(); + void destroy() override; + bool create() override; + void updateResources(UpdateFlags flags) override; + + QVarLengthArray<QRhiShaderResourceBinding, 8> sortedBindings; + bool hasSlottedResource = false; + bool hasDynamicOffset = false; + int poolIndex = -1; + VkDescriptorSetLayout layout = VK_NULL_HANDLE; + VkDescriptorSet descSets[QVK_FRAMES_IN_FLIGHT]; // multiple sets to support dynamic buffers + int lastActiveFrameSlot = -1; + uint generation = 0; + + // Keep track of the generation number of each referenced QRhi* to be able + // to detect that the underlying descriptor set became out of date and they + // need to be written again with the up-to-date VkBuffer etc. objects. + struct BoundUniformBufferData { + quint64 id; + uint generation; + }; + struct BoundSampledTextureData { + int count; + struct { + quint64 texId; + uint texGeneration; + quint64 samplerId; + uint samplerGeneration; + } d[QRhiShaderResourceBinding::Data::MAX_TEX_SAMPLER_ARRAY_SIZE]; + }; + struct BoundStorageImageData { + quint64 id; + uint generation; + }; + struct BoundStorageBufferData { + quint64 id; + uint generation; + }; + struct BoundResourceData { + union { + BoundUniformBufferData ubuf; + BoundSampledTextureData stex; + BoundStorageImageData simage; + BoundStorageBufferData sbuf; + }; + }; + QVarLengthArray<BoundResourceData, 8> boundResourceData[QVK_FRAMES_IN_FLIGHT]; + + friend class QRhiVulkan; +}; + +Q_DECLARE_TYPEINFO(QVkShaderResourceBindings::BoundResourceData, Q_RELOCATABLE_TYPE); + +struct QVkGraphicsPipeline : public QRhiGraphicsPipeline +{ + QVkGraphicsPipeline(QRhiImplementation *rhi); + ~QVkGraphicsPipeline(); + void destroy() override; + bool create() override; + + VkPipelineLayout layout = VK_NULL_HANDLE; + VkPipeline pipeline = VK_NULL_HANDLE; + int lastActiveFrameSlot = -1; + uint generation = 0; + friend class QRhiVulkan; +}; + +struct QVkComputePipeline : public QRhiComputePipeline +{ + QVkComputePipeline(QRhiImplementation *rhi); + ~QVkComputePipeline(); + void destroy() override; + bool create() override; + + VkPipelineLayout layout = VK_NULL_HANDLE; + VkPipeline pipeline = VK_NULL_HANDLE; + int lastActiveFrameSlot = -1; + uint generation = 0; + friend class QRhiVulkan; +}; + +struct QVkCommandBuffer : public QRhiCommandBuffer +{ + QVkCommandBuffer(QRhiImplementation *rhi); + ~QVkCommandBuffer(); + void destroy() override; + + const QRhiNativeHandles *nativeHandles(); + + VkCommandBuffer cb = VK_NULL_HANDLE; // primary + QRhiVulkanCommandBufferNativeHandles nativeHandlesStruct; + + enum PassType { + NoPass, + RenderPass, + ComputePass + }; + + void resetState() { + recordingPass = NoPass; + passUsesSecondaryCb = false; + lastGpuTime = 0; + currentTarget = nullptr; + activeSecondaryCbStack.clear(); + resetCommands(); + resetCachedState(); + } + + void resetCachedState() { + currentGraphicsPipeline = nullptr; + currentComputePipeline = nullptr; + currentPipelineGeneration = 0; + currentGraphicsSrb = nullptr; + currentComputeSrb = nullptr; + currentSrbGeneration = 0; + currentDescSetSlot = -1; + currentIndexBuffer = VK_NULL_HANDLE; + currentIndexOffset = 0; + currentIndexFormat = VK_INDEX_TYPE_UINT16; + memset(currentVertexBuffers, 0, sizeof(currentVertexBuffers)); + memset(currentVertexOffsets, 0, sizeof(currentVertexOffsets)); + inExternal = false; + } + + PassType recordingPass; + bool passUsesSecondaryCb; + double lastGpuTime = 0; + QRhiRenderTarget *currentTarget; + QRhiGraphicsPipeline *currentGraphicsPipeline; + QRhiComputePipeline *currentComputePipeline; + uint currentPipelineGeneration; + QRhiShaderResourceBindings *currentGraphicsSrb; + QRhiShaderResourceBindings *currentComputeSrb; + uint currentSrbGeneration; + int currentDescSetSlot; + VkBuffer currentIndexBuffer; + quint32 currentIndexOffset; + VkIndexType currentIndexFormat; + static const int VERTEX_INPUT_RESOURCE_SLOT_COUNT = 32; + VkBuffer currentVertexBuffers[VERTEX_INPUT_RESOURCE_SLOT_COUNT]; + quint32 currentVertexOffsets[VERTEX_INPUT_RESOURCE_SLOT_COUNT]; + QVarLengthArray<VkCommandBuffer, 4> activeSecondaryCbStack; + bool inExternal; + + struct { + QHash<QRhiResource *, QPair<VkAccessFlags, bool> > writtenResources; + void reset() { + writtenResources.clear(); + } + } computePassState; + + struct Command { + enum Cmd { + CopyBuffer, + CopyBufferToImage, + CopyImage, + CopyImageToBuffer, + ImageBarrier, + BufferBarrier, + BlitImage, + BeginRenderPass, + EndRenderPass, + BindPipeline, + BindDescriptorSet, + BindVertexBuffer, + BindIndexBuffer, + SetViewport, + SetScissor, + SetBlendConstants, + SetStencilRef, + Draw, + DrawIndexed, + DebugMarkerBegin, + DebugMarkerEnd, + DebugMarkerInsert, + TransitionPassResources, + Dispatch, + ExecuteSecondary + }; + Cmd cmd; + + union Args { + struct { + VkBuffer src; + VkBuffer dst; + VkBufferCopy desc; + } copyBuffer; + struct { + VkBuffer src; + VkImage dst; + VkImageLayout dstLayout; + int count; + int bufferImageCopyIndex; + } copyBufferToImage; + struct { + VkImage src; + VkImageLayout srcLayout; + VkImage dst; + VkImageLayout dstLayout; + VkImageCopy desc; + } copyImage; + struct { + VkImage src; + VkImageLayout srcLayout; + VkBuffer dst; + VkBufferImageCopy desc; + } copyImageToBuffer; + struct { + VkPipelineStageFlags srcStageMask; + VkPipelineStageFlags dstStageMask; + int count; + int index; + } imageBarrier; + struct { + VkPipelineStageFlags srcStageMask; + VkPipelineStageFlags dstStageMask; + int count; + int index; + } bufferBarrier; + struct { + VkImage src; + VkImageLayout srcLayout; + VkImage dst; + VkImageLayout dstLayout; + VkFilter filter; + VkImageBlit desc; + } blitImage; + struct { + VkRenderPassBeginInfo desc; + int clearValueIndex; + bool useSecondaryCb; + } beginRenderPass; + struct { + } endRenderPass; + struct { + VkPipelineBindPoint bindPoint; + VkPipeline pipeline; + } bindPipeline; + struct { + VkPipelineBindPoint bindPoint; + VkPipelineLayout pipelineLayout; + VkDescriptorSet descSet; + int dynamicOffsetCount; + int dynamicOffsetIndex; + } bindDescriptorSet; + struct { + int startBinding; + int count; + int vertexBufferIndex; + int vertexBufferOffsetIndex; + } bindVertexBuffer; + struct { + VkBuffer buf; + VkDeviceSize ofs; + VkIndexType type; + } bindIndexBuffer; + struct { + VkViewport viewport; + } setViewport; + struct { + VkRect2D scissor; + } setScissor; + struct { + float c[4]; + } setBlendConstants; + struct { + uint32_t ref; + } setStencilRef; + struct { + uint32_t vertexCount; + uint32_t instanceCount; + uint32_t firstVertex; + uint32_t firstInstance; + } draw; + struct { + uint32_t indexCount; + uint32_t instanceCount; + uint32_t firstIndex; + int32_t vertexOffset; + uint32_t firstInstance; + } drawIndexed; + struct { +#ifdef VK_EXT_debug_utils + VkDebugUtilsLabelEXT label; + int labelNameIndex; +#endif + } debugMarkerBegin; + struct { + } debugMarkerEnd; + struct { +#ifdef VK_EXT_debug_utils + VkDebugUtilsLabelEXT label; + int labelNameIndex; +#endif + } debugMarkerInsert; + struct { + int trackerIndex; + } transitionResources; + struct { + int x, y, z; + } dispatch; + struct { + VkCommandBuffer cb; + } executeSecondary; + } args; + }; + + QRhiBackendCommandList<Command> commands; + QVarLengthArray<QRhiPassResourceTracker, 8> passResTrackers; + int currentPassResTrackerIndex; + + void resetCommands() { + commands.reset(); + resetPools(); + + passResTrackers.clear(); + currentPassResTrackerIndex = -1; + } + + void resetPools() { + pools.clearValue.clear(); + pools.bufferImageCopy.clear(); + pools.dynamicOffset.clear(); + pools.vertexBuffer.clear(); + pools.vertexBufferOffset.clear(); + pools.debugMarkerData.clear(); + pools.imageBarrier.clear(); + pools.bufferBarrier.clear(); + } + + struct { + QVarLengthArray<VkClearValue, 4> clearValue; + QVarLengthArray<VkBufferImageCopy, 16> bufferImageCopy; + QVarLengthArray<uint32_t, 4> dynamicOffset; + QVarLengthArray<VkBuffer, 4> vertexBuffer; + QVarLengthArray<VkDeviceSize, 4> vertexBufferOffset; + QVarLengthArray<QByteArray, 4> debugMarkerData; + QVarLengthArray<VkImageMemoryBarrier, 8> imageBarrier; + QVarLengthArray<VkBufferMemoryBarrier, 8> bufferBarrier; + } pools; + + friend class QRhiVulkan; +}; + +struct QVkSwapChain : public QRhiSwapChain +{ + QVkSwapChain(QRhiImplementation *rhi); + ~QVkSwapChain(); + void destroy() override; + + QRhiCommandBuffer *currentFrameCommandBuffer() override; + QRhiRenderTarget *currentFrameRenderTarget() override; + QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer) override; + + QSize surfacePixelSize() override; + bool isFormatSupported(Format f) override; + + QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() override; + bool createOrResize() override; + + bool ensureSurface(); + + static const quint32 EXPECTED_MAX_BUFFER_COUNT = 4; + + QWindow *window = nullptr; + QSize pixelSize; + bool supportsReadback = false; + bool stereo = false; + VkSwapchainKHR sc = VK_NULL_HANDLE; + int bufferCount = 0; + VkSurfaceKHR surface = VK_NULL_HANDLE; + VkSurfaceKHR lastConnectedSurface = VK_NULL_HANDLE; + VkFormat colorFormat = VK_FORMAT_B8G8R8A8_UNORM; + VkColorSpaceKHR colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR; + QVkRenderBuffer *ds = nullptr; + VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT; + QVarLengthArray<VkPresentModeKHR, 8> supportedPresentationModes; + VkDeviceMemory msaaImageMem = VK_NULL_HANDLE; + QVkSwapChainRenderTarget rtWrapper; + QVkSwapChainRenderTarget rtWrapperRight; + QVkCommandBuffer cbWrapper; + + struct ImageResources { + VkImage image = VK_NULL_HANDLE; + VkImageView imageView = VK_NULL_HANDLE; + VkFramebuffer fb = VK_NULL_HANDLE; + VkImage msaaImage = VK_NULL_HANDLE; + VkImageView msaaImageView = VK_NULL_HANDLE; + enum LastUse { + ScImageUseNone, + ScImageUseRender, + ScImageUseTransferSource + }; + LastUse lastUse = ScImageUseNone; + }; + QVarLengthArray<ImageResources, EXPECTED_MAX_BUFFER_COUNT> imageRes; + + struct FrameResources { + VkFence imageFence = VK_NULL_HANDLE; + bool imageFenceWaitable = false; + VkSemaphore imageSem = VK_NULL_HANDLE; + VkSemaphore drawSem = VK_NULL_HANDLE; + bool imageAcquired = false; + bool imageSemWaitable = false; + VkFence cmdFence = VK_NULL_HANDLE; + bool cmdFenceWaitable = false; + VkCommandBuffer cmdBuf = VK_NULL_HANDLE; // primary + int timestampQueryIndex = -1; + } frameRes[QVK_FRAMES_IN_FLIGHT]; + + quint32 currentImageIndex = 0; // index in imageRes + quint32 currentFrameSlot = 0; // index in frameRes + int frameCount = 0; + + friend class QRhiVulkan; +}; + +class QRhiVulkan : public QRhiImplementation +{ +public: + QRhiVulkan(QRhiVulkanInitParams *params, QRhiVulkanNativeHandles *importParams = nullptr); + + bool create(QRhi::Flags flags) override; + void destroy() override; + + QRhiGraphicsPipeline *createGraphicsPipeline() override; + QRhiComputePipeline *createComputePipeline() override; + QRhiShaderResourceBindings *createShaderResourceBindings() override; + QRhiBuffer *createBuffer(QRhiBuffer::Type type, + QRhiBuffer::UsageFlags usage, + quint32 size) override; + QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type, + const QSize &pixelSize, + int sampleCount, + QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint) override; + QRhiTexture *createTexture(QRhiTexture::Format format, + const QSize &pixelSize, + int depth, + int arraySize, + int sampleCount, + QRhiTexture::Flags flags) override; + QRhiSampler *createSampler(QRhiSampler::Filter magFilter, + QRhiSampler::Filter minFilter, + QRhiSampler::Filter mipmapMode, + QRhiSampler:: AddressMode u, + QRhiSampler::AddressMode v, + QRhiSampler::AddressMode w) override; + + QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, + QRhiTextureRenderTarget::Flags flags) override; + + QRhiSwapChain *createSwapChain() override; + QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override; + QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override; + QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override; + QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override; + QRhi::FrameOpResult finish() override; + + void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + + void beginPass(QRhiCommandBuffer *cb, + QRhiRenderTarget *rt, + const QColor &colorClearValue, + const QRhiDepthStencilClearValue &depthStencilClearValue, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) override; + void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + + void setGraphicsPipeline(QRhiCommandBuffer *cb, + QRhiGraphicsPipeline *ps) override; + + void setShaderResources(QRhiCommandBuffer *cb, + QRhiShaderResourceBindings *srb, + int dynamicOffsetCount, + const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override; + + void setVertexInput(QRhiCommandBuffer *cb, + int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, + QRhiBuffer *indexBuf, quint32 indexOffset, + QRhiCommandBuffer::IndexFormat indexFormat) override; + + void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override; + void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override; + void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override; + void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override; + + void draw(QRhiCommandBuffer *cb, quint32 vertexCount, + quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override; + + void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, + quint32 instanceCount, quint32 firstIndex, + qint32 vertexOffset, quint32 firstInstance) override; + + void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override; + void debugMarkEnd(QRhiCommandBuffer *cb) override; + void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override; + + void beginComputePass(QRhiCommandBuffer *cb, + QRhiResourceUpdateBatch *resourceUpdates, + QRhiCommandBuffer::BeginPassFlags flags) override; + void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override; + void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override; + void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override; + + const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) override; + void beginExternal(QRhiCommandBuffer *cb) override; + void endExternal(QRhiCommandBuffer *cb) override; + double lastCompletedGpuTime(QRhiCommandBuffer *cb) override; + + QList<int> supportedSampleCounts() const override; + int ubufAlignment() const override; + bool isYUpInFramebuffer() const override; + bool isYUpInNDC() const override; + bool isClipDepthZeroToOne() const override; + QMatrix4x4 clipSpaceCorrMatrix() const override; + bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override; + bool isFeatureSupported(QRhi::Feature feature) const override; + int resourceLimit(QRhi::ResourceLimit limit) const override; + const QRhiNativeHandles *nativeHandles() override; + QRhiDriverInfo driverInfo() const override; + QRhiStats statistics() override; + bool makeThreadLocalNativeContextCurrent() override; + void releaseCachedResources() override; + bool isDeviceLost() const override; + + QByteArray pipelineCacheData() override; + void setPipelineCacheData(const QByteArray &data) override; + + VkResult createDescriptorPool(VkDescriptorPool *pool); + bool allocateDescriptorSet(VkDescriptorSetAllocateInfo *allocInfo, VkDescriptorSet *result, int *resultPoolIndex); + uint32_t chooseTransientImageMemType(VkImage img, uint32_t startIndex); + bool createTransientImage(VkFormat format, const QSize &pixelSize, VkImageUsageFlags usage, + VkImageAspectFlags aspectMask, VkSampleCountFlagBits samples, + VkDeviceMemory *mem, VkImage *images, VkImageView *views, int count); + + bool recreateSwapChain(QRhiSwapChain *swapChain); + void releaseSwapChainResources(QRhiSwapChain *swapChain); + + VkFormat optimalDepthStencilFormat(); + VkSampleCountFlagBits effectiveSampleCountBits(int sampleCount); + bool createDefaultRenderPass(QVkRenderPassDescriptor *rpD, + bool hasDepthStencil, + VkSampleCountFlagBits samples, + VkFormat colorFormat); + bool createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, + const QRhiColorAttachment *colorAttachmentsBegin, + const QRhiColorAttachment *colorAttachmentsEnd, + bool preserveColor, + bool preserveDs, + bool storeDs, + QRhiRenderBuffer *depthStencilBuffer, + QRhiTexture *depthTexture, + QRhiTexture *depthResolveTexture); + bool ensurePipelineCache(const void *initialData = nullptr, size_t initialDataSize = 0); + VkShaderModule createShader(const QByteArray &spirv); + + void prepareNewFrame(QRhiCommandBuffer *cb); + VkCommandBuffer startSecondaryCommandBuffer(QVkRenderTargetData *rtD = nullptr); + void endAndEnqueueSecondaryCommandBuffer(VkCommandBuffer cb, QVkCommandBuffer *cbD); + QRhi::FrameOpResult startPrimaryCommandBuffer(VkCommandBuffer *cb); + QRhi::FrameOpResult endAndSubmitPrimaryCommandBuffer(VkCommandBuffer cb, VkFence cmdFence, + VkSemaphore *waitSem, VkSemaphore *signalSem); + void waitCommandCompletion(int frameSlot); + VkDeviceSize subresUploadByteSize(const QRhiTextureSubresourceUploadDescription &subresDesc) const; + using BufferImageCopyList = QVarLengthArray<VkBufferImageCopy, 16>; + void prepareUploadSubres(QVkTexture *texD, int layer, int level, + const QRhiTextureSubresourceUploadDescription &subresDesc, + size_t *curOfs, void *mp, + BufferImageCopyList *copyInfos); + void enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdateBatch *resourceUpdates); + void executeBufferHostWritesForSlot(QVkBuffer *bufD, int slot); + void enqueueTransitionPassResources(QVkCommandBuffer *cbD); + void recordPrimaryCommandBuffer(QVkCommandBuffer *cbD); + void trackedRegisterBuffer(QRhiPassResourceTracker *passResTracker, + QVkBuffer *bufD, + int slot, + QRhiPassResourceTracker::BufferAccess access, + QRhiPassResourceTracker::BufferStage stage); + void trackedRegisterTexture(QRhiPassResourceTracker *passResTracker, + QVkTexture *texD, + QRhiPassResourceTracker::TextureAccess access, + QRhiPassResourceTracker::TextureStage stage); + void recordTransitionPassResources(QVkCommandBuffer *cbD, const QRhiPassResourceTracker &tracker); + void activateTextureRenderTarget(QVkCommandBuffer *cbD, QVkTextureRenderTarget *rtD); + void executeDeferredReleases(bool forced = false); + void finishActiveReadbacks(bool forced = false); + + void setObjectName(uint64_t object, VkObjectType type, const QByteArray &name, int slot = -1); + void trackedBufferBarrier(QVkCommandBuffer *cbD, QVkBuffer *bufD, int slot, + VkAccessFlags access, VkPipelineStageFlags stage); + void trackedImageBarrier(QVkCommandBuffer *cbD, QVkTexture *texD, + VkImageLayout layout, VkAccessFlags access, VkPipelineStageFlags stage); + void depthStencilExplicitBarrier(QVkCommandBuffer *cbD, QVkRenderBuffer *rbD); + void subresourceBarrier(QVkCommandBuffer *cbD, VkImage image, + VkImageLayout oldLayout, VkImageLayout newLayout, + VkAccessFlags srcAccess, VkAccessFlags dstAccess, + VkPipelineStageFlags srcStage, VkPipelineStageFlags dstStage, + int startLayer, int layerCount, + int startLevel, int levelCount); + void updateShaderResourceBindings(QRhiShaderResourceBindings *srb, int descSetIdx = -1); + void ensureCommandPoolForNewFrame(); + double elapsedSecondsFromTimestamp(quint64 timestamp[2], bool *ok); + void printExtraErrorInfo(VkResult err); + + QVulkanInstance *inst = nullptr; + QWindow *maybeWindow = nullptr; + QByteArrayList requestedDeviceExtensions; + bool importedDevice = false; + VkPhysicalDevice physDev = VK_NULL_HANDLE; + VkDevice dev = VK_NULL_HANDLE; + VkCommandPool cmdPool[QVK_FRAMES_IN_FLIGHT] = {}; + quint32 gfxQueueFamilyIdx = 0; + quint32 gfxQueueIdx = 0; + VkQueue gfxQueue = VK_NULL_HANDLE; + quint32 timestampValidBits = 0; + bool importedAllocator = false; + QVkAllocator allocator = nullptr; + QVulkanFunctions *f = nullptr; + QVulkanDeviceFunctions *df = nullptr; + QRhi::Flags rhiFlags; + VkPhysicalDeviceFeatures physDevFeatures; +#ifdef VK_VERSION_1_1 + VkPhysicalDeviceMultiviewFeatures multiviewFeaturesIfApi11; +#endif +#ifdef VK_VERSION_1_2 + VkPhysicalDeviceVulkan11Features physDevFeatures11IfApi12OrNewer; + VkPhysicalDeviceVulkan12Features physDevFeatures12; +#endif +#ifdef VK_VERSION_1_3 + VkPhysicalDeviceVulkan13Features physDevFeatures13; +#endif + VkPhysicalDeviceProperties physDevProperties; + VkDeviceSize ubufAlign; + VkDeviceSize texbufAlign; + bool deviceLost = false; + bool releaseCachedResourcesCalledBeforeFrameStart = false; + +#ifdef VK_EXT_debug_utils + PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT = nullptr; + PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT = nullptr; + PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT = nullptr; + PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT = nullptr; +#endif + + PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR = nullptr; + PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR; + PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR; + PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR; + PFN_vkQueuePresentKHR vkQueuePresentKHR; + PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR; + PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR; + PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR; + +#ifdef VK_KHR_create_renderpass2 + PFN_vkCreateRenderPass2KHR vkCreateRenderPass2KHR = nullptr; +#endif + + struct { + bool compute = false; + bool wideLines = false; + bool debugUtils = false; + bool vertexAttribDivisor = false; + bool texture3DSliceAs2D = false; + bool tessellation = false; + bool geometryShader = false; + bool nonFillPolygonMode = false; + bool multiView = false; + bool renderPass2KHR = false; + bool depthStencilResolveKHR = false; + QVersionNumber apiVersion; + } caps; + + VkPipelineCache pipelineCache = VK_NULL_HANDLE; + struct DescriptorPoolData { + DescriptorPoolData() { } + DescriptorPoolData(VkDescriptorPool pool_) + : pool(pool_) + { } + VkDescriptorPool pool = VK_NULL_HANDLE; + int refCount = 0; + int allocedDescSets = 0; + }; + QVarLengthArray<DescriptorPoolData, 8> descriptorPools; + QVarLengthArray<VkCommandBuffer, 4> freeSecondaryCbs[QVK_FRAMES_IN_FLIGHT]; + + VkQueryPool timestampQueryPool = VK_NULL_HANDLE; + QBitArray timestampQueryPoolMap; + + VkFormat optimalDsFormat = VK_FORMAT_UNDEFINED; + QMatrix4x4 clipCorrectMatrix; + + QVkSwapChain *currentSwapChain = nullptr; + QSet<QVkSwapChain *> swapchains; + QRhiVulkanNativeHandles nativeHandlesStruct; + QRhiDriverInfo driverInfoStruct; + + struct OffscreenFrame { + OffscreenFrame(QRhiImplementation *rhi) + { + for (int i = 0; i < QVK_FRAMES_IN_FLIGHT; ++i) + cbWrapper[i] = new QVkCommandBuffer(rhi); + } + ~OffscreenFrame() + { + for (int i = 0; i < QVK_FRAMES_IN_FLIGHT; ++i) + delete cbWrapper[i]; + } + bool active = false; + QVkCommandBuffer *cbWrapper[QVK_FRAMES_IN_FLIGHT]; + VkFence cmdFence = VK_NULL_HANDLE; + int timestampQueryIndex = -1; + } ofr; + + struct TextureReadback { + int activeFrameSlot = -1; + QRhiReadbackDescription desc; + QRhiReadbackResult *result; + VkBuffer stagingBuf; + QVkAlloc stagingAlloc; + quint32 byteSize; + QSize pixelSize; + QRhiTexture::Format format; + }; + QVarLengthArray<TextureReadback, 2> activeTextureReadbacks; + struct BufferReadback { + int activeFrameSlot = -1; + QRhiReadbackResult *result; + quint32 byteSize; + VkBuffer stagingBuf; + QVkAlloc stagingAlloc; + }; + QVarLengthArray<BufferReadback, 2> activeBufferReadbacks; + + struct DeferredReleaseEntry { + enum Type { + Pipeline, + ShaderResourceBindings, + Buffer, + RenderBuffer, + Texture, + Sampler, + TextureRenderTarget, + RenderPass, + StagingBuffer, + SecondaryCommandBuffer + }; + Type type; + int lastActiveFrameSlot; // -1 if not used otherwise 0..FRAMES_IN_FLIGHT-1 + union { + struct { + VkPipeline pipeline; + VkPipelineLayout layout; + } pipelineState; + struct { + int poolIndex; + VkDescriptorSetLayout layout; + } shaderResourceBindings; + struct { + VkBuffer buffers[QVK_FRAMES_IN_FLIGHT]; + QVkAlloc allocations[QVK_FRAMES_IN_FLIGHT]; + VkBuffer stagingBuffers[QVK_FRAMES_IN_FLIGHT]; + QVkAlloc stagingAllocations[QVK_FRAMES_IN_FLIGHT]; + } buffer; + struct { + VkDeviceMemory memory; + VkImage image; + VkImageView imageView; + } renderBuffer; + struct { + VkImage image; + VkImageView imageView; + QVkAlloc allocation; + VkBuffer stagingBuffers[QVK_FRAMES_IN_FLIGHT]; + QVkAlloc stagingAllocations[QVK_FRAMES_IN_FLIGHT]; + VkImageView extraImageViews[QRhi::MAX_MIP_LEVELS]; + } texture; + struct { + VkSampler sampler; + } sampler; + struct { + VkFramebuffer fb; + VkImageView rtv[QVkRenderTargetData::MAX_COLOR_ATTACHMENTS]; + VkImageView resrtv[QVkRenderTargetData::MAX_COLOR_ATTACHMENTS]; + VkImageView dsv; + VkImageView resdsv; + } textureRenderTarget; + struct { + VkRenderPass rp; + } renderPass; + struct { + VkBuffer stagingBuffer; + QVkAlloc stagingAllocation; + } stagingBuffer; + struct { + VkCommandBuffer cb; + } secondaryCommandBuffer; + }; + }; + QList<DeferredReleaseEntry> releaseQueue; +}; + +Q_DECLARE_TYPEINFO(QRhiVulkan::DescriptorPoolData, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QRhiVulkan::DeferredReleaseEntry, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QRhiVulkan::TextureReadback, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QRhiVulkan::BufferReadback, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qscreen_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qscreen_p.h new file mode 100644 index 0000000000000000000000000000000000000000..81e919a9ba08a467118b6abccfd8c1e802000379 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qscreen_p.h @@ -0,0 +1,60 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSCREEN_P_H +#define QSCREEN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtGui/qscreen.h> +#include <qpa/qplatformscreen.h> +#include "qhighdpiscaling_p.h" + +#include <QtCore/private/qobject_p.h> + +QT_BEGIN_NAMESPACE + +struct QScreenData +{ + QPlatformScreen *platformScreen = nullptr; + + Qt::ScreenOrientation orientation = Qt::PrimaryOrientation; + Qt::ScreenOrientation primaryOrientation = Qt::LandscapeOrientation; + QRect geometry; + QRect availableGeometry; + QDpi logicalDpi = {96, 96}; + qreal refreshRate = 60; +}; + +class QScreenPrivate : public QObjectPrivate, public QScreenData +{ + Q_DECLARE_PUBLIC(QScreen) +public: + void updateGeometry(); + void updatePrimaryOrientation(); + + class UpdateEmitter + { + public: + explicit UpdateEmitter(QScreen *screen); + ~UpdateEmitter(); + UpdateEmitter(UpdateEmitter&&) noexcept = default; + private: + Q_DISABLE_COPY(UpdateEmitter) + QScreenData initialState; + }; +}; + +QT_END_NAMESPACE + +#endif // QSCREEN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qsessionmanager_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qsessionmanager_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1d91ca46fb037b0db1e0c79fdd6d09f156c61118 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qsessionmanager_p.h @@ -0,0 +1,45 @@ +// Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSESSIONMANAGER_P_H +#define QSESSIONMANAGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <private/qobject_p.h> +#include <QtCore/qstring.h> +#include <QtCore/qstringlist.h> + +#ifndef QT_NO_SESSIONMANAGER + +QT_BEGIN_NAMESPACE + +class QPlatformSessionManager; + +class Q_GUI_EXPORT QSessionManagerPrivate : public QObjectPrivate +{ +public: + QSessionManagerPrivate(const QString &id, + const QString &key); + + ~QSessionManagerPrivate(); + + QPlatformSessionManager *platformSessionManager; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_SESSIONMANAGER + +#endif // QSESSIONMANAGER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshader_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..691e6c8a088a005a167ba73ec534111934d7158f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshader_p.h @@ -0,0 +1,91 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSHADER_P_H +#define QSHADER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <rhi/qshader.h> +#include <QtCore/QAtomicInt> +#include <QtCore/QMap> +#include <QtCore/QDebug> + +QT_BEGIN_NAMESPACE + +struct Q_GUI_EXPORT QShaderPrivate +{ + static const int QSB_VERSION = 9; + static const int QSB_VERSION_WITHOUT_INPUT_OUTPUT_INTERFACE_BLOCKS = 8; + static const int QSB_VERSION_WITHOUT_EXTENDED_STORAGE_BUFFER_INFO = 7; + static const int QSB_VERSION_WITHOUT_NATIVE_SHADER_INFO = 6; + static const int QSB_VERSION_WITHOUT_SEPARATE_IMAGES_AND_SAMPLERS = 5; + static const int QSB_VERSION_WITHOUT_VAR_ARRAYDIMS = 4; + static const int QSB_VERSION_WITH_CBOR = 3; + static const int QSB_VERSION_WITH_BINARY_JSON = 2; + static const int QSB_VERSION_WITHOUT_BINDINGS = 1; + + enum MslNativeShaderInfoExtraBufferBindings { + MslTessVertIndicesBufferBinding = 0, + MslTessVertTescOutputBufferBinding, + MslTessTescTessLevelBufferBinding, + MslTessTescPatchOutputBufferBinding, + MslTessTescParamsBufferBinding, + MslTessTescInputBufferBinding, + MslBufferSizeBufferBinding, + MslMultiViewMaskBufferBinding + }; + + QShaderPrivate() + : ref(1) + { + } + + QShaderPrivate(const QShaderPrivate &other) + : ref(1), + qsbVersion(other.qsbVersion), + stage(other.stage), + desc(other.desc), + shaders(other.shaders), + bindings(other.bindings), + combinedImageMap(other.combinedImageMap), + nativeShaderInfoMap(other.nativeShaderInfoMap) + { + } + + static QShaderPrivate *get(QShader *s) { return s->d; } + static const QShaderPrivate *get(const QShader *s) { return s->d; } + static int qtQsbVersion(QShader::SerializedFormatVersion qtVersion) { + switch (qtVersion) { + case QShader::SerializedFormatVersion::Qt_6_4: + return (QShaderPrivate::QSB_VERSION_WITHOUT_SEPARATE_IMAGES_AND_SAMPLERS + 1); + case QShader::SerializedFormatVersion::Qt_6_5: + return (QShaderPrivate::QSB_VERSION_WITHOUT_EXTENDED_STORAGE_BUFFER_INFO + 1); + default: + return QShaderPrivate::QSB_VERSION; + } + } + + QAtomicInt ref; + int qsbVersion = QSB_VERSION; + QShader::Stage stage = QShader::VertexStage; + QShaderDescription desc; + // QMap not QHash because we need to be able to iterate based on sorted keys + QMap<QShaderKey, QShaderCode> shaders; + QMap<QShaderKey, QShader::NativeResourceBindingMap> bindings; + QMap<QShaderKey, QShader::SeparateToCombinedImageSamplerMappingList> combinedImageMap; + QMap<QShaderKey, QShader::NativeShaderInfo> nativeShaderInfoMap; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshaderdescription_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshaderdescription_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f9ad7386f36c1e3a40c0ce8f988f687812b5330d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshaderdescription_p.h @@ -0,0 +1,81 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSHADERDESCRIPTION_P_H +#define QSHADERDESCRIPTION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <rhi/qshaderdescription.h> +#include <QtCore/QList> +#include <QtCore/QAtomicInt> +#include <QtCore/QJsonDocument> + +QT_BEGIN_NAMESPACE + +struct Q_GUI_EXPORT QShaderDescriptionPrivate +{ + QShaderDescriptionPrivate() + : ref(1) + { + } + + QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other) + : ref(1), + inVars(other.inVars), + outVars(other.outVars), + uniformBlocks(other.uniformBlocks), + pushConstantBlocks(other.pushConstantBlocks), + storageBlocks(other.storageBlocks), + combinedImageSamplers(other.combinedImageSamplers), + separateImages(other.separateImages), + separateSamplers(other.separateSamplers), + storageImages(other.storageImages), + inBuiltins(other.inBuiltins), + outBuiltins(other.outBuiltins), + localSize(other.localSize), + tessOutVertCount(other.tessOutVertCount), + tessMode(other.tessMode), + tessWind(other.tessWind), + tessPart(other.tessPart) + { + } + + static QShaderDescriptionPrivate *get(QShaderDescription *desc) { return desc->d; } + static const QShaderDescriptionPrivate *get(const QShaderDescription *desc) { return desc->d; } + + QJsonDocument makeDoc(); + void writeToStream(QDataStream *stream, int version); + void loadFromStream(QDataStream *stream, int version); + + QAtomicInt ref; + QList<QShaderDescription::InOutVariable> inVars; + QList<QShaderDescription::InOutVariable> outVars; + QList<QShaderDescription::UniformBlock> uniformBlocks; + QList<QShaderDescription::PushConstantBlock> pushConstantBlocks; + QList<QShaderDescription::StorageBlock> storageBlocks; + QList<QShaderDescription::InOutVariable> combinedImageSamplers; + QList<QShaderDescription::InOutVariable> separateImages; + QList<QShaderDescription::InOutVariable> separateSamplers; + QList<QShaderDescription::InOutVariable> storageImages; + QList<QShaderDescription::BuiltinVariable> inBuiltins; + QList<QShaderDescription::BuiltinVariable> outBuiltins; + std::array<uint, 3> localSize = {}; + uint tessOutVertCount = 0; + QShaderDescription::TessellationMode tessMode = QShaderDescription::UnknownTessellationMode; + QShaderDescription::TessellationWindingOrder tessWind = QShaderDescription::UnknownTessellationWindingOrder; + QShaderDescription::TessellationPartitioning tessPart = QShaderDescription::UnknownTessellationPartitioning; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshapedpixmapdndwindow_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshapedpixmapdndwindow_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dff53111e654e15f7ccb865e09a5e063ebc10f6c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshapedpixmapdndwindow_p.h @@ -0,0 +1,50 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSHAPEDPIXMAPDNDWINDOW_H +#define QSHAPEDPIXMAPDNDWINDOW_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtGui/QRasterWindow> +#include <QtGui/QPixmap> + +QT_REQUIRE_CONFIG(draganddrop); + +QT_BEGIN_NAMESPACE + +class QShapedPixmapWindow : public QRasterWindow +{ + Q_OBJECT +public: + explicit QShapedPixmapWindow(QScreen *screen = nullptr); + ~QShapedPixmapWindow(); + + void setUseCompositing(bool on) { m_useCompositing = on; } + void setPixmap(const QPixmap &pixmap); + void setHotspot(const QPoint &hotspot); + + void updateGeometry(const QPoint &pos); + +protected: + void paintEvent(QPaintEvent *) override; + +private: + QPixmap m_pixmap; + QPoint m_hotSpot; + bool m_useCompositing; +}; + +QT_END_NAMESPACE + +#endif // QSHAPEDPIXMAPDNDWINDOW_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshortcut_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshortcut_p.h new file mode 100644 index 0000000000000000000000000000000000000000..069718f65810dced45d630b79652ebaabc266eec --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshortcut_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSHORTCUT_P_H +#define QSHORTCUT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "qshortcut.h" +#include <QtGui/qkeysequence.h> + +#include <QtCore/qlist.h> +#include <QtCore/qstring.h> +#include <QtCore/private/qobject_p.h> + +#include <private/qshortcutmap_p.h> + + +QT_BEGIN_NAMESPACE + +class QShortcutMap; + +/* + \internal + Private data accessed through d-pointer. +*/ +class Q_GUI_EXPORT QShortcutPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QShortcut) +public: + QShortcutPrivate() = default; + + virtual QShortcutMap::ContextMatcher contextMatcher() const; + virtual bool handleWhatsThis() { return false; } + + static bool simpleContextMatcher(QObject *object, Qt::ShortcutContext context); + + QList<QKeySequence> sc_sequences; + QString sc_whatsthis; + Qt::ShortcutContext sc_context = Qt::WindowShortcut; + bool sc_enabled = true; + bool sc_autorepeat = true; + QList<int> sc_ids; + void redoGrab(QShortcutMap &map); +}; + +QT_END_NAMESPACE + +#endif // QSHORTCUT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshortcutmap_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshortcutmap_p.h new file mode 100644 index 0000000000000000000000000000000000000000..255bbfcb88cedb8ee6905d77443b30bbd928b293 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qshortcutmap_p.h @@ -0,0 +1,75 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSHORTCUTMAP_P_H +#define QSHORTCUTMAP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qkeysequence.h" +#include "QtCore/qlist.h" +#include "QtCore/qscopedpointer.h" + +QT_REQUIRE_CONFIG(shortcut); + +QT_BEGIN_NAMESPACE + +// To enable dump output uncomment below +//#define Dump_QShortcutMap + +class QKeyEvent; +struct QShortcutEntry; +class QShortcutMapPrivate; +class QObject; + +class Q_GUI_EXPORT QShortcutMap +{ + Q_DECLARE_PRIVATE(QShortcutMap) +public: + QShortcutMap(); + ~QShortcutMap(); + + typedef bool (*ContextMatcher)(QObject *object, Qt::ShortcutContext context); + + int addShortcut(QObject *owner, const QKeySequence &key, Qt::ShortcutContext context, ContextMatcher matcher); + int removeShortcut(int id, QObject *owner, const QKeySequence &key = QKeySequence()); + int setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &key = QKeySequence()); + int setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &key = QKeySequence()); + + QKeySequence::SequenceMatch state(); + + bool tryShortcut(QKeyEvent *e); + bool hasShortcutForKeySequence(const QKeySequence &seq) const; + QList<QKeySequence> keySequences(bool getAll = false) const; + +#ifdef Dump_QShortcutMap + void dumpMap() const; +#endif + +private: + void resetState(); + QKeySequence::SequenceMatch nextState(QKeyEvent *e); + void dispatchEvent(QKeyEvent *e); + + QKeySequence::SequenceMatch find(QKeyEvent *e, int ignoredModifiers = 0); + QList<const QShortcutEntry *> matches() const; + void createNewSequences(QKeyEvent *e, QList<QKeySequence> &ksl, int ignoredModifiers); + void clearSequence(QList<QKeySequence> &ksl); + int translateModifiers(Qt::KeyboardModifiers modifiers); + + QScopedPointer<QShortcutMapPrivate> d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QSHORTCUTMAP_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qsimpledrag_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qsimpledrag_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1036ddfa393961202d6866b4ad8e86865b201f42 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qsimpledrag_p.h @@ -0,0 +1,110 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSIMPLEDRAG_P_H +#define QSIMPLEDRAG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <qpa/qplatformdrag.h> + +#include <QtCore/QObject> +#include <QtCore/QPointer> +#include <QtGui/QWindow> + +QT_REQUIRE_CONFIG(draganddrop); + +QT_BEGIN_NAMESPACE + +class QMouseEvent; +class QEventLoop; +class QDropData; +class QShapedPixmapWindow; +class QScreen; + +class Q_GUI_EXPORT QBasicDrag : public QPlatformDrag, public QObject +{ +public: + ~QBasicDrag(); + + virtual Qt::DropAction drag(QDrag *drag) override; + void cancelDrag() override; + + virtual bool eventFilter(QObject *o, QEvent *e) override; + +protected: + QBasicDrag(); + + virtual void startDrag(); + virtual void cancel(); + virtual void move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) = 0; + virtual void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) = 0; + virtual void endDrag(); + + + void moveShapedPixmapWindow(const QPoint &deviceIndependentPosition); + QShapedPixmapWindow *shapedPixmapWindow() const { return m_drag_icon_window; } + void recreateShapedPixmapWindow(QScreen *screen, const QPoint &pos); + void updateCursor(Qt::DropAction action); + + bool canDrop() const { return m_can_drop; } + void setCanDrop(bool c) { m_can_drop = c; } + + bool useCompositing() const { return m_useCompositing; } + void setUseCompositing(bool on) { m_useCompositing = on; } + + void setScreen(QScreen *screen) { m_screen = screen; } + + Qt::DropAction executedDropAction() const { return m_executed_drop_action; } + void setExecutedDropAction(Qt::DropAction da) { m_executed_drop_action = da; } + + QDrag *drag() const { return m_drag; } + +protected: + QWindow *m_sourceWindow = nullptr; + QPointer<QWindow> m_windowUnderCursor = nullptr; + +private: + void enableEventFilter(); + void disableEventFilter(); + void restoreCursor(); + void exitDndEventLoop(); + +#ifndef QT_NO_CURSOR + bool m_dndHasSetOverrideCursor = false; +#endif + QEventLoop *m_eventLoop = nullptr; + Qt::DropAction m_executed_drop_action = Qt::IgnoreAction; + bool m_can_drop = false; + QDrag *m_drag = nullptr; + QShapedPixmapWindow *m_drag_icon_window = nullptr; + bool m_useCompositing = true; + QScreen *m_screen = nullptr; + QPoint m_lastPos; +}; + +class Q_GUI_EXPORT QSimpleDrag : public QBasicDrag +{ +public: + QSimpleDrag(); + +protected: + virtual void startDrag() override; + virtual void cancel() override; + virtual void move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override; + virtual void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstandarditemmodel_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstandarditemmodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f7084262db63606ca4c6bddd3eda82e0bc076acf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstandarditemmodel_p.h @@ -0,0 +1,223 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSTANDARDITEMMODEL_P_H +#define QSTANDARDITEMMODEL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qstandarditemmodel.h> + +#include <QtGui/private/qtguiglobal_p.h> +#include "private/qabstractitemmodel_p.h" + +#include <QtCore/qlist.h> +#include <QtCore/qpair.h> +#include <QtCore/qstack.h> +#include <QtCore/qvariant.h> +#include <QtCore/qdebug.h> + +QT_REQUIRE_CONFIG(standarditemmodel); + +QT_BEGIN_NAMESPACE + +class QStandardItemData +{ +public: + inline QStandardItemData() : role(-1) {} + inline QStandardItemData(int r, const QVariant &v) : + role(r == Qt::EditRole ? Qt::DisplayRole : r), value(v) {} + inline QStandardItemData(const std::pair<const int&, const QVariant&> &p) : + role(p.first == Qt::EditRole ? Qt::DisplayRole : p.first), value(p.second) {} + int role; + QVariant value; + inline bool operator==(const QStandardItemData &other) const { return role == other.role && value == other.value; } +}; +Q_DECLARE_TYPEINFO(QStandardItemData, Q_RELOCATABLE_TYPE); + +#ifndef QT_NO_DATASTREAM + +inline QDataStream &operator>>(QDataStream &in, QStandardItemData &data) +{ + in >> data.role; + in >> data.value; + return in; +} + +inline QDataStream &operator<<(QDataStream &out, const QStandardItemData &data) +{ + out << data.role; + out << data.value; + return out; +} + +inline QDebug &operator<<(QDebug &debug, const QStandardItemData &data) +{ + QDebugStateSaver saver(debug); + debug.nospace() << data.role + << " " + << data.value; + return debug.space(); +} + +#endif // QT_NO_DATASTREAM + +class QStandardItemPrivate +{ + Q_DECLARE_PUBLIC(QStandardItem) +public: + inline QStandardItemPrivate() + : model(nullptr), + parent(nullptr), + rows(0), + columns(0), + q_ptr(nullptr), + lastKnownIndex(-1) + { } + + inline int childIndex(int row, int column) const { + if ((row < 0) || (column < 0) + || (row >= rowCount()) || (column >= columnCount())) { + return -1; + } + return (row * columnCount()) + column; + } + inline int childIndex(const QStandardItem *child) const { + const int lastChild = children.size() - 1; + int &childsLastIndexInParent = child->d_func()->lastKnownIndex; + if (childsLastIndexInParent != -1 && childsLastIndexInParent <= lastChild) { + if (children.at(childsLastIndexInParent) == child) + return childsLastIndexInParent; + } else { + childsLastIndexInParent = lastChild / 2; + } + + // assuming the item is in the vicinity of the previous index, iterate forwards and + // backwards through the children + int backwardIter = childsLastIndexInParent - 1; + int forwardIter = childsLastIndexInParent; + for (;;) { + if (forwardIter <= lastChild) { + if (children.at(forwardIter) == child) { + childsLastIndexInParent = forwardIter; + break; + } + ++forwardIter; + } else if (backwardIter < 0) { + childsLastIndexInParent = -1; + break; + } + if (backwardIter >= 0) { + if (children.at(backwardIter) == child) { + childsLastIndexInParent = backwardIter; + break; + } + --backwardIter; + } + } + return childsLastIndexInParent; + } + QPair<int, int> position() const; + void setChild(int row, int column, QStandardItem *item, + bool emitChanged = false); + inline int rowCount() const { + return rows; + } + inline int columnCount() const { + return columns; + } + void childDeleted(QStandardItem *child); + + void setModel(QStandardItemModel *mod); + + inline void setParentAndModel( + QStandardItem *par, + QStandardItemModel *mod) { + setModel(mod); + parent = par; + } + + void changeFlags(bool enable, Qt::ItemFlags f); + void setItemData(const QMap<int, QVariant> &roles); + QMap<int, QVariant> itemData() const; + + bool insertRows(int row, int count, const QList<QStandardItem*> &items); + bool insertRows(int row, const QList<QStandardItem*> &items); + bool insertColumns(int column, int count, const QList<QStandardItem*> &items); + + void sortChildren(int column, Qt::SortOrder order); + + QStandardItemModel *model; + QStandardItem *parent; + QList<QStandardItemData> values; + QList<QStandardItem *> children; + int rows; + int columns; + + QStandardItem *q_ptr; + + mutable int lastKnownIndex; // this is a cached value +}; + +class QStandardItemModelPrivate : public QAbstractItemModelPrivate +{ + Q_DECLARE_PUBLIC(QStandardItemModel) + +public: + QStandardItemModelPrivate(); + ~QStandardItemModelPrivate(); + + void init(); + + inline QStandardItem *createItem() const { + return itemPrototype ? itemPrototype->clone() : new QStandardItem; + } + + inline QStandardItem *itemFromIndex(const QModelIndex &index) const { + Q_Q(const QStandardItemModel); + if (!index.isValid()) + return root.data(); + if (index.model() != q) + return nullptr; + QStandardItem *parent = static_cast<QStandardItem*>(index.internalPointer()); + if (parent == nullptr) + return nullptr; + return parent->child(index.row(), index.column()); + } + + void sort(QStandardItem *parent, int column, Qt::SortOrder order); + void itemChanged(QStandardItem *item, const QList<int> &roles = QList<int>()); + void rowsAboutToBeInserted(QStandardItem *parent, int start, int end); + void columnsAboutToBeInserted(QStandardItem *parent, int start, int end); + void rowsAboutToBeRemoved(QStandardItem *parent, int start, int end); + void columnsAboutToBeRemoved(QStandardItem *parent, int start, int end); + void rowsInserted(QStandardItem *parent, int row, int count); + void columnsInserted(QStandardItem *parent, int column, int count); + void rowsRemoved(QStandardItem *parent, int row, int count); + void columnsRemoved(QStandardItem *parent, int column, int count); + + void _q_emitItemChanged(const QModelIndex &topLeft, + const QModelIndex &bottomRight); + + void decodeDataRecursive(QDataStream &stream, QStandardItem *item); + + QList<QStandardItem *> columnHeaderItems; + QList<QStandardItem *> rowHeaderItems; + QHash<int, QByteArray> roleNames; + QScopedPointer<QStandardItem> root; + const QStandardItem *itemPrototype; + Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QStandardItemModelPrivate, int, sortRole, Qt::DisplayRole) +}; + +QT_END_NAMESPACE + +#endif // QSTANDARDITEMMODEL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstatictext_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstatictext_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6a7b2ea09cf3aaf54b9f98537107a9f99d4d9e46 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstatictext_p.h @@ -0,0 +1,133 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSTATICTEXT_P_H +#define QSTATICTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "qstatictext.h" + +#include <private/qtextureglyphcache_p.h> +#include <QtGui/qcolor.h> + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QStaticTextUserData +{ +public: + enum Type { + NoUserData, + OpenGLUserData + }; + + QStaticTextUserData(Type t) : ref(0), type(t) {} + virtual ~QStaticTextUserData(); + + QAtomicInt ref; + Type type; +}; + +class Q_GUI_EXPORT QStaticTextItem +{ +public: + QStaticTextItem() : useBackendOptimizations(false), + userDataNeedsUpdate(0), usesRawFont(0), + m_fontEngine(nullptr), m_userData(nullptr) {} + + void setUserData(QStaticTextUserData *newUserData) + { + m_userData = newUserData; + } + QStaticTextUserData *userData() const { return m_userData.data(); } + + void setFontEngine(QFontEngine *fe) + { + m_fontEngine = fe; + } + + QFontEngine *fontEngine() const { return m_fontEngine.data(); } + + union { + QFixedPoint *glyphPositions; // 8 bytes per glyph + int positionOffset; + }; + union { + glyph_t *glyphs; // 4 bytes per glyph + int glyphOffset; + }; + // ================= + // 12 bytes per glyph + + // 8 bytes for pointers + int numGlyphs; // 4 bytes per item + QFont font; // 8 bytes per item + QColor color; // 10 bytes per item + char useBackendOptimizations : 1; // 1 byte per item + char userDataNeedsUpdate : 1; // + char usesRawFont : 1; // + +private: // private to avoid abuse + QExplicitlySharedDataPointer<QFontEngine> m_fontEngine; // 4 bytes per item + QExplicitlySharedDataPointer<QStaticTextUserData> m_userData; // 8 bytes per item + // ================ + // 43 bytes per item +}; +Q_DECLARE_TYPEINFO(QStaticTextItem, Q_RELOCATABLE_TYPE); + +class QStaticText; +class Q_AUTOTEST_EXPORT QStaticTextPrivate +{ +public: + QStaticTextPrivate(); + QStaticTextPrivate(const QStaticTextPrivate &other); + ~QStaticTextPrivate(); + + void init(); + void paintText(const QPointF &pos, QPainter *p, const QColor &pen); + + void invalidate() + { + needsRelayout = true; + } + + QAtomicInt ref; // 4 bytes per text + + QString text; // 4 bytes per text + QFont font; // 8 bytes per text + qreal textWidth; // 8 bytes per text + QSizeF actualSize; // 16 bytes per text + QPointF position; // 16 bytes per text + + QTransform matrix; // 80 bytes per text + QStaticTextItem *items; // 4 bytes per text + int itemCount; // 4 bytes per text + + glyph_t *glyphPool; // 4 bytes per text + QFixedPoint *positionPool; // 4 bytes per text + + QTextOption textOption; // 28 bytes per text + + unsigned char needsRelayout : 1; // 1 byte per text + unsigned char useBackendOptimizations : 1; + unsigned char textFormat : 2; + unsigned char untransformedCoordinates : 1; + // ================ + // 191 bytes per text + + static QStaticTextPrivate *get(const QStaticText *q); +}; + +QT_END_NAMESPACE + +#endif // QSTATICTEXT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstroker_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstroker_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fb9f4299fad820eb5c109829bf2205890a3abbe9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstroker_p.h @@ -0,0 +1,369 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSTROKER_P_H +#define QSTROKER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qpainterpath.h" +#include "private/qdatabuffer_p.h" +#include "private/qnumeric_p.h" + +QT_BEGIN_NAMESPACE + +// #define QFIXED_IS_26_6 + +#if defined QFIXED_IS_26_6 +typedef int qfixed; +#define qt_real_to_fixed(real) qfixed(real * 64) +#define qt_int_to_fixed(real) qfixed(int(real) << 6) +#define qt_fixed_to_real(fixed) qreal(fixed / qreal(64)) +#define qt_fixed_to_int(fixed) int(fixed >> 6) +struct qfixed2d +{ + qfixed x; + qfixed y; + + bool operator==(const qfixed2d &other) const { return x == other.x && y == other.y; } +}; +#elif defined QFIXED_IS_32_32 +typedef qint64 qfixed; +#define qt_real_to_fixed(real) qfixed(real * double(qint64(1) << 32)) +#define qt_fixed_to_real(fixed) qreal(fixed / double(qint64(1) << 32)) +struct qfixed2d +{ + qfixed x; + qfixed y; + + bool operator==(const qfixed2d &other) const { return x == other.x && y == other.y; } +}; +#elif defined QFIXED_IS_16_16 +typedef int qfixed; +#define qt_real_to_fixed(real) qfixed(real * qreal(1 << 16)) +#define qt_fixed_to_real(fixed) qreal(fixed / qreal(1 << 16)) +struct qfixed2d +{ + qfixed x; + qfixed y; + + bool operator==(const qfixed2d &other) const { return x == other.x && y == other.y; } +}; +#else +typedef qreal qfixed; +#define qt_real_to_fixed(real) qfixed(real) +#define qt_fixed_to_real(fixed) fixed +struct qfixed2d +{ + qfixed x; + qfixed y; + + bool isFinite() { return qIsFinite(x) && qIsFinite(y); } + bool operator==(const qfixed2d &other) const { return qFuzzyCompare(x, other.x) + && qFuzzyCompare(y, other.y); } +}; +#endif + +#define QT_PATH_KAPPA 0.5522847498 + +QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLength, + QPointF *controlPoints, int *point_count); + +qreal qt_t_for_arc_angle(qreal angle); + +typedef void (*qStrokerMoveToHook)(qfixed x, qfixed y, void *data); +typedef void (*qStrokerLineToHook)(qfixed x, qfixed y, void *data); +typedef void (*qStrokerCubicToHook)(qfixed c1x, qfixed c1y, + qfixed c2x, qfixed c2y, + qfixed ex, qfixed ey, + void *data); + +// qtransform.cpp +Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); + +class Q_GUI_EXPORT QStrokerOps +{ +public: + struct Element { + QPainterPath::ElementType type; + qfixed x; + qfixed y; + + inline bool isMoveTo() const { return type == QPainterPath::MoveToElement; } + inline bool isLineTo() const { return type == QPainterPath::LineToElement; } + inline bool isCurveTo() const { return type == QPainterPath::CurveToElement; } + + operator qfixed2d () { qfixed2d pt = { x, y }; return pt; } + }; + + QStrokerOps(); + virtual ~QStrokerOps(); + + void setMoveToHook(qStrokerMoveToHook moveToHook) { m_moveTo = moveToHook; } + void setLineToHook(qStrokerLineToHook lineToHook) { m_lineTo = lineToHook; } + void setCubicToHook(qStrokerCubicToHook cubicToHook) { m_cubicTo = cubicToHook; } + + virtual void begin(void *customData); + virtual void end(); + + inline void moveTo(qfixed x, qfixed y); + inline void lineTo(qfixed x, qfixed y); + inline void cubicTo(qfixed x1, qfixed y1, qfixed x2, qfixed y2, qfixed ex, qfixed ey); + + void strokePath(const QPainterPath &path, void *data, const QTransform &matrix); + void strokePolygon(const QPointF *points, int pointCount, bool implicit_close, + void *data, const QTransform &matrix); + void strokeEllipse(const QRectF &ellipse, void *data, const QTransform &matrix); + + QRectF clipRect() const { return m_clip_rect; } + void setClipRect(const QRectF &clip) { m_clip_rect = clip; } + + void setCurveThresholdFromTransform(const QTransform &transform) + { + qreal scale; + qt_scaleForTransform(transform, &scale); + m_dashThreshold = scale == 0 ? qreal(0.5) : (qreal(0.5) / scale); + } + + void setCurveThreshold(qfixed threshold) { m_curveThreshold = threshold; } + qfixed curveThreshold() const { return m_curveThreshold; } + +protected: + inline void emitMoveTo(qfixed x, qfixed y); + inline void emitLineTo(qfixed x, qfixed y); + inline void emitCubicTo(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey); + + virtual void processCurrentSubpath() = 0; + QDataBuffer<Element> m_elements; + + QRectF m_clip_rect; + qfixed m_curveThreshold; + qfixed m_dashThreshold; + + void *m_customData; + qStrokerMoveToHook m_moveTo; + qStrokerLineToHook m_lineTo; + qStrokerCubicToHook m_cubicTo; + +}; + +class Q_GUI_EXPORT QStroker : public QStrokerOps +{ +public: + + enum LineJoinMode { + FlatJoin, + SquareJoin, + MiterJoin, + RoundJoin, + RoundCap, + SvgMiterJoin + }; + + QStroker(); + ~QStroker(); + + void setStrokeWidth(qfixed width) + { + m_strokeWidth = width; + m_curveThreshold = qt_real_to_fixed(qBound(0.00025, 1.0 / qt_fixed_to_real(width), 0.25)); + } + qfixed strokeWidth() const { return m_strokeWidth; } + + void setCapStyle(Qt::PenCapStyle capStyle) { m_capStyle = joinModeForCap(capStyle); } + Qt::PenCapStyle capStyle() const { return capForJoinMode(m_capStyle); } + LineJoinMode capStyleMode() const { return m_capStyle; } + + void setJoinStyle(Qt::PenJoinStyle style) { m_joinStyle = joinModeForJoin(style); } + Qt::PenJoinStyle joinStyle() const { return joinForJoinMode(m_joinStyle); } + LineJoinMode joinStyleMode() const { return m_joinStyle; } + + void setMiterLimit(qfixed length) { m_miterLimit = length; } + qfixed miterLimit() const { return m_miterLimit; } + + void setForceOpen(bool state) { m_forceOpen = state; } + bool forceOpen() const { return m_forceOpen; } + + void joinPoints(qfixed x, qfixed y, const QLineF &nextLine, LineJoinMode join); + inline void emitMoveTo(qfixed x, qfixed y); + inline void emitLineTo(qfixed x, qfixed y); + inline void emitCubicTo(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey); + +protected: + static Qt::PenCapStyle capForJoinMode(LineJoinMode mode); + static LineJoinMode joinModeForCap(Qt::PenCapStyle); + + static Qt::PenJoinStyle joinForJoinMode(LineJoinMode mode); + static LineJoinMode joinModeForJoin(Qt::PenJoinStyle joinStyle); + + void processCurrentSubpath() override; + + qfixed m_strokeWidth; + qfixed m_miterLimit; + + LineJoinMode m_capStyle; + LineJoinMode m_joinStyle; + + qfixed m_back1X; + qfixed m_back1Y; + + qfixed m_back2X; + qfixed m_back2Y; + + bool m_forceOpen; +}; + +class Q_GUI_EXPORT QDashStroker : public QStrokerOps +{ +public: + QDashStroker(QStroker *stroker); + ~QDashStroker(); + + QStroker *stroker() const { return m_stroker; } + + static QList<qfixed> patternForStyle(Qt::PenStyle style); + static int repetitionLimit() { return 10000; } + + void setDashPattern(const QList<qfixed> &dashPattern) { m_dashPattern = dashPattern; } + QList<qfixed> dashPattern() const { return m_dashPattern; } + + void setDashOffset(qreal offset) { m_dashOffset = offset; } + qreal dashOffset() const { return m_dashOffset; } + + void begin(void *data) override; + void end() override; + + inline void setStrokeWidth(qreal width) { m_stroke_width = width; } + inline void setMiterLimit(qreal limit) { m_miter_limit = limit; } + +protected: + void processCurrentSubpath() override; + + QStroker *m_stroker; + QList<qfixed> m_dashPattern; + qreal m_dashOffset; + + qreal m_stroke_width; + qreal m_miter_limit; +}; + + +/******************************************************************************* + * QStrokerOps inline membmers + */ + +inline void QStrokerOps::emitMoveTo(qfixed x, qfixed y) +{ + Q_ASSERT(m_moveTo); + m_moveTo(x, y, m_customData); +} + +inline void QStrokerOps::emitLineTo(qfixed x, qfixed y) +{ + Q_ASSERT(m_lineTo); + m_lineTo(x, y, m_customData); +} + +inline void QStrokerOps::emitCubicTo(qfixed c1x, qfixed c1y, qfixed c2x, qfixed c2y, qfixed ex, qfixed ey) +{ + Q_ASSERT(m_cubicTo); + m_cubicTo(c1x, c1y, c2x, c2y, ex, ey, m_customData); +} + +inline void QStrokerOps::moveTo(qfixed x, qfixed y) +{ + if (m_elements.size()>1) + processCurrentSubpath(); + m_elements.reset(); + Element e = { QPainterPath::MoveToElement, x, y }; + m_elements.add(e); +} + +inline void QStrokerOps::lineTo(qfixed x, qfixed y) +{ + Element e = { QPainterPath::LineToElement, x, y }; + m_elements.add(e); +} + +inline void QStrokerOps::cubicTo(qfixed x1, qfixed y1, qfixed x2, qfixed y2, qfixed ex, qfixed ey) +{ + Element c1 = { QPainterPath::CurveToElement, x1, y1 }; + Element c2 = { QPainterPath::CurveToDataElement, x2, y2 }; + Element e = { QPainterPath::CurveToDataElement, ex, ey }; + m_elements.add(c1); + m_elements.add(c2); + m_elements.add(e); +} + +/******************************************************************************* + * QStroker inline members + */ +inline void QStroker::emitMoveTo(qfixed x, qfixed y) +{ + m_back2X = m_back1X; + m_back2Y = m_back1Y; + m_back1X = x; + m_back1Y = y; + QStrokerOps::emitMoveTo(x, y); +} + +inline void QStroker::emitLineTo(qfixed x, qfixed y) +{ + m_back2X = m_back1X; + m_back2Y = m_back1Y; + m_back1X = x; + m_back1Y = y; + QStrokerOps::emitLineTo(x, y); +} + +inline void QStroker::emitCubicTo(qfixed c1x, qfixed c1y, + qfixed c2x, qfixed c2y, + qfixed ex, qfixed ey) +{ + if (c2x == ex && c2y == ey) { + if (c1x == ex && c1y == ey) { + m_back2X = m_back1X; + m_back2Y = m_back1Y; + } else { + m_back2X = c1x; + m_back2Y = c1y; + } + } else { + m_back2X = c2x; + m_back2Y = c2y; + } + m_back1X = ex; + m_back1Y = ey; + QStrokerOps::emitCubicTo(c1x, c1y, c2x, c2y, ex, ey); +} + +/******************************************************************************* + * QDashStroker inline members + */ +inline void QDashStroker::begin(void *data) +{ + if (m_stroker) + m_stroker->begin(data); + QStrokerOps::begin(data); +} + +inline void QDashStroker::end() +{ + QStrokerOps::end(); + if (m_stroker) + m_stroker->end(); +} + +QT_END_NAMESPACE + +#endif // QSTROKER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstylehints_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstylehints_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fcb8230bc5db7a95304da80ba5b091e9f6afdb5f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qstylehints_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSTYLEHINTS_P_H +#define QSTYLEHINTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qpa/qplatformintegration.h> +#include <QPalette> +#include <private/qguiapplication_p.h> +#include "qstylehints.h" + +QT_BEGIN_NAMESPACE + +class QStyleHintsPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QStyleHints) +public: + int m_mouseDoubleClickInterval = -1; + int m_mousePressAndHoldInterval = -1; + int m_startDragDistance = -1; + int m_startDragTime = -1; + int m_keyboardInputInterval = -1; + int m_cursorFlashTime = -1; + int m_tabFocusBehavior = -1; + int m_uiEffects = -1; + int m_showShortcutsInContextMenus = -1; + int m_contextMenuTrigger = -1; + int m_wheelScrollLines = -1; + int m_mouseQuickSelectionThreshold = -1; + int m_mouseDoubleClickDistance = -1; + int m_touchDoubleTapDistance = -1; + + Qt::ColorScheme colorScheme() const { return m_colorScheme; } + void updateColorScheme(Qt::ColorScheme colorScheme); + + static QStyleHintsPrivate *get(QStyleHints *q); + +private: + Qt::ColorScheme m_colorScheme = Qt::ColorScheme::Unknown; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextcursor_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextcursor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5d9ea068c127623d941ccfe693b7727d03f36437 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextcursor_p.h @@ -0,0 +1,90 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTCURSOR_P_H +#define QTEXTCURSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "qtextcursor.h" +#include "qtextdocument.h" +#include "qtextdocument_p.h" +#include <private/qtextformat_p.h> +#include "qtextobject.h" + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QTextCursorPrivate : public QSharedData +{ +public: + QTextCursorPrivate(QTextDocumentPrivate *p); + QTextCursorPrivate(const QTextCursorPrivate &rhs); + ~QTextCursorPrivate(); + + static inline QTextCursorPrivate *getPrivate(QTextCursor *c) { return c->d; } + + enum AdjustResult { CursorMoved, CursorUnchanged }; + AdjustResult adjustPosition(int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op); + + void adjustCursor(QTextCursor::MoveOperation m); + + void remove(); + void clearCells(QTextTable *table, int startRow, int startCol, int numRows, int numCols, QTextUndoCommand::Operation op); + inline bool setPosition(int newPosition) { + Q_ASSERT(newPosition >= 0 && newPosition < priv->length()); + bool moved = position != newPosition; + if (moved) { + position = newPosition; + currentCharFormat = -1; + } + return moved; + } + void setX(); + bool canDelete(int pos) const; + + void insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat); + bool movePosition(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor); + + inline QTextBlock block() const + { return QTextBlock(priv, priv->blockMap().findNode(position)); } + inline QTextBlockFormat blockFormat() const + { return block().blockFormat(); } + + QTextLayout *blockLayout(QTextBlock &block) const; + + QTextTable *complexSelectionTable() const; + void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const; + + void setBlockCharFormat(const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode); + void setBlockFormat(const QTextBlockFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode); + void setCharFormat(const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode); + + void aboutToRemoveCell(int from, int to); + + static QTextCursor fromPosition(QTextDocumentPrivate *d, int pos) + { return QTextCursor(d, pos); } + + QTextDocumentPrivate *priv; + qreal x; + int position; + int anchor; + int adjusted_anchor; + int currentCharFormat; + uint visualNavigation : 1; + uint keepPositionOnInsert : 1; + uint changed : 1; +}; + +QT_END_NAMESPACE + +#endif // QTEXTCURSOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextdocument_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextdocument_p.h new file mode 100644 index 0000000000000000000000000000000000000000..de3cc42b3ef26e08ea649d02162c6111cca78365 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextdocument_p.h @@ -0,0 +1,419 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTDOCUMENT_P_H +#define QTEXTDOCUMENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qtextcursor.h" +#include "QtGui/qtextdocument.h" +#include "QtGui/qtextlayout.h" +#include "QtGui/qtextobject.h" +#include "QtGui/qtextoption.h" + +#include "QtCore/qlist.h" +#include "QtCore/qmap.h" +#include "QtCore/qset.h" +#include "QtCore/qstring.h" +#include "QtCore/qurl.h" +#include "QtCore/qvariant.h" + +#if QT_CONFIG(cssparser) +#include "private/qcssparser_p.h" +#endif +#include "private/qfragmentmap_p.h" +#include "private/qobject_p.h" +#include "private/qtextformat_p.h" + +// #define QT_QMAP_DEBUG + +#ifdef QT_QMAP_DEBUG +#include <iostream> +#endif + +QT_BEGIN_NAMESPACE + +class QTextFormatCollection; +class QTextFormat; +class QTextBlockFormat; +class QTextCursorPrivate; +class QAbstractTextDocumentLayout; +class QTextDocument; +class QTextFrame; + +#define QTextBeginningOfFrame QChar(u'\xfdd0') +#define QTextEndOfFrame QChar(u'\xfdd1') + +class QTextFragmentData : public QFragment<> +{ +public: + inline void initialize() {} + inline void invalidate() const {} + inline void free() {} + int stringPosition; + int format; +}; + +class QTextBlockData : public QFragment<3> +{ +public: + inline void initialize() + { layout = nullptr; userData = nullptr; userState = -1; revision = 0; hidden = 0; } + void invalidate() const; + inline void free() + { delete layout; layout = nullptr; delete userData; userData = nullptr; } + + mutable int format; + // ##### probably store a QTextEngine * here! + mutable QTextLayout *layout; + mutable QTextBlockUserData *userData; + mutable int userState; + mutable signed int revision : 31; + mutable uint hidden : 1; +}; + + +class QAbstractUndoItem; + +class QTextUndoCommand +{ +public: + enum Command { + Inserted = 0, + Removed = 1, + CharFormatChanged = 2, + BlockFormatChanged = 3, + BlockInserted = 4, + BlockRemoved = 5, + BlockAdded = 6, + BlockDeleted = 7, + GroupFormatChange = 8, + CursorMoved = 9, + Custom = 256 + }; + enum Operation { + KeepCursor = 0, + MoveCursor = 1 + }; + quint16 command; + uint block_part : 1; // all commands that are part of an undo block (including the first and the last one) have this set to 1 + uint block_end : 1; // the last command in an undo block has this set to 1. + uint block_padding : 6; // padding since block used to be a quint8 + quint8 operation; + int format; + quint32 strPos; + quint32 pos; + union { + int blockFormat; + quint32 length; + QAbstractUndoItem *custom; + int objectIndex; + }; + quint32 revision; + + bool tryMerge(const QTextUndoCommand &other); +}; +Q_DECLARE_TYPEINFO(QTextUndoCommand, Q_PRIMITIVE_TYPE); + +class Q_GUI_EXPORT QTextDocumentPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QTextDocument) +public: + typedef QFragmentMap<QTextFragmentData> FragmentMap; + typedef FragmentMap::ConstIterator FragmentIterator; + typedef QFragmentMap<QTextBlockData> BlockMap; + + QTextDocumentPrivate(); + ~QTextDocumentPrivate(); + + void init(); + void clear(); + + void setLayout(QAbstractTextDocumentLayout *layout); + + void insert(int pos, QStringView text, int format); + void insert(int pos, QChar c, int format) + { insert(pos, QStringView(&c, 1), format); } + void insert(int pos, int strPos, int strLength, int format); + int insertBlock(int pos, int blockFormat, int charFormat, QTextUndoCommand::Operation = QTextUndoCommand::MoveCursor); + int insertBlock(QChar blockSeparator, int pos, int blockFormat, int charFormat, + QTextUndoCommand::Operation op = QTextUndoCommand::MoveCursor); + + void move(int from, int to, int length, QTextUndoCommand::Operation = QTextUndoCommand::MoveCursor); + void remove(int pos, int length, QTextUndoCommand::Operation = QTextUndoCommand::MoveCursor); + + void aboutToRemoveCell(int cursorFrom, int cursorEnd); + + QTextFrame *insertFrame(int start, int end, const QTextFrameFormat &format); + void removeFrame(QTextFrame *frame); + + enum FormatChangeMode { MergeFormat, SetFormat, SetFormatAndPreserveObjectIndices }; + + void setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode = SetFormat); + void setBlockFormat(const QTextBlock &from, const QTextBlock &to, + const QTextBlockFormat &newFormat, FormatChangeMode mode = SetFormat); + + void emitUndoAvailable(bool available); + void emitRedoAvailable(bool available); + + int undoRedo(bool undo); + inline void undo() { undoRedo(true); } + inline void redo() { undoRedo(false); } + void appendUndoItem(QAbstractUndoItem *); + inline void beginEditBlock() { if (0 == editBlock++) ++revision; } + void joinPreviousEditBlock(); + void endEditBlock(); + void finishEdit(); + inline bool isInEditBlock() const { return editBlock; } + void enableUndoRedo(bool enable); + inline bool isUndoRedoEnabled() const { return undoEnabled; } + + inline bool isUndoAvailable() const { return undoEnabled && undoState > 0; } + inline bool isRedoAvailable() const { return undoEnabled && undoState < undoStack.size(); } + + inline int availableUndoSteps() const { return undoEnabled ? undoState : 0; } + inline int availableRedoSteps() const { return undoEnabled ? qMax(undoStack.size() - undoState - 1, 0) : 0; } + + inline QString buffer() const { return text; } + QString plainText() const; + inline int length() const { return fragments.length(); } + + inline QTextFormatCollection *formatCollection() { return &formats; } + inline const QTextFormatCollection *formatCollection() const { return &formats; } + inline QAbstractTextDocumentLayout *layout() const { return lout; } + + inline FragmentIterator find(int pos) const { return fragments.find(pos); } + inline FragmentIterator begin() const { return fragments.begin(); } + inline FragmentIterator end() const { return fragments.end(); } + + inline QTextBlock blocksBegin() const { return QTextBlock(const_cast<QTextDocumentPrivate *>(this), blocks.firstNode()); } + inline QTextBlock blocksEnd() const { return QTextBlock(const_cast<QTextDocumentPrivate *>(this), 0); } + inline QTextBlock blocksFind(int pos) const { return QTextBlock(const_cast<QTextDocumentPrivate *>(this), blocks.findNode(pos)); } + int blockCharFormatIndex(int node) const; + + inline int numBlocks() const { return blocks.numNodes(); } + + const BlockMap &blockMap() const { return blocks; } + const FragmentMap &fragmentMap() const { return fragments; } + BlockMap &blockMap() { return blocks; } + FragmentMap &fragmentMap() { return fragments; } + + static const QTextBlockData *block(const QTextBlock &it) { return it.p->blocks.fragment(it.n); } + + int nextCursorPosition(int position, QTextLayout::CursorMode mode) const; + int previousCursorPosition(int position, QTextLayout::CursorMode mode) const; + int leftCursorPosition(int position) const; + int rightCursorPosition(int position) const; + + void changeObjectFormat(QTextObject *group, int format); + + void setModified(bool m); + inline bool isModified() const { return modified; } + + inline QFont defaultFont() const { return formats.defaultFont(); } + inline void setDefaultFont(const QFont &f) { formats.setDefaultFont(f); } + + void clearUndoRedoStacks(QTextDocument::Stacks stacksToClear, bool emitSignals = false); + +private: + bool split(int pos); + bool unite(uint f); + + void insert_string(int pos, uint strPos, uint length, int format, QTextUndoCommand::Operation op); + int insert_block(int pos, uint strPos, int format, int blockformat, QTextUndoCommand::Operation op, int command); + int remove_string(int pos, uint length, QTextUndoCommand::Operation op); + int remove_block(int pos, int *blockformat, int command, QTextUndoCommand::Operation op); + + void insert_frame(QTextFrame *f); + void scan_frames(int pos, int charsRemoved, int charsAdded); + static void clearFrame(QTextFrame *f); + + void adjustDocumentChangesAndCursors(int from, int addedOrRemoved, QTextUndoCommand::Operation op); + + bool wasUndoAvailable; + bool wasRedoAvailable; + +public: + void documentChange(int from, int length); + + void addCursor(QTextCursorPrivate *c); + void removeCursor(QTextCursorPrivate *c); + + QTextFrame *frameAt(int pos) const; + QTextFrame *rootFrame() const; + + QTextObject *objectForIndex(int objectIndex) const; + QTextObject *objectForFormat(int formatIndex) const; + QTextObject *objectForFormat(const QTextFormat &f) const; + + QTextObject *createObject(const QTextFormat &newFormat, int objectIndex = -1); + void deleteObject(QTextObject *object); + + QTextDocument *document() { return q_func(); } + const QTextDocument *document() const { return q_func(); } + + bool ensureMaximumBlockCount(); + + static inline const QTextDocumentPrivate *get(const QTextDocument *document) + { + return document->d_func(); + } + + static inline QTextDocumentPrivate *get(QTextDocument *document) + { + return document->d_func(); + } + + static inline QTextDocumentPrivate *get(QTextBlock &block) + { + return block.p; + } + + static inline const QTextDocumentPrivate *get(const QTextBlock &block) + { + return block.p; + } + + static inline QTextDocumentPrivate *get(QTextObject *object) + { + return get(object->document()); + } + + static inline const QTextDocumentPrivate *get(const QTextObject *object) + { + return get(object->document()); + } + + bool canLayout() const { return layoutEnabled && !pageSize.isNull(); } + +private: + QTextDocumentPrivate(const QTextDocumentPrivate& m); + QTextDocumentPrivate& operator= (const QTextDocumentPrivate& m); + + void appendUndoItem(const QTextUndoCommand &c); + + void contentsChanged(); + + void compressPieceTable(); + + QString text; + uint unreachableCharacterCount; + + QList<QTextUndoCommand> undoStack; + bool undoEnabled; + int undoState; + int revision; + // position in undo stack of the last setModified(false) call + int modifiedState; + bool modified; + + int editBlock; + int editBlockCursorPosition; + int docChangeFrom; + int docChangeOldLength; + int docChangeLength; + bool framesDirty; + + QTextFormatCollection formats; + mutable QTextFrame *rtFrame; + QAbstractTextDocumentLayout *lout; + FragmentMap fragments; + BlockMap blocks; + int initialBlockCharFormatIndex; + + QSet<QTextCursorPrivate *> cursors; + QMap<int, QTextObject *> objects; + QMap<QUrl, QVariant> resources; + QMap<QUrl, QVariant> cachedResources; + QTextDocument::ResourceProvider resourceProvider; + QString defaultStyleSheet; + + int lastBlockCount; + +public: + bool inContentsChange; + bool layoutEnabled = true; + QTextOption defaultTextOption; + Qt::CursorMoveStyle defaultCursorMoveStyle; +#ifndef QT_NO_CSSPARSER + QCss::StyleSheet parsedDefaultStyleSheet; +#endif + int maximumBlockCount; + uint needsEnsureMaximumBlockCount : 1; + uint blockCursorAdjustment : 1; + QSizeF pageSize; + QString title; + QString url; + QString cssMedia; + QString frontMatter; + qreal indentWidth; + qreal documentMargin; + QUrl baseUrl; + + void mergeCachedResources(const QTextDocumentPrivate *priv); + + friend struct QTextHtmlParserNode; + friend class QTextHtmlExporter; + friend class QTextCursor; +}; + +class QTextTable; +class QTextHtmlExporter +{ +public: + QTextHtmlExporter(const QTextDocument *_doc); + + enum ExportMode { + ExportEntireDocument, + ExportFragment + }; + + QString toHtml(ExportMode mode = ExportEntireDocument); + +private: + enum StyleMode { EmitStyleTag, OmitStyleTag }; + enum FrameType { TextFrame, TableFrame, RootFrame }; + + void emitFrame(const QTextFrame::Iterator &frameIt); + void emitTextFrame(const QTextFrame *frame); + void emitBlock(const QTextBlock &block); + void emitTable(const QTextTable *table); + void emitFragment(const QTextFragment &fragment); + + void emitBlockAttributes(const QTextBlock &block); + bool emitCharFormatStyle(const QTextCharFormat &format); + void emitTextLength(const char *attribute, const QTextLength &length); + void emitAlignment(Qt::Alignment alignment); + void emitFloatStyle(QTextFrameFormat::Position pos, StyleMode mode = EmitStyleTag); + void emitMargins(const QString &top, const QString &bottom, const QString &left, const QString &right); + void emitAttribute(const char *attribute, const QString &value); + void emitFrameStyle(const QTextFrameFormat &format, FrameType frameType); + void emitBorderStyle(QTextFrameFormat::BorderStyle style); + void emitPageBreakPolicy(QTextFormat::PageBreakFlags policy); + + void emitFontFamily(const QStringList &families); + + void emitBackgroundAttribute(const QTextFormat &format); + QString findUrlForImage(const QTextDocument *doc, qint64 cacheKey, bool isPixmap); + + QString html; + QTextCharFormat defaultCharFormat; + const QTextDocument *doc; + bool fragmentMarkers; + QStringList closingTags; +}; + +QT_END_NAMESPACE + +#endif // QTEXTDOCUMENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextdocumentfragment_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextdocumentfragment_p.h new file mode 100644 index 0000000000000000000000000000000000000000..54bd2acc7588bb1016deb01b48d44f8c8da2088c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextdocumentfragment_p.h @@ -0,0 +1,208 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTDOCUMENTFRAGMENT_P_H +#define QTEXTDOCUMENTFRAGMENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qtextdocument.h" +#include "private/qtexthtmlparser_p.h" +#include "private/qtextdocument_p.h" +#include "QtGui/qtexttable.h" +#include "QtCore/qatomic.h" +#include "QtCore/qlist.h" +#include "QtCore/qmap.h" +#include "QtCore/qpointer.h" +#include "QtCore/qvarlengtharray.h" +#include "QtCore/qdatastream.h" + +QT_BEGIN_NAMESPACE + +class QTextDocumentFragmentPrivate; + +class QTextCopyHelper +{ +public: + QTextCopyHelper(const QTextCursor &_source, const QTextCursor &_destination, bool forceCharFormat = false, const QTextCharFormat &fmt = QTextCharFormat()); + + void copy(); + +private: + void appendFragments(int pos, int endPos); + int appendFragment(int pos, int endPos, int objectIndex = -1); + int convertFormatIndex(const QTextFormat &oldFormat, int objectIndexToSet = -1); + inline int convertFormatIndex(int oldFormatIndex, int objectIndexToSet = -1) + { return convertFormatIndex(src->formatCollection()->format(oldFormatIndex), objectIndexToSet); } + inline QTextFormat convertFormat(const QTextFormat &fmt) + { return dst->formatCollection()->format(convertFormatIndex(fmt)); } + + int insertPos; + + bool forceCharFormat; + int primaryCharFormatIndex; + + QTextCursor cursor; + QTextDocumentPrivate *dst; + QTextDocumentPrivate *src; + QTextFormatCollection &formatCollection; + const QString originalText; + QMap<int, int> objectIndexMap; +}; + +class QTextDocumentFragmentPrivate +{ +public: + QTextDocumentFragmentPrivate(const QTextCursor &cursor = QTextCursor()); + inline ~QTextDocumentFragmentPrivate() { delete doc; } + + void insert(QTextCursor &cursor) const; + + QAtomicInt ref; + QTextDocument *doc; + + uint importedFromPlainText : 1; +private: + Q_DISABLE_COPY_MOVE(QTextDocumentFragmentPrivate) +}; + +#ifndef QT_NO_TEXTHTMLPARSER + +class QTextHtmlImporter : public QTextHtmlParser +{ + struct Table; +public: + enum ImportMode { + ImportToFragment, + ImportToDocument + }; + + QTextHtmlImporter(QTextDocument *_doc, const QString &html, + ImportMode mode, + const QTextDocument *resourceProvider = nullptr); + + void import(); + +private: + bool closeTag(); + + Table scanTable(int tableNodeIdx); + + enum ProcessNodeResult { ContinueWithNextNode, ContinueWithCurrentNode, ContinueWithNextSibling }; + + void appendBlock(const QTextBlockFormat &format, QTextCharFormat charFmt = QTextCharFormat()); + bool appendNodeText(); + + ProcessNodeResult processBlockNode(); + ProcessNodeResult processSpecialNodes(); + + struct List + { + inline List() : listNode(0) {} + QTextListFormat format; + int listNode; + QPointer<QTextList> list; + }; + friend class QTypeInfo<List>; + QList<List> lists; + int indent; + int headingLevel; + + // insert a named anchor the next time we emit a char format, + // either in a block or in regular text + QStringList namedAnchors; + +#ifdef Q_CC_SUN + friend struct QTextHtmlImporter::Table; +#endif + struct TableCellIterator + { + inline TableCellIterator(QTextTable *t = nullptr) : table(t), row(0), column(0) {} + + inline TableCellIterator &operator++() { + if (atEnd()) + return *this; + do { + const QTextTableCell cell = table->cellAt(row, column); + if (!cell.isValid()) + break; + column += cell.columnSpan(); + if (column >= table->columns()) { + column = 0; + ++row; + } + } while (row < table->rows() && table->cellAt(row, column).row() != row); + + return *this; + } + + inline bool atEnd() const { return table == nullptr || row >= table->rows(); } + + QTextTableCell cell() const { return table->cellAt(row, column); } + + QTextTable *table; + int row; + int column; + }; + friend class QTypeInfo<TableCellIterator>; + + friend struct Table; + struct Table + { + Table() : isTextFrame(false), rows(0), columns(0), currentRow(0), lastIndent(0) {} + QPointer<QTextFrame> frame; + bool isTextFrame; + int rows; + int columns; + int currentRow; // ... for buggy html (see html_skipCell testcase) + TableCellIterator currentCell; + int lastIndent; + }; + friend class QTypeInfo<Table>; + QList<Table> tables; + + struct RowColSpanInfo + { + int row, col; + int rowSpan, colSpan; + }; + friend class QTypeInfo<RowColSpanInfo>; + + enum WhiteSpace + { + RemoveWhiteSpace, + CollapseWhiteSpace, + PreserveWhiteSpace + }; + + WhiteSpace compressNextWhitespace; + + QTextDocument *doc; + QTextCursor cursor; + QTextHtmlParserNode::WhiteSpaceMode wsm; + ImportMode importMode; + bool hasBlock; + bool forceBlockMerging; + bool blockTagClosed; + int currentNodeIdx; + const QTextHtmlParserNode *currentNode; +}; +Q_DECLARE_TYPEINFO(QTextHtmlImporter::List, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QTextHtmlImporter::TableCellIterator, Q_PRIMITIVE_TYPE); +Q_DECLARE_TYPEINFO(QTextHtmlImporter::Table, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QTextHtmlImporter::RowColSpanInfo, Q_PRIMITIVE_TYPE); + +QT_END_NAMESPACE +#endif // QT_NO_TEXTHTMLPARSER + +#endif // QTEXTDOCUMENTFRAGMENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextdocumentlayout_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextdocumentlayout_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3cc4e5882c3e5723b6c39b1bbf265a1041bf90c2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextdocumentlayout_p.h @@ -0,0 +1,84 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTDOCUMENTLAYOUT_P_H +#define QTEXTDOCUMENTLAYOUT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qabstracttextdocumentlayout.h" +#include "QtGui/qtextoption.h" +#include "QtGui/qtextobject.h" + +QT_BEGIN_NAMESPACE + +class QTextListFormat; +class QTextTableCell; +class QTextDocumentLayoutPrivate; + +class Q_GUI_EXPORT QTextDocumentLayout : public QAbstractTextDocumentLayout +{ + Q_DECLARE_PRIVATE(QTextDocumentLayout) + Q_OBJECT + Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth) + Q_PROPERTY(qreal idealWidth READ idealWidth) + Q_PROPERTY(bool contentHasAlignment READ contentHasAlignment) +public: + explicit QTextDocumentLayout(QTextDocument *doc); + + // from the abstract layout + void draw(QPainter *painter, const PaintContext &context) override; + int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const override; + + int pageCount() const override; + QSizeF documentSize() const override; + + void setCursorWidth(int width); + int cursorWidth() const; + + // internal, to support the ugly FixedColumnWidth wordwrap mode in QTextEdit + void setFixedColumnWidth(int width); + + // internal for QTextEdit's NoWrap mode + void setViewport(const QRectF &viewport); + + virtual QRectF frameBoundingRect(QTextFrame *frame) const override; + virtual QRectF blockBoundingRect(const QTextBlock &block) const override; + QRectF tableBoundingRect(QTextTable *table) const; + QRectF tableCellBoundingRect(QTextTable *table, const QTextTableCell &cell) const; + + // #### + int layoutStatus() const; + int dynamicPageCount() const; + QSizeF dynamicDocumentSize() const; + void ensureLayouted(qreal); + + qreal idealWidth() const; + + bool contentHasAlignment() const; + +protected: + void documentChanged(int from, int oldLength, int length) override; + void resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) override; + void positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) override; + void drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item, + int posInDocument, const QTextFormat &format) override; + virtual void timerEvent(QTimerEvent *e) override; +private: + QRectF doLayout(int from, int oldLength, int length); + void layoutFinished(); +}; + +QT_END_NAMESPACE + +#endif // QTEXTDOCUMENTLAYOUT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextengine_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3e44e7ee8f6e9293cddc05c77ec8aedef4eb960b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextengine_p.h @@ -0,0 +1,692 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTENGINE_P_H +#define QTEXTENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qpaintengine.h" +#include "QtGui/qtextcursor.h" +#include "QtGui/qtextobject.h" +#include "QtGui/qtextoption.h" +#include "QtGui/qtextlayout.h" + +#include "QtCore/qdebug.h" +#include "QtCore/qlist.h" +#include "QtCore/qnamespace.h" +#include "QtCore/qset.h" +#include <QtCore/qspan.h> +#include "QtCore/qstring.h" +#include "QtCore/qvarlengtharray.h" + +#include "private/qfixed_p.h" +#include "private/qfont_p.h" +#include "private/qtextformat_p.h" +#include "private/qunicodetools_p.h" +#ifndef QT_BUILD_COMPAT_LIB +#include "private/qtextdocument_p.h" +#endif + +#include <stdlib.h> +#include <vector> + +QT_BEGIN_NAMESPACE + +class QFontPrivate; +class QFontEngine; + +class QString; +class QPainter; + +class QAbstractTextDocumentLayout; + +typedef quint32 glyph_t; + +// this uses the same coordinate system as Qt, but a different one to freetype. +// * y is usually negative, and is equal to the ascent. +// * negative yoff means the following stuff is drawn higher up. +// the characters bounding rect is given by QRect(x,y,width,height), its advance by +// xoo and yoff +struct Q_GUI_EXPORT glyph_metrics_t +{ + inline glyph_metrics_t() + : x(100000), y(100000) {} + inline glyph_metrics_t(QFixed _x, QFixed _y, QFixed _width, QFixed _height, QFixed _xoff, QFixed _yoff) + : x(_x), + y(_y), + width(_width), + height(_height), + xoff(_xoff), + yoff(_yoff) + {} + QFixed x; + QFixed y; + QFixed width; + QFixed height; + QFixed xoff; + QFixed yoff; + + glyph_metrics_t transformed(const QTransform &xform) const; + inline bool isValid() const {return x != 100000 && y != 100000;} + + inline QFixed leftBearing() const + { + if (!isValid()) + return QFixed(); + + return x; + } + + inline QFixed rightBearing() const + { + if (!isValid()) + return QFixed(); + + return xoff - x - width; + } +}; +Q_DECLARE_TYPEINFO(glyph_metrics_t, Q_PRIMITIVE_TYPE); + +struct Q_AUTOTEST_EXPORT QScriptAnalysis +{ + enum Flags { + None = 0, + Lowercase = 1, + Uppercase = 2, + SmallCaps = 3, + LineOrParagraphSeparator = 4, + Space = 5, + SpaceTabOrObject = Space, + Nbsp = 6, + Tab = 7, + TabOrObject = Tab, + Object = 8 + }; + enum BidiFlags { + BidiBN = 1, + BidiMaybeResetToParagraphLevel = 2, + BidiResetToParagraphLevel = 4, + BidiMirrored = 8 + }; + unsigned short script : 8; + unsigned short flags : 4; + unsigned short bidiFlags : 4; + unsigned short bidiLevel : 8; // Unicode Bidi algorithm embedding level (0-125) + QChar::Direction bidiDirection : 8; // used when running the bidi algorithm + inline bool operator == (const QScriptAnalysis &other) const { + return script == other.script && bidiLevel == other.bidiLevel && flags == other.flags; + } +}; +Q_DECLARE_TYPEINFO(QScriptAnalysis, Q_PRIMITIVE_TYPE); + +struct QGlyphJustification +{ + inline QGlyphJustification() + : type(0), nKashidas(0), space_18d6(0) + {} + + enum JustificationType { + JustifyNone, + JustifySpace, + JustifyKashida + }; + + uint type :2; + uint nKashidas : 6; // more do not make sense... + uint space_18d6 : 24; +}; +Q_DECLARE_TYPEINFO(QGlyphJustification, Q_PRIMITIVE_TYPE); + +struct QGlyphAttributes { + uchar clusterStart : 1; + uchar dontPrint : 1; + uchar justification : 4; + uchar reserved : 2; +}; +static_assert(sizeof(QGlyphAttributes) == 1); +Q_DECLARE_TYPEINFO(QGlyphAttributes, Q_PRIMITIVE_TYPE); + +struct QGlyphLayout +{ + static constexpr qsizetype SpaceNeeded = sizeof(glyph_t) + sizeof(QFixed) + sizeof(QFixedPoint) + + sizeof(QGlyphAttributes) + sizeof(QGlyphJustification); + + // init to 0 not needed, done when shaping + QFixedPoint *offsets; // 8 bytes per element + glyph_t *glyphs; // 4 bytes per element + QFixed *advances; // 4 bytes per element + QGlyphJustification *justifications; // 4 bytes per element + QGlyphAttributes *attributes; // 1 byte per element + + int numGlyphs; + + inline QGlyphLayout() : numGlyphs(0) {} + + inline explicit QGlyphLayout(char *address, int totalGlyphs) + { + offsets = reinterpret_cast<QFixedPoint *>(address); + qsizetype offset = totalGlyphs * sizeof(QFixedPoint); + glyphs = reinterpret_cast<glyph_t *>(address + offset); + offset += totalGlyphs * sizeof(glyph_t); + advances = reinterpret_cast<QFixed *>(address + offset); + offset += totalGlyphs * sizeof(QFixed); + justifications = reinterpret_cast<QGlyphJustification *>(address + offset); + offset += totalGlyphs * sizeof(QGlyphJustification); + attributes = reinterpret_cast<QGlyphAttributes *>(address + offset); + numGlyphs = totalGlyphs; + } + + inline QGlyphLayout mid(int position, int n = -1) const { + QGlyphLayout copy = *this; + copy.glyphs += position; + copy.advances += position; + copy.offsets += position; + copy.justifications += position; + copy.attributes += position; + if (n == -1) + copy.numGlyphs -= position; + else + copy.numGlyphs = n; + return copy; + } + + inline QFixed effectiveAdvance(int item) const + { return (advances[item] + QFixed::fromFixed(justifications[item].space_18d6)) * !attributes[item].dontPrint; } + + inline void clear(int first = 0, int last = -1) { + if (last == -1) + last = numGlyphs; + if (first == 0 && last == numGlyphs + && reinterpret_cast<char *>(offsets + numGlyphs) == reinterpret_cast<char *>(glyphs)) { + memset(static_cast<void *>(offsets), 0, qsizetype(numGlyphs) * SpaceNeeded); + } else { + const int num = last - first; + memset(static_cast<void *>(offsets + first), 0, num * sizeof(QFixedPoint)); + memset(glyphs + first, 0, num * sizeof(glyph_t)); + memset(static_cast<void *>(advances + first), 0, num * sizeof(QFixed)); + memset(static_cast<void *>(justifications + first), 0, num * sizeof(QGlyphJustification)); + memset(attributes + first, 0, num * sizeof(QGlyphAttributes)); + } + } + + inline char *data() { + return reinterpret_cast<char *>(offsets); + } + + void copy(QGlyphLayout *other); + void grow(char *address, int totalGlyphs); +}; + +class QVarLengthGlyphLayoutArray : private QVarLengthArray<void *>, public QGlyphLayout +{ +private: + typedef QVarLengthArray<void *> Array; +public: + QVarLengthGlyphLayoutArray(int totalGlyphs) + : Array((totalGlyphs * SpaceNeeded) / sizeof(void *) + 1) + , QGlyphLayout(reinterpret_cast<char *>(Array::data()), totalGlyphs) + { + memset(Array::data(), 0, Array::size() * sizeof(void *)); + } + + void resize(int totalGlyphs) + { + Array::resize((totalGlyphs * SpaceNeeded) / sizeof(void *) + 1); + + *((QGlyphLayout *)this) = QGlyphLayout(reinterpret_cast<char *>(Array::data()), totalGlyphs); + memset(Array::data(), 0, Array::size() * sizeof(void *)); + } +}; + +template <int N> struct QGlyphLayoutArray : public QGlyphLayout +{ +public: + QGlyphLayoutArray() + : QGlyphLayout(reinterpret_cast<char *>(buffer), N) + { + memset(buffer, 0, sizeof(buffer)); + } + +private: + void *buffer[(N * SpaceNeeded) / sizeof(void *) + 1]; +}; + +struct QScriptItem; +/// Internal QTextItem +class QTextItemInt : public QTextItem +{ +public: + inline QTextItemInt() = default; + QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format = QTextCharFormat()); + QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe, + const QTextCharFormat &format = QTextCharFormat()); + + /// copy the structure items, adjusting the glyphs arrays to the right subarrays. + /// the width of the returned QTextItemInt is not adjusted, for speed reasons + QTextItemInt midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const; + void initWithScriptItem(const QScriptItem &si); + + QFixed descent; + QFixed ascent; + QFixed width; + + RenderFlags flags; + bool justified = false; + QTextCharFormat::UnderlineStyle underlineStyle = QTextCharFormat::NoUnderline; + const QTextCharFormat charFormat; + int num_chars = 0; + const QChar *chars = nullptr; + const unsigned short *logClusters = nullptr; + const QFont *f = nullptr; + + QGlyphLayout glyphs; + QFontEngine *fontEngine = nullptr; +}; + +struct QScriptItem +{ + constexpr QScriptItem(int p, QScriptAnalysis a) noexcept + : position(p), analysis(a), + num_glyphs(0), descent(-1), ascent(-1), leading(-1), width(-1), + glyph_data_offset(0) {} + + int position; + QScriptAnalysis analysis; + unsigned short num_glyphs; + QFixed descent; + QFixed ascent; + QFixed leading; + QFixed width; + int glyph_data_offset; + constexpr QFixed height() const noexcept { return ascent + descent; } +private: + friend class QList<QScriptItem>; + QScriptItem() {} // for QList, don't use +}; +Q_DECLARE_TYPEINFO(QScriptItem, Q_PRIMITIVE_TYPE); + +typedef QList<QScriptItem> QScriptItemArray; + +struct Q_AUTOTEST_EXPORT QScriptLine +{ + // created and filled in QTextLine::layout_helper + QScriptLine() + : from(0), trailingSpaces(0), length(0), + justified(0), gridfitted(0), + hasTrailingSpaces(0), leadingIncluded(0) {} + QFixed descent; + QFixed ascent; + QFixed leading; + QFixed x; + QFixed y; + QFixed width; + QFixed textWidth; + QFixed textAdvance; + int from; + unsigned short trailingSpaces; + signed int length : 28; + mutable uint justified : 1; + mutable uint gridfitted : 1; + uint hasTrailingSpaces : 1; + uint leadingIncluded : 1; + QFixed height() const { return ascent + descent + + (leadingIncluded? qMax(QFixed(),leading) : QFixed()); } + QFixed base() const { return ascent; } + void setDefaultHeight(QTextEngine *eng); + void operator+=(const QScriptLine &other); +}; +Q_DECLARE_TYPEINFO(QScriptLine, Q_PRIMITIVE_TYPE); + + +inline void QScriptLine::operator+=(const QScriptLine &other) +{ + leading= qMax(leading + ascent, other.leading + other.ascent) - qMax(ascent, other.ascent); + descent = qMax(descent, other.descent); + ascent = qMax(ascent, other.ascent); + textWidth += other.textWidth; + length += other.length; +} + +typedef QList<QScriptLine> QScriptLineArray; + +class QFontPrivate; +class QTextFormatCollection; + +class Q_GUI_EXPORT QTextEngine { +public: + enum LayoutState { + LayoutEmpty, + InLayout, + LayoutFailed + }; + struct Q_GUI_EXPORT LayoutData { + LayoutData(const QString &str, void **stack_memory, qsizetype mem_size); + LayoutData(); + ~LayoutData(); + mutable QScriptItemArray items; + qsizetype allocated; + qsizetype available_glyphs; + void **memory; + unsigned short *logClustersPtr; + QGlyphLayout glyphLayout; + mutable int used; + uint hasBidi : 1; + uint layoutState : 2; + uint memory_on_stack : 1; + uint haveCharAttributes : 1; + QFixed currentMaxWidth; + QString string; + bool reallocate(int totalGlyphs); + }; + + struct ItemDecoration { + ItemDecoration() { } // for QList, don't use + ItemDecoration(qreal x1, qreal x2, qreal y, const QPen &pen): + x1(x1), x2(x2), y(y), pen(pen) {} + + qreal x1; + qreal x2; + qreal y; + QPen pen; + }; + + typedef QList<ItemDecoration> ItemDecorationList; + + QTextEngine(); + QTextEngine(const QString &str, const QFont &f); + ~QTextEngine(); + + enum Mode { + WidthOnly = 0x07 + }; + + void invalidate(); + void clearLineData(); + + void validate() const; + void itemize() const; + + bool isRightToLeft() const; + static void bidiReorder(int numRuns, const quint8 *levels, int *visualOrder); + + const QCharAttributes *attributes() const; + + void shape(int item) const; + + void justify(const QScriptLine &si); + QFixed alignLine(const QScriptLine &line); + + QFixed width(int charFrom, int numChars) const; + glyph_metrics_t boundingBox(int from, int len) const; + glyph_metrics_t tightBoundingBox(int from, int len) const; + + int length(int item) const { + const QScriptItem &si = layoutData->items[item]; + int from = si.position; + item++; + return (item < layoutData->items.size() ? layoutData->items[item].position : layoutData->string.size()) - from; + } + int length(const QScriptItem *si) const { + int end; + if (si + 1 < layoutData->items.constData()+ layoutData->items.size()) + end = (si+1)->position; + else + end = layoutData->string.size(); + return end - si->position; + } + + QFontEngine *fontEngine(const QScriptItem &si, QFixed *ascent = nullptr, QFixed *descent = nullptr, QFixed *leading = nullptr) const; + QFont font(const QScriptItem &si) const; + inline QFont font() const { return fnt; } + + /** + * Returns a pointer to an array of log clusters, offset at the script item. + * Each item in the array is a unsigned short. For each character in the original string there is an entry in the table + * so there is a one to one correlation in indexes between the original text and the index in the logcluster. + * The value of each item is the position in the glyphs array. Multiple similar pointers in the logclusters array imply + * that one glyph is used for more than one character. + * \sa glyphs() + */ + inline unsigned short *logClusters(const QScriptItem *si) const + { return layoutData->logClustersPtr+si->position; } + /** + * Returns an array of QGlyphLayout items, offset at the script item. + * Each item in the array matches one glyph in the text, storing the advance, position etc. + * The returned item's length equals to the number of available glyphs. This may be more + * than what was actually shaped. + * \sa logClusters() + */ + inline QGlyphLayout availableGlyphs(const QScriptItem *si) const { + return layoutData->glyphLayout.mid(si->glyph_data_offset); + } + /** + * Returns an array of QGlyphLayout items, offset at the script item. + * Each item in the array matches one glyph in the text, storing the advance, position etc. + * The returned item's length equals to the number of shaped glyphs. + * \sa logClusters() + */ + inline QGlyphLayout shapedGlyphs(const QScriptItem *si) const { + return layoutData->glyphLayout.mid(si->glyph_data_offset, si->num_glyphs); + } + + inline bool ensureSpace(int nGlyphs) const { + if (layoutData->glyphLayout.numGlyphs - layoutData->used < nGlyphs) + return layoutData->reallocate((((layoutData->used + nGlyphs)*3/2 + 15) >> 4) << 4); + return true; + } + + void freeMemory(); + + int findItem(int strPos, int firstItem = 0) const; + inline QTextFormatCollection *formatCollection() const { + if (QTextDocumentPrivate::get(block) != nullptr) + return const_cast<QTextFormatCollection *>(QTextDocumentPrivate::get(block)->formatCollection()); + return specialData ? specialData->formatCollection.data() : nullptr; + } + QTextCharFormat format(const QScriptItem *si) const; + inline QAbstractTextDocumentLayout *docLayout() const { + Q_ASSERT(QTextDocumentPrivate::get(block) != nullptr); + return QTextDocumentPrivate::get(block)->document()->documentLayout(); + } + int formatIndex(const QScriptItem *si) const; + + /// returns the width of tab at index (in the tabs array) with the tab-start at position x + QFixed calculateTabWidth(int index, QFixed x) const; + + mutable QScriptLineArray lines; + +private: + struct FontEngineCache { + FontEngineCache(); + mutable QFontEngine *prevFontEngine; + mutable QFontEngine *prevScaledFontEngine; + mutable int prevScript; + mutable int prevPosition; + mutable int prevLength; + inline void reset() { + prevFontEngine = nullptr; + prevScaledFontEngine = nullptr; + prevScript = -1; + prevPosition = -1; + prevLength = -1; + } + }; + mutable FontEngineCache feCache; + +public: + QString text; + mutable QFont fnt; +#ifndef QT_NO_RAWFONT + QRawFont rawFont; +#endif + QTextBlock block; + + QTextOption option; + + QFixed minWidth; + QFixed maxWidth; + QPointF position; + uint ignoreBidi : 1; + uint cacheGlyphs : 1; + uint stackEngine : 1; + uint forceJustification : 1; + uint visualMovement : 1; + uint delayDecorations: 1; +#ifndef QT_NO_RAWFONT + uint useRawFont : 1; +#endif + + mutable LayoutData *layoutData; + + ItemDecorationList underlineList; + ItemDecorationList strikeOutList; + ItemDecorationList overlineList; + + inline bool visualCursorMovement() const + { return visualMovement || (QTextDocumentPrivate::get(block) != nullptr && QTextDocumentPrivate::get(block)->defaultCursorMoveStyle == Qt::VisualMoveStyle); } + + inline int preeditAreaPosition() const { return specialData ? specialData->preeditPosition : -1; } + inline QString preeditAreaText() const { return specialData ? specialData->preeditText : QString(); } + void setPreeditArea(int position, const QString &text); + + inline bool hasFormats() const + { return QTextDocumentPrivate::get(block) != nullptr || (specialData && !specialData->formats.isEmpty()); } + inline QList<QTextLayout::FormatRange> formats() const + { + return specialData ? specialData->formats : QList<QTextLayout::FormatRange>(); + } + void setFormats(const QList<QTextLayout::FormatRange> &formats); + +private: + static void init(QTextEngine *e); + + struct SpecialData { + int preeditPosition; + QString preeditText; + QList<QTextLayout::FormatRange> formats; + QList<QTextCharFormat> resolvedFormats; + // only used when no QTextDocumentPrivate is available + QScopedPointer<QTextFormatCollection> formatCollection; + }; + SpecialData *specialData; + + void indexFormats(); + void resolveFormats() const; + +public: + bool atWordSeparator(int position) const; + + QString elidedText(Qt::TextElideMode mode, QFixed width, int flags = 0, int from = 0, int count = -1) const; + + void shapeLine(const QScriptLine &line); + QFixed leadingSpaceWidth(const QScriptLine &line); + + QFixed offsetInLigature(const QScriptItem *si, int pos, int max, int glyph_pos); + int positionInLigature(const QScriptItem *si, int end, QFixed x, QFixed edge, int glyph_pos, bool cursorOnCharacter); + int previousLogicalPosition(int oldPos) const; + int nextLogicalPosition(int oldPos) const; + int lineNumberForTextPosition(int pos); + int positionAfterVisualMovement(int oldPos, QTextCursor::MoveOperation op); + std::vector<int> insertionPointsForLine(int lineNum); + void resetFontEngineCache(); + + void enableDelayDecorations(bool enable = true) { delayDecorations = enable; } + + void addUnderline(QPainter *painter, const QLineF &line); + void addStrikeOut(QPainter *painter, const QLineF &line); + void addOverline(QPainter *painter, const QLineF &line); + + void drawDecorations(QPainter *painter); + void clearDecorations(); + void adjustUnderlines(); + +private: + void addItemDecoration(QPainter *painter, const QLineF &line, ItemDecorationList *decorationList); + void adjustUnderlines(ItemDecorationList::iterator start, + ItemDecorationList::iterator end, + qreal underlinePos, qreal penWidth); + void drawItemDecorationList(QPainter *painter, const ItemDecorationList &decorationList); + void setBoundary(int strPos) const; + void addRequiredBoundaries() const; + void shapeText(int item) const; +#if QT_CONFIG(harfbuzz) + int shapeTextWithHarfbuzzNG(const QScriptItem &si, + const ushort *string, + int itemLength, + QFontEngine *fontEngine, + QSpan<uint> itemBoundaries, + bool kerningEnabled, + bool hasLetterSpacing, + const QHash<QFont::Tag, quint32> &features) const; +#endif + + int endOfLine(int lineNum); + int beginningOfLine(int lineNum); + int getClusterLength(unsigned short *logClusters, const QCharAttributes *attributes, int from, int to, int glyph_pos, int *start); +}; + +class Q_GUI_EXPORT QStackTextEngine : public QTextEngine { +public: + enum { MemSize = 256*40/sizeof(void *) }; + QStackTextEngine(const QString &string, const QFont &f); + LayoutData _layoutData; + void *_memory[MemSize]; +}; +Q_DECLARE_TYPEINFO(QTextEngine::ItemDecoration, Q_RELOCATABLE_TYPE); + +struct QTextLineItemIterator +{ + QTextLineItemIterator(QTextEngine *eng, int lineNum, const QPointF &pos = QPointF(), + const QTextLayout::FormatRange *_selection = nullptr); + + inline bool atEnd() const { return logicalItem >= nItems - 1; } + inline bool atBeginning() const { return logicalItem <= 0; } + QScriptItem &next(); + + bool getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const; + inline bool isOutsideSelection() const { + QFixed tmp1, tmp2; + return !getSelectionBounds(&tmp1, &tmp2); + } + + QTextEngine *eng; + + QFixed x; + const QScriptLine &line; + QScriptItem *si; + + const int lineNum; + const int lineEnd; + const int firstItem; + const int lastItem; + const int nItems; + int logicalItem; + int item; + int itemLength; + + int glyphsStart; + int glyphsEnd; + int itemStart; + int itemEnd; + + QFixed itemWidth; + + QVarLengthArray<int> visualOrder; + + const QTextLayout::FormatRange *selection; +}; + +QT_END_NAMESPACE + +#endif // QTEXTENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextformat_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextformat_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4ea47eb1185275da6be12cd59ad09332ca64ca3d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextformat_p.h @@ -0,0 +1,84 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTFORMAT_P_H +#define QTEXTFORMAT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qtextformat.h" +#include "QtCore/qlist.h" +#include <QtCore/qhash.h> // QMultiHash + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QTextFormatCollection +{ +public: + QTextFormatCollection() {} + ~QTextFormatCollection(); + + void clear(); + + inline QTextFormat objectFormat(int objectIndex) const + { return format(objectFormatIndex(objectIndex)); } + inline void setObjectFormat(int objectIndex, const QTextFormat &format) + { setObjectFormatIndex(objectIndex, indexForFormat(format)); } + + int objectFormatIndex(int objectIndex) const; + void setObjectFormatIndex(int objectIndex, int formatIndex); + + int createObjectIndex(const QTextFormat &f); + + int indexForFormat(const QTextFormat &f); + bool hasFormatCached(const QTextFormat &format) const; + + QTextFormat format(int idx) const; + inline QTextBlockFormat blockFormat(int index) const + { return format(index).toBlockFormat(); } + inline QTextCharFormat charFormat(int index) const + { return format(index).toCharFormat(); } + inline QTextListFormat listFormat(int index) const + { return format(index).toListFormat(); } + inline QTextTableFormat tableFormat(int index) const + { return format(index).toTableFormat(); } + inline QTextImageFormat imageFormat(int index) const + { return format(index).toImageFormat(); } + + inline int numFormats() const { return formats.size(); } + + typedef QList<QTextFormat> FormatVector; + + FormatVector formats; + QList<qint32> objFormats; + QMultiHash<size_t,int> hashes; + + inline QFont defaultFont() const { return defaultFnt; } + void setDefaultFont(const QFont &f); + + inline void setSuperScriptBaseline(qreal baseline) { defaultFormat.setSuperScriptBaseline(baseline); } + inline void setSubScriptBaseline(qreal baseline) { defaultFormat.setSubScriptBaseline(baseline); } + inline void setBaselineOffset(qreal baseline) { defaultFormat.setBaselineOffset(baseline); } + + inline QTextCharFormat defaultTextFormat() const { return defaultFormat; } + +private: + QFont defaultFnt; + QTextCharFormat defaultFormat; + + Q_DISABLE_COPY_MOVE(QTextFormatCollection) +}; + +QT_END_NAMESPACE + +#endif // QTEXTFORMAT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexthtmlparser_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexthtmlparser_p.h new file mode 100644 index 0000000000000000000000000000000000000000..953225910584ef453ddecbefe932028a5a58ef00 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexthtmlparser_p.h @@ -0,0 +1,339 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTHTMLPARSER_P_H +#define QTEXTHTMLPARSER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qbrush.h" +#include "QtGui/qcolor.h" +#include "QtGui/qfont.h" +#include "QtGui/qtextdocument.h" +#include "QtGui/qtextcursor.h" + +#include "QtCore/qlist.h" + +#include "private/qtextformat_p.h" +#include "private/qtextdocument_p.h" +#if QT_CONFIG(cssparser) +#include "private/qcssparser_p.h" +#endif + +#ifndef QT_NO_TEXTHTMLPARSER + +QT_BEGIN_NAMESPACE + +enum QTextHTMLElements { + Html_unknown = -1, + Html_qt = 0, + Html_body, + + Html_a, + Html_em, + Html_i, + Html_big, + Html_small, + Html_strong, + Html_b, + Html_cite, + Html_address, + Html_var, + Html_dfn, + + Html_h1, + Html_h2, + Html_h3, + Html_h4, + Html_h5, + Html_h6, + Html_p, + Html_center, + + Html_font, + + Html_ul, + Html_ol, + Html_li, + + Html_code, + Html_tt, + Html_kbd, + Html_samp, + + Html_img, + Html_br, + Html_hr, + + Html_sub, + Html_sup, + + Html_pre, + Html_blockquote, + Html_head, + Html_div, + Html_span, + Html_dl, + Html_dt, + Html_dd, + Html_u, + Html_s, + Html_nobr, + + // tables + Html_table, + Html_tr, + Html_td, + Html_th, + Html_thead, + Html_tbody, + Html_tfoot, + Html_caption, + + // misc... + Html_html, + Html_style, + Html_title, + Html_meta, + Html_link, + Html_script, + + Html_NumElements +}; + +struct QTextHtmlElement +{ + const char name[11]; + QTextHTMLElements id; + enum DisplayMode { DisplayBlock, DisplayInline, DisplayTable, DisplayNone } displayMode; +}; + +class QTextHtmlParser; + +struct QTextHtmlParserNode { + enum WhiteSpaceMode { + WhiteSpaceNormal, + WhiteSpacePre, + WhiteSpaceNoWrap, + WhiteSpacePreWrap, + WhiteSpacePreLine, + WhiteSpaceModeUndefined = -1 + }; + + QTextHtmlParserNode(); + QString tag; + QString text; + QStringList attributes; + int parent; + QList<int> children; + QTextHTMLElements id; + QTextCharFormat charFormat; + QTextBlockFormat blockFormat; + uint cssFloat : 2; + uint hasOwnListStyle : 1; + uint hasOwnLineHeightType : 1; + uint hasLineHeightMultiplier : 1; + uint hasCssListIndent : 1; + uint isEmptyParagraph : 1; + uint isTextFrame : 1; + uint isRootFrame : 1; + uint displayMode : 3; // QTextHtmlElement::DisplayMode + uint hasHref : 1; + QTextListFormat::Style listStyle; + int listStart = 1; + QString textListNumberPrefix; + QString textListNumberSuffix; + QString imageName; + QString imageAlt; + qreal imageWidth; + qreal imageHeight; + QTextLength width; + QTextLength height; + qreal tableBorder; + int tableCellRowSpan; + int tableCellColSpan; + qreal tableCellSpacing; + qreal tableCellPadding; + qreal tableCellBorder[4]; + QBrush tableCellBorderBrush[4]; + QTextFrameFormat::BorderStyle tableCellBorderStyle[4]; + QBrush borderBrush; + QTextFrameFormat::BorderStyle borderStyle; + bool borderCollapse; + int userState; + + int cssListIndent; + + WhiteSpaceMode wsm; + + inline bool isListStart() const + { return id == Html_ol || id == Html_ul; } + inline bool isTableCell() const + { return id == Html_td || id == Html_th; } + inline bool isBlock() const + { return displayMode == QTextHtmlElement::DisplayBlock; } + + inline bool isNotSelfNesting() const + { return id == Html_p || id == Html_li; } + + inline bool allowedInContext(int parentId) const + { + switch (id) { + case Html_dd: + case Html_dt: return (parentId == Html_dl); + case Html_tr: return (parentId == Html_table + || parentId == Html_thead + || parentId == Html_tbody + || parentId == Html_tfoot + ); + case Html_th: + case Html_td: return (parentId == Html_tr); + case Html_thead: + case Html_tbody: + case Html_tfoot: return (parentId == Html_table); + case Html_caption: return (parentId == Html_table); + case Html_body: return parentId != Html_head; + default: break; + } + return true; + } + + inline bool mayNotHaveChildren() const + { return id == Html_img || id == Html_hr || id == Html_br || id == Html_meta; } + + void initializeProperties(const QTextHtmlParserNode *parent, const QTextHtmlParser *parser); + + inline int uncollapsedMargin(int mar) const { return margin[mar]; } + + bool isNestedList(const QTextHtmlParser *parser) const; + + void parseStyleAttribute(const QString &value, const QTextDocument *resourceProvider); + +#if QT_CONFIG(cssparser) + void applyCssDeclarations(const QList<QCss::Declaration> &declarations, + const QTextDocument *resourceProvider); + + void setListStyle(const QList<QCss::Value> &cssValues); +# endif + + void applyForegroundImage(qint64 cacheKey, const QTextDocument *resourceProvider); + void applyBackgroundImage(const QString &url, const QTextDocument *resourceProvider); + + bool hasOnlyWhitespace() const; + + int margin[4]; + int padding[4]; + + friend class QTextHtmlParser; +}; +Q_DECLARE_TYPEINFO(QTextHtmlParserNode, Q_RELOCATABLE_TYPE); + + +class QTextHtmlParser +{ +public: + enum Margin { + MarginTop, + MarginRight, + MarginBottom, + MarginLeft + }; + ~QTextHtmlParser() + { + qDeleteAll(nodes); + } + + inline const QTextHtmlParserNode &at(int i) const { return *nodes.at(i); } + inline QTextHtmlParserNode &operator[](int i) { return *nodes[i]; } + inline int count() const { return nodes.size(); } + inline int last() const { return nodes.size()-1; } + int depth(int i) const; + int topMargin(int i) const; + int bottomMargin(int i) const; + inline int leftMargin(int i) const { return margin(i, MarginLeft); } + inline int rightMargin(int i) const { return margin(i, MarginRight); } + + inline int topPadding(int i) const { return at(i).padding[MarginTop]; } + inline int bottomPadding(int i) const { return at(i).padding[MarginBottom]; } + inline int leftPadding(int i) const { return at(i).padding[MarginLeft]; } + inline int rightPadding(int i) const { return at(i).padding[MarginRight]; } + + inline qreal tableCellBorder(int i, int edge) const { return at(i).tableCellBorder[edge]; } + inline QTextFrameFormat::BorderStyle tableCellBorderStyle(int i, int edge) const { return at(i).tableCellBorderStyle[edge]; } + inline QBrush tableCellBorderBrush(int i, int edge) const { return at(i).tableCellBorderBrush[edge]; } + + void dumpHtml(); + + void parse(const QString &text, const QTextDocument *resourceProvider); + + static int lookupElement(QStringView element); + + Q_GUI_EXPORT static QString parseEntity(QStringView entity); + +protected: + QTextHtmlParserNode *newNode(int parent); + QList<QTextHtmlParserNode *> nodes; + QString txt; + int pos, len; + + bool textEditMode; + + void parse(); + void parseTag(); + void parseCloseTag(); + void parseExclamationTag(); + QString parseEntity(); + QString parseWord(); + QTextHtmlParserNode *resolveParent(); + void resolveNode(); + QStringList parseAttributes(); + void applyAttributes(const QStringList &attributes); + void eatSpace(); + inline bool hasPrefix(QChar c, int lookahead = 0) const + { + return pos + lookahead < len && txt.at(pos + lookahead) == c; + } + int margin(int i, int mar) const; + + bool nodeIsChildOf(int i, QTextHTMLElements id) const; + + +#if QT_CONFIG(cssparser) + QList<QCss::Declaration> declarationsForNode(int node) const; + void resolveStyleSheetImports(const QCss::StyleSheet &sheet); + void importStyleSheet(const QString &href); + + struct ExternalStyleSheet + { + inline ExternalStyleSheet() {} + inline ExternalStyleSheet(const QString &_url, const QCss::StyleSheet &_sheet) + : url(_url), sheet(_sheet) {} + QString url; + QCss::StyleSheet sheet; + }; + friend class QTypeInfo<ExternalStyleSheet>; + QList<ExternalStyleSheet> externalStyleSheets; + QList<QCss::StyleSheet> inlineStyleSheets; +# endif + + const QTextDocument *resourceProvider; +}; +#if QT_CONFIG(cssparser) +Q_DECLARE_TYPEINFO(QTextHtmlParser::ExternalStyleSheet, Q_RELOCATABLE_TYPE); +#endif + +QT_END_NAMESPACE + +#endif // QT_NO_TEXTHTMLPARSER + +#endif // QTEXTHTMLPARSER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextimagehandler_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextimagehandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d05ebb1fa25b0cc5345149d8bbc95de3b8c3a010 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextimagehandler_p.h @@ -0,0 +1,41 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTIMAGEHANDLER_P_H +#define QTEXTIMAGEHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtCore/qobject.h" +#include "QtGui/qabstracttextdocumentlayout.h" + +QT_BEGIN_NAMESPACE + +class QTextImageFormat; + +class Q_GUI_EXPORT QTextImageHandler : public QObject, + public QTextObjectInterface +{ + Q_OBJECT + Q_INTERFACES(QTextObjectInterface) +public: + explicit QTextImageHandler(QObject *parent = nullptr); + + virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) override; + virtual void drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) override; + QImage image(QTextDocument *doc, const QTextImageFormat &imageFormat); +}; + +QT_END_NAMESPACE + +#endif // QTEXTIMAGEHANDLER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextmarkdownimporter_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextmarkdownimporter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bf30c14f4c45e628ae094eb61abc38477102bd3e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextmarkdownimporter_p.h @@ -0,0 +1,112 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTMARKDOWNIMPORTER_H +#define QTEXTMARKDOWNIMPORTER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qfont.h> +#include <QtGui/qtguiglobal.h> +#include <QtGui/qpalette.h> +#include <QtGui/qtextdocument.h> +#include <QtGui/qtextlist.h> +#include <QtCore/qpointer.h> +#include <QtCore/qstack.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QTextCursor; +class QTextDocument; +class QTextTable; + +class Q_GUI_EXPORT QTextMarkdownImporter +{ +public: + enum Feature { + FeatureCollapseWhitespace = 0x0001, + FeaturePermissiveATXHeaders = 0x0002, + FeaturePermissiveURLAutoLinks = 0x0004, + FeaturePermissiveMailAutoLinks = 0x0008, + FeatureNoIndentedCodeBlocks = 0x0010, + FeatureNoHTMLBlocks = 0x0020, + FeatureNoHTMLSpans = 0x0040, + FeatureTables = 0x0100, + FeatureStrikeThrough = 0x0200, + FeaturePermissiveWWWAutoLinks = 0x0400, + FeatureTasklists = 0x0800, + FeatureUnderline = 0x4000, + FeatureFrontMatter = 0x100000, // Qt feature, not yet in MD4C + // composite flags + FeaturePermissiveAutoLinks = FeaturePermissiveMailAutoLinks + | FeaturePermissiveURLAutoLinks | FeaturePermissiveWWWAutoLinks, + FeatureNoHTML = QTextDocument::MarkdownNoHTML, + DialectCommonMark = QTextDocument::MarkdownDialectCommonMark, + DialectGitHub = QTextDocument::MarkdownDialectGitHub + }; + Q_DECLARE_FLAGS(Features, Feature) + + QTextMarkdownImporter(QTextDocument *doc, Features features); + QTextMarkdownImporter(QTextDocument *doc, QTextDocument::MarkdownFeatures features); + + void import(const QString &markdown); + +public: + // MD4C callbacks + int cbEnterBlock(int blockType, void* detail); + int cbLeaveBlock(int blockType, void* detail); + int cbEnterSpan(int spanType, void* detail); + int cbLeaveSpan(int spanType, void* detail); + int cbText(int textType, const char* text, unsigned size); + +private: + void insertBlock(); + +private: + QTextCursor m_cursor; + QTextTable *m_currentTable = nullptr; // because m_cursor->currentTable() doesn't work +#if QT_CONFIG(regularexpression) + QString m_htmlAccumulator; +#endif + QString m_blockCodeLanguage; + QList<int> m_nonEmptyTableCells; // in the current row + QStack<QPointer<QTextList>> m_listStack; + QStack<QTextCharFormat> m_spanFormatStack; + QFont m_monoFont; + QPalette m_palette; +#if QT_CONFIG(regularexpression) + int m_htmlTagDepth = 0; +#endif + int m_blockQuoteDepth = 0; + int m_tableColumnCount = 0; + int m_tableRowCount = 0; + int m_tableCol = -1; // because relative cell movements (e.g. m_cursor->movePosition(QTextCursor::NextCell)) don't work + int m_paragraphMargin = 0; + int m_blockType = 0; + char m_blockCodeFence = 0; + Features m_features; + QTextImageFormat m_imageFormat; + QTextListFormat m_listFormat; + QTextBlockFormat::MarkerType m_markerType = QTextBlockFormat::MarkerType::NoMarker; + bool m_needsInsertBlock = false; + bool m_needsInsertList = false; + bool m_listItem = false; // true from the beginning of LI to the end of the first P + bool m_codeBlock = false; + bool m_imageSpan = false; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QTextMarkdownImporter::Features) + +QT_END_NAMESPACE + +#endif // QTEXTMARKDOWNIMPORTER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextmarkdownwriter_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextmarkdownwriter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..53125ce3828e5c7c7f038639d0ff5869bae91214 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextmarkdownwriter_p.h @@ -0,0 +1,65 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTMARKDOWNWRITER_P_H +#define QTEXTMARKDOWNWRITER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtCore/QTextStream> + +#include "qtextdocument_p.h" +#include "qtextdocumentwriter.h" + +QT_BEGIN_NAMESPACE + +class QAbstractItemModel; + +class Q_GUI_EXPORT QTextMarkdownWriter +{ +public: + QTextMarkdownWriter(QTextStream &stream, QTextDocument::MarkdownFeatures features); + bool writeAll(const QTextDocument *document); +#if QT_CONFIG(itemmodel) + void writeTable(const QAbstractItemModel *table); +#endif + + int writeBlock(const QTextBlock &block, bool table, bool ignoreFormat, bool ignoreEmpty); + void writeFrame(const QTextFrame *frame); + void writeFrontMatter(const QString &fm); + +private: + struct ListInfo { + bool loose; + }; + + ListInfo listInfo(QTextList *list); + void setLinePrefixForBlockQuote(int level); + +private: + QTextStream &m_stream; + QTextDocument::MarkdownFeatures m_features; + QMap<QTextList *, ListInfo> m_listInfo; + QString m_linePrefix; + QString m_codeBlockFence; + int m_wrappedLineIndent = 0; + int m_lastListIndent = 1; + bool m_doubleNewlineWritten = false; + bool m_linePrefixWritten = false; + bool m_indentedCodeBlock = false; + bool m_fencedCodeBlock = false; +}; + +QT_END_NAMESPACE + +#endif // QTEXTMARKDOWNWRITER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextobject_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f8a09f1e35721c997fc94163615047e71488d97f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextobject_p.h @@ -0,0 +1,77 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTOBJECT_P_H +#define QTEXTOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qtextobject.h" +#include "private/qobject_p.h" +#include "QtGui/qtextdocument.h" + +QT_BEGIN_NAMESPACE + +class QTextDocumentPrivate; + +class QTextObjectPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QTextObject) +public: + QTextObjectPrivate(QTextDocument *doc) + : pieceTable(doc->d_func()), objectIndex(-1) + { + } + QTextDocumentPrivate *pieceTable; + int objectIndex; +}; + +class QTextBlockGroupPrivate : public QTextObjectPrivate +{ + Q_DECLARE_PUBLIC(QTextBlockGroup) +public: + QTextBlockGroupPrivate(QTextDocument *doc) + : QTextObjectPrivate(doc) + { + } + typedef QList<QTextBlock> BlockList; + BlockList blocks; + void markBlocksDirty(); +}; + +class QTextFrameLayoutData; + +class QTextFramePrivate : public QTextObjectPrivate +{ + friend class QTextDocumentPrivate; + Q_DECLARE_PUBLIC(QTextFrame) +public: + QTextFramePrivate(QTextDocument *doc) + : QTextObjectPrivate(doc), fragment_start(0), fragment_end(0), parentFrame(nullptr), layoutData(nullptr) + { + } + virtual void fragmentAdded(QChar type, uint fragment); + virtual void fragmentRemoved(QChar type, uint fragment); + void remove_me(); + + uint fragment_start; + uint fragment_end; + + QTextFrame *parentFrame; + QList<QTextFrame *> childFrames; + QTextFrameLayoutData *layoutData; +}; + +QT_END_NAMESPACE + +#endif // QTEXTOBJECT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextodfwriter_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextodfwriter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c22285b3f29c87bc9ff51b2d7aa4f02f9994d5e7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextodfwriter_p.h @@ -0,0 +1,94 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTODFWRITER_H +#define QTEXTODFWRITER_H + +#include <QtGui/private/qtguiglobal_p.h> + +#ifndef QT_NO_TEXTODFWRITER + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qhash.h> +#include <QtCore/qlist.h> +#include <QtCore/qset.h> +#include <QtCore/qstack.h> +#include <QtCore/QXmlStreamWriter> + +#include "qtextdocument_p.h" +#include "qtextdocumentwriter.h" + +QT_BEGIN_NAMESPACE + +class QTextDocumentPrivate; +class QTextCursor; +class QTextBlock; +class QIODevice; +class QXmlStreamWriter; +class QTextOdfWriterPrivate; +class QTextBlockFormat; +class QTextCharFormat; +class QTextListFormat; +class QTextFrameFormat; +class QTextTableCellFormat; +class QTextFrame; +class QTextFragment; +class QOutputStrategy; + +class Q_AUTOTEST_EXPORT QTextOdfWriter { +public: + QTextOdfWriter(const QTextDocument &document, QIODevice *device); + bool writeAll(); + + void setCreateArchive(bool on) { m_createArchive = on; } + bool createArchive() const { return m_createArchive; } + + void writeBlock(QXmlStreamWriter &writer, const QTextBlock &block); + void writeFormats(QXmlStreamWriter &writer, const QSet<int> &formatIds) const; + void writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat format, int formatIndex) const; + void writeCharacterFormat(QXmlStreamWriter &writer, QTextCharFormat format, int formatIndex) const; + void writeListFormat(QXmlStreamWriter &writer, QTextListFormat format, int formatIndex) const; + void writeFrameFormat(QXmlStreamWriter &writer, QTextFrameFormat format, int formatIndex) const; + void writeTableFormat(QXmlStreamWriter &writer, QTextTableFormat format, int formatIndex) const; + void writeTableCellFormat(QXmlStreamWriter &writer, QTextTableCellFormat format, + int formatIndex, QList<QTextFormat> &styles) const; + void writeFrame(QXmlStreamWriter &writer, const QTextFrame *frame); + void writeInlineCharacter(QXmlStreamWriter &writer, const QTextFragment &fragment) const; + + const QString officeNS, textNS, styleNS, foNS, tableNS, drawNS, xlinkNS, svgNS; + const int defaultImageResolution = 11811; // 11811 dots per meter = (about) 300 dpi + +protected: + void tableCellStyleElement(QXmlStreamWriter &writer, const int &formatIndex, + const QTextTableCellFormat &format, + bool hasBorder, int tableId = 0, + const QTextTableFormat tableFormatTmp = QTextTableFormat()) const; + +private: + const QTextDocument *m_document; + QIODevice *m_device; + + QOutputStrategy *m_strategy; + bool m_createArchive; + + QStack<QTextList *> m_listStack; + + QHash<int, QList<int>> m_cellFormatsInTablesWithBorders; + QSet<int> m_tableFormatsWithBorders; + mutable QSet<int> m_tableFormatsWithColWidthConstraints; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_TEXTODFWRITER +#endif // QTEXTODFWRITER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexttable_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexttable_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9e333dd0c796ededad095b613e68dc324f5c423b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexttable_p.h @@ -0,0 +1,53 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTTABLE_P_H +#define QTEXTTABLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "private/qtextobject_p.h" +#include "private/qtextdocument_p.h" + +#include <vector> + +QT_BEGIN_NAMESPACE + +class QTextTablePrivate : public QTextFramePrivate +{ + Q_DECLARE_PUBLIC(QTextTable) +public: + QTextTablePrivate(QTextDocument *document) : QTextFramePrivate(document), nRows(0), nCols(0), dirty(true), blockFragmentUpdates(false) {} + + static QTextTable *createTable(QTextDocumentPrivate *, int pos, int rows, int cols, const QTextTableFormat &tableFormat); + void fragmentAdded(QChar type, uint fragment) override; + void fragmentRemoved(QChar type, uint fragment) override; + + void update() const; + + int findCellIndex(int fragment) const; + + QList<int> cells; + // symmetric to cells array and maps to indecs in grid, + // used for fast-lookup for row/column by fragment + mutable QList<int> cellIndices; + mutable std::vector<int> grid; + mutable int nRows; + mutable int nCols; + mutable bool dirty; + bool blockFragmentUpdates; +}; + +QT_END_NAMESPACE + +#endif // QTEXTTABLE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexturefiledata_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexturefiledata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f6962633286af49d190e74a7417f02b70e1a9001 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexturefiledata_p.h @@ -0,0 +1,92 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTUREFILEDATA_P_H +#define QTEXTUREFILEDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qtguiglobal.h> +#include <QSharedDataPointer> +#include <QLoggingCategory> +#include <QDebug> +#include <private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcQtGuiTextureIO) + +class QTextureFileDataPrivate; + +class Q_GUI_EXPORT QTextureFileData +{ +public: + enum Mode { ByteArrayMode, ImageMode }; + + QTextureFileData(Mode mode = ByteArrayMode); + QTextureFileData(const QTextureFileData &other); + QTextureFileData &operator=(const QTextureFileData &other); + ~QTextureFileData(); + + bool isNull() const; + bool isValid() const; + + void clear(); + + QByteArray data() const; + void setData(const QByteArray &data); + void setData(const QImage &image, int level = 0, int face = 0); + + int dataOffset(int level = 0, int face = 0) const; + void setDataOffset(int offset, int level = 0, int face = 0); + + int dataLength(int level = 0, int face = 0) const; + void setDataLength(int length, int level = 0, int face = 0); + + QByteArrayView getDataView(int level = 0, int face = 0) const; + + int numLevels() const; + void setNumLevels(int num); + + int numFaces() const; + void setNumFaces(int num); + + QSize size() const; + void setSize(const QSize &size); + + quint32 glFormat() const; + void setGLFormat(quint32 format); + + quint32 glInternalFormat() const; + void setGLInternalFormat(quint32 format); + + quint32 glBaseInternalFormat() const; + void setGLBaseInternalFormat(quint32 format); + + QByteArray logName() const; + void setLogName(const QByteArray &name); + + QMap<QByteArray, QByteArray> keyValueMetadata() const; + void setKeyValueMetadata(const QMap<QByteArray, QByteArray> &keyValues); + +private: + QSharedDataPointer<QTextureFileDataPrivate> d; + friend Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QTextureFileData &d); +}; + +Q_DECLARE_TYPEINFO(QTextureFileData, Q_RELOCATABLE_TYPE); + +Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QTextureFileData &d); + +QT_END_NAMESPACE + +#endif // QABSTRACTLAYOUTSTYLEINFO_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexturefilehandler_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexturefilehandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..29b0025cd50c4eec0185b31dabd7d9cbbe3658b7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexturefilehandler_p.h @@ -0,0 +1,43 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTUREFILEHANDLER_P_H +#define QTEXTUREFILEHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtexturefiledata_p.h" + +QT_BEGIN_NAMESPACE + +class QTextureFileHandler +{ +public: + QTextureFileHandler(QIODevice *device, const QByteArray &logName = QByteArray()) + : m_device(device) + { + m_logName = !logName.isEmpty() ? logName : QByteArrayLiteral("(unknown)"); + } + virtual ~QTextureFileHandler(); + + virtual QTextureFileData read() = 0; + QIODevice *device() const { return m_device; } + QByteArray logName() const { return m_logName; } + +private: + QIODevice *m_device = nullptr; + QByteArray m_logName; +}; + +QT_END_NAMESPACE + +#endif // QTEXTUREFILEHANDLER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexturefilereader_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexturefilereader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2ac6c0b391800a7366be6de5ccb1672f6601a976 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtexturefilereader_p.h @@ -0,0 +1,52 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTUREFILEREADER_H +#define QTEXTUREFILEREADER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtexturefiledata_p.h" +#include <QString> +#include <QFileInfo> + +QT_BEGIN_NAMESPACE + +class QIODevice; +class QTextureFileHandler; + +class Q_GUI_EXPORT QTextureFileReader +{ +public: + QTextureFileReader(QIODevice *device, const QString &fileName = QString()); //### drop this logname thing? + ~QTextureFileReader(); + + bool canRead(); + QTextureFileData read(); + + // TBD access function to params + // TBD ask for identified fmt + + static QList<QByteArray> supportedFileFormats(); + +private: + bool init(); + QIODevice *m_device = nullptr; + QString m_fileName; + QTextureFileHandler *m_handler = nullptr; + bool checked = false; +}; + +QT_END_NAMESPACE + + +#endif // QTEXTUREFILEREADER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextureglyphcache_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextureglyphcache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..350a642379ae5fc3b0384e274838d8307c32e905 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtextureglyphcache_p.h @@ -0,0 +1,160 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTUREGLYPHCACHE_P_H +#define QTEXTUREGLYPHCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <qhash.h> +#include <qimage.h> +#include <qobject.h> +#include <qtransform.h> + +#include <private/qfontengineglyphcache_p.h> + +#ifndef QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH +#define QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH 256 +#endif + +struct glyph_metrics_t; +typedef unsigned int glyph_t; + + +QT_BEGIN_NAMESPACE + +class QTextItemInt; + +class Q_GUI_EXPORT QTextureGlyphCache : public QFontEngineGlyphCache +{ +public: + QTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix, const QColor &color = QColor()) + : QFontEngineGlyphCache(format, matrix, color), m_current_fontengine(nullptr), + m_w(0), m_h(0), m_cx(0), m_cy(0), m_currentRowHeight(0) + { } + + ~QTextureGlyphCache(); + + struct GlyphAndSubPixelPosition + { + GlyphAndSubPixelPosition(glyph_t g, const QFixedPoint &spp) + : glyph(g), subPixelPosition(spp) {} + + bool operator==(const GlyphAndSubPixelPosition &other) const + { + return glyph == other.glyph && subPixelPosition == other.subPixelPosition; + } + + glyph_t glyph; + QFixedPoint subPixelPosition; + }; + + struct Coord { + int x; + int y; + int w; + int h; + + int baseLineX; + int baseLineY; + + bool isNull() const + { + return w == 0 || h == 0; + } + }; + + bool populate(QFontEngine *fontEngine, + qsizetype numGlyphs, + const glyph_t *glyphs, + const QFixedPoint *positions, + QPainter::RenderHints renderHints = QPainter::RenderHints(), + bool includeGlyphCacheScale = false); + bool hasPendingGlyphs() const { return !m_pendingGlyphs.isEmpty(); } + void fillInPendingGlyphs(); + + virtual void createTextureData(int width, int height) = 0; + virtual void resizeTextureData(int width, int height) = 0; + virtual int glyphPadding() const { return 0; } + + virtual void beginFillTexture() { } + virtual void fillTexture(const Coord &coord, + glyph_t glyph, + const QFixedPoint &subPixelPosition) = 0; + virtual void endFillTexture() { } + + inline void createCache(int width, int height) { + m_w = width; + m_h = height; + createTextureData(width, height); + } + + inline void resizeCache(int width, int height) + { + resizeTextureData(width, height); + m_w = width; + m_h = height; + } + + inline bool isNull() const { return m_h == 0; } + + QHash<GlyphAndSubPixelPosition, Coord> coords; + virtual int maxTextureWidth() const { return QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH; } + virtual int maxTextureHeight() const { return -1; } + + QImage textureMapForGlyph(glyph_t g, const QFixedPoint &subPixelPosition) const; + +protected: + int calculateSubPixelPositionCount(glyph_t) const; + + QFontEngine *m_current_fontengine; + QHash<GlyphAndSubPixelPosition, Coord> m_pendingGlyphs; + + int m_w; // image width + int m_h; // image height + int m_cx; // current x + int m_cy; // current y + int m_currentRowHeight; // Height of last row +}; + +inline size_t qHash(const QTextureGlyphCache::GlyphAndSubPixelPosition &g, size_t seed = 0) +{ + return qHashMulti(seed, + g.glyph, + g.subPixelPosition.x.value(), + g.subPixelPosition.y.value()); +} + + +class Q_GUI_EXPORT QImageTextureGlyphCache : public QTextureGlyphCache +{ +public: + QImageTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix, const QColor &color = QColor()) + : QTextureGlyphCache(format, matrix, color) { } + ~QImageTextureGlyphCache(); + + virtual void createTextureData(int width, int height) override; + virtual void resizeTextureData(int width, int height) override; + virtual void fillTexture(const Coord &c, + glyph_t glyph, + const QFixedPoint &subPixelPosition) override; + + inline const QImage &image() const { return m_image; } + +private: + QImage m_image; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtgui-config_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtgui-config_p.h new file mode 100644 index 0000000000000000000000000000000000000000..100fb06dd6d8e30be011da33460805dc256dde7e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtgui-config_p.h @@ -0,0 +1,122 @@ +#define QT_FEATURE_accessibility_atspi_bridge -1 + +#define QT_FEATURE_directfb -1 + +#define QT_FEATURE_directwrite 1 + +#define QT_FEATURE_directwrite3 1 + +#define QT_FEATURE_direct2d 1 + +#define QT_FEATURE_direct2d1_1 1 + +#define QT_FEATURE_evdev -1 + +#define QT_FEATURE_freetype 1 + +#define QT_FEATURE_system_freetype -1 + +#define QT_FEATURE_fontconfig -1 + +#define QT_FEATURE_harfbuzz 1 + +#define QT_FEATURE_system_harfbuzz -1 + +#define QT_FEATURE_qqnx_imf -1 + +#define QT_FEATURE_integrityfb -1 + +#define QT_FEATURE_kms -1 + +#define QT_FEATURE_drm_atomic -1 + +#define QT_FEATURE_libinput -1 + +#define QT_FEATURE_integrityhid -1 + +#define QT_FEATURE_libinput_axis_api -1 + +#define QT_FEATURE_libinput_hires_wheel_support -1 + +#define QT_FEATURE_linuxfb -1 + +#define QT_FEATURE_vsp2 -1 + +#define QT_FEATURE_vnc -1 + +#define QT_FEATURE_mtdev -1 + +#define QT_FEATURE_vkgen 1 + +#define QT_FEATURE_vkkhrdisplay -1 + +#define QT_FEATURE_egl_x11 -1 + +#define QT_FEATURE_eglfs -1 + +#define QT_FEATURE_eglfs_brcm -1 + +#define QT_FEATURE_eglfs_egldevice -1 + +#define QT_FEATURE_eglfs_gbm -1 + +#define QT_FEATURE_eglfs_vsp2 -1 + +#define QT_FEATURE_eglfs_mali -1 + +#define QT_FEATURE_eglfs_viv -1 + +#define QT_FEATURE_eglfs_rcar -1 + +#define QT_FEATURE_eglfs_viv_wl -1 + +#define QT_FEATURE_eglfs_openwfd -1 + +#define QT_FEATURE_eglfs_x11 -1 + +#define QT_FEATURE_gif 1 + +#define QT_FEATURE_ico 1 + +#define QT_FEATURE_jpeg 1 + +#define QT_FEATURE_system_jpeg -1 + +#define QT_FEATURE_png 1 + +#define QT_FEATURE_system_png -1 + +#define QT_FEATURE_imageio_text_loading 1 + +#define QT_FEATURE_tslib -1 + +#define QT_FEATURE_tuiotouch 1 + +#define QT_FEATURE_xcb_glx -1 + +#define QT_FEATURE_xcb_egl_plugin -1 + +#define QT_FEATURE_xcb_native_painting -1 + +#define QT_FEATURE_xrender -1 + +#define QT_FEATURE_xcb_xlib -1 + +#define QT_FEATURE_xcb_sm -1 + +#define QT_FEATURE_system_xcb_xinput -1 + +#define QT_FEATURE_xkbcommon -1 + +#define QT_FEATURE_xkbcommon_x11 -1 + +#define QT_FEATURE_xlib -1 + +#define QT_FEATURE_multiprocess 1 + +#define QT_FEATURE_raster_64bit 1 + +#define QT_FEATURE_raster_fp 1 + +#define QT_FEATURE_graphicsframecapture -1 + diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtguiglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtguiglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..91eaf261be56f0b514964e773840541bff89bb25 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtguiglobal_p.h @@ -0,0 +1,22 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTGUIGLOBAL_P_H +#define QTGUIGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/private/qglobal_p.h> +#include <QtGui/private/qtgui-config_p.h> + +#endif // QTGUIGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtriangulatingstroker_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtriangulatingstroker_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bc454bcc78df7bfb1636d583c40502bebf039a44 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtriangulatingstroker_p.h @@ -0,0 +1,127 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTRIANGULATINGSTROKER_P_H +#define QTRIANGULATINGSTROKER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qmath.h> +#include <QtGui/private/qtguiglobal_p.h> +#include <private/qdatabuffer_p.h> +#include <qvarlengtharray.h> +#include <private/qvectorpath_p.h> +#include <private/qbezier_p.h> +#include <private/qnumeric_p.h> +#include <private/qmath_p.h> + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QTriangulatingStroker +{ +public: + QTriangulatingStroker() : m_vertices(0), m_cx(0), m_cy(0), m_nvx(0), m_nvy(0), m_width(1), m_miter_limit(2), + m_roundness(0), m_sin_theta(0), m_cos_theta(0), m_inv_scale(1), m_curvyness_mul(1), m_curvyness_add(0), + m_join_style(Qt::BevelJoin), m_cap_style(Qt::SquareCap) {} + + void process(const QVectorPath &path, const QPen &pen, const QRectF &clip, QPainter::RenderHints hints); + + inline int vertexCount() const { return m_vertices.size(); } + inline const float *vertices() const { return m_vertices.data(); } + + inline void setInvScale(qreal invScale) { m_inv_scale = invScale; } + +private: + inline void emitLineSegment(float x, float y, float nx, float ny); + void moveTo(const qreal *pts); + inline void lineTo(const qreal *pts); + void cubicTo(const qreal *pts); + void join(const qreal *pts); + inline void normalVector(float x1, float y1, float x2, float y2, float *nx, float *ny); + void endCap(const qreal *pts); + void arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray<float> &points); + void endCapOrJoinClosed(const qreal *start, const qreal *cur, bool implicitClose, bool endsAtStart); + + + QDataBuffer<float> m_vertices; + + float m_cx, m_cy; // current points + float m_nvx, m_nvy; // normal vector... + float m_width; + qreal m_miter_limit; + + int m_roundness; // Number of line segments in a round join + qreal m_sin_theta; // sin(m_roundness / 360); + qreal m_cos_theta; // cos(m_roundness / 360); + qreal m_inv_scale; + float m_curvyness_mul; + float m_curvyness_add; + + Qt::PenJoinStyle m_join_style; + Qt::PenCapStyle m_cap_style; +}; + +class Q_GUI_EXPORT QDashedStrokeProcessor +{ +public: + QDashedStrokeProcessor(); + + void process(const QVectorPath &path, const QPen &pen, const QRectF &clip, QPainter::RenderHints hints); + + inline void addElement(QPainterPath::ElementType type, qreal x, qreal y) { + m_points.add(x); + m_points.add(y); + m_types.add(type); + } + + inline int elementCount() const { return m_types.size(); } + inline qreal *points() const { return m_points.data(); } + inline QPainterPath::ElementType *elementTypes() const { return m_types.data(); } + + inline void setInvScale(qreal invScale) { m_inv_scale = invScale; } + +private: + QDataBuffer<qreal> m_points; + QDataBuffer<QPainterPath::ElementType> m_types; + QDashStroker m_dash_stroker; + qreal m_inv_scale; +}; + +inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, float y2, + float *nx, float *ny) +{ + const float dx = x2 - x1; + const float dy = y2 - y1; + const float pw = m_width / qHypot(dx, dy); + + *nx = -dy * pw; + *ny = dx * pw; +} + +inline void QTriangulatingStroker::emitLineSegment(float x, float y, float vx, float vy) +{ + m_vertices.add(x + vx); + m_vertices.add(y + vy); + m_vertices.add(x - vx); + m_vertices.add(y - vy); +} + +void QTriangulatingStroker::lineTo(const qreal *pts) +{ + emitLineSegment(pts[0], pts[1], m_nvx, m_nvy); + m_cx = pts[0]; + m_cy = pts[1]; +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtriangulator_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtriangulator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..52c05ecde567c32909b6413b5839e928f4dab904 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qtriangulator_p.h @@ -0,0 +1,100 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTRIANGULATOR_P_H +#define QTRIANGULATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtGui/private/qvectorpath_p.h> +#include <QtCore/qlist.h> + +QT_BEGIN_NAMESPACE + +class QVertexIndexVector +{ +public: + enum Type { + UnsignedInt, + UnsignedShort + }; + + inline Type type() const { return t; } + + inline void setDataUint(const QList<quint32> &data) + { + t = UnsignedInt; + indices32 = data; + } + + inline void setDataUshort(const QList<quint16> &data) + { + t = UnsignedShort; + indices16 = data; + } + + inline const void* data() const + { + if (t == UnsignedInt) + return indices32.data(); + return indices16.data(); + } + + inline int size() const + { + if (t == UnsignedInt) + return indices32.size(); + return indices16.size(); + } + +private: + + Type t; + QList<quint32> indices32; + QList<quint16> indices16; +}; + +struct QTriangleSet +{ + // The vertices of a triangle are given by: (x[i[n]], y[i[n]]), (x[j[n]], y[j[n]]), (x[k[n]], y[k[n]]), n = 0, 1, ... + QList<qreal> vertices; // [x[0], y[0], x[1], y[1], x[2], ...] + QVertexIndexVector indices; // [i[0], j[0], k[0], i[1], j[1], k[1], i[2], ...] +}; + +struct QPolylineSet +{ + QList<qreal> vertices; // [x[0], y[0], x[1], y[1], x[2], ...] + QVertexIndexVector indices; // End of polyline is marked with -1. +}; + +// The vertex coordinates of the returned triangle set will be rounded to a grid with a mesh size +// of 1/32. The polygon is first transformed, then scaled by 32, the coordinates are rounded to +// integers, the polygon is triangulated, and then scaled back by 1/32. +// 'hint' should be a combination of QVectorPath::Hints. +// 'lod' is the level of detail. Default is 1. Curves are split into more lines when 'lod' is higher. +QTriangleSet Q_GUI_EXPORT qTriangulate(const qreal *polygon, int count, + uint hint = QVectorPath::PolygonHint | QVectorPath::OddEvenFill, + const QTransform &matrix = QTransform(), + bool allowUintIndices = true); +QTriangleSet Q_GUI_EXPORT qTriangulate(const QVectorPath &path, const QTransform &matrix = QTransform(), + qreal lod = 1, bool allowUintIndices = true); +QTriangleSet Q_GUI_EXPORT qTriangulate(const QPainterPath &path, const QTransform &matrix = QTransform(), + qreal lod = 1, bool allowUintIndices = true); +QPolylineSet qPolyline(const QVectorPath &path, const QTransform &matrix = QTransform(), + qreal lod = 1, bool allowUintIndices = true); +QPolylineSet Q_GUI_EXPORT qPolyline(const QPainterPath &path, const QTransform &matrix = QTransform(), + qreal lod = 1, bool allowUintIndices = true); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qundostack_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qundostack_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b9f9912878eb2daa2223b0c8f5909fbc320ccf56 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qundostack_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QUNDOSTACK_P_H +#define QUNDOSTACK_P_H + +#include <QtGui/private/qtguiglobal_p.h> +#include <private/qobject_p.h> +#include <QtCore/qlist.h> +#include <QtCore/qstring.h> +#if QT_CONFIG(action) +# include <QtGui/qaction.h> +#endif + +#include "qundostack.h" + +QT_BEGIN_NAMESPACE +class QUndoCommand; +class QUndoGroup; + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +class QUndoCommandPrivate +{ +public: + QUndoCommandPrivate() : id(-1), obsolete(false) {} + QList<QUndoCommand*> child_list; + QString text; + QString actionText; + int id; + bool obsolete; +}; + +#if QT_CONFIG(undostack) + +class QUndoStackPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QUndoStack) +public: + QUndoStackPrivate() : index(0), clean_index(0), group(nullptr), undo_limit(0) {} + + QList<QUndoCommand*> command_list; + QList<QUndoCommand*> macro_stack; + int index; + int clean_index; + QUndoGroup *group; + int undo_limit; + + void setIndex(int idx, bool clean); + bool checkUndoLimit(); + +#ifndef QT_NO_ACTION + static void setPrefixedText(QAction *action, const QString &prefix, const QString &defaultText, const QString &text); +#endif +}; + +QT_END_NAMESPACE +#endif // QT_CONFIG(undostack) +#endif // QUNDOSTACK_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvectorpath_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvectorpath_p.h new file mode 100644 index 0000000000000000000000000000000000000000..47874c522c7d4e9020b0ecfc879db5c53c46b3ab --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvectorpath_p.h @@ -0,0 +1,179 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QVECTORPATH_P_H +#define QVECTORPATH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtGui/qpaintengine.h> + +#include <private/qpaintengine_p.h> +#include <private/qstroker_p.h> +#include <private/qpainter_p.h> + + +QT_BEGIN_NAMESPACE + + +class QPaintEngineEx; + +typedef void (*qvectorpath_cache_cleanup)(QPaintEngineEx *engine, void *data); + +struct QRealRect { + qreal x1, y1, x2, y2; +}; + +class Q_GUI_EXPORT QVectorPath +{ +public: + enum Hint { + // Shape hints, in 0x000000ff, access using shape() + AreaShapeMask = 0x0001, // shape covers an area + NonConvexShapeMask = 0x0002, // shape is not convex + CurvedShapeMask = 0x0004, // shape contains curves... + LinesShapeMask = 0x0008, + RectangleShapeMask = 0x0010, + ShapeMask = 0x001f, + + // Shape hints merged into basic shapes.. + LinesHint = LinesShapeMask, + RectangleHint = AreaShapeMask | RectangleShapeMask, + EllipseHint = AreaShapeMask | CurvedShapeMask, + ConvexPolygonHint = AreaShapeMask, + PolygonHint = AreaShapeMask | NonConvexShapeMask, + RoundedRectHint = AreaShapeMask | CurvedShapeMask, + ArbitraryShapeHint = AreaShapeMask | NonConvexShapeMask | CurvedShapeMask, + + // Other hints + IsCachedHint = 0x0100, // Set if the cache hint is set + ShouldUseCacheHint = 0x0200, // Set if the path should be cached when possible.. + ControlPointRect = 0x0400, // Set if the control point rect has been calculated... + + // Shape rendering specifiers... + OddEvenFill = 0x1000, + WindingFill = 0x2000, + ImplicitClose = 0x4000, + ExplicitOpen = 0x8000 + }; + + // ### Falcon: introduca a struct XY for points so lars is not so confused... + QVectorPath(const qreal *points, + int count, + const QPainterPath::ElementType *elements = nullptr, + uint hints = ArbitraryShapeHint) + : m_elements(elements), + m_points(points), + m_count(count), + m_hints(hints) + { + } + + ~QVectorPath(); + + QRectF controlPointRect() const; + + inline Hint shape() const { return (Hint) (m_hints & ShapeMask); } + inline bool isConvex() const { return (m_hints & NonConvexShapeMask) == 0; } + inline bool isCurved() const { return m_hints & CurvedShapeMask; } + + inline bool isCacheable() const { return m_hints & ShouldUseCacheHint; } + inline bool hasImplicitClose() const { return m_hints & ImplicitClose; } + inline bool hasExplicitOpen() const { return m_hints & ExplicitOpen; } + inline bool hasWindingFill() const { return m_hints & WindingFill; } + + inline void makeCacheable() const { m_hints |= ShouldUseCacheHint; m_cache = nullptr; } + inline uint hints() const { return m_hints; } + + inline const QPainterPath::ElementType *elements() const { return m_elements; } + inline const qreal *points() const { return m_points; } + inline bool isEmpty() const { return m_points == nullptr; } + + inline int elementCount() const { return m_count; } + inline const QPainterPath convertToPainterPath() const; + + static inline uint polygonFlags(QPaintEngine::PolygonDrawMode mode) + { + switch (mode) { + case QPaintEngine::ConvexMode: return ConvexPolygonHint | ImplicitClose; + case QPaintEngine::OddEvenMode: return PolygonHint | OddEvenFill | ImplicitClose; + case QPaintEngine::WindingMode: return PolygonHint | WindingFill | ImplicitClose; + case QPaintEngine::PolylineMode: return PolygonHint | ExplicitOpen; + default: return 0; + } + } + + struct CacheEntry { + QPaintEngineEx *engine; + void *data; + qvectorpath_cache_cleanup cleanup; + CacheEntry *next; + }; + + CacheEntry *addCacheData(QPaintEngineEx *engine, void *data, qvectorpath_cache_cleanup cleanup) const; + inline CacheEntry *lookupCacheData(QPaintEngineEx *engine) const { + Q_ASSERT(m_hints & ShouldUseCacheHint); + CacheEntry *e = m_cache; + while (e) { + if (e->engine == engine) + return e; + e = e->next; + } + return nullptr; + } + + template <typename T> static inline bool isRect(const T *pts, int elementCount) { + return (elementCount == 5 // 5-point polygon, check for closed rect + && pts[0] == pts[8] && pts[1] == pts[9] // last point == first point + && pts[0] == pts[6] && pts[2] == pts[4] // x values equal + && pts[1] == pts[3] && pts[5] == pts[7] // y values equal... + && pts[0] < pts[4] && pts[1] < pts[5] + ) || + (elementCount == 4 // 4-point polygon, check for unclosed rect + && pts[0] == pts[6] && pts[2] == pts[4] // x values equal + && pts[1] == pts[3] && pts[5] == pts[7] // y values equal... + && pts[0] < pts[4] && pts[1] < pts[5] + ); + } + + inline bool isRect() const + { + const QPainterPath::ElementType * const types = elements(); + + return (shape() == QVectorPath::RectangleHint) + || (isRect(points(), elementCount()) + && (!types || (types[0] == QPainterPath::MoveToElement + && types[1] == QPainterPath::LineToElement + && types[2] == QPainterPath::LineToElement + && types[3] == QPainterPath::LineToElement))); + } + + +private: + Q_DISABLE_COPY_MOVE(QVectorPath) + + const QPainterPath::ElementType *m_elements; + const qreal *m_points; + const int m_count; + + mutable uint m_hints; + mutable QRealRect m_cp_rect; + + mutable CacheEntry *m_cache; +}; + +Q_GUI_EXPORT const QVectorPath &qtVectorPathForPath(const QPainterPath &path); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkandefaultinstance_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkandefaultinstance_p.h new file mode 100644 index 0000000000000000000000000000000000000000..700206a697a494a3eb52e8ffa4688f8d5592c48c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkandefaultinstance_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QVULKANDEFAULTINSTANCE_P_H +#define QVULKANDEFAULTINSTANCE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> + +#if QT_CONFIG(vulkan) + +#include <QtGui/qvulkaninstance.h> + +QT_BEGIN_NAMESPACE + +struct Q_GUI_EXPORT QVulkanDefaultInstance +{ + enum Flag { + EnableValidation = 0x01 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + static Flags flags(); + static void setFlag(Flag flag, bool on = true); + static bool hasInstance(); + static QVulkanInstance *instance(); + static void cleanup(); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QVulkanDefaultInstance::Flags) + +QT_END_NAMESPACE + +#endif // QT_CONFIG(vulkan) + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkanfunctions_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkanfunctions_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a8ba199a3ff63d39faf6c6c6e831336080242d32 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkanfunctions_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// This file is automatically generated by qvkgen. Do not edit. + +#ifndef QVULKANFUNCTIONS_P_H +#define QVULKANFUNCTIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qvulkanfunctions.h" + +QT_BEGIN_NAMESPACE + +class QVulkanInstance; + +class QVulkanFunctionsPrivate +{ +public: + QVulkanFunctionsPrivate(QVulkanInstance *inst); + + PFN_vkVoidFunction m_funcs[26]; +}; + +class QVulkanDeviceFunctionsPrivate +{ +public: + QVulkanDeviceFunctionsPrivate(QVulkanInstance *inst, VkDevice device); + + PFN_vkVoidFunction m_funcs[185]; +}; + +QT_END_NAMESPACE + +#endif // QVULKANFUNCTIONS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkaninstance_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkaninstance_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0bbc7edbec8562adce2643bb712064a689fb5b07 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkaninstance_p.h @@ -0,0 +1,60 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QVULKANINSTANCE_P_H +#define QVULKANINSTANCE_P_H + +#include <QtGui/private/qtguiglobal_p.h> + +#if QT_CONFIG(vulkan) || defined(Q_QDOC) + +#include "qvulkaninstance.h" +#include <private/qvulkanfunctions_p.h> +#include <QtCore/QHash> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QVulkanInstancePrivate +{ +public: + QVulkanInstancePrivate(QVulkanInstance *q) + : q_ptr(q), + vkInst(VK_NULL_HANDLE), + errorCode(VK_SUCCESS) + { } + ~QVulkanInstancePrivate() { reset(); } + static QVulkanInstancePrivate *get(QVulkanInstance *q) { return q->d_ptr.data(); } + + bool ensureVulkan(); + void reset(); + + QVulkanInstance *q_ptr; + QScopedPointer<QPlatformVulkanInstance> platformInst; + VkInstance vkInst; + QVulkanInstance::Flags flags; + QByteArrayList layers; + QByteArrayList extensions; + QVersionNumber apiVersion; + VkResult errorCode; + QScopedPointer<QVulkanFunctions> funcs; + QHash<VkDevice, QVulkanDeviceFunctions *> deviceFuncs; + QList<QVulkanInstance::DebugFilter> debugFilters; // legacy filters based on VK_EXT_debug_report + QList<QVulkanInstance::DebugUtilsFilter> debugUtilsFilters; // the modern version based on VK_EXT_debug_utils +}; + +QT_END_NAMESPACE + +#endif // QT_CONFIG(vulkan) + +#endif // QVULKANINSTANCE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkanwindow_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkanwindow_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ee9fe6313cb020f4814d9f9a43d79ae60cfc17fa --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qvulkanwindow_p.h @@ -0,0 +1,156 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QVULKANWINDOW_P_H +#define QVULKANWINDOW_P_H + +#include <QtGui/private/qtguiglobal_p.h> + +#if QT_CONFIG(vulkan) || defined(Q_QDOC) + +#include "qvulkanwindow.h" +#include <QtCore/QHash> +#include <private/qwindow_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QVulkanWindowPrivate : public QWindowPrivate +{ + Q_DECLARE_PUBLIC(QVulkanWindow) + +public: + ~QVulkanWindowPrivate(); + + void ensureStarted(); + void init(); + void reset(); + bool createDefaultRenderPass(); + QSize surfacePixelSize() const; + void recreateSwapChain(); + uint32_t chooseTransientImageMemType(VkImage img, uint32_t startIndex); + bool createTransientImage(VkFormat format, VkImageUsageFlags usage, VkImageAspectFlags aspectMask, + VkImage *images, VkDeviceMemory *mem, VkImageView *views, int count); + void releaseSwapChain(); + void beginFrame(); + void endFrame(); + bool checkDeviceLost(VkResult err); + void addReadback(); + void finishBlockingReadback(); + + enum Status { + StatusUninitialized, + StatusFail, + StatusFailRetry, + StatusDeviceReady, + StatusReady + }; + Status status = StatusUninitialized; + QVulkanWindowRenderer *renderer = nullptr; + QVulkanInstance *inst = nullptr; + VkSurfaceKHR surface = VK_NULL_HANDLE; + int physDevIndex = 0; + QList<VkPhysicalDevice> physDevs; + QList<VkPhysicalDeviceProperties> physDevProps; + QVulkanWindow::Flags flags; + QByteArrayList requestedDevExtensions; + QHash<VkPhysicalDevice, QVulkanInfoVector<QVulkanExtension> > supportedDevExtensions; + QList<VkFormat> requestedColorFormats; + VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_1_BIT; + QVulkanWindow::QueueCreateInfoModifier queueCreateInfoModifier; + QVulkanWindow::EnabledFeaturesModifier enabledFeaturesModifier; + QVulkanWindow::EnabledFeatures2Modifier enabledFeatures2Modifier; + + VkDevice dev = VK_NULL_HANDLE; + QVulkanDeviceFunctions *devFuncs; + uint32_t gfxQueueFamilyIdx; + uint32_t presQueueFamilyIdx; + VkQueue gfxQueue; + VkQueue presQueue; + VkCommandPool cmdPool = VK_NULL_HANDLE; + VkCommandPool presCmdPool = VK_NULL_HANDLE; + uint32_t hostVisibleMemIndex; + uint32_t deviceLocalMemIndex; + VkFormat colorFormat; + VkColorSpaceKHR colorSpace; + VkFormat dsFormat = VK_FORMAT_D24_UNORM_S8_UINT; + + PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR = nullptr; + PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR; + PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR; + PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR; + PFN_vkQueuePresentKHR vkQueuePresentKHR; + PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR = nullptr; + PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR; + + static const int MAX_SWAPCHAIN_BUFFER_COUNT = 4; + static const int MAX_FRAME_LAG = QVulkanWindow::MAX_CONCURRENT_FRAME_COUNT; + // QVulkanWindow only supports the always available FIFO mode. The + // rendering thread will get throttled to the presentation rate (vsync). + // This is in effect Example 5 from the VK_KHR_swapchain spec. + VkPresentModeKHR presentMode = VK_PRESENT_MODE_FIFO_KHR; + int swapChainBufferCount = 0; + int frameLag = 2; + + QSize swapChainImageSize; + VkSwapchainKHR swapChain = VK_NULL_HANDLE; + bool swapChainSupportsReadBack = false; + + struct ImageResources { + VkImage image = VK_NULL_HANDLE; + VkImageView imageView = VK_NULL_HANDLE; + VkCommandBuffer cmdBuf = VK_NULL_HANDLE; + VkFence cmdFence = VK_NULL_HANDLE; + bool cmdFenceWaitable = false; + VkFramebuffer fb = VK_NULL_HANDLE; + VkCommandBuffer presTransCmdBuf = VK_NULL_HANDLE; + VkImage msaaImage = VK_NULL_HANDLE; + VkImageView msaaImageView = VK_NULL_HANDLE; + } imageRes[MAX_SWAPCHAIN_BUFFER_COUNT]; + + VkDeviceMemory msaaImageMem = VK_NULL_HANDLE; + + uint32_t currentImage; + + struct FrameResources { + VkFence fence = VK_NULL_HANDLE; + bool fenceWaitable = false; + VkSemaphore imageSem = VK_NULL_HANDLE; + VkSemaphore drawSem = VK_NULL_HANDLE; + VkSemaphore presTransSem = VK_NULL_HANDLE; + bool imageAcquired = false; + bool imageSemWaitable = false; + } frameRes[MAX_FRAME_LAG]; + + uint32_t currentFrame; + + VkRenderPass defaultRenderPass = VK_NULL_HANDLE; + + VkDeviceMemory dsMem = VK_NULL_HANDLE; + VkImage dsImage = VK_NULL_HANDLE; + VkImageView dsView = VK_NULL_HANDLE; + + bool framePending = false; + bool frameGrabbing = false; + QImage frameGrabTargetImage; + VkImage frameGrabImage = VK_NULL_HANDLE; + VkDeviceMemory frameGrabImageMem = VK_NULL_HANDLE; + + QMatrix4x4 m_clipCorrect; +}; + +QT_END_NAMESPACE + +#endif // QT_CONFIG(vulkan) + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindow_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindow_p.h new file mode 100644 index 0000000000000000000000000000000000000000..21de702086a851c624fd3d26a3ede0bd98336cf9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindow_p.h @@ -0,0 +1,170 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOW_P_H +#define QWINDOW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtGui/qscreen.h> +#include <QtGui/qwindow.h> +#include <qpa/qplatformwindow.h> + +#include <QtCore/private/qobject_p.h> +#include <QtCore/qelapsedtimer.h> +#include <QtCore/qxpfunctional.h> +#include <QtGui/qicon.h> +#include <QtGui/qpalette.h> + +#include <QtCore/qpointer.h> + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QWindowPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QWindow) + +public: + enum PositionPolicy + { + WindowFrameInclusive, + WindowFrameExclusive + }; + + QWindowPrivate(); + ~QWindowPrivate() override; + + void init(QWindow *parent, QScreen *targetScreen = nullptr); + +#ifndef QT_NO_CURSOR + void setCursor(const QCursor *c = nullptr); + bool applyCursor(); +#endif + + QPoint globalPosition() const; + + QWindow *topLevelWindow(QWindow::AncestorMode mode = QWindow::IncludeTransients) const; + + virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; } + virtual QPalette windowPalette() const { return QPalette(); } + + virtual void setVisible(bool visible); + void updateVisibility(); + void _q_clearAlert(); + + enum SiblingPosition { PositionTop, PositionBottom }; + void updateSiblingPosition(SiblingPosition); + + bool windowRecreationRequired(QScreen *newScreen) const; + void create(bool recursive); + void destroy(); + void setTopLevelScreen(QScreen *newScreen, bool recreate); + void connectToScreen(QScreen *topLevelScreen); + void disconnectFromScreen(); + void emitScreenChangedRecursion(QScreen *newScreen); + QScreen *screenForGeometry(const QRect &rect) const; + void setTransientParent(QWindow *parent); + + virtual void clearFocusObject(); + + enum class FocusTarget { + First, + Last, + Current, + Next, + Prev + }; + virtual void setFocusToTarget(FocusTarget, Qt::FocusReason) {} + + virtual QRectF closestAcceptableGeometry(const QRectF &rect) const; + + void setMinOrMaxSize(QSize *oldSizeMember, const QSize &size, + qxp::function_ref<void()> funcWidthChanged, + qxp::function_ref<void()> funcHeightChanged); + + virtual void processSafeAreaMarginsChanged() {} + + virtual bool participatesInLastWindowClosed() const; + virtual bool treatAsVisible() const; + + const QWindow *forwardToPopup(QEvent *event, const QWindow *activePopupOnPress); + + bool isPopup() const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; } + void setAutomaticPositionAndResizeEnabled(bool a) + { positionAutomatic = resizeAutomatic = a; } + + bool updateDevicePixelRatio(); + + static QWindowPrivate *get(QWindow *window) { return window->d_func(); } + + static Qt::WindowState effectiveState(Qt::WindowStates); + + QWindow::SurfaceType surfaceType = QWindow::RasterSurface; + Qt::WindowFlags windowFlags = Qt::Window; + QWindow *parentWindow = nullptr; + QPlatformWindow *platformWindow = nullptr; + bool visible= false; + bool visibilityOnDestroy = false; + bool exposed = false; + bool inClose = false; + QSurfaceFormat requestedFormat; + QString windowTitle; + QString windowFilePath; + QIcon windowIcon; + QRect geometry; + qreal devicePixelRatio = 1.0; + Qt::WindowStates windowState = Qt::WindowNoState; + QWindow::Visibility visibility = QWindow::Hidden; + bool resizeEventPending = true; + bool receivedExpose = false; + PositionPolicy positionPolicy = WindowFrameExclusive; + bool positionAutomatic = true; + // resizeAutomatic suppresses resizing by QPlatformWindow::initialGeometry(). + // It also indicates that width/height=0 is acceptable (for example, for + // the QRollEffect widget) and is thus not cleared in setGeometry(). + // An alternative approach might be using -1,-1 as a default size. + bool resizeAutomatic = true; + Qt::ScreenOrientation contentOrientation = Qt::PrimaryOrientation; + qreal opacity= 1; + QRegion mask; + + QSize minimumSize = {0, 0}; + QSize maximumSize = {QWINDOWSIZE_MAX, QWINDOWSIZE_MAX}; + QSize baseSize; + QSize sizeIncrement; + + Qt::WindowModality modality = Qt::NonModal; + bool blockedByModalWindow = false; + + bool updateRequestPending = false; + bool transientParentPropertySet = false; + + QPointer<QWindow> transientParent; + QPointer<QScreen> topLevelScreen; + +#ifndef QT_NO_CURSOR + QCursor cursor = {Qt::ArrowCursor}; + bool hasCursor = false; +#endif + + QElapsedTimer lastComposeTime; + +#if QT_CONFIG(vulkan) + QVulkanInstance *vulkanInstance = nullptr; +#endif +}; + + +QT_END_NAMESPACE + +#endif // QWINDOW_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsdirectwritefontdatabase_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsdirectwritefontdatabase_p.h new file mode 100644 index 0000000000000000000000000000000000000000..16466010cac4589f2c05e83ba9b5b80855c60977 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsdirectwritefontdatabase_p.h @@ -0,0 +1,77 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOWSDIRECTWRITEFONTDATABASE_P_H +#define QWINDOWSDIRECTWRITEFONTDATABASE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qtguiglobal.h> +#include <QtGui/private/qtgui-config_p.h> + +QT_REQUIRE_CONFIG(directwrite3); + +#include "qwindowsfontdatabase_p.h" +#include <QtCore/qloggingcategory.h> + +struct IDWriteFactory; +struct IDWriteFont; +struct IDWriteFont1; +struct IDWriteFontFamily; +struct IDWriteLocalizedStrings; + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QWindowsDirectWriteFontDatabase : public QWindowsFontDatabase +{ + Q_DISABLE_COPY_MOVE(QWindowsDirectWriteFontDatabase) +public: + QWindowsDirectWriteFontDatabase(); + ~QWindowsDirectWriteFontDatabase() override; + + void populateFontDatabase() override; + void populateFamily(const QString &familyName) override; + bool populateFamilyAliases(const QString &missingFamily) override; + QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override; + QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override; + QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const override; + QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *font = nullptr) override; + + bool isPrivateFontFamily(const QString &family) const override; + bool supportsVariableApplicationFonts() const override; + + void registerBitmapFont(const QString &bitmapFont) + { + m_populatedBitmapFonts.insert(bitmapFont); + } + + bool hasPopulatedFont(const QString &fontFamily) const + { + return m_populatedFonts.contains(fontFamily); + } + +protected: + void invalidate() override; + +private: + friend class QWindowsFontEngineDirectWrite; + static QString localeString(IDWriteLocalizedStrings *names, wchar_t localeName[]); + + QSupportedWritingSystems supportedWritingSystems(IDWriteFontFace *face) const; + + QHash<QString, IDWriteFontFamily *> m_populatedFonts; + QSet<QString> m_populatedBitmapFonts; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSDIRECTWRITEFONTDATABASE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontdatabase_ft_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontdatabase_ft_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f69b6cf82a8438f0065466fb43fd321090fd176c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontdatabase_ft_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOWSFONTDATABASEFT_H +#define QWINDOWSFONTDATABASEFT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qfreetypefontdatabase_p.h> +#include <QtCore/QSharedPointer> +#include <QtCore/qt_windows.h> + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QWindowsFontDatabaseFT : public QFreeTypeFontDatabase +{ +public: + void populateFontDatabase() override; + bool populateFamilyAliases(const QString &familyName) override; + void populateFamily(const QString &familyName) override; + QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override; + QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, + QFont::HintingPreference hintingPreference) override; + + QStringList fallbacksForFamily(const QString &family, QFont::Style style, + QFont::StyleHint styleHint, + QChar::Script script) const override; + + QString fontDir() const override; + QFont defaultFont() const override; + + bool m_hasPopulatedAliases = false; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSFONTDATABASEFT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontdatabase_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontdatabase_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f896719556ac4197f4a977fd06690c488cf73a20 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontdatabase_p.h @@ -0,0 +1,159 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOWSFONTDATABASE_H +#define QWINDOWSFONTDATABASE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qwindowsfontdatabasebase_p.h" + +#include <qpa/qplatformfontdatabase.h> +#include <QtCore/QSharedPointer> +#include <QtCore/QLoggingCategory> +#include <QtCore/qhashfunctions.h> +#include <QtCore/qmutex.h> +#include <QtCore/qt_windows.h> + +QT_BEGIN_NAMESPACE + +class QDebug; + +class Q_GUI_EXPORT QWindowsFontDatabase : public QWindowsFontDatabaseBase +{ + Q_DISABLE_COPY_MOVE(QWindowsFontDatabase) +public: + enum FontOptions { + // Relevant bits from QWindowsIntegration::Options + DontUseDirectWriteFonts = 0x40, + DontUseColorFonts = 0x80 + }; + + QWindowsFontDatabase(); + ~QWindowsFontDatabase() override; + + void ensureFamilyPopulated(const QString &familyName); + + void populateFontDatabase() override; + void invalidate() override; + void removeApplicationFonts(); + + void populateFamily(const QString &familyName) override; + bool populateFamilyAliases(const QString &missingFamily) override; + QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override; + QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override; + QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const override; + QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *applicationFont = nullptr) override; + void releaseHandle(void *handle) override; + QString fontDir() const override; + + QFont defaultFont() const override { return systemDefaultFont(); } + bool fontsAlwaysScalable() const override; + void derefUniqueFont(const QString &uniqueFont); + void refUniqueFont(const QString &uniqueFont); + bool isPrivateFontFamily(const QString &family) const override; + + static QFontEngine *createEngine(const QFontDef &request, const QString &faceName, + int dpi, + const QSharedPointer<QWindowsFontEngineData> &data); + + static qreal fontSmoothingGamma(); + + static void setFontOptions(unsigned options); + static unsigned fontOptions(); + +#ifndef QT_NO_DEBUG_STREAM + static void debugFormat(QDebug &d, const LOGFONT &lf); +#endif // !QT_NO_DEBUG_STREAM + + struct FontHandle { + FontHandle(const QString &name) : faceName(name) {} + FontHandle(IDWriteFontFace *face, const QString &name); + ~FontHandle(); + + IDWriteFontFace *fontFace = nullptr; + QString faceName; + }; + +private: + void addDefaultEUDCFont(); + + struct WinApplicationFont { + HANDLE handle; + QString fileName; + }; + + QList<WinApplicationFont> m_applicationFonts; + + struct UniqueFontData { + HANDLE handle; + int refCount; + }; + + QMutex m_uniqueFontDataMutex; // protects m_uniqueFontData + QMap<QString, UniqueFontData> m_uniqueFontData; + + static unsigned m_fontOptions; + QStringList m_eudcFonts; + bool m_hasPopulatedAliases = false; +}; + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug, const QFontDef &def); +#endif + +inline quint16 qt_getUShort(const unsigned char *p) +{ + quint16 val; + val = *p++ << 8; + val |= *p; + + return val; +} + +struct QFontNames +{ + QString name; // e.g. "DejaVu Sans Condensed" + QString style; // e.g. "Italic" + QString preferredName; // e.g. "DejaVu Sans" + QString preferredStyle; // e.g. "Condensed Italic" +}; + +struct QFontValues +{ + quint16 weight = 0; + bool isItalic = false; + bool isOverstruck = false; + bool isUnderlined = false; +}; + +bool qt_localizedName(const QString &name); +QString qt_getEnglishName(const QString &familyName, bool includeStyle = false); +QFontNames qt_getCanonicalFontNames(const LOGFONT &lf); + +struct FontAndStyle { + QString font; + QString style; + + friend inline bool operator==(const FontAndStyle &lhs, const FontAndStyle &rhs) noexcept + { return lhs.font == rhs.font && lhs.style == rhs.style; } + friend inline bool operator!=(const FontAndStyle &lhs, const FontAndStyle &rhs) noexcept + { return !operator==(lhs, rhs); } +}; +inline size_t qHash(const FontAndStyle &key, size_t seed) noexcept +{ + return qHashMulti(seed, key.font, key.style); +} + +QT_END_NAMESPACE + +#endif // QWINDOWSFONTDATABASE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontdatabasebase_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontdatabasebase_p.h new file mode 100644 index 0000000000000000000000000000000000000000..eddc7279f6251db0facfec75ab0b8a64797702c6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontdatabasebase_p.h @@ -0,0 +1,115 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOWSFONTDATABASEBASE_P_H +#define QWINDOWSFONTDATABASEBASE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qpa/qplatformfontdatabase.h> +#include <QtGui/private/qtgui-config_p.h> +#include <QtCore/QSharedPointer> +#include <QtCore/QLoggingCategory> +#include <QtCore/qt_windows.h> + +#if QT_CONFIG(directwrite) + struct IDWriteFactory; + struct IDWriteGdiInterop; + struct IDWriteFontFace; +#endif + +QT_BEGIN_NAMESPACE + +#if QT_CONFIG(directwrite) + class QCustomFontFileLoader; +#endif + +class QWindowsFontEngineData +{ + Q_DISABLE_COPY_MOVE(QWindowsFontEngineData) +public: + QWindowsFontEngineData(); + ~QWindowsFontEngineData(); + + uint pow_gamma[256]; + + bool clearTypeEnabled = false; + qreal fontSmoothingGamma; + HDC hdc = 0; +#if QT_CONFIG(directwrite) + IDWriteFactory *directWriteFactory = nullptr; + IDWriteGdiInterop *directWriteGdiInterop = nullptr; +#endif +}; + +class Q_GUI_EXPORT QWindowsFontDatabaseBase : public QPlatformFontDatabase +{ +public: + QWindowsFontDatabaseBase(); + ~QWindowsFontDatabaseBase() override; + + QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override; + QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override; + + void invalidate() override; + + static int defaultVerticalDPI(); + + static QSharedPointer<QWindowsFontEngineData> data(); +#if QT_CONFIG(directwrite) + static void createDirectWriteFactory(IDWriteFactory **factory); +#endif + static QFont systemDefaultFont(); + static HFONT systemFont(); + static LOGFONT fontDefToLOGFONT(const QFontDef &fontDef, const QString &faceName); + static QFont LOGFONT_to_QFont(const LOGFONT& lf, int verticalDPI = 0); + + static QString familyForStyleHint(QFont::StyleHint styleHint); + static QStringList extraTryFontsForFamily(const QString &family); + + class FontTable{}; + class EmbeddedFont + { + public: + EmbeddedFont(const QByteArray &fontData) : m_fontData(fontData) {} + + QString changeFamilyName(const QString &newFamilyName); + QByteArray data() const { return m_fontData; } + void updateFromOS2Table(QFontEngine *fontEngine); + FontTable *tableDirectoryEntry(const QByteArray &tagName); + QString familyName(FontTable *nameTableDirectory = nullptr); + + private: + QByteArray m_fontData; + }; + + QFontDef sanitizeRequest(QFontDef request) const; + +protected: + +#if QT_CONFIG(directwrite) + QList<IDWriteFontFace *> createDirectWriteFaces(const QByteArray &fontData, + bool queryVariations = true) const; + IDWriteFontFace *createDirectWriteFace(const QByteArray &fontData); +#endif + +private: + static bool init(QSharedPointer<QWindowsFontEngineData> data); + +#if QT_CONFIG(directwrite) + mutable std::unique_ptr<QCustomFontFileLoader> m_fontFileLoader; +#endif +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSFONTDATABASEBASE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontengine_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..eb6f8edbadf52df4192d370940d6cf89a8464fa4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontengine_p.h @@ -0,0 +1,143 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOWSFONTENGINE_H +#define QWINDOWSFONTENGINE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qfontengine_p.h> + +#include <QtGui/QImage> +#include <QtCore/QSharedPointer> +#include <QtCore/QMetaType> + +#include <QtCore/qt_windows.h> + +QT_BEGIN_NAMESPACE + +class QWindowsNativeImage; +class QWindowsFontEngineData; + +class QWindowsFontEngine : public QFontEngine +{ + Q_DISABLE_COPY_MOVE(QWindowsFontEngine) +public: + QWindowsFontEngine(const QString &name, LOGFONT lf, + const QSharedPointer<QWindowsFontEngineData> &fontEngineData); + + ~QWindowsFontEngine() override; + void initFontInfo(const QFontDef &request, + int dpi); + + QFixed lineThickness() const override; + Properties properties() const override; + void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) override; + FaceId faceId() const override; + bool getSfntTableData(uint tag, uchar *buffer, uint *length) const override; + int synthesized() const override; + QFixed emSquareSize() const override; + + glyph_t glyphIndex(uint ucs4) const override; + int stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const override; + void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags) const override; + + void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags) override; + void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, + QPainterPath *path, QTextItem::RenderFlags flags) override; + + HGDIOBJ selectDesignFont() const; + + glyph_metrics_t boundingBox(glyph_t g) override { return boundingBox(g, QTransform()); } + glyph_metrics_t boundingBox(glyph_t g, const QTransform &t) override; + + + QFixed xHeight() const override; + QFixed capHeight() const override; + QFixed averageCharWidth() const override; + qreal maxCharWidth() const override; + qreal minLeftBearing() const override; + qreal minRightBearing() const override; + + QImage alphaMapForGlyph(glyph_t t) override { return alphaMapForGlyph(t, QTransform()); } + QImage alphaMapForGlyph(glyph_t, const QTransform &xform) override; + QImage alphaRGBMapForGlyph(glyph_t t, + const QFixedPoint &subPixelPosition, + const QTransform &xform) override; + glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, + const QFixedPoint &, + const QTransform &matrix, + GlyphFormat) override; + + QFontEngine *cloneWithSize(qreal pixelSize) const override; + Qt::HANDLE handle() const override; + bool supportsTransformation(const QTransform &transform) const override; + +#ifndef Q_CC_MINGW + void getGlyphBearings(glyph_t glyph, qreal *leftBearing = nullptr, qreal *rightBearing = nullptr) override; +#endif + + bool hasUnreliableGlyphOutline() const override; + + int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, int *mappedGlyphs) const; + void getCMap(); + + bool getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const; + + const QSharedPointer<QWindowsFontEngineData> &fontEngineData() const { return m_fontEngineData; } + + void setUniqueFamilyName(const QString &newName) { uniqueFamilyName = newName; } + +protected: + void initializeHeightMetrics() const override; + +private: + QWindowsNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform, + QImage::Format mask_format); + bool hasCFFTable() const; + bool hasCMapTable() const; + + const QSharedPointer<QWindowsFontEngineData> m_fontEngineData; + + const QString _name; + QString uniqueFamilyName; + HFONT hfont = 0; + const LOGFONT m_logfont; + uint ttf : 1; + uint hasOutline : 1; + uint hasUnreliableOutline : 1; + uint cffTable : 1; + TEXTMETRIC tm; + const unsigned char *cmap = nullptr; + int cmapSize = 0; + QByteArray cmapTable; + mutable qreal lbearing = SHRT_MIN; + mutable qreal rbearing = SHRT_MIN; + QFixed designToDevice; + int unitsPerEm = 0; + QFixed x_height = -1; + FaceId _faceId; + + mutable int synthesized_flags = -1; + mutable QFixed lineWidth = -1; + mutable unsigned char *widthCache = nullptr; + mutable uint widthCacheSize = 0; + mutable QFixed *designAdvances = nullptr; + mutable int designAdvancesSize = 0; +}; + +QT_END_NAMESPACE + +QT_DECL_METATYPE_EXTERN(HFONT, Q_GUI_EXPORT) +QT_DECL_METATYPE_EXTERN(LOGFONT, Q_GUI_EXPORT) + +#endif // QWINDOWSFONTENGINE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontenginedirectwrite_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontenginedirectwrite_p.h new file mode 100644 index 0000000000000000000000000000000000000000..44418f4340e6b1aa10fdd3d86dea3059d0fed640 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsfontenginedirectwrite_p.h @@ -0,0 +1,140 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOWSFONTENGINEDIRECTWRITE_H +#define QWINDOWSFONTENGINEDIRECTWRITE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qtguiglobal.h> +#include <QtGui/private/qtgui-config_p.h> + +QT_REQUIRE_CONFIG(directwrite); + +#include <QtGui/private/qfontengine_p.h> +#include <QtCore/QSharedPointer> +#include <dwrite.h> + +struct IDWriteFont; +struct IDWriteFontFace; +struct IDWriteFontFile; +struct IDWriteFactory; +struct IDWriteBitmapRenderTarget; +struct IDWriteGdiInterop; +struct IDWriteGlyphRunAnalysis; + +QT_BEGIN_NAMESPACE + +class QWindowsFontEngineData; + +class Q_GUI_EXPORT QWindowsFontEngineDirectWrite : public QFontEngine +{ + Q_DISABLE_COPY_MOVE(QWindowsFontEngineDirectWrite) +public: + explicit QWindowsFontEngineDirectWrite(IDWriteFontFace *directWriteFontFace, + qreal pixelSize, + const QSharedPointer<QWindowsFontEngineData> &d); + ~QWindowsFontEngineDirectWrite() override; + + void initFontInfo(const QFontDef &request, int dpi); + + QFixed lineThickness() const override; + QFixed underlinePosition() const override; + bool getSfntTableData(uint tag, uchar *buffer, uint *length) const override; + QFixed emSquareSize() const override; + + glyph_t glyphIndex(uint ucs4) const override; + int stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, + ShaperFlags flags) const override; + void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags) const override; + + void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, + QPainterPath *path, QTextItem::RenderFlags flags) override; + + glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) override; + glyph_metrics_t boundingBox(glyph_t g) override; + glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, const QFixedPoint&, + const QTransform &matrix, GlyphFormat) override; + + QFixed capHeight() const override; + QFixed xHeight() const override; + qreal maxCharWidth() const override; + FaceId faceId() const override; + + bool supportsHorizontalSubPixelPositions() const override; + + HFONT createHFONT() const; + + QImage alphaMapForGlyph(glyph_t glyph, const QFixedPoint &subPixelPosition) override; + QImage alphaMapForGlyph(glyph_t glyph, + const QFixedPoint &subPixelPosition, + const QTransform &t) override; + QImage alphaRGBMapForGlyph(glyph_t t, + const QFixedPoint &subPixelPosition, + const QTransform &xform) override; + QImage bitmapForGlyph(glyph_t, + const QFixedPoint &subPixelPosition, + const QTransform &t, + const QColor &color) override; + + QFontEngine *cloneWithSize(qreal pixelSize) const override; + Qt::HANDLE handle() const override; + + const QSharedPointer<QWindowsFontEngineData> &fontEngineData() const { return m_fontEngineData; } + + static QString fontNameSubstitute(const QString &familyName); + + IDWriteFontFace *directWriteFontFace() const { return m_directWriteFontFace; } + + void setUniqueFamilyName(const QString &newName) { m_uniqueFamilyName = newName; } + + void initializeHeightMetrics() const override; + + Properties properties() const override; + void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) override; + +private: + QImage imageForGlyph(glyph_t t, + const QFixedPoint &subPixelPosition, + int margin, + const QTransform &xform, + const QColor &color = QColor()); + void collectMetrics(); + void renderGlyphRun(QImage *destination, + float r, + float g, + float b, + float a, + IDWriteGlyphRunAnalysis *glyphAnalysis, + const QRect &boundingRect, + DWRITE_RENDERING_MODE renderMode); + static QString filenameFromFontFile(IDWriteFontFile *fontFile); + DWRITE_RENDERING_MODE hintingPreferenceToRenderingMode(const QFontDef &fontDef) const; + + const QSharedPointer<QWindowsFontEngineData> m_fontEngineData; + + IDWriteFontFace *m_directWriteFontFace; + IDWriteBitmapRenderTarget *m_directWriteBitmapRenderTarget; + + QFixed m_lineThickness; + QFixed m_underlinePosition; + int m_unitsPerEm; + QFixed m_capHeight; + QFixed m_xHeight; + QFixed m_maxAdvanceWidth; + FaceId m_faceId; + QString m_uniqueFamilyName; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSFONTENGINEDIRECTWRITE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsguieventdispatcher_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsguieventdispatcher_p.h new file mode 100644 index 0000000000000000000000000000000000000000..36bb81a179ecc300587a9fc50c46b862ce654cac --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsguieventdispatcher_p.h @@ -0,0 +1,40 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOWSGUIEVENTDISPATCHER_H +#define QWINDOWSGUIEVENTDISPATCHER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qeventdispatcher_win_p.h> +#include <QtGui/qtguiglobal.h> + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QWindowsGuiEventDispatcher : public QEventDispatcherWin32 +{ + Q_OBJECT +public: + explicit QWindowsGuiEventDispatcher(QObject *parent = nullptr); + + static const char *windowsMessageName(UINT msg); + + bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags) override; + void sendPostedEvents() override; + +private: + QEventLoop::ProcessEventsFlags m_flags; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSGUIEVENTDISPATCHER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsnativeimage_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsnativeimage_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3b5984baffb6827e4c509910d3d54f65a9ae7e41 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsnativeimage_p.h @@ -0,0 +1,54 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOWSNATIVEIMAGE_H +#define QWINDOWSNATIVEIMAGE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/QtGlobal> +#include <QtCore/qt_windows.h> +#include <QtGui/QImage> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QWindowsNativeImage +{ + Q_DISABLE_COPY_MOVE(QWindowsNativeImage) +public: + QWindowsNativeImage(int width, int height, + QImage::Format format); + + ~QWindowsNativeImage(); + + inline int width() const { return m_image.width(); } + inline int height() const { return m_image.height(); } + + QImage &image() { return m_image; } + const QImage &image() const { return m_image; } + + HDC hdc() const { return m_hdc; } + + static QImage::Format systemFormat(); + +private: + const HDC m_hdc; + QImage m_image; + + HBITMAP m_bitmap = 0; + HBITMAP m_null_bitmap = 0; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSNATIVEIMAGE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsthemecache_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsthemecache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..190de8dc59df3daede0197a51c828ab4a8b54862 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qwindowsthemecache_p.h @@ -0,0 +1,35 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOWSTHEME_CACHE_P_H +#define QWINDOWSTHEME_CACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtGui/private/qtguiglobal_p.h" + +#include <QtCore/qt_windows.h> +#include <uxtheme.h> + +QT_BEGIN_NAMESPACE + +namespace QWindowsThemeCache +{ + Q_GUI_EXPORT QString themeName(int theme); + Q_GUI_EXPORT HTHEME createTheme(int theme, HWND hwnd); + Q_GUI_EXPORT void clearThemeCache(HWND hwnd); + Q_GUI_EXPORT void clearAllThemeCaches(); +} + +QT_END_NAMESPACE + +#endif // QWINDOWSTHEME_CACHE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qxbmhandler_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qxbmhandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b4c893d33206fd06f5932c07709280e3480c5bb3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qxbmhandler_p.h @@ -0,0 +1,56 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QXBMHANDLER_P_H +#define QXBMHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qimageiohandler.h" + +#ifndef QT_NO_IMAGEFORMAT_XBM + +QT_BEGIN_NAMESPACE + +class QXbmHandler : public QImageIOHandler +{ +public: + QXbmHandler(); + bool canRead() const override; + bool read(QImage *image) override; + bool write(const QImage &image) override; + + static bool canRead(QIODevice *device); + + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant &value) override; + bool supportsOption(ImageOption option) const override; + +private: + bool readHeader(); + enum State { + Ready, + ReadHeader, + Error + }; + State state; + int width; + int height; + QString fileName; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_IMAGEFORMAT_XBM + +#endif // QXBMHANDLER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qxpmhandler_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qxpmhandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..46d08a4fbccf9e131447fb13a649b871dde90d4d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/qxpmhandler_p.h @@ -0,0 +1,61 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QXPMHANDLER_P_H +#define QXPMHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "QtGui/qimageiohandler.h" + +#ifndef QT_NO_IMAGEFORMAT_XPM + +QT_BEGIN_NAMESPACE + +class QXpmHandler : public QImageIOHandler +{ +public: + QXpmHandler(); + bool canRead() const override; + bool read(QImage *image) override; + bool write(const QImage &image) override; + + static bool canRead(QIODevice *device); + + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant &value) override; + bool supportsOption(ImageOption option) const override; + +private: + bool readHeader(); + bool readImage(QImage *image); + enum State { + Ready, + ReadHeader, + Error + }; + State state; + int width; + int height; + int ncols; + int cpp; + QByteArray buffer; + int index; + QString fileName; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_IMAGEFORMAT_XPM + +#endif // QXPMHANDLER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/vs_test_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/vs_test_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9f15d2d99f6574e1b93aa9bb9242f10d497a74c6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/private/vs_test_p.h @@ -0,0 +1,237 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef VS_TEST_P_H +#define VS_TEST_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +#ifdef Q_OS_WIN + +#include <qt_windows.h> + +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 10.1 +// +// +// Buffer Definitions: +// +// cbuffer buf +// { +// +// row_major float4x4 ubuf_mvp; // Offset: 0 Size: 64 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim HLSL Bind Count +// ------------------------------ ---------- ------- ----------- -------------- ------ +// buf cbuffer NA NA cb0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// TEXCOORD 0 xyzw 0 NONE float xyzw +// TEXCOORD 1 xyz 1 NONE float xyz +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 POS float xyzw +// TEXCOORD 0 xyz 1 NONE float xyz +// +vs_5_0 +dcl_globalFlags refactoringAllowed +dcl_constantbuffer CB0[4], immediateIndexed +dcl_input v0.xyzw +dcl_input v1.xyz +dcl_output_siv o0.xyzw, position +dcl_output o1.xyz +dcl_temps 1 +mul r0.xyzw, v0.yyyy, cb0[1].xyzw +mad r0.xyzw, v0.xxxx, cb0[0].xyzw, r0.xyzw +mad r0.xyzw, v0.zzzz, cb0[2].xyzw, r0.xyzw +mad o0.xyzw, v0.wwww, cb0[3].xyzw, r0.xyzw +mov o1.xyz, v1.xyzx +ret +// Approximately 6 instruction slots used +#endif + +inline constexpr BYTE g_testVertexShader[] = +{ + 68, 88, 66, 67, 75, 198, + 18, 149, 172, 244, 247, 123, + 98, 31, 128, 185, 22, 199, + 182, 233, 1, 0, 0, 0, + 140, 3, 0, 0, 5, 0, + 0, 0, 52, 0, 0, 0, + 60, 1, 0, 0, 136, 1, + 0, 0, 224, 1, 0, 0, + 240, 2, 0, 0, 82, 68, + 69, 70, 0, 1, 0, 0, + 1, 0, 0, 0, 96, 0, + 0, 0, 1, 0, 0, 0, + 60, 0, 0, 0, 0, 5, + 254, 255, 0, 1, 0, 0, + 216, 0, 0, 0, 82, 68, + 49, 49, 60, 0, 0, 0, + 24, 0, 0, 0, 32, 0, + 0, 0, 40, 0, 0, 0, + 36, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, + 92, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, + 0, 0, 98, 117, 102, 0, + 92, 0, 0, 0, 1, 0, + 0, 0, 120, 0, 0, 0, + 64, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 160, 0, 0, 0, 0, 0, + 0, 0, 64, 0, 0, 0, + 2, 0, 0, 0, 180, 0, + 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 255, 255, 255, 255, + 0, 0, 0, 0, 117, 98, + 117, 102, 95, 109, 118, 112, + 0, 102, 108, 111, 97, 116, + 52, 120, 52, 0, 171, 171, + 2, 0, 3, 0, 4, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 169, 0, 0, 0, + 77, 105, 99, 114, 111, 115, + 111, 102, 116, 32, 40, 82, + 41, 32, 72, 76, 83, 76, + 32, 83, 104, 97, 100, 101, + 114, 32, 67, 111, 109, 112, + 105, 108, 101, 114, 32, 49, + 48, 46, 49, 0, 73, 83, + 71, 78, 68, 0, 0, 0, + 2, 0, 0, 0, 8, 0, + 0, 0, 56, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 15, + 0, 0, 56, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 7, + 0, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 171, + 171, 171, 79, 83, 71, 78, + 80, 0, 0, 0, 2, 0, + 0, 0, 8, 0, 0, 0, + 56, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 1, 0, + 0, 0, 7, 8, 0, 0, + 83, 86, 95, 80, 111, 115, + 105, 116, 105, 111, 110, 0, + 84, 69, 88, 67, 79, 79, + 82, 68, 0, 171, 171, 171, + 83, 72, 69, 88, 8, 1, + 0, 0, 80, 0, 1, 0, + 66, 0, 0, 0, 106, 8, + 0, 1, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 114, 16, + 16, 0, 1, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 1, 0, 0, 0, 104, 0, + 0, 2, 1, 0, 0, 0, + 56, 0, 0, 8, 242, 0, + 16, 0, 0, 0, 0, 0, + 86, 21, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 50, 0, 0, 10, + 242, 0, 16, 0, 0, 0, + 0, 0, 6, 16, 16, 0, + 0, 0, 0, 0, 70, 142, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 70, 14, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 10, 242, 0, + 16, 0, 0, 0, 0, 0, + 166, 26, 16, 0, 0, 0, + 0, 0, 70, 142, 32, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 10, 242, 32, 16, 0, + 0, 0, 0, 0, 246, 31, + 16, 0, 0, 0, 0, 0, + 70, 142, 32, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 114, 32, 16, 0, 1, 0, + 0, 0, 70, 18, 16, 0, + 1, 0, 0, 0, 62, 0, + 0, 1, 83, 84, 65, 84, + 148, 0, 0, 0, 6, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 4, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0 +}; + +#endif // Q_OS_WIN + +#endif // VS_TEST_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformaccessibility.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformaccessibility.h new file mode 100644 index 0000000000000000000000000000000000000000..2065c1f8c5a0c430820b2249d569c47bbdac7ff8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformaccessibility.h @@ -0,0 +1,47 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QPLATFORMACCESSIBILITY_H +#define QPLATFORMACCESSIBILITY_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> + +#if QT_CONFIG(accessibility) + +#include <QtCore/qobject.h> +#include <QtGui/qaccessible.h> + +QT_BEGIN_NAMESPACE + + +class Q_GUI_EXPORT QPlatformAccessibility +{ +public: + QPlatformAccessibility(); + + virtual ~QPlatformAccessibility(); + virtual void notifyAccessibilityUpdate(QAccessibleEvent *event); + virtual void setRootObject(QObject *o); + virtual void initialize(); + virtual void cleanup(); + + inline bool isActive() const { return m_active; } + void setActive(bool active); + +private: + bool m_active; +}; + +QT_END_NAMESPACE + +#endif // QT_CONFIG(accessibility) + +#endif // QPLATFORMACCESSIBILITY_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformbackingstore.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformbackingstore.h new file mode 100644 index 0000000000000000000000000000000000000000..26a6497feff4320e554b04e9161989c48e71a62c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformbackingstore.h @@ -0,0 +1,193 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMBACKINGSTORE_H +#define QPLATFORMBACKINGSTORE_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qrect.h> +#include <QtCore/qobject.h> + +#include <QtGui/qwindow.h> +#include <QtGui/qregion.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcQpaBackingStore, Q_GUI_EXPORT) + +class QRegion; +class QRect; +class QPoint; +class QImage; +class QPlatformBackingStorePrivate; +class QPlatformTextureList; +class QPlatformTextureListPrivate; +class QPlatformGraphicsBuffer; +class QRhi; +class QRhiTexture; +class QRhiResourceUpdateBatch; + +struct Q_GUI_EXPORT QPlatformBackingStoreRhiConfig +{ + Q_GADGET +public: + enum Api { + OpenGL, + Metal, + Vulkan, + D3D11, + D3D12, + Null + }; + Q_ENUM(Api) + + QPlatformBackingStoreRhiConfig() + : m_enable(false) + { } + + QPlatformBackingStoreRhiConfig(Api api) + : m_enable(true), + m_api(api) + { } + + bool isEnabled() const { return m_enable; } + void setEnabled(bool enable) { m_enable = enable; } + + Api api() const { return m_api; } + void setApi(Api api) { m_api = api; } + + bool isDebugLayerEnabled() const { return m_debugLayer; } + void setDebugLayer(bool enable) { m_debugLayer = enable; } + +private: + bool m_enable; + Api m_api = Null; + bool m_debugLayer = false; + friend bool operator==(const QPlatformBackingStoreRhiConfig &a, const QPlatformBackingStoreRhiConfig &b); +}; + +inline bool operator==(const QPlatformBackingStoreRhiConfig &a, const QPlatformBackingStoreRhiConfig &b) +{ + return a.m_enable == b.m_enable + && a.m_api == b.m_api + && a.m_debugLayer == b.m_debugLayer; +} + +inline bool operator!=(const QPlatformBackingStoreRhiConfig &a, const QPlatformBackingStoreRhiConfig &b) +{ + return !(a == b); +} + +class Q_GUI_EXPORT QPlatformTextureList : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QPlatformTextureList) +public: + enum Flag { + StacksOnTop = 0x01, + TextureIsSrgb = 0x02, + NeedsPremultipliedAlphaBlending = 0x04, + MirrorVertically = 0x08 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + explicit QPlatformTextureList(QObject *parent = nullptr); + ~QPlatformTextureList(); + + int count() const; + bool isEmpty() const { return count() == 0; } + QRhiTexture *texture(int index) const; + QRhiTexture *textureExtra(int index) const; + QRect geometry(int index) const; + QRect clipRect(int index) const; + void *source(int index); + Flags flags(int index) const; + void lock(bool on); + bool isLocked() const; + + void appendTexture(void *source, QRhiTexture *texture, const QRect &geometry, + const QRect &clipRect = QRect(), Flags flags = { }); + + void appendTexture(void *source, QRhiTexture *textureLeft, QRhiTexture *textureRight, const QRect &geometry, + const QRect &clipRect = QRect(), Flags flags = { }); + void clear(); + + Q_SIGNALS: + void locked(bool); +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformTextureList::Flags) + +class Q_GUI_EXPORT QPlatformBackingStore +{ +public: + enum FlushResult { + FlushSuccess, + FlushFailed, + FlushFailedDueToLostDevice + }; + + explicit QPlatformBackingStore(QWindow *window); + virtual ~QPlatformBackingStore(); + + QWindow *window() const; + QBackingStore *backingStore() const; + + virtual QPaintDevice *paintDevice() = 0; + + virtual void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); + + virtual FlushResult rhiFlush(QWindow *window, + qreal sourceDevicePixelRatio, + const QRegion ®ion, + const QPoint &offset, + QPlatformTextureList *textures, + bool translucentBackground); + + virtual QImage toImage() const; + + enum TextureFlag { + TextureSwizzle = 0x01, + TextureFlip = 0x02, + TexturePremultiplied = 0x04 + }; + Q_DECLARE_FLAGS(TextureFlags, TextureFlag) + virtual QRhiTexture *toTexture(QRhiResourceUpdateBatch *resourceUpdates, + const QRegion &dirtyRegion, + TextureFlags *flags) const; + + virtual QPlatformGraphicsBuffer *graphicsBuffer() const; + + virtual void resize(const QSize &size, const QRegion &staticContents) = 0; + + virtual bool scroll(const QRegion &area, int dx, int dy); + + virtual void beginPaint(const QRegion &); + virtual void endPaint(); + + void createRhi(QWindow *window, QPlatformBackingStoreRhiConfig config); + QRhi *rhi(QWindow *window) const; + void surfaceAboutToBeDestroyed(); + void graphicsDeviceReportedLost(QWindow *window); + +private: + QPlatformBackingStorePrivate *d_ptr; + + void setBackingStore(QBackingStore *); + friend class QBackingStore; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformBackingStore::TextureFlags) + +QT_END_NAMESPACE + +#endif // QPLATFORMBACKINGSTORE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformclipboard.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformclipboard.h new file mode 100644 index 0000000000000000000000000000000000000000..f891962192c01cf285d91d8adace02715a21ddad --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformclipboard.h @@ -0,0 +1,44 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMCLIPBOARD_H +#define QPLATFORMCLIPBOARD_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> + +#ifndef QT_NO_CLIPBOARD + +#include <QtGui/QClipboard> + +QT_BEGIN_NAMESPACE + + +class Q_GUI_EXPORT QPlatformClipboard +{ +public: + Q_DISABLE_COPY_MOVE(QPlatformClipboard) + + QPlatformClipboard() = default; + virtual ~QPlatformClipboard(); + + virtual QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard); + virtual void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard); + virtual bool supportsMode(QClipboard::Mode mode) const; + virtual bool ownsMode(QClipboard::Mode mode) const; + void emitChanged(QClipboard::Mode mode); +}; + +QT_END_NAMESPACE + +#endif // QT_NO_CLIPBOARD + +#endif //QPLATFORMCLIPBOARD_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformcursor.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformcursor.h new file mode 100644 index 0000000000000000000000000000000000000000..5356fa6a6b895985edad2ee9538655f6f2009b6d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformcursor.h @@ -0,0 +1,80 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QPLATFORMCURSOR_H +#define QPLATFORMCURSOR_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/QList> +#include <QtGui/QImage> +#include <QtGui/QMouseEvent> +#include <QtCore/QWeakPointer> +#include <QtCore/QObject> +#include <qpa/qplatformscreen.h> +#include <QtGui/QCursor> + +QT_BEGIN_NAMESPACE + + +// Cursor graphics management +class Q_GUI_EXPORT QPlatformCursorImage { +public: + QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + { set(data, mask, width, height, hotX, hotY); } + QImage * image() { return &cursorImage; } + QPoint hotspot() const { return hot; } + void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void set(const QImage &image, int hx, int hy); + void set(Qt::CursorShape); +private: + static void createSystemCursor(int id); + QImage cursorImage; + QPoint hot; +}; + +class Q_GUI_EXPORT QPlatformCursor : public QObject { +public: + Q_DISABLE_COPY_MOVE(QPlatformCursor) + + enum Capability { + OverrideCursor = 0x1 + }; + Q_DECLARE_FLAGS(Capabilities, Capability) + + QPlatformCursor(); + + // input methods + virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } +#ifndef QT_NO_CURSOR + virtual void changeCursor(QCursor * windowCursor, QWindow * window) = 0; + virtual void setOverrideCursor(const QCursor &); + virtual void clearOverrideCursor(); +#endif // QT_NO_CURSOR + virtual QPoint pos() const; + virtual void setPos(const QPoint &pos); + virtual QSize size() const; + + static Capabilities capabilities() { return m_capabilities; } + static void setCapabilities(Capabilities c) { m_capabilities = c; } + static void setCapability(Capability c) { m_capabilities.setFlag(c); } + +private: + friend void qt_qpa_set_cursor(QWidget * w, bool force); + friend class QApplicationPrivate; + + static Capabilities m_capabilities; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformCursor::Capabilities) + +QT_END_NAMESPACE + +#endif // QPLATFORMCURSOR_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformdialoghelper.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformdialoghelper.h new file mode 100644 index 0000000000000000000000000000000000000000..57014aa7b69c87bc3047ee49bf43466386854c1e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformdialoghelper.h @@ -0,0 +1,499 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMDIALOGHELPER_H +#define QPLATFORMDIALOGHELPER_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/QtGlobal> +#include <QtCore/QObject> +#include <QtCore/QList> +#include <QtCore/QSharedDataPointer> +#include <QtCore/QSharedPointer> +#include <QtCore/QDir> +#include <QtCore/QUrl> +#include <QtGui/QRgb> +Q_MOC_INCLUDE(<QFont>) +Q_MOC_INCLUDE(<QColor>) + +QT_BEGIN_NAMESPACE + + +class QString; +class QColor; +class QFont; +class QWindow; +class QVariant; +class QUrl; +class QColorDialogOptionsPrivate; +class QFontDialogOptionsPrivate; +class QFileDialogOptionsPrivate; +class QMessageDialogOptionsPrivate; + +#define QPLATFORMDIALOGHELPERS_HAS_CREATE + +class Q_GUI_EXPORT QPlatformDialogHelper : public QObject +{ + Q_OBJECT +public: + enum StyleHint { + DialogIsQtWindow + }; + enum DialogCode { Rejected, Accepted }; + + enum StandardButton { + // keep this in sync with QDialogButtonBox::StandardButton and QMessageBox::StandardButton + NoButton = 0x00000000, + Ok = 0x00000400, + Save = 0x00000800, + SaveAll = 0x00001000, + Open = 0x00002000, + Yes = 0x00004000, + YesToAll = 0x00008000, + No = 0x00010000, + NoToAll = 0x00020000, + Abort = 0x00040000, + Retry = 0x00080000, + Ignore = 0x00100000, + Close = 0x00200000, + Cancel = 0x00400000, + Discard = 0x00800000, + Help = 0x01000000, + Apply = 0x02000000, + Reset = 0x04000000, + RestoreDefaults = 0x08000000, + + + FirstButton = Ok, // internal + LastButton = RestoreDefaults, // internal + LowestBit = 10, // internal: log2(FirstButton) + HighestBit = 27 // internal: log2(LastButton) + }; + + Q_DECLARE_FLAGS(StandardButtons, StandardButton) + Q_FLAG(StandardButtons) + + enum ButtonRole { + // keep this in sync with QDialogButtonBox::ButtonRole and QMessageBox::ButtonRole + // TODO Qt 6: make the enum copies explicit, and make InvalidRole == 0 so that + // AcceptRole can be or'ed with flags, and EOL can be the same as InvalidRole (null-termination) + InvalidRole = -1, + AcceptRole, + RejectRole, + DestructiveRole, + ActionRole, + HelpRole, + YesRole, + NoRole, + ResetRole, + ApplyRole, + + NRoles, + + RoleMask = 0x0FFFFFFF, + AlternateRole = 0x10000000, + Stretch = 0x20000000, + Reverse = 0x40000000, + EOL = InvalidRole + }; + Q_ENUM(ButtonRole) + + enum ButtonLayout { + // keep this in sync with QDialogButtonBox::ButtonLayout + UnknownLayout = -1, + WinLayout, + MacLayout, + KdeLayout, + GnomeLayout, + AndroidLayout + }; + Q_ENUM(ButtonLayout) + + QPlatformDialogHelper(); + ~QPlatformDialogHelper(); + + virtual QVariant styleHint(StyleHint hint) const; + + virtual void exec() = 0; + virtual bool show(Qt::WindowFlags windowFlags, + Qt::WindowModality windowModality, + QWindow *parent) = 0; + virtual void hide() = 0; + + static QVariant defaultStyleHint(QPlatformDialogHelper::StyleHint hint); + + static const int *buttonLayout(Qt::Orientation orientation = Qt::Horizontal, ButtonLayout policy = UnknownLayout); + static ButtonRole buttonRole(StandardButton button); + +Q_SIGNALS: + void accept(); + void reject(); +}; + +QT_END_NAMESPACE +QT_DECL_METATYPE_EXTERN_TAGGED(QPlatformDialogHelper::StandardButton, + QPlatformDialogHelper__StandardButton, Q_GUI_EXPORT) +QT_DECL_METATYPE_EXTERN_TAGGED(QPlatformDialogHelper::ButtonRole, + QPlatformDialogHelper__ButtonRole, Q_GUI_EXPORT) +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QColorDialogOptions +{ + Q_GADGET + Q_DISABLE_COPY(QColorDialogOptions) +protected: + explicit QColorDialogOptions(QColorDialogOptionsPrivate *dd); + ~QColorDialogOptions(); +public: + enum ColorDialogOption { + ShowAlphaChannel = 0x00000001, + NoButtons = 0x00000002, + DontUseNativeDialog = 0x00000004, + NoEyeDropperButton = 0x00000008 + }; + + Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) + Q_FLAG(ColorDialogOptions) + + static QSharedPointer<QColorDialogOptions> create(); + QSharedPointer<QColorDialogOptions> clone() const; + + QString windowTitle() const; + void setWindowTitle(const QString &); + + void setOption(ColorDialogOption option, bool on = true); + bool testOption(ColorDialogOption option) const; + void setOptions(ColorDialogOptions options); + ColorDialogOptions options() const; + + static int customColorCount(); + static QRgb customColor(int index); + static QRgb *customColors(); + static void setCustomColor(int index, QRgb color); + + static QRgb *standardColors(); + static QRgb standardColor(int index); + static void setStandardColor(int index, QRgb color); + +private: + QColorDialogOptionsPrivate *d; +}; + +class Q_GUI_EXPORT QPlatformColorDialogHelper : public QPlatformDialogHelper +{ + Q_OBJECT +public: + const QSharedPointer<QColorDialogOptions> &options() const; + void setOptions(const QSharedPointer<QColorDialogOptions> &options); + + virtual void setCurrentColor(const QColor &) = 0; + virtual QColor currentColor() const = 0; + +Q_SIGNALS: + void currentColorChanged(const QColor &color); + void colorSelected(const QColor &color); + +private: + QSharedPointer<QColorDialogOptions> m_options; +}; + +class Q_GUI_EXPORT QFontDialogOptions +{ + Q_GADGET + Q_DISABLE_COPY(QFontDialogOptions) +protected: + explicit QFontDialogOptions(QFontDialogOptionsPrivate *dd); + ~QFontDialogOptions(); + +public: + enum FontDialogOption { + NoButtons = 0x00000001, + DontUseNativeDialog = 0x00000002, + ScalableFonts = 0x00000004, + NonScalableFonts = 0x00000008, + MonospacedFonts = 0x00000010, + ProportionalFonts = 0x00000020 + }; + + Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption) + Q_FLAG(FontDialogOptions) + + static QSharedPointer<QFontDialogOptions> create(); + QSharedPointer<QFontDialogOptions> clone() const; + + QString windowTitle() const; + void setWindowTitle(const QString &); + + void setOption(FontDialogOption option, bool on = true); + bool testOption(FontDialogOption option) const; + void setOptions(FontDialogOptions options); + FontDialogOptions options() const; + +private: + QFontDialogOptionsPrivate *d; +}; + +class Q_GUI_EXPORT QPlatformFontDialogHelper : public QPlatformDialogHelper +{ + Q_OBJECT +public: + virtual void setCurrentFont(const QFont &) = 0; + virtual QFont currentFont() const = 0; + + const QSharedPointer<QFontDialogOptions> &options() const; + void setOptions(const QSharedPointer<QFontDialogOptions> &options); + +Q_SIGNALS: + void currentFontChanged(const QFont &font); + void fontSelected(const QFont &font); + +private: + QSharedPointer<QFontDialogOptions> m_options; +}; + +class Q_GUI_EXPORT QFileDialogOptions +{ + Q_GADGET + Q_DISABLE_COPY(QFileDialogOptions) +protected: + QFileDialogOptions(QFileDialogOptionsPrivate *dd); + ~QFileDialogOptions(); + +public: + enum ViewMode { Detail, List }; + Q_ENUM(ViewMode) + + enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly }; + Q_ENUM(FileMode) + + enum AcceptMode { AcceptOpen, AcceptSave }; + Q_ENUM(AcceptMode) + + enum DialogLabel { LookIn, FileName, FileType, Accept, Reject, DialogLabelCount }; + Q_ENUM(DialogLabel) + + // keep this in sync with QFileDialog::Options + enum FileDialogOption + { + ShowDirsOnly = 0x00000001, + DontResolveSymlinks = 0x00000002, + DontConfirmOverwrite = 0x00000004, + DontUseNativeDialog = 0x00000008, + ReadOnly = 0x00000010, + HideNameFilterDetails = 0x00000020, + DontUseCustomDirectoryIcons = 0x00000040 + }; + Q_DECLARE_FLAGS(FileDialogOptions, FileDialogOption) + Q_FLAG(FileDialogOptions) + + static QSharedPointer<QFileDialogOptions> create(); + QSharedPointer<QFileDialogOptions> clone() const; + + QString windowTitle() const; + void setWindowTitle(const QString &); + + void setOption(FileDialogOption option, bool on = true); + bool testOption(FileDialogOption option) const; + void setOptions(FileDialogOptions options); + FileDialogOptions options() const; + + QDir::Filters filter() const; + void setFilter(QDir::Filters filters); + + void setViewMode(ViewMode mode); + ViewMode viewMode() const; + + void setFileMode(FileMode mode); + FileMode fileMode() const; + + void setAcceptMode(AcceptMode mode); + AcceptMode acceptMode() const; + + void setSidebarUrls(const QList<QUrl> &urls); + QList<QUrl> sidebarUrls() const; + + bool useDefaultNameFilters() const; + void setUseDefaultNameFilters(bool d); + + void setNameFilters(const QStringList &filters); + QStringList nameFilters() const; + + void setMimeTypeFilters(const QStringList &filters); + QStringList mimeTypeFilters() const; + + void setDefaultSuffix(const QString &suffix); + QString defaultSuffix() const; + + void setHistory(const QStringList &paths); + QStringList history() const; + + void setLabelText(DialogLabel label, const QString &text); + QString labelText(DialogLabel label) const; + bool isLabelExplicitlySet(DialogLabel label); + + QUrl initialDirectory() const; + void setInitialDirectory(const QUrl &); + + QString initiallySelectedMimeTypeFilter() const; + void setInitiallySelectedMimeTypeFilter(const QString &); + + QString initiallySelectedNameFilter() const; + void setInitiallySelectedNameFilter(const QString &); + + QList<QUrl> initiallySelectedFiles() const; + void setInitiallySelectedFiles(const QList<QUrl> &); + + void setSupportedSchemes(const QStringList &schemes); + QStringList supportedSchemes() const; + + static QString defaultNameFilterString(); + +private: + QFileDialogOptionsPrivate *d; +}; + +class Q_GUI_EXPORT QPlatformFileDialogHelper : public QPlatformDialogHelper +{ + Q_OBJECT +public: + virtual bool defaultNameFilterDisables() const = 0; + virtual void setDirectory(const QUrl &directory) = 0; + virtual QUrl directory() const = 0; + virtual void selectFile(const QUrl &filename) = 0; + virtual QList<QUrl> selectedFiles() const = 0; + virtual void setFilter() = 0; + virtual void selectMimeTypeFilter(const QString &filter); + virtual void selectNameFilter(const QString &filter) = 0; + virtual QString selectedMimeTypeFilter() const; + virtual QString selectedNameFilter() const = 0; + + virtual bool isSupportedUrl(const QUrl &url) const; + + const QSharedPointer<QFileDialogOptions> &options() const; + void setOptions(const QSharedPointer<QFileDialogOptions> &options); + + static QStringList cleanFilterList(const QString &filter); + static const char filterRegExp[]; + +Q_SIGNALS: + void fileSelected(const QUrl &file); + void filesSelected(const QList<QUrl> &files); + void currentChanged(const QUrl &path); + void directoryEntered(const QUrl &directory); + void filterSelected(const QString &filter); + +private: + QSharedPointer<QFileDialogOptions> m_options; +}; + +class Q_GUI_EXPORT QMessageDialogOptions +{ + Q_GADGET + Q_DISABLE_COPY(QMessageDialogOptions) +protected: + QMessageDialogOptions(QMessageDialogOptionsPrivate *dd); + ~QMessageDialogOptions(); + +public: + // Keep in sync with QMessageBox Option + enum class Option { + DontUseNativeDialog = 0x00000001, + }; + Q_DECLARE_FLAGS(Options, Option); + Q_FLAG(Options); + + // Keep in sync with QMessageBox::Icon + enum StandardIcon { NoIcon, Information, Warning, Critical, Question }; + Q_ENUM(StandardIcon) + + static QSharedPointer<QMessageDialogOptions> create(); + QSharedPointer<QMessageDialogOptions> clone() const; + + QString windowTitle() const; + void setWindowTitle(const QString &); + + void setStandardIcon(StandardIcon icon); + StandardIcon standardIcon() const; + + void setIconPixmap(const QPixmap &pixmap); + QPixmap iconPixmap() const; + + void setText(const QString &text); + QString text() const; + + void setInformativeText(const QString &text); + QString informativeText() const; + + void setDetailedText(const QString &text); + QString detailedText() const; + + void setOption(Option option, bool on = true); + bool testOption(Option option) const; + void setOptions(Options options); + Options options() const; + + void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons); + QPlatformDialogHelper::StandardButtons standardButtons() const; + + struct CustomButton { + explicit CustomButton( + int id = -1, const QString &label = QString(), + QPlatformDialogHelper::ButtonRole role = QPlatformDialogHelper::InvalidRole, + void *button = nullptr) : + label(label), role(role), id(id), button(button) + {} + + QString label; + QPlatformDialogHelper::ButtonRole role; + int id; + void *button; // strictly internal use only + }; + + int addButton(const QString &label, QPlatformDialogHelper::ButtonRole role, + void *buttonImpl = nullptr, int buttonId = 0); + void removeButton(int id); + const QList<CustomButton> &customButtons(); + const CustomButton *customButton(int id); + void clearCustomButtons(); + + void setCheckBox(const QString &label, Qt::CheckState state); + QString checkBoxLabel() const; + Qt::CheckState checkBoxState() const; + + void setEscapeButton(int id); + int escapeButton() const; + + void setDefaultButton(int id); + int defaultButton() const; + +private: + QMessageDialogOptionsPrivate *d; +}; + +class Q_GUI_EXPORT QPlatformMessageDialogHelper : public QPlatformDialogHelper +{ + Q_OBJECT +public: + const QSharedPointer<QMessageDialogOptions> &options() const; + void setOptions(const QSharedPointer<QMessageDialogOptions> &options); + +Q_SIGNALS: + void clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role); + void checkBoxStateChanged(Qt::CheckState state); + +private: + QSharedPointer<QMessageDialogOptions> m_options; +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMDIALOGHELPER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformdrag.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformdrag.h new file mode 100644 index 0000000000000000000000000000000000000000..0c630ddec29bb49a16e4069c2d6aab09bbe01211 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformdrag.h @@ -0,0 +1,81 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMDRAG_H +#define QPLATFORMDRAG_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtGui/QPixmap> + +QT_REQUIRE_CONFIG(draganddrop); + +QT_BEGIN_NAMESPACE + +class QMimeData; +class QMouseEvent; +class QDrag; +class QObject; +class QEvent; +class QPlatformDragPrivate; + +class Q_GUI_EXPORT QPlatformDropQtResponse +{ +public: + QPlatformDropQtResponse(bool accepted, Qt::DropAction acceptedAction); + bool isAccepted() const; + Qt::DropAction acceptedAction() const; + +private: + bool m_accepted; + Qt::DropAction m_accepted_action; + +}; + +class Q_GUI_EXPORT QPlatformDragQtResponse : public QPlatformDropQtResponse +{ +public: + QPlatformDragQtResponse(bool accepted, Qt::DropAction acceptedAction, QRect answerRect); + + QRect answerRect() const; + +private: + QRect m_answer_rect; +}; + +class Q_GUI_EXPORT QPlatformDrag +{ + Q_DECLARE_PRIVATE(QPlatformDrag) +public: + Q_DISABLE_COPY_MOVE(QPlatformDrag) + + QPlatformDrag(); + virtual ~QPlatformDrag(); + + QDrag *currentDrag() const; + + virtual Qt::DropAction drag(QDrag *m_drag) = 0; + virtual void cancelDrag(); + void updateAction(Qt::DropAction action); + + virtual Qt::DropAction defaultAction(Qt::DropActions possibleActions, Qt::KeyboardModifiers modifiers) const; + + static QPixmap defaultPixmap(); + + virtual bool ownsDragObject() const; + +private: + QPlatformDragPrivate *d_ptr; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformfontdatabase.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformfontdatabase.h new file mode 100644 index 0000000000000000000000000000000000000000..5fe00153715178d2d9b3c747f7aeb4a6e666f84f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformfontdatabase.h @@ -0,0 +1,115 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMFONTDATABASE_H +#define QPLATFORMFONTDATABASE_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QList> +#include <QtGui/QFontDatabase> +#include <QtGui/private/qfontengine_p.h> +#include <QtGui/private/qfont_p.h> +#include <QtGui/private/qfontdatabase_p.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcQpaFonts, Q_GUI_EXPORT) + +class QWritingSystemsPrivate; + +class Q_GUI_EXPORT QSupportedWritingSystems +{ +public: + + QSupportedWritingSystems(); + QSupportedWritingSystems(const QSupportedWritingSystems &other); + QSupportedWritingSystems &operator=(const QSupportedWritingSystems &other); + ~QSupportedWritingSystems(); + + void setSupported(QFontDatabase::WritingSystem, bool supported = true); + bool supported(QFontDatabase::WritingSystem) const; + +private: + void detach(); + + QWritingSystemsPrivate *d; + + friend Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &); + friend Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &); +#ifndef QT_NO_DEBUG_STREAM + friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &); +#endif +}; + +Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &); +Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &); + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &); +#endif + +class QFontRequestPrivate; +class QFontEngineMulti; + +class Q_GUI_EXPORT QPlatformFontDatabase +{ +public: + virtual ~QPlatformFontDatabase(); + virtual void populateFontDatabase(); + virtual bool populateFamilyAliases(const QString &missingFamily) { Q_UNUSED(missingFamily); return false; } + virtual void populateFamily(const QString &familyName); + virtual void invalidate(); + + virtual QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const; + virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *font = nullptr); + + virtual QFontEngine *fontEngine(const QFontDef &fontDef, void *handle); + virtual QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference); + virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script); + virtual void releaseHandle(void *handle); + + virtual QString fontDir() const; + + virtual QFont defaultFont() const; + virtual bool isPrivateFontFamily(const QString &family) const; + + virtual QString resolveFontFamilyAlias(const QString &family) const; + virtual bool fontsAlwaysScalable() const; + virtual QList<int> standardSizes() const; + + virtual bool supportsVariableApplicationFonts() const; + + // helper + static QSupportedWritingSystems writingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2]); + static QSupportedWritingSystems writingSystemsFromOS2Table(const char *os2Table, size_t length); + + //callback + static void registerFont(const QString &familyname, const QString &stylename, + const QString &foundryname, QFont::Weight weight, + QFont::Style style, QFont::Stretch stretch, bool antialiased, + bool scalable, int pixelSize, bool fixedPitch, + const QSupportedWritingSystems &writingSystems, void *handle); + + static void registerFontFamily(const QString &familyName); + static void registerAliasToFontFamily(const QString &familyName, const QString &alias); + + static void repopulateFontDatabase(); + + static bool isFamilyPopulated(const QString &familyName); +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMFONTDATABASE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformgraphicsbuffer.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformgraphicsbuffer.h new file mode 100644 index 0000000000000000000000000000000000000000..ebe9ced85a2025f5f4d7a4f24af0b15d630ae8a9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformgraphicsbuffer.h @@ -0,0 +1,82 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMGRAPHICSBUFFER_H +#define QPLATFORMGRAPHICSBUFFER_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + + +#include <QtGui/qtguiglobal.h> +#include <QtCore/QSize> +#include <QtCore/QRect> +#include <QtGui/QPixelFormat> +#include <QtCore/qflags.h> +#include <QtCore/QObject> + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QPlatformGraphicsBuffer : public QObject +{ +Q_OBJECT +public: + enum AccessType + { + None = 0x00, + SWReadAccess = 0x01, + SWWriteAccess = 0x02, + TextureAccess = 0x04, + HWCompositor = 0x08 + }; + Q_ENUM(AccessType); + Q_DECLARE_FLAGS(AccessTypes, AccessType); + + enum Origin { + OriginBottomLeft, + OriginTopLeft + }; + Q_ENUM(Origin); + + ~QPlatformGraphicsBuffer(); + + AccessTypes isLocked() const { return m_lock_access; } + bool lock(AccessTypes access, const QRect &rect = QRect()); + void unlock(); + + virtual bool bindToTexture(const QRect &rect = QRect()) const; + + virtual const uchar *data() const; + virtual uchar *data(); + virtual int bytesPerLine() const; + int byteCount() const; + + virtual Origin origin() const; + + QSize size() const { return m_size; } + QPixelFormat format() const { return m_format; } + +Q_SIGNALS: + void unlocked(AccessTypes previousAccessTypes); + +protected: + QPlatformGraphicsBuffer(const QSize &size, const QPixelFormat &format); + + virtual bool doLock(AccessTypes access, const QRect &rect = QRect()) = 0; + virtual void doUnlock() = 0; + +private: + QSize m_size; + QPixelFormat m_format; + AccessTypes m_lock_access; +}; + +QT_END_NAMESPACE + +#endif //QPLATFORMGRAPHICSBUFFER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformgraphicsbufferhelper.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformgraphicsbufferhelper.h new file mode 100644 index 0000000000000000000000000000000000000000..97dc11618e02568364749feb6cf48ebfa502d67b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformgraphicsbufferhelper.h @@ -0,0 +1,19 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMGRAPHICSBUFFERHELPER_H +#define QPLATFORMGRAPHICSBUFFERHELPER_H + +#include <QtGui/qtguiglobal.h> +#include <QtGui/qpa/qplatformgraphicsbuffer.h> + +QT_BEGIN_NAMESPACE + +namespace QPlatformGraphicsBufferHelper { + Q_GUI_EXPORT bool lockAndBindToTexture(QPlatformGraphicsBuffer *graphicsBuffer, bool *swizzleRandB, bool *premultipliedB, const QRect &rect = QRect()); + bool bindSWToTexture(const QPlatformGraphicsBuffer *graphicsBuffer, bool *swizzleRandB = nullptr, bool *premultipliedB = nullptr, const QRect &rect = QRect()); +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontext.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontext.h new file mode 100644 index 0000000000000000000000000000000000000000..0ced3b2d6b02f02a0a138b76a88ff9e84af3978e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontext.h @@ -0,0 +1,81 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMINPUTCONTEXT_H +#define QPLATFORMINPUTCONTEXT_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtGui/qinputmethod.h> + +QT_BEGIN_NAMESPACE + +class QPlatformInputContextPrivate; + +class Q_GUI_EXPORT QPlatformInputContext : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QPlatformInputContext) + +public: + enum Capability { + HiddenTextCapability = 0x1 + }; + + QPlatformInputContext(); + ~QPlatformInputContext(); + + virtual bool isValid() const; + virtual bool hasCapability(Capability capability) const; + + virtual void reset(); + virtual void commit(); + virtual void update(Qt::InputMethodQueries); + virtual void invokeAction(QInputMethod::Action, int cursorPosition); + virtual bool filterEvent(const QEvent *event); + virtual QRectF keyboardRect() const; + void emitKeyboardRectChanged(); + + virtual bool isAnimating() const; + void emitAnimatingChanged(); + + virtual void showInputPanel(); + virtual void hideInputPanel(); + virtual bool isInputPanelVisible() const; + void emitInputPanelVisibleChanged(); + + virtual QLocale locale() const; + void emitLocaleChanged(); + virtual Qt::LayoutDirection inputDirection() const; + void emitInputDirectionChanged(Qt::LayoutDirection newDirection); + + virtual void setFocusObject(QObject *object); + bool inputMethodAccepted() const; + + static void setSelectionOnFocusObject(const QPointF &anchorPos, const QPointF &cursorPos); + static QVariant queryFocusObject(Qt::InputMethodQuery query, QPointF position); + static QRectF inputItemRectangle(); + static QRectF inputItemClipRectangle(); + static QRectF cursorRectangle(); + static QRectF anchorRectangle(); + static QRectF keyboardRectangle(); + +private: + friend class QGuiApplication; + friend class QGuiApplicationPrivate; + friend class QInputMethod; + + Qt::LayoutDirection m_inputDirection; +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMINPUTCONTEXT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontext_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontext_p.h new file mode 100644 index 0000000000000000000000000000000000000000..09024d1d8a2f362157934fb547a30ccaead877b0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontext_p.h @@ -0,0 +1,37 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMINPUTCONTEXT_P_H +#define QPLATFORMINPUTCONTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <private/qobject_p.h> + +QT_BEGIN_NAMESPACE + +class QPlatformInputContextPrivate: public QObjectPrivate +{ +public: + QPlatformInputContextPrivate() {} + ~QPlatformInputContextPrivate() {} + + static void setInputMethodAccepted(bool accepted); + static bool inputMethodAccepted(); + + static bool s_inputMethodAccepted; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontextfactory_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontextfactory_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bbed44b78f6998511db39fb83f40b6e30f84bfe1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontextfactory_p.h @@ -0,0 +1,39 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMINPUTCONTEXTFACTORY_H +#define QPLATFORMINPUTCONTEXTFACTORY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtCore/qstringlist.h> + +QT_BEGIN_NAMESPACE + + +class QPlatformInputContext; + +class Q_GUI_EXPORT QPlatformInputContextFactory +{ +public: + static QStringList keys(); + static QStringList requested(); + static QPlatformInputContext *create(const QStringList &keys); + static QPlatformInputContext *create(const QString &key); + static QPlatformInputContext *create(); +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMINPUTCONTEXTFACTORY_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontextplugin_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontextplugin_p.h new file mode 100644 index 0000000000000000000000000000000000000000..30f9f5c7a41456adcdb910abf5cdfebea56794ca --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatforminputcontextplugin_p.h @@ -0,0 +1,41 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMINPUTCONTEXTPLUGIN_H +#define QPLATFORMINPUTCONTEXTPLUGIN_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtCore/qplugin.h> +#include <QtCore/qfactoryinterface.h> + +QT_BEGIN_NAMESPACE + + +class QPlatformInputContext; + +#define QPlatformInputContextFactoryInterface_iid "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1" + +class Q_GUI_EXPORT QPlatformInputContextPlugin : public QObject +{ + Q_OBJECT +public: + explicit QPlatformInputContextPlugin(QObject *parent = nullptr); + ~QPlatformInputContextPlugin(); + + virtual QPlatformInputContext *create(const QString &key, const QStringList ¶mList) = 0; +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMINPUTCONTEXTPLUGIN_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformintegration.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformintegration.h new file mode 100644 index 0000000000000000000000000000000000000000..7ae134a6828ccac22a7a294de960a7cd11b6246b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformintegration.h @@ -0,0 +1,220 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMINTEGRATION_H +#define QPLATFORMINTEGRATION_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtGui/qwindowdefs.h> +#include <qpa/qplatformscreen.h> +#include <QtGui/qsurfaceformat.h> +#include <QtGui/qopenglcontext.h> + +QT_BEGIN_NAMESPACE + + +class QPlatformWindow; +class QWindow; +class QPlatformBackingStore; +class QPlatformFontDatabase; +class QPlatformClipboard; +class QPlatformNativeInterface; +class QPlatformDrag; +class QPlatformOpenGLContext; +class QGuiGLFormat; +class QAbstractEventDispatcher; +class QPlatformInputContext; +class QPlatformKeyMapper; +class QPlatformAccessibility; +class QPlatformTheme; +class QPlatformDialogHelper; +class QPlatformSharedGraphicsCache; +class QPlatformServices; +class QPlatformSessionManager; +class QKeyEvent; +class QPlatformOffscreenSurface; +class QOffscreenSurface; +class QPlatformVulkanInstance; +class QVulkanInstance; + +namespace QNativeInterface::Private { + +template <typename R, typename I, auto func, typename... Args> +struct QInterfaceProxyImp +{ + template <typename T> + static R apply(T *obj, Args... args) + { + if (auto *iface = dynamic_cast<I*>(obj)) + return (iface->*func)(args...); + else + return R(); + } +}; + +template <auto func> +struct QInterfaceProxy; +template <typename R, typename I, typename... Args, R(I::*func)(Args...)> +struct QInterfaceProxy<func> : public QInterfaceProxyImp<R, I, func, Args...> {}; +template <typename R, typename I, typename... Args, R(I::*func)(Args...) const> +struct QInterfaceProxy<func> : public QInterfaceProxyImp<R, I, func, Args...> {}; + +} // QNativeInterface::Private + +class Q_GUI_EXPORT QPlatformIntegration +{ +public: + Q_DISABLE_COPY_MOVE(QPlatformIntegration) + + enum Capability { + ThreadedPixmaps = 1, + OpenGL, + ThreadedOpenGL, + SharedGraphicsCache, + BufferQueueingOpenGL, + WindowMasks, + MultipleWindows, + ApplicationState, + ForeignWindows, + NonFullScreenWindows, + NativeWidgets, + WindowManagement, + WindowActivation, // whether requestActivate is supported + SyncState, + RasterGLSurface, + AllGLFunctionsQueryable, + ApplicationIcon, + SwitchableWidgetComposition, + TopStackedNativeChildWindows, + OpenGLOnRasterSurface, + MaximizeUsingFullscreenGeometry, + PaintEvents, + RhiBasedRendering, + ScreenWindowGrabbing, // whether QScreen::grabWindow() is supported + BackingStoreStaticContents + }; + + virtual ~QPlatformIntegration() { } + + virtual bool hasCapability(Capability cap) const; + + virtual QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const; + virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0; + virtual QPlatformWindow *createForeignWindow(QWindow *, WId) const { return nullptr; } + virtual QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const = 0; +#ifndef QT_NO_OPENGL + virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; +#endif + virtual QPlatformSharedGraphicsCache *createPlatformSharedGraphicsCache(const char *cacheId) const; + virtual QPaintEngine *createImagePaintEngine(QPaintDevice *paintDevice) const; + +// Event dispatcher: + virtual QAbstractEventDispatcher *createEventDispatcher() const = 0; + virtual void initialize(); + virtual void destroy(); + +//Deeper window system integrations + virtual QPlatformFontDatabase *fontDatabase() const; +#ifndef QT_NO_CLIPBOARD + virtual QPlatformClipboard *clipboard() const; +#endif +#if QT_CONFIG(draganddrop) + virtual QPlatformDrag *drag() const; +#endif + virtual QPlatformInputContext *inputContext() const; +#if QT_CONFIG(accessibility) + virtual QPlatformAccessibility *accessibility() const; +#endif + + // Access native handles. The window handle is already available from Wid; + virtual QPlatformNativeInterface *nativeInterface() const; + + virtual QPlatformServices *services() const; + + enum StyleHint { + CursorFlashTime, + KeyboardInputInterval, + MouseDoubleClickInterval, + StartDragDistance, + StartDragTime, + KeyboardAutoRepeatRate, + ShowIsFullScreen, + PasswordMaskDelay, + FontSmoothingGamma, + StartDragVelocity, + UseRtlExtensions, + PasswordMaskCharacter, + SetFocusOnTouchRelease, + ShowIsMaximized, + MousePressAndHoldInterval, + TabFocusBehavior, + ReplayMousePressOutsidePopup, + ItemViewActivateItemOnSingleClick, + UiEffects, + WheelScrollLines, + ShowShortcutsInContextMenus, + MouseQuickSelectionThreshold, + MouseDoubleClickDistance, + FlickStartDistance, + FlickMaximumVelocity, + FlickDeceleration, + UnderlineShortcut, + }; + + virtual QVariant styleHint(StyleHint hint) const; + virtual Qt::WindowState defaultWindowState(Qt::WindowFlags) const; + +protected: + virtual Qt::KeyboardModifiers queryKeyboardModifiers() const; + virtual QList<int> possibleKeys(const QKeyEvent *) const; + friend class QPlatformKeyMapper; +public: + virtual QPlatformKeyMapper *keyMapper() const; + + virtual QStringList themeNames() const; + virtual QPlatformTheme *createPlatformTheme(const QString &name) const; + + virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const; + +#ifndef QT_NO_SESSIONMANAGER + virtual QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const; +#endif + + virtual void sync(); + +#ifndef QT_NO_OPENGL + virtual QOpenGLContext::OpenGLModuleType openGLModuleType(); +#endif + virtual void setApplicationIcon(const QIcon &icon) const; + virtual void setApplicationBadge(qint64 number); + + virtual void beep() const; + virtual void quit() const; + +#if QT_CONFIG(vulkan) || defined(Q_QDOC) + virtual QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const; +#endif + + template <auto func, typename... Args> + auto call(Args... args) + { + using namespace QNativeInterface::Private; + return QInterfaceProxy<func>::apply(this, args...); + } + +protected: + QPlatformIntegration() = default; +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMINTEGRATION_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformintegrationfactory_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformintegrationfactory_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6984460680a2f24d28370b086779623256a1e974 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformintegrationfactory_p.h @@ -0,0 +1,36 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMINTEGRATIONFACTORY_H +#define QPLATFORMINTEGRATIONFACTORY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtCore/qstringlist.h> + +QT_BEGIN_NAMESPACE + + +class QPlatformIntegration; + +class Q_GUI_EXPORT QPlatformIntegrationFactory +{ +public: + static QStringList keys(const QString &platformPluginPath = QString()); + static QPlatformIntegration *create(const QString &name, const QStringList &args, int &argc, char **argv, const QString &platformPluginPath = QString()); +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMINTEGRATIONFACTORY_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformintegrationplugin.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformintegrationplugin.h new file mode 100644 index 0000000000000000000000000000000000000000..e79d8051cff21beb783aff8600ea5724d768672d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformintegrationplugin.h @@ -0,0 +1,40 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMINTEGRATIONPLUGIN_H +#define QPLATFORMINTEGRATIONPLUGIN_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qplugin.h> +#include <QtCore/qfactoryinterface.h> + +QT_BEGIN_NAMESPACE + + +class QPlatformIntegration; + +#define QPlatformIntegrationFactoryInterface_iid "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3" + +class Q_GUI_EXPORT QPlatformIntegrationPlugin : public QObject +{ + Q_OBJECT +public: + explicit QPlatformIntegrationPlugin(QObject *parent = nullptr); + ~QPlatformIntegrationPlugin(); + + virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList); + virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList, int &argc, char **argv); +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMINTEGRATIONPLUGIN_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformkeymapper.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformkeymapper.h new file mode 100644 index 0000000000000000000000000000000000000000..d6e8bc961c944d7dee5b35888b2732e379efeffd --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformkeymapper.h @@ -0,0 +1,36 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMKEYMAPPER_P +#define QPLATFORMKEYMAPPER_P + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qloggingcategory.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcQpaKeyMapper, Q_GUI_EXPORT) + +class QKeyEvent; + +class Q_GUI_EXPORT QPlatformKeyMapper +{ +public: + virtual ~QPlatformKeyMapper(); + + virtual QList<QKeyCombination> possibleKeyCombinations(const QKeyEvent *event) const; + virtual Qt::KeyboardModifiers queryKeyboardModifiers() const; +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMKEYMAPPER_P diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformmenu.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformmenu.h new file mode 100644 index 0000000000000000000000000000000000000000..eb2d03b9f8810585af143aa701884b1208af2c7b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformmenu.h @@ -0,0 +1,137 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author James Turner <james.turner@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMMENU_H +#define QPLATFORMMENU_H +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtCore/qobject.h> +#include <QtGui/qtguiglobal.h> +#include <QtCore/qpointer.h> +#include <QtGui/qfont.h> +#if QT_CONFIG(shortcut) +# include <QtGui/qkeysequence.h> +#endif +#include <QtGui/qicon.h> + +QT_BEGIN_NAMESPACE + +class QPlatformMenu; +class Q_GUI_EXPORT QPlatformMenuItem : public QObject +{ +Q_OBJECT +public: + QPlatformMenuItem(); + + // copied from, and must stay in sync with, QAction menu roles. + enum MenuRole { NoRole = 0, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, + AboutRole, PreferencesRole, QuitRole, + // However these roles are private, perhaps temporarily. + // They could be added as public QAction roles if necessary. + CutRole, CopyRole, PasteRole, SelectAllRole, + RoleCount }; + Q_ENUM(MenuRole) + + virtual void setTag(quintptr tag); + virtual quintptr tag() const; + + virtual void setText(const QString &text) = 0; + virtual void setIcon(const QIcon &icon) = 0; + virtual void setMenu(QPlatformMenu *menu) = 0; + virtual void setVisible(bool isVisible) = 0; + virtual void setIsSeparator(bool isSeparator) = 0; + virtual void setFont(const QFont &font) = 0; + virtual void setRole(MenuRole role) = 0; + virtual void setCheckable(bool checkable) = 0; + virtual void setChecked(bool isChecked) = 0; +#if QT_CONFIG(shortcut) + virtual void setShortcut(const QKeySequence& shortcut) = 0; +#endif + virtual void setEnabled(bool enabled) = 0; + virtual void setIconSize(int size) = 0; + virtual void setNativeContents(WId item) { Q_UNUSED(item); } + virtual void setHasExclusiveGroup(bool hasExclusiveGroup) { Q_UNUSED(hasExclusiveGroup); } + +Q_SIGNALS: + void activated(); + void hovered(); + +private: + quintptr m_tag; +}; + +class Q_GUI_EXPORT QPlatformMenu : public QObject +{ +Q_OBJECT +public: + QPlatformMenu(); + + enum MenuType { DefaultMenu = 0, EditMenu }; + Q_ENUM(MenuType) + + virtual void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) = 0; + virtual void removeMenuItem(QPlatformMenuItem *menuItem) = 0; + virtual void syncMenuItem(QPlatformMenuItem *menuItem) = 0; + virtual void syncSeparatorsCollapsible(bool enable) = 0; + + virtual void setTag(quintptr tag); + virtual quintptr tag() const; + + virtual void setText(const QString &text) = 0; + virtual void setIcon(const QIcon &icon) = 0; + virtual void setEnabled(bool enabled) = 0; + virtual bool isEnabled() const { return true; } + virtual void setVisible(bool visible) = 0; + virtual void setMinimumWidth(int width) { Q_UNUSED(width); } + virtual void setFont(const QFont &font) { Q_UNUSED(font); } + virtual void setMenuType(MenuType type) { Q_UNUSED(type); } + + virtual void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) + { + Q_UNUSED(parentWindow); + Q_UNUSED(targetRect); + Q_UNUSED(item); + setVisible(true); + } + + virtual void dismiss() { } // Closes this and all its related menu popups + + virtual QPlatformMenuItem *menuItemAt(int position) const = 0; + virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const = 0; + + virtual QPlatformMenuItem *createMenuItem() const; + virtual QPlatformMenu *createSubMenu() const; +Q_SIGNALS: + void aboutToShow(); + void aboutToHide(); + +private: + quintptr m_tag; +}; + +class Q_GUI_EXPORT QPlatformMenuBar : public QObject +{ +Q_OBJECT +public: + virtual void insertMenu(QPlatformMenu *menu, QPlatformMenu *before) = 0; + virtual void removeMenu(QPlatformMenu *menu) = 0; + virtual void syncMenu(QPlatformMenu *menuItem) = 0; + virtual void handleReparent(QWindow *newParentWindow) = 0; + virtual QWindow *parentWindow() const { return nullptr; } + + virtual QPlatformMenu *menuForTag(quintptr tag) const = 0; + virtual QPlatformMenu *createMenu() const; +}; + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformmenu_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformmenu_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a74bfd1dfbe628fbccd15cbbed00d78641e1c3f4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformmenu_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMMENU_P_H +#define QPLATFORMMENU_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> + +#include <QtCore/qnativeinterface.h> + +QT_BEGIN_NAMESPACE + +// ----------------- QNativeInterface ----------------- + +#if !defined(Q_OS_MACOS) && defined(Q_QDOC) +typedef void NSMenu; +#else +QT_END_NAMESPACE +Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu); +QT_BEGIN_NAMESPACE +#endif + +namespace QNativeInterface::Private { + +#if defined(Q_OS_MACOS) || defined(Q_QDOC) +struct Q_GUI_EXPORT QCocoaMenu +{ + QT_DECLARE_NATIVE_INTERFACE(QCocoaMenu) + virtual NSMenu *nsMenu() const = 0; + virtual void setAsDockMenu() const = 0; +}; + +struct Q_GUI_EXPORT QCocoaMenuBar +{ + QT_DECLARE_NATIVE_INTERFACE(QCocoaMenuBar) + virtual NSMenu *nsMenu() const = 0; +}; +#endif + +} // QNativeInterface::Private + +QT_END_NAMESPACE + +#endif // QPLATFORMMENU_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformnativeinterface.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformnativeinterface.h new file mode 100644 index 0000000000000000000000000000000000000000..863e02e853a44de9394de18c46185c0428ca5f8b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformnativeinterface.h @@ -0,0 +1,68 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMNATIVEINTERFACE_H +#define QPLATFORMNATIVEINTERFACE_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtGui/qwindowdefs.h> +#include <QtCore/QObject> +#include <QtCore/QVariant> + +QT_BEGIN_NAMESPACE + + +class QOpenGLContext; +class QScreen; +class QWindow; +class QPlatformWindow; +class QBackingStore; + +class Q_GUI_EXPORT QPlatformNativeInterface : public QObject +{ + Q_OBJECT + Q_MOC_INCLUDE(<qpa/qplatformwindow.h>) +public: + virtual void *nativeResourceForIntegration(const QByteArray &resource); + virtual void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context); + virtual void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen); + virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window); + virtual void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore); +#ifndef QT_NO_CURSOR + virtual void *nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor); +#endif + + typedef void * (*NativeResourceForIntegrationFunction)(); + typedef void * (*NativeResourceForContextFunction)(QOpenGLContext *context); + typedef void * (*NativeResourceForScreenFunction)(QScreen *screen); + typedef void * (*NativeResourceForWindowFunction)(QWindow *window); + typedef void * (*NativeResourceForBackingStoreFunction)(QBackingStore *backingStore); + virtual NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource); + virtual NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource); + virtual NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource); + virtual NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource); + virtual NativeResourceForBackingStoreFunction nativeResourceFunctionForBackingStore(const QByteArray &resource); + + virtual QFunctionPointer platformFunction(const QByteArray &function) const; + + virtual QVariantMap windowProperties(QPlatformWindow *window) const; + virtual QVariant windowProperty(QPlatformWindow *window, const QString &name) const; + virtual QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const; + virtual void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value); + +Q_SIGNALS: + void windowPropertyChanged(QPlatformWindow *window, const QString &propertyName); +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMNATIVEINTERFACE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformoffscreensurface.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformoffscreensurface.h new file mode 100644 index 0000000000000000000000000000000000000000..2a851994bd138598c541bb620e8860a9eaf07380 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformoffscreensurface.h @@ -0,0 +1,65 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMOFFSCREENSURFACE_H +#define QPLATFORMOFFSCREENSURFACE_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include "qplatformsurface.h" + +#include <QtGui/qoffscreensurface.h> +#include <QtCore/qscopedpointer.h> + +#include <QtCore/qnativeinterface.h> + +QT_BEGIN_NAMESPACE + +class QOffscreenSurface; +class QPlatformScreen; +class QPlatformOffscreenSurfacePrivate; + +class Q_GUI_EXPORT QPlatformOffscreenSurface : public QPlatformSurface +{ + Q_DECLARE_PRIVATE(QPlatformOffscreenSurface) +public: + explicit QPlatformOffscreenSurface(QOffscreenSurface *offscreenSurface); + ~QPlatformOffscreenSurface() override; + + QOffscreenSurface *offscreenSurface() const; + + QPlatformScreen *screen() const override; + + virtual QSurfaceFormat format() const override; + virtual bool isValid() const; + +protected: + QScopedPointer<QPlatformOffscreenSurfacePrivate> d_ptr; + friend class QOffscreenSurfacePrivate; +private: + Q_DISABLE_COPY(QPlatformOffscreenSurface) +}; + +namespace QNativeInterface::Private { + +#if defined(Q_OS_ANDROID) +struct Q_GUI_EXPORT QAndroidOffScreenIntegration +{ + QT_DECLARE_NATIVE_INTERFACE(QAndroidOffScreenIntegration) + virtual QOffscreenSurface *createOffscreenSurface(ANativeWindow *nativeSurface) const = 0; +}; +#endif + +} // QNativeInterface::Private + + +QT_END_NAMESPACE + +#endif // QPLATFORMOFFSCREENSURFACE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformopenglcontext.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformopenglcontext.h new file mode 100644 index 0000000000000000000000000000000000000000..1b3c8899d521d603df4118fe2cd2b6e9da4c8e08 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformopenglcontext.h @@ -0,0 +1,115 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMOPENGLCONTEXT_H +#define QPLATFORMOPENGLCONTEXT_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qnamespace.h> + +#ifndef QT_NO_OPENGL + +#include <QtGui/qsurfaceformat.h> +#include <QtGui/qwindow.h> +#include <QtGui/qopengl.h> +#include <QtGui/qopenglcontext.h> + +#include <QtCore/qnativeinterface.h> + +QT_BEGIN_NAMESPACE + + +class QPlatformOpenGLContextPrivate; + +class Q_GUI_EXPORT QPlatformOpenGLContext +{ + Q_DECLARE_PRIVATE(QPlatformOpenGLContext) +public: + QPlatformOpenGLContext(); + virtual ~QPlatformOpenGLContext(); + + virtual void initialize(); + + virtual QSurfaceFormat format() const = 0; + + virtual void swapBuffers(QPlatformSurface *surface) = 0; + + virtual GLuint defaultFramebufferObject(QPlatformSurface *surface) const; + + virtual bool makeCurrent(QPlatformSurface *surface) = 0; + virtual void doneCurrent() = 0; + + virtual void beginFrame(); + virtual void endFrame(); + + virtual bool isSharing() const { return false; } + virtual bool isValid() const { return true; } + + virtual QFunctionPointer getProcAddress(const char *procName) = 0; + + QOpenGLContext *context() const; + + static bool parseOpenGLVersion(const QByteArray &versionString, int &major, int &minor); + +private: + friend class QOpenGLContext; + friend class QOpenGLContextPrivate; + + QScopedPointer<QPlatformOpenGLContextPrivate> d_ptr; + + void setContext(QOpenGLContext *context); + + Q_DISABLE_COPY(QPlatformOpenGLContext) +}; + +namespace QNativeInterface::Private { + +#if defined(Q_OS_MACOS) +struct Q_GUI_EXPORT QCocoaGLIntegration +{ + QT_DECLARE_NATIVE_INTERFACE(QCocoaGLIntegration) + virtual QOpenGLContext *createOpenGLContext(NSOpenGLContext *, QOpenGLContext *shareContext) const = 0; +}; +#endif + +#if defined(Q_OS_WIN) +struct Q_GUI_EXPORT QWindowsGLIntegration +{ + QT_DECLARE_NATIVE_INTERFACE(QWindowsGLIntegration) + virtual HMODULE openGLModuleHandle() const = 0; + virtual QOpenGLContext *createOpenGLContext(HGLRC context, HWND window, QOpenGLContext *shareContext) const = 0; +}; +#endif + +#if QT_CONFIG(xcb_glx_plugin) +struct Q_GUI_EXPORT QGLXIntegration +{ + QT_DECLARE_NATIVE_INTERFACE(QGLXIntegration) + virtual QOpenGLContext *createOpenGLContext(GLXContext context, void *visualInfo, QOpenGLContext *shareContext) const = 0; +}; +#endif + +#if QT_CONFIG(egl) +struct Q_GUI_EXPORT QEGLIntegration +{ + QT_DECLARE_NATIVE_INTERFACE(QEGLIntegration) + virtual QOpenGLContext *createOpenGLContext(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext) const = 0; +}; +#endif + +} // QNativeInterface::Private + +QT_END_NAMESPACE + +#endif // QT_NO_OPENGL + +#endif // QPLATFORMOPENGLCONTEXT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformpixmap.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformpixmap.h new file mode 100644 index 0000000000000000000000000000000000000000..5db935650fbb901c76bffff639bfa911e4f17660 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformpixmap.h @@ -0,0 +1,134 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMPIXMAP_H +#define QPLATFORMPIXMAP_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtGui/qpixmap.h> +#include <QtCore/qatomic.h> + +QT_BEGIN_NAMESPACE + + +class QImageReader; + +class Q_GUI_EXPORT QPlatformPixmap +{ +public: + enum PixelType { + // WARNING: Do not change the first two + // Must match QPixmap::Type + PixmapType, BitmapType + }; + + enum ClassId { RasterClass, DirectFBClass, + BlitterClass, Direct2DClass, + X11Class, CustomClass = 1024 }; + + QPlatformPixmap(PixelType pixelType, int classId); + virtual ~QPlatformPixmap(); + + virtual QPlatformPixmap *createCompatiblePlatformPixmap() const; + + virtual void resize(int width, int height) = 0; + virtual void fromImage(const QImage &image, + Qt::ImageConversionFlags flags) = 0; + virtual void fromImageInPlace(QImage &image, + Qt::ImageConversionFlags flags) + { + fromImage(image, flags); + } + + virtual void fromImageReader(QImageReader *imageReader, + Qt::ImageConversionFlags flags); + + virtual bool fromFile(const QString &filename, const char *format, + Qt::ImageConversionFlags flags); + virtual bool fromData(const uchar *buffer, uint len, const char *format, + Qt::ImageConversionFlags flags); + + virtual void copy(const QPlatformPixmap *data, const QRect &rect); + virtual bool scroll(int dx, int dy, const QRect &rect); + + virtual int metric(QPaintDevice::PaintDeviceMetric metric) const = 0; + virtual void fill(const QColor &color) = 0; + + virtual QBitmap mask() const; + virtual void setMask(const QBitmap &mask); + + virtual bool hasAlphaChannel() const = 0; + virtual QPixmap transformed(const QTransform &matrix, + Qt::TransformationMode mode) const; + + virtual QImage toImage() const = 0; + virtual QImage toImage(const QRect &rect) const; + virtual QPaintEngine* paintEngine() const = 0; + + inline int serialNumber() const { return ser_no; } + + inline PixelType pixelType() const { return type; } + inline ClassId classId() const { return static_cast<ClassId>(id); } + + virtual qreal devicePixelRatio() const = 0; + virtual void setDevicePixelRatio(qreal scaleFactor) = 0; + + virtual QImage* buffer(); + + inline int width() const { return w; } + inline int height() const { return h; } + inline int colorCount() const { return metric(QPaintDevice::PdmNumColors); } + inline int depth() const { return d; } + inline bool isNull() const { return is_null; } + inline qint64 cacheKey() const { + int classKey = id; + if (classKey >= 1024) + classKey = -(classKey >> 10); + return ((((qint64) classKey) << 56) + | (((qint64) ser_no) << 32) + | ((qint64) detach_no)); + } + + static QPlatformPixmap *create(int w, int h, PixelType type); + +protected: + + void setSerialNumber(int serNo); + void setDetachNumber(int detNo); + int w; + int h; + int d; + bool is_null; + +private: + friend class QPixmap; + friend class QX11PlatformPixmap; + friend class QImagePixmapCleanupHooks; // Needs to set is_cached + friend class QOpenGLTextureCache; //Needs to check the reference count + friend class QExplicitlySharedDataPointer<QPlatformPixmap>; + + QAtomicInt ref; + int detach_no; + + PixelType type; + int id; + int ser_no; + uint is_cached; +}; + +# define QT_XFORM_TYPE_MSBFIRST 0 +# define QT_XFORM_TYPE_LSBFIRST 1 +Q_GUI_EXPORT bool qt_xForm_helper(const QTransform&, int, int, int, uchar*, qsizetype, int, int, const uchar*, qsizetype, int, int); + +QT_END_NAMESPACE + +#endif // QPLATFORMPIXMAP_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformscreen.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformscreen.h new file mode 100644 index 0000000000000000000000000000000000000000..ce0a0ca50aeb52f72d310fd3a0edf1474ad4874e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformscreen.h @@ -0,0 +1,162 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMSCREEN_H +#define QPLATFORMSCREEN_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qmetatype.h> +#include <QtCore/qnamespace.h> +#include <QtCore/qcoreevent.h> +#include <QtCore/qvariant.h> +#include <QtCore/qrect.h> +#include <QtCore/qobject.h> + +#include <QtGui/qcolorspace.h> +#include <QtGui/qcursor.h> +#include <QtGui/qimage.h> +#include <QtGui/qwindowdefs.h> +#include <qpa/qplatformpixmap.h> + +QT_BEGIN_NAMESPACE + + +class QPlatformBackingStore; +class QPlatformScreenPrivate; +class QPlatformWindow; +class QPlatformCursor; +class QScreen; +class QSurfaceFormat; + +typedef QPair<qreal, qreal> QDpi; + + +class Q_GUI_EXPORT QPlatformScreen +{ + Q_GADGET + Q_DECLARE_PRIVATE(QPlatformScreen) + +public: + Q_DISABLE_COPY_MOVE(QPlatformScreen) + + enum SubpixelAntialiasingType { // copied from qfontengine_p.h since we can't include private headers + Subpixel_None, + Subpixel_RGB, + Subpixel_BGR, + Subpixel_VRGB, + Subpixel_VBGR + }; + + enum PowerState { + PowerStateOn, + PowerStateStandby, + PowerStateSuspend, + PowerStateOff + }; + + struct Mode { + QSize size; + qreal refreshRate; + }; + + QPlatformScreen(); + virtual ~QPlatformScreen(); + + virtual bool isPlaceholder() const { return false; } + + virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; + + virtual QRect geometry() const = 0; + virtual QRect availableGeometry() const {return geometry();} + + virtual int depth() const = 0; + virtual QImage::Format format() const = 0; + virtual QColorSpace colorSpace() const { return QColorSpace::SRgb; } + + virtual QSizeF physicalSize() const; + virtual QDpi logicalDpi() const; + virtual QDpi logicalBaseDpi() const; + virtual qreal devicePixelRatio() const; + + virtual qreal refreshRate() const; + + virtual Qt::ScreenOrientation nativeOrientation() const; + virtual Qt::ScreenOrientation orientation() const; + + virtual QWindow *topLevelAt(const QPoint &point) const; + QWindowList windows() const; + + virtual QList<QPlatformScreen *> virtualSiblings() const; + const QPlatformScreen *screenForPosition(const QPoint &point) const; + + QScreen *screen() const; + + //jl: should this function be in QPlatformIntegration + //jl: maybe screenForWindow is a better name? + static QPlatformScreen *platformScreenForWindow(const QWindow *window); + + virtual QString name() const { return QString(); } + + virtual QString manufacturer() const; + virtual QString model() const; + virtual QString serialNumber() const; + + virtual QPlatformCursor *cursor() const; + virtual SubpixelAntialiasingType subpixelAntialiasingTypeHint() const; + + virtual PowerState powerState() const; + virtual void setPowerState(PowerState state); + + virtual QList<Mode> modes() const; + + virtual int currentMode() const; + virtual int preferredMode() const; + + static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b); + static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target); + static QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect); + + static QDpi overrideDpi(const QDpi &in); + +protected: + void resizeMaximizedWindows(); + + QScopedPointer<QPlatformScreenPrivate> d_ptr; + +private: + friend class QScreen; +}; + +// Qt doesn't currently support running with no platform screen +// QPA plugins can use this class to create a fake screen +class Q_GUI_EXPORT QPlatformPlaceholderScreen : public QPlatformScreen { +public: + // virtualSibling can be passed in to make the placeholder a sibling with other screens during + // the transitioning phase when the real screen is about to be removed, or the first real screen + // is about to be added. This is useful because Qt will currently recreate (but now show!) + // windows when they are moved from one virtual desktop to another, so if the last monitor is + // unplugged, then plugged in again, windows will be hidden unless the placeholder belongs to + // the same virtual desktop as the other screens. + QPlatformPlaceholderScreen(bool virtualSibling = true) : m_virtualSibling(virtualSibling) {} + bool isPlaceholder() const override { return true; } + QRect geometry() const override { return QRect(); } + QRect availableGeometry() const override { return QRect(); } + int depth() const override { return 32; } + QImage::Format format() const override { return QImage::Format::Format_RGB32; } + QList<QPlatformScreen *> virtualSiblings() const override; +private: + bool m_virtualSibling = true; +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMSCREEN_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformscreen_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformscreen_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d7694b8d17dbd4abcf4c668f770383e48c6da2db --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformscreen_p.h @@ -0,0 +1,74 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMSCREEN_P_H +#define QPLATFORMSCREEN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> + +#include <QtCore/qpointer.h> +#include <QtCore/qnativeinterface.h> + +QT_BEGIN_NAMESPACE + +class QScreen; + +class QPlatformScreenPrivate +{ +public: + QPointer<QScreen> screen; +}; + +// ----------------- QNativeInterface ----------------- + +namespace QNativeInterface::Private { + +#if QT_CONFIG(xcb) || defined(Q_QDOC) +struct Q_GUI_EXPORT QXcbScreen +{ + QT_DECLARE_NATIVE_INTERFACE(QXcbScreen, 1, QScreen) + virtual int virtualDesktopNumber() const = 0; +}; +#endif + +#if QT_CONFIG(vsp2) || defined(Q_QDOC) +struct Q_GUI_EXPORT QVsp2Screen +{ + QT_DECLARE_NATIVE_INTERFACE(QVsp2Screen, 1, QScreen) + virtual int addLayer(int dmabufFd, const QSize &size, const QPoint &position, uint drmPixelFormat, uint bytesPerLine) = 0; + virtual void setLayerBuffer(int id, int dmabufFd) = 0; + virtual void setLayerPosition(int id, const QPoint &position) = 0; + virtual void setLayerAlpha(int id, qreal alpha) = 0; + virtual bool removeLayer(int id) = 0; + virtual void addBlendListener(void (*callback)()) = 0; +}; +#endif + +#if defined(Q_OS_WEBOS) || defined(Q_QDOC) +struct Q_GUI_EXPORT QWebOSScreen +{ + QT_DECLARE_NATIVE_INTERFACE(QWebOSScreen, 1, QScreen) + virtual int addLayer(void *gbm_bo, const QRectF &geometry) = 0; + virtual void setLayerBuffer(int id, void *gbm_bo) = 0; + virtual void setLayerGeometry(int id, const QRectF &geometry) = 0; + virtual void setLayerAlpha(int id, qreal alpha) = 0; + virtual bool removeLayer(int id) = 0; + virtual void addFlipListener(void (*callback)()) = 0; +}; +#endif +} // QNativeInterface::Private + +QT_END_NAMESPACE + +#endif // QPLATFORMSCREEN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformservices.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformservices.h new file mode 100644 index 0000000000000000000000000000000000000000..d76f5542718de65e2a3960148be423206e79500d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformservices.h @@ -0,0 +1,58 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMSERVICES_H +#define QPLATFORMSERVICES_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qobject.h> + +QT_BEGIN_NAMESPACE + +class QUrl; +class QWindow; + +class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject +{ + Q_OBJECT +public: + using QObject::QObject; + virtual void pickColor() = 0; +Q_SIGNALS: + void colorPicked(const QColor &color); +}; + +class Q_GUI_EXPORT QPlatformServices +{ +public: + Q_DISABLE_COPY_MOVE(QPlatformServices) + + enum Capability { + ColorPicking, + }; + + QPlatformServices(); + virtual ~QPlatformServices() { } + + virtual bool openUrl(const QUrl &url); + virtual bool openDocument(const QUrl &url); + + virtual QByteArray desktopEnvironment() const; + + virtual bool hasCapability(Capability capability) const; + + virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr); +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMSERVICES_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsessionmanager.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsessionmanager.h new file mode 100644 index 0000000000000000000000000000000000000000..a6dde7db30bafdbcb0e53c9d1f7528f76e53b578 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsessionmanager.h @@ -0,0 +1,76 @@ +// Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch> +// Copyright (C) 2013 Teo Mrnjavac <teo@kde.org> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMSESSIONMANAGER_H +#define QPLATFORMSESSIONMANAGER_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qmetatype.h> +#include <QtCore/qnamespace.h> + +#include <QtGui/qsessionmanager.h> + +#ifndef QT_NO_SESSIONMANAGER + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QPlatformSessionManager +{ +public: + Q_DISABLE_COPY_MOVE(QPlatformSessionManager) + + explicit QPlatformSessionManager(const QString &id, const QString &key); + virtual ~QPlatformSessionManager(); + + virtual QString sessionId() const; + virtual QString sessionKey() const; + + virtual bool allowsInteraction(); + virtual bool allowsErrorInteraction(); + virtual void release(); + + virtual void cancel(); + + virtual void setRestartHint(QSessionManager::RestartHint restartHint); + virtual QSessionManager::RestartHint restartHint() const; + + virtual void setRestartCommand(const QStringList &command); + virtual QStringList restartCommand() const; + virtual void setDiscardCommand(const QStringList &command); + virtual QStringList discardCommand() const; + + virtual void setManagerProperty(const QString &name, const QString &value); + virtual void setManagerProperty(const QString &name, const QStringList &value); + + virtual bool isPhase2() const; + virtual void requestPhase2(); + + void appCommitData(); + void appSaveState(); + +protected: + QString m_sessionId; + QString m_sessionKey; + +private: + QStringList m_restartCommand; + QStringList m_discardCommand; + QSessionManager::RestartHint m_restartHint; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_SESSIONMANAGER + +#endif // QPLATFORMSESSIONMANAGER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsharedgraphicscache.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsharedgraphicscache.h new file mode 100644 index 0000000000000000000000000000000000000000..ed14484a150bb2bb4680a2c43cd9ebf0b3579e53 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsharedgraphicscache.h @@ -0,0 +1,66 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMSHAREDGRAPHICSCACHE_H +#define QPLATFORMSHAREDGRAPHICSCACHE_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qobject.h> +#include <QtGui/qimage.h> + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QPlatformSharedGraphicsCache: public QObject +{ + Q_OBJECT +public: + enum PixelFormat + { + Alpha8 + }; + + enum BufferType + { + OpenGLTexture + }; + + explicit QPlatformSharedGraphicsCache(QObject *parent = nullptr) : QObject(parent) {} + + virtual void beginRequestBatch() = 0; + virtual void ensureCacheInitialized(const QByteArray &cacheId, BufferType bufferType, + PixelFormat pixelFormat) = 0; + virtual void requestItems(const QByteArray &cacheId, const QList<quint32> &itemIds) = 0; + virtual void insertItems(const QByteArray &cacheId, const QList<quint32> &itemIds, + const QList<QImage> &items) = 0; + virtual void releaseItems(const QByteArray &cacheId, const QList<quint32> &itemIds) = 0; + virtual void endRequestBatch() = 0; + + virtual bool requestBatchStarted() const = 0; + + virtual uint textureIdForBuffer(void *bufferId) = 0; + virtual void referenceBuffer(void *bufferId) = 0; + virtual bool dereferenceBuffer(void *bufferId) = 0; + virtual QSize sizeOfBuffer(void *bufferId) = 0; + virtual void *eglImageForBuffer(void *bufferId) = 0; + +Q_SIGNALS: + void itemsMissing(const QByteArray &cacheId, const QList<quint32> &itemIds); + void itemsAvailable(const QByteArray &cacheId, void *bufferId, const QList<quint32> &itemIds, + const QList<QPoint> &positionsInBuffer); + void itemsInvalidated(const QByteArray &cacheId, const QList<quint32> &itemIds); + void itemsUpdated(const QByteArray &cacheId, void *bufferId, const QList<quint32> &itemIds, + const QList<QPoint> &positionsInBuffer); +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMSHAREDGRAPHICSCACHE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsurface.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsurface.h new file mode 100644 index 0000000000000000000000000000000000000000..a9adaab94a599fc5f75509f48800936e11aead3d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsurface.h @@ -0,0 +1,58 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMSURFACE_H +#define QPLATFORMSURFACE_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qnamespace.h> +#include <QtGui/qsurface.h> +#include <QtGui/qsurfaceformat.h> + +QT_BEGIN_NAMESPACE + +class QPlatformScreen; + +#ifndef QT_NO_DEBUG_STREAM +class QDebug; +#endif + +class Q_GUI_EXPORT QPlatformSurface +{ +public: + Q_DISABLE_COPY_MOVE(QPlatformSurface) + + virtual ~QPlatformSurface(); + virtual QSurfaceFormat format() const = 0; + + QSurface *surface() const; + virtual QPlatformScreen *screen() const = 0; + + static bool isRasterSurface(QSurface *surface); + +private: + explicit QPlatformSurface(QSurface *surface); + + QSurface *m_surface; + + friend class QPlatformWindow; + friend class QPlatformOffscreenSurface; +}; + + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QPlatformSurface *surface); +#endif + +QT_END_NAMESPACE + +#endif //QPLATFORMSURFACE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsystemtrayicon.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsystemtrayicon.h new file mode 100644 index 0000000000000000000000000000000000000000..5d57b0ee471ab55dda1db2569d92a95f70f921ad --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformsystemtrayicon.h @@ -0,0 +1,64 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2012 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMSYSTEMTRAYICON_H +#define QPLATFORMSYSTEMTRAYICON_H + +#include <QtGui/qtguiglobal.h> +#include <qpa/qplatformscreen.h> +#include "QtCore/qobject.h" + +#ifndef QT_NO_SYSTEMTRAYICON + +QT_BEGIN_NAMESPACE + +class QPlatformMenu; +class QIcon; +class QString; +class QRect; + +class Q_GUI_EXPORT QPlatformSystemTrayIcon : public QObject +{ + Q_OBJECT +public: + enum ActivationReason { + Unknown, + Context, + DoubleClick, + Trigger, + MiddleClick + }; + Q_ENUM(ActivationReason) + + enum MessageIcon { NoIcon, Information, Warning, Critical }; + Q_ENUM(MessageIcon) + + QPlatformSystemTrayIcon(); + ~QPlatformSystemTrayIcon(); + + virtual void init() = 0; + virtual void cleanup() = 0; + virtual void updateIcon(const QIcon &icon) = 0; + virtual void updateToolTip(const QString &tooltip) = 0; + virtual void updateMenu(QPlatformMenu *menu) = 0; + virtual QRect geometry() const = 0; + virtual void showMessage(const QString &title, const QString &msg, + const QIcon &icon, MessageIcon iconType, int msecs) = 0; + + virtual bool isSystemTrayAvailable() const = 0; + virtual bool supportsMessages() const = 0; + + virtual QPlatformMenu *createMenu() const; + +Q_SIGNALS: + void activated(QPlatformSystemTrayIcon::ActivationReason reason); + void contextMenuRequested(QPoint globalPos, const QPlatformScreen *screen); + void messageClicked(); +}; + +QT_END_NAMESPACE + +#endif // QT_NO_SYSTEMTRAYICON + +#endif // QSYSTEMTRAYICON_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformtheme.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformtheme.h new file mode 100644 index 0000000000000000000000000000000000000000..a088e6fa038b353ce6326d65a11fdf6a0c20093f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformtheme.h @@ -0,0 +1,337 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMTHEME_H +#define QPLATFORMTHEME_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/QObject> +#include <QtCore/QScopedPointer> +#if QT_CONFIG(shortcut) +# include <QtGui/QKeySequence> +#endif + +QT_BEGIN_NAMESPACE + +class QIcon; +class QIconEngine; +class QMenu; +class QMenuBar; +class QPlatformMenuItem; +class QPlatformMenu; +class QPlatformMenuBar; +class QPlatformDialogHelper; +class QPlatformSystemTrayIcon; +class QPlatformThemePrivate; +class QVariant; +class QPalette; +class QFont; +class QPixmap; +class QSizeF; +class QFileInfo; + +class Q_GUI_EXPORT QPlatformTheme +{ + Q_GADGET + Q_DECLARE_PRIVATE(QPlatformTheme) + +public: + Q_DISABLE_COPY_MOVE(QPlatformTheme) + + enum ThemeHint { + CursorFlashTime, + KeyboardInputInterval, + MouseDoubleClickInterval, + StartDragDistance, + StartDragTime, + KeyboardAutoRepeatRate, + PasswordMaskDelay, + StartDragVelocity, + TextCursorWidth, + DropShadow, + MaximumScrollBarDragDistance, + ToolButtonStyle, + ToolBarIconSize, + ItemViewActivateItemOnSingleClick, + SystemIconThemeName, + SystemIconFallbackThemeName, + IconThemeSearchPaths, + StyleNames, + WindowAutoPlacement, + DialogButtonBoxLayout, + DialogButtonBoxButtonsHaveIcons, + UseFullScreenForPopupMenu, + KeyboardScheme, + UiEffects, + SpellCheckUnderlineStyle, + TabFocusBehavior, + IconPixmapSizes, + PasswordMaskCharacter, + DialogSnapToDefaultButton, + ContextMenuOnMouseRelease, + MousePressAndHoldInterval, + MouseDoubleClickDistance, + WheelScrollLines, + TouchDoubleTapDistance, + ShowShortcutsInContextMenus, + IconFallbackSearchPaths, + MouseQuickSelectionThreshold, + InteractiveResizeAcrossScreens, + ShowDirectoriesFirst, + PreselectFirstFileInDirectory, + ButtonPressKeys, + SetFocusOnTouchRelease, + FlickStartDistance, + FlickMaximumVelocity, + FlickDeceleration, + MenuBarFocusOnAltPressRelease, + MouseCursorTheme, + MouseCursorSize, + UnderlineShortcut, + ShowIconsInMenus, + PreferFileIconFromTheme, + }; + Q_ENUM(ThemeHint) + + enum DialogType { + FileDialog, + ColorDialog, + FontDialog, + MessageDialog + }; + Q_ENUM(DialogType); + + enum Palette { + SystemPalette, + ToolTipPalette, + ToolButtonPalette, + ButtonPalette, + CheckBoxPalette, + RadioButtonPalette, + HeaderPalette, + ComboBoxPalette, + ItemViewPalette, + MessageBoxLabelPelette, + MessageBoxLabelPalette = MessageBoxLabelPelette, + TabBarPalette, + LabelPalette, + GroupBoxPalette, + MenuPalette, + MenuBarPalette, + TextEditPalette, + TextLineEditPalette, + NPalettes + }; + Q_ENUM(Palette) + + enum Font { + SystemFont, + MenuFont, + MenuBarFont, + MenuItemFont, + MessageBoxFont, + LabelFont, + TipLabelFont, + StatusBarFont, + TitleBarFont, + MdiSubWindowTitleFont, + DockWidgetTitleFont, + PushButtonFont, + CheckBoxFont, + RadioButtonFont, + ToolButtonFont, + ItemViewFont, + ListViewFont, + HeaderViewFont, + ListBoxFont, + ComboMenuItemFont, + ComboLineEditFont, + SmallFont, + MiniFont, + FixedFont, + GroupBoxTitleFont, + TabButtonFont, + EditorFont, + NFonts + }; + Q_ENUM(Font) + + enum StandardPixmap { // Keep in sync with QStyle::StandardPixmap + TitleBarMenuButton, + TitleBarMinButton, + TitleBarMaxButton, + TitleBarCloseButton, + TitleBarNormalButton, + TitleBarShadeButton, + TitleBarUnshadeButton, + TitleBarContextHelpButton, + DockWidgetCloseButton, + MessageBoxInformation, + MessageBoxWarning, + MessageBoxCritical, + MessageBoxQuestion, + DesktopIcon, + TrashIcon, + ComputerIcon, + DriveFDIcon, + DriveHDIcon, + DriveCDIcon, + DriveDVDIcon, + DriveNetIcon, + DirOpenIcon, + DirClosedIcon, + DirLinkIcon, + DirLinkOpenIcon, + FileIcon, + FileLinkIcon, + ToolBarHorizontalExtensionButton, + ToolBarVerticalExtensionButton, + FileDialogStart, + FileDialogEnd, + FileDialogToParent, + FileDialogNewFolder, + FileDialogDetailedView, + FileDialogInfoView, + FileDialogContentsView, + FileDialogListView, + FileDialogBack, + DirIcon, + DialogOkButton, + DialogCancelButton, + DialogHelpButton, + DialogOpenButton, + DialogSaveButton, + DialogCloseButton, + DialogApplyButton, + DialogResetButton, + DialogDiscardButton, + DialogYesButton, + DialogNoButton, + ArrowUp, + ArrowDown, + ArrowLeft, + ArrowRight, + ArrowBack, + ArrowForward, + DirHomeIcon, + CommandLink, + VistaShield, + BrowserReload, + BrowserStop, + MediaPlay, + MediaStop, + MediaPause, + MediaSkipForward, + MediaSkipBackward, + MediaSeekForward, + MediaSeekBackward, + MediaVolume, + MediaVolumeMuted, + LineEditClearButton, + DialogYesToAllButton, + DialogNoToAllButton, + DialogSaveAllButton, + DialogAbortButton, + DialogRetryButton, + DialogIgnoreButton, + RestoreDefaultsButton, + TabCloseButton, + NStandardPixmap, // assertion value for sync with QStyle::StandardPixmap + + // do not add any values below/greater than this + CustomBase = 0xf0000000 + }; + Q_ENUM(StandardPixmap) + + enum KeyboardSchemes + { + WindowsKeyboardScheme, + MacKeyboardScheme, + X11KeyboardScheme, + KdeKeyboardScheme, + GnomeKeyboardScheme, + CdeKeyboardScheme + }; + Q_ENUM(KeyboardSchemes) + + enum UiEffect + { + GeneralUiEffect = 0x1, + AnimateMenuUiEffect = 0x2, + FadeMenuUiEffect = 0x4, + AnimateComboUiEffect = 0x8, + AnimateTooltipUiEffect = 0x10, + FadeTooltipUiEffect = 0x20, + AnimateToolBoxUiEffect = 0x40, + HoverEffect = 0x80 + }; + Q_ENUM(UiEffect) + + enum IconOption { + DontUseCustomDirectoryIcons = 0x01 + }; + Q_DECLARE_FLAGS(IconOptions, IconOption) + + explicit QPlatformTheme(); + virtual ~QPlatformTheme(); + + virtual QPlatformMenuItem* createPlatformMenuItem() const; + virtual QPlatformMenu* createPlatformMenu() const; + virtual QPlatformMenuBar* createPlatformMenuBar() const; + virtual void showPlatformMenuBar() {} + + virtual bool usePlatformNativeDialog(DialogType type) const; + virtual QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const; + +#ifndef QT_NO_SYSTEMTRAYICON + virtual QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const; +#endif + + virtual Qt::ColorScheme colorScheme() const; + + virtual const QPalette *palette(Palette type = SystemPalette) const; + + virtual const QFont *font(Font type = SystemFont) const; + + virtual QVariant themeHint(ThemeHint hint) const; + + virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; + virtual QIcon fileIcon(const QFileInfo &fileInfo, + QPlatformTheme::IconOptions iconOptions = { }) const; + virtual QIconEngine *createIconEngine(const QString &iconName) const; + +#if QT_CONFIG(shortcut) + virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const; +#endif + + virtual QString standardButtonText(int button) const; +#if QT_CONFIG(shortcut) + virtual QKeySequence standardButtonShortcut(int button) const; +#endif + virtual void requestColorScheme(Qt::ColorScheme scheme); + + static QVariant defaultThemeHint(ThemeHint hint); + static QString defaultStandardButtonText(int button); + static QString removeMnemonics(const QString &original); + QString name() const; + +protected: + explicit QPlatformTheme(QPlatformThemePrivate *priv); + QScopedPointer<QPlatformThemePrivate> d_ptr; + +private: + friend class QPlatformThemeFactory; +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMTHEME_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformtheme_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformtheme_p.h new file mode 100644 index 0000000000000000000000000000000000000000..aeafceba6049cfc7ba2bcda109edd0bf1b40d862 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformtheme_p.h @@ -0,0 +1,50 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMTHEME_P_H +#define QPLATFORMTHEME_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#if QT_CONFIG(shortcut) +# include "private/qkeysequence_p.h" +#endif + +QT_BEGIN_NAMESPACE + +class QPalette; + +class Q_GUI_EXPORT QPlatformThemePrivate +{ +public: + QPlatformThemePrivate(); + + virtual ~QPlatformThemePrivate(); + + void initializeSystemPalette(); + +#if QT_CONFIG(shortcut) + static const QKeyBinding keyBindings[]; + static const uint numberOfKeyBindings; +#endif + + static unsigned currentKeyPlatforms(); + + QPalette *systemPalette; + + QString name; +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMTHEME_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformthemefactory_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformthemefactory_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fe14f6be7a4066962715568a5d1bcde95c65ecc2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformthemefactory_p.h @@ -0,0 +1,35 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMTHEMEFACTORY_H +#define QPLATFORMTHEMEFACTORY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtCore/qstringlist.h> + +QT_BEGIN_NAMESPACE + + +class QPlatformTheme; + +class Q_GUI_EXPORT QPlatformThemeFactory +{ +public: + static QStringList keys(const QString &platformPluginPath = QString()); + static QPlatformTheme *create(const QString &key, const QString &platformPluginPath = QString()); +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMTHEMEFACTORY_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformthemeplugin.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformthemeplugin.h new file mode 100644 index 0000000000000000000000000000000000000000..5dd24e39808046ed8e250806d5f0f4b051979f02 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformthemeplugin.h @@ -0,0 +1,38 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMTHEMEPLUGIN_H +#define QPLATFORMTHEMEPLUGIN_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qplugin.h> +#include <QtCore/qfactoryinterface.h> + +QT_BEGIN_NAMESPACE + +class QPlatformTheme; + +#define QPlatformThemeFactoryInterface_iid "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" + +class Q_GUI_EXPORT QPlatformThemePlugin : public QObject +{ + Q_OBJECT +public: + explicit QPlatformThemePlugin(QObject *parent = nullptr); + ~QPlatformThemePlugin(); + + virtual QPlatformTheme *create(const QString &key, const QStringList ¶mList) = 0; +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMTHEMEPLUGIN_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformvulkaninstance.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformvulkaninstance.h new file mode 100644 index 0000000000000000000000000000000000000000..f2bad1382387b62169f5dc30dea06cfff1919726 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformvulkaninstance.h @@ -0,0 +1,122 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMVULKANINSTANCE_H +#define QPLATFORMVULKANINSTANCE_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> + +#if QT_CONFIG(vulkan) || defined(Q_QDOC) + +#include <qvulkaninstance.h> + +QT_BEGIN_NAMESPACE + +class QPlatformVulkanInstancePrivate; + +class Q_GUI_EXPORT QPlatformVulkanInstance +{ + Q_DECLARE_PRIVATE(QPlatformVulkanInstance) + +public: + QPlatformVulkanInstance(); + virtual ~QPlatformVulkanInstance(); + + virtual QVulkanInfoVector<QVulkanLayer> supportedLayers() const = 0; + virtual QVulkanInfoVector<QVulkanExtension> supportedExtensions() const = 0; + virtual QVersionNumber supportedApiVersion() const = 0; + virtual void createOrAdoptInstance() = 0; + virtual bool isValid() const = 0; + virtual VkResult errorCode() const = 0; + virtual VkInstance vkInstance() const = 0; + virtual QByteArrayList enabledLayers() const = 0; + virtual QByteArrayList enabledExtensions() const = 0; + virtual PFN_vkVoidFunction getInstanceProcAddr(const char *name) = 0; + virtual bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) = 0; + virtual void presentAboutToBeQueued(QWindow *window); + virtual void presentQueued(QWindow *window); + virtual void setDebugFilters(const QList<QVulkanInstance::DebugFilter> &filters); + virtual void setDebugUtilsFilters(const QList<QVulkanInstance::DebugUtilsFilter> &filters); + virtual void beginFrame(QWindow *window); + virtual void endFrame(QWindow *window); + +private: + QScopedPointer<QPlatformVulkanInstancePrivate> d_ptr; + Q_DISABLE_COPY(QPlatformVulkanInstance) +}; + +QT_END_NAMESPACE + +#endif // QT_CONFIG(vulkan) + +#if defined(Q_QDOC) +/* + The following include file did not exist for clang-qdoc running + in macOS, but the classes are documented in qvulkanfunctions.cpp. + clang-qdoc must parse the class declarations in an include file, + or else it can't find a place to put the documentation for the + classes. Apparently these classes are created at build time if + Vulkan is present. + */ +#ifndef QVULKANFUNCTIONS_H +#define QVULKANFUNCTIONS_H + +#include <QtGui/qtguiglobal.h> + +#if QT_CONFIG(vulkan) || defined(Q_QDOC) + +#ifndef VK_NO_PROTOTYPES +#define VK_NO_PROTOTYPES +#endif +#include <vulkan/vulkan.h> + +#include <QtCore/qscopedpointer.h> + +QT_BEGIN_NAMESPACE + +class QVulkanInstance; +class QVulkanFunctionsPrivate; +class QVulkanDeviceFunctionsPrivate; + +class Q_GUI_EXPORT QVulkanFunctions +{ +public: + ~QVulkanFunctions(); + +private: + Q_DISABLE_COPY(QVulkanFunctions) + QVulkanFunctions(QVulkanInstance *inst); + + QScopedPointer<QVulkanFunctionsPrivate> d_ptr; + friend class QVulkanInstance; +}; + +class Q_GUI_EXPORT QVulkanDeviceFunctions +{ +public: + ~QVulkanDeviceFunctions(); + +private: + Q_DISABLE_COPY(QVulkanDeviceFunctions) + QVulkanDeviceFunctions(QVulkanInstance *inst, VkDevice device); + + QScopedPointer<QVulkanDeviceFunctionsPrivate> d_ptr; + friend class QVulkanInstance; +}; + +QT_END_NAMESPACE + +#endif // QT_CONFIG(vulkan) || defined(Q_QDOC) +#endif // QVULKANFUNCTIONS_H; +#endif // Q_QDOC + +#endif // QPLATFORMVULKANINSTANCE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformwindow.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformwindow.h new file mode 100644 index 0000000000000000000000000000000000000000..d3ca03438a81b978e54b2fc1f8f7a87c7e689186 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformwindow.h @@ -0,0 +1,142 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QPLATFORMWINDOW_H +#define QPLATFORMWINDOW_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qscopedpointer.h> +#include <QtCore/qrect.h> +#include <QtCore/qmargins.h> +#include <QtCore/qstring.h> +#include <QtGui/qwindowdefs.h> +#include <QtGui/qwindow.h> +#include <qpa/qplatformopenglcontext.h> +#include <qpa/qplatformsurface.h> + +QT_BEGIN_NAMESPACE + +#define QWINDOWSIZE_MAX ((1<<24)-1) + +class QPlatformScreen; +class QPlatformWindowPrivate; +class QScreen; +class QWindow; +class QIcon; +class QRegion; + +class Q_GUI_EXPORT QPlatformWindow : public QPlatformSurface +{ + Q_DECLARE_PRIVATE(QPlatformWindow) +public: + Q_DISABLE_COPY_MOVE(QPlatformWindow) + + explicit QPlatformWindow(QWindow *window); + ~QPlatformWindow() override; + + virtual void initialize(); + + QWindow *window() const; + QPlatformWindow *parent() const; + + QPlatformScreen *screen() const override; + + virtual QSurfaceFormat format() const override; + + virtual void setGeometry(const QRect &rect); + virtual QRect geometry() const; + virtual QRect normalGeometry() const; + + virtual QMargins frameMargins() const; + virtual QMargins safeAreaMargins() const; + + virtual void setVisible(bool visible); + virtual void setWindowFlags(Qt::WindowFlags flags); + virtual void setWindowState(Qt::WindowStates state); + + virtual WId winId() const; + virtual void setParent(const QPlatformWindow *window); + + virtual void setWindowTitle(const QString &title); + virtual void setWindowFilePath(const QString &title); + virtual void setWindowIcon(const QIcon &icon); + virtual bool close(); + virtual void raise(); + virtual void lower(); + + virtual bool isExposed() const; + virtual bool isActive() const; + virtual bool isAncestorOf(const QPlatformWindow *child) const; + virtual bool isEmbedded() const; + virtual bool isForeignWindow() const { return false; } + virtual QPoint mapToGlobal(const QPoint &pos) const; + QPointF mapToGlobalF(const QPointF &pos) const; + virtual QPoint mapFromGlobal(const QPoint &pos) const; + QPointF mapFromGlobalF(const QPointF &pos) const; + + virtual void propagateSizeHints(); + + virtual void setOpacity(qreal level); + virtual void setMask(const QRegion ®ion); + virtual void requestActivateWindow(); + + virtual void handleContentOrientationChange(Qt::ScreenOrientation orientation); + + virtual qreal devicePixelRatio() const; + + virtual bool setKeyboardGrabEnabled(bool grab); + virtual bool setMouseGrabEnabled(bool grab); + + virtual bool setWindowModified(bool modified); + + virtual bool windowEvent(QEvent *event); + + virtual bool startSystemResize(Qt::Edges edges); + virtual bool startSystemMove(); + + virtual void setFrameStrutEventsEnabled(bool enabled); + virtual bool frameStrutEventsEnabled() const; + + virtual void setAlertState(bool enabled); + virtual bool isAlertState() const; + + virtual void invalidateSurface(); + + static QRect initialGeometry(const QWindow *w, const QRect &initialGeometry, + int defaultWidth, int defaultHeight, + const QScreen **resultingScreenReturn = nullptr); + + virtual void requestUpdate(); + bool hasPendingUpdateRequest() const; + virtual void deliverUpdateRequest(); + + // Window property accessors. Platform plugins should use these + // instead of accessing QWindow directly. + QSize windowMinimumSize() const; + QSize windowMaximumSize() const; + QSize windowBaseSize() const; + QSize windowSizeIncrement() const; + QRect windowGeometry() const; + QRect windowFrameGeometry() const; + QRectF windowClosestAcceptableGeometry(const QRectF &nativeRect) const; + static QRectF closestAcceptableGeometry(const QWindow *w, const QRectF &nativeRect); + +protected: + static QString formatWindowTitle(const QString &title, const QString &separator); + QPlatformScreen *screenForGeometry(const QRect &newGeometry) const; + static QSize constrainWindowSize(const QSize &size); + + QScopedPointer<QPlatformWindowPrivate> d_ptr; +}; + +QT_END_NAMESPACE + +#endif //QPLATFORMWINDOW_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformwindow_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformwindow_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5a80fa59fbfa5a08b9e347cc756af8f6f2676c05 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qplatformwindow_p.h @@ -0,0 +1,144 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMWINDOW_P_H +#define QPLATFORMWINDOW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include <QtCore/qbasictimer.h> +#include <QtCore/qrect.h> +#include <QtCore/qnativeinterface.h> +#include <QtGui/qwindow.h> + +#if QT_CONFIG(wayland) +#include <any> +#include <QtCore/qobject.h> + +struct wl_surface; +#endif + +QT_BEGIN_NAMESPACE + +class QMargins; + +class QPlatformWindowPrivate +{ +public: + QRect rect; + QBasicTimer updateTimer; +}; + +// ----------------- QNativeInterface ----------------- + +namespace QNativeInterface::Private { + +#if defined(Q_OS_WASM) || defined(Q_QDOC) +struct Q_GUI_EXPORT QWasmWindow +{ + QT_DECLARE_NATIVE_INTERFACE(QWasmWindow, 1, QWindow) + virtual emscripten::val document() const = 0; + virtual emscripten::val clientArea() const = 0; +}; +#endif + +#if defined(Q_OS_MACOS) || defined(Q_QDOC) +struct Q_GUI_EXPORT QCocoaWindow +{ + QT_DECLARE_NATIVE_INTERFACE(QCocoaWindow, 1, QWindow) + virtual void setContentBorderEnabled(bool enable) = 0; + virtual QPoint bottomLeftClippedByNSWindowOffset() const = 0; + + virtual bool inLiveResize() const = 0; +}; +#endif + +#if QT_CONFIG(xcb) || defined(Q_QDOC) +struct Q_GUI_EXPORT QXcbWindow +{ + QT_DECLARE_NATIVE_INTERFACE(QXcbWindow, 1, QWindow) + + enum WindowType { + None = 0x000000, + Normal = 0x000001, + Desktop = 0x000002, + Dock = 0x000004, + Toolbar = 0x000008, + Menu = 0x000010, + Utility = 0x000020, + Splash = 0x000040, + Dialog = 0x000080, + DropDownMenu = 0x000100, + PopupMenu = 0x000200, + Tooltip = 0x000400, + Notification = 0x000800, + Combo = 0x001000, + Dnd = 0x002000, + KdeOverride = 0x004000 + }; + Q_DECLARE_FLAGS(WindowTypes, WindowType) + + virtual void setWindowType(WindowTypes type) = 0; + virtual void setWindowRole(const QString &role) = 0; + virtual void setWindowIconText(const QString &text) = 0; + virtual uint visualId() const = 0; +}; +#endif // xcb + +#if defined(Q_OS_WIN) || defined(Q_QDOC) +struct Q_GUI_EXPORT QWindowsWindow +{ + QT_DECLARE_NATIVE_INTERFACE(QWindowsWindow, 1, QWindow) + + virtual void setHasBorderInFullScreen(bool border) = 0; + virtual bool hasBorderInFullScreen() const = 0; + + virtual QMargins customMargins() const = 0; + virtual void setCustomMargins(const QMargins &margins) = 0; +}; +#endif // Q_OS_WIN + +#if QT_CONFIG(wayland) +struct Q_GUI_EXPORT QWaylandWindow : public QObject +{ + Q_OBJECT +public: + QT_DECLARE_NATIVE_INTERFACE(QWaylandWindow, 1, QWindow) + + virtual wl_surface *surface() const = 0; + virtual void setCustomMargins(const QMargins &margins) = 0; + virtual void requestXdgActivationToken(uint serial) = 0; + template<typename T> + T *surfaceRole() const + { + std::any anyRole = _surfaceRole(); + auto role = std::any_cast<T *>(&anyRole); + return role ? *role : nullptr; + } +Q_SIGNALS: + void surfaceCreated(); + void surfaceDestroyed(); + void surfaceRoleCreated(); + void surfaceRoleDestroyed(); + void xdgActivationTokenCreated(const QString &token); + +protected: + virtual std::any _surfaceRole() const = 0; +}; +#endif + +} // QNativeInterface::Private + +QT_END_NAMESPACE + +#endif // QPLATFORMWINDOW_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qwindowsysteminterface.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qwindowsysteminterface.h new file mode 100644 index 0000000000000000000000000000000000000000..0c6a1a1bc9336a4a3a6c6f1a3f1a9492a370aa6a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qwindowsysteminterface.h @@ -0,0 +1,282 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QWINDOWSYSTEMINTERFACE_H +#define QWINDOWSYSTEMINTERFACE_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/QTime> +#include <QtGui/qwindowdefs.h> +#include <QtCore/QEvent> +#include <QtCore/QAbstractEventDispatcher> +#include <QtGui/QScreen> +#include <QtGui/QWindow> +#include <QtCore/QWeakPointer> +#include <QtCore/QMutex> +#include <QtGui/QTouchEvent> +#include <QtCore/QEventLoop> +#include <QtGui/QVector2D> + +QT_BEGIN_NAMESPACE + +class QMimeData; +class QPointingDevice; +class QPlatformDragQtResponse; +class QPlatformDropQtResponse; + + +class Q_GUI_EXPORT QWindowSystemInterface +{ +public: + struct SynchronousDelivery {}; + struct AsynchronousDelivery {}; + struct DefaultDelivery {}; + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global, + Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, + Qt::KeyboardModifiers mods = Qt::NoModifier, + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleMouseEvent(QWindow *window, const QPointingDevice *device, + const QPointF &local, const QPointF &global, + Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, + Qt::KeyboardModifiers mods = Qt::NoModifier, + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleMouseEvent(QWindow *window, ulong timestamp, const QPointF &local, + const QPointF &global, Qt::MouseButtons state, + Qt::MouseButton button, QEvent::Type type, + Qt::KeyboardModifiers mods = Qt::NoModifier, + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleMouseEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, + const QPointF &local, const QPointF &global, Qt::MouseButtons state, + Qt::MouseButton button, QEvent::Type type, + Qt::KeyboardModifiers mods = Qt::NoModifier, + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); + + static bool handleShortcutEvent(QWindow *window, ulong timestamp, int k, Qt::KeyboardModifiers mods, quint32 nativeScanCode, + quint32 nativeVirtualKey, quint32 nativeModifiers, const QString & text = QString(), bool autorep = false, ushort count = 1); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleKeyEvent(QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleKeyEvent(QWindow *window, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1); + + static bool handleExtendedKeyEvent(QWindow *window, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, + quint32 nativeScanCode, quint32 nativeVirtualKey, + quint32 nativeModifiers, + const QString& text = QString(), bool autorep = false, + ushort count = 1); + static bool handleExtendedKeyEvent(QWindow *window, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, + quint32 nativeScanCode, quint32 nativeVirtualKey, + quint32 nativeModifiers, + const QString& text = QString(), bool autorep = false, + ushort count = 1); + static bool handleExtendedKeyEvent(QWindow *window, ulong timestamp, const QInputDevice *device, + QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, + quint32 nativeScanCode, quint32 nativeVirtualKey, + quint32 nativeModifiers, + const QString& text = QString(), bool autorep = false, + ushort count = 1); + static bool handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global, + QPoint pixelDelta, QPoint angleDelta, + Qt::KeyboardModifiers mods = Qt::NoModifier, + Qt::ScrollPhase phase = Qt::NoScrollPhase, + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); + static bool handleWheelEvent(QWindow *window, ulong timestamp, const QPointF &local, const QPointF &global, + QPoint pixelDelta, QPoint angleDelta, + Qt::KeyboardModifiers mods = Qt::NoModifier, + Qt::ScrollPhase phase = Qt::NoScrollPhase, + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized, + bool inverted = false); + static bool handleWheelEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, + const QPointF &local, const QPointF &global, + QPoint pixelDelta, QPoint angleDelta, + Qt::KeyboardModifiers mods = Qt::NoModifier, + Qt::ScrollPhase phase = Qt::NoScrollPhase, + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized, + bool inverted = false); + + // A very-temporary QPA touchpoint which gets converted to a QEventPoint as early as possible + // in QWindowSystemInterfacePrivate::fromNativeTouchPoints() + struct TouchPoint { + TouchPoint() : id(0), uniqueId(-1), pressure(0), rotation(0), state(QEventPoint::State::Stationary) { } + int id; // for application use + qint64 uniqueId; // for TUIO: object/token ID; otherwise empty + // TODO for TUIO 2.0: add registerPointerUniqueID(QPointingDeviceUniqueId) + QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1) + QRectF area; // dimensions of the elliptical contact patch, unrotated, and centered at position in screen coordinates + // width is the horizontal diameter, height is the vertical diameter + qreal pressure; // 0 to 1 + qreal rotation; // rotation applied to the elliptical contact patch + // 0 means pointing straight up; 0 if unknown (like QTabletEvent::rotation) + QEventPoint::State state; // Pressed|Updated|Stationary|Released + QVector2D velocity; // in screen coordinate system, pixels / seconds + QList<QPointF> rawPositions; // in screen coordinates + }; + + static void registerInputDevice(const QInputDevice *device); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleTouchEvent(QWindow *window, const QPointingDevice *device, + const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleTouchEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, + const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleTouchCancelEvent(QWindow *window, const QPointingDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleTouchCancelEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier); + + // rect is relative to parent + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleGeometryChange(QWindow *window, const QRect &newRect); + + // region is in local coordinates, do not confuse with geometry which is parent-relative + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleExposeEvent(QWindow *window, const QRegion ®ion); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handlePaintEvent(QWindow *window, const QRegion ®ion); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleCloseEvent(QWindow *window); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleEnterEvent(QWindow *window, const QPointF &local = QPointF(), const QPointF& global = QPointF()); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleLeaveEvent(QWindow *window); + static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF& global = QPointF()); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleFocusWindowChanged(QWindow *window, Qt::FocusReason r = Qt::OtherFocusReason); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState = -1); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleWindowDevicePixelRatioChanged(QWindow *window); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleSafeAreaMarginsChanged(QWindow *window); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleApplicationTermination(); + +#if QT_CONFIG(draganddrop) + static QPlatformDragQtResponse handleDrag(QWindow *window, const QMimeData *dropData, + const QPoint &p, Qt::DropActions supportedActions, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); + static QPlatformDropQtResponse handleDrop(QWindow *window, const QMimeData *dropData, + const QPoint &p, Qt::DropActions supportedActions, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); +#endif // QT_CONFIG(draganddrop) + + static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result); + + // Changes to the screen + static void handleScreenAdded(QPlatformScreen *screen, bool isPrimary = false); + static void handleScreenRemoved(QPlatformScreen *screen); + static void handlePrimaryScreenChanged(QPlatformScreen *newPrimary); + + static void handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation newOrientation); + static void handleScreenGeometryChange(QScreen *screen, const QRect &newGeometry, const QRect &newAvailableGeometry); + static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY); + static void handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleThemeChange(QWindow *window = nullptr); + + static void handleFileOpenEvent(const QString& fileName); + static void handleFileOpenEvent(const QUrl &url); + + static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, + const QPointF &local, const QPointF &global, + Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt, + qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers = Qt::NoModifier); + static bool handleTabletEvent(QWindow *window, const QPointingDevice *device, + const QPointF &local, const QPointF &global, + Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt, + qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers = Qt::NoModifier); + static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointF &local, const QPointF &global, + int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt, + qreal tangentialPressure, qreal rotation, int z, qint64 uid, + Qt::KeyboardModifiers modifiers = Qt::NoModifier); + static bool handleTabletEvent(QWindow *window, const QPointF &local, const QPointF &global, + int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt, + qreal tangentialPressure, qreal rotation, int z, qint64 uid, + Qt::KeyboardModifiers modifiers = Qt::NoModifier); + static bool handleTabletEnterLeaveProximityEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, + bool inProximity, const QPointF &local = QPointF(), const QPointF &global = QPointF(), + Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0, + qreal tangentialPressure = 0, qreal rotation = 0, int z = 0, + Qt::KeyboardModifiers modifiers = Qt::NoModifier); + static bool handleTabletEnterLeaveProximityEvent(QWindow *window, const QPointingDevice *device, + bool inProximity, const QPointF &local = QPointF(), const QPointF &global = QPointF(), + Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0, + qreal tangentialPressure = 0, qreal rotation = 0, int z = 0, + Qt::KeyboardModifiers modifiers = Qt::NoModifier); + + // The following 4 functions are deprecated (QTBUG-114560) + static bool handleTabletEnterProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid); + static void handleTabletEnterProximityEvent(int deviceType, int pointerType, qint64 uid); + static bool handleTabletLeaveProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid); + static void handleTabletLeaveProximityEvent(int deviceType, int pointerType, qint64 uid); + +#ifndef QT_NO_GESTURES + static bool handleGestureEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, + const QPointF &local, const QPointF &global, int fingerCount = 0); + static bool handleGestureEventWithRealValue(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, + qreal value, const QPointF &local, const QPointF &global, int fingerCount = 2); + static bool handleGestureEventWithValueAndDelta(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, qreal value, + const QPointF &delta, const QPointF &local, const QPointF &global, int fingerCount = 2); +#endif // QT_NO_GESTURES + + static void handlePlatformPanelEvent(QWindow *window); + +#ifndef QT_NO_CONTEXTMENU +#if QT_GUI_REMOVED_SINCE(6, 8) + static void handleContextMenuEvent(QWindow *window, bool mouseTriggered, + const QPoint &pos, const QPoint &globalPos, + Qt::KeyboardModifiers modifiers); +#endif + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static bool handleContextMenuEvent(QWindow *window, bool mouseTriggered, + const QPoint &pos, const QPoint &globalPos, + Qt::KeyboardModifiers modifiers); +#endif +#if QT_CONFIG(whatsthis) + static void handleEnterWhatsThisEvent(); +#endif + + // For event dispatcher implementations + static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags); + static void setSynchronousWindowSystemEvents(bool enable); + static bool flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents); + static void deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags); + static int windowSystemEventsQueued(); + static bool nonUserInputEventsQueued(); +}; + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p); +#endif + +QT_END_NAMESPACE + +#endif // QWINDOWSYSTEMINTERFACE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qwindowsysteminterface_p.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qwindowsysteminterface_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2966f8370bf30055a17b2152f12076a16335b4ed --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/qpa/qwindowsysteminterface_p.h @@ -0,0 +1,553 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QWINDOWSYSTEMINTERFACE_P_H +#define QWINDOWSYSTEMINTERFACE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qevent_p.h> +#include <QtGui/private/qtguiglobal_p.h> +#include "qwindowsysteminterface.h" + +#include <QElapsedTimer> +#include <QPointer> +#include <QMutex> +#include <QList> +#include <QWaitCondition> +#include <QAtomicInt> +#include <QLoggingCategory> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcQpaInputDevices); + +class QWindowSystemEventHandler; + +class Q_GUI_EXPORT QWindowSystemInterfacePrivate { +public: + enum EventType { + UserInputEvent = 0x100, + Close = UserInputEvent | 0x01, + GeometryChange = 0x02, + Enter = UserInputEvent | 0x03, + Leave = UserInputEvent | 0x04, + FocusWindow = 0x05, + WindowStateChanged = 0x06, + Mouse = UserInputEvent | 0x07, + Wheel = UserInputEvent | 0x09, + Key = UserInputEvent | 0x0a, + Touch = UserInputEvent | 0x0b, + ScreenOrientation = 0x0c, + ScreenGeometry = 0x0d, + ScreenAvailableGeometry = 0x0e, + ScreenLogicalDotsPerInch = 0x0f, + ScreenRefreshRate = 0x10, + ThemeChange = 0x11, + Expose = 0x12, + FileOpen = UserInputEvent | 0x13, + Tablet = UserInputEvent | 0x14, + TabletEnterProximity = UserInputEvent | 0x15, + TabletLeaveProximity = UserInputEvent | 0x16, + PlatformPanel = UserInputEvent | 0x17, + ContextMenu = UserInputEvent | 0x18, + EnterWhatsThisMode = UserInputEvent | 0x19, +#ifndef QT_NO_GESTURES + Gesture = UserInputEvent | 0x1a, +#endif + ApplicationStateChanged = 0x19, + FlushEvents = 0x20, + WindowScreenChanged = 0x21, + SafeAreaMarginsChanged = 0x22, + ApplicationTermination = 0x23, + Paint = 0x24, + WindowDevicePixelRatioChanged = 0x25, + }; + + class WindowSystemEvent { + public: + enum { + Synthetic = 0x1, + NullWindow = 0x2 + }; + + explicit WindowSystemEvent(EventType t) + : type(t), flags(0), eventAccepted(true) { } + virtual ~WindowSystemEvent() { } + + bool synthetic() const { return flags & Synthetic; } + bool nullWindow() const { return flags & NullWindow; } + + EventType type; + int flags; + bool eventAccepted; + }; + + class CloseEvent : public WindowSystemEvent { + public: + explicit CloseEvent(QWindow *w) + : WindowSystemEvent(Close), window(w) + { } + QPointer<QWindow> window; + }; + + class GeometryChangeEvent : public WindowSystemEvent { + public: + GeometryChangeEvent(QWindow *window, const QRect &newGeometry); + QPointer<QWindow> window; + QRect requestedGeometry; + QRect newGeometry; + }; + + class EnterEvent : public WindowSystemEvent { + public: + explicit EnterEvent(QWindow *enter, const QPointF &local, const QPointF &global) + : WindowSystemEvent(Enter), enter(enter), localPos(local), globalPos(global) + { } + QPointer<QWindow> enter; + const QPointF localPos; + const QPointF globalPos; + }; + + class LeaveEvent : public WindowSystemEvent { + public: + explicit LeaveEvent(QWindow *leave) + : WindowSystemEvent(Leave), leave(leave) + { } + QPointer<QWindow> leave; + }; + + class FocusWindowEvent : public WindowSystemEvent { + public: + explicit FocusWindowEvent(QWindow *focusedWindow, Qt::FocusReason r) + : WindowSystemEvent(FocusWindow), focused(focusedWindow), reason(r) + { } + QPointer<QWindow> focused; + Qt::FocusReason reason; + }; + + class WindowStateChangedEvent : public WindowSystemEvent { + public: + WindowStateChangedEvent(QWindow *_window, Qt::WindowStates _newState, Qt::WindowStates _oldState) + : WindowSystemEvent(WindowStateChanged), window(_window), newState(_newState), oldState(_oldState) + { } + + QPointer<QWindow> window; + Qt::WindowStates newState; + Qt::WindowStates oldState; + }; + + class WindowScreenChangedEvent : public WindowSystemEvent { + public: + WindowScreenChangedEvent(QWindow *w, QScreen *s) + : WindowSystemEvent(WindowScreenChanged), window(w), screen(s) + { } + + QPointer<QWindow> window; + QPointer<QScreen> screen; + }; + + class WindowDevicePixelRatioChangedEvent : public WindowSystemEvent { + public: + WindowDevicePixelRatioChangedEvent(QWindow *w) + : WindowSystemEvent(WindowDevicePixelRatioChanged), window(w) + { } + + QPointer<QWindow> window; + }; + + class SafeAreaMarginsChangedEvent : public WindowSystemEvent { + public: + SafeAreaMarginsChangedEvent(QWindow *w) + : WindowSystemEvent(SafeAreaMarginsChanged), window(w) + { } + + QPointer<QWindow> window; + }; + + class ApplicationStateChangedEvent : public WindowSystemEvent { + public: + ApplicationStateChangedEvent(Qt::ApplicationState newState, bool forcePropagate = false) + : WindowSystemEvent(ApplicationStateChanged), newState(newState), forcePropagate(forcePropagate) + { } + + Qt::ApplicationState newState; + bool forcePropagate; + }; + + class FlushEventsEvent : public WindowSystemEvent { + public: + FlushEventsEvent(QEventLoop::ProcessEventsFlags f = QEventLoop::AllEvents) + : WindowSystemEvent(FlushEvents) + , flags(f) + { } + QEventLoop::ProcessEventsFlags flags; + }; + + class UserEvent : public WindowSystemEvent { + public: + UserEvent(QWindow * w, ulong time, EventType t) + : WindowSystemEvent(t), window(w), timestamp(time) + { + if (!w) + flags |= NullWindow; + } + QPointer<QWindow> window; + unsigned long timestamp; + }; + + class InputEvent: public UserEvent { + public: + InputEvent(QWindow *w, ulong time, EventType t, Qt::KeyboardModifiers mods, const QInputDevice *dev) + : UserEvent(w, time, t), modifiers(mods), device(dev) {} + Qt::KeyboardModifiers modifiers; + const QInputDevice *device; + }; + + class PointerEvent : public InputEvent { + public: + PointerEvent(QWindow * w, ulong time, EventType t, Qt::KeyboardModifiers mods, const QPointingDevice *device) + : InputEvent(w, time, t, mods, device) {} + }; + + class MouseEvent : public PointerEvent { + public: + MouseEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global, + Qt::MouseButtons state, Qt::KeyboardModifiers mods, + Qt::MouseButton b, QEvent::Type type, + Qt::MouseEventSource src = Qt::MouseEventNotSynthesized, bool frame = false, + const QPointingDevice *device = QPointingDevice::primaryPointingDevice(), + int evPtId = -1) + : PointerEvent(w, time, Mouse, mods, device), localPos(local), globalPos(global), + buttons(state), source(src), nonClientArea(frame), button(b), buttonType(type), + eventPointId(evPtId) { } + + QPointF localPos; + QPointF globalPos; + Qt::MouseButtons buttons; + Qt::MouseEventSource source; + bool nonClientArea; + Qt::MouseButton button; + QEvent::Type buttonType; + int eventPointId; // from the original device if synth-mouse, otherwise -1 + }; + + class WheelEvent : public PointerEvent { + public: + WheelEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global, QPoint pixelD, QPoint angleD, int qt4D, Qt::Orientation qt4O, + Qt::KeyboardModifiers mods, Qt::ScrollPhase phase = Qt::NoScrollPhase, Qt::MouseEventSource src = Qt::MouseEventNotSynthesized, + bool inverted = false, const QPointingDevice *device = QPointingDevice::primaryPointingDevice()) + : PointerEvent(w, time, Wheel, mods, device), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D), + qt4Orientation(qt4O), localPos(local), globalPos(global), phase(phase), source(src), inverted(inverted) { } + QPoint pixelDelta; + QPoint angleDelta; + int qt4Delta; + Qt::Orientation qt4Orientation; + QPointF localPos; + QPointF globalPos; + Qt::ScrollPhase phase; + Qt::MouseEventSource source; + bool inverted; + }; + + class KeyEvent : public InputEvent { + public: + KeyEvent(QWindow *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, + const QString & text = QString(), bool autorep = false, ushort count = 1, + const QInputDevice *device = QInputDevice::primaryKeyboard()) + : InputEvent(w, time, Key, mods, device), source(nullptr), key(k), unicode(text), + repeat(autorep), repeatCount(count), keyType(t), + nativeScanCode(0), nativeVirtualKey(0), nativeModifiers(0) { } + KeyEvent(QWindow *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, + quint32 nativeSC, quint32 nativeVK, quint32 nativeMods, + const QString & text = QString(), bool autorep = false, ushort count = 1, + const QInputDevice *device = QInputDevice::primaryKeyboard()) + : InputEvent(w, time, Key, mods, device), source(nullptr), key(k), unicode(text), + repeat(autorep), repeatCount(count), keyType(t), + nativeScanCode(nativeSC), nativeVirtualKey(nativeVK), nativeModifiers(nativeMods) { } + const QInputDevice *source; + int key; + QString unicode; + bool repeat; + ushort repeatCount; + QEvent::Type keyType; + quint32 nativeScanCode; + quint32 nativeVirtualKey; + quint32 nativeModifiers; + }; + + class TouchEvent : public PointerEvent { + public: + TouchEvent(QWindow *w, ulong time, QEvent::Type t, const QPointingDevice *device, + const QList<QEventPoint> &p, Qt::KeyboardModifiers mods) + : PointerEvent(w, time, Touch, mods, device), points(p), touchType(t) { } + QList<QEventPoint> points; + QEvent::Type touchType; + }; + + class ScreenOrientationEvent : public WindowSystemEvent { + public: + ScreenOrientationEvent(QScreen *s, Qt::ScreenOrientation o) + : WindowSystemEvent(ScreenOrientation), screen(s), orientation(o) { } + QPointer<QScreen> screen; + Qt::ScreenOrientation orientation; + }; + + class ScreenGeometryEvent : public WindowSystemEvent { + public: + ScreenGeometryEvent(QScreen *s, const QRect &g, const QRect &ag) + : WindowSystemEvent(ScreenGeometry), screen(s), geometry(g), availableGeometry(ag) { } + QPointer<QScreen> screen; + QRect geometry; + QRect availableGeometry; + }; + + class ScreenLogicalDotsPerInchEvent : public WindowSystemEvent { + public: + ScreenLogicalDotsPerInchEvent(QScreen *s, qreal dx, qreal dy) + : WindowSystemEvent(ScreenLogicalDotsPerInch), screen(s), dpiX(dx), dpiY(dy) { } + QPointer<QScreen> screen; + qreal dpiX; + qreal dpiY; + }; + + class ScreenRefreshRateEvent : public WindowSystemEvent { + public: + ScreenRefreshRateEvent(QScreen *s, qreal r) + : WindowSystemEvent(ScreenRefreshRate), screen(s), rate(r) { } + QPointer<QScreen> screen; + qreal rate; + }; + + class ThemeChangeEvent : public WindowSystemEvent { + public: + explicit ThemeChangeEvent(QWindow * w) + : WindowSystemEvent(ThemeChange), window(w) { } + QPointer<QWindow> window; + }; + + class ExposeEvent : public WindowSystemEvent { + public: + ExposeEvent(QWindow *window, const QRegion ®ion); + QPointer<QWindow> window; + bool isExposed; + QRegion region; + }; + + class PaintEvent : public WindowSystemEvent { + public: + PaintEvent(QWindow *window, const QRegion ®ion) + : WindowSystemEvent(Paint), window(window), region(region) {} + QPointer<QWindow> window; + QRegion region; + }; + + class FileOpenEvent : public WindowSystemEvent { + public: + FileOpenEvent(const QString& fileName) + : WindowSystemEvent(FileOpen), url(QUrl::fromLocalFile(fileName)) + { } + FileOpenEvent(const QUrl &url) + : WindowSystemEvent(FileOpen), url(url) + { } + QUrl url; + }; + + class Q_GUI_EXPORT TabletEvent : public PointerEvent { + public: + // TODO take QPointingDevice* instead of types and IDs + static void handleTabletEvent(QWindow *w, const QPointF &local, const QPointF &global, + int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt, + qreal tangentialPressure, qreal rotation, int z, qint64 uid, + Qt::KeyboardModifiers modifiers = Qt::NoModifier); + static void setPlatformSynthesizesMouse(bool v); + + TabletEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global, + const QPointingDevice *device, Qt::MouseButtons b, qreal pressure, int xTilt, int yTilt, qreal tpressure, + qreal rotation, int z, Qt::KeyboardModifiers mods) + : PointerEvent(w, time, Tablet, mods, device), + buttons(b), local(local), global(global), + pressure(pressure), xTilt(xTilt), yTilt(yTilt), tangentialPressure(tpressure), + rotation(rotation), z(z) { } + Qt::MouseButtons buttons; + QPointF local; + QPointF global; + qreal pressure; + int xTilt; + int yTilt; + qreal tangentialPressure; + qreal rotation; + int z; + static bool platformSynthesizesMouse; + }; + + class TabletEnterProximityEvent : public PointerEvent { + public: + // TODO store more info: position and whatever else we can get on most platforms + TabletEnterProximityEvent(ulong time, const QPointingDevice *device) + : PointerEvent(nullptr, time, TabletEnterProximity, Qt::NoModifier, device) { } + }; + + class TabletLeaveProximityEvent : public PointerEvent { + public: + // TODO store more info: position and whatever else we can get on most platforms + TabletLeaveProximityEvent(ulong time, const QPointingDevice *device) + : PointerEvent(nullptr, time, TabletLeaveProximity, Qt::NoModifier, device) { } + }; + + class PlatformPanelEvent : public WindowSystemEvent { + public: + explicit PlatformPanelEvent(QWindow *w) + : WindowSystemEvent(PlatformPanel), window(w) { } + QPointer<QWindow> window; + }; + +#ifndef QT_NO_CONTEXTMENU + class ContextMenuEvent : public WindowSystemEvent { + public: + explicit ContextMenuEvent(QWindow *w, bool mouseTriggered, const QPoint &pos, + const QPoint &globalPos, Qt::KeyboardModifiers modifiers) + : WindowSystemEvent(ContextMenu), window(w), mouseTriggered(mouseTriggered), pos(pos), + globalPos(globalPos), modifiers(modifiers) { } + QPointer<QWindow> window; + bool mouseTriggered; + QPoint pos; // Only valid if triggered by mouse + QPoint globalPos; // Only valid if triggered by mouse + Qt::KeyboardModifiers modifiers; + }; +#endif + +#ifndef QT_NO_GESTURES + class GestureEvent : public PointerEvent { + public: + GestureEvent(QWindow *window, ulong time, Qt::NativeGestureType type, const QPointingDevice *dev, + int fingerCount, QPointF pos, QPointF globalPos, qreal realValue, QPointF delta) + : PointerEvent(window, time, Gesture, Qt::NoModifier, dev), type(type), pos(pos), globalPos(globalPos), + delta(delta), fingerCount(fingerCount), realValue(realValue), sequenceId(0), intValue(0) { } + Qt::NativeGestureType type; + QPointF pos; + QPointF globalPos; + QPointF delta; + int fingerCount; + // Mac + qreal realValue; + // Windows + ulong sequenceId; + quint64 intValue; + }; +#endif + + class WindowSystemEventList { + QList<WindowSystemEvent *> impl; + mutable QMutex mutex; + public: + WindowSystemEventList() : impl(), mutex() {} + ~WindowSystemEventList() { clear(); } + + void clear() + { const QMutexLocker locker(&mutex); qDeleteAll(impl); impl.clear(); } + void prepend(WindowSystemEvent *e) + { const QMutexLocker locker(&mutex); impl.prepend(e); } + WindowSystemEvent *takeFirstOrReturnNull() + { const QMutexLocker locker(&mutex); return impl.empty() ? nullptr : impl.takeFirst(); } + WindowSystemEvent *takeFirstNonUserInputOrReturnNull() + { + const QMutexLocker locker(&mutex); + for (int i = 0; i < impl.size(); ++i) + if (!(impl.at(i)->type & QWindowSystemInterfacePrivate::UserInputEvent)) + return impl.takeAt(i); + return nullptr; + } + bool nonUserInputEventsQueued() + { + const QMutexLocker locker(&mutex); + for (int i = 0; i < impl.size(); ++i) + if (!(impl.at(i)->type & QWindowSystemInterfacePrivate::UserInputEvent)) + return true; + return false; + } + void append(WindowSystemEvent *e) + { const QMutexLocker locker(&mutex); impl.append(e); } + qsizetype count() const + { const QMutexLocker locker(&mutex); return impl.size(); } + WindowSystemEvent *peekAtFirstOfType(EventType t) const + { + const QMutexLocker locker(&mutex); + for (int i = 0; i < impl.size(); ++i) { + if (impl.at(i)->type == t) + return impl.at(i); + } + return nullptr; + } + void remove(const WindowSystemEvent *e) + { + const QMutexLocker locker(&mutex); + for (int i = 0; i < impl.size(); ++i) { + if (impl.at(i) == e) { + delete impl.takeAt(i); + break; + } + } + } + private: + Q_DISABLE_COPY_MOVE(WindowSystemEventList) + }; + + static WindowSystemEventList windowSystemEventQueue; + + static qsizetype windowSystemEventsQueued(); + static bool nonUserInputEventsQueued(); + static WindowSystemEvent *getWindowSystemEvent(); + static WindowSystemEvent *getNonUserInputWindowSystemEvent(); + static WindowSystemEvent *peekWindowSystemEvent(EventType t); + static void removeWindowSystemEvent(WindowSystemEvent *event); + +public: + static QElapsedTimer eventTime; + static bool synchronousWindowSystemEvents; + static bool platformFiltersEvents; + + static QWaitCondition eventsFlushed; + static QMutex flushEventMutex; + static QAtomicInt eventAccepted; + + static QList<QEventPoint> + fromNativeTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points, + const QWindow *window, QEvent::Type *type = nullptr); + template<class EventPointList> + static QList<QWindowSystemInterface::TouchPoint> + toNativeTouchPoints(const EventPointList &pointList, const QWindow *window) + { + QList<QWindowSystemInterface::TouchPoint> newList; + newList.reserve(pointList.size()); + for (const auto &point : pointList) { + newList.append(toNativeTouchPoint(point, window)); + } + return newList; + } + static QWindowSystemInterface::TouchPoint + toNativeTouchPoint(const QEventPoint &point, const QWindow *window); + + static void installWindowSystemEventHandler(QWindowSystemEventHandler *handler); + static void removeWindowSystemEventhandler(QWindowSystemEventHandler *handler); + static QWindowSystemEventHandler *eventHandler; +}; + +class Q_GUI_EXPORT QWindowSystemEventHandler +{ +public: + virtual ~QWindowSystemEventHandler(); + virtual bool sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *event); +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSYSTEMINTERFACE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qrhi.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qrhi.h new file mode 100644 index 0000000000000000000000000000000000000000..bff9703a751d2bf70cf2073f8b987d12354f03c2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qrhi.h @@ -0,0 +1,2027 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRHI_H +#define QRHI_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the RHI API, with limited compatibility guarantees. +// Usage of this API may make your code source and binary incompatible with +// future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qsize.h> +#include <QtCore/qlist.h> +#include <QtCore/qvarlengtharray.h> +#include <QtCore/qthread.h> +#include <QtGui/qmatrix4x4.h> +#include <QtGui/qcolor.h> +#include <QtGui/qimage.h> +#include <functional> +#include <array> + +#include <rhi/qshader.h> + +QT_BEGIN_NAMESPACE + +class QWindow; +class QRhi; +class QRhiImplementation; +class QRhiBuffer; +class QRhiRenderBuffer; +class QRhiTexture; +class QRhiSampler; +class QRhiCommandBuffer; +class QRhiResourceUpdateBatch; +class QRhiResourceUpdateBatchPrivate; +class QRhiSwapChain; + +class Q_GUI_EXPORT QRhiDepthStencilClearValue +{ +public: + QRhiDepthStencilClearValue() = default; + QRhiDepthStencilClearValue(float d, quint32 s); + + float depthClearValue() const { return m_d; } + void setDepthClearValue(float d) { m_d = d; } + + quint32 stencilClearValue() const { return m_s; } + void setStencilClearValue(quint32 s) { m_s = s; } + +private: + float m_d = 1.0f; + quint32 m_s = 0; + + friend bool operator==(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept + { + return a.m_d == b.m_d && a.m_s == b.m_s; + } + + friend bool operator!=(const QRhiDepthStencilClearValue &a, const QRhiDepthStencilClearValue &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiDepthStencilClearValue &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_d); + seed = hash(seed, v.m_s); + return seed; + } +}; + +Q_DECLARE_TYPEINFO(QRhiDepthStencilClearValue, Q_RELOCATABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiDepthStencilClearValue &); +#endif + +class Q_GUI_EXPORT QRhiViewport +{ +public: + QRhiViewport() = default; + QRhiViewport(float x, float y, float w, float h, float minDepth = 0.0f, float maxDepth = 1.0f); + + std::array<float, 4> viewport() const { return m_rect; } + void setViewport(float x, float y, float w, float h) { + m_rect[0] = x; m_rect[1] = y; m_rect[2] = w; m_rect[3] = h; + } + + float minDepth() const { return m_minDepth; } + void setMinDepth(float minDepth) { m_minDepth = minDepth; } + + float maxDepth() const { return m_maxDepth; } + void setMaxDepth(float maxDepth) { m_maxDepth = maxDepth; } + +private: + std::array<float, 4> m_rect { { 0.0f, 0.0f, 0.0f, 0.0f } }; + float m_minDepth = 0.0f; + float m_maxDepth = 1.0f; + + friend bool operator==(const QRhiViewport &a, const QRhiViewport &b) noexcept + { + return a.m_rect == b.m_rect + && a.m_minDepth == b.m_minDepth + && a.m_maxDepth == b.m_maxDepth; + } + + friend bool operator!=(const QRhiViewport &a, const QRhiViewport &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiViewport &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_rect[0]); + seed = hash(seed, v.m_rect[1]); + seed = hash(seed, v.m_rect[2]); + seed = hash(seed, v.m_rect[3]); + seed = hash(seed, v.m_minDepth); + seed = hash(seed, v.m_maxDepth); + return seed; + } +}; + +Q_DECLARE_TYPEINFO(QRhiViewport, Q_RELOCATABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiViewport &); +#endif + +class Q_GUI_EXPORT QRhiScissor +{ +public: + QRhiScissor() = default; + QRhiScissor(int x, int y, int w, int h); + + std::array<int, 4> scissor() const { return m_rect; } + void setScissor(int x, int y, int w, int h) { + m_rect[0] = x; m_rect[1] = y; m_rect[2] = w; m_rect[3] = h; + } + +private: + std::array<int, 4> m_rect { { 0, 0, 0, 0 } }; + + friend bool operator==(const QRhiScissor &a, const QRhiScissor &b) noexcept + { + return a.m_rect == b.m_rect; + } + + friend bool operator!=(const QRhiScissor &a, const QRhiScissor &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiScissor &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_rect[0]); + seed = hash(seed, v.m_rect[1]); + seed = hash(seed, v.m_rect[2]); + seed = hash(seed, v.m_rect[3]); + return seed; + } +}; + +Q_DECLARE_TYPEINFO(QRhiScissor, Q_RELOCATABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiScissor &); +#endif + +class Q_GUI_EXPORT QRhiVertexInputBinding +{ +public: + enum Classification { + PerVertex, + PerInstance + }; + + QRhiVertexInputBinding() = default; + QRhiVertexInputBinding(quint32 stride, Classification cls = PerVertex, quint32 stepRate = 1); + + quint32 stride() const { return m_stride; } + void setStride(quint32 s) { m_stride = s; } + + Classification classification() const { return m_classification; } + void setClassification(Classification c) { m_classification = c; } + + quint32 instanceStepRate() const { return m_instanceStepRate; } + void setInstanceStepRate(quint32 rate) { m_instanceStepRate = rate; } + +private: + quint32 m_stride = 0; + Classification m_classification = PerVertex; + quint32 m_instanceStepRate = 1; + + friend bool operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept + { + return a.m_stride == b.m_stride + && a.m_classification == b.m_classification + && a.m_instanceStepRate == b.m_instanceStepRate; + } + + friend bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiVertexInputBinding &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_stride); + seed = hash(seed, v.m_classification); + seed = hash(seed, v.m_instanceStepRate); + return seed; + } +}; + +Q_DECLARE_TYPEINFO(QRhiVertexInputBinding, Q_RELOCATABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputBinding &); +#endif + +class Q_GUI_EXPORT QRhiVertexInputAttribute +{ +public: + enum Format { + Float4, + Float3, + Float2, + Float, + UNormByte4, + UNormByte2, + UNormByte, + UInt4, + UInt3, + UInt2, + UInt, + SInt4, + SInt3, + SInt2, + SInt, + Half4, + Half3, + Half2, + Half, + UShort4, + UShort3, + UShort2, + UShort, + SShort4, + SShort3, + SShort2, + SShort, + }; + + QRhiVertexInputAttribute() = default; + QRhiVertexInputAttribute(int binding, int location, Format format, quint32 offset, int matrixSlice = -1); + + int binding() const { return m_binding; } + void setBinding(int b) { m_binding = b; } + + int location() const { return m_location; } + void setLocation(int loc) { m_location = loc; } + + Format format() const { return m_format; } + void setFormat(Format f) { m_format = f; } + + quint32 offset() const { return m_offset; } + void setOffset(quint32 ofs) { m_offset = ofs; } + + int matrixSlice() const { return m_matrixSlice; } + void setMatrixSlice(int slice) { m_matrixSlice = slice; } + +private: + int m_binding = 0; + int m_location = 0; + Format m_format = Float4; + quint32 m_offset = 0; + int m_matrixSlice = -1; + + friend bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept + { + return a.m_binding == b.m_binding + && a.m_location == b.m_location + && a.m_format == b.m_format + && a.m_offset == b.m_offset; + // matrixSlice excluded intentionally + } + + friend bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiVertexInputAttribute &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_binding); + seed = hash(seed, v.m_location); + seed = hash(seed, v.m_format); + seed = hash(seed, v.m_offset); + return seed; + } +}; + +Q_DECLARE_TYPEINFO(QRhiVertexInputAttribute, Q_RELOCATABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputAttribute &); +#endif + +class Q_GUI_EXPORT QRhiVertexInputLayout +{ +public: + QRhiVertexInputLayout() = default; + + void setBindings(std::initializer_list<QRhiVertexInputBinding> list) { m_bindings = list; } + template<typename InputIterator> + void setBindings(InputIterator first, InputIterator last) + { + m_bindings.clear(); + std::copy(first, last, std::back_inserter(m_bindings)); + } + const QRhiVertexInputBinding *cbeginBindings() const { return m_bindings.cbegin(); } + const QRhiVertexInputBinding *cendBindings() const { return m_bindings.cend(); } + const QRhiVertexInputBinding *bindingAt(qsizetype index) const { return &m_bindings.at(index); } + qsizetype bindingCount() const { return m_bindings.count(); } + + void setAttributes(std::initializer_list<QRhiVertexInputAttribute> list) { m_attributes = list; } + template<typename InputIterator> + void setAttributes(InputIterator first, InputIterator last) + { + m_attributes.clear(); + std::copy(first, last, std::back_inserter(m_attributes)); + } + const QRhiVertexInputAttribute *cbeginAttributes() const { return m_attributes.cbegin(); } + const QRhiVertexInputAttribute *cendAttributes() const { return m_attributes.cend(); } + const QRhiVertexInputAttribute *attributeAt(qsizetype index) const { return &m_attributes.at(index); } + qsizetype attributeCount() const { return m_attributes.count(); } + +private: + QVarLengthArray<QRhiVertexInputBinding, 8> m_bindings; + QVarLengthArray<QRhiVertexInputAttribute, 8> m_attributes; + + friend bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept + { + return a.m_bindings == b.m_bindings && a.m_attributes == b.m_attributes; + } + + friend bool operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiVertexInputLayout &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_bindings); + seed = hash(seed, v.m_attributes); + return seed; + } + + friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &); +}; + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &); +#endif + +class Q_GUI_EXPORT QRhiShaderStage +{ +public: + enum Type { + Vertex, + TessellationControl, + TessellationEvaluation, + Geometry, + Fragment, + Compute + }; + + QRhiShaderStage() = default; + QRhiShaderStage(Type type, const QShader &shader, + QShader::Variant v = QShader::StandardShader); + + Type type() const { return m_type; } + void setType(Type t) { m_type = t; } + + QShader shader() const { return m_shader; } + void setShader(const QShader &s) { m_shader = s; } + + QShader::Variant shaderVariant() const { return m_shaderVariant; } + void setShaderVariant(QShader::Variant v) { m_shaderVariant = v; } + +private: + Type m_type = Vertex; + QShader m_shader; + QShader::Variant m_shaderVariant = QShader::StandardShader; + + friend bool operator==(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept + { + return a.m_type == b.m_type + && a.m_shader == b.m_shader + && a.m_shaderVariant == b.m_shaderVariant; + } + + friend bool operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QRhiShaderStage &v, size_t seed = 0) noexcept + { + QtPrivate::QHashCombine hash; + seed = hash(seed, v.m_type); + seed = hash(seed, v.m_shader); + seed = hash(seed, v.m_shaderVariant); + return seed; + } +}; + +Q_DECLARE_TYPEINFO(QRhiShaderStage, Q_RELOCATABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderStage &); +#endif + +using QRhiGraphicsShaderStage = QRhiShaderStage; + +class Q_GUI_EXPORT QRhiShaderResourceBinding +{ +public: + enum Type { + UniformBuffer, + SampledTexture, + Texture, + Sampler, + ImageLoad, + ImageStore, + ImageLoadStore, + BufferLoad, + BufferStore, + BufferLoadStore + }; + + enum StageFlag { + VertexStage = 1 << 0, + TessellationControlStage = 1 << 1, + TessellationEvaluationStage = 1 << 2, + GeometryStage = 1 << 3, + FragmentStage = 1 << 4, + ComputeStage = 1 << 5 + }; + Q_DECLARE_FLAGS(StageFlags, StageFlag) + + QRhiShaderResourceBinding() = default; + + bool isLayoutCompatible(const QRhiShaderResourceBinding &other) const; + + static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf); + static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size); + static QRhiShaderResourceBinding uniformBufferWithDynamicOffset(int binding, StageFlags stage, QRhiBuffer *buf, quint32 size); + + static QRhiShaderResourceBinding sampledTexture(int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler); + + struct TextureAndSampler { + QRhiTexture *tex; + QRhiSampler *sampler; + }; + static QRhiShaderResourceBinding sampledTextures(int binding, StageFlags stage, int count, const TextureAndSampler *texSamplers); + + static QRhiShaderResourceBinding texture(int binding, StageFlags stage, QRhiTexture *tex); + static QRhiShaderResourceBinding textures(int binding, StageFlags stage, int count, QRhiTexture **tex); + static QRhiShaderResourceBinding sampler(int binding, StageFlags stage, QRhiSampler *sampler); + + static QRhiShaderResourceBinding imageLoad(int binding, StageFlags stage, QRhiTexture *tex, int level); + static QRhiShaderResourceBinding imageStore(int binding, StageFlags stage, QRhiTexture *tex, int level); + static QRhiShaderResourceBinding imageLoadStore(int binding, StageFlags stage, QRhiTexture *tex, int level); + + static QRhiShaderResourceBinding bufferLoad(int binding, StageFlags stage, QRhiBuffer *buf); + static QRhiShaderResourceBinding bufferLoad(int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size); + static QRhiShaderResourceBinding bufferStore(int binding, StageFlags stage, QRhiBuffer *buf); + static QRhiShaderResourceBinding bufferStore(int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size); + static QRhiShaderResourceBinding bufferLoadStore(int binding, StageFlags stage, QRhiBuffer *buf); + static QRhiShaderResourceBinding bufferLoadStore(int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size); + + struct Data + { + int binding; + QRhiShaderResourceBinding::StageFlags stage; + QRhiShaderResourceBinding::Type type; + struct UniformBufferData { + QRhiBuffer *buf; + quint32 offset; + quint32 maybeSize; + bool hasDynamicOffset; + }; + static constexpr int MAX_TEX_SAMPLER_ARRAY_SIZE = 16; + struct TextureAndOrSamplerData { + int count; + TextureAndSampler texSamplers[MAX_TEX_SAMPLER_ARRAY_SIZE]; + }; + struct StorageImageData { + QRhiTexture *tex; + int level; + }; + struct StorageBufferData { + QRhiBuffer *buf; + quint32 offset; + quint32 maybeSize; + }; + union { + UniformBufferData ubuf; + TextureAndOrSamplerData stex; + StorageImageData simage; + StorageBufferData sbuf; + } u; + + int arraySize() const + { + return type == QRhiShaderResourceBinding::SampledTexture || type == QRhiShaderResourceBinding::Texture + ? u.stex.count + : 1; + } + + template<typename Output> + Output serialize(Output dst) const + { + // must write out exactly LAYOUT_DESC_ENTRIES_PER_BINDING elements here + *dst++ = quint32(binding); + *dst++ = quint32(stage); + *dst++ = quint32(type); + *dst++ = quint32(arraySize()); + return dst; + } + }; + + static constexpr int LAYOUT_DESC_ENTRIES_PER_BINDING = 4; + + template<typename Output> + static void serializeLayoutDescription(const QRhiShaderResourceBinding *first, + const QRhiShaderResourceBinding *last, + Output dst) + { + while (first != last) { + dst = first->d.serialize(dst); + ++first; + } + } + +private: + Data d; + friend class QRhiImplementation; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderResourceBinding::StageFlags) + +Q_DECLARE_TYPEINFO(QRhiShaderResourceBinding, Q_PRIMITIVE_TYPE); + +Q_GUI_EXPORT bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) noexcept; +Q_GUI_EXPORT bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) noexcept; +Q_GUI_EXPORT size_t qHash(const QRhiShaderResourceBinding &b, size_t seed = 0) noexcept; +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderResourceBinding &); +#endif + +class Q_GUI_EXPORT QRhiColorAttachment +{ +public: + QRhiColorAttachment() = default; + QRhiColorAttachment(QRhiTexture *texture); + QRhiColorAttachment(QRhiRenderBuffer *renderBuffer); + + QRhiTexture *texture() const { return m_texture; } + void setTexture(QRhiTexture *tex) { m_texture = tex; } + + QRhiRenderBuffer *renderBuffer() const { return m_renderBuffer; } + void setRenderBuffer(QRhiRenderBuffer *rb) { m_renderBuffer = rb; } + + int layer() const { return m_layer; } + void setLayer(int layer) { m_layer = layer; } + + int level() const { return m_level; } + void setLevel(int level) { m_level = level; } + + QRhiTexture *resolveTexture() const { return m_resolveTexture; } + void setResolveTexture(QRhiTexture *tex) { m_resolveTexture = tex; } + + int resolveLayer() const { return m_resolveLayer; } + void setResolveLayer(int layer) { m_resolveLayer = layer; } + + int resolveLevel() const { return m_resolveLevel; } + void setResolveLevel(int level) { m_resolveLevel = level; } + + int multiViewCount() const { return m_multiViewCount; } + void setMultiViewCount(int count) { m_multiViewCount = count; } + +private: + QRhiTexture *m_texture = nullptr; + QRhiRenderBuffer *m_renderBuffer = nullptr; + int m_layer = 0; + int m_level = 0; + QRhiTexture *m_resolveTexture = nullptr; + int m_resolveLayer = 0; + int m_resolveLevel = 0; + int m_multiViewCount = 0; +}; + +Q_DECLARE_TYPEINFO(QRhiColorAttachment, Q_RELOCATABLE_TYPE); + +class Q_GUI_EXPORT QRhiTextureRenderTargetDescription +{ +public: + QRhiTextureRenderTargetDescription() = default; + QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment); + QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiRenderBuffer *depthStencilBuffer); + QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiTexture *depthTexture); + + void setColorAttachments(std::initializer_list<QRhiColorAttachment> list) { m_colorAttachments = list; } + template<typename InputIterator> + void setColorAttachments(InputIterator first, InputIterator last) + { + m_colorAttachments.clear(); + std::copy(first, last, std::back_inserter(m_colorAttachments)); + } + const QRhiColorAttachment *cbeginColorAttachments() const { return m_colorAttachments.cbegin(); } + const QRhiColorAttachment *cendColorAttachments() const { return m_colorAttachments.cend(); } + const QRhiColorAttachment *colorAttachmentAt(qsizetype index) const { return &m_colorAttachments.at(index); } + qsizetype colorAttachmentCount() const { return m_colorAttachments.count(); } + + QRhiRenderBuffer *depthStencilBuffer() const { return m_depthStencilBuffer; } + void setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer) { m_depthStencilBuffer = renderBuffer; } + + QRhiTexture *depthTexture() const { return m_depthTexture; } + void setDepthTexture(QRhiTexture *texture) { m_depthTexture = texture; } + + QRhiTexture *depthResolveTexture() const { return m_depthResolveTexture; } + void setDepthResolveTexture(QRhiTexture *tex) { m_depthResolveTexture = tex; } + +private: + QVarLengthArray<QRhiColorAttachment, 8> m_colorAttachments; + QRhiRenderBuffer *m_depthStencilBuffer = nullptr; + QRhiTexture *m_depthTexture = nullptr; + QRhiTexture *m_depthResolveTexture = nullptr; +}; + +class Q_GUI_EXPORT QRhiTextureSubresourceUploadDescription +{ +public: + QRhiTextureSubresourceUploadDescription() = default; + explicit QRhiTextureSubresourceUploadDescription(const QImage &image); + QRhiTextureSubresourceUploadDescription(const void *data, quint32 size); + explicit QRhiTextureSubresourceUploadDescription(const QByteArray &data); + + QImage image() const { return m_image; } + void setImage(const QImage &image) { m_image = image; } + + QByteArray data() const { return m_data; } + void setData(const QByteArray &data) { m_data = data; } + + quint32 dataStride() const { return m_dataStride; } + void setDataStride(quint32 stride) { m_dataStride = stride; } + + QPoint destinationTopLeft() const { return m_destinationTopLeft; } + void setDestinationTopLeft(const QPoint &p) { m_destinationTopLeft = p; } + + QSize sourceSize() const { return m_sourceSize; } + void setSourceSize(const QSize &size) { m_sourceSize = size; } + + QPoint sourceTopLeft() const { return m_sourceTopLeft; } + void setSourceTopLeft(const QPoint &p) { m_sourceTopLeft = p; } + +private: + QImage m_image; + QByteArray m_data; + quint32 m_dataStride = 0; + QPoint m_destinationTopLeft; + QSize m_sourceSize; + QPoint m_sourceTopLeft; +}; + +Q_DECLARE_TYPEINFO(QRhiTextureSubresourceUploadDescription, Q_RELOCATABLE_TYPE); + +class Q_GUI_EXPORT QRhiTextureUploadEntry +{ +public: + QRhiTextureUploadEntry() = default; + QRhiTextureUploadEntry(int layer, int level, const QRhiTextureSubresourceUploadDescription &desc); + + int layer() const { return m_layer; } + void setLayer(int layer) { m_layer = layer; } + + int level() const { return m_level; } + void setLevel(int level) { m_level = level; } + + QRhiTextureSubresourceUploadDescription description() const { return m_desc; } + void setDescription(const QRhiTextureSubresourceUploadDescription &desc) { m_desc = desc; } + +private: + int m_layer = 0; + int m_level = 0; + QRhiTextureSubresourceUploadDescription m_desc; +}; + +Q_DECLARE_TYPEINFO(QRhiTextureUploadEntry, Q_RELOCATABLE_TYPE); + +class Q_GUI_EXPORT QRhiTextureUploadDescription +{ +public: + QRhiTextureUploadDescription() = default; + QRhiTextureUploadDescription(const QRhiTextureUploadEntry &entry); + QRhiTextureUploadDescription(std::initializer_list<QRhiTextureUploadEntry> list); + + void setEntries(std::initializer_list<QRhiTextureUploadEntry> list) { m_entries = list; } + template<typename InputIterator> + void setEntries(InputIterator first, InputIterator last) + { + m_entries.clear(); + std::copy(first, last, std::back_inserter(m_entries)); + } + const QRhiTextureUploadEntry *cbeginEntries() const { return m_entries.cbegin(); } + const QRhiTextureUploadEntry *cendEntries() const { return m_entries.cend(); } + const QRhiTextureUploadEntry *entryAt(qsizetype index) const { return &m_entries.at(index); } + qsizetype entryCount() const { return m_entries.count(); } + +private: + QVarLengthArray<QRhiTextureUploadEntry, 16> m_entries; +}; + +class Q_GUI_EXPORT QRhiTextureCopyDescription +{ +public: + QRhiTextureCopyDescription() = default; + + QSize pixelSize() const { return m_pixelSize; } + void setPixelSize(const QSize &sz) { m_pixelSize = sz; } + + int sourceLayer() const { return m_sourceLayer; } + void setSourceLayer(int layer) { m_sourceLayer = layer; } + + int sourceLevel() const { return m_sourceLevel; } + void setSourceLevel(int level) { m_sourceLevel = level; } + + QPoint sourceTopLeft() const { return m_sourceTopLeft; } + void setSourceTopLeft(const QPoint &p) { m_sourceTopLeft = p; } + + int destinationLayer() const { return m_destinationLayer; } + void setDestinationLayer(int layer) { m_destinationLayer = layer; } + + int destinationLevel() const { return m_destinationLevel; } + void setDestinationLevel(int level) { m_destinationLevel = level; } + + QPoint destinationTopLeft() const { return m_destinationTopLeft; } + void setDestinationTopLeft(const QPoint &p) { m_destinationTopLeft = p; } + +private: + QSize m_pixelSize; + int m_sourceLayer = 0; + int m_sourceLevel = 0; + QPoint m_sourceTopLeft; + int m_destinationLayer = 0; + int m_destinationLevel = 0; + QPoint m_destinationTopLeft; +}; + +Q_DECLARE_TYPEINFO(QRhiTextureCopyDescription, Q_RELOCATABLE_TYPE); + +class Q_GUI_EXPORT QRhiReadbackDescription +{ +public: + QRhiReadbackDescription() = default; + QRhiReadbackDescription(QRhiTexture *texture); + + QRhiTexture *texture() const { return m_texture; } + void setTexture(QRhiTexture *tex) { m_texture = tex; } + + int layer() const { return m_layer; } + void setLayer(int layer) { m_layer = layer; } + + int level() const { return m_level; } + void setLevel(int level) { m_level = level; } + +private: + QRhiTexture *m_texture = nullptr; + int m_layer = 0; + int m_level = 0; +}; + +Q_DECLARE_TYPEINFO(QRhiReadbackDescription, Q_RELOCATABLE_TYPE); + +struct Q_GUI_EXPORT QRhiNativeHandles +{ +}; + +class Q_GUI_EXPORT QRhiResource +{ +public: + enum Type { + Buffer, + Texture, + Sampler, + RenderBuffer, + RenderPassDescriptor, + SwapChainRenderTarget, + TextureRenderTarget, + ShaderResourceBindings, + GraphicsPipeline, + SwapChain, + ComputePipeline, + CommandBuffer + }; + + virtual ~QRhiResource(); + + virtual Type resourceType() const = 0; + + virtual void destroy() = 0; + + void deleteLater(); + + QByteArray name() const; + void setName(const QByteArray &name); + + quint64 globalResourceId() const; + + QRhi *rhi() const; + +protected: + QRhiResource(QRhiImplementation *rhi); + Q_DISABLE_COPY(QRhiResource) + friend class QRhiImplementation; + QRhiImplementation *m_rhi = nullptr; + quint64 m_id; + QByteArray m_objectName; +}; + +class Q_GUI_EXPORT QRhiBuffer : public QRhiResource +{ +public: + enum Type { + Immutable, + Static, + Dynamic + }; + + enum UsageFlag { + VertexBuffer = 1 << 0, + IndexBuffer = 1 << 1, + UniformBuffer = 1 << 2, + StorageBuffer = 1 << 3 + }; + Q_DECLARE_FLAGS(UsageFlags, UsageFlag) + + struct NativeBuffer { + const void *objects[3]; + int slotCount; + }; + + QRhiResource::Type resourceType() const override; + + Type type() const { return m_type; } + void setType(Type t) { m_type = t; } + + UsageFlags usage() const { return m_usage; } + void setUsage(UsageFlags u) { m_usage = u; } + + quint32 size() const { return m_size; } + void setSize(quint32 sz) { m_size = sz; } + + virtual bool create() = 0; + + virtual NativeBuffer nativeBuffer(); + + virtual char *beginFullDynamicBufferUpdateForCurrentFrame(); + virtual void endFullDynamicBufferUpdateForCurrentFrame(); + virtual void fullDynamicBufferUpdateForCurrentFrame(const void *data, quint32 size = 0); + +protected: + QRhiBuffer(QRhiImplementation *rhi, Type type_, UsageFlags usage_, quint32 size_); + Type m_type; + UsageFlags m_usage; + quint32 m_size; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiBuffer::UsageFlags) + +class Q_GUI_EXPORT QRhiTexture : public QRhiResource +{ +public: + enum Flag { + RenderTarget = 1 << 0, + CubeMap = 1 << 2, + MipMapped = 1 << 3, + sRGB = 1 << 4, + UsedAsTransferSource = 1 << 5, + UsedWithGenerateMips = 1 << 6, + UsedWithLoadStore = 1 << 7, + UsedAsCompressedAtlas = 1 << 8, + ExternalOES = 1 << 9, + ThreeDimensional = 1 << 10, + TextureRectangleGL = 1 << 11, + TextureArray = 1 << 12, + OneDimensional = 1 << 13 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + enum Format { + UnknownFormat, + + RGBA8, + BGRA8, + R8, + RG8, + R16, + RG16, + RED_OR_ALPHA8, + + RGBA16F, + RGBA32F, + R16F, + R32F, + + RGB10A2, + + D16, + D24, + D24S8, + D32F, + + BC1, + BC2, + BC3, + BC4, + BC5, + BC6H, + BC7, + + ETC2_RGB8, + ETC2_RGB8A1, + ETC2_RGBA8, + + ASTC_4x4, + ASTC_5x4, + ASTC_5x5, + ASTC_6x5, + ASTC_6x6, + ASTC_8x5, + ASTC_8x6, + ASTC_8x8, + ASTC_10x5, + ASTC_10x6, + ASTC_10x8, + ASTC_10x10, + ASTC_12x10, + ASTC_12x12 + }; + + struct NativeTexture { + quint64 object; + int layout; // or state + }; + + QRhiResource::Type resourceType() const override; + + Format format() const { return m_format; } + void setFormat(Format fmt) { m_format = fmt; } + + QSize pixelSize() const { return m_pixelSize; } + void setPixelSize(const QSize &sz) { m_pixelSize = sz; } + + int depth() const { return m_depth; } + void setDepth(int depth) { m_depth = depth; } + + int arraySize() const { return m_arraySize; } + void setArraySize(int arraySize) { m_arraySize = arraySize; } + + int arrayRangeStart() const { return m_arrayRangeStart; } + int arrayRangeLength() const { return m_arrayRangeLength; } + void setArrayRange(int startIndex, int count) + { + m_arrayRangeStart = startIndex; + m_arrayRangeLength = count; + } + + Flags flags() const { return m_flags; } + void setFlags(Flags f) { m_flags = f; } + + int sampleCount() const { return m_sampleCount; } + void setSampleCount(int s) { m_sampleCount = s; } + + struct ViewFormat { + QRhiTexture::Format format; + bool srgb; + }; + ViewFormat readViewFormat() const { return m_readViewFormat; } + void setReadViewFormat(const ViewFormat &fmt) { m_readViewFormat = fmt; } + ViewFormat writeViewFormat() const { return m_writeViewFormat; } + void setWriteViewFormat(const ViewFormat &fmt) { m_writeViewFormat = fmt; } + + virtual bool create() = 0; + virtual NativeTexture nativeTexture(); + virtual bool createFrom(NativeTexture src); + virtual void setNativeLayout(int layout); + +protected: + QRhiTexture(QRhiImplementation *rhi, Format format_, const QSize &pixelSize_, int depth_, + int arraySize_, int sampleCount_, Flags flags_); + Format m_format; + QSize m_pixelSize; + int m_depth; + int m_arraySize; + int m_sampleCount; + Flags m_flags; + int m_arrayRangeStart = -1; + int m_arrayRangeLength = -1; + ViewFormat m_readViewFormat = { UnknownFormat, false }; + ViewFormat m_writeViewFormat = { UnknownFormat, false }; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiTexture::Flags) + +class Q_GUI_EXPORT QRhiSampler : public QRhiResource +{ +public: + enum Filter { + None, + Nearest, + Linear + }; + + enum AddressMode { + Repeat, + ClampToEdge, + Mirror, + }; + + enum CompareOp { + Never, + Less, + Equal, + LessOrEqual, + Greater, + NotEqual, + GreaterOrEqual, + Always + }; + + QRhiResource::Type resourceType() const override; + + Filter magFilter() const { return m_magFilter; } + void setMagFilter(Filter f) { m_magFilter = f; } + + Filter minFilter() const { return m_minFilter; } + void setMinFilter(Filter f) { m_minFilter = f; } + + Filter mipmapMode() const { return m_mipmapMode; } + void setMipmapMode(Filter f) { m_mipmapMode = f; } + + AddressMode addressU() const { return m_addressU; } + void setAddressU(AddressMode mode) { m_addressU = mode; } + + AddressMode addressV() const { return m_addressV; } + void setAddressV(AddressMode mode) { m_addressV = mode; } + + AddressMode addressW() const { return m_addressW; } + void setAddressW(AddressMode mode) { m_addressW = mode; } + + CompareOp textureCompareOp() const { return m_compareOp; } + void setTextureCompareOp(CompareOp op) { m_compareOp = op; } + + virtual bool create() = 0; + +protected: + QRhiSampler(QRhiImplementation *rhi, + Filter magFilter_, Filter minFilter_, Filter mipmapMode_, + AddressMode u_, AddressMode v_, AddressMode w_); + Filter m_magFilter; + Filter m_minFilter; + Filter m_mipmapMode; + AddressMode m_addressU; + AddressMode m_addressV; + AddressMode m_addressW; + CompareOp m_compareOp; +}; + +class Q_GUI_EXPORT QRhiRenderBuffer : public QRhiResource +{ +public: + enum Type { + DepthStencil, + Color + }; + + enum Flag { + UsedWithSwapChainOnly = 1 << 0 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + struct NativeRenderBuffer { + quint64 object; + }; + + QRhiResource::Type resourceType() const override; + + Type type() const { return m_type; } + void setType(Type t) { m_type = t; } + + QSize pixelSize() const { return m_pixelSize; } + void setPixelSize(const QSize &sz) { m_pixelSize = sz; } + + int sampleCount() const { return m_sampleCount; } + void setSampleCount(int s) { m_sampleCount = s; } + + Flags flags() const { return m_flags; } + void setFlags(Flags f) { m_flags = f; } + + virtual bool create() = 0; + virtual bool createFrom(NativeRenderBuffer src); + + virtual QRhiTexture::Format backingFormat() const = 0; + +protected: + QRhiRenderBuffer(QRhiImplementation *rhi, Type type_, const QSize &pixelSize_, + int sampleCount_, Flags flags_, QRhiTexture::Format backingFormatHint_); + Type m_type; + QSize m_pixelSize; + int m_sampleCount; + Flags m_flags; + QRhiTexture::Format m_backingFormatHint; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiRenderBuffer::Flags) + +class Q_GUI_EXPORT QRhiRenderPassDescriptor : public QRhiResource +{ +public: + QRhiResource::Type resourceType() const override; + + virtual bool isCompatible(const QRhiRenderPassDescriptor *other) const = 0; + virtual const QRhiNativeHandles *nativeHandles(); + + virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() const = 0; + + virtual QVector<quint32> serializedFormat() const = 0; + +protected: + QRhiRenderPassDescriptor(QRhiImplementation *rhi); +}; + +class Q_GUI_EXPORT QRhiRenderTarget : public QRhiResource +{ +public: + virtual QSize pixelSize() const = 0; + virtual float devicePixelRatio() const = 0; + virtual int sampleCount() const = 0; + + QRhiRenderPassDescriptor *renderPassDescriptor() const { return m_renderPassDesc; } + void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; } + +protected: + QRhiRenderTarget(QRhiImplementation *rhi); + QRhiRenderPassDescriptor *m_renderPassDesc = nullptr; +}; + +class Q_GUI_EXPORT QRhiSwapChainRenderTarget : public QRhiRenderTarget +{ +public: + QRhiResource::Type resourceType() const override; + QRhiSwapChain *swapChain() const { return m_swapchain; } + +protected: + QRhiSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain_); + QRhiSwapChain *m_swapchain; +}; + +class Q_GUI_EXPORT QRhiTextureRenderTarget : public QRhiRenderTarget +{ +public: + enum Flag { + PreserveColorContents = 1 << 0, + PreserveDepthStencilContents = 1 << 1, + DoNotStoreDepthStencilContents = 1 << 2 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + QRhiResource::Type resourceType() const override; + + QRhiTextureRenderTargetDescription description() const { return m_desc; } + void setDescription(const QRhiTextureRenderTargetDescription &desc) { m_desc = desc; } + + Flags flags() const { return m_flags; } + void setFlags(Flags f) { m_flags = f; } + + virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() = 0; + + virtual bool create() = 0; + +protected: + QRhiTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc_, Flags flags_); + QRhiTextureRenderTargetDescription m_desc; + Flags m_flags; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiTextureRenderTarget::Flags) + +class Q_GUI_EXPORT QRhiShaderResourceBindings : public QRhiResource +{ +public: + QRhiResource::Type resourceType() const override; + + void setBindings(std::initializer_list<QRhiShaderResourceBinding> list) { m_bindings = list; } + template<typename InputIterator> + void setBindings(InputIterator first, InputIterator last) + { + m_bindings.clear(); + std::copy(first, last, std::back_inserter(m_bindings)); + } + const QRhiShaderResourceBinding *cbeginBindings() const { return m_bindings.cbegin(); } + const QRhiShaderResourceBinding *cendBindings() const { return m_bindings.cend(); } + const QRhiShaderResourceBinding *bindingAt(qsizetype index) const { return &m_bindings.at(index); } + qsizetype bindingCount() const { return m_bindings.count(); } + + bool isLayoutCompatible(const QRhiShaderResourceBindings *other) const; + + QVector<quint32> serializedLayoutDescription() const { return m_layoutDesc; } + + virtual bool create() = 0; + + enum UpdateFlag { + BindingsAreSorted = 0x01 + }; + Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag) + + virtual void updateResources(UpdateFlags flags = {}) = 0; + +protected: + static constexpr int BINDING_PREALLOC = 12; + QRhiShaderResourceBindings(QRhiImplementation *rhi); + QVarLengthArray<QRhiShaderResourceBinding, BINDING_PREALLOC> m_bindings; + size_t m_layoutDescHash = 0; + // Intentionally not using QVLA for m_layoutDesc: clients like Qt Quick are much + // better served with an implicitly shared container here, because they will likely + // throw this directly into structs serving as cache keys. + QVector<quint32> m_layoutDesc; + friend class QRhiImplementation; +#ifndef QT_NO_DEBUG_STREAM + friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderResourceBindings &); +#endif +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderResourceBindings::UpdateFlags) + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderResourceBindings &); +#endif + +// The proper name. Until it gets rolled out universally, have the better name +// as a typedef. Eventually it should be reversed (the old name being a typedef +// to the new one). +using QRhiShaderResourceBindingSet = QRhiShaderResourceBindings; + +class Q_GUI_EXPORT QRhiGraphicsPipeline : public QRhiResource +{ +public: + enum Flag { + UsesBlendConstants = 1 << 0, + UsesStencilRef = 1 << 1, + UsesScissor = 1 << 2, + CompileShadersWithDebugInfo = 1 << 3 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + enum Topology { + Triangles, + TriangleStrip, + TriangleFan, + Lines, + LineStrip, + Points, + Patches + }; + + enum CullMode { + None, + Front, + Back + }; + + enum FrontFace { + CCW, + CW + }; + + enum ColorMaskComponent { + R = 1 << 0, + G = 1 << 1, + B = 1 << 2, + A = 1 << 3 + }; + Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent) + + enum BlendFactor { + Zero, + One, + SrcColor, + OneMinusSrcColor, + DstColor, + OneMinusDstColor, + SrcAlpha, + OneMinusSrcAlpha, + DstAlpha, + OneMinusDstAlpha, + ConstantColor, + OneMinusConstantColor, + ConstantAlpha, + OneMinusConstantAlpha, + SrcAlphaSaturate, + Src1Color, + OneMinusSrc1Color, + Src1Alpha, + OneMinusSrc1Alpha + }; + + enum BlendOp { + Add, + Subtract, + ReverseSubtract, + Min, + Max + }; + + struct TargetBlend { + ColorMask colorWrite = ColorMask(0xF); // R | G | B | A + bool enable = false; + BlendFactor srcColor = One; + BlendFactor dstColor = OneMinusSrcAlpha; + BlendOp opColor = Add; + BlendFactor srcAlpha = One; + BlendFactor dstAlpha = OneMinusSrcAlpha; + BlendOp opAlpha = Add; + }; + + enum CompareOp { + Never, + Less, + Equal, + LessOrEqual, + Greater, + NotEqual, + GreaterOrEqual, + Always + }; + + enum StencilOp { + StencilZero, + Keep, + Replace, + IncrementAndClamp, + DecrementAndClamp, + Invert, + IncrementAndWrap, + DecrementAndWrap + }; + + struct StencilOpState { + StencilOp failOp = Keep; + StencilOp depthFailOp = Keep; + StencilOp passOp = Keep; + CompareOp compareOp = Always; + }; + + enum PolygonMode { + Fill, + Line + }; + + QRhiResource::Type resourceType() const override; + + Flags flags() const { return m_flags; } + void setFlags(Flags f) { m_flags = f; } + + Topology topology() const { return m_topology; } + void setTopology(Topology t) { m_topology = t; } + + CullMode cullMode() const { return m_cullMode; } + void setCullMode(CullMode mode) { m_cullMode = mode; } + + FrontFace frontFace() const { return m_frontFace; } + void setFrontFace(FrontFace f) { m_frontFace = f; } + + void setTargetBlends(std::initializer_list<TargetBlend> list) { m_targetBlends = list; } + template<typename InputIterator> + void setTargetBlends(InputIterator first, InputIterator last) + { + m_targetBlends.clear(); + std::copy(first, last, std::back_inserter(m_targetBlends)); + } + const TargetBlend *cbeginTargetBlends() const { return m_targetBlends.cbegin(); } + const TargetBlend *cendTargetBlends() const { return m_targetBlends.cend(); } + const TargetBlend *targetBlendAt(qsizetype index) const { return &m_targetBlends.at(index); } + qsizetype targetBlendCount() const { return m_targetBlends.count(); } + + bool hasDepthTest() const { return m_depthTest; } + void setDepthTest(bool enable) { m_depthTest = enable; } + + bool hasDepthWrite() const { return m_depthWrite; } + void setDepthWrite(bool enable) { m_depthWrite = enable; } + + CompareOp depthOp() const { return m_depthOp; } + void setDepthOp(CompareOp op) { m_depthOp = op; } + + bool hasStencilTest() const { return m_stencilTest; } + void setStencilTest(bool enable) { m_stencilTest = enable; } + + StencilOpState stencilFront() const { return m_stencilFront; } + void setStencilFront(const StencilOpState &state) { m_stencilFront = state; } + + StencilOpState stencilBack() const { return m_stencilBack; } + void setStencilBack(const StencilOpState &state) { m_stencilBack = state; } + + quint32 stencilReadMask() const { return m_stencilReadMask; } + void setStencilReadMask(quint32 mask) { m_stencilReadMask = mask; } + + quint32 stencilWriteMask() const { return m_stencilWriteMask; } + void setStencilWriteMask(quint32 mask) { m_stencilWriteMask = mask; } + + int sampleCount() const { return m_sampleCount; } + void setSampleCount(int s) { m_sampleCount = s; } + + float lineWidth() const { return m_lineWidth; } + void setLineWidth(float width) { m_lineWidth = width; } + + int depthBias() const { return m_depthBias; } + void setDepthBias(int bias) { m_depthBias = bias; } + + float slopeScaledDepthBias() const { return m_slopeScaledDepthBias; } + void setSlopeScaledDepthBias(float bias) { m_slopeScaledDepthBias = bias; } + + void setShaderStages(std::initializer_list<QRhiShaderStage> list) { m_shaderStages = list; } + template<typename InputIterator> + void setShaderStages(InputIterator first, InputIterator last) + { + m_shaderStages.clear(); + std::copy(first, last, std::back_inserter(m_shaderStages)); + } + const QRhiShaderStage *cbeginShaderStages() const { return m_shaderStages.cbegin(); } + const QRhiShaderStage *cendShaderStages() const { return m_shaderStages.cend(); } + const QRhiShaderStage *shaderStageAt(qsizetype index) const { return &m_shaderStages.at(index); } + qsizetype shaderStageCount() const { return m_shaderStages.count(); } + + QRhiVertexInputLayout vertexInputLayout() const { return m_vertexInputLayout; } + void setVertexInputLayout(const QRhiVertexInputLayout &layout) { m_vertexInputLayout = layout; } + + QRhiShaderResourceBindings *shaderResourceBindings() const { return m_shaderResourceBindings; } + void setShaderResourceBindings(QRhiShaderResourceBindings *srb) { m_shaderResourceBindings = srb; } + + QRhiRenderPassDescriptor *renderPassDescriptor() const { return m_renderPassDesc; } + void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; } + + int patchControlPointCount() const { return m_patchControlPointCount; } + void setPatchControlPointCount(int count) { m_patchControlPointCount = count; } + + PolygonMode polygonMode() const {return m_polygonMode; } + void setPolygonMode(PolygonMode mode) {m_polygonMode = mode; } + + int multiViewCount() const { return m_multiViewCount; } + void setMultiViewCount(int count) { m_multiViewCount = count; } + + virtual bool create() = 0; + +protected: + QRhiGraphicsPipeline(QRhiImplementation *rhi); + Flags m_flags; + Topology m_topology = Triangles; + CullMode m_cullMode = None; + FrontFace m_frontFace = CCW; + QVarLengthArray<TargetBlend, 8> m_targetBlends; + bool m_depthTest = false; + bool m_depthWrite = false; + CompareOp m_depthOp = Less; + bool m_stencilTest = false; + StencilOpState m_stencilFront; + StencilOpState m_stencilBack; + quint32 m_stencilReadMask = 0xFF; + quint32 m_stencilWriteMask = 0xFF; + int m_sampleCount = 1; + float m_lineWidth = 1.0f; + int m_depthBias = 0; + float m_slopeScaledDepthBias = 0.0f; + int m_patchControlPointCount = 3; + PolygonMode m_polygonMode = Fill; + int m_multiViewCount = 0; + QVarLengthArray<QRhiShaderStage, 4> m_shaderStages; + QRhiVertexInputLayout m_vertexInputLayout; + QRhiShaderResourceBindings *m_shaderResourceBindings = nullptr; + QRhiRenderPassDescriptor *m_renderPassDesc = nullptr; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiGraphicsPipeline::Flags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiGraphicsPipeline::ColorMask) +Q_DECLARE_TYPEINFO(QRhiGraphicsPipeline::TargetBlend, Q_RELOCATABLE_TYPE); + +struct QRhiSwapChainHdrInfo +{ + enum LimitsType { + LuminanceInNits, + ColorComponentValue + }; + + enum LuminanceBehavior { + SceneReferred, + DisplayReferred + }; + + LimitsType limitsType; + union { + struct { + float minLuminance; + float maxLuminance; + } luminanceInNits; + struct { + float maxColorComponentValue; + float maxPotentialColorComponentValue; + } colorComponentValue; + } limits; + LuminanceBehavior luminanceBehavior; + float sdrWhiteLevel; +}; + +Q_DECLARE_TYPEINFO(QRhiSwapChainHdrInfo, Q_RELOCATABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiSwapChainHdrInfo &); +#endif + +struct QRhiSwapChainProxyData +{ + void *reserved[2] = {}; +}; + +class Q_GUI_EXPORT QRhiSwapChain : public QRhiResource +{ +public: + enum Flag { + SurfaceHasPreMulAlpha = 1 << 0, + SurfaceHasNonPreMulAlpha = 1 << 1, + sRGB = 1 << 2, + UsedAsTransferSource = 1 << 3, + NoVSync = 1 << 4, + MinimalBufferCount = 1 << 5 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + enum Format { + SDR, + HDRExtendedSrgbLinear, + HDR10, + HDRExtendedDisplayP3Linear + }; + + enum StereoTargetBuffer { + LeftBuffer, + RightBuffer + }; + + QRhiResource::Type resourceType() const override; + + QWindow *window() const { return m_window; } + void setWindow(QWindow *window) { m_window = window; } + + QRhiSwapChainProxyData proxyData() const { return m_proxyData; } + void setProxyData(const QRhiSwapChainProxyData &d) { m_proxyData = d; } + + Flags flags() const { return m_flags; } + void setFlags(Flags f) { m_flags = f; } + + Format format() const { return m_format; } + void setFormat(Format f) { m_format = f; } + + QRhiRenderBuffer *depthStencil() const { return m_depthStencil; } + void setDepthStencil(QRhiRenderBuffer *ds) { m_depthStencil = ds; } + + int sampleCount() const { return m_sampleCount; } + void setSampleCount(int samples) { m_sampleCount = samples; } + + QRhiRenderPassDescriptor *renderPassDescriptor() const { return m_renderPassDesc; } + void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; } + + QSize currentPixelSize() const { return m_currentPixelSize; } + + virtual QRhiCommandBuffer *currentFrameCommandBuffer() = 0; + virtual QRhiRenderTarget *currentFrameRenderTarget() = 0; + virtual QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer); + virtual QSize surfacePixelSize() = 0; + virtual bool isFormatSupported(Format f) = 0; + virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() = 0; + virtual bool createOrResize() = 0; + virtual QRhiSwapChainHdrInfo hdrInfo(); + +protected: + QRhiSwapChain(QRhiImplementation *rhi); + QWindow *m_window = nullptr; + Flags m_flags; + Format m_format = SDR; + QRhiRenderBuffer *m_depthStencil = nullptr; + int m_sampleCount = 1; + QRhiRenderPassDescriptor *m_renderPassDesc = nullptr; + QSize m_currentPixelSize; + QRhiSwapChainProxyData m_proxyData; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiSwapChain::Flags) + +class Q_GUI_EXPORT QRhiComputePipeline : public QRhiResource +{ +public: + enum Flag { + CompileShadersWithDebugInfo = 1 << 0 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + QRhiResource::Type resourceType() const override; + virtual bool create() = 0; + + Flags flags() const { return m_flags; } + void setFlags(Flags f) { m_flags = f; } + + QRhiShaderStage shaderStage() const { return m_shaderStage; } + void setShaderStage(const QRhiShaderStage &stage) { m_shaderStage = stage; } + + QRhiShaderResourceBindings *shaderResourceBindings() const { return m_shaderResourceBindings; } + void setShaderResourceBindings(QRhiShaderResourceBindings *srb) { m_shaderResourceBindings = srb; } + +protected: + QRhiComputePipeline(QRhiImplementation *rhi); + Flags m_flags; + QRhiShaderStage m_shaderStage; + QRhiShaderResourceBindings *m_shaderResourceBindings = nullptr; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiComputePipeline::Flags) + +class Q_GUI_EXPORT QRhiCommandBuffer : public QRhiResource +{ +public: + enum IndexFormat { + IndexUInt16, + IndexUInt32 + }; + + enum BeginPassFlag { + ExternalContent = 0x01, + DoNotTrackResourcesForCompute = 0x02 + }; + Q_DECLARE_FLAGS(BeginPassFlags, BeginPassFlag) + + QRhiResource::Type resourceType() const override; + + void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates); + + void beginPass(QRhiRenderTarget *rt, + const QColor &colorClearValue, + const QRhiDepthStencilClearValue &depthStencilClearValue, + QRhiResourceUpdateBatch *resourceUpdates = nullptr, + BeginPassFlags flags = {}); + void endPass(QRhiResourceUpdateBatch *resourceUpdates = nullptr); + + void setGraphicsPipeline(QRhiGraphicsPipeline *ps); + using DynamicOffset = QPair<int, quint32>; // binding, offset + void setShaderResources(QRhiShaderResourceBindings *srb = nullptr, + int dynamicOffsetCount = 0, + const DynamicOffset *dynamicOffsets = nullptr); + using VertexInput = QPair<QRhiBuffer *, quint32>; // buffer, offset + void setVertexInput(int startBinding, int bindingCount, const VertexInput *bindings, + QRhiBuffer *indexBuf = nullptr, quint32 indexOffset = 0, + IndexFormat indexFormat = IndexUInt16); + + void setViewport(const QRhiViewport &viewport); + void setScissor(const QRhiScissor &scissor); + void setBlendConstants(const QColor &c); + void setStencilRef(quint32 refValue); + + void draw(quint32 vertexCount, + quint32 instanceCount = 1, + quint32 firstVertex = 0, + quint32 firstInstance = 0); + + void drawIndexed(quint32 indexCount, + quint32 instanceCount = 1, + quint32 firstIndex = 0, + qint32 vertexOffset = 0, + quint32 firstInstance = 0); + + void debugMarkBegin(const QByteArray &name); + void debugMarkEnd(); + void debugMarkMsg(const QByteArray &msg); + + void beginComputePass(QRhiResourceUpdateBatch *resourceUpdates = nullptr, BeginPassFlags flags = {}); + void endComputePass(QRhiResourceUpdateBatch *resourceUpdates = nullptr); + void setComputePipeline(QRhiComputePipeline *ps); + void dispatch(int x, int y, int z); + + const QRhiNativeHandles *nativeHandles(); + void beginExternal(); + void endExternal(); + + double lastCompletedGpuTime(); + +protected: + QRhiCommandBuffer(QRhiImplementation *rhi); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiCommandBuffer::BeginPassFlags) + +struct Q_GUI_EXPORT QRhiReadbackResult +{ + std::function<void()> completed = nullptr; + QRhiTexture::Format format; + QSize pixelSize; + QByteArray data; +}; + +class Q_GUI_EXPORT QRhiResourceUpdateBatch +{ +public: + ~QRhiResourceUpdateBatch(); + + void release(); + + void merge(QRhiResourceUpdateBatch *other); + bool hasOptimalCapacity() const; + + void updateDynamicBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data); + void uploadStaticBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data); + void uploadStaticBuffer(QRhiBuffer *buf, const void *data); + void readBackBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result); + void uploadTexture(QRhiTexture *tex, const QRhiTextureUploadDescription &desc); + void uploadTexture(QRhiTexture *tex, const QImage &image); + void copyTexture(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc = QRhiTextureCopyDescription()); + void readBackTexture(const QRhiReadbackDescription &rb, QRhiReadbackResult *result); + void generateMips(QRhiTexture *tex); + +private: + QRhiResourceUpdateBatch(QRhiImplementation *rhi); + Q_DISABLE_COPY(QRhiResourceUpdateBatch) + QRhiResourceUpdateBatchPrivate *d; + friend class QRhiResourceUpdateBatchPrivate; + friend class QRhi; +}; + +struct Q_GUI_EXPORT QRhiDriverInfo +{ + enum DeviceType { + UnknownDevice, + IntegratedDevice, + DiscreteDevice, + ExternalDevice, + VirtualDevice, + CpuDevice + }; + + QByteArray deviceName; + quint64 deviceId = 0; + quint64 vendorId = 0; + DeviceType deviceType = UnknownDevice; +}; + +Q_DECLARE_TYPEINFO(QRhiDriverInfo, Q_RELOCATABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiDriverInfo &); +#endif + +struct Q_GUI_EXPORT QRhiStats +{ + qint64 totalPipelineCreationTime = 0; + // Vulkan or D3D12 memory allocator statistics + quint32 blockCount = 0; + quint32 allocCount = 0; + quint64 usedBytes = 0; + quint64 unusedBytes = 0; + // D3D12 only, from IDXGIAdapter3::QueryVideoMemoryInfo(), incl. all resources + quint64 totalUsageBytes = 0; +}; + +Q_DECLARE_TYPEINFO(QRhiStats, Q_RELOCATABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiStats &); +#endif + +struct Q_GUI_EXPORT QRhiInitParams +{ +}; + +class Q_GUI_EXPORT QRhi +{ +public: + enum Implementation { + Null, + Vulkan, + OpenGLES2, + D3D11, + Metal, + D3D12 + }; + + enum Flag { + EnableDebugMarkers = 1 << 0, + PreferSoftwareRenderer = 1 << 1, + EnablePipelineCacheDataSave = 1 << 2, + EnableTimestamps = 1 << 3, + SuppressSmokeTestWarnings = 1 << 4 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + enum FrameOpResult { + FrameOpSuccess = 0, + FrameOpError, + FrameOpSwapChainOutOfDate, + FrameOpDeviceLost + }; + + enum Feature { + MultisampleTexture = 1, + MultisampleRenderBuffer, + DebugMarkers, + Timestamps, + Instancing, + CustomInstanceStepRate, + PrimitiveRestart, + NonDynamicUniformBuffers, + NonFourAlignedEffectiveIndexBufferOffset, + NPOTTextureRepeat, + RedOrAlpha8IsRed, + ElementIndexUint, + Compute, + WideLines, + VertexShaderPointSize, + BaseVertex, + BaseInstance, + TriangleFanTopology, + ReadBackNonUniformBuffer, + ReadBackNonBaseMipLevel, + TexelFetch, + RenderToNonBaseMipLevel, + IntAttributes, + ScreenSpaceDerivatives, + ReadBackAnyTextureFormat, + PipelineCacheDataLoadSave, + ImageDataStride, + RenderBufferImport, + ThreeDimensionalTextures, + RenderTo3DTextureSlice, + TextureArrays, + Tessellation, + GeometryShader, + TextureArrayRange, + NonFillPolygonMode, + OneDimensionalTextures, + OneDimensionalTextureMipmaps, + HalfAttributes, + RenderToOneDimensionalTexture, + ThreeDimensionalTextureMipmaps, + MultiView, + TextureViewFormat, + ResolveDepthStencil + }; + + enum BeginFrameFlag { + }; + Q_DECLARE_FLAGS(BeginFrameFlags, BeginFrameFlag) + + enum EndFrameFlag { + SkipPresent = 1 << 0 + }; + Q_DECLARE_FLAGS(EndFrameFlags, EndFrameFlag) + + enum ResourceLimit { + TextureSizeMin = 1, + TextureSizeMax, + MaxColorAttachments, + FramesInFlight, + MaxAsyncReadbackFrames, + MaxThreadGroupsPerDimension, + MaxThreadsPerThreadGroup, + MaxThreadGroupX, + MaxThreadGroupY, + MaxThreadGroupZ, + TextureArraySizeMax, + MaxUniformBufferRange, + MaxVertexInputs, + MaxVertexOutputs + }; + + ~QRhi(); + + static QRhi *create(Implementation impl, + QRhiInitParams *params, + Flags flags = {}, + QRhiNativeHandles *importDevice = nullptr); + static bool probe(Implementation impl, QRhiInitParams *params); + + Implementation backend() const; + const char *backendName() const; + static const char *backendName(Implementation impl); + QRhiDriverInfo driverInfo() const; + QThread *thread() const; + + using CleanupCallback = std::function<void(QRhi *)>; + void addCleanupCallback(const CleanupCallback &callback); + void addCleanupCallback(const void *key, const CleanupCallback &callback); + void removeCleanupCallback(const void *key); + void runCleanup(); + + QRhiGraphicsPipeline *newGraphicsPipeline(); + QRhiComputePipeline *newComputePipeline(); + QRhiShaderResourceBindings *newShaderResourceBindings(); + + QRhiBuffer *newBuffer(QRhiBuffer::Type type, + QRhiBuffer::UsageFlags usage, + quint32 size); + + QRhiRenderBuffer *newRenderBuffer(QRhiRenderBuffer::Type type, + const QSize &pixelSize, + int sampleCount = 1, + QRhiRenderBuffer::Flags flags = {}, + QRhiTexture::Format backingFormatHint = QRhiTexture::UnknownFormat); + + QRhiTexture *newTexture(QRhiTexture::Format format, + const QSize &pixelSize, + int sampleCount = 1, + QRhiTexture::Flags flags = {}); + + QRhiTexture *newTexture(QRhiTexture::Format format, + int width, int height, int depth, + int sampleCount = 1, + QRhiTexture::Flags flags = {}); + + QRhiTexture *newTextureArray(QRhiTexture::Format format, + int arraySize, + const QSize &pixelSize, + int sampleCount = 1, + QRhiTexture::Flags flags = {}); + + QRhiSampler *newSampler(QRhiSampler::Filter magFilter, + QRhiSampler::Filter minFilter, + QRhiSampler::Filter mipmapMode, + QRhiSampler::AddressMode addressU, + QRhiSampler::AddressMode addressV, + QRhiSampler::AddressMode addressW = QRhiSampler::Repeat); + + QRhiTextureRenderTarget *newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, + QRhiTextureRenderTarget::Flags flags = {}); + + QRhiSwapChain *newSwapChain(); + FrameOpResult beginFrame(QRhiSwapChain *swapChain, BeginFrameFlags flags = {}); + FrameOpResult endFrame(QRhiSwapChain *swapChain, EndFrameFlags flags = {}); + bool isRecordingFrame() const; + int currentFrameSlot() const; + + FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrameFlags flags = {}); + FrameOpResult endOffscreenFrame(EndFrameFlags flags = {}); + + QRhi::FrameOpResult finish(); + + QRhiResourceUpdateBatch *nextResourceUpdateBatch(); + + QList<int> supportedSampleCounts() const; + + int ubufAlignment() const; + int ubufAligned(int v) const; + + static int mipLevelsForSize(const QSize &size); + static QSize sizeForMipLevel(int mipLevel, const QSize &baseLevelSize); + + bool isYUpInFramebuffer() const; + bool isYUpInNDC() const; + bool isClipDepthZeroToOne() const; + + QMatrix4x4 clipSpaceCorrMatrix() const; + + bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags = {}) const; + bool isFeatureSupported(QRhi::Feature feature) const; + int resourceLimit(ResourceLimit limit) const; + + const QRhiNativeHandles *nativeHandles(); + bool makeThreadLocalNativeContextCurrent(); + + static constexpr int MAX_MIP_LEVELS = 16; // -> max width or height is 65536 + + void releaseCachedResources(); + + bool isDeviceLost() const; + + QByteArray pipelineCacheData(); + void setPipelineCacheData(const QByteArray &data); + + QRhiStats statistics() const; + + static QRhiSwapChainProxyData updateSwapChainProxyData(Implementation impl, QWindow *window); + +protected: + QRhi(); + +private: + Q_DISABLE_COPY(QRhi) + QRhiImplementation *d = nullptr; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::Flags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::BeginFrameFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::EndFrameFlags) + +QT_END_NAMESPACE + +#include <rhi/qrhi_platform.h> + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qrhi_platform.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qrhi_platform.h new file mode 100644 index 0000000000000000000000000000000000000000..32952b89c3193b0f0cc74c071e6a9794a2d3e336 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qrhi_platform.h @@ -0,0 +1,175 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRHIPLATFORM_H +#define QRHIPLATFORM_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the RHI API, with limited compatibility guarantees. +// Usage of this API may make your code source and binary incompatible with +// future versions of Qt. +// + +#include <rhi/qrhi.h> + +#if QT_CONFIG(opengl) +#include <QtGui/qsurfaceformat.h> +#endif + +#if QT_CONFIG(vulkan) +#include <QtGui/qvulkaninstance.h> +#endif + +#if QT_CONFIG(metal) || defined(Q_QDOC) +Q_FORWARD_DECLARE_OBJC_CLASS(MTLDevice); +Q_FORWARD_DECLARE_OBJC_CLASS(MTLCommandQueue); +Q_FORWARD_DECLARE_OBJC_CLASS(MTLCommandBuffer); +Q_FORWARD_DECLARE_OBJC_CLASS(MTLRenderCommandEncoder); +#endif + +QT_BEGIN_NAMESPACE + +struct Q_GUI_EXPORT QRhiNullInitParams : public QRhiInitParams +{ +}; + +struct Q_GUI_EXPORT QRhiNullNativeHandles : public QRhiNativeHandles +{ +}; + +#if QT_CONFIG(opengl) || defined(Q_QDOC) + +class QOpenGLContext; +class QOffscreenSurface; +class QSurface; +class QWindow; + +struct Q_GUI_EXPORT QRhiGles2InitParams : public QRhiInitParams +{ + QRhiGles2InitParams(); + + QSurfaceFormat format; + QSurface *fallbackSurface = nullptr; + QWindow *window = nullptr; + QOpenGLContext *shareContext = nullptr; + + static QOffscreenSurface *newFallbackSurface(const QSurfaceFormat &format = QSurfaceFormat::defaultFormat()); +}; + +struct Q_GUI_EXPORT QRhiGles2NativeHandles : public QRhiNativeHandles +{ + QOpenGLContext *context = nullptr; +}; + +#endif // opengl/qdoc + +#if (QT_CONFIG(vulkan) && __has_include(<vulkan/vulkan.h>)) || defined(Q_QDOC) + +struct Q_GUI_EXPORT QRhiVulkanInitParams : public QRhiInitParams +{ + QVulkanInstance *inst = nullptr; + QWindow *window = nullptr; + QByteArrayList deviceExtensions; + + static QByteArrayList preferredInstanceExtensions(); + static QByteArrayList preferredExtensionsForImportedDevice(); +}; + +struct Q_GUI_EXPORT QRhiVulkanNativeHandles : public QRhiNativeHandles +{ + // to import a physical device (always required) + VkPhysicalDevice physDev = VK_NULL_HANDLE; + // to import a device and queue + VkDevice dev = VK_NULL_HANDLE; + quint32 gfxQueueFamilyIdx = 0; + quint32 gfxQueueIdx = 0; + // and optionally, the mem allocator + void *vmemAllocator = nullptr; + + // only for querying (rhi->nativeHandles()) + VkQueue gfxQueue = VK_NULL_HANDLE; + QVulkanInstance *inst = nullptr; +}; + +struct Q_GUI_EXPORT QRhiVulkanCommandBufferNativeHandles : public QRhiNativeHandles +{ + VkCommandBuffer commandBuffer = VK_NULL_HANDLE; +}; + +struct Q_GUI_EXPORT QRhiVulkanRenderPassNativeHandles : public QRhiNativeHandles +{ + VkRenderPass renderPass = VK_NULL_HANDLE; +}; + +#endif // vulkan/qdoc + +#if defined(Q_OS_WIN) || defined(Q_QDOC) + +// no d3d includes here, to prevent precompiled header mess due to COM, hence the void pointers + +struct Q_GUI_EXPORT QRhiD3D11InitParams : public QRhiInitParams +{ + bool enableDebugLayer = false; +}; + +struct Q_GUI_EXPORT QRhiD3D11NativeHandles : public QRhiNativeHandles +{ + // to import a device and a context + void *dev = nullptr; + void *context = nullptr; + // alternatively, to specify the device feature level and/or the adapter to use + int featureLevel = 0; + quint32 adapterLuidLow = 0; + qint32 adapterLuidHigh = 0; +}; + +struct Q_GUI_EXPORT QRhiD3D12InitParams : public QRhiInitParams +{ + bool enableDebugLayer = false; +}; + +struct Q_GUI_EXPORT QRhiD3D12NativeHandles : public QRhiNativeHandles +{ + // to import a device + void *dev = nullptr; + int minimumFeatureLevel = 0; + // to just specify the adapter to use, set these and leave dev set to null + quint32 adapterLuidLow = 0; + qint32 adapterLuidHigh = 0; + // in addition, can specify the command queue to use + void *commandQueue = nullptr; +}; + +struct Q_GUI_EXPORT QRhiD3D12CommandBufferNativeHandles : public QRhiNativeHandles +{ + void *commandList = nullptr; // ID3D12GraphicsCommandList1 +}; + +#endif // WIN/QDOC + +#if QT_CONFIG(metal) || defined(Q_QDOC) + +struct Q_GUI_EXPORT QRhiMetalInitParams : public QRhiInitParams +{ +}; + +struct Q_GUI_EXPORT QRhiMetalNativeHandles : public QRhiNativeHandles +{ + MTLDevice *dev = nullptr; + MTLCommandQueue *cmdQueue = nullptr; +}; + +struct Q_GUI_EXPORT QRhiMetalCommandBufferNativeHandles : public QRhiNativeHandles +{ + MTLCommandBuffer *commandBuffer = nullptr; + MTLRenderCommandEncoder *encoder = nullptr; +}; + +#endif // MACOS/IOS/QDOC + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qshader.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qshader.h new file mode 100644 index 0000000000000000000000000000000000000000..39064d1a75bae0c5dec87549858037d6c25e8cb2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qshader.h @@ -0,0 +1,241 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSHADER_H +#define QSHADER_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the RHI API, with limited compatibility guarantees. +// Usage of this API may make your code source and binary incompatible with +// future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qhash.h> +#include <QtCore/qmap.h> +#include <rhi/qshaderdescription.h> + +QT_BEGIN_NAMESPACE + +struct QShaderPrivate; +class QShaderKey; + +#ifdef Q_OS_INTEGRITY + class QShaderVersion; + size_t qHash(const QShaderVersion &, size_t = 0) noexcept; +#endif + +class Q_GUI_EXPORT QShaderVersion +{ +public: + enum Flag { + GlslEs = 0x01 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + QShaderVersion() = default; + QShaderVersion(int v, Flags f = Flags()); + + int version() const { return m_version; } + void setVersion(int v) { m_version = v; } + + Flags flags() const { return m_flags; } + void setFlags(Flags f) { m_flags = f; } + +private: + int m_version = 100; + Flags m_flags; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QShaderVersion::Flags) +Q_DECLARE_TYPEINFO(QShaderVersion, Q_RELOCATABLE_TYPE); + +class QShaderCode; +Q_GUI_EXPORT size_t qHash(const QShaderCode &, size_t = 0) noexcept; + +class Q_GUI_EXPORT QShaderCode +{ +public: + QShaderCode() = default; + QShaderCode(const QByteArray &code, const QByteArray &entry = QByteArray()); + + QByteArray shader() const { return m_shader; } + void setShader(const QByteArray &code) { m_shader = code; } + + QByteArray entryPoint() const { return m_entryPoint; } + void setEntryPoint(const QByteArray &entry) { m_entryPoint = entry; } + +private: + friend Q_GUI_EXPORT size_t qHash(const QShaderCode &, size_t) noexcept; + + QByteArray m_shader; + QByteArray m_entryPoint; +}; + +Q_DECLARE_TYPEINFO(QShaderCode, Q_RELOCATABLE_TYPE); + +class Q_GUI_EXPORT QShader +{ +public: + enum Stage { + VertexStage = 0, + TessellationControlStage, + TessellationEvaluationStage, + GeometryStage, + FragmentStage, + ComputeStage + }; + + enum Source { + SpirvShader = 0, + GlslShader, + HlslShader, + DxbcShader, // fxc + MslShader, + DxilShader, // dxc + MetalLibShader, // xcrun metal + xcrun metallib + WgslShader + }; + + enum Variant { + StandardShader = 0, + BatchableVertexShader, + UInt16IndexedVertexAsComputeShader, + UInt32IndexedVertexAsComputeShader, + NonIndexedVertexAsComputeShader + }; + + enum class SerializedFormatVersion { + Latest = 0, + Qt_6_5, + Qt_6_4 + }; + + QShader(); + QShader(const QShader &other); + QShader &operator=(const QShader &other); + QShader(QShader &&other) noexcept : d(std::exchange(other.d, nullptr)) {} + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QShader) + ~QShader(); + + void swap(QShader &other) noexcept { qt_ptr_swap(d, other.d); } + void detach(); + + bool isValid() const; + + Stage stage() const; + void setStage(Stage stage); + + QShaderDescription description() const; + void setDescription(const QShaderDescription &desc); + + QList<QShaderKey> availableShaders() const; + QShaderCode shader(const QShaderKey &key) const; + void setShader(const QShaderKey &key, const QShaderCode &shader); + void removeShader(const QShaderKey &key); + + QByteArray serialized(SerializedFormatVersion version = SerializedFormatVersion::Latest) const; + static QShader fromSerialized(const QByteArray &data); + + using NativeResourceBindingMap = QMap<int, QPair<int, int> >; // binding -> native_binding[, native_binding] + NativeResourceBindingMap nativeResourceBindingMap(const QShaderKey &key) const; + void setResourceBindingMap(const QShaderKey &key, const NativeResourceBindingMap &map); + void removeResourceBindingMap(const QShaderKey &key); + + struct SeparateToCombinedImageSamplerMapping { + QByteArray combinedSamplerName; + int textureBinding; + int samplerBinding; + }; + using SeparateToCombinedImageSamplerMappingList = QList<SeparateToCombinedImageSamplerMapping>; + SeparateToCombinedImageSamplerMappingList separateToCombinedImageSamplerMappingList(const QShaderKey &key) const; + void setSeparateToCombinedImageSamplerMappingList(const QShaderKey &key, + const SeparateToCombinedImageSamplerMappingList &list); + void removeSeparateToCombinedImageSamplerMappingList(const QShaderKey &key); + + struct NativeShaderInfo { + int flags = 0; + QMap<int, int> extraBufferBindings; + }; + NativeShaderInfo nativeShaderInfo(const QShaderKey &key) const; + void setNativeShaderInfo(const QShaderKey &key, const NativeShaderInfo &info); + void removeNativeShaderInfo(const QShaderKey &key); + +private: + QShaderPrivate *d; + friend struct QShaderPrivate; + friend Q_GUI_EXPORT bool operator==(const QShader &, const QShader &) noexcept; + friend Q_GUI_EXPORT size_t qHash(const QShader &, size_t) noexcept; +#ifndef QT_NO_DEBUG_STREAM + friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QShader &); +#endif +}; + +class Q_GUI_EXPORT QShaderKey +{ +public: + QShaderKey() = default; + QShaderKey(QShader::Source s, + const QShaderVersion &sver, + QShader::Variant svar = QShader::StandardShader); + + QShader::Source source() const { return m_source; } + void setSource(QShader::Source s) { m_source = s; } + + QShaderVersion sourceVersion() const { return m_sourceVersion; } + void setSourceVersion(const QShaderVersion &sver) { m_sourceVersion = sver; } + + QShader::Variant sourceVariant() const { return m_sourceVariant; } + void setSourceVariant(QShader::Variant svar) { m_sourceVariant = svar; } + +private: + QShader::Source m_source = QShader::SpirvShader; + QShaderVersion m_sourceVersion; + QShader::Variant m_sourceVariant = QShader::StandardShader; +}; + +Q_DECLARE_TYPEINFO(QShaderKey, Q_RELOCATABLE_TYPE); + +Q_GUI_EXPORT bool operator==(const QShader &lhs, const QShader &rhs) noexcept; +Q_GUI_EXPORT size_t qHash(const QShader &s, size_t seed = 0) noexcept; + +inline bool operator!=(const QShader &lhs, const QShader &rhs) noexcept +{ + return !(lhs == rhs); +} + +Q_GUI_EXPORT bool operator==(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept; +Q_GUI_EXPORT bool operator<(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept; +Q_GUI_EXPORT bool operator==(const QShaderKey &lhs, const QShaderKey &rhs) noexcept; +Q_GUI_EXPORT bool operator<(const QShaderKey &lhs, const QShaderKey &rhs) noexcept; +Q_GUI_EXPORT bool operator==(const QShaderCode &lhs, const QShaderCode &rhs) noexcept; + +inline bool operator!=(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept +{ + return !(lhs == rhs); +} + +inline bool operator!=(const QShaderKey &lhs, const QShaderKey &rhs) noexcept +{ + return !(lhs == rhs); +} + +inline bool operator!=(const QShaderCode &lhs, const QShaderCode &rhs) noexcept +{ + return !(lhs == rhs); +} + +Q_GUI_EXPORT size_t qHash(const QShaderKey &k, size_t seed = 0) noexcept; + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QShader &); +Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QShaderKey &k); +Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QShaderVersion &v); +#endif + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qshaderdescription.h b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qshaderdescription.h new file mode 100644 index 0000000000000000000000000000000000000000..636013c3d0889b810ecf81709ba9502fc69dd368 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtGui/6.8.1/QtGui/rhi/qshaderdescription.h @@ -0,0 +1,386 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSHADERDESCRIPTION_H +#define QSHADERDESCRIPTION_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the RHI API, with limited compatibility guarantees. +// Usage of this API may make your code source and binary incompatible with +// future versions of Qt. +// + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qstring.h> +#include <QtCore/qlist.h> +#include <array> + +QT_BEGIN_NAMESPACE + +struct QShaderDescriptionPrivate; +class QDataStream; + +class Q_GUI_EXPORT QShaderDescription +{ +public: + QShaderDescription(); + QShaderDescription(const QShaderDescription &other); + QShaderDescription &operator=(const QShaderDescription &other); + ~QShaderDescription(); + void detach(); + + bool isValid() const; + + void serialize(QDataStream *stream, int version) const; + QByteArray toJson() const; + + static QShaderDescription deserialize(QDataStream *stream, int version); + + enum VariableType { + Unknown = 0, + + // do not reorder + Float, + Vec2, + Vec3, + Vec4, + Mat2, + Mat2x3, + Mat2x4, + Mat3, + Mat3x2, + Mat3x4, + Mat4, + Mat4x2, + Mat4x3, + + Int, + Int2, + Int3, + Int4, + + Uint, + Uint2, + Uint3, + Uint4, + + Bool, + Bool2, + Bool3, + Bool4, + + Double, + Double2, + Double3, + Double4, + DMat2, + DMat2x3, + DMat2x4, + DMat3, + DMat3x2, + DMat3x4, + DMat4, + DMat4x2, + DMat4x3, + + Sampler1D, + Sampler2D, + Sampler2DMS, + Sampler3D, + SamplerCube, + Sampler1DArray, + Sampler2DArray, + Sampler2DMSArray, + Sampler3DArray, + SamplerCubeArray, + SamplerRect, + SamplerBuffer, + SamplerExternalOES, + Sampler, + + Image1D, + Image2D, + Image2DMS, + Image3D, + ImageCube, + Image1DArray, + Image2DArray, + Image2DMSArray, + Image3DArray, + ImageCubeArray, + ImageRect, + ImageBuffer, + + Struct, + + Half, + Half2, + Half3, + Half4 + }; + + enum ImageFormat { + // must match SPIR-V's ImageFormat + ImageFormatUnknown = 0, + ImageFormatRgba32f = 1, + ImageFormatRgba16f = 2, + ImageFormatR32f = 3, + ImageFormatRgba8 = 4, + ImageFormatRgba8Snorm = 5, + ImageFormatRg32f = 6, + ImageFormatRg16f = 7, + ImageFormatR11fG11fB10f = 8, + ImageFormatR16f = 9, + ImageFormatRgba16 = 10, + ImageFormatRgb10A2 = 11, + ImageFormatRg16 = 12, + ImageFormatRg8 = 13, + ImageFormatR16 = 14, + ImageFormatR8 = 15, + ImageFormatRgba16Snorm = 16, + ImageFormatRg16Snorm = 17, + ImageFormatRg8Snorm = 18, + ImageFormatR16Snorm = 19, + ImageFormatR8Snorm = 20, + ImageFormatRgba32i = 21, + ImageFormatRgba16i = 22, + ImageFormatRgba8i = 23, + ImageFormatR32i = 24, + ImageFormatRg32i = 25, + ImageFormatRg16i = 26, + ImageFormatRg8i = 27, + ImageFormatR16i = 28, + ImageFormatR8i = 29, + ImageFormatRgba32ui = 30, + ImageFormatRgba16ui = 31, + ImageFormatRgba8ui = 32, + ImageFormatR32ui = 33, + ImageFormatRgb10a2ui = 34, + ImageFormatRg32ui = 35, + ImageFormatRg16ui = 36, + ImageFormatRg8ui = 37, + ImageFormatR16ui = 38, + ImageFormatR8ui = 39 + }; + + enum ImageFlag { + ReadOnlyImage = 1 << 0, + WriteOnlyImage = 1 << 1 + }; + Q_DECLARE_FLAGS(ImageFlags, ImageFlag) + + enum QualifierFlag { + QualifierReadOnly = 1 << 0, + QualifierWriteOnly = 1 << 1, + QualifierCoherent = 1 << 2, + QualifierVolatile = 1 << 3, + QualifierRestrict = 1 << 4, + }; + Q_DECLARE_FLAGS(QualifierFlags, QualifierFlag) + + // Optional data (like decorations) usually default to an otherwise invalid value (-1 or 0). This is intentional. + + struct BlockVariable { + QByteArray name; + VariableType type = Unknown; + int offset = 0; + int size = 0; + QList<int> arrayDims; + int arrayStride = 0; + int matrixStride = 0; + bool matrixIsRowMajor = false; + QList<BlockVariable> structMembers; + }; + + struct InOutVariable { + QByteArray name; + VariableType type = Unknown; + int location = -1; + int binding = -1; + int descriptorSet = -1; + ImageFormat imageFormat = ImageFormatUnknown; + ImageFlags imageFlags; + QList<int> arrayDims; + bool perPatch = false; + QList<BlockVariable> structMembers; + }; + + struct UniformBlock { + QByteArray blockName; + QByteArray structName; // instanceName + int size = 0; + int binding = -1; + int descriptorSet = -1; + QList<BlockVariable> members; + }; + + struct PushConstantBlock { + QByteArray name; + int size = 0; + QList<BlockVariable> members; + }; + + struct StorageBlock { + QByteArray blockName; + QByteArray instanceName; + int knownSize = 0; + int binding = -1; + int descriptorSet = -1; + QList<BlockVariable> members; + int runtimeArrayStride = 0; + QualifierFlags qualifierFlags; + }; + + QList<InOutVariable> inputVariables() const; + QList<InOutVariable> outputVariables() const; + QList<UniformBlock> uniformBlocks() const; + QList<PushConstantBlock> pushConstantBlocks() const; + QList<StorageBlock> storageBlocks() const; + QList<InOutVariable> combinedImageSamplers() const; + QList<InOutVariable> separateImages() const; + QList<InOutVariable> separateSamplers() const; + QList<InOutVariable> storageImages() const; + + enum BuiltinType { + // must match SpvBuiltIn + PositionBuiltin = 0, + PointSizeBuiltin = 1, + ClipDistanceBuiltin = 3, + CullDistanceBuiltin = 4, + VertexIdBuiltin = 5, + InstanceIdBuiltin = 6, + PrimitiveIdBuiltin = 7, + InvocationIdBuiltin = 8, + LayerBuiltin = 9, + ViewportIndexBuiltin = 10, + TessLevelOuterBuiltin = 11, + TessLevelInnerBuiltin = 12, + TessCoordBuiltin = 13, + PatchVerticesBuiltin = 14, + FragCoordBuiltin = 15, + PointCoordBuiltin = 16, + FrontFacingBuiltin = 17, + SampleIdBuiltin = 18, + SamplePositionBuiltin = 19, + SampleMaskBuiltin = 20, + FragDepthBuiltin = 22, + NumWorkGroupsBuiltin = 24, + WorkgroupSizeBuiltin = 25, + WorkgroupIdBuiltin = 26, + LocalInvocationIdBuiltin = 27, + GlobalInvocationIdBuiltin = 28, + LocalInvocationIndexBuiltin = 29, + VertexIndexBuiltin = 42, + InstanceIndexBuiltin = 43 + }; + + struct BuiltinVariable { + BuiltinType type; + VariableType varType; + QList<int> arrayDims; + }; + + QList<BuiltinVariable> inputBuiltinVariables() const; + QList<BuiltinVariable> outputBuiltinVariables() const; + + std::array<uint, 3> computeShaderLocalSize() const; + + uint tessellationOutputVertexCount() const; + + enum TessellationMode { + UnknownTessellationMode, + TrianglesTessellationMode, + QuadTessellationMode, + IsolineTessellationMode + }; + + TessellationMode tessellationMode() const; + + enum TessellationWindingOrder { + UnknownTessellationWindingOrder, + CwTessellationWindingOrder, + CcwTessellationWindingOrder + }; + + TessellationWindingOrder tessellationWindingOrder() const; + + enum TessellationPartitioning { + UnknownTessellationPartitioning, + EqualTessellationPartitioning, + FractionalEvenTessellationPartitioning, + FractionalOddTessellationPartitioning + }; + + TessellationPartitioning tessellationPartitioning() const; + +private: + QShaderDescriptionPrivate *d; + friend struct QShaderDescriptionPrivate; +#ifndef QT_NO_DEBUG_STREAM + friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription &); +#endif + friend Q_GUI_EXPORT bool operator==(const QShaderDescription &lhs, const QShaderDescription &rhs) noexcept; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QShaderDescription::ImageFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QShaderDescription::QualifierFlags) + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription &); +Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription::InOutVariable &); +Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription::BlockVariable &); +Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription::UniformBlock &); +Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription::PushConstantBlock &); +Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription::StorageBlock &); +Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription::BuiltinVariable &); +#endif + +Q_GUI_EXPORT bool operator==(const QShaderDescription &lhs, const QShaderDescription &rhs) noexcept; +Q_GUI_EXPORT bool operator==(const QShaderDescription::InOutVariable &lhs, const QShaderDescription::InOutVariable &rhs) noexcept; +Q_GUI_EXPORT bool operator==(const QShaderDescription::BlockVariable &lhs, const QShaderDescription::BlockVariable &rhs) noexcept; +Q_GUI_EXPORT bool operator==(const QShaderDescription::UniformBlock &lhs, const QShaderDescription::UniformBlock &rhs) noexcept; +Q_GUI_EXPORT bool operator==(const QShaderDescription::PushConstantBlock &lhs, const QShaderDescription::PushConstantBlock &rhs) noexcept; +Q_GUI_EXPORT bool operator==(const QShaderDescription::StorageBlock &lhs, const QShaderDescription::StorageBlock &rhs) noexcept; +Q_GUI_EXPORT bool operator==(const QShaderDescription::BuiltinVariable &lhs, const QShaderDescription::BuiltinVariable &rhs) noexcept; + +inline bool operator!=(const QShaderDescription &lhs, const QShaderDescription &rhs) noexcept +{ + return !(lhs == rhs); +} + +inline bool operator!=(const QShaderDescription::InOutVariable &lhs, const QShaderDescription::InOutVariable &rhs) noexcept +{ + return !(lhs == rhs); +} + +inline bool operator!=(const QShaderDescription::BlockVariable &lhs, const QShaderDescription::BlockVariable &rhs) noexcept +{ + return !(lhs == rhs); +} + +inline bool operator!=(const QShaderDescription::UniformBlock &lhs, const QShaderDescription::UniformBlock &rhs) noexcept +{ + return !(lhs == rhs); +} + +inline bool operator!=(const QShaderDescription::PushConstantBlock &lhs, const QShaderDescription::PushConstantBlock &rhs) noexcept +{ + return !(lhs == rhs); +} + +inline bool operator!=(const QShaderDescription::StorageBlock &lhs, const QShaderDescription::StorageBlock &rhs) noexcept +{ + return !(lhs == rhs); +} + +inline bool operator!=(const QShaderDescription::BuiltinVariable &lhs, const QShaderDescription::BuiltinVariable &rhs) noexcept +{ + return !(lhs == rhs); +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-blob.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-blob.h new file mode 100644 index 0000000000000000000000000000000000000000..55fd1882b1f1f17d25239f9f18ddbdde755d7dec --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-blob.h @@ -0,0 +1 @@ +#include "../../src/hb-blob.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-buffer.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..62021d56ee1130c3402857e2aaead427dec30808 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-buffer.h @@ -0,0 +1 @@ +#include "../../src/hb-buffer.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-common.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-common.h new file mode 100644 index 0000000000000000000000000000000000000000..05ef698b74d97575ffafb35f7fe2a4ac3bdfdabb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-common.h @@ -0,0 +1 @@ +#include "../../src/hb-common.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-deprecated.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-deprecated.h new file mode 100644 index 0000000000000000000000000000000000000000..e6a9ee26bf9f3ef3f02d792ac9fe23f2f238fe21 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-deprecated.h @@ -0,0 +1 @@ +#include "../../src/hb-deprecated.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-face.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-face.h new file mode 100644 index 0000000000000000000000000000000000000000..7f33933228d465f0652e7eddd55635620ac5078c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-face.h @@ -0,0 +1 @@ +#include "../../src/hb-face.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-font.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-font.h new file mode 100644 index 0000000000000000000000000000000000000000..5962b6706f622252e3b49236c1c915c0bec55605 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-font.h @@ -0,0 +1 @@ +#include "../../src/hb-font.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-font.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-font.h new file mode 100644 index 0000000000000000000000000000000000000000..e292771d49514985bdd786dc0543ab582c2e85ae --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-font.h @@ -0,0 +1 @@ +#include "../../src/hb-ot-font.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-layout.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-layout.h new file mode 100644 index 0000000000000000000000000000000000000000..86d5c93cdc8a920fd27f8978823abb2dc75ddb87 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-layout.h @@ -0,0 +1 @@ +#include "../../src/hb-ot-layout.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-math.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-math.h new file mode 100644 index 0000000000000000000000000000000000000000..2d4340c537d1afc9458360a3f6c3b3dffbb8b3da --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-math.h @@ -0,0 +1 @@ +#include "../../src/hb-ot-math.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-shape.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-shape.h new file mode 100644 index 0000000000000000000000000000000000000000..263475ea2ea4dda6b2cafa79358cf2b2fa926b6f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-shape.h @@ -0,0 +1 @@ +#include "../../src/hb-ot-shape.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-tag.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-tag.h new file mode 100644 index 0000000000000000000000000000000000000000..604fcdf54d68021ce4e7e9dc1fe677f391f509d7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-tag.h @@ -0,0 +1 @@ +#include "../../src/hb-ot-tag.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-var.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-var.h new file mode 100644 index 0000000000000000000000000000000000000000..6af1209d4d48308c8d663fec3d77c7555c1a2d07 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot-var.h @@ -0,0 +1 @@ +#include "../../src/hb-ot-var.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot.h new file mode 100644 index 0000000000000000000000000000000000000000..67874c70b54ced151c4de1429490ee7c674b9c9e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-ot.h @@ -0,0 +1 @@ +#include "../../src/hb-ot.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-set.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-set.h new file mode 100644 index 0000000000000000000000000000000000000000..eaa5b0b2c654ef3973d75b7195d1f06a381edb8d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-set.h @@ -0,0 +1 @@ +#include "../../src/hb-set.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-shape-plan.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-shape-plan.h new file mode 100644 index 0000000000000000000000000000000000000000..c53729cf4ab47dd7d850d7cbc69f04f6210da779 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-shape-plan.h @@ -0,0 +1 @@ +#include "../../src/hb-shape-plan.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-shape.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-shape.h new file mode 100644 index 0000000000000000000000000000000000000000..2bcb20991132347b60a6c22a6b05230383a1655b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-shape.h @@ -0,0 +1 @@ +#include "../../src/hb-shape.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-unicode.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-unicode.h new file mode 100644 index 0000000000000000000000000000000000000000..0dc6f32bfd71d4321b6e3a409f39e0711268ab62 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-unicode.h @@ -0,0 +1 @@ +#include "../../src/hb-unicode.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-version.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-version.h new file mode 100644 index 0000000000000000000000000000000000000000..adb530367f536e6890286c5b3dc935bd8579c4db --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb-version.h @@ -0,0 +1 @@ +#include "../../src/hb-version.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb.h b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb.h new file mode 100644 index 0000000000000000000000000000000000000000..8c0ff6e6e05ff08a2de1b30dbeb4a7352233e2ee --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHarfbuzz/harfbuzz/hb.h @@ -0,0 +1 @@ +#include "../../src/hb.h" diff --git a/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qfilternamedialog_p.h b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qfilternamedialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f2f75ae06fed222f2bb42b03ef826e26e7dc9466 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qfilternamedialog_p.h @@ -0,0 +1,43 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFILTERNAMEDIALOG_H +#define QFILTERNAMEDIALOG_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the help generator tools. This header file may change from version +// to version without notice, or even be removed. +// +// We mean it. +// + +#include "ui_qfilternamedialog.h" + +#include <QtWidgets/qdialog.h> + +QT_BEGIN_NAMESPACE + +class QFilterNameDialog : public QDialog +{ + Q_OBJECT + +public: + QFilterNameDialog(QWidget *parent = nullptr); + + void setFilterName(const QString &filter); + QString filterName() const { return m_ui.lineEdit->text(); } + +private slots: + void updateOkButton(); + +private: + Ui::FilterNameDialogClass m_ui; +}; + +QT_END_NAMESPACE + +#endif // QFILTERNAMEDIALOG_H diff --git a/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpcollectionhandler_p.h b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpcollectionhandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ecf445e361f015165deffc3f2c9e2334055ab0ea --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpcollectionhandler_p.h @@ -0,0 +1,201 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHELPCOLLECTIONHANDLER_H +#define QHELPCOLLECTIONHANDLER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the help generator tools. This header file may change from version +// to version without notice, or even be removed. +// +// We mean it. +// + +#include "qhelpdbreader_p.h" +#include "qhelplink.h" + +#include <QtCore/qdatetime.h> +#include <QtCore/qobject.h> +#include <QtCore/qstringlist.h> + +QT_BEGIN_NAMESPACE + +class QHelpFilterData; +class QSqlQuery; +class QVariant; +class QVersionNumber; + +class QHelpCollectionHandler : public QObject +{ + Q_OBJECT + +public: + struct FileInfo + { + QString fileName; + QString folderName; + QString namespaceName; + }; + typedef QList<FileInfo> FileInfoList; + + struct TimeStamp + { + int namespaceId = -1; + int folderId = -1; + QString fileName; + int size = 0; + QDateTime timeStamp; + }; + + struct ContentsData + { + QString namespaceName; + QString folderName; + QList<QByteArray> contentsList; + }; + + explicit QHelpCollectionHandler(const QString &collectionFile, QObject *parent = nullptr); + ~QHelpCollectionHandler(); + + QString collectionFile() const { return m_collectionFile; } + + bool openCollectionFile(); + bool copyCollectionFile(const QString &fileName); + + // *** Legacy block start *** + // legacy API since Qt 5.13 + + // use filters() instead + QStringList customFilters() const; + + // use QHelpFilterEngine::removeFilter() instead + bool removeCustomFilter(const QString &filterName); + + // use QHelpFilterEngine::setFilterData() instead + bool addCustomFilter(const QString &filterName, const QStringList &attributes); + + // use files(const QString &, const QString &, const QString &) instead + QStringList files(const QString &namespaceName, + const QStringList &filterAttributes, + const QString &extensionFilter) const; + + // use namespaceForFile(const QUrl &, const QString &) instead + QString namespaceForFile(const QUrl &url, const QStringList &filterAttributes) const; + + // use findFile(const QUrl &, const QString &) instead + QUrl findFile(const QUrl &url, const QStringList &filterAttributes) const; + + // use indicesForFilter(const QString &) instead + QStringList indicesForFilter(const QStringList &filterAttributes) const; + + // use contentsForFilter(const QString &) instead + QList<ContentsData> contentsForFilter(const QStringList &filterAttributes) const; + + // use QHelpFilterEngine::activeFilter() and filterData(const QString &) instead; + QStringList filterAttributes() const; + + // use filterData(const QString &) instead + QStringList filterAttributes(const QString &filterName) const; + + // use filterData(const QString &) instead + QList<QStringList> filterAttributeSets(const QString &namespaceName) const; + + // *** Legacy block end *** + + QStringList filters() const; + + QStringList availableComponents() const; + QList<QVersionNumber> availableVersions() const; + QMap<QString, QString> namespaceToComponent() const; + QMap<QString, QVersionNumber> namespaceToVersion() const; + QHelpFilterData filterData(const QString &filterName) const; + bool setFilterData(const QString &filterName, const QHelpFilterData &filterData); + bool removeFilter(const QString &filterName); + + FileInfo registeredDocumentation(const QString &namespaceName) const; + FileInfoList registeredDocumentations() const; + bool registerDocumentation(const QString &fileName); + bool unregisterDocumentation(const QString &namespaceName); + + bool fileExists(const QUrl &url) const; + QStringList files(const QString &namespaceName, + const QString &filterName, + const QString &extensionFilter) const; + QString namespaceForFile(const QUrl &url, const QString &filterName) const; + QUrl findFile(const QUrl &url, const QString &filterName) const; + QByteArray fileData(const QUrl &url) const; + + QStringList indicesForFilter(const QString &filterName) const; + QList<ContentsData> contentsForFilter(const QString &filterName) const; + + bool removeCustomValue(const QString &key); + QVariant customValue(const QString &key, const QVariant &defaultValue) const; + bool setCustomValue(const QString &key, const QVariant &value); + + int registerNamespace(const QString &nspace, const QString &fileName); + int registerVirtualFolder(const QString &folderName, int namespaceId); + int registerComponent(const QString &componentName, int namespaceId); + bool registerVersion(const QString &version, int namespaceId); + + QList<QHelpLink> documentsForIdentifier(const QString &id, const QString &filterName) const; + QList<QHelpLink> documentsForKeyword(const QString &keyword, const QString &filterName) const; + QList<QHelpLink> documentsForIdentifier(const QString &id, + const QStringList &filterAttributes) const; + QList<QHelpLink> documentsForKeyword(const QString &keyword, + const QStringList &filterAttributes) const; + + QStringList namespacesForFilter(const QString &filterName) const; + + void setReadOnly(bool readOnly) { m_readOnly = readOnly; } + + static QUrl buildQUrl(const QString &ns, const QString &folder, + const QString &relFileName, const QString &anchor); + +signals: + void error(const QString &msg); + +private: + // legacy stuff + QList<QHelpLink> documentsForField(const QString &fieldName, + const QString &fieldValue, + const QStringList &filterAttributes) const; + + QString namespaceVersion(const QString &namespaceName) const; + QMultiMap<QString, QUrl> linksForField(const QString &fieldName, const QString &fieldValue, + const QString &filterName) const; + QList<QHelpLink> documentsForField(const QString &fieldName, + const QString &fieldValue, + const QString &filterName) const; + + bool isDBOpened() const; + bool createTables(QSqlQuery *query); + void closeDB(); + bool recreateIndexAndNamespaceFilterTables(QSqlQuery *query); + bool registerIndexAndNamespaceFilterTables(const QString &nameSpace, + bool createDefaultVersionFilter = false); + void createVersionFilter(const QString &version); + bool registerFilterAttributes(const QList<QStringList> &attributeSets, int nsId); + bool registerFileAttributeSets(const QList<QStringList> &attributeSets, int nsId); + bool registerIndexTable(const QHelpDBReader::IndexTable &indexTable, + int nsId, int vfId, const QString &fileName); + bool unregisterIndexTable(int nsId, int vfId); + QString absoluteDocPath(const QString &fileName) const; + bool isTimeStampCorrect(const TimeStamp &timeStamp) const; + bool hasTimeStampInfo(const QString &nameSpace) const; + void scheduleVacuum(); + void execVacuum(); + + QString m_collectionFile; + QString m_connectionName; + std::unique_ptr<QSqlQuery> m_query; + bool m_vacuumScheduled = false; + bool m_readOnly = true; +}; + +QT_END_NAMESPACE + +#endif // QHELPCOLLECTIONHANDLER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpdbreader_p.h b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpdbreader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f3471c51c64f3ccd0ec909a45a4258e05a956706 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpdbreader_p.h @@ -0,0 +1,100 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHELPDBREADER_H +#define QHELPDBREADER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the help generator tools. This header file may change from version +// to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qbytearray.h> +#include <QtCore/qobject.h> +#include <QtCore/qstringlist.h> + +QT_BEGIN_NAMESPACE + +class QSqlQuery; + +class QHelpDBReader : public QObject +{ + Q_OBJECT + +public: + class IndexItem + { + public: + QString name; + QString identifier; + int fileId = 0; + QString anchor; + QStringList filterAttributes; + }; + + class FileItem + { + public: + QString name; + QString title; + QStringList filterAttributes; + }; + + class ContentsItem + { + public: + QByteArray data; + QStringList filterAttributes; + }; + + class IndexTable + { + public: + QList<IndexItem> indexItems; + QList<FileItem> fileItems; + QList<ContentsItem> contentsItems; + QStringList usedFilterAttributes; + }; + + QHelpDBReader(const QString &dbName); + QHelpDBReader(const QString &dbName, const QString &uniqueId, QObject *parent); + ~QHelpDBReader(); + + bool init(); + + QString namespaceName() const; + QString virtualFolder() const; + QString version() const; + IndexTable indexTable() const; + QList<QStringList> filterAttributeSets() const; + QMultiMap<QString, QByteArray> filesData(const QStringList &filterAttributes, + const QString &extensionFilter = {}) const; + QByteArray fileData(const QString &virtualFolder, const QString &filePath) const; + + QStringList customFilters() const; + QStringList filterAttributes(const QString &filterName = {}) const; + + QVariant metaData(const QString &name) const; + +private: + QString quote(const QString &string) const; + bool initDB(); + QString qtVersionHeuristic() const; + + bool m_initDone = false; + QString m_dbName; + QString m_uniqueId; + QString m_error; + std::unique_ptr<QSqlQuery> m_query; + mutable QString m_namespace; +}; + +QT_END_NAMESPACE + +#endif // QHELPDBREADER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpsearchindexreader_p.h b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpsearchindexreader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2885992afd1bc7403f5c5004f22f2449cd7cdebe --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpsearchindexreader_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHELPSEARCHINDEXREADER_H +#define QHELPSEARCHINDEXREADER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the help generator tools. This header file may change from version +// to version without notice, or even be removed. +// +// We mean it. +// + +#include "qhelpsearchresult.h" + +#include <QtCore/qlist.h> +#include <QtCore/qmutex.h> +#include <QtCore/qthread.h> + +QT_BEGIN_NAMESPACE + +namespace fulltextsearch { + +// TODO: Employ QFuture / QtConcurrent::run() ? +class QHelpSearchIndexReader : public QThread +{ + Q_OBJECT + +public: + ~QHelpSearchIndexReader() override; + + void cancelSearching(); + void search(const QString &collectionFile, const QString &indexFilesFolder, + const QString &searchInput, bool usesFilterEngine = false); + int searchResultCount() const; + QList<QHelpSearchResult> searchResults(int start, int end) const; + +signals: + void searchingStarted(); + void searchingFinished(); + +private: + void run() override; + + mutable QMutex m_mutex; + QList<QHelpSearchResult> m_searchResults; + bool m_cancel = false; + QString m_collectionFile; + QString m_searchInput; + QString m_indexFilesFolder; + bool m_usesFilterEngine = false; +}; + +} // namespace fulltextsearch + +QT_END_NAMESPACE + +#endif // QHELPSEARCHINDEXREADER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpsearchindexwriter_p.h b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpsearchindexwriter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..55d76c5a2ae58215e9cc404eec8423a1ac67c601 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qhelpsearchindexwriter_p.h @@ -0,0 +1,58 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHELPSEARCHINDEXWRITER_H +#define QHELPSEARCHINDEXWRITER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the help generator tools. This header file may change from version +// to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qmutex.h> +#include <QtCore/qthread.h> + +QT_BEGIN_NAMESPACE + +class QSqlDatabase; + +namespace fulltextsearch { + +// TODO: Employ QFuture / QtConcurrent::run() ? +class QHelpSearchIndexWriter : public QThread +{ + Q_OBJECT + +public: + ~QHelpSearchIndexWriter() override; + + void cancelIndexing(); + void updateIndex(const QString &collectionFile, const QString &indexFilesFolder, bool reindex); + +signals: + void indexingStarted(); + void indexingFinished(); + +private: + void run() override; + +private: + QMutex m_mutex; + + bool m_cancel = false; + bool m_reindex; + QString m_collectionFile; + QString m_indexFilesFolder; +}; + +} // namespace fulltextsearch + +QT_END_NAMESPACE + +#endif // QHELPSEARCHINDEXWRITER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qoptionswidget_p.h b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qoptionswidget_p.h new file mode 100644 index 0000000000000000000000000000000000000000..40caa7fd9d31bc0309d3eb41850a6f0f4f876906 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtHelp/6.8.1/QtHelp/private/qoptionswidget_p.h @@ -0,0 +1,61 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPTIONSWIDGET_H +#define QOPTIONSWIDGET_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the help generator tools. This header file may change from version +// to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qhash.h> +#include <QtWidgets/qwidget.h> + +QT_BEGIN_NAMESPACE + +class QListWidget; +class QListWidgetItem; + +class QOptionsWidget : public QWidget +{ + Q_OBJECT +public: + QOptionsWidget(QWidget *parent = nullptr); + + void clear() { setOptions({}, {}); } + void setOptions(const QStringList &validOptions, const QStringList &selectedOptions); + QStringList validOptions() const { return m_validOptions; } + QStringList selectedOptions() const { return m_selectedOptions; } + + void setNoOptionText(const QString &text); + void setInvalidOptionText(const QString &text); + +signals: + void optionSelectionChanged(const QStringList &options); + +private: + QString optionText(const QString &optionName, bool valid) const; + QListWidgetItem *appendItem(const QString &optionName, bool valid, bool selected); + void appendSeparator(); + void itemChanged(QListWidgetItem *item); + + QListWidget *m_listWidget = nullptr; + QString m_noOptionText; + QString m_invalidOptionText; + QStringList m_validOptions; + QStringList m_invalidOptions; + QStringList m_selectedOptions; + QHash<QString, QListWidgetItem *> m_optionToItem; + QHash<QListWidgetItem *, QString> m_itemToOption; +}; + +QT_END_NAMESPACE + +#endif // QOPTIONSWIDGET_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsAnimation/6.8.1/QtLabsAnimation/private/qqmlanimationglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsAnimation/6.8.1/QtLabsAnimation/private/qqmlanimationglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..527fb6ce3052993afb66eda423ce87767256c95c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsAnimation/6.8.1/QtLabsAnimation/private/qqmlanimationglobal_p.h @@ -0,0 +1,22 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTLABSANIMATIONGLOBAL_P_H +#define QTLABSANIMATIONGLOBAL_P_H + +#include <QtCore/qglobal.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLabsAnimation/qtlabsanimationexports.h> + +#endif // QTLABSANIMATIONGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsAnimation/6.8.1/QtLabsAnimation/private/qquickboundaryrule_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsAnimation/6.8.1/QtLabsAnimation/private/qquickboundaryrule_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7e4f6649f7322fb8696527124c992bcb2a933fe8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsAnimation/6.8.1/QtLabsAnimation/private/qquickboundaryrule_p.h @@ -0,0 +1,114 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKBOUNDARYRULE_H +#define QQUICKBOUNDARYRULE_H + +#include "qqmlanimationglobal_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> + +#include <private/qqmlpropertyvalueinterceptor_p.h> +#include <qqml.h> + +QT_BEGIN_NAMESPACE + +class QQuickAbstractAnimation; +class QQuickBoundaryRulePrivate; +class Q_LABSANIMATION_EXPORT QQuickBoundaryRule : public QObject, public QQmlPropertyValueInterceptor, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_DECLARE_PRIVATE(QQuickBoundaryRule) + + Q_INTERFACES(QQmlPropertyValueInterceptor) + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL) + Q_PROPERTY(qreal minimum READ minimum WRITE setMinimum NOTIFY minimumChanged FINAL) + Q_PROPERTY(qreal minimumOvershoot READ minimumOvershoot WRITE setMinimumOvershoot NOTIFY minimumOvershootChanged FINAL) + Q_PROPERTY(qreal maximum READ maximum WRITE setMaximum NOTIFY maximumChanged FINAL) + Q_PROPERTY(qreal maximumOvershoot READ maximumOvershoot WRITE setMaximumOvershoot NOTIFY maximumOvershootChanged FINAL) + Q_PROPERTY(qreal overshootScale READ overshootScale WRITE setOvershootScale NOTIFY overshootScaleChanged FINAL) + Q_PROPERTY(qreal currentOvershoot READ currentOvershoot NOTIFY currentOvershootChanged FINAL) + Q_PROPERTY(qreal peakOvershoot READ peakOvershoot NOTIFY peakOvershootChanged FINAL) + Q_PROPERTY(OvershootFilter overshootFilter READ overshootFilter WRITE setOvershootFilter NOTIFY overshootFilterChanged FINAL) + Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged FINAL) + Q_PROPERTY(int returnDuration READ returnDuration WRITE setReturnDuration NOTIFY returnDurationChanged FINAL) + QML_NAMED_ELEMENT(BoundaryRule) + QML_ADDED_IN_VERSION(1, 0) + +public: + enum OvershootFilter { + None, + Peak + }; + Q_ENUM(OvershootFilter) + + QQuickBoundaryRule(QObject *parent=nullptr); + ~QQuickBoundaryRule(); + + void setTarget(const QQmlProperty &) override; + void write(const QVariant &value) override; + + bool enabled() const; + void setEnabled(bool enabled); + + qreal minimum() const; + void setMinimum(qreal minimum); + qreal minimumOvershoot() const; + void setMinimumOvershoot(qreal minimum); + + qreal maximum() const; + void setMaximum(qreal maximum); + qreal maximumOvershoot() const; + void setMaximumOvershoot(qreal maximum); + + qreal overshootScale() const; + void setOvershootScale(qreal scale); + + qreal currentOvershoot() const; + qreal peakOvershoot() const; + + OvershootFilter overshootFilter() const; + void setOvershootFilter(OvershootFilter overshootFilter); + + Q_INVOKABLE bool returnToBounds(); + + QEasingCurve easing() const; + void setEasing(const QEasingCurve &easing); + + int returnDuration() const; + void setReturnDuration(int duration); + + // QQmlParserStatus interface + void classBegin() override; + void componentComplete() override; + +Q_SIGNALS: + void enabledChanged(); + void minimumChanged(); + void minimumOvershootChanged(); + void maximumChanged(); + void maximumOvershootChanged(); + void overshootScaleChanged(); + void currentOvershootChanged(); + void peakOvershootChanged(); + void overshootFilterChanged(); + void easingChanged(); + void returnDurationChanged(); + void returnedToBounds(); +}; + +QT_END_NAMESPACE + +#endif // QQUICKBOUNDARYRULE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/fileinfothread_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/fileinfothread_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cf437ff2ce05e53fe813d0ff4fa8db0976626d36 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/fileinfothread_p.h @@ -0,0 +1,113 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef FILEINFOTHREAD_P_H +#define FILEINFOTHREAD_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QThread> +#include <QMutex> +#include <QWaitCondition> +#if QT_CONFIG(filesystemwatcher) +#include <QFileSystemWatcher> +#endif +#include <QFileInfo> +#include <QDir> + +#include "fileproperty_p.h" +#include "qquickfolderlistmodel_p.h" + +QT_BEGIN_NAMESPACE + +class FileInfoThread : public QThread +{ + Q_OBJECT + +Q_SIGNALS: + void directoryChanged(const QString &directory, const QList<FileProperty> &list) const; + void directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex) const; + void sortFinished(const QList<FileProperty> &list) const; + void statusChanged(QQuickFolderListModel::Status status) const; + +public: + FileInfoThread(QObject *parent = nullptr); + ~FileInfoThread(); + + void clear(); + void removePath(const QString &path); + void setPath(const QString &path); + void setRootPath(const QString &path); + void setSortFlags(QDir::SortFlags flags); + void setNameFilters(const QStringList & nameFilters); + void setShowFiles(bool show); + void setShowDirs(bool showFolders); + void setShowDirsFirst(bool show); + void setShowDotAndDotDot(bool on); + void setShowHidden(bool on); + void setShowOnlyReadable(bool on); + void setCaseSensitive(bool on); + +public Q_SLOTS: +#if QT_CONFIG(filesystemwatcher) + void dirChanged(const QString &directoryPath); + void updateFile(const QString &path); +#endif + +protected: + void run() override; + void runOnce(); + void initiateScan(); + void getFileInfos(const QString &path); + void findChangeRange(const QList<FileProperty> &list, int &fromIndex, int &toIndex); + +private: + enum class UpdateType { + None = 1 << 0, + // The order of the files in the current folder changed. + Sort = 1 << 1, + // A subset of files in the current folder changed. + Contents = 1 << 2 + }; + Q_DECLARE_FLAGS(UpdateTypes, UpdateType) + + // Declare these ourselves, as Q_DECLARE_OPERATORS_FOR_FLAGS needs the enum to be public. + friend constexpr UpdateTypes operator|(UpdateType f1, UpdateTypes f2) noexcept; + friend constexpr UpdateTypes operator&(UpdateType f1, UpdateTypes f2) noexcept; + + QMutex mutex; + QWaitCondition condition; + volatile bool abort; + bool scanPending; + +#if QT_CONFIG(filesystemwatcher) + QFileSystemWatcher *watcher; +#endif + QList<FileProperty> currentFileList; + QDir::SortFlags sortFlags; + QString currentPath; + QString rootPath; + QStringList nameFilters; + bool needUpdate; + UpdateTypes updateTypes; + bool showFiles; + bool showDirs; + bool showDirsFirst; + bool showDotAndDotDot; + bool showHidden; + bool showOnlyReadable; + bool caseSensitive; +}; + +QT_END_NAMESPACE + +#endif // FILEINFOTHREAD_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/fileproperty_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/fileproperty_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9ba4732c303874ec5535e29ac8045f54af46bd0b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/fileproperty_p.h @@ -0,0 +1,77 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef FILEPROPERTY_P_H +#define FILEPROPERTY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQmlIntegration/qqmlintegration.h> +#include <QtCore/qfileinfo.h> +#include <QtCore/qdatetime.h> + +#include <private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class FileProperty +{ + Q_GADGET + QML_ANONYMOUS +public: + FileProperty(const QFileInfo &info) : + mFileName(info.fileName()), + mFilePath(info.filePath()), + mBaseName(info.baseName()), + mSuffix(info.completeSuffix()), + mSize(info.size()), + mIsDir(info.isDir()), + mIsFile(info.isFile()), + mLastModified(info.lastModified()), + mLastRead(info.lastRead()) + { + } + ~FileProperty() + {} + + inline QString fileName() const { return mFileName; } + inline QString filePath() const { return mFilePath; } + inline QString baseName() const { return mBaseName; } + inline qint64 size() const { return mSize; } + inline QString suffix() const { return mSuffix; } + inline bool isDir() const { return mIsDir; } + inline bool isFile() const { return mIsFile; } + inline QDateTime lastModified() const { return mLastModified; } + inline QDateTime lastRead() const { return mLastRead; } + + inline bool operator !=(const FileProperty &fileInfo) const { + return !operator==(fileInfo); + } + bool operator ==(const FileProperty &property) const { + return ((mFileName == property.mFileName) && (isDir() == property.isDir())); + } + +private: + QString mFileName; + QString mFilePath; + QString mBaseName; + QString mSuffix; + qint64 mSize; + bool mIsDir; + bool mIsFile; + QDateTime mLastModified; + QDateTime mLastRead; +}; + +QT_END_NAMESPACE + +#endif // FILEPROPERTY_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/qquickfolderlistmodel_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/qquickfolderlistmodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..287f3243b3629e0b08e17e32d9085ed580eeb40f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/qquickfolderlistmodel_p.h @@ -0,0 +1,166 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKFOLDERLISTMODEL_P_H +#define QQUICKFOLDERLISTMODEL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquickfolderlistmodelglobal_p.h" + +#include <QtQml/qqml.h> +#include <QStringList> +#include <QUrl> +#include <QAbstractListModel> + +QT_BEGIN_NAMESPACE + + +class QQmlContext; +class QModelIndex; + +class QQuickFolderListModelPrivate; + +//![class begin] +class Q_LABSFOLDERLISTMODEL_EXPORT QQuickFolderListModel : public QAbstractListModel, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) +//![class begin] + +//![class props] + Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged FINAL) + Q_PROPERTY(QUrl rootFolder READ rootFolder WRITE setRootFolder FINAL) + Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged FINAL) + Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters FINAL) + Q_PROPERTY(SortField sortField READ sortField WRITE setSortField FINAL) + Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed FINAL) + Q_PROPERTY(bool showFiles READ showFiles WRITE setShowFiles REVISION(2, 1) FINAL) + Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs FINAL) + Q_PROPERTY(bool showDirsFirst READ showDirsFirst WRITE setShowDirsFirst FINAL) + Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot FINAL) + Q_PROPERTY(bool showHidden READ showHidden WRITE setShowHidden REVISION(2, 1) FINAL) + Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable FINAL) + Q_PROPERTY(bool caseSensitive READ caseSensitive WRITE setCaseSensitive REVISION(2, 2) FINAL) + Q_PROPERTY(int count READ count NOTIFY countChanged FINAL) + Q_PROPERTY(Status status READ status NOTIFY statusChanged REVISION(2, 11) FINAL) + Q_PROPERTY(bool sortCaseSensitive READ sortCaseSensitive WRITE setSortCaseSensitive REVISION(2, 12) FINAL) +//![class props] + + QML_NAMED_ELEMENT(FolderListModel) + QML_ADDED_IN_VERSION(1, 0) +//![abslistmodel] +public: + QQuickFolderListModel(QObject *parent = nullptr); + ~QQuickFolderListModel(); + + enum Roles { + FileNameRole = Qt::UserRole + 1, + FilePathRole = Qt::UserRole + 2, + FileBaseNameRole = Qt::UserRole + 3, + FileSuffixRole = Qt::UserRole + 4, + FileSizeRole = Qt::UserRole + 5, + FileLastModifiedRole = Qt::UserRole + 6, + FileLastReadRole = Qt::UserRole +7, + FileIsDirRole = Qt::UserRole + 8, + FileUrlRole = Qt::UserRole + 9, + FileURLRole = Qt::UserRole + 10 + }; + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QHash<int, QByteArray> roleNames() const override; +//![abslistmodel] + +//![count] + int count() const { return rowCount(QModelIndex()); } +//![count] + +//![prop funcs] + QUrl folder() const; + void setFolder(const QUrl &folder); + QUrl rootFolder() const; + void setRootFolder(const QUrl &path); + + QUrl parentFolder() const; + + QStringList nameFilters() const; + void setNameFilters(const QStringList &filters); + + enum SortField { Unsorted, Name, Time, Size, Type }; + Q_ENUM(SortField) + SortField sortField() const; + void setSortField(SortField field); + + bool sortReversed() const; + void setSortReversed(bool rev); + + bool showFiles() const; + void setShowFiles(bool showFiles); + bool showDirs() const; + void setShowDirs(bool showDirs); + bool showDirsFirst() const; + void setShowDirsFirst(bool showDirsFirst); + bool showDotAndDotDot() const; + void setShowDotAndDotDot(bool on); + bool showHidden() const; + void setShowHidden(bool on); + bool showOnlyReadable() const; + void setShowOnlyReadable(bool on); + bool caseSensitive() const; + void setCaseSensitive(bool on); + + enum Status { Null, Ready, Loading }; + Q_ENUM(Status) + Status status() const; + bool sortCaseSensitive() const; + void setSortCaseSensitive(bool on); +//![prop funcs] + + Q_INVOKABLE bool isFolder(int index) const; + Q_INVOKABLE QVariant get(int idx, const QString &property) const; + Q_INVOKABLE int indexOf(const QUrl &file) const; + +//![parserstatus] + void classBegin() override; + void componentComplete() override; +//![parserstatus] + + int roleFromString(const QString &roleName) const; + +//![notifier] +Q_SIGNALS: + void folderChanged(); + void rowCountChanged() const; + Q_REVISION(2, 1) void countChanged() const; + Q_REVISION(2, 11) void statusChanged(); +//![notifier] + +//![class end] + + +private: + Q_DISABLE_COPY(QQuickFolderListModel) + Q_DECLARE_PRIVATE(QQuickFolderListModel) + QScopedPointer<QQuickFolderListModelPrivate> d_ptr; + + Q_PRIVATE_SLOT(d_func(), void _q_directoryChanged(const QString &directory, const QList<FileProperty> &list)) + Q_PRIVATE_SLOT(d_func(), void _q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex)) + Q_PRIVATE_SLOT(d_func(), void _q_sortFinished(const QList<FileProperty> &list)) + Q_PRIVATE_SLOT(d_func(), void _q_statusChanged(QQuickFolderListModel::Status s)) +}; +//![class end] + +QT_END_NAMESPACE + +#endif // QQUICKFOLDERLISTMODEL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/qquickfolderlistmodelglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/qquickfolderlistmodelglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..847de538b4aa8829fb51d2384d1ed4e5a0edc7cf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsFolderListModel/6.8.1/QtLabsFolderListModel/private/qquickfolderlistmodelglobal_p.h @@ -0,0 +1,22 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTLABSFOLDERLISTMODELGLOBAL_P_H +#define QTLABSFOLDERLISTMODELGLOBAL_P_H + +#include <QtCore/qglobal.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLabsFolderListModel/qtlabsfolderlistmodelexports.h> + +#endif // QTLABSFOLDERLISTMODELGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformcolordialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformcolordialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a85e4e5d73ffdc7406c090e24090087922ce631b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformcolordialog_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMCOLORDIALOG_P_H +#define QQUICKLABSPLATFORMCOLORDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquicklabsplatformdialog_p.h" +#include <QtGui/qcolor.h> +#include <QtQml/qqml.h> + +QT_BEGIN_NAMESPACE + +class QQuickLabsPlatformColorDialog : public QQuickLabsPlatformDialog +{ + Q_OBJECT + QML_NAMED_ELEMENT(ColorDialog) + QML_EXTENDED_NAMESPACE(QColorDialogOptions) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL) + Q_PROPERTY(QColor currentColor READ currentColor WRITE setCurrentColor NOTIFY currentColorChanged FINAL) + Q_PROPERTY(QColorDialogOptions::ColorDialogOptions options READ options WRITE setOptions NOTIFY optionsChanged FINAL) + +public: + explicit QQuickLabsPlatformColorDialog(QObject *parent = nullptr); + + QColor color() const; + void setColor(const QColor &color); + + QColor currentColor() const; + void setCurrentColor(const QColor &color); + + QColorDialogOptions::ColorDialogOptions options() const; + void setOptions(QColorDialogOptions::ColorDialogOptions options); + +Q_SIGNALS: + void colorChanged(); + void currentColorChanged(); + void optionsChanged(); + +protected: + bool useNativeDialog() const override; + void onCreate(QPlatformDialogHelper *dialog) override; + void onShow(QPlatformDialogHelper *dialog) override; + void accept() override; + +private: + QColor m_color; + QColor m_currentColor; // TODO: QColorDialogOptions::initialColor + QSharedPointer<QColorDialogOptions> m_options; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMCOLORDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformdialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformdialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3a7b5431f5ec43176e709b0ea251a0c29846b1f5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformdialog_p.h @@ -0,0 +1,121 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMDIALOG_P_H +#define QQUICKLABSPLATFORMDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtGui/qpa/qplatformtheme.h> +#include <QtGui/qpa/qplatformdialoghelper.h> +#include <QtQml/qqmlparserstatus.h> +#include <QtQml/qqmllist.h> +#include <QtQml/qqml.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QWindow; +class QPlatformDialogHelper; + +class QQuickLabsPlatformDialog : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + QML_NAMED_ELEMENT(Dialog) + QML_UNCREATABLE("Dialog is an abstract base class") + Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL) + Q_PROPERTY(QWindow *parentWindow READ parentWindow WRITE setParentWindow NOTIFY parentWindowChanged FINAL) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) + Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFlags NOTIFY flagsChanged FINAL) + Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged FINAL) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) + Q_PROPERTY(int result READ result WRITE setResult NOTIFY resultChanged FINAL) + Q_CLASSINFO("DefaultProperty", "data") + +public: + explicit QQuickLabsPlatformDialog(QPlatformTheme::DialogType type, QObject *parent = nullptr); + ~QQuickLabsPlatformDialog(); + + QPlatformDialogHelper *handle() const; + + QQmlListProperty<QObject> data(); + + QWindow *parentWindow() const; + void setParentWindow(QWindow *window); + + QString title() const; + void setTitle(const QString &title); + + Qt::WindowFlags flags() const; + void setFlags(Qt::WindowFlags flags); + + Qt::WindowModality modality() const; + void setModality(Qt::WindowModality modality); + + bool isVisible() const; + void setVisible(bool visible); + + enum StandardCode { Rejected, Accepted }; + Q_ENUM(StandardCode) + + int result() const; + void setResult(int result); + +public Q_SLOTS: + void open(); + void close(); + virtual void accept(); + virtual void reject(); + virtual void done(int result); + +Q_SIGNALS: + void accepted(); + void rejected(); + void parentWindowChanged(); + void titleChanged(); + void flagsChanged(); + void modalityChanged(); + void visibleChanged(); + void resultChanged(); + +protected: + void classBegin() override; + void componentComplete() override; + + bool create(); + void destroy(); + + virtual bool useNativeDialog() const; + virtual void onCreate(QPlatformDialogHelper *dialog); + virtual void onShow(QPlatformDialogHelper *dialog); + virtual void onHide(QPlatformDialogHelper *dialog); + + QWindow *findParentWindow() const; + +private: + bool m_visible; + bool m_complete; + int m_result; + QWindow *m_parentWindow; + QString m_title; + Qt::WindowFlags m_flags; + Qt::WindowModality m_modality; + QPlatformTheme::DialogType m_type; + QList<QObject *> m_data; + QPlatformDialogHelper *m_handle; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformfiledialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformfiledialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4994796fb01e3205a73ff2eb8984e73997a2ac8e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformfiledialog_p.h @@ -0,0 +1,164 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMFILEDIALOG_P_H +#define QQUICKLABSPLATFORMFILEDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquicklabsplatformdialog_p.h" +#include <QtCore/qurl.h> +#include <QtQml/qqml.h> + +QT_BEGIN_NAMESPACE + +class QQuickLabsPlatformFileNameFilter; + +class QQuickLabsPlatformFileDialog : public QQuickLabsPlatformDialog +{ + Q_OBJECT + QML_NAMED_ELEMENT(FileDialog) + QML_EXTENDED_NAMESPACE(QFileDialogOptions) + Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode NOTIFY fileModeChanged FINAL) + Q_PROPERTY(QUrl file READ file WRITE setFile NOTIFY fileChanged FINAL) + Q_PROPERTY(QList<QUrl> files READ files WRITE setFiles NOTIFY filesChanged FINAL) + Q_PROPERTY(QUrl currentFile READ currentFile WRITE setCurrentFile NOTIFY currentFileChanged FINAL) + Q_PROPERTY(QList<QUrl> currentFiles READ currentFiles WRITE setCurrentFiles NOTIFY currentFilesChanged FINAL) + Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged FINAL) + Q_PROPERTY(QFileDialogOptions::FileDialogOptions options READ options WRITE setOptions RESET resetOptions NOTIFY optionsChanged FINAL) + Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters RESET resetNameFilters NOTIFY nameFiltersChanged FINAL) + Q_PROPERTY(QQuickLabsPlatformFileNameFilter *selectedNameFilter READ selectedNameFilter CONSTANT FINAL) + Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix RESET resetDefaultSuffix NOTIFY defaultSuffixChanged FINAL) + Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel RESET resetAcceptLabel NOTIFY acceptLabelChanged FINAL) + Q_PROPERTY(QString rejectLabel READ rejectLabel WRITE setRejectLabel RESET resetRejectLabel NOTIFY rejectLabelChanged FINAL) + +public: + explicit QQuickLabsPlatformFileDialog(QObject *parent = nullptr); + + enum FileMode { + OpenFile, + OpenFiles, + SaveFile + }; + Q_ENUM(FileMode) + + FileMode fileMode() const; + void setFileMode(FileMode fileMode); + + QUrl file() const; + void setFile(const QUrl &file); + + QList<QUrl> files() const; + void setFiles(const QList<QUrl> &files); + + QUrl currentFile() const; + void setCurrentFile(const QUrl &file); + + QList<QUrl> currentFiles() const; + void setCurrentFiles(const QList<QUrl> &files); + + QUrl folder() const; + void setFolder(const QUrl &folder); + + QFileDialogOptions::FileDialogOptions options() const; + void setOptions(QFileDialogOptions::FileDialogOptions options); + void resetOptions(); + + QStringList nameFilters() const; + void setNameFilters(const QStringList &filters); + void resetNameFilters(); + + QQuickLabsPlatformFileNameFilter *selectedNameFilter() const; + + QString defaultSuffix() const; + void setDefaultSuffix(const QString &suffix); + void resetDefaultSuffix(); + + QString acceptLabel() const; + void setAcceptLabel(const QString &label); + void resetAcceptLabel(); + + QString rejectLabel() const; + void setRejectLabel(const QString &label); + void resetRejectLabel(); + +Q_SIGNALS: + void fileModeChanged(); + void fileChanged(); + void filesChanged(); + void currentFileChanged(); + void currentFilesChanged(); + void folderChanged(); + void optionsChanged(); + void nameFiltersChanged(); + void defaultSuffixChanged(); + void acceptLabelChanged(); + void rejectLabelChanged(); + +protected: + bool useNativeDialog() const override; + void onCreate(QPlatformDialogHelper *dialog) override; + void onShow(QPlatformDialogHelper *dialog) override; + void onHide(QPlatformDialogHelper *dialog) override; + void accept() override; + +private: + QUrl addDefaultSuffix(const QUrl &file) const; + QList<QUrl> addDefaultSuffixes(const QList<QUrl> &files) const; + + FileMode m_fileMode; + QList<QUrl> m_files; + bool m_firstShow = true; + QSharedPointer<QFileDialogOptions> m_options; + mutable QQuickLabsPlatformFileNameFilter *m_selectedNameFilter; +}; + +class QQuickLabsPlatformFileNameFilter : public QObject +{ + Q_OBJECT + QML_ANONYMOUS + Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged FINAL) + Q_PROPERTY(QString name READ name NOTIFY nameChanged FINAL) + Q_PROPERTY(QStringList extensions READ extensions NOTIFY extensionsChanged FINAL) + +public: + explicit QQuickLabsPlatformFileNameFilter(QObject *parent = nullptr); + + int index() const; + void setIndex(int index); + + QString name() const; + QStringList extensions() const; + + QSharedPointer<QFileDialogOptions> options() const; + void setOptions(const QSharedPointer<QFileDialogOptions> &options); + + void update(const QString &filter); + +Q_SIGNALS: + void indexChanged(int index); + void nameChanged(const QString &name); + void extensionsChanged(const QStringList &extensions); + +private: + QStringList nameFilters() const; + QString nameFilter(int index) const; + + int m_index; + QString m_name; + QStringList m_extensions; + QSharedPointer<QFileDialogOptions> m_options; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMFILEDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformfolderdialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformfolderdialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d0c5c8e86a5d5b4f11a4a59ab86955072981a32a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformfolderdialog_p.h @@ -0,0 +1,76 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMFOLDERDIALOG_P_H +#define QQUICKLABSPLATFORMFOLDERDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This folder is not part of the Qt API. It exists purely as an +// implementation detail. This header folder may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquicklabsplatformdialog_p.h" +#include <QtCore/qurl.h> +#include <QtQml/qqml.h> + +QT_BEGIN_NAMESPACE + +class QQuickLabsPlatformFolderDialog : public QQuickLabsPlatformDialog +{ + Q_OBJECT + QML_NAMED_ELEMENT(FolderDialog) + QML_EXTENDED_NAMESPACE(QFileDialogOptions) + Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged FINAL) + Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged FINAL) + Q_PROPERTY(QFileDialogOptions::FileDialogOptions options READ options WRITE setOptions RESET resetOptions NOTIFY optionsChanged FINAL) + Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel RESET resetAcceptLabel NOTIFY acceptLabelChanged FINAL) + Q_PROPERTY(QString rejectLabel READ rejectLabel WRITE setRejectLabel RESET resetRejectLabel NOTIFY rejectLabelChanged FINAL) + +public: + explicit QQuickLabsPlatformFolderDialog(QObject *parent = nullptr); + + QUrl folder() const; + void setFolder(const QUrl &folder); + + QUrl currentFolder() const; + void setCurrentFolder(const QUrl &folder); + + QFileDialogOptions::FileDialogOptions options() const; + void setOptions(QFileDialogOptions::FileDialogOptions options); + void resetOptions(); + + QString acceptLabel() const; + void setAcceptLabel(const QString &label); + void resetAcceptLabel(); + + QString rejectLabel() const; + void setRejectLabel(const QString &label); + void resetRejectLabel(); + +Q_SIGNALS: + void folderChanged(); + void currentFolderChanged(); + void optionsChanged(); + void acceptLabelChanged(); + void rejectLabelChanged(); + +protected: + bool useNativeDialog() const override; + void onCreate(QPlatformDialogHelper *dialog) override; + void onShow(QPlatformDialogHelper *dialog) override; + void accept() override; + +private: + QUrl m_folder; + QSharedPointer<QFileDialogOptions> m_options; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMFOLDERDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformfontdialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformfontdialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8963872fe25a5a55b663f2bc61aa4637e1035988 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformfontdialog_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMFONTDIALOG_P_H +#define QQUICKLABSPLATFORMFONTDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquicklabsplatformdialog_p.h" +#include <QtGui/qfont.h> +#include <QtQml/qqml.h> + +QT_BEGIN_NAMESPACE + +class QQuickLabsPlatformFontDialog : public QQuickLabsPlatformDialog +{ + Q_OBJECT + QML_NAMED_ELEMENT(FontDialog) + QML_EXTENDED_NAMESPACE(QFontDialogOptions) + Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL) + Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged FINAL) + Q_PROPERTY(QFontDialogOptions::FontDialogOptions options READ options WRITE setOptions NOTIFY optionsChanged FINAL) + +public: + explicit QQuickLabsPlatformFontDialog(QObject *parent = nullptr); + + QFont font() const; + void setFont(const QFont &font); + + QFont currentFont() const; + void setCurrentFont(const QFont &font); + + QFontDialogOptions::FontDialogOptions options() const; + void setOptions(QFontDialogOptions::FontDialogOptions options); + +Q_SIGNALS: + void fontChanged(); + void currentFontChanged(); + void optionsChanged(); + +protected: + bool useNativeDialog() const override; + void onCreate(QPlatformDialogHelper *dialog) override; + void onShow(QPlatformDialogHelper *dialog) override; + void accept() override; + +private: + QFont m_font; + QFont m_currentFont; // TODO: QFontDialogOptions::initialFont + QSharedPointer<QFontDialogOptions> m_options; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMFONTDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformicon_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformicon_p.h new file mode 100644 index 0000000000000000000000000000000000000000..08fa4b0b0c1a0f8399e089d4480f156099075f3f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformicon_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMICON_P_H +#define QQUICKLABSPLATFORMICON_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qurl.h> +#include <QtCore/qstring.h> + +#include <QtQml/qqmlengine.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QObject; + +class QQuickLabsPlatformIcon +{ + Q_GADGET + QML_ANONYMOUS + Q_PROPERTY(QUrl source READ source WRITE setSource FINAL) + Q_PROPERTY(QString name READ name WRITE setName FINAL) + Q_PROPERTY(bool mask READ isMask WRITE setMask FINAL) + +public: + QUrl source() const; + void setSource(const QUrl &source); + + QString name() const; + void setName(const QString &name); + + bool isMask() const; + void setMask(bool mask); + + bool operator==(const QQuickLabsPlatformIcon &other) const; + bool operator!=(const QQuickLabsPlatformIcon &other) const; + +private: + bool m_mask = false; + QUrl m_source; + QString m_name; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMICON_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformiconloader_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformiconloader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..09cd8b9dfad410002c535cea40a384f8dc8a21de --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformiconloader_p.h @@ -0,0 +1,53 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMICONLOADER_P_H +#define QQUICKLABSPLATFORMICONLOADER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qurl.h> +#include <QtCore/qstring.h> +#include <QtGui/qicon.h> +#include <QtQuick/private/qquickpixmap_p.h> + +#include "qquicklabsplatformicon_p.h" + +QT_BEGIN_NAMESPACE + +class QObject; + +class QQuickLabsPlatformIconLoader : public QQuickPixmap +{ +public: + QQuickLabsPlatformIconLoader(int slot, QObject *parent); + + bool isEnabled() const; + void setEnabled(bool enabled); + + QIcon toQIcon() const; + + QQuickLabsPlatformIcon icon() const; + void setIcon(const QQuickLabsPlatformIcon &icon); + +private: + void loadIcon(); + + QObject *m_parent; + int m_slot; + bool m_enabled; + QQuickLabsPlatformIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMICONLOADER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenu_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenu_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e085b8f02d8fe760fd0b135b62dce81e65884cb6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenu_p.h @@ -0,0 +1,181 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMMENU_P_H +#define QQUICKLABSPLATFORMMENU_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtCore/qurl.h> +#include <QtGui/qfont.h> +#include <QtGui/qpa/qplatformmenu.h> +#include <QtQml/qqmlparserstatus.h> +#include <QtQml/qqmllist.h> +#include <QtQml/qqml.h> + +#include "qquicklabsplatformicon_p.h" + +QT_BEGIN_NAMESPACE + +class QIcon; +class QWindow; +class QQuickItem; +class QPlatformMenu; +class QQuickLabsPlatformMenuBar; +class QQuickLabsPlatformMenuItem; +class QQuickLabsPlatformIconLoader; +class QQuickLabsPlatformSystemTrayIcon; + +class QQuickLabsPlatformMenu : public QObject, public QQmlParserStatus +{ + Q_OBJECT + QML_NAMED_ELEMENT(Menu) + QML_EXTENDED_NAMESPACE(QPlatformMenu) + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL) + Q_PROPERTY(QQmlListProperty<QQuickLabsPlatformMenuItem> items READ items NOTIFY itemsChanged FINAL) + Q_PROPERTY(QQuickLabsPlatformMenuBar *menuBar READ menuBar NOTIFY menuBarChanged FINAL) + Q_PROPERTY(QQuickLabsPlatformMenu *parentMenu READ parentMenu NOTIFY parentMenuChanged FINAL) +#if QT_CONFIG(systemtrayicon) + Q_PROPERTY(QQuickLabsPlatformSystemTrayIcon *systemTrayIcon READ systemTrayIcon NOTIFY systemTrayIconChanged FINAL) +#endif + Q_PROPERTY(QQuickLabsPlatformMenuItem *menuItem READ menuItem CONSTANT FINAL) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) + Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged FINAL) + Q_PROPERTY(QPlatformMenu::MenuType type READ type WRITE setType NOTIFY typeChanged FINAL) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) + Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL) + Q_PROPERTY(QQuickLabsPlatformIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION(1, 1)) + Q_CLASSINFO("DefaultProperty", "data") + +public: + explicit QQuickLabsPlatformMenu(QObject *parent = nullptr); + ~QQuickLabsPlatformMenu(); + + QPlatformMenu *handle() const; + QPlatformMenu *create(); + void destroy(); + void sync(); + + QQmlListProperty<QObject> data(); + QQmlListProperty<QQuickLabsPlatformMenuItem> items(); + + QQuickLabsPlatformMenuBar *menuBar() const; + void setMenuBar(QQuickLabsPlatformMenuBar *menuBar); + + QQuickLabsPlatformMenu *parentMenu() const; + void setParentMenu(QQuickLabsPlatformMenu *menu); + +#if QT_CONFIG(systemtrayicon) + QQuickLabsPlatformSystemTrayIcon *systemTrayIcon() const; + void setSystemTrayIcon(QQuickLabsPlatformSystemTrayIcon *icon); +#endif + + QQuickLabsPlatformMenuItem *menuItem() const; + + bool isEnabled() const; + void setEnabled(bool enabled); + + bool isVisible() const; + void setVisible(bool visible); + + int minimumWidth() const; + void setMinimumWidth(int width); + + QPlatformMenu::MenuType type() const; + void setType(QPlatformMenu::MenuType type); + + QString title() const; + void setTitle(const QString &title); + + QFont font() const; + void setFont(const QFont &font); + + QQuickLabsPlatformIcon icon() const; + void setIcon(const QQuickLabsPlatformIcon &icon); + + Q_INVOKABLE void addItem(QQuickLabsPlatformMenuItem *item); + Q_INVOKABLE void insertItem(int index, QQuickLabsPlatformMenuItem *item); + Q_INVOKABLE void removeItem(QQuickLabsPlatformMenuItem *item); + + Q_INVOKABLE void addMenu(QQuickLabsPlatformMenu *menu); + Q_INVOKABLE void insertMenu(int index, QQuickLabsPlatformMenu *menu); + Q_INVOKABLE void removeMenu(QQuickLabsPlatformMenu *menu); + + Q_INVOKABLE void clear(); + +public Q_SLOTS: + void open(QQmlV4FunctionPtr args); + void close(); + +Q_SIGNALS: + void aboutToShow(); + void aboutToHide(); + + void itemsChanged(); + void menuBarChanged(); + void parentMenuChanged(); + void systemTrayIconChanged(); + void titleChanged(); + void enabledChanged(); + void visibleChanged(); + void minimumWidthChanged(); + void fontChanged(); + void typeChanged(); + Q_REVISION(2, 1) void iconChanged(); + +protected: + void classBegin() override; + void componentComplete() override; + + QQuickLabsPlatformIconLoader *iconLoader() const; + + QWindow *findWindow(QQuickItem *target, QPoint *offset) const; + + static void data_append(QQmlListProperty<QObject> *property, QObject *object); + static qsizetype data_count(QQmlListProperty<QObject> *property); + static QObject *data_at(QQmlListProperty<QObject> *property, qsizetype index); + static void data_clear(QQmlListProperty<QObject> *property); + + static void items_append(QQmlListProperty<QQuickLabsPlatformMenuItem> *property, QQuickLabsPlatformMenuItem *item); + static qsizetype items_count(QQmlListProperty<QQuickLabsPlatformMenuItem> *property); + static QQuickLabsPlatformMenuItem *items_at(QQmlListProperty<QQuickLabsPlatformMenuItem> *property, qsizetype index); + static void items_clear(QQmlListProperty<QQuickLabsPlatformMenuItem> *property); + +private Q_SLOTS: + void updateIcon(); + +private: + void unparentSubmenus(); + + bool m_complete; + bool m_enabled; + bool m_visible; + int m_minimumWidth; + QPlatformMenu::MenuType m_type; + QString m_title; + QFont m_font; + QList<QObject *> m_data; + QList<QQuickLabsPlatformMenuItem *> m_items; + QQuickLabsPlatformMenuBar *m_menuBar; + QQuickLabsPlatformMenu *m_parentMenu; + QQuickLabsPlatformSystemTrayIcon *m_systemTrayIcon; + mutable QQuickLabsPlatformMenuItem *m_menuItem; + mutable QQuickLabsPlatformIconLoader *m_iconLoader; + QPlatformMenu *m_handle; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMMENU_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenubar_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenubar_p.h new file mode 100644 index 0000000000000000000000000000000000000000..461240ad021c51a570f317f00aaedae5acdf5562 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenubar_p.h @@ -0,0 +1,87 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMMENUBAR_P_H +#define QQUICKLABSPLATFORMMENUBAR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtQml/qqmlparserstatus.h> +#include <QtQml/qqmllist.h> +#include <QtQml/qqml.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QWindow; +class QPlatformMenuBar; +class QQuickLabsPlatformMenu; + +class QQuickLabsPlatformMenuBar : public QObject, public QQmlParserStatus +{ + Q_OBJECT + QML_NAMED_ELEMENT(MenuBar) + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL) + Q_PROPERTY(QQmlListProperty<QQuickLabsPlatformMenu> menus READ menus NOTIFY menusChanged FINAL) + Q_PROPERTY(QWindow *window READ window WRITE setWindow NOTIFY windowChanged FINAL) + Q_CLASSINFO("DefaultProperty", "data") + +public: + explicit QQuickLabsPlatformMenuBar(QObject *parent = nullptr); + ~QQuickLabsPlatformMenuBar(); + + QPlatformMenuBar *handle() const; + + QQmlListProperty<QObject> data(); + QQmlListProperty<QQuickLabsPlatformMenu> menus(); + + QWindow *window() const; + void setWindow(QWindow *window); + + Q_INVOKABLE void addMenu(QQuickLabsPlatformMenu *menu); + Q_INVOKABLE void insertMenu(int index, QQuickLabsPlatformMenu *menu); + Q_INVOKABLE void removeMenu(QQuickLabsPlatformMenu *menu); + Q_INVOKABLE void clear(); + +Q_SIGNALS: + void menusChanged(); + void windowChanged(); + +protected: + void classBegin() override; + void componentComplete() override; + + QWindow *findWindow() const; + + static void data_append(QQmlListProperty<QObject> *property, QObject *object); + static qsizetype data_count(QQmlListProperty<QObject> *property); + static QObject *data_at(QQmlListProperty<QObject> *property, qsizetype index); + static void data_clear(QQmlListProperty<QObject> *property); + + static void menus_append(QQmlListProperty<QQuickLabsPlatformMenu> *property, QQuickLabsPlatformMenu *menu); + static qsizetype menus_count(QQmlListProperty<QQuickLabsPlatformMenu> *property); + static QQuickLabsPlatformMenu *menus_at(QQmlListProperty<QQuickLabsPlatformMenu> *property, qsizetype index); + static void menus_clear(QQmlListProperty<QQuickLabsPlatformMenu> *property); + +private: + bool m_complete; + QWindow *m_window; + QList<QObject *> m_data; + QList<QQuickLabsPlatformMenu *> m_menus; + QPlatformMenuBar *m_handle; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMMENUBAR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenuitem_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenuitem_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a11957aa1a54676cf67f35ec5528c09364081491 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenuitem_p.h @@ -0,0 +1,160 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMMENUITEM_P_H +#define QQUICKLABSPLATFORMMENUITEM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtCore/qurl.h> +#include <QtGui/qfont.h> +#include <QtGui/qpa/qplatformmenu.h> +#include <QtQml/qqmlparserstatus.h> +#include <QtQml/qqml.h> + +#include "qquicklabsplatformicon_p.h" + +QT_BEGIN_NAMESPACE + +class QPlatformMenuItem; +class QQuickLabsPlatformMenu; +class QQuickLabsPlatformIconLoader; +class QQuickLabsPlatformMenuItemGroup; + +class QQuickLabsPlatformMenuItem : public QObject, public QQmlParserStatus +{ + Q_OBJECT + QML_NAMED_ELEMENT(MenuItem) + QML_EXTENDED_NAMESPACE(QPlatformMenuItem) + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QQuickLabsPlatformMenu *menu READ menu NOTIFY menuChanged FINAL) + Q_PROPERTY(QQuickLabsPlatformMenu *subMenu READ subMenu NOTIFY subMenuChanged FINAL) + Q_PROPERTY(QQuickLabsPlatformMenuItemGroup *group READ group WRITE setGroup NOTIFY groupChanged FINAL) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) + Q_PROPERTY(bool separator READ isSeparator WRITE setSeparator NOTIFY separatorChanged FINAL) + Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL) + Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) + Q_PROPERTY(QPlatformMenuItem::MenuRole role READ role WRITE setRole NOTIFY roleChanged FINAL) + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL) + Q_PROPERTY(QVariant shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged FINAL) + Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL) + Q_PROPERTY(QQuickLabsPlatformIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION(1, 1)) + +public: + explicit QQuickLabsPlatformMenuItem(QObject *parent = nullptr); + ~QQuickLabsPlatformMenuItem(); + + QPlatformMenuItem *handle() const; + QPlatformMenuItem *create(); + void sync(); + + QQuickLabsPlatformMenu *menu() const; + void setMenu(QQuickLabsPlatformMenu* menu); + + QQuickLabsPlatformMenu *subMenu() const; + void setSubMenu(QQuickLabsPlatformMenu *menu); + + QQuickLabsPlatformMenuItemGroup *group() const; + void setGroup(QQuickLabsPlatformMenuItemGroup *group); + + bool isEnabled() const; + void setEnabled(bool enabled); + + bool isVisible() const; + void setVisible(bool visible); + + bool isSeparator() const; + void setSeparator(bool separator); + + bool isCheckable() const; + void setCheckable(bool checkable); + + bool isChecked() const; + void setChecked(bool checked); + + QPlatformMenuItem::MenuRole role() const; + void setRole(QPlatformMenuItem::MenuRole role); + + QString text() const; + void setText(const QString &text); + + QVariant shortcut() const; + void setShortcut(const QVariant& shortcut); + + QFont font() const; + void setFont(const QFont &font); + + QQuickLabsPlatformIcon icon() const; + void setIcon(const QQuickLabsPlatformIcon &icon); + +public Q_SLOTS: + void toggle(); + +Q_SIGNALS: + void triggered(); + void hovered(); + + void menuChanged(); + void subMenuChanged(); + void groupChanged(); + void enabledChanged(); + void visibleChanged(); + void separatorChanged(); + void checkableChanged(); + void checkedChanged(); + void roleChanged(); + void textChanged(); + void shortcutChanged(); + void fontChanged(); + Q_REVISION(2, 1) void iconChanged(); + +protected: + void classBegin() override; + void componentComplete() override; + + QQuickLabsPlatformIconLoader *iconLoader() const; + + bool event(QEvent *e) override; +private Q_SLOTS: + void activate(); + void updateIcon(); + +private: + void addShortcut(); + void removeShortcut(); + + bool m_complete; + bool m_enabled; + bool m_visible; + bool m_separator; + bool m_checkable; + bool m_checked; + QPlatformMenuItem::MenuRole m_role; + QString m_text; + QVariant m_shortcut; + QFont m_font; + QQuickLabsPlatformMenu *m_menu; + QQuickLabsPlatformMenu *m_subMenu; + QQuickLabsPlatformMenuItemGroup *m_group; + mutable QQuickLabsPlatformIconLoader *m_iconLoader; + QPlatformMenuItem *m_handle; + int m_shortcutId = -1; + + friend class QQuickLabsPlatformMenu; + friend class QQuickLabsPlatformMenuItemGroup; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMMENUITEM_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenuitemgroup_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenuitemgroup_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9efad360e693959b9294b3030e45024633e37e40 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenuitemgroup_p.h @@ -0,0 +1,90 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMMENUITEMGROUP_P_H +#define QQUICKLABSPLATFORMMENUITEMGROUP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtCore/qlist.h> +#include <QtQml/qqml.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QQuickLabsPlatformMenuItem; +class QQuickLabsPlatformMenuItemGroupPrivate; + +class QQuickLabsPlatformMenuItemGroup : public QObject +{ + Q_OBJECT + QML_NAMED_ELEMENT(MenuItemGroup) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) + Q_PROPERTY(bool exclusive READ isExclusive WRITE setExclusive NOTIFY exclusiveChanged FINAL) + Q_PROPERTY(QQuickLabsPlatformMenuItem *checkedItem READ checkedItem WRITE setCheckedItem NOTIFY checkedItemChanged FINAL) + Q_PROPERTY(QQmlListProperty<QQuickLabsPlatformMenuItem> items READ items NOTIFY itemsChanged FINAL) + +public: + explicit QQuickLabsPlatformMenuItemGroup(QObject *parent = nullptr); + ~QQuickLabsPlatformMenuItemGroup(); + + bool isEnabled() const; + void setEnabled(bool enabled); + + bool isVisible() const; + void setVisible(bool visible); + + bool isExclusive() const; + void setExclusive(bool exclusive); + + QQuickLabsPlatformMenuItem *checkedItem() const; + void setCheckedItem(QQuickLabsPlatformMenuItem *item); + + QQmlListProperty<QQuickLabsPlatformMenuItem> items(); + + Q_INVOKABLE void addItem(QQuickLabsPlatformMenuItem *item); + Q_INVOKABLE void removeItem(QQuickLabsPlatformMenuItem *item); + Q_INVOKABLE void clear(); + +Q_SIGNALS: + void triggered(QQuickLabsPlatformMenuItem *item); + void hovered(QQuickLabsPlatformMenuItem *item); + + void enabledChanged(); + void visibleChanged(); + void exclusiveChanged(); + void checkedItemChanged(); + void itemsChanged(); + +private: + QQuickLabsPlatformMenuItem *findCurrent() const; + void updateCurrent(); + void activateItem(); + void hoverItem(); + + static void items_append(QQmlListProperty<QQuickLabsPlatformMenuItem> *prop, QQuickLabsPlatformMenuItem *obj); + static qsizetype items_count(QQmlListProperty<QQuickLabsPlatformMenuItem> *prop); + static QQuickLabsPlatformMenuItem *items_at(QQmlListProperty<QQuickLabsPlatformMenuItem> *prop, qsizetype index); + static void items_clear(QQmlListProperty<QQuickLabsPlatformMenuItem> *prop); + + bool m_enabled; + bool m_visible; + bool m_exclusive; + QQuickLabsPlatformMenuItem *m_checkedItem; + QList<QQuickLabsPlatformMenuItem*> m_items; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMMENUITEMGROUP_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenuseparator_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenuseparator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6f0590ad22025db3d6b3f420e3976c449c48eac1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmenuseparator_p.h @@ -0,0 +1,32 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMMENUSEPARATOR_P_H +#define QQUICKLABSPLATFORMMENUSEPARATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquicklabsplatformmenuitem_p.h" + +QT_BEGIN_NAMESPACE + +class QQuickLabsPlatformMenuSeparator : public QQuickLabsPlatformMenuItem +{ + Q_OBJECT + QML_NAMED_ELEMENT(MenuSeparator) +public: + explicit QQuickLabsPlatformMenuSeparator(QObject *parent = nullptr); +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMMENUSEPARATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmessagedialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmessagedialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dddd2e0bb0d8bbda47fd262aded6093e39e791bb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformmessagedialog_p.h @@ -0,0 +1,87 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMMESSAGEDIALOG_P_H +#define QQUICKLABSPLATFORMMESSAGEDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquicklabsplatformdialog_p.h" +#include <QtQml/qqml.h> + +QT_BEGIN_NAMESPACE + +class QQuickLabsPlatformMessageDialog : public QQuickLabsPlatformDialog +{ + Q_OBJECT + QML_NAMED_ELEMENT(MessageDialog) + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL) + Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged FINAL) + Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText NOTIFY detailedTextChanged FINAL) + Q_PROPERTY(QPlatformDialogHelper::StandardButtons buttons READ buttons WRITE setButtons NOTIFY buttonsChanged FINAL) + QML_EXTENDED_NAMESPACE(QPlatformDialogHelper) + +public: + explicit QQuickLabsPlatformMessageDialog(QObject *parent = nullptr); + + QString text() const; + void setText(const QString &text); + + QString informativeText() const; + void setInformativeText(const QString &text); + + QString detailedText() const; + void setDetailedText(const QString &text); + + QPlatformDialogHelper::StandardButtons buttons() const; + void setButtons(QPlatformDialogHelper::StandardButtons buttons); + +Q_SIGNALS: + void textChanged(); + void informativeTextChanged(); + void detailedTextChanged(); + void buttonsChanged(); + void clicked(QPlatformDialogHelper::StandardButton button); + + void okClicked(); + void saveClicked(); + void saveAllClicked(); + void openClicked(); + void yesClicked(); + void yesToAllClicked(); + void noClicked(); + void noToAllClicked(); + void abortClicked(); + void retryClicked(); + void ignoreClicked(); + void closeClicked(); + void cancelClicked(); + void discardClicked(); + void helpClicked(); + void applyClicked(); + void resetClicked(); + void restoreDefaultsClicked(); + +protected: + void onCreate(QPlatformDialogHelper *dialog) override; + void onShow(QPlatformDialogHelper *dialog) override; + +private Q_SLOTS: + void handleClick(QPlatformDialogHelper::StandardButton button); + +private: + QSharedPointer<QMessageDialogOptions> m_options; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMMESSAGEDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformstandardpaths_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformstandardpaths_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2f17b5aacb3d56869ff0c3128b6ac275d2f1056f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformstandardpaths_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMSTANDARDPATHS_P_H +#define QQUICKLABSPLATFORMSTANDARDPATHS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtCore/qstandardpaths.h> +#include <QtCore/qurl.h> +#include <QtQml/qqml.h> +#include <QtCore/private/qglobal_p.h> + +#if QT_DEPRECATED_SINCE(6, 4) + +QT_BEGIN_NAMESPACE + +class QQmlEngine; +class QJSEngine; + +class QQuickLabsPlatformStandardPaths : public QObject +{ + Q_OBJECT + QML_SINGLETON + QML_NAMED_ELEMENT(StandardPaths) + QML_EXTENDED_NAMESPACE(QStandardPaths) + +public: + explicit QQuickLabsPlatformStandardPaths(QObject *parent = nullptr); + + static QObject *create(QQmlEngine *engine, QJSEngine *scriptEngine); + + Q_INVOKABLE static QString displayName(QStandardPaths::StandardLocation type); + Q_INVOKABLE static QUrl findExecutable(const QString &executableName, const QStringList &paths = QStringList()); + Q_INVOKABLE static QUrl locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile); + Q_INVOKABLE static QList<QUrl> locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile); + Q_INVOKABLE static void setTestModeEnabled(bool testMode); + Q_INVOKABLE static QList<QUrl> standardLocations(QStandardPaths::StandardLocation type); + Q_INVOKABLE static QUrl writableLocation(QStandardPaths::StandardLocation type); + +private: + Q_DISABLE_COPY(QQuickLabsPlatformStandardPaths) +}; + +QT_END_NAMESPACE + +#endif // QT_DEPRECATED_SINCE(6, 4) + +#endif // QQUICKLABSPLATFORMSTANDARDPATHS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformsystemtrayicon_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformsystemtrayicon_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ac490af68b425daf2ea790bf3866c1d126ba2f43 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qquicklabsplatformsystemtrayicon_p.h @@ -0,0 +1,109 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLABSPLATFORMSYSTEMTRAYICON_P_H +#define QQUICKLABSPLATFORMSYSTEMTRAYICON_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qurl.h> +#include <QtCore/qrect.h> +#include <QtGui/qpa/qplatformsystemtrayicon.h> +#include <QtQml/qqmlparserstatus.h> +#include <QtQml/qqml.h> + +#include "qquicklabsplatformicon_p.h" + +QT_REQUIRE_CONFIG(systemtrayicon); + +QT_BEGIN_NAMESPACE + +class QQuickLabsPlatformMenu; +class QQuickLabsPlatformIconLoader; + +class QQuickLabsPlatformSystemTrayIcon : public QObject, public QQmlParserStatus +{ + Q_OBJECT + QML_NAMED_ELEMENT(SystemTrayIcon) + QML_EXTENDED_NAMESPACE(QPlatformSystemTrayIcon) + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(bool available READ isAvailable CONSTANT FINAL) + Q_PROPERTY(bool supportsMessages READ supportsMessages CONSTANT FINAL) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) + Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged FINAL) + Q_PROPERTY(QQuickLabsPlatformMenu *menu READ menu WRITE setMenu NOTIFY menuChanged FINAL) + Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged FINAL REVISION(1, 1)) + Q_PROPERTY(QQuickLabsPlatformIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION(1, 1)) + +public: + explicit QQuickLabsPlatformSystemTrayIcon(QObject *parent = nullptr); + ~QQuickLabsPlatformSystemTrayIcon(); + + QPlatformSystemTrayIcon *handle() const; + + bool isAvailable() const; + bool supportsMessages() const; + + bool isVisible() const; + void setVisible(bool visible); + + QString tooltip() const; + void setTooltip(const QString &tooltip); + + QQuickLabsPlatformMenu *menu() const; + void setMenu(QQuickLabsPlatformMenu *menu); + + QRect geometry() const; + + QQuickLabsPlatformIcon icon() const; + void setIcon(const QQuickLabsPlatformIcon &icon); + +public Q_SLOTS: + void show(); + void hide(); + + void showMessage(const QString &title, const QString &message, + QPlatformSystemTrayIcon::MessageIcon iconType = QPlatformSystemTrayIcon::Information, int msecs = 10000); + +Q_SIGNALS: + void activated(QPlatformSystemTrayIcon::ActivationReason reason); + void messageClicked(); + void visibleChanged(); + void tooltipChanged(); + void menuChanged(); + Q_REVISION(2, 1) void geometryChanged(); + Q_REVISION(2, 1) void iconChanged(); + +protected: + void init(); + void cleanup(); + + void classBegin() override; + void componentComplete() override; + + QQuickLabsPlatformIconLoader *iconLoader() const; + +private Q_SLOTS: + void updateIcon(); + +private: + bool m_complete; + bool m_visible; + QString m_tooltip; + QQuickLabsPlatformMenu *m_menu; + mutable QQuickLabsPlatformIconLoader *m_iconLoader; + QPlatformSystemTrayIcon *m_handle; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABSPLATFORMSYSTEMTRAYICON_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatform_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatform_p.h new file mode 100644 index 0000000000000000000000000000000000000000..354d370f5e79c381d102885ff86faa2d3443d84f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatform_p.h @@ -0,0 +1,137 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWIDGETPLATFORM_P_H +#define QWIDGETPLATFORM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qdebug.h> +#include <QtCore/qcoreapplication.h> +#include <QtGui/qpa/qplatformtheme.h> +#include <QtGui/qpa/qplatformdialoghelper.h> +#include <QtGui/qpa/qplatformsystemtrayicon.h> +#include <QtGui/qpa/qplatformmenu.h> + +#ifdef QT_WIDGETS_LIB +#include <QtWidgets/qtwidgetsglobal.h> +#if QT_CONFIG(colordialog) +#include "qwidgetplatformcolordialog_p.h" +#endif +#if QT_CONFIG(filedialog) +#include "qwidgetplatformfiledialog_p.h" +#endif +#if QT_CONFIG(fontdialog) +#include "qwidgetplatformfontdialog_p.h" +#endif +#if QT_CONFIG(messagebox) +#include "qwidgetplatformmessagedialog_p.h" +#endif +#if QT_CONFIG(menu) +#include "qwidgetplatformmenu_p.h" +#include "qwidgetplatformmenuitem_p.h" +#endif +#ifndef QT_NO_SYSTEMTRAYICON +#include "qwidgetplatformsystemtrayicon_p.h" +#endif +#endif + +QT_BEGIN_NAMESPACE + +#ifndef QT_WIDGETS_LIB +typedef QPlatformMenu QWidgetPlatformMenu; +typedef QPlatformMenuItem QWidgetPlatformMenuItem; +typedef QPlatformColorDialogHelper QWidgetPlatformColorDialog; +typedef QPlatformFileDialogHelper QWidgetPlatformFileDialog; +typedef QPlatformFontDialogHelper QWidgetPlatformFontDialog; +typedef QPlatformMessageDialogHelper QWidgetPlatformMessageDialog; +typedef QPlatformSystemTrayIcon QWidgetPlatformSystemTrayIcon; +#endif + +namespace QWidgetPlatform +{ + static inline bool isAvailable(const char *type) + { + if (!qApp->inherits("QApplication")) { + qCritical("\nERROR: No native %s implementation available." + "\nQt Labs Platform requires Qt Widgets on this setup." + "\nAdd 'QT += widgets' to .pro and create QApplication in main().\n", type); + return false; + } + return true; + } + + template<typename T> + static inline T *createWidget(const char *name, QObject *parent) + { + static bool available = isAvailable(name); +#ifdef QT_WIDGETS_LIB + if (available) + return new T(parent); +#else + Q_UNUSED(parent); + Q_UNUSED(available); +#endif + return nullptr; + } + + static inline QPlatformMenu *createMenu(QObject *parent = nullptr) { +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(menu) + return createWidget<QWidgetPlatformMenu>("Menu", parent); +#else + Q_UNUSED(parent); + return nullptr; +#endif + } + static inline QPlatformMenuItem *createMenuItem(QObject *parent = nullptr) { +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(menu) + return createWidget<QWidgetPlatformMenuItem>("MenuItem", parent); +#else + Q_UNUSED(parent); + return nullptr; +#endif + } + static inline QPlatformSystemTrayIcon *createSystemTrayIcon(QObject *parent = nullptr) { +#ifndef QT_NO_SYSTEMTRAYICON + return createWidget<QWidgetPlatformSystemTrayIcon>("SystemTrayIcon", parent); +#else + Q_UNUSED(parent); + return nullptr; +#endif + } + static inline QPlatformDialogHelper *createDialog(QPlatformTheme::DialogType type, QObject *parent = nullptr) + { +#if !defined(QT_WIDGETS_LIB) || !(QT_CONFIG(colordialog) || QT_CONFIG(filedialog) || QT_CONFIG(fontdialog) || QT_CONFIG(messagebox)) + Q_UNUSED(parent); +#endif + switch (type) { +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(colordialog) + case QPlatformTheme::ColorDialog: return createWidget<QWidgetPlatformColorDialog>("ColorDialog", parent); +#endif +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(filedialog) + case QPlatformTheme::FileDialog: return createWidget<QWidgetPlatformFileDialog>("FileDialog", parent); +#endif +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(fontdialog) + case QPlatformTheme::FontDialog: return createWidget<QWidgetPlatformFontDialog>("FontDialog", parent); +#endif +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(messagebox) + case QPlatformTheme::MessageDialog: return createWidget<QWidgetPlatformMessageDialog>("MessageDialog", parent); +#endif + default: break; + } + return nullptr; + } +} + +QT_END_NAMESPACE + +#endif // QWIDGETPLATFORM_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformcolordialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformcolordialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..48d2c9171e6e4917eac277ca5a350a175faa1ea2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformcolordialog_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWIDGETPLATFORMCOLORDIALOG_P_H +#define QWIDGETPLATFORMCOLORDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qpa/qplatformdialoghelper.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QColorDialog; + +class QWidgetPlatformColorDialog : public QPlatformColorDialogHelper +{ + Q_OBJECT + +public: + explicit QWidgetPlatformColorDialog(QObject *parent = nullptr); + ~QWidgetPlatformColorDialog(); + + QColor currentColor() const override; + void setCurrentColor(const QColor &color) override; + + void exec() override; + bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override; + void hide() override; + +private: + QScopedPointer<QColorDialog> m_dialog; +}; + +QT_END_NAMESPACE + +#endif // QWIDGETPLATFORMCOLORDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformdialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformdialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f709fbbda5d8cfec3b7360e8957830dc915c623e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformdialog_p.h @@ -0,0 +1,34 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWIDGETPLATFORMDIALOG_P_H +#define QWIDGETPLATFORMDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qnamespace.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QDialog; +class QWindow; + +class QWidgetPlatformDialog +{ +public: + static bool show(QDialog *dialog, Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent); +}; + +QT_END_NAMESPACE + +#endif // QWIDGETPLATFORMDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformfiledialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformfiledialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..868ceac7f132923588b6b2f926fffaeffb342874 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformfiledialog_p.h @@ -0,0 +1,52 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWIDGETPLATFORMFILEDIALOG_P_H +#define QWIDGETPLATFORMFILEDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qpa/qplatformdialoghelper.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QFileDialog; + +class QWidgetPlatformFileDialog : public QPlatformFileDialogHelper +{ + Q_OBJECT + +public: + explicit QWidgetPlatformFileDialog(QObject *parent = nullptr); + ~QWidgetPlatformFileDialog(); + + bool defaultNameFilterDisables() const override; + void setDirectory(const QUrl &directory) override; + QUrl directory() const override; + void selectFile(const QUrl &filename) override; + QList<QUrl> selectedFiles() const override; + void setFilter() override; + void selectNameFilter(const QString &filter) override; + QString selectedNameFilter() const override; + + void exec() override; + bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override; + void hide() override; + +private: + QScopedPointer<QFileDialog> m_dialog; +}; + +QT_END_NAMESPACE + +#endif // QWIDGETPLATFORMFILEDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformfontdialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformfontdialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..49114372c86a8443523d51846e56960a0ef6c51a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformfontdialog_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWIDGETPLATFORMFONTDIALOG_P_H +#define QWIDGETPLATFORMFONTDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qpa/qplatformdialoghelper.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QFontDialog; + +class QWidgetPlatformFontDialog : public QPlatformFontDialogHelper +{ + Q_OBJECT + +public: + explicit QWidgetPlatformFontDialog(QObject *parent = nullptr); + ~QWidgetPlatformFontDialog(); + + QFont currentFont() const override; + void setCurrentFont(const QFont &font) override; + + void exec() override; + bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override; + void hide() override; + +private: + QScopedPointer<QFontDialog> m_dialog; +}; + +QT_END_NAMESPACE + +#endif // QWIDGETPLATFORMFONTDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformmenu_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformmenu_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7119c9539e3eb221b3d6a9554221b27aa49cc17b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformmenu_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWIDGETPLATFORMMENU_P_H +#define QWIDGETPLATFORMMENU_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qpa/qplatformmenu.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QMenu; +class QWidgetPlatformMenuItem; + +class QWidgetPlatformMenu : public QPlatformMenu +{ + Q_OBJECT + +public: + explicit QWidgetPlatformMenu(QObject *parent = nullptr); + ~QWidgetPlatformMenu(); + + QMenu *menu() const; + + void insertMenuItem(QPlatformMenuItem *item, QPlatformMenuItem *before) override; + void removeMenuItem(QPlatformMenuItem *item) override; + void syncMenuItem(QPlatformMenuItem *item) override; + void syncSeparatorsCollapsible(bool enable) override; + + void setText(const QString &text) override; + void setIcon(const QIcon &icon) override; + void setEnabled(bool enabled) override; + bool isEnabled() const override; + void setVisible(bool visible) override; + void setMinimumWidth(int width) override; + void setFont(const QFont &font) override; + void setMenuType(MenuType type) override; + + void showPopup(const QWindow *window, const QRect &targetRect, const QPlatformMenuItem *item) override; + void dismiss() override; + + QPlatformMenuItem *menuItemAt(int position) const override; + QPlatformMenuItem *menuItemForTag(quintptr tag) const override; + + QPlatformMenuItem *createMenuItem() const override; + QPlatformMenu *createSubMenu() const override; + +private: + QScopedPointer<QMenu> m_menu; + QList<QWidgetPlatformMenuItem *> m_items; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QPlatformMenu::MenuType) + +#endif // QWIDGETPLATFORMMENU_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformmenuitem_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformmenuitem_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4e31a98ccfcf4ff6a33152cb9a3934dbf09095aa --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformmenuitem_p.h @@ -0,0 +1,56 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWIDGETPLATFORMMENUITEM_P_H +#define QWIDGETPLATFORMMENUITEM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qpa/qplatformmenu.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QAction; + +class QWidgetPlatformMenuItem : public QPlatformMenuItem +{ + Q_OBJECT + +public: + explicit QWidgetPlatformMenuItem(QObject *parent = nullptr); + ~QWidgetPlatformMenuItem(); + + QAction *action() const; + + void setText(const QString &text) override; + void setIcon(const QIcon &icon) override; + void setMenu(QPlatformMenu *menu) override; + void setVisible(bool visible) override; + void setIsSeparator(bool separator) override; + void setFont(const QFont &font) override; + void setRole(MenuRole role) override; + void setCheckable(bool checkable) override; + void setChecked(bool checked) override; +#if QT_CONFIG(shortcut) + void setShortcut(const QKeySequence& shortcut) override; +#endif + void setEnabled(bool enabled) override; + void setIconSize(int size) override; + +private: + QScopedPointer<QAction> m_action; +}; + +QT_END_NAMESPACE + +#endif // QWIDGETPLATFORMMENUITEM_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformmessagedialog_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformmessagedialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c852b864ebbc3003a1c78706b8d6c654f8890b3f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformmessagedialog_p.h @@ -0,0 +1,43 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWIDGETPLATFORMMESSAGEDIALOG_P_H +#define QWIDGETPLATFORMMESSAGEDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qpa/qplatformdialoghelper.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QMessageBox; + +class QWidgetPlatformMessageDialog : public QPlatformMessageDialogHelper +{ + Q_OBJECT + +public: + explicit QWidgetPlatformMessageDialog(QObject *parent = nullptr); + ~QWidgetPlatformMessageDialog(); + + void exec() override; + bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override; + void hide() override; + +private: + QScopedPointer<QMessageBox> m_dialog; +}; + +QT_END_NAMESPACE + +#endif // QWIDGETPLATFORMMESSAGEDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformsystemtrayicon_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformsystemtrayicon_p.h new file mode 100644 index 0000000000000000000000000000000000000000..11785e90ca7ef4b23e75017cbc5a8cbef9f7a95a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsPlatform/6.8.1/QtLabsPlatform/private/qwidgetplatformsystemtrayicon_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWIDGETPLATFORMSYSTEMTRAYICON_P_H +#define QWIDGETPLATFORMSYSTEMTRAYICON_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qpa/qplatformsystemtrayicon.h> +#include <QtCore/private/qglobal_p.h> + +QT_REQUIRE_CONFIG(systemtrayicon); + +QT_BEGIN_NAMESPACE + +class QSystemTrayIcon; + +class QWidgetPlatformSystemTrayIcon : public QPlatformSystemTrayIcon +{ + Q_OBJECT + +public: + explicit QWidgetPlatformSystemTrayIcon(QObject *parent = nullptr); + ~QWidgetPlatformSystemTrayIcon(); + + void init() override; + void cleanup() override; + void updateIcon(const QIcon &icon) override; + void updateToolTip(const QString &tooltip) override; + void updateMenu(QPlatformMenu *menu) override; + QRect geometry() const override; + void showMessage(const QString &title, const QString &msg, + const QIcon &icon, MessageIcon iconType, int msecs) override; + + bool isSystemTrayAvailable() const override; + bool supportsMessages() const override; + + QPlatformMenu *createMenu() const override; + +private: + QScopedPointer<QSystemTrayIcon> m_systray; +}; + +QT_END_NAMESPACE + +#endif // QWIDGETPLATFORMSYSTEMTRAYICON_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmldelegatecomponent_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmldelegatecomponent_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3e00bbb1da28e871ebb216d47d24bcac6a3783cf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmldelegatecomponent_p.h @@ -0,0 +1,104 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDELEGATECOMPONENT_P_H +#define QQMLDELEGATECOMPONENT_P_H + +#include "qqmlmodelsglobal_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQmlModels/private/qtqmlmodelsglobal_p.h> +#include <QtQmlModels/private/qqmlabstractdelegatecomponent_p.h> +#include <QtQml/qqmlcomponent.h> + +QT_REQUIRE_CONFIG(qml_delegate_model); + +QT_BEGIN_NAMESPACE + +class Q_LABSQMLMODELS_EXPORT QQmlDelegateChoice : public QObject +{ + Q_OBJECT + Q_PROPERTY(QVariant roleValue READ roleValue WRITE setRoleValue NOTIFY roleValueChanged FINAL) + Q_PROPERTY(int row READ row WRITE setRow NOTIFY rowChanged FINAL) + Q_PROPERTY(int index READ row WRITE setRow NOTIFY indexChanged FINAL) + Q_PROPERTY(int column READ column WRITE setColumn NOTIFY columnChanged FINAL) + Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) + Q_CLASSINFO("DefaultProperty", "delegate") + QML_NAMED_ELEMENT(DelegateChoice) + QML_ADDED_IN_VERSION(1, 0) + +public: + QVariant roleValue() const; + void setRoleValue(const QVariant &roleValue); + + int row() const; + void setRow(int r); + + int column() const; + void setColumn(int c); + + QQmlComponent *delegate() const; + void setDelegate(QQmlComponent *delegate); + + virtual bool match(int row, int column, const QVariant &value) const; + +Q_SIGNALS: + void roleValueChanged(); + void rowChanged(); + void indexChanged(); + void columnChanged(); + void delegateChanged(); + void changed(); + +private: + QVariant m_value; + int m_row = -1; + int m_column = -1; + QQmlComponent *m_delegate = nullptr; +}; + +class Q_LABSQMLMODELS_EXPORT QQmlDelegateChooser : public QQmlAbstractDelegateComponent +{ + Q_OBJECT + Q_PROPERTY(QString role READ role WRITE setRole NOTIFY roleChanged FINAL) + Q_PROPERTY(QQmlListProperty<QQmlDelegateChoice> choices READ choices CONSTANT FINAL) + Q_CLASSINFO("DefaultProperty", "choices") + QML_NAMED_ELEMENT(DelegateChooser) + QML_ADDED_IN_VERSION(1, 0) + +public: + QString role() const final { return m_role; } + void setRole(const QString &role); + + virtual QQmlListProperty<QQmlDelegateChoice> choices(); + static void choices_append(QQmlListProperty<QQmlDelegateChoice> *, QQmlDelegateChoice *); + static qsizetype choices_count(QQmlListProperty<QQmlDelegateChoice> *); + static QQmlDelegateChoice *choices_at(QQmlListProperty<QQmlDelegateChoice> *, qsizetype); + static void choices_clear(QQmlListProperty<QQmlDelegateChoice> *); + static void choices_replace(QQmlListProperty<QQmlDelegateChoice> *, qsizetype, + QQmlDelegateChoice *); + static void choices_removeLast(QQmlListProperty<QQmlDelegateChoice> *); + + QQmlComponent *delegate(QQmlAdaptorModel *adaptorModel, int row, int column = -1) const override; + +Q_SIGNALS: + void roleChanged(); + +private: + QString m_role; + QList<QQmlDelegateChoice *> m_choices; +}; + +QT_END_NAMESPACE + +#endif // QQMLDELEGATECOMPONENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmlmodelsglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmlmodelsglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c2a4b37e4260c7ff2fa43fb9d399072d178ef9c5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmlmodelsglobal_p.h @@ -0,0 +1,22 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTLABSQMLMODELSGLOBAL_P_H +#define QTLABSQMLMODELSGLOBAL_P_H + +#include <QtCore/qglobal.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLabsQmlModels/qtlabsqmlmodelsexports.h> + +#endif // QTLABSQMLMODELSGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmltablemodel_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmltablemodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d81dbc9387e8434e9d837813202fb6d47c60bc3a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmltablemodel_p.h @@ -0,0 +1,143 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTABLEMODEL_P_H +#define QQMLTABLEMODEL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlmodelsglobal_p.h" +#include "qqmltablemodelcolumn_p.h" + +#include <QtCore/QObject> +#include <QtCore/QHash> +#include <QtCore/QAbstractTableModel> +#include <QtQml/qqml.h> +#include <QtQmlModels/private/qtqmlmodelsglobal_p.h> +#include <QtQml/QJSValue> +#include <QtQml/QQmlListProperty> + +QT_REQUIRE_CONFIG(qml_table_model); + +QT_BEGIN_NAMESPACE + +class Q_LABSQMLMODELS_EXPORT QQmlTableModel : public QAbstractTableModel, public QQmlParserStatus +{ + Q_OBJECT + Q_PROPERTY(int columnCount READ columnCount NOTIFY columnCountChanged FINAL) + Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged FINAL) + Q_PROPERTY(QVariant rows READ rows WRITE setRows NOTIFY rowsChanged FINAL) + Q_PROPERTY(QQmlListProperty<QQmlTableModelColumn> columns READ columns CONSTANT FINAL) + Q_INTERFACES(QQmlParserStatus) + Q_CLASSINFO("DefaultProperty", "columns") + QML_NAMED_ELEMENT(TableModel) + QML_ADDED_IN_VERSION(1, 0) + +public: + QQmlTableModel(QObject *parent = nullptr); + ~QQmlTableModel() override; + + QVariant rows() const; + void setRows(const QVariant &rows); + + Q_INVOKABLE void appendRow(const QVariant &row); + Q_INVOKABLE void clear(); + Q_INVOKABLE QVariant getRow(int rowIndex); + Q_INVOKABLE void insertRow(int rowIndex, const QVariant &row); + Q_INVOKABLE void moveRow(int fromRowIndex, int toRowIndex, int rows = 1); + Q_INVOKABLE void removeRow(int rowIndex, int rows = 1); + Q_INVOKABLE void setRow(int rowIndex, const QVariant &row); + + QQmlListProperty<QQmlTableModelColumn> columns(); + + static void columns_append(QQmlListProperty<QQmlTableModelColumn> *property, QQmlTableModelColumn *value); + static qsizetype columns_count(QQmlListProperty<QQmlTableModelColumn> *property); + static QQmlTableModelColumn *columns_at(QQmlListProperty<QQmlTableModelColumn> *property, qsizetype index); + static void columns_clear(QQmlListProperty<QQmlTableModelColumn> *property); + static void columns_replace(QQmlListProperty<QQmlTableModelColumn> *property, qsizetype index, QQmlTableModelColumn *value); + static void columns_removeLast(QQmlListProperty<QQmlTableModelColumn> *property); + + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + Q_INVOKABLE QVariant data(const QModelIndex &index, const QString &role) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + Q_INVOKABLE bool setData(const QModelIndex &index, const QString &role, const QVariant &value); + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole) override; + QHash<int, QByteArray> roleNames() const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; + +Q_SIGNALS: + void columnCountChanged(); + void rowCountChanged(); + void rowsChanged(); + +protected: + void classBegin() override; + void componentComplete() override; + +private: + class ColumnRoleMetadata + { + public: + ColumnRoleMetadata(); + ColumnRoleMetadata(bool isStringRole, const QString &name, int type, const QString &typeName); + + bool isValid() const; + + // If this is false, it's a function role. + bool isStringRole = false; + QString name; + int type = QMetaType::UnknownType; + QString typeName; + }; + + struct ColumnMetadata + { + // Key = role name that will be made visible to the delegate + // Value = metadata about that role, including actual name in the model data, type, etc. + QHash<QString, ColumnRoleMetadata> roles; + }; + + enum NewRowOperationFlag { + OtherOperation, // insert(), set(), etc. + SetRowsOperation, + AppendOperation + }; + + void doSetRows(const QVariantList &rowsAsVariantList); + ColumnRoleMetadata fetchColumnRoleData(const QString &roleNameKey, + QQmlTableModelColumn *tableModelColumn, int columnIndex) const; + void fetchColumnMetadata(); + + bool validateRowType(const char *functionName, const QVariant &row) const; + bool validateNewRow(const char *functionName, const QVariant &row, + int rowIndex, NewRowOperationFlag operation = OtherOperation) const; + bool validateRowIndex(const char *functionName, const char *argumentName, int rowIndex) const; + + void doInsert(int rowIndex, const QVariant &row); + + bool componentCompleted = false; + QVariantList mRows; + QList<QQmlTableModelColumn *> mColumns; + int mRowCount = 0; + int mColumnCount = 0; + // Each entry contains information about the properties of the column at that index. + QVector<ColumnMetadata> mColumnMetadata; + // key = property index (0 to number of properties across all columns) + // value = role name + QHash<int, QByteArray> mRoleNames; +}; + +QT_END_NAMESPACE + +#endif // QQMLTABLEMODEL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmltablemodelcolumn_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmltablemodelcolumn_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7fd5518fd9546c5c50f527fbbebf1e3f9c057482 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsQmlModels/6.8.1/QtLabsQmlModels/private/qqmltablemodelcolumn_p.h @@ -0,0 +1,191 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTABLEMODELCOLUMN_P_H +#define QQMLTABLEMODELCOLUMN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlmodelsglobal_p.h" + +#include <QtCore/QObject> +#include <QtCore/QHash> +#include <QtQml/qqml.h> +#include <QtQmlModels/private/qtqmlmodelsglobal_p.h> +#include <QtQml/qjsvalue.h> + +QT_REQUIRE_CONFIG(qml_table_model); + +QT_BEGIN_NAMESPACE + +class Q_LABSQMLMODELS_EXPORT QQmlTableModelColumn : public QObject +{ + Q_OBJECT + Q_PROPERTY(QJSValue display READ display WRITE setDisplay NOTIFY displayChanged FINAL) + Q_PROPERTY(QJSValue setDisplay READ getSetDisplay WRITE setSetDisplay NOTIFY setDisplayChanged FINAL) + Q_PROPERTY(QJSValue decoration READ decoration WRITE setDecoration NOTIFY decorationChanged FINAL) + Q_PROPERTY(QJSValue setDecoration READ getSetDecoration WRITE setSetDecoration NOTIFY setDecorationChanged FINAL) + Q_PROPERTY(QJSValue edit READ edit WRITE setEdit NOTIFY editChanged FINAL) + Q_PROPERTY(QJSValue setEdit READ getSetEdit WRITE setSetEdit NOTIFY setEditChanged FINAL) + Q_PROPERTY(QJSValue toolTip READ toolTip WRITE setToolTip NOTIFY toolTipChanged FINAL) + Q_PROPERTY(QJSValue setToolTip READ getSetToolTip WRITE setSetToolTip NOTIFY setToolTipChanged FINAL) + Q_PROPERTY(QJSValue statusTip READ statusTip WRITE setStatusTip NOTIFY statusTipChanged FINAL) + Q_PROPERTY(QJSValue setStatusTip READ getSetStatusTip WRITE setSetStatusTip NOTIFY setStatusTipChanged FINAL) + Q_PROPERTY(QJSValue whatsThis READ whatsThis WRITE setWhatsThis NOTIFY whatsThisChanged FINAL) + Q_PROPERTY(QJSValue setWhatsThis READ getSetWhatsThis WRITE setSetWhatsThis NOTIFY setWhatsThisChanged FINAL) + + Q_PROPERTY(QJSValue font READ font WRITE setFont NOTIFY fontChanged FINAL) + Q_PROPERTY(QJSValue setFont READ getSetFont WRITE setSetFont NOTIFY setFontChanged FINAL) + Q_PROPERTY(QJSValue textAlignment READ textAlignment WRITE setTextAlignment NOTIFY textAlignmentChanged FINAL) + Q_PROPERTY(QJSValue setTextAlignment READ getSetTextAlignment WRITE setSetTextAlignment NOTIFY setTextAlignmentChanged FINAL) + Q_PROPERTY(QJSValue background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) + Q_PROPERTY(QJSValue setBackground READ getSetBackground WRITE setSetBackground NOTIFY setBackgroundChanged FINAL) + Q_PROPERTY(QJSValue foreground READ foreground WRITE setForeground NOTIFY foregroundChanged FINAL) + Q_PROPERTY(QJSValue setForeground READ getSetForeground WRITE setSetForeground NOTIFY setForegroundChanged FINAL) + Q_PROPERTY(QJSValue checkState READ checkState WRITE setCheckState NOTIFY checkStateChanged FINAL) + Q_PROPERTY(QJSValue setCheckState READ getSetCheckState WRITE setSetCheckState NOTIFY setCheckStateChanged FINAL) + + Q_PROPERTY(QJSValue accessibleText READ accessibleText WRITE setAccessibleText NOTIFY accessibleTextChanged FINAL) + Q_PROPERTY(QJSValue setAccessibleText READ getSetAccessibleText WRITE setSetAccessibleText NOTIFY setAccessibleTextChanged FINAL) + Q_PROPERTY(QJSValue accessibleDescription READ accessibleDescription + WRITE setAccessibleDescription NOTIFY accessibleDescriptionChanged FINAL) + Q_PROPERTY(QJSValue setAccessibleDescription READ getSetAccessibleDescription + WRITE setSetAccessibleDescription NOTIFY setAccessibleDescriptionChanged FINAL) + + Q_PROPERTY(QJSValue sizeHint READ sizeHint WRITE setSizeHint NOTIFY sizeHintChanged FINAL) + Q_PROPERTY(QJSValue setSizeHint READ getSetSizeHint WRITE setSetSizeHint NOTIFY setSizeHintChanged FINAL) + QML_NAMED_ELEMENT(TableModelColumn) + QML_ADDED_IN_VERSION(1, 0) + +public: + QQmlTableModelColumn(QObject *parent = nullptr); + ~QQmlTableModelColumn() override; + + QJSValue display() const; + void setDisplay(const QJSValue &stringOrFunction); + QJSValue getSetDisplay() const; + void setSetDisplay(const QJSValue &function); + + QJSValue decoration() const; + void setDecoration(const QJSValue &stringOrFunction); + QJSValue getSetDecoration() const; + void setSetDecoration(const QJSValue &function); + + QJSValue edit() const; + void setEdit(const QJSValue &stringOrFunction); + QJSValue getSetEdit() const; + void setSetEdit(const QJSValue &function); + + QJSValue toolTip() const; + void setToolTip(const QJSValue &stringOrFunction); + QJSValue getSetToolTip() const; + void setSetToolTip(const QJSValue &function); + + QJSValue statusTip() const; + void setStatusTip(const QJSValue &stringOrFunction); + QJSValue getSetStatusTip() const; + void setSetStatusTip(const QJSValue &function); + + QJSValue whatsThis() const; + void setWhatsThis(const QJSValue &stringOrFunction); + QJSValue getSetWhatsThis() const; + void setSetWhatsThis(const QJSValue &function); + + QJSValue font() const; + void setFont(const QJSValue &stringOrFunction); + QJSValue getSetFont() const; + void setSetFont(const QJSValue &function); + + QJSValue textAlignment() const; + void setTextAlignment(const QJSValue &stringOrFunction); + QJSValue getSetTextAlignment() const; + void setSetTextAlignment(const QJSValue &function); + + QJSValue background() const; + void setBackground(const QJSValue &stringOrFunction); + QJSValue getSetBackground() const; + void setSetBackground(const QJSValue &function); + + QJSValue foreground() const; + void setForeground(const QJSValue &stringOrFunction); + QJSValue getSetForeground() const; + void setSetForeground(const QJSValue &function); + + QJSValue checkState() const; + void setCheckState(const QJSValue &stringOrFunction); + QJSValue getSetCheckState() const; + void setSetCheckState(const QJSValue &function); + + QJSValue accessibleText() const; + void setAccessibleText(const QJSValue &stringOrFunction); + QJSValue getSetAccessibleText() const; + void setSetAccessibleText(const QJSValue &function); + + QJSValue accessibleDescription() const; + void setAccessibleDescription(const QJSValue &stringOrFunction); + QJSValue getSetAccessibleDescription() const; + void setSetAccessibleDescription(const QJSValue &function); + + QJSValue sizeHint() const; + void setSizeHint(const QJSValue &stringOrFunction); + QJSValue getSetSizeHint() const; + void setSetSizeHint(const QJSValue &function); + + QJSValue getterAtRole(const QString &roleName); + QJSValue setterAtRole(const QString &roleName); + + const QHash<QString, QJSValue> getters() const; + + static const QHash<int, QString> supportedRoleNames(); + +Q_SIGNALS: + void indexChanged(); + void displayChanged(); + void setDisplayChanged(); + void decorationChanged(); + void setDecorationChanged(); + void editChanged(); + void setEditChanged(); + void toolTipChanged(); + void setToolTipChanged(); + void statusTipChanged(); + void setStatusTipChanged(); + void whatsThisChanged(); + void setWhatsThisChanged(); + + void fontChanged(); + void setFontChanged(); + void textAlignmentChanged(); + void setTextAlignmentChanged(); + void backgroundChanged(); + void setBackgroundChanged(); + void foregroundChanged(); + void setForegroundChanged(); + void checkStateChanged(); + void setCheckStateChanged(); + + void accessibleTextChanged(); + void setAccessibleTextChanged(); + void accessibleDescriptionChanged(); + void setAccessibleDescriptionChanged(); + void sizeHintChanged(); + void setSizeHintChanged(); + +private: + // We store these in hashes because QQuickTableModel needs string-based lookup in certain situations. + QHash<QString, QJSValue> mGetters; + QHash<QString, QJSValue> mSetters; +}; + +QT_END_NAMESPACE + +#endif // QQMLTABLEMODELCOLUMN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsSettings/6.8.1/QtLabsSettings/private/qqmlsettings_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsSettings/6.8.1/QtLabsSettings/private/qqmlsettings_p.h new file mode 100644 index 0000000000000000000000000000000000000000..23faf11833c33eeb4d324bbadb8e0ce3c7866a78 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsSettings/6.8.1/QtLabsSettings/private/qqmlsettings_p.h @@ -0,0 +1,67 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSETTINGS_P_H +#define QQMLSETTINGS_P_H + +#include "qqmlsettingsglobal_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqml.h> +#include <QtCore/qobject.h> +#include <QtCore/qscopedpointer.h> +#include <QtQml/qqmlparserstatus.h> + +QT_BEGIN_NAMESPACE + +class QQmlSettingsPrivate; + +class Q_LABSSETTINGS_EXPORT QQmlSettings : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QString category READ category WRITE setCategory FINAL) + Q_PROPERTY(QString fileName READ fileName WRITE setFileName FINAL) + QML_NAMED_ELEMENT(Settings) + QML_ADDED_IN_VERSION(1, 0) + +public: + explicit QQmlSettings(QObject *parent = nullptr); + ~QQmlSettings(); + + QString category() const; + void setCategory(const QString &category); + + QString fileName() const; + void setFileName(const QString &fileName); + + Q_INVOKABLE QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const; + Q_INVOKABLE void setValue(const QString &key, const QVariant &value); + Q_INVOKABLE void sync(); + +protected: + void timerEvent(QTimerEvent *event) override; + + void classBegin() override; + void componentComplete() override; + +private: + Q_DISABLE_COPY(QQmlSettings) + Q_DECLARE_PRIVATE(QQmlSettings) + QScopedPointer<QQmlSettingsPrivate> d_ptr; + Q_PRIVATE_SLOT(d_func(), void _q_propertyChanged()) +}; + +QT_END_NAMESPACE + +#endif // QQMLSETTINGS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsSettings/6.8.1/QtLabsSettings/private/qqmlsettingsglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsSettings/6.8.1/QtLabsSettings/private/qqmlsettingsglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..494daa5286e05ae4f140f17b4fb658602501d671 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsSettings/6.8.1/QtLabsSettings/private/qqmlsettingsglobal_p.h @@ -0,0 +1,22 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTLABSSETTINGSGLOBAL_P_H +#define QTLABSSETTINGSGLOBAL_P_H + +#include <QtCore/qglobal.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLabsSettings/qtlabssettingsexports.h> + +#endif // QTLABSSETTINGSGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsSharedImage/6.8.1/QtLabsSharedImage/private/qsharedimageloader_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsSharedImage/6.8.1/QtLabsSharedImage/private/qsharedimageloader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..06bc334644f4f1077a455bf87c8b1fe7efde3f80 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsSharedImage/6.8.1/QtLabsSharedImage/private/qsharedimageloader_p.h @@ -0,0 +1,58 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSHAREDIMAGELOADER_H +#define QSHAREDIMAGELOADER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtlabssharedimageglobal_p.h" + +#include <QImage> +#include <QVariant> +#include <QLoggingCategory> +#include <qqml.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcSharedImage); + +class QSharedImageLoaderPrivate; + +class Q_LABSSHAREDIMAGE_EXPORT QSharedImageLoader : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QSharedImageLoader) + + // We need to provide some type, in order to mention the 1.0 version. + QML_ANONYMOUS + QML_ADDED_IN_VERSION(1, 0) + +public: + typedef QVector<QVariant> ImageParameters; + + QSharedImageLoader(QObject *parent = nullptr); + ~QSharedImageLoader(); + + QImage load(const QString &path, ImageParameters *params = nullptr); + +protected: + virtual QImage loadFile(const QString &path, ImageParameters *params); + virtual QString key(const QString &path, ImageParameters *params); + +private: + Q_DISABLE_COPY(QSharedImageLoader) +}; + +QT_END_NAMESPACE + +#endif // QSHAREDIMAGELOADER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsSharedImage/6.8.1/QtLabsSharedImage/private/qsharedimageprovider_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsSharedImage/6.8.1/QtLabsSharedImage/private/qsharedimageprovider_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9a848fc6119d603f289c81568e55174791c64e39 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsSharedImage/6.8.1/QtLabsSharedImage/private/qsharedimageprovider_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSHAREDIMAGEPROVIDER_H +#define QSHAREDIMAGEPROVIDER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtlabssharedimageglobal_p.h" + +#include <QQuickImageProvider> +#include <private/qquickpixmap_p.h> +#include <QScopedPointer> + +#include "qsharedimageloader_p.h" + +QT_BEGIN_NAMESPACE + +class SharedImageProvider; + +class QuickSharedImageLoader : public QSharedImageLoader +{ + Q_OBJECT + friend class SharedImageProvider; + +public: + enum ImageParameter { + OriginalSize = 0, + RequestedSize, + ProviderOptions, + NumImageParameters + }; + + QuickSharedImageLoader(QObject *parent = nullptr); +protected: + QImage loadFile(const QString &path, ImageParameters *params) override; + QString key(const QString &path, ImageParameters *params) override; +}; + +class Q_LABSSHAREDIMAGE_EXPORT SharedImageProvider : public QQuickImageProviderWithOptions +{ +public: + SharedImageProvider(); + + QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize, const QQuickImageProviderOptions &options) override; + +protected: + QScopedPointer<QuickSharedImageLoader> loader; +}; + +QT_END_NAMESPACE + +#endif // QSHAREDIMAGEPROVIDER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsSharedImage/6.8.1/QtLabsSharedImage/private/qtlabssharedimageglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsSharedImage/6.8.1/QtLabsSharedImage/private/qtlabssharedimageglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9107a5119574a27c79034c02e69265593c9ba2bf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsSharedImage/6.8.1/QtLabsSharedImage/private/qtlabssharedimageglobal_p.h @@ -0,0 +1,28 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTLABSSHAREDIMAGEGLOBAL_P_H +#define QTLABSSHAREDIMAGEGLOBAL_P_H + +#include <QtCore/qglobal.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLabsSharedImage/qtlabssharedimageexports.h> + +QT_BEGIN_NAMESPACE + +void Q_LABSSHAREDIMAGE_EXPORT qml_register_types_Qt_labs_sharedimage(); + +QT_END_NAMESPACE + +#endif // QTLABSSHAREDIMAGEGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsWavefrontMesh/6.8.1/QtLabsWavefrontMesh/private/qqmlwavefrontmeshglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsWavefrontMesh/6.8.1/QtLabsWavefrontMesh/private/qqmlwavefrontmeshglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..23b403281c36e9f60c40dcf6309c9a6195b059c3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsWavefrontMesh/6.8.1/QtLabsWavefrontMesh/private/qqmlwavefrontmeshglobal_p.h @@ -0,0 +1,22 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTLABSWAVEFRONTMESHGLOBAL_P_H +#define QTLABSWAVEFRONTMESHGLOBAL_P_H + +#include <QtCore/qglobal.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLabsWavefrontMesh/qtlabswavefrontmeshexports.h> + +#endif // QTLABSWAVEFRONTMESHGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtLabsWavefrontMesh/6.8.1/QtLabsWavefrontMesh/private/qwavefrontmesh_p.h b/qt/6.8.1/msvc2022_64/include/QtLabsWavefrontMesh/6.8.1/QtLabsWavefrontMesh/private/qwavefrontmesh_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d91582d33f31b8c06885366f3e07545207812bed --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtLabsWavefrontMesh/6.8.1/QtLabsWavefrontMesh/private/qwavefrontmesh_p.h @@ -0,0 +1,91 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWAVEFRONTMESH_P_H +#define QWAVEFRONTMESH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlwavefrontmeshglobal_p.h" + +#include <QtQuick/private/qquickshadereffectmesh_p.h> + +#include <QtCore/qurl.h> +#include <QtGui/qvector3d.h> + +QT_BEGIN_NAMESPACE + +class QWavefrontMeshPrivate; +class Q_LABSWAVEFRONTMESH_EXPORT QWavefrontMesh : public QQuickShaderEffectMesh +{ + Q_OBJECT + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged FINAL) + Q_PROPERTY(Error lastError READ lastError NOTIFY lastErrorChanged FINAL) + Q_PROPERTY(QVector3D projectionPlaneV READ projectionPlaneV WRITE setProjectionPlaneV NOTIFY projectionPlaneVChanged FINAL) + Q_PROPERTY(QVector3D projectionPlaneW READ projectionPlaneW WRITE setProjectionPlaneW NOTIFY projectionPlaneWChanged FINAL) + QML_NAMED_ELEMENT(WavefrontMesh) + QML_ADDED_IN_VERSION(1, 0) + +public: + enum Error { + NoError, + InvalidSourceError, + UnsupportedFaceShapeError, + UnsupportedIndexSizeError, + FileNotFoundError, + NoAttributesError, + MissingPositionAttributeError, + MissingTextureCoordinateAttributeError, + MissingPositionAndTextureCoordinateAttributesError, + TooManyAttributesError, + InvalidPlaneDefinitionError + }; + Q_ENUM(Error) + + QWavefrontMesh(QObject *parent = nullptr); + ~QWavefrontMesh() override; + + QUrl source() const; + void setSource(const QUrl &url); + + Error lastError() const; + void setLastError(Error lastError); + + bool validateAttributes(const QList<QByteArray> &attributes, int *posIndex) override; + QSGGeometry *updateGeometry(QSGGeometry *geometry, int attrCount, int posIndex, + const QRectF &srcRect, const QRectF &rect) override; + QString log() const override; + + QVector3D projectionPlaneV() const; + void setProjectionPlaneV(const QVector3D &projectionPlaneV); + + QVector3D projectionPlaneW() const; + void setProjectionPlaneW(const QVector3D &projectionPlaneW); + +Q_SIGNALS: + void sourceChanged(); + void lastErrorChanged(); + void projectionPlaneVChanged(); + void projectionPlaneWChanged(); + +protected Q_SLOTS: + void readData(); + +private: + Q_DISABLE_COPY(QWavefrontMesh) + Q_DECLARE_PRIVATE(QWavefrontMesh) +}; + +QT_END_NAMESPACE + +#endif // QWAVEFRONTMESH_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/bitstreams_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/bitstreams_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e3c3a8a1e204e9f7f5de36deb6e6fb34f23c5899 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/bitstreams_p.h @@ -0,0 +1,149 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef BITSTREAMS_P_H +#define BITSTREAMS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qdebug.h> + +#include <type_traits> +#include <algorithm> +#include <vector> + +QT_BEGIN_NAMESPACE + +class QByteArray; + +namespace HPack +{ + +// BitOStream works with an external buffer, +// for example, HEADERS frame. +class Q_AUTOTEST_EXPORT BitOStream +{ +public: + BitOStream(std::vector<uchar> &buffer); + + // Write 'bitLength' bits from the least significant + // bits in 'bits' to bitstream: + void writeBits(uchar bits, quint8 bitLength); + // HPACK data format, we support: + // * 32-bit integers + // * strings + void write(quint32 src); + void write(QByteArrayView src, bool compressed); + + quint64 bitLength() const; + quint64 byteLength() const; + const uchar *begin() const; + const uchar *end() const; + + void clear(); + +private: + Q_DISABLE_COPY_MOVE(BitOStream); + + std::vector<uchar> &buffer; + quint64 bitsSet; +}; + +class Q_AUTOTEST_EXPORT BitIStream +{ +public: + // Error is set by 'read' functions. + // 'peek' does not set the error, + // since it just peeks some bits + // without the notion of wrong/right. + // 'read' functions only change 'streamOffset' + // on success. + enum class Error + { + NoError, + NotEnoughData, + CompressionError, + InvalidInteger + }; + + BitIStream(); + BitIStream(const uchar *f, const uchar *l); + + quint64 bitLength() const; + bool hasMoreBits() const; + + // peekBits tries to read 'length' bits from the bitstream into + // 'dst' ('length' must be <= sizeof(dst) * 8), packing them + // starting from the most significant bit of the most significant + // byte. It's a template so that we can use it with different + // integer types. Returns the number of bits actually read. + // Does not change stream's offset. + + template<class T> + quint64 peekBits(quint64 from, quint64 length, T *dstPtr) const + { + static_assert(std::is_unsigned<T>::value, "peekBits: unsigned integer type expected"); + + Q_ASSERT(dstPtr); + Q_ASSERT(length <= sizeof(T) * 8); + + if (from >= bitLength() || !length) + return 0; + + T &dst = *dstPtr; + dst = T(); + length = std::min(length, bitLength() - from); + + const uchar *srcByte = first + from / 8; + auto bitsToRead = length + from % 8; + + while (bitsToRead > 8) { + dst = (dst << 8) | *srcByte; + bitsToRead -= 8; + ++srcByte; + } + + dst <<= bitsToRead; + dst |= *srcByte >> (8 - bitsToRead); + dst <<= sizeof(T) * 8 - length; + + return length; + } + + quint64 streamOffset() const + { + return offset; + } + + bool skipBits(quint64 nBits); + bool rewindOffset(quint64 nBits); + + bool read(quint32 *dstPtr); + bool read(QByteArray *dstPtr); + + Error error() const; + +private: + void setError(Error newState); + + const uchar *first; + const uchar *last; + quint64 offset; + Error streamError; +}; + +} // namespace HPack + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/hpack_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/hpack_p.h new file mode 100644 index 0000000000000000000000000000000000000000..67131c0a36e3a7309d261d73fabb0aae28038056 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/hpack_p.h @@ -0,0 +1,123 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef HPACK_P_H +#define HPACK_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "hpacktable_p.h" + +#include <QtCore/qglobal.h> +#include <QtCore/qurl.h> + +#include <vector> +#include <optional> + +QT_BEGIN_NAMESPACE + +class QByteArray; + +namespace HPack +{ + +using HttpHeader = std::vector<HeaderField>; +HeaderSize header_size(const HttpHeader &header); +struct BitPattern; +class Q_AUTOTEST_EXPORT Encoder +{ +public: + Encoder(quint32 maxTableSize, bool compressStrings); + + quint32 dynamicTableSize() const; + + bool encodeRequest(class BitOStream &outputStream, + const HttpHeader &header); + bool encodeResponse(BitOStream &outputStream, + const HttpHeader &header); + + bool encodeSizeUpdate(BitOStream &outputStream, + quint32 newSize); + + void setMaxDynamicTableSize(quint32 size); + void setCompressStrings(bool compress); + +private: + bool encodeRequestPseudoHeaders(BitOStream &outputStream, + const HttpHeader &header); + bool encodeHeaderField(BitOStream &outputStream, + const HeaderField &field); + bool encodeMethod(BitOStream &outputStream, + const HeaderField &field); + + bool encodeResponsePseudoHeaders(BitOStream &outputStream, + const HttpHeader &header); + + bool encodeIndexedField(BitOStream &outputStream, quint32 index) const; + + + bool encodeLiteralField(BitOStream &outputStream, + BitPattern fieldType, + quint32 nameIndex, + const QByteArray &value, + bool withCompression); + + bool encodeLiteralField(BitOStream &outputStream, + BitPattern fieldType, + const QByteArray &name, + const QByteArray &value, + bool withCompression); + + FieldLookupTable lookupTable; + bool compressStrings; +}; + +class Q_AUTOTEST_EXPORT Decoder +{ +public: + Decoder(quint32 maxTableSize); + + bool decodeHeaderFields(class BitIStream &inputStream); + + const HttpHeader &decodedHeader() const + { + return header; + } + + quint32 dynamicTableSize() const; + + void setMaxDynamicTableSize(quint32 size); + +private: + + bool decodeIndexedField(BitIStream &inputStream); + bool decodeSizeUpdate(BitIStream &inputStream); + bool decodeLiteralField(BitPattern fieldType, + BitIStream &inputStream); + + bool processDecodedField(BitPattern fieldType, + const QByteArray &name, + const QByteArray &value); + + void handleStreamError(BitIStream &inputStream); + + HttpHeader header; + FieldLookupTable lookupTable; +}; + +std::optional<QUrl> makePromiseKeyUrl(const HttpHeader &requestHeader); +} + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/hpacktable_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/hpacktable_p.h new file mode 100644 index 0000000000000000000000000000000000000000..410f9c21672aff37e0c70d7849d63449c5475cf7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/hpacktable_p.h @@ -0,0 +1,210 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef HPACKTABLE_P_H +#define HPACKTABLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qbytearray.h> +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qpair.h> + +#include <vector> +#include <memory> +#include <deque> +#include <set> + +QT_BEGIN_NAMESPACE + +namespace HPack +{ + +struct Q_AUTOTEST_EXPORT HeaderField +{ + HeaderField() + { + } + + HeaderField(const QByteArray &n, const QByteArray &v) + : name(n), + value(v) + { + } + + bool operator == (const HeaderField &rhs) const + { + return name == rhs.name && value == rhs.value; + } + + QByteArray name; + QByteArray value; +}; + +using HeaderSize = QPair<bool, quint32>; + +HeaderSize entry_size(QByteArrayView name, QByteArrayView value); + +inline HeaderSize entry_size(const HeaderField &entry) +{ + return entry_size(entry.name, entry.value); +} + +/* + Lookup table consists of two parts (HPACK, 2.3): + the immutable static table (pre-defined by HPACK's specs) + and dynamic table which is updated while + compressing/decompressing headers. + + Table must provide/implement: + 1. Fast random access - we read fields' indices from + HPACK's bit stream. + 2. FIFO for dynamic part - to push new items to the front + and evict them from the back (HPACK, 2.3.2). + 3. Fast lookup - encoder receives pairs of strings + (name|value) and it has to find an index for a pair + as the whole or for a name at least (if it's already + in either static or dynamic table). + + Static table is an immutable vector. + + Dynamic part is implemented in a way similar to std::deque - + it's a vector of pointers to chunks. Each chunk is a vector of + (name|value) pairs. Once allocated with a fixed size, chunk + never re-allocates its data, so entries' addresses do not change. + We add new chunks prepending them to the front of a vector, + in each chunk we fill (name|value) pairs starting from the back + of the chunk (this simplifies item eviction/FIFO). + Given a 'linear' index we can find a chunk number and + offset in this chunk - random access. + + Lookup in a static part is straightforward: + it's an (immutable) vector, data is sorted, + contains no duplicates, we use binary search comparing string values. + + To provide a lookup in dynamic table faster than a linear search, + we have an std::set of 'SearchEntries', where each entry contains: + - a pointer to a (name|value) pair (to compare + name|value strings). + - a pointer to a chunk containing this pair and + - an offset within this chunk - to calculate a + 'linear' index. + + Entries in a table can be duplicated (HPACK, 2.3.2), + if we evict an entry, we must update our index removing + the exactly right key, thus keys in this set are sorted + by name|value pairs first, and then by chunk index/offset + (so that NewSearchEntryKey < OldSearchEntry even if strings + are equal). +*/ + +class Q_AUTOTEST_EXPORT FieldLookupTable +{ +public: + enum + { + ChunkSize = 16, + DefaultSize = 4096 // Recommended by HTTP2. + }; + + FieldLookupTable(quint32 maxTableSize, bool useIndex); + + bool prependField(const QByteArray &name, const QByteArray &value); + void evictEntry(); + + quint32 numberOfEntries() const; + quint32 numberOfStaticEntries() const; + quint32 numberOfDynamicEntries() const; + quint32 dynamicDataSize() const; + void clearDynamicTable(); + + bool indexIsValid(quint32 index) const; + quint32 indexOf(const QByteArray &name, const QByteArray &value) const; + quint32 indexOf(const QByteArray &name) const; + bool field(quint32 index, QByteArray *name, QByteArray *value) const; + bool fieldName(quint32 index, QByteArray *dst) const; + bool fieldValue(quint32 index, QByteArray *dst) const; + + bool updateDynamicTableSize(quint32 size); + void setMaxDynamicTableSize(quint32 size); + + static const std::vector<HeaderField> &staticPart(); + +private: + // Table's maximum size is controlled + // by SETTINGS_HEADER_TABLE_SIZE (HTTP/2, 6.5.2). + quint32 maxTableSize; + // The tableCapacity is how many bytes the table + // can currently hold. It cannot exceed maxTableSize. + // It can be modified by a special message in + // the HPACK bit stream (HPACK, 6.3). + quint32 tableCapacity; + + using Chunk = std::vector<HeaderField>; + using ChunkPtr = std::unique_ptr<Chunk>; + std::deque<ChunkPtr> chunks; + using size_type = std::deque<ChunkPtr>::size_type; + + struct SearchEntry; + friend struct SearchEntry; + + struct SearchEntry + { + SearchEntry(); + SearchEntry(const HeaderField *f, const Chunk *c, + quint32 o, const FieldLookupTable *t); + + const HeaderField *field; + const Chunk *chunk; + const quint32 offset; + const FieldLookupTable *table; + + bool operator < (const SearchEntry &rhs) const; + }; + + bool useIndex; + std::set<SearchEntry> searchIndex; + + SearchEntry frontKey() const; + SearchEntry backKey() const; + + bool fieldAt(quint32 index, HeaderField *field) const; + + const HeaderField &front() const; + HeaderField &front(); + const HeaderField &back() const; + + quint32 nDynamic; + quint32 begin; + quint32 end; + quint32 dataSize; + + quint32 indexOfChunk(const Chunk *chunk) const; + quint32 keyToIndex(const SearchEntry &key) const; + + enum class CompareMode { + nameOnly, + nameAndValue + }; + + static std::vector<HeaderField>::const_iterator findInStaticPart(const HeaderField &field, CompareMode mode); + + mutable QByteArray dummyDst; + + Q_DISABLE_COPY_MOVE(FieldLookupTable) +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/http2frames_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/http2frames_p.h new file mode 100644 index 0000000000000000000000000000000000000000..585a312f4f176fdc8a3923f91b5de703cd0131c2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/http2frames_p.h @@ -0,0 +1,155 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef HTTP2FRAMES_P_H +#define HTTP2FRAMES_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "http2protocol_p.h" +#include "hpack_p.h" + +#include <QtCore/qendian.h> +#include <QtCore/qglobal.h> + +#include <algorithm> +#include <vector> + +QT_BEGIN_NAMESPACE + +class QHttp2ProtocolHandler; +class QIODevice; + +namespace Http2 +{ + +struct Q_AUTOTEST_EXPORT Frame +{ + Frame(); + // Reading these values without first forming a valid frame (either reading + // it from a socket or building it) will result in undefined behavior: + FrameType type() const; + quint32 streamID() const; + FrameFlags flags() const; + quint32 payloadSize() const; + uchar padding() const; + // In HTTP/2 a stream's priority is specified by its weight and a stream + // (id) it depends on: + bool priority(quint32 *streamID = nullptr, + uchar *weight = nullptr) const; + + FrameStatus validateHeader() const; + FrameStatus validatePayload() const; + + // Number of payload bytes without padding and/or priority. + quint32 dataSize() const; + // HEADERS data size for HEADERS, PUSH_PROMISE and CONTINUATION streams: + quint32 hpackBlockSize() const; + // Beginning of payload without priority/padding bytes. + const uchar *dataBegin() const; + // HEADERS data beginning for HEADERS, PUSH_PROMISE and CONTINUATION streams: + const uchar *hpackBlockBegin() const; + + std::vector<uchar> buffer; +}; + +class Q_AUTOTEST_EXPORT FrameReader +{ +public: + FrameStatus read(QIODevice &socket); + + Frame &inboundFrame() + { + return frame; + } +private: + bool readHeader(QIODevice &socket); + bool readPayload(QIODevice &socket); + + quint32 offset = 0; + Frame frame; +}; + +class Q_AUTOTEST_EXPORT FrameWriter +{ +public: + using payload_type = std::vector<uchar>; + using size_type = payload_type::size_type; + + FrameWriter(); + FrameWriter(FrameType type, FrameFlags flags, quint32 streamID); + + Frame &outboundFrame() + { + return frame; + } + + void setOutboundFrame(Frame &&newFrame); + + // Frame 'builders': + void start(FrameType type, FrameFlags flags, quint32 streamID); + void setPayloadSize(quint32 size); + void setType(FrameType type); + void setFlags(FrameFlags flags); + void addFlag(FrameFlag flag); + + // All append functions also update frame's payload length. + template<typename ValueType> + void append(ValueType val) + { + uchar wired[sizeof val] = {}; + qToBigEndian(val, wired); + append(wired, wired + sizeof val); + } + void append(uchar val) + { + frame.buffer.push_back(val); + updatePayloadSize(); + } + void append(Settings identifier) + { + append(quint16(identifier)); + } + void append(const payload_type &payload) + { + append(&payload[0], &payload[0] + payload.size()); + } + void append(QByteArrayView payload) + { + append(reinterpret_cast<const uchar *>(payload.begin()), + reinterpret_cast<const uchar *>(payload.end())); + } + + void append(const uchar *begin, const uchar *end); + + // Write as a single frame: + bool write(QIODevice &socket) const; + // Two types of frames we are sending are affected by frame size limits: + // HEADERS and DATA. HEADERS' payload (hpacked HTTP headers, following a + // frame header) is always in our 'buffer', we send the initial HEADERS + // frame first and then CONTINUTATION frame(s) if needed: + bool writeHEADERS(QIODevice &socket, quint32 sizeLimit); + // With DATA frames the actual payload is never in our 'buffer', it's a + // 'readPointer' from QNonContiguousData. We split this payload as needed + // into DATA frames with correct payload size fitting into frame size limit: + bool writeDATA(QIODevice &socket, quint32 sizeLimit, + const uchar *src, quint32 size); +private: + void updatePayloadSize(); + Frame frame; +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/http2protocol_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/http2protocol_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c25435fcb21fa13cbf927483d8ac4aaec6cf3540 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/http2protocol_p.h @@ -0,0 +1,173 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef HTTP2PROTOCOL_P_H +#define HTTP2PROTOCOL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/qnetworkreply.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qmetatype.h> +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qmap.h> + +#include <vector> + +// Different HTTP/2 constants/values as defined by RFC 7540. + +QT_BEGIN_NAMESPACE + +class QHttpNetworkRequest; +class QHttp2Configuration; +class QHttpNetworkReply; +class QByteArray; +class QString; + +namespace Http2 +{ + +enum class Settings : quint16 +{ + HEADER_TABLE_SIZE_ID = 0x1, + ENABLE_PUSH_ID = 0x2, + MAX_CONCURRENT_STREAMS_ID = 0x3, + INITIAL_WINDOW_SIZE_ID = 0x4, + MAX_FRAME_SIZE_ID = 0x5, + MAX_HEADER_LIST_SIZE_ID = 0x6 +}; + +enum class FrameType : uchar +{ + DATA = 0x0, + HEADERS = 0x1, + PRIORITY = 0x2, + RST_STREAM = 0x3, + SETTINGS = 0x4, + PUSH_PROMISE = 0x5, + PING = 0x6, + GOAWAY = 0x7, + WINDOW_UPDATE = 0x8, + CONTINUATION = 0x9, + // ATTENTION: enumerators must be sorted. + // We use LAST_FRAME_TYPE to check if + // frame type is known, if not - this frame + // must be ignored, HTTP/2 5.1). + LAST_FRAME_TYPE +}; + +enum class FrameFlag : uchar +{ + EMPTY = 0x0, // Valid for any frame type. + ACK = 0x1, // Valid for PING, SETTINGS + END_STREAM = 0x1, // Valid for HEADERS, DATA + END_HEADERS = 0x4, // Valid for PUSH_PROMISE, HEADERS, + PADDED = 0x8, // Valid for PUSH_PROMISE, HEADERS, DATA + PRIORITY = 0x20 // Valid for HEADERS, +}; + +Q_DECLARE_FLAGS(FrameFlags, FrameFlag) +Q_DECLARE_OPERATORS_FOR_FLAGS(FrameFlags) + +enum Http2PredefinedParameters +{ + // Old-style enum, so we + // can use as Http2::frameHeaderSize for example. + clientPrefaceLength = 24, // HTTP/2, 3.5 + connectionStreamID = 0, // HTTP/2, 5.1.1 + frameHeaderSize = 9, // HTTP/2, 4.1 + + // The initial allowed payload size. We would use it as an + // upper limit for a frame payload we send, until our peer + // updates us with a larger SETTINGS_MAX_FRAME_SIZE. + + // The initial maximum payload size that an HTTP/2 frame + // can contain is 16384. It's also the minimal size that + // can be advertised via 'SETTINGS' frames. A real frame + // can have a payload smaller than 16384. + minPayloadLimit = 16384, // HTTP/2 6.5.2 + // The maximum allowed payload size. + maxPayloadSize = (1 << 24) - 1, // HTTP/2 6.5.2 + + defaultSessionWindowSize = 65535, // HTTP/2 6.5.2 + maxConcurrentStreams = 100 // HTTP/2, 6.5.2 +}; + +// These are ints, const, they have internal linkage, it's ok to have them in +// headers - no ODR violation. +const quint32 lastValidStreamID((quint32(1) << 31) - 1); // HTTP/2, 5.1.1 + +// The default size of 64K is too small and limiting: if we use it, we end up +// sending WINDOW_UPDATE frames on a stream/session all the time, for each +// 2 DATE frames of size 16K (also default) we'll send a WINDOW_UPDATE frame +// for a given stream and have a download speed order of magnitude lower than +// our own HTTP/1.1 protocol handler. We choose a bigger window size: normally, +// HTTP/2 servers are not afraid to immediately set it to the possible max, +// we do the same and split this window size between our concurrent streams. +const qint32 maxSessionReceiveWindowSize((quint32(1) << 31) - 1); +// Presumably, we never use up to 100 streams so let it be 10 simultaneous: +const qint32 qtDefaultStreamReceiveWindowSize = maxSessionReceiveWindowSize / 10; + +struct Frame Q_AUTOTEST_EXPORT configurationToSettingsFrame(const QHttp2Configuration &configuration); +QByteArray settingsFrameToBase64(const Frame &settingsFrame); +void appendProtocolUpgradeHeaders(const QHttp2Configuration &configuration, QHttpNetworkRequest *request); +std::vector<uchar> assemble_hpack_block(const std::vector<Frame> &frames); + +extern const Q_AUTOTEST_EXPORT char Http2clientPreface[clientPrefaceLength]; + +enum class FrameStatus +{ + protocolError, + sizeError, + incompleteFrame, + goodFrame +}; + +enum Http2Error : quint32 +{ + // Old-style enum to avoid excessive name + // qualification ... + // NB: + // I use the last enumerator to check + // that errorCode (quint32) is valid, + // so it needs to be the highest-numbered! + // HTTP/2 7: + HTTP2_NO_ERROR = 0x0, + PROTOCOL_ERROR = 0x1, + INTERNAL_ERROR = 0x2, + FLOW_CONTROL_ERROR = 0x3, + SETTINGS_TIMEOUT = 0x4, + STREAM_CLOSED = 0x5, + FRAME_SIZE_ERROR = 0x6, + REFUSE_STREAM = 0x7, + CANCEL = 0x8, + COMPRESSION_ERROR = 0x9, + CONNECT_ERROR = 0xa, + ENHANCE_YOUR_CALM = 0xb, + INADEQUATE_SECURITY = 0xc, + HTTP_1_1_REQUIRED = 0xd +}; + +void qt_error(quint32 errorCode, QNetworkReply::NetworkError &error, QString &errorString); +QString qt_error_string(quint32 errorCode); +QNetworkReply::NetworkError qt_error(quint32 errorCode); +bool is_protocol_upgraded(const QHttpNetworkReply &reply); + +} // namespace Http2 + +Q_DECLARE_LOGGING_CATEGORY(QT_HTTP2) + +QT_END_NAMESPACE + +QT_DECL_METATYPE_EXTERN_TAGGED(Http2::Settings, Http2__Settings, Q_NETWORK_EXPORT) + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/http2streams_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/http2streams_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8522117a823e8507db0497dfc9323c406dc0fa78 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/http2streams_p.h @@ -0,0 +1,91 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef HTTP2STREAMS_P_H +#define HTTP2STREAMS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "http2frames_p.h" +#include "hpack_p.h" + +#include <private/qhttpnetworkconnectionchannel_p.h> +#include <private/qhttpnetworkrequest_p.h> + +#include <QtCore/qglobal.h> +#include <QtCore/qstring.h> + +#include <vector> + +QT_REQUIRE_CONFIG(http); + +QT_BEGIN_NAMESPACE + +class QNonContiguousByteDevice; + +namespace Http2 +{ + +struct Q_AUTOTEST_EXPORT Stream +{ + enum StreamState { + idle, + open, + halfClosedLocal, + halfClosedRemote, + remoteReserved, + closed + }; + + Stream(); + // That's a ctor for a client-initiated stream: + Stream(const HttpMessagePair &message, quint32 streamID, qint32 sendSize, + qint32 recvSize); + // That's a reserved stream, created by PUSH_PROMISE from a server: + Stream(const QString &key, quint32 streamID, qint32 recvSize); + + QHttpNetworkReply *reply() const; + const QHttpNetworkRequest &request() const; + QHttpNetworkRequest &request(); + QHttpNetworkRequest::Priority priority() const; + uchar weight() const; + + QNonContiguousByteDevice *data() const; + + HttpMessagePair httpPair; + quint32 streamID = 0; + // Signed as window sizes can become negative: + qint32 sendWindow = 65535; + qint32 recvWindow = 65535; + + StreamState state = idle; + QString key; // for PUSH_PROMISE +}; + +struct PushPromise +{ + quint32 reservedID = 0; + // PUSH_PROMISE has its own HEADERS, + // usually similar to what request has: + HPack::HttpHeader pushHeader; + // Response has its own (normal) HEADERS: + HPack::HttpHeader responseHeader; + // DATA frames on a promised stream: + std::vector<Frame> dataFrames; +}; + +} // namespace Http2 + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/huffman_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/huffman_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7743d19d115f3bc9dbb3842784006e6dff459cad --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/huffman_p.h @@ -0,0 +1,133 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef HUFFMAN_P_H +#define HUFFMAN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QByteArray; + +namespace HPack +{ + +struct CodeEntry +{ + quint32 byteValue; + quint32 huffmanCode; + quint32 bitLength; +}; + +class BitOStream; + +quint64 huffman_encoded_bit_length(QByteArrayView inputData); +void huffman_encode_string(QByteArrayView inputData, BitOStream &outputStream); + +// PrefixTable: +// Huffman codes with a small bit length +// fit into a table (these are 'terminal' symbols), +// codes with longer codes require additional +// tables, so several symbols will have the same index +// in a table - pointing into the next table. +// Every table has an 'indexLength' - that's +// how many bits can fit in table's indices + +// 'prefixLength' - how many bits were addressed +// by its 'parent' table(s). +// All PrefixTables are kept in 'prefixTables' array. +// PrefixTable itself does not have any entries, +// it just holds table's prefix/index + 'offset' - +// there table's data starts in an array of all +// possible entries ('tableData'). + +struct PrefixTable +{ + PrefixTable() + : prefixLength(), + indexLength(), + offset() + { + } + + PrefixTable(quint32 prefix, quint32 index) + : prefixLength(prefix), + indexLength(index), + offset() + { + } + + quint32 size()const + { + // Number of entries table contains: + return 1 << indexLength; + } + + quint32 prefixLength; + quint32 indexLength; + quint32 offset; +}; + +// Table entry is either a terminal entry (thus probably the code found) +// or points into another table ('nextTable' - index into +// 'prefixTables' array). If it's a terminal, 'nextTable' index +// refers to the same table. + +struct PrefixTableEntry +{ + PrefixTableEntry() + : bitLength(), + nextTable(), + byteValue() + { + } + + quint32 bitLength; + quint32 nextTable; + quint32 byteValue; +}; + +class BitIStream; + +class HuffmanDecoder +{ +public: + enum class BitConstants + { + rootPrefix = 9, + childPrefix = 6 + }; + + HuffmanDecoder(); + + bool decodeStream(BitIStream &inputStream, QByteArray &outputBuffer); + +private: + quint32 addTable(quint32 prefixLength, quint32 indexLength); + PrefixTableEntry tableEntry(PrefixTable table, quint32 index); + void setTableEntry(PrefixTable table, quint32 index, PrefixTableEntry entry); + + std::vector<PrefixTable> prefixTables; + std::vector<PrefixTableEntry> tableData; + quint32 minCodeLength; +}; + +bool huffman_decode_string(BitIStream &inputStream, QByteArray *outputBuffer); + +} // namespace HPack + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractnetworkcache_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractnetworkcache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..731c7ec7111fdf52459cf07229c52e7760932790 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractnetworkcache_p.h @@ -0,0 +1,29 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTNETWORKCACHE_P_H +#define QABSTRACTNETWORKCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access framework. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "private/qobject_p.h" + +QT_BEGIN_NAMESPACE + +class QAbstractNetworkCachePrivate: public QObjectPrivate +{ +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractprotocolhandler_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractprotocolhandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..88881e67971d7390f6ecb18be885fa73e0494452 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractprotocolhandler_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2014 BlackBerry Limited. All rights reserved. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTPROTOCOLHANDLER_H +#define QABSTRACTPROTOCOLHANDLER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +QT_REQUIRE_CONFIG(http); + +QT_BEGIN_NAMESPACE + +class QHttpNetworkConnectionChannel; +class QHttpNetworkReply; +class QIODevice; +class QHttpNetworkConnection; + +class QAbstractProtocolHandler { +public: + QAbstractProtocolHandler(QHttpNetworkConnectionChannel *channel); + virtual ~QAbstractProtocolHandler(); + + virtual void _q_receiveReply() = 0; + virtual void _q_readyRead() = 0; + virtual bool sendRequest() = 0; + void setReply(QHttpNetworkReply *reply); + +protected: + QHttpNetworkConnectionChannel *m_channel; + QHttpNetworkReply *m_reply; + QIODevice *m_socket; + QHttpNetworkConnection *m_connection; +}; + +QT_END_NAMESPACE + +#endif // QABSTRACTPROTOCOLHANDLER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractsocket_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractsocket_p.h new file mode 100644 index 0000000000000000000000000000000000000000..88dc5639402ac026f97330321c9fa710ea8f1701 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractsocket_p.h @@ -0,0 +1,138 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTSOCKET_P_H +#define QABSTRACTSOCKET_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QAbstractSocket class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "QtNetwork/qabstractsocket.h" +#include "QtCore/qbytearray.h" +#include "QtCore/qlist.h" +#include "QtCore/qtimer.h" +#include "private/qiodevice_p.h" +#include "private/qabstractsocketengine_p.h" +#include "qnetworkproxy.h" + +QT_BEGIN_NAMESPACE + +class QHostInfo; + +class QAbstractSocketPrivate : public QIODevicePrivate, public QAbstractSocketEngineReceiver +{ + Q_DECLARE_PUBLIC(QAbstractSocket) +public: + QAbstractSocketPrivate(); + virtual ~QAbstractSocketPrivate(); + + // from QAbstractSocketEngineReceiver + inline void readNotification() override { canReadNotification(); } + inline void writeNotification() override { canWriteNotification(); } + inline void exceptionNotification() override {} + inline void closeNotification() override { canCloseNotification(); } + void connectionNotification() override; +#ifndef QT_NO_NETWORKPROXY + inline void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator) override { + Q_Q(QAbstractSocket); + emit q->proxyAuthenticationRequired(proxy, authenticator); + } +#endif + + virtual bool bind(const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode); + + virtual bool canReadNotification(); + bool canWriteNotification(); + void canCloseNotification(); + + // slots + void _q_connectToNextAddress(); + void _q_startConnecting(const QHostInfo &hostInfo); + void _q_testConnection(); + void _q_abortConnectionAttempt(); + + bool emittedReadyRead = false; + bool emittedBytesWritten = false; + + bool abortCalled = false; + bool pendingClose = false; + + QAbstractSocket::PauseModes pauseMode = QAbstractSocket::PauseNever; + + QString hostName; + quint16 port = 0; + QHostAddress host; + QList<QHostAddress> addresses; + + quint16 localPort = 0; + quint16 peerPort = 0; + QHostAddress localAddress; + QHostAddress peerAddress; + QString peerName; + + QAbstractSocketEngine *socketEngine = nullptr; + qintptr cachedSocketDescriptor = -1; + +#ifndef QT_NO_NETWORKPROXY + QNetworkProxy proxy; + QNetworkProxy proxyInUse; + QString protocolTag; + void resolveProxy(const QString &hostName, quint16 port); +#else + inline void resolveProxy(const QString &, quint16) { } +#endif + inline void resolveProxy(quint16 port) { resolveProxy(QString(), port); } + + void resetSocketLayer(); + virtual bool flush(); + + bool initSocketLayer(QAbstractSocket::NetworkLayerProtocol protocol); + virtual void configureCreatedSocket(); + void startConnectingByName(const QString &host); + void fetchConnectionParameters(); + bool readFromSocket(); + virtual bool writeToSocket(); + void emitReadyRead(int channel = 0); + void emitBytesWritten(qint64 bytes, int channel = 0); + + void setError(QAbstractSocket::SocketError errorCode, const QString &errorString); + void setErrorAndEmit(QAbstractSocket::SocketError errorCode, const QString &errorString); + + qint64 readBufferMaxSize = 0; + bool isBuffered = false; + bool hasPendingData = false; + bool hasPendingDatagram = false; + + QTimer *connectTimer = nullptr; + + int hostLookupId = -1; + + QAbstractSocket::SocketType socketType = QAbstractSocket::UnknownSocketType; + QAbstractSocket::SocketState state = QAbstractSocket::UnconnectedState; + + // Must be kept in sync with QIODevicePrivate::errorString. + QAbstractSocket::SocketError socketError = QAbstractSocket::UnknownSocketError; + + QAbstractSocket::NetworkLayerProtocol preferredNetworkLayerProtocol = + QAbstractSocket::UnknownNetworkLayerProtocol; + + bool prePauseReadSocketNotifierState = false; + bool prePauseWriteSocketNotifierState = false; + bool prePauseExceptionSocketNotifierState = false; + static void pauseSocketNotifiers(QAbstractSocket*); + static void resumeSocketNotifiers(QAbstractSocket*); + static QAbstractSocketEngine* getSocketEngine(QAbstractSocket*); +}; + +QT_END_NAMESPACE + +#endif // QABSTRACTSOCKET_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractsocketengine_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractsocketengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c4379c4b20e127d894f76db99511a1435195f2d0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qabstractsocketengine_p.h @@ -0,0 +1,231 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTSOCKETENGINE_P_H +#define QABSTRACTSOCKETENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "QtNetwork/qhostaddress.h" +#include "QtNetwork/qabstractsocket.h" +#include <QtCore/qdeadlinetimer.h> +#include "private/qnetworkdatagram_p.h" +#include "private/qobject_p.h" + +QT_BEGIN_NAMESPACE + +class QAuthenticator; +class QAbstractSocketEnginePrivate; +#ifndef QT_NO_NETWORKINTERFACE +class QNetworkInterface; +#endif +class QNetworkProxy; + +class QAbstractSocketEngineReceiver { +public: + virtual ~QAbstractSocketEngineReceiver(){} + virtual void readNotification()= 0; + virtual void writeNotification()= 0; + virtual void closeNotification()= 0; + virtual void exceptionNotification()= 0; + virtual void connectionNotification()= 0; +#ifndef QT_NO_NETWORKPROXY + virtual void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)= 0; +#endif +}; + +static constexpr std::chrono::seconds DefaultTimeout{30}; + +class Q_AUTOTEST_EXPORT QAbstractSocketEngine : public QObject +{ + Q_OBJECT + Q_MOC_INCLUDE(<QtNetwork/qauthenticator.h>) +public: + + static QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType, const QNetworkProxy &, QObject *parent); + static QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent); + + QAbstractSocketEngine(QObject *parent = nullptr); + + enum SocketOption { + NonBlockingSocketOption, + BroadcastSocketOption, + ReceiveBufferSocketOption, + SendBufferSocketOption, + AddressReusable, + BindExclusively, + ReceiveOutOfBandData, + LowDelayOption, + KeepAliveOption, + MulticastTtlOption, + MulticastLoopbackOption, + TypeOfServiceOption, + ReceivePacketInformation, + ReceiveHopLimit, + MaxStreamsSocketOption, + PathMtuInformation + }; + + enum PacketHeaderOption { + WantNone = 0, + WantDatagramSender = 0x01, + WantDatagramDestination = 0x02, + WantDatagramHopLimit = 0x04, + WantStreamNumber = 0x08, + WantEndOfRecord = 0x10, + + WantAll = 0xff + }; + Q_DECLARE_FLAGS(PacketHeaderOptions, PacketHeaderOption) + + virtual bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) = 0; + + virtual bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState) = 0; + + virtual qintptr socketDescriptor() const = 0; + + virtual bool isValid() const = 0; + + virtual bool connectToHost(const QHostAddress &address, quint16 port) = 0; + virtual bool connectToHostByName(const QString &name, quint16 port) = 0; + virtual bool bind(const QHostAddress &address, quint16 port) = 0; + virtual bool listen(int backlog) = 0; + virtual qintptr accept() = 0; + virtual void close() = 0; + + virtual qint64 bytesAvailable() const = 0; + + virtual qint64 read(char *data, qint64 maxlen) = 0; + virtual qint64 write(const char *data, qint64 len) = 0; + +#ifndef QT_NO_UDPSOCKET +#ifndef QT_NO_NETWORKINTERFACE + virtual bool joinMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &iface) = 0; + virtual bool leaveMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &iface) = 0; + virtual QNetworkInterface multicastInterface() const = 0; + virtual bool setMulticastInterface(const QNetworkInterface &iface) = 0; +#endif // QT_NO_NETWORKINTERFACE + + virtual bool hasPendingDatagrams() const = 0; + virtual qint64 pendingDatagramSize() const = 0; +#endif // QT_NO_UDPSOCKET + + virtual qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader *header = nullptr, + PacketHeaderOptions = WantNone) = 0; + virtual qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &header) = 0; + virtual qint64 bytesToWrite() const = 0; + + virtual int option(SocketOption option) const = 0; + virtual bool setOption(SocketOption option, int value) = 0; + + virtual bool waitForRead(QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) = 0; + virtual bool waitForWrite(QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) = 0; + virtual bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, + bool checkRead, bool checkWrite, + QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) = 0; + + QAbstractSocket::SocketError error() const; + QString errorString() const; + QAbstractSocket::SocketState state() const; + QAbstractSocket::SocketType socketType() const; + QAbstractSocket::NetworkLayerProtocol protocol() const; + + QHostAddress localAddress() const; + quint16 localPort() const; + QHostAddress peerAddress() const; + quint16 peerPort() const; + int inboundStreamCount() const; + int outboundStreamCount() const; + + virtual bool isReadNotificationEnabled() const = 0; + virtual void setReadNotificationEnabled(bool enable) = 0; + virtual bool isWriteNotificationEnabled() const = 0; + virtual void setWriteNotificationEnabled(bool enable) = 0; + virtual bool isExceptionNotificationEnabled() const = 0; + virtual void setExceptionNotificationEnabled(bool enable) = 0; + +public Q_SLOTS: + void readNotification(); + void writeNotification(); + void closeNotification(); + void exceptionNotification(); + void connectionNotification(); +#ifndef QT_NO_NETWORKPROXY + void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator); +#endif + +public: + void setReceiver(QAbstractSocketEngineReceiver *receiver); +protected: + QAbstractSocketEngine(QAbstractSocketEnginePrivate &dd, QObject* parent = nullptr); + + void setError(QAbstractSocket::SocketError error, const QString &errorString) const; + void setState(QAbstractSocket::SocketState state); + void setSocketType(QAbstractSocket::SocketType socketType); + void setProtocol(QAbstractSocket::NetworkLayerProtocol protocol); + void setLocalAddress(const QHostAddress &address); + void setLocalPort(quint16 port); + void setPeerAddress(const QHostAddress &address); + void setPeerPort(quint16 port); + +private: + Q_DECLARE_PRIVATE(QAbstractSocketEngine) + Q_DISABLE_COPY_MOVE(QAbstractSocketEngine) +}; + +class QAbstractSocketEnginePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QAbstractSocketEngine) +public: + QAbstractSocketEnginePrivate(); + + mutable QAbstractSocket::SocketError socketError; + mutable bool hasSetSocketError; + mutable QString socketErrorString; + QAbstractSocket::SocketState socketState; + QAbstractSocket::SocketType socketType; + QAbstractSocket::NetworkLayerProtocol socketProtocol; + QHostAddress localAddress; + quint16 localPort; + QHostAddress peerAddress; + quint16 peerPort; + int inboundStreamCount; + int outboundStreamCount; + QAbstractSocketEngineReceiver *receiver; +}; + + +class Q_AUTOTEST_EXPORT QSocketEngineHandler +{ +protected: + QSocketEngineHandler(); + virtual ~QSocketEngineHandler(); + virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType, + const QNetworkProxy &, QObject *parent) = 0; + virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent) = 0; + +private: + friend class QAbstractSocketEngine; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSocketEngine::PacketHeaderOptions) + +QT_END_NAMESPACE + +#endif // QABSTRACTSOCKETENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qauthenticator_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qauthenticator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a4c11d39d3b749f46cd06441ce3a78cedadcf33e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qauthenticator_p.h @@ -0,0 +1,93 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QAUTHENTICATOR_P_H +#define QAUTHENTICATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <qhash.h> +#include <qbytearray.h> +#include <qscopedpointer.h> +#include <qstring.h> +#include <qauthenticator.h> +#include <qvariant.h> + +QT_BEGIN_NAMESPACE + +class QHttpResponseHeader; +class QHttpHeaders; +#if QT_CONFIG(sspi) // SSPI +class QSSPIWindowsHandles; +#elif QT_CONFIG(gssapi) // GSSAPI +class QGssApiHandles; +#endif + +class Q_NETWORK_EXPORT QAuthenticatorPrivate +{ +public: + enum Method { None, Basic, Negotiate, Ntlm, DigestMd5, }; + QAuthenticatorPrivate(); + ~QAuthenticatorPrivate(); + + QString user; + QString extractedUser; + QString password; + QVariantHash options; + Method method; + QString realm; + QByteArray challenge; +#if QT_CONFIG(sspi) // SSPI + QScopedPointer<QSSPIWindowsHandles> sspiWindowsHandles; +#elif QT_CONFIG(gssapi) // GSSAPI + QScopedPointer<QGssApiHandles> gssApiHandles; +#endif + bool hasFailed; //credentials have been tried but rejected by server. + + enum Phase { + Start, + Phase1, + Phase2, + Done, + Invalid + }; + Phase phase; + + // digest specific + QByteArray cnonce; + int nonceCount; + + // ntlm specific + QString workstation; + QString userDomain; + + QByteArray calculateResponse(QByteArrayView method, QByteArrayView path, QStringView host); + + inline static QAuthenticatorPrivate *getPrivate(QAuthenticator &auth) { return auth.d; } + inline static const QAuthenticatorPrivate *getPrivate(const QAuthenticator &auth) { return auth.d; } + + QByteArray digestMd5Response(QByteArrayView challenge, QByteArrayView method, + QByteArrayView path); + static QHash<QByteArray, QByteArray> + parseDigestAuthenticationChallenge(QByteArrayView challenge); + + void parseHttpResponse(const QHttpHeaders &headers, bool isProxy, QStringView host); + void updateCredentials(); + + static bool isMethodSupported(QByteArrayView method); +}; + + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qdecompresshelper_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qdecompresshelper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..340bb2e31600ba7e49efd95e71238444339863c8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qdecompresshelper_p.h @@ -0,0 +1,108 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef DECOMPRESS_HELPER_P_H +#define DECOMPRESS_HELPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtCore/private/qbytedata_p.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +class QIODevice; +class Q_AUTOTEST_EXPORT QDecompressHelper +{ +public: + enum ContentEncoding { + None, + Deflate, + GZip, + Brotli, + Zstandard, + }; + + QDecompressHelper() = default; + ~QDecompressHelper(); + + bool setEncoding(QByteArrayView contentEncoding); + + bool isCountingBytes() const; + void setCountingBytesEnabled(bool shouldCount); + + qint64 uncompressedSize() const; + + bool hasData() const; + void feed(const QByteArray &data); + void feed(QByteArray &&data); + void feed(const QByteDataBuffer &buffer); + void feed(QByteDataBuffer &&buffer); + qsizetype read(char *data, qsizetype maxSize); + + bool isValid() const; + + void clear(); + + void setDecompressedSafetyCheckThreshold(qint64 threshold); + + static bool isSupportedEncoding(QByteArrayView encoding); + static QByteArrayList acceptedEncoding(); + + QString errorString() const; + +private: + bool isPotentialArchiveBomb() const; + bool hasDataInternal() const; + qsizetype readInternal(char *data, qsizetype maxSize); + + bool countInternal(); + bool countInternal(const QByteArray &data); + bool countInternal(const QByteDataBuffer &buffer); + + bool setEncoding(ContentEncoding ce); + qint64 encodedBytesAvailable() const; + + qsizetype readZLib(char *data, qsizetype maxSize); + qsizetype readBrotli(char *data, qsizetype maxSize); + qsizetype readZstandard(char *data, qsizetype maxSize); + + QByteDataBuffer compressedDataBuffer; + QByteDataBuffer decompressedDataBuffer; + const qsizetype MaxDecompressedDataBufferSize = 10 * 1024 * 1024; + bool decoderHasData = false; + + bool countDecompressed = false; + std::unique_ptr<QDecompressHelper> countHelper; + + QString errorStr; + + // Used for calculating the ratio + qint64 archiveBombCheckThreshold = 10 * 1024 * 1024; + qint64 totalUncompressedBytes = 0; + qint64 totalCompressedBytes = 0; + qint64 totalBytesRead = 0; + + ContentEncoding contentEncoding = None; + + void *decoderPointer = nullptr; +#if QT_CONFIG(brotli) + const uint8_t *brotliUnconsumedDataPtr = nullptr; + size_t brotliUnconsumedAmount = 0; +#endif +}; + +QT_END_NAMESPACE + +#endif // DECOMPRESS_HELPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qdnslookup_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qdnslookup_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dff9091fdc81e659af8b0c5b279aa4ff0480641f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qdnslookup_p.h @@ -0,0 +1,312 @@ +// Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org> +// Copyright (C) 2023 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDNSLOOKUP_P_H +#define QDNSLOOKUP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QDnsLookup class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "QtCore/qmutex.h" +#include "QtCore/qrunnable.h" +#if QT_CONFIG(thread) +#include "QtCore/qthreadpool.h" +#endif +#include "QtNetwork/qdnslookup.h" +#include "QtNetwork/qhostaddress.h" +#include "private/qobject_p.h" +#include "private/qurl_p.h" + +#if QT_CONFIG(ssl) +# include "qsslconfiguration.h" +#endif + +QT_REQUIRE_CONFIG(dnslookup); + +QT_BEGIN_NAMESPACE + +//#define QDNSLOOKUP_DEBUG + +constexpr qsizetype MaxDomainNameLength = 255; +constexpr quint16 DnsPort = 53; +constexpr quint16 DnsOverTlsPort = 853; + +class QDnsLookupRunnable; +QDebug operator<<(QDebug &, QDnsLookupRunnable *); + +class QDnsLookupReply +{ +public: + QDnsLookup::Error error = QDnsLookup::NoError; + bool authenticData = false; + QString errorString; + + QList<QDnsDomainNameRecord> canonicalNameRecords; + QList<QDnsHostAddressRecord> hostAddressRecords; + QList<QDnsMailExchangeRecord> mailExchangeRecords; + QList<QDnsDomainNameRecord> nameServerRecords; + QList<QDnsDomainNameRecord> pointerRecords; + QList<QDnsServiceRecord> serviceRecords; + QList<QDnsTlsAssociationRecord> tlsAssociationRecords; + QList<QDnsTextRecord> textRecords; + +#if QT_CONFIG(ssl) + std::optional<QSslConfiguration> sslConfiguration; +#endif + + // helper methods + void setError(QDnsLookup::Error err, QString &&msg) + { + error = err; + errorString = std::move(msg); + } + + void makeResolverSystemError(int code = -1) + { + Q_ASSERT(allAreEmpty()); + setError(QDnsLookup::ResolverError, qt_error_string(code)); + } + + void makeTimeoutError() + { + Q_ASSERT(allAreEmpty()); + setError(QDnsLookup::TimeoutError, QDnsLookup::tr("Request timed out")); + } + + void makeDnsRcodeError(quint8 rcode) + { + Q_ASSERT(allAreEmpty()); + switch (rcode) { + case 1: // FORMERR + error = QDnsLookup::InvalidRequestError; + errorString = QDnsLookup::tr("Server could not process query"); + return; + case 2: // SERVFAIL + case 4: // NOTIMP + error = QDnsLookup::ServerFailureError; + errorString = QDnsLookup::tr("Server failure"); + return; + case 3: // NXDOMAIN + error = QDnsLookup::NotFoundError; + errorString = QDnsLookup::tr("Non existent domain"); + return; + case 5: // REFUSED + error = QDnsLookup::ServerRefusedError; + errorString = QDnsLookup::tr("Server refused to answer"); + return; + default: + error = QDnsLookup::InvalidReplyError; + errorString = QDnsLookup::tr("Invalid reply received (rcode %1)") + .arg(rcode); + return; + } + } + + void makeInvalidReplyError(QString &&msg = QString()) + { + if (msg.isEmpty()) + msg = QDnsLookup::tr("Invalid reply received"); + else + msg = QDnsLookup::tr("Invalid reply received (%1)").arg(std::move(msg)); + *this = QDnsLookupReply(); // empty our lists + setError(QDnsLookup::InvalidReplyError, std::move(msg)); + } + +private: + bool allAreEmpty() const + { + return canonicalNameRecords.isEmpty() + && hostAddressRecords.isEmpty() + && mailExchangeRecords.isEmpty() + && nameServerRecords.isEmpty() + && pointerRecords.isEmpty() + && serviceRecords.isEmpty() + && tlsAssociationRecords.isEmpty() + && textRecords.isEmpty(); + } +}; + +class QDnsLookupPrivate : public QObjectPrivate +{ +public: + QDnsLookupPrivate() + : type(QDnsLookup::A) + , port(0) + , protocol(QDnsLookup::Standard) + { } + + void nameChanged() + { + emit q_func()->nameChanged(name); + } + Q_OBJECT_BINDABLE_PROPERTY(QDnsLookupPrivate, QString, name, + &QDnsLookupPrivate::nameChanged); + + void nameserverChanged() + { + emit q_func()->nameserverChanged(nameserver); + } + Q_OBJECT_BINDABLE_PROPERTY(QDnsLookupPrivate, QHostAddress, nameserver, + &QDnsLookupPrivate::nameserverChanged); + + void typeChanged() + { + emit q_func()->typeChanged(type); + } + + Q_OBJECT_BINDABLE_PROPERTY(QDnsLookupPrivate, QDnsLookup::Type, + type, &QDnsLookupPrivate::typeChanged); + + void nameserverPortChanged() + { + emit q_func()->nameserverPortChanged(port); + } + + Q_OBJECT_BINDABLE_PROPERTY(QDnsLookupPrivate, quint16, + port, &QDnsLookupPrivate::nameserverPortChanged); + + void nameserverProtocolChanged() + { + emit q_func()->nameserverProtocolChanged(protocol); + } + + Q_OBJECT_BINDABLE_PROPERTY(QDnsLookupPrivate, QDnsLookup::Protocol, + protocol, &QDnsLookupPrivate::nameserverProtocolChanged); + + QDnsLookupReply reply; + QDnsLookupRunnable *runnable = nullptr; + bool isFinished = false; + +#if QT_CONFIG(ssl) + std::optional<QSslConfiguration> sslConfiguration; +#endif + + Q_DECLARE_PUBLIC(QDnsLookup) +}; + +class QDnsLookupRunnable : public QObject, public QRunnable +{ + Q_OBJECT + +public: +#ifdef Q_OS_WIN + using EncodedLabel = QString; +#else + using EncodedLabel = QByteArray; +#endif + // minimum IPv6 MTU (1280) minus the IPv6 (40) and UDP headers (8) + static constexpr qsizetype ReplyBufferSize = 1280 - 40 - 8; + using ReplyBuffer = QVarLengthArray<unsigned char, ReplyBufferSize>; + + QDnsLookupRunnable(const QDnsLookupPrivate *d); + void run() override; + bool sendDnsOverTls(QDnsLookupReply *reply, QSpan<unsigned char> query, ReplyBuffer &response); + +signals: + void finished(const QDnsLookupReply &reply); + +private: + template <typename T> static QString decodeLabel(T encodedLabel) + { + return qt_ACE_do(encodedLabel.toString(), NormalizeAce, ForbidLeadingDot); + } + void query(QDnsLookupReply *reply); + + EncodedLabel requestName; + QHostAddress nameserver; + QDnsLookup::Type requestType; + quint16 port; + QDnsLookup::Protocol protocol; + +#if QT_CONFIG(ssl) + std::optional<QSslConfiguration> sslConfiguration; +#endif + friend QDebug operator<<(QDebug &, QDnsLookupRunnable *); +}; + +class QDnsRecordPrivate : public QSharedData +{ +public: + QDnsRecordPrivate() + : timeToLive(0) + { } + + QString name; + quint32 timeToLive; +}; + +class QDnsDomainNameRecordPrivate : public QDnsRecordPrivate +{ +public: + QDnsDomainNameRecordPrivate() + { } + + QString value; +}; + +class QDnsHostAddressRecordPrivate : public QDnsRecordPrivate +{ +public: + QDnsHostAddressRecordPrivate() + { } + + QHostAddress value; +}; + +class QDnsMailExchangeRecordPrivate : public QDnsRecordPrivate +{ +public: + QDnsMailExchangeRecordPrivate() + : preference(0) + { } + + QString exchange; + quint16 preference; +}; + +class QDnsServiceRecordPrivate : public QDnsRecordPrivate +{ +public: + QDnsServiceRecordPrivate() + : port(0), + priority(0), + weight(0) + { } + + QString target; + quint16 port; + quint16 priority; + quint16 weight; +}; + +class QDnsTextRecordPrivate : public QDnsRecordPrivate +{ +public: + QDnsTextRecordPrivate() + { } + + QList<QByteArray> values; +}; + +class QDnsTlsAssociationRecordPrivate : public QDnsRecordPrivate +{ +public: + QDnsTlsAssociationRecord::CertificateUsage usage; + QDnsTlsAssociationRecord::Selector selector; + QDnsTlsAssociationRecord::MatchingType matchType; + QByteArray value; +}; + +QT_END_NAMESPACE + +#endif // QDNSLOOKUP_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qdtls_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qdtls_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4bb10c7f770fb79bbb7e056239794ab11d19b7c5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qdtls_p.h @@ -0,0 +1,47 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDTLS_P_H +#define QDTLS_P_H + +#include <private/qtnetworkglobal_p.h> + +#include "qtlsbackend_p.h" + +#include <QtCore/private/qobject_p.h> +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_REQUIRE_CONFIG(dtls); + +QT_BEGIN_NAMESPACE + +class QHostAddress; + +class QDtlsClientVerifierPrivate : public QObjectPrivate +{ +public: + QDtlsClientVerifierPrivate(); + ~QDtlsClientVerifierPrivate(); + std::unique_ptr<QTlsPrivate::DtlsCookieVerifier> backend; +}; + +class QDtlsPrivate : public QObjectPrivate +{ +public: + QDtlsPrivate(); + ~QDtlsPrivate(); + std::unique_ptr<QTlsPrivate::DtlsCryptograph> backend; +}; + +QT_END_NAMESPACE + +#endif // QDTLS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhostaddress_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhostaddress_p.h new file mode 100644 index 0000000000000000000000000000000000000000..01db3f96766a68d532b47a0a0e79dae0e334f0ce --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhostaddress_p.h @@ -0,0 +1,99 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHOSTADDRESSPRIVATE_H +#define QHOSTADDRESSPRIVATE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QHostAddress and QNetworkInterface classes. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qhostaddress.h" +#include "qabstractsocket.h" + +QT_BEGIN_NAMESPACE + +enum AddressClassification { + LoopbackAddress = 1, + LocalNetAddress, // RFC 1122 + LinkLocalAddress, // RFC 4291 (v6), RFC 3927 (v4) + MulticastAddress, // RFC 4291 (v6), RFC 3171 (v4) + BroadcastAddress, // RFC 919, 922 + + GlobalAddress = 16, + TestNetworkAddress, // RFC 3849 (v6), RFC 5737 (v4), + PrivateNetworkAddress, // RFC 1918 + UniqueLocalAddress, // RFC 4193 + SiteLocalAddress, // RFC 4291 (deprecated by RFC 3879, should be treated as global) + + UnknownAddress = 0 // unclassified or reserved +}; + +class QNetmask +{ + // stores 0-32 for IPv4, 0-128 for IPv6, or 255 for invalid + quint8 length; +public: + constexpr QNetmask() : length(255) {} + + bool setAddress(const QHostAddress &address); + QHostAddress address(QAbstractSocket::NetworkLayerProtocol protocol) const; + + int prefixLength() const { return length == 255 ? -1 : length; } + void setPrefixLength(QAbstractSocket::NetworkLayerProtocol proto, int len) + { + int maxlen = -1; + if (proto == QAbstractSocket::IPv4Protocol) + maxlen = 32; + else if (proto == QAbstractSocket::IPv6Protocol) + maxlen = 128; + if (len > maxlen || len < 0) + length = 255U; + else + length = unsigned(len); + } + + friend bool operator==(QNetmask n1, QNetmask n2) + { return n1.length == n2.length; } +}; + +class QHostAddressPrivate : public QSharedData +{ +public: + QHostAddressPrivate(); + + void setAddress(quint32 a_ = 0); + void setAddress(const quint8 *a_); + void setAddress(const Q_IPV6ADDR &a_); + + bool parse(const QString &ipString); + void clear(); + + QString scopeId; + + union { + Q_IPV6ADDR a6; // IPv6 address + struct { quint64 c[2]; } a6_64; + struct { quint32 c[4]; } a6_32; + }; + quint32 a; // IPv4 address + qint8 protocol; + + AddressClassification classify() const; + static AddressClassification classify(const QHostAddress &address) + { return address.d->classify(); } + + friend class QHostAddress; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhostinfo_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhostinfo_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8228097f98ad1bfa6e8e43481fbba9b2caf40308 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhostinfo_p.h @@ -0,0 +1,193 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHOSTINFO_P_H +#define QHOSTINFO_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QHostInfo class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "QtCore/qcoreapplication.h" +#include "private/qcoreapplication_p.h" +#include "private/qmetaobject_p.h" +#include "QtNetwork/qhostinfo.h" +#include "QtCore/qmutex.h" +#include "QtCore/qwaitcondition.h" +#include "QtCore/qobject.h" +#include "QtCore/qpointer.h" +#include "QtCore/qthread.h" +#if QT_CONFIG(thread) +#include "QtCore/qthreadpool.h" +#endif +#include "QtCore/qrunnable.h" +#include "QtCore/qlist.h" +#include "QtCore/qqueue.h" +#include <QElapsedTimer> +#include <QCache> + +#include <atomic> + +QT_BEGIN_NAMESPACE + + +class QHostInfoResult : public QObject +{ + Q_OBJECT +public: + explicit QHostInfoResult(const QObject *receiver, QtPrivate::SlotObjUniquePtr slot); + ~QHostInfoResult() override; + + void postResultsReady(const QHostInfo &info); + +Q_SIGNALS: + void resultsReady(const QHostInfo &info); + +private Q_SLOTS: + void finalizePostResultsReady(const QHostInfo &info); + +private: + QHostInfoResult(QHostInfoResult *other) + : receiver(other->receiver.get() != other ? other->receiver.get() : this), + slotObj{std::move(other->slotObj)} + { + // cleanup if the application terminates before results are delivered + connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, + this, &QObject::deleteLater); + // maintain thread affinity + moveToThread(other->thread()); + } + + // receiver is either a QObject provided by the user, + // or it's set to `this` (to emulate the behavior of the contextless connect()) + QPointer<const QObject> receiver = nullptr; + QtPrivate::SlotObjUniquePtr slotObj; +}; + +class QHostInfoAgent +{ +public: + static QHostInfo fromName(const QString &hostName); + static QHostInfo lookup(const QString &hostName); + static QHostInfo reverseLookup(const QHostAddress &address); +}; + +class QHostInfoPrivate +{ +public: + inline QHostInfoPrivate() + : err(QHostInfo::NoError), + errorStr(QLatin1StringView(QT_TRANSLATE_NOOP("QHostInfo", "Unknown error"))), + lookupId(0) + { + } + static int lookupHostImpl(const QString &name, + const QObject *receiver, + QtPrivate::QSlotObjectBase *slotObj, + const char *member); + + QHostInfo::HostInfoError err; + QString errorStr; + QList<QHostAddress> addrs; + QString hostName; + int lookupId; +}; + +// These functions are outside of the QHostInfo class and strictly internal. +// Do NOT use them outside of QAbstractSocket. +QHostInfo Q_NETWORK_EXPORT qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id); +void Q_AUTOTEST_EXPORT qt_qhostinfo_clear_cache(); +void Q_AUTOTEST_EXPORT qt_qhostinfo_enable_cache(bool e); +void Q_AUTOTEST_EXPORT qt_qhostinfo_cache_inject(const QString &hostname, const QHostInfo &resolution); + +class QHostInfoCache +{ +public: + QHostInfoCache(); + const int max_age; // seconds + + QHostInfo get(const QString &name, bool *valid); + void put(const QString &name, const QHostInfo &info); + void clear(); + + bool isEnabled() { return enabled.load(std::memory_order_relaxed); } + // this function is currently only used for the auto tests + // and not usable by public API + void setEnabled(bool e) { enabled.store(e, std::memory_order_relaxed); } +private: + std::atomic<bool> enabled; + struct QHostInfoCacheElement { + QHostInfo info; + QElapsedTimer age; + }; + QCache<QString,QHostInfoCacheElement> cache; + QMutex mutex; +}; + +// the following classes are used for the (normal) case: We use multiple threads to lookup DNS + +class QHostInfoRunnable : public QRunnable +{ +public: + explicit QHostInfoRunnable(const QString &hn, int i, const QObject *receiver, + QtPrivate::SlotObjUniquePtr slotObj); + ~QHostInfoRunnable() override; + + void run() override; + + QString toBeLookedUp; + int id; + QHostInfoResult resultEmitter; +}; + + +class QHostInfoLookupManager +{ +public: + QHostInfoLookupManager(); + ~QHostInfoLookupManager(); + + void clear(); + + // called from QHostInfo + void scheduleLookup(QHostInfoRunnable *r); + void abortLookup(int id); + + // called from QHostInfoRunnable + void lookupFinished(QHostInfoRunnable *r); + bool wasAborted(int id); + + QHostInfoCache cache; + + friend class QHostInfoRunnable; +protected: +#if QT_CONFIG(thread) + QList<QHostInfoRunnable*> currentLookups; // in progress + QList<QHostInfoRunnable*> postponedLookups; // postponed because in progress for same host +#endif + QQueue<QHostInfoRunnable*> scheduledLookups; // not yet started + QList<QHostInfoRunnable*> finishedLookups; // recently finished + QList<int> abortedLookups; // ids of aborted lookups + +#if QT_CONFIG(thread) + QThreadPool threadPool; +#endif + QMutex mutex; + + bool wasDeleted; + +private: + void rescheduleWithMutexHeld(); +}; + +QT_END_NAMESPACE + +#endif // QHOSTINFO_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhsts_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhsts_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3d0cec60138ce2d8a6a790e61d40a011aee4d127 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhsts_p.h @@ -0,0 +1,119 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHSTS_P_H +#define QHSTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include <QtNetwork/qhstspolicy.h> + +#include <QtCore/qbytearray.h> +#include <QtCore/qdatetime.h> +#include <QtCore/qstring.h> +#include <QtCore/qglobal.h> +#include <QtCore/qpair.h> +#include <QtCore/qurl.h> +#include <QtCore/qcontainerfwd.h> + +#include <map> + +QT_BEGIN_NAMESPACE + +class QHttpHeaders; + +class Q_AUTOTEST_EXPORT QHstsCache +{ +public: + + void updateFromHeaders(const QHttpHeaders &headers, + const QUrl &url); + void updateFromPolicies(const QList<QHstsPolicy> &hosts); + void updateKnownHost(const QUrl &url, const QDateTime &expires, + bool includeSubDomains); + bool isKnownHost(const QUrl &url) const; + void clear(); + + QList<QHstsPolicy> policies() const; + +#if QT_CONFIG(settings) + void setStore(class QHstsStore *store); +#endif // QT_CONFIG(settings) + +private: + + void updateKnownHost(const QString &hostName, const QDateTime &expires, + bool includeSubDomains); + + struct HostName + { + explicit HostName(const QString &n) : name(n) { } + explicit HostName(QStringView r) : fragment(r) { } + + bool operator < (const HostName &rhs) const + { + if (fragment.size()) { + if (rhs.fragment.size()) + return fragment < rhs.fragment; + return fragment < QStringView{rhs.name}; + } + + if (rhs.fragment.size()) + return QStringView{name} < rhs.fragment; + return name < rhs.name; + } + + // We use 'name' for a HostName object contained in our dictionary; + // we use 'fragment' only during lookup, when chopping the complete host + // name, removing subdomain names (such HostName object is 'transient', it + // must not outlive the original QString object. + QString name; + QStringView fragment; + }; + + mutable std::map<HostName, QHstsPolicy> knownHosts; +#if QT_CONFIG(settings) + QHstsStore *hstsStore = nullptr; +#endif // QT_CONFIG(settings) +}; + +class Q_AUTOTEST_EXPORT QHstsHeaderParser +{ +public: + + bool parse(const QHttpHeaders &headers); + + QDateTime expirationDate() const { return expiry; } + bool includeSubDomains() const { return subDomainsFound; } + +private: + + bool parseSTSHeader(); + bool parseDirective(); + bool processDirective(const QByteArray &name, const QByteArray &value); + bool nextToken(); + + QByteArray header; + QByteArray token; + + QDateTime expiry; + int tokenPos = 0; + bool maxAgeFound = false; + qint64 maxAge = 0; + bool subDomainsFound = false; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhstsstore_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhstsstore_p.h new file mode 100644 index 0000000000000000000000000000000000000000..79cf33f9fa9c3a5af509f8cf8c28d6c50e705467 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhstsstore_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHSTSSTORE_P_H +#define QHSTSSTORE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +QT_REQUIRE_CONFIG(settings); + +#include <QtCore/qlist.h> +#include <QtCore/qsettings.h> + +QT_BEGIN_NAMESPACE + +class QHstsPolicy; +class QByteArray; +class QString; + +class Q_AUTOTEST_EXPORT QHstsStore +{ +public: + explicit QHstsStore(const QString &dirName); + ~QHstsStore(); + + QList<QHstsPolicy> readPolicies(); + void addToObserved(const QHstsPolicy &policy); + void synchronize(); + + bool isWritable() const; + + static QString absoluteFilePath(const QString &dirName); +private: + void beginHstsGroups(); + bool serializePolicy(const QString &key, const QHstsPolicy &policy); + bool deserializePolicy(const QString &key, QHstsPolicy &policy); + void evictPolicy(const QString &key); + void endHstsGroups(); + + QList<QHstsPolicy> observedPolicies; + QSettings store; + + Q_DISABLE_COPY_MOVE(QHstsStore) +}; + +QT_END_NAMESPACE + +#endif // QHSTSSTORE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttp2connection_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttp2connection_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d329a51d110024a697ad79bfcea1424ac3879435 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttp2connection_p.h @@ -0,0 +1,395 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef HTTP2CONNECTION_P_H +#define HTTP2CONNECTION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtnetworkglobal_p.h> + +#include <QtCore/qobject.h> +#include <QtCore/qhash.h> +#include <QtCore/qset.h> +#include <QtCore/qvarlengtharray.h> +#include <QtCore/qxpfunctional.h> +#include <QtNetwork/qhttp2configuration.h> +#include <QtNetwork/qtcpsocket.h> + +#include <private/http2protocol_p.h> +#include <private/http2streams_p.h> +#include <private/http2frames_p.h> +#include <private/hpack_p.h> + +#include <variant> +#include <optional> +#include <type_traits> +#include <limits> + +class tst_QHttp2Connection; + +QT_BEGIN_NAMESPACE + +template <typename T, typename Err> +class QH2Expected +{ + static_assert(!std::is_same_v<T, Err>, "T and Err must be different types"); +public: + // Rule Of Zero applies + QH2Expected(T &&value) : m_data(std::move(value)) { } + QH2Expected(const T &value) : m_data(value) { } + QH2Expected(Err &&error) : m_data(std::move(error)) { } + QH2Expected(const Err &error) : m_data(error) { } + + QH2Expected &operator=(T &&value) + { + m_data = std::move(value); + return *this; + } + QH2Expected &operator=(const T &value) + { + m_data = value; + return *this; + } + QH2Expected &operator=(Err &&error) + { + m_data = std::move(error); + return *this; + } + QH2Expected &operator=(const Err &error) + { + m_data = error; + return *this; + } + T unwrap() const + { + Q_ASSERT(ok()); + return std::get<T>(m_data); + } + Err error() const + { + Q_ASSERT(has_error()); + return std::get<Err>(m_data); + } + bool ok() const noexcept { return std::holds_alternative<T>(m_data); } + bool has_value() const noexcept { return ok(); } + bool has_error() const noexcept { return std::holds_alternative<Err>(m_data); } + void clear() noexcept { m_data.reset(); } + +private: + std::variant<T, Err> m_data; +}; + +class QHttp2Connection; +class Q_NETWORK_EXPORT QHttp2Stream : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY_MOVE(QHttp2Stream) + +public: + enum class State { Idle, ReservedRemote, Open, HalfClosedLocal, HalfClosedRemote, Closed }; + Q_ENUM(State) + constexpr static quint8 DefaultPriority = 127; + + ~QHttp2Stream() noexcept; + + // HTTP2 things + quint32 streamID() const noexcept { return m_streamID; } + + // Are we waiting for a larger send window before sending more data? + bool isUploadBlocked() const noexcept; + bool isUploadingDATA() const noexcept { return m_uploadByteDevice != nullptr; } + State state() const noexcept { return m_state; } + bool isActive() const noexcept { return m_state != State::Closed && m_state != State::Idle; } + bool isPromisedStream() const noexcept { return m_isReserved; } + bool wasReset() const noexcept { return m_RST_STREAM_received.has_value() || + m_RST_STREAM_sent.has_value(); } + bool wasResetbyPeer() const noexcept { return m_RST_STREAM_received.has_value(); } + quint32 RST_STREAMCodeReceived() const noexcept { return m_RST_STREAM_received.value_or(0); } + quint32 RST_STREAMCodeSent() const noexcept { return m_RST_STREAM_sent.value_or(0); } + // Just the list of headers, as received, may contain duplicates: + HPack::HttpHeader receivedHeaders() const noexcept { return m_headers; } + + QByteDataBuffer downloadBuffer() const noexcept { return m_downloadBuffer; } + QByteDataBuffer takeDownloadBuffer() noexcept { return std::exchange(m_downloadBuffer, {}); } + void clearDownloadBuffer() { m_downloadBuffer.clear(); } + +Q_SIGNALS: + void headersReceived(const HPack::HttpHeader &headers, bool endStream); + void headersUpdated(); + void errorOccurred(Http2::Http2Error errorCode, const QString &errorString); + void stateChanged(QHttp2Stream::State newState); + void promisedStreamReceived(quint32 newStreamID); + void uploadBlocked(); + void dataReceived(const QByteArray &data, bool endStream); + void rstFrameRecived(quint32 errorCode); + + void bytesWritten(qint64 bytesWritten); + void uploadDeviceError(const QString &errorString); + void uploadFinished(); + +public Q_SLOTS: + bool sendRST_STREAM(Http2::Http2Error errorCode); + bool sendHEADERS(const HPack::HttpHeader &headers, bool endStream, + quint8 priority = DefaultPriority); + void sendDATA(QIODevice *device, bool endStream); + void sendDATA(QNonContiguousByteDevice *device, bool endStream); + void sendWINDOW_UPDATE(quint32 delta); + +private Q_SLOTS: + void maybeResumeUpload(); + void uploadDeviceReadChannelFinished(); + void uploadDeviceDestroyed(); + +private: + friend class QHttp2Connection; + QHttp2Stream(QHttp2Connection *connection, quint32 streamID) noexcept; + + [[nodiscard]] QHttp2Connection *getConnection() const + { + return qobject_cast<QHttp2Connection *>(parent()); + } + + enum class StateTransition { + Open, + CloseLocal, + CloseRemote, + RST, + }; + + void setState(State newState); + void transitionState(StateTransition transition); + void internalSendDATA(); + void finishSendDATA(); + + void handleDATA(const Http2::Frame &inboundFrame); + void handleHEADERS(Http2::FrameFlags frameFlags, const HPack::HttpHeader &headers); + void handleRST_STREAM(const Http2::Frame &inboundFrame); + void handleWINDOW_UPDATE(const Http2::Frame &inboundFrame); + + void finishWithError(Http2::Http2Error errorCode, const QString &message); + void finishWithError(Http2::Http2Error errorCode); + + void streamError(Http2::Http2Error errorCode, + QLatin1StringView message); + + // Keep it const since it never changes after creation + const quint32 m_streamID = 0; + qint32 m_recvWindow = 0; + qint32 m_sendWindow = 0; + bool m_endStreamAfterDATA = false; + std::optional<quint32> m_RST_STREAM_received; + std::optional<quint32> m_RST_STREAM_sent; + + QIODevice *m_uploadDevice = nullptr; + QNonContiguousByteDevice *m_uploadByteDevice = nullptr; + + QByteDataBuffer m_downloadBuffer; + State m_state = State::Idle; + HPack::HttpHeader m_headers; + bool m_isReserved = false; + bool m_owningByteDevice = false; + + friend tst_QHttp2Connection; +}; + +class Q_NETWORK_EXPORT QHttp2Connection : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY_MOVE(QHttp2Connection) + +public: + enum class CreateStreamError { + MaxConcurrentStreamsReached, + StreamIdsExhausted, + ReceivedGOAWAY, + UnknownError, + }; + Q_ENUM(CreateStreamError) + + enum class PingState { + Ping, + PongSignatureIdentical, + PongSignatureChanged, + PongNoPingSent, // We got an ACKed ping but had not sent any + }; + + // For a pre-established connection: + [[nodiscard]] static QHttp2Connection * + createUpgradedConnection(QIODevice *socket, const QHttp2Configuration &config); + // For a new connection, potential TLS handshake must already be finished: + [[nodiscard]] static QHttp2Connection *createDirectConnection(QIODevice *socket, + const QHttp2Configuration &config); + [[nodiscard]] static QHttp2Connection * + createDirectServerConnection(QIODevice *socket, const QHttp2Configuration &config); + ~QHttp2Connection(); + + [[nodiscard]] QH2Expected<QHttp2Stream *, CreateStreamError> createStream(); + + QHttp2Stream *getStream(quint32 streamId) const; + QHttp2Stream *promisedStream(const QUrl &streamKey) const + { + if (quint32 id = m_promisedStreams.value(streamKey, 0); id) + return m_streams.value(id); + return nullptr; + } + + void close() { sendGOAWAY(Http2::HTTP2_NO_ERROR); } + + bool isGoingAway() const noexcept { return m_goingAway; } + + quint32 maxConcurrentStreams() const noexcept { return m_maxConcurrentStreams; } + quint32 maxHeaderListSize() const noexcept { return m_maxHeaderListSize; } + + bool isUpgradedConnection() const noexcept { return m_upgradedConnection; } + +Q_SIGNALS: + void newIncomingStream(QHttp2Stream *stream); + void newPromisedStream(QHttp2Stream *stream); + void errorReceived(/*@future: add as needed?*/); // Connection errors only, no stream-specific errors + void connectionClosed(); + void settingsFrameReceived(); + void pingFrameRecived(QHttp2Connection::PingState state); + void errorOccurred(Http2::Http2Error errorCode, const QString &errorString); + void receivedGOAWAY(Http2::Http2Error errorCode, quint32 lastStreamID); + void receivedEND_STREAM(quint32 streamID); +public Q_SLOTS: + bool sendPing(); + bool sendPing(QByteArrayView data); + void handleReadyRead(); + void handleConnectionClosure(); + +private: + friend class QHttp2Stream; + [[nodiscard]] QIODevice *getSocket() const { return qobject_cast<QIODevice *>(parent()); } + + QH2Expected<QHttp2Stream *, QHttp2Connection::CreateStreamError> createStreamInternal(); + QHttp2Stream *createStreamInternal_impl(quint32 streamID); + + bool isInvalidStream(quint32 streamID) noexcept; + bool streamWasResetLocally(quint32 streamID) noexcept; + + void connectionError(Http2::Http2Error errorCode, + const char *message); // Connection failed to be established? + void setH2Configuration(QHttp2Configuration config); + void closeSession(); + void registerStreamAsResetLocally(quint32 streamID); + qsizetype numActiveStreamsImpl(quint32 mask) const noexcept; + qsizetype numActiveRemoteStreams() const noexcept; + qsizetype numActiveLocalStreams() const noexcept; + + bool sendClientPreface(); + bool sendSETTINGS(); + bool sendServerPreface(); + bool serverCheckClientPreface(); + bool sendWINDOW_UPDATE(quint32 streamID, quint32 delta); + bool sendGOAWAY(Http2::Http2Error errorCode); + bool sendSETTINGS_ACK(); + + void handleDATA(); + void handleHEADERS(); + void handlePRIORITY(); + void handleRST_STREAM(); + void handleSETTINGS(); + void handlePUSH_PROMISE(); + void handlePING(); + void handleGOAWAY(); + void handleWINDOW_UPDATE(); + void handleCONTINUATION(); + + void handleContinuedHEADERS(); + + bool acceptSetting(Http2::Settings identifier, quint32 newValue); + + bool readClientPreface(); + + explicit QHttp2Connection(QIODevice *socket); + + enum class Type { Client, Server } m_connectionType = Type::Client; + + bool waitingForSettingsACK = false; + + static constexpr quint32 maxAcceptableTableSize = 16 * HPack::FieldLookupTable::DefaultSize; + // HTTP/2 4.3: Header compression is stateful. One compression context and + // one decompression context are used for the entire connection. + HPack::Decoder decoder = HPack::Decoder(HPack::FieldLookupTable::DefaultSize); + HPack::Encoder encoder = HPack::Encoder(HPack::FieldLookupTable::DefaultSize, true); + + QHttp2Configuration m_config; + QHash<quint32, QPointer<QHttp2Stream>> m_streams; + QSet<quint32> m_blockedStreams; + QHash<QUrl, quint32> m_promisedStreams; + QList<quint32> m_resetStreamIDs; + + std::optional<QByteArray> m_lastPingSignature = std::nullopt; + quint32 m_nextStreamID = 1; + + // Peer's max frame size (this min is the default value + // we start with, that can be updated by SETTINGS frame): + quint32 maxFrameSize = Http2::minPayloadLimit; + + Http2::FrameReader frameReader; + Http2::Frame inboundFrame; + Http2::FrameWriter frameWriter; + + // Temporary storage to assemble HEADERS' block + // from several CONTINUATION frames ... + bool continuationExpected = false; + std::vector<Http2::Frame> continuedFrames; + + // Control flow: + + // This is how many concurrent streams our peer allows us, 100 is the + // initial value, can be updated by the server's SETTINGS frame(s): + quint32 m_maxConcurrentStreams = Http2::maxConcurrentStreams; + // While we allow sending SETTTINGS_MAX_CONCURRENT_STREAMS to limit our peer, + // it's just a hint and we do not actually enforce it (and we can continue + // sending requests and creating streams while maxConcurrentStreams allows). + + // This is our (client-side) maximum possible receive window size, we set + // it in a ctor from QHttp2Configuration, it does not change after that. + // The default is 64Kb: + qint32 maxSessionReceiveWindowSize = Http2::defaultSessionWindowSize; + + // Our session current receive window size, updated in a ctor from + // QHttp2Configuration. Signed integer since it can become negative + // (it's still a valid window size). + qint32 sessionReceiveWindowSize = Http2::defaultSessionWindowSize; + // Our per-stream receive window size, default is 64 Kb, will be updated + // from QHttp2Configuration. Again, signed - can become negative. + qint32 streamInitialReceiveWindowSize = Http2::defaultSessionWindowSize; + + // These are our peer's receive window sizes, they will be updated by the + // peer's SETTINGS and WINDOW_UPDATE frames, defaults presumed to be 64Kb. + qint32 sessionSendWindowSize = Http2::defaultSessionWindowSize; + qint32 streamInitialSendWindowSize = Http2::defaultSessionWindowSize; + + // Our peer's header size limitations. It's unlimited by default, but can + // be changed via peer's SETTINGS frame. + quint32 m_maxHeaderListSize = (std::numeric_limits<quint32>::max)(); + // While we can send SETTINGS_MAX_HEADER_LIST_SIZE value (our limit on + // the headers size), we never enforce it, it's just a hint to our peer. + + bool m_upgradedConnection = false; + bool m_goingAway = false; + bool pushPromiseEnabled = false; + quint32 m_lastIncomingStreamID = Http2::connectionStreamID; + + // Server-side only: + bool m_waitingForClientPreface = false; + + friend tst_QHttp2Connection; +}; + +QT_END_NAMESPACE + +#endif // HTTP2CONNECTION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttp2protocolhandler_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttp2protocolhandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2c4e33bdcea79171461a6d7edf99b5f8bc37bc54 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttp2protocolhandler_p.h @@ -0,0 +1,204 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTP2PROTOCOLHANDLER_P_H +#define QHTTP2PROTOCOLHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qhttpnetworkconnectionchannel_p.h> +#include <private/qabstractprotocolhandler_p.h> +#include <private/qhttpnetworkrequest_p.h> + +#include <access/qhttp2configuration.h> + +#include <private/http2protocol_p.h> +#include <private/http2streams_p.h> +#include <private/http2frames_p.h> +#include <private/hpacktable_p.h> +#include <private/hpack_p.h> + +#include <QtCore/qnamespace.h> +#include <QtCore/qbytearray.h> +#include <QtCore/qglobal.h> +#include <QtCore/qobject.h> +#include <QtCore/qflags.h> +#include <QtCore/qhash.h> + +#include <vector> +#include <limits> +#include <deque> +#include <set> + +QT_REQUIRE_CONFIG(http); + +QT_BEGIN_NAMESPACE + +class QHttp2ProtocolHandler : public QObject, public QAbstractProtocolHandler +{ + Q_OBJECT + +public: + QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *channel); + + QHttp2ProtocolHandler(const QHttp2ProtocolHandler &rhs) = delete; + QHttp2ProtocolHandler(QHttp2ProtocolHandler &&rhs) = delete; + + QHttp2ProtocolHandler &operator = (const QHttp2ProtocolHandler &rhs) = delete; + QHttp2ProtocolHandler &operator = (QHttp2ProtocolHandler &&rhs) = delete; + + Q_INVOKABLE void handleConnectionClosure(); + Q_INVOKABLE void ensureClientPrefaceSent(); + +private slots: + void _q_uploadDataReadyRead(); + void _q_replyDestroyed(QObject* reply); + void _q_uploadDataDestroyed(QObject* uploadData); + +private: + using Stream = Http2::Stream; + + void _q_readyRead() override; + Q_INVOKABLE void _q_receiveReply() override; + Q_INVOKABLE bool sendRequest() override; + + bool sendClientPreface(); + bool sendSETTINGS_ACK(); + bool sendHEADERS(Stream &stream); + bool sendDATA(Stream &stream); + Q_INVOKABLE bool sendWINDOW_UPDATE(quint32 streamID, quint32 delta); + bool sendRST_STREAM(quint32 streamID, quint32 errorCoder); + bool sendGOAWAY(quint32 errorCode); + + void handleDATA(); + void handleHEADERS(); + void handlePRIORITY(); + void handleRST_STREAM(); + void handleSETTINGS(); + void handlePUSH_PROMISE(); + void handlePING(); + void handleGOAWAY(); + void handleWINDOW_UPDATE(); + void handleCONTINUATION(); + + void handleContinuedHEADERS(); + + bool acceptSetting(Http2::Settings identifier, quint32 newValue); + + void handleAuthorization(Stream &stream); + void updateStream(Stream &stream, const HPack::HttpHeader &headers, + Qt::ConnectionType connectionType = Qt::DirectConnection); + void updateStream(Stream &stream, const Http2::Frame &dataFrame, + Qt::ConnectionType connectionType = Qt::DirectConnection); + void finishStream(Stream &stream, Qt::ConnectionType connectionType = Qt::DirectConnection); + // Error code send by a peer (GOAWAY/RST_STREAM): + void finishStreamWithError(Stream &stream, quint32 errorCode); + // Locally encountered error: + void finishStreamWithError(Stream &stream, QNetworkReply::NetworkError error, + const QString &message); + + // Stream's lifecycle management: + quint32 createNewStream(const HttpMessagePair &message, bool uploadDone = false); + void addToSuspended(Stream &stream); + void markAsReset(quint32 streamID); + quint32 popStreamToResume(); + void removeFromSuspended(quint32 streamID); + void deleteActiveStream(quint32 streamID); + bool streamWasReset(quint32 streamID) const; + + bool prefaceSent = false; + // In the current implementation we send + // SETTINGS only once, immediately after + // the client's preface 24-byte message. + bool waitingForSettingsACK = false; + + inline static const quint32 maxAcceptableTableSize = 16 * HPack::FieldLookupTable::DefaultSize; + // HTTP/2 4.3: Header compression is stateful. One compression context and + // one decompression context are used for the entire connection. + HPack::Decoder decoder; + HPack::Encoder encoder; + + QHash<QObject *, int> streamIDs; + QHash<quint32, Stream> activeStreams; + std::deque<quint32> suspendedStreams[3]; // 3 for priorities: High, Normal, Low. + inline static const std::deque<quint32>::size_type maxRecycledStreams = 10000; + std::deque<quint32> recycledStreams; + + // Peer's max frame size (this min is the default value + // we start with, that can be updated by SETTINGS frame): + quint32 maxFrameSize = Http2::minPayloadLimit; + + Http2::FrameReader frameReader; + Http2::Frame inboundFrame; + Http2::FrameWriter frameWriter; + // Temporary storage to assemble HEADERS' block + // from several CONTINUATION frames ... + bool continuationExpected = false; + std::vector<Http2::Frame> continuedFrames; + + // Control flow: + + // This is how many concurrent streams our peer allows us, 100 is the + // initial value, can be updated by the server's SETTINGS frame(s): + quint32 maxConcurrentStreams = Http2::maxConcurrentStreams; + // While we allow sending SETTTINGS_MAX_CONCURRENT_STREAMS to limit our peer, + // it's just a hint and we do not actually enforce it (and we can continue + // sending requests and creating streams while maxConcurrentStreams allows). + + // This is our (client-side) maximum possible receive window size, we set + // it in a ctor from QHttp2Configuration, it does not change after that. + // The default is 64Kb: + qint32 maxSessionReceiveWindowSize = Http2::defaultSessionWindowSize; + + // Our session current receive window size, updated in a ctor from + // QHttp2Configuration. Signed integer since it can become negative + // (it's still a valid window size). + qint32 sessionReceiveWindowSize = Http2::defaultSessionWindowSize; + // Our per-stream receive window size, default is 64 Kb, will be updated + // from QHttp2Configuration. Again, signed - can become negative. + qint32 streamInitialReceiveWindowSize = Http2::defaultSessionWindowSize; + + // These are our peer's receive window sizes, they will be updated by the + // peer's SETTINGS and WINDOW_UPDATE frames, defaults presumed to be 64Kb. + qint32 sessionSendWindowSize = Http2::defaultSessionWindowSize; + qint32 streamInitialSendWindowSize = Http2::defaultSessionWindowSize; + + // Our peer's header size limitations. It's unlimited by default, but can + // be changed via peer's SETTINGS frame. + quint32 maxHeaderListSize = (std::numeric_limits<quint32>::max)(); + // While we can send SETTINGS_MAX_HEADER_LIST_SIZE value (our limit on + // the headers size), we never enforce it, it's just a hint to our peer. + + Q_INVOKABLE void resumeSuspendedStreams(); + // Our stream IDs (all odd), the first valid will be 1. + quint32 nextID = 1; + quint32 allocateStreamID(); + bool validPeerStreamID() const; + bool goingAway = false; + bool pushPromiseEnabled = false; + quint32 lastPromisedID = Http2::connectionStreamID; + QHash<QString, Http2::PushPromise> promisedData; + bool tryReserveStream(const Http2::Frame &pushPromiseFrame, + const HPack::HttpHeader &requestHeader); + void resetPromisedStream(const Http2::Frame &pushPromiseFrame, + Http2::Http2Error reason); + void initReplyFromPushPromise(const HttpMessagePair &message, + const QString &cacheKey); + // Errors: + void connectionError(Http2::Http2Error errorCode, + const char *message); + void closeSession(); +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpheaderparser_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpheaderparser_p.h new file mode 100644 index 0000000000000000000000000000000000000000..13b56e4e8aec89775be20f72382809e645aebb29 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpheaderparser_p.h @@ -0,0 +1,102 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPHEADERPARSER_H +#define QHTTPHEADERPARSER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtNetwork/qhttpheaders.h> + +#include <QByteArray> +#include <QList> +#include <QPair> +#include <QString> + +QT_BEGIN_NAMESPACE + +namespace HeaderConstants { + +// We previously used 8K, which is common on server side, but it turned out to +// not be enough for various uses. Historically Firefox used 10K as the limit of +// a single field, but some Location headers and Authorization challenges can +// get even longer. Other browsers, such as Chrome, instead have a limit on the +// total size of all the headers (as well as extra limits on some of the +// individual fields). We'll use 100K as our default limit, which would be a ridiculously large +// header, with the possibility to override it where we need to. +static constexpr int MAX_HEADER_FIELD_SIZE = 100 * 1024; +// Taken from http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfields +static constexpr int MAX_HEADER_FIELDS = 100; +// Chromium has a limit on the total size of the header set to 256KB, +// which is a reasonable default for QNetworkAccessManager. +// https://stackoverflow.com/a/3436155 +static constexpr int MAX_TOTAL_HEADER_SIZE = 256 * 1024; + +} + +class Q_NETWORK_EXPORT QHttpHeaderParser +{ +public: + QHttpHeaderParser(); + + void clear(); + bool parseHeaders(QByteArrayView headers); + bool parseStatus(QByteArrayView status); + + const QHttpHeaders& headers() const &; + QHttpHeaders headers() &&; + void setStatusCode(int code); + int getStatusCode() const; + int getMajorVersion() const; + void setMajorVersion(int version); + int getMinorVersion() const; + void setMinorVersion(int version); + QString getReasonPhrase() const; + void setReasonPhrase(const QString &reason); + + QByteArray firstHeaderField(QByteArrayView name, + const QByteArray &defaultValue = QByteArray()) const; + QByteArray combinedHeaderValue(QByteArrayView name, + const QByteArray &defaultValue = QByteArray()) const; + QList<QByteArray> headerFieldValues(QByteArrayView name) const; + void setHeaderField(const QByteArray &name, const QByteArray &data); + void prependHeaderField(const QByteArray &name, const QByteArray &data); + void appendHeaderField(const QByteArray &name, const QByteArray &data); + void removeHeaderField(QByteArrayView name); + void clearHeaders(); + + void setMaxHeaderFieldSize(qsizetype size) { maxFieldSize = size; } + qsizetype maxHeaderFieldSize() const { return maxFieldSize; } + + void setMaxTotalHeaderSize(qsizetype size) { maxTotalSize = size; } + qsizetype maxTotalHeaderSize() const { return maxTotalSize; } + + void setMaxHeaderFields(qsizetype count) { maxFieldCount = count; } + qsizetype maxHeaderFields() const { return maxFieldCount; } + +private: + QHttpHeaders fields; + QString reasonPhrase; + int statusCode; + int majorVersion; + int minorVersion; + + qsizetype maxFieldSize = HeaderConstants::MAX_HEADER_FIELD_SIZE; + qsizetype maxTotalSize = HeaderConstants::MAX_TOTAL_HEADER_SIZE; + qsizetype maxFieldCount = HeaderConstants::MAX_HEADER_FIELDS; +}; + + +QT_END_NAMESPACE + +#endif // QHTTPHEADERPARSER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpheadershelper_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpheadershelper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..67fa34c4d426198b19e4cc6a0954158573894806 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpheadershelper_p.h @@ -0,0 +1,30 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPHEADERSHELPER_H +#define QHTTPHEADERSHELPER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QHttpHeaders; + +namespace QHttpHeadersHelper { + Q_NETWORK_EXPORT bool compareStrict(const QHttpHeaders &left, const QHttpHeaders &right); +}; + +QT_END_NAMESPACE + +#endif // QHTTPHEADERSHELPER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpmultipart_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpmultipart_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3c15414aab844a9d3f44150efcf1826210627d21 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpmultipart_p.h @@ -0,0 +1,157 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPMULTIPART_P_H +#define QHTTPMULTIPART_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtNetwork/qhttpmultipart.h> + +#include "QtCore/qshareddata.h" +#include "qnetworkrequest_p.h" // for deriving QHttpPartPrivate from QNetworkHeadersPrivate +#include "qhttpheadershelper_p.h" + +#include "private/qobject_p.h" +#include <QtCore/qiodevice.h> + +#ifndef Q_OS_WASM +QT_REQUIRE_CONFIG(http); +#endif + +QT_BEGIN_NAMESPACE + + +class QHttpPartPrivate: public QSharedData, public QNetworkHeadersPrivate +{ +public: + inline QHttpPartPrivate() : bodyDevice(nullptr), headerCreated(false), readPointer(0) + { + } + ~QHttpPartPrivate() + { + } + + + QHttpPartPrivate(const QHttpPartPrivate &other) + : QSharedData(other), QNetworkHeadersPrivate(other), body(other.body), + header(other.header), headerCreated(other.headerCreated), readPointer(other.readPointer) + { + bodyDevice = other.bodyDevice; + } + + inline bool operator==(const QHttpPartPrivate &other) const + { + return QHttpHeadersHelper::compareStrict(httpHeaders, other.httpHeaders) + && body == other.body + && bodyDevice == other.bodyDevice + && readPointer == other.readPointer; + } + + void setBodyDevice(QIODevice *device) { + bodyDevice = device; + readPointer = 0; + } + void setBody(const QByteArray &newBody) { + body = newBody; + readPointer = 0; + } + + // QIODevice-style methods called by QHttpMultiPartIODevice (but this class is + // not a QIODevice): + qint64 bytesAvailable() const; + qint64 readData(char *data, qint64 maxSize); + qint64 size() const; + bool reset(); + + QByteArray body; + QIODevice *bodyDevice; + +private: + void checkHeaderCreated() const; + + mutable QByteArray header; + mutable bool headerCreated; + qint64 readPointer; +}; + + + +class QHttpMultiPartPrivate; + +class Q_AUTOTEST_EXPORT QHttpMultiPartIODevice : public QIODevice +{ +public: + QHttpMultiPartIODevice(QHttpMultiPartPrivate *parentMultiPart) : + QIODevice(), multiPart(parentMultiPart), readPointer(0), deviceSize(-1) { + } + + ~QHttpMultiPartIODevice() override; + + virtual bool atEnd() const override { + return readPointer == size(); + } + + virtual qint64 bytesAvailable() const override { + return size() - readPointer; + } + + virtual void close() override { + readPointer = 0; + partOffsets.clear(); + deviceSize = -1; + QIODevice::close(); + } + + virtual qint64 bytesToWrite() const override { + return 0; + } + + virtual qint64 size() const override; + virtual bool isSequential() const override; + virtual bool reset() override; + virtual qint64 readData(char *data, qint64 maxSize) override; + virtual qint64 writeData(const char *data, qint64 maxSize) override; + + QHttpMultiPartPrivate *multiPart; + qint64 readPointer; + mutable QList<qint64> partOffsets; + mutable qint64 deviceSize; +}; + + + +class Q_AUTOTEST_EXPORT QHttpMultiPartPrivate: public QObjectPrivate +{ +public: + + QHttpMultiPartPrivate(); + ~QHttpMultiPartPrivate() override; + + static QHttpMultiPartPrivate *get(QHttpMultiPart *message) { return message->d_func(); } + static const QHttpMultiPartPrivate *get(const QHttpMultiPart *message) + { + return message->d_func(); + } + + QList<QHttpPart> parts; + QByteArray boundary; + QHttpMultiPart::ContentType contentType; + QHttpMultiPartIODevice *device; + +}; + +QT_END_NAMESPACE + + +#endif // QHTTPMULTIPART_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkconnection_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkconnection_p.h new file mode 100644 index 0000000000000000000000000000000000000000..095aa2380b7ae13ce14fa3ec77e2b2c04756b574 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkconnection_p.h @@ -0,0 +1,271 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPNETWORKCONNECTION_H +#define QHTTPNETWORKCONNECTION_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtNetwork/qnetworkrequest.h> +#include <QtNetwork/qnetworkreply.h> +#include <QtNetwork/qabstractsocket.h> + +#include <qhttp2configuration.h> + +#include <private/qobject_p.h> +#include <qauthenticator.h> +#include <qnetworkproxy.h> +#include <qbuffer.h> +#include <qtimer.h> +#include <qsharedpointer.h> + +#include <private/qhttpnetworkheader_p.h> +#include <private/qhttpnetworkrequest_p.h> +#include <private/qhttpnetworkreply_p.h> +#include <private/qnetconmonitor_p.h> +#include <private/http2protocol_p.h> + +#include <private/qhttpnetworkconnectionchannel_p.h> + +QT_REQUIRE_CONFIG(http); + +QT_BEGIN_NAMESPACE + +class QHttpNetworkRequest; +class QHttpNetworkReply; +class QHttpThreadDelegate; +class QByteArray; +class QHostInfo; +#ifndef QT_NO_SSL +class QSslConfiguration; +class QSslContext; +#endif // !QT_NO_SSL + +class QHttpNetworkConnectionPrivate; +class Q_NETWORK_EXPORT QHttpNetworkConnection : public QObject +{ + Q_OBJECT +public: + + enum ConnectionType { + ConnectionTypeHTTP, + ConnectionTypeHTTP2, + ConnectionTypeHTTP2Direct + }; + + QHttpNetworkConnection(quint16 channelCount, const QString &hostName, quint16 port = 80, + bool encrypt = false, bool isLocalSocket = false, + QObject *parent = nullptr, + ConnectionType connectionType = ConnectionTypeHTTP); + ~QHttpNetworkConnection(); + + //The hostname to which this is connected to. + QString hostName() const; + //The HTTP port in use. + quint16 port() const; + + //add a new HTTP request through this connection + QHttpNetworkReply* sendRequest(const QHttpNetworkRequest &request); + void fillHttp2Queue(); + +#ifndef QT_NO_NETWORKPROXY + //set the proxy for this connection + void setCacheProxy(const QNetworkProxy &networkProxy); + QNetworkProxy cacheProxy() const; + void setTransparentProxy(const QNetworkProxy &networkProxy); + QNetworkProxy transparentProxy() const; +#endif + + bool isSsl() const; + + QHttpNetworkConnectionChannel *channels() const; + + ConnectionType connectionType() const; + void setConnectionType(ConnectionType type); + + QHttp2Configuration http2Parameters() const; + void setHttp2Parameters(const QHttp2Configuration ¶ms); + +#ifndef QT_NO_SSL + void setSslConfiguration(const QSslConfiguration &config); + void ignoreSslErrors(int channel = -1); + void ignoreSslErrors(const QList<QSslError> &errors, int channel = -1); + std::shared_ptr<QSslContext> sslContext() const; + void setSslContext(std::shared_ptr<QSslContext> context); +#endif + + void preConnectFinished(); + + QString peerVerifyName() const; + void setPeerVerifyName(const QString &peerName); + +public slots: + void onlineStateChanged(bool isOnline); + +private: + Q_DECLARE_PRIVATE(QHttpNetworkConnection) + Q_DISABLE_COPY_MOVE(QHttpNetworkConnection) + friend class QHttpThreadDelegate; + friend class QHttpNetworkReply; + friend class QHttpNetworkReplyPrivate; + friend class QHttpNetworkConnectionChannel; + friend class QHttp2ProtocolHandler; + friend class QHttpProtocolHandler; + + Q_PRIVATE_SLOT(d_func(), void _q_startNextRequest()) + Q_PRIVATE_SLOT(d_func(), void _q_hostLookupFinished(QHostInfo)) + Q_PRIVATE_SLOT(d_func(), void _q_connectDelayedChannel()) +}; + + +// private classes +typedef QPair<QHttpNetworkRequest, QHttpNetworkReply*> HttpMessagePair; + + +class QHttpNetworkConnectionPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QHttpNetworkConnection) + Q_DISABLE_COPY_MOVE(QHttpNetworkConnectionPrivate) +public: + // Note: Only used from auto tests, normal usage is via QHttp1Configuration + static constexpr int defaultHttpChannelCount = 6; + static const int defaultPipelineLength; + static const int defaultRePipelineLength; + + enum ConnectionState { + RunningState = 0, + PausedState = 1 + }; + + enum NetworkLayerPreferenceState { + Unknown, + HostLookupPending, + IPv4, + IPv6, + IPv4or6 + }; + + QHttpNetworkConnectionPrivate(quint16 connectionCount, const QString &hostName, quint16 port, + bool encrypt, bool isLocalSocket, + QHttpNetworkConnection::ConnectionType type); + ~QHttpNetworkConnectionPrivate(); + void init(); + + void pauseConnection(); + void resumeConnection(); + ConnectionState state = RunningState; + NetworkLayerPreferenceState networkLayerState = Unknown; + + enum { ChunkSize = 4096 }; + + int indexOf(QIODevice *socket) const; + + QHttpNetworkReply *queueRequest(const QHttpNetworkRequest &request); + void requeueRequest(const HttpMessagePair &pair); // e.g. after pipeline broke + void fillHttp2Queue(); + bool dequeueRequest(QIODevice *socket); + void prepareRequest(HttpMessagePair &request); + void updateChannel(int i, const HttpMessagePair &messagePair); + QHttpNetworkRequest predictNextRequest() const; + QHttpNetworkReply* predictNextRequestsReply() const; + + void fillPipeline(QIODevice *socket); + bool fillPipeline(QList<HttpMessagePair> &queue, QHttpNetworkConnectionChannel &channel); + + // read more HTTP body after the next event loop spin + void readMoreLater(QHttpNetworkReply *reply); + + void copyCredentials(int fromChannel, QAuthenticator *auth, bool isProxy); + + void startHostInfoLookup(); + void startNetworkLayerStateLookup(); + void networkLayerDetected(QAbstractSocket::NetworkLayerProtocol protocol); + + // private slots + void _q_startNextRequest(); // send the next request from the queue + + void _q_hostLookupFinished(const QHostInfo &info); + void _q_connectDelayedChannel(); + + void createAuthorization(QIODevice *socket, QHttpNetworkRequest &request); + + QString errorDetail(QNetworkReply::NetworkError errorCode, QIODevice *socket, + const QString &extraDetail = QString()); + + void removeReply(QHttpNetworkReply *reply); + + QString hostName; + quint16 port; + bool encrypt; + bool isLocalSocket; + bool delayIpv4 = true; + + // Number of channels we are trying to use at the moment: + int activeChannelCount; + // The total number of channels we reserved: + const int channelCount; + QTimer delayedConnectionTimer; + QHttpNetworkConnectionChannel * const channels; // parallel connections to the server + bool shouldEmitChannelError(QIODevice *socket); + + qint64 uncompressedBytesAvailable(const QHttpNetworkReply &reply) const; + qint64 uncompressedBytesAvailableNextBlock(const QHttpNetworkReply &reply) const; + + + void emitReplyError(QIODevice *socket, QHttpNetworkReply *reply, QNetworkReply::NetworkError errorCode); + bool handleAuthenticateChallenge(QIODevice *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend); + struct ParseRedirectResult { + QUrl redirectUrl; + QNetworkReply::NetworkError errorCode; + }; + static ParseRedirectResult parseRedirectResponse(QHttpNetworkReply *reply); + // Used by the HTTP1 code-path + QUrl parseRedirectResponse(QIODevice *socket, QHttpNetworkReply *reply); + +#ifndef QT_NO_NETWORKPROXY + QNetworkProxy networkProxy; + void emitProxyAuthenticationRequired(const QHttpNetworkConnectionChannel *chan, const QNetworkProxy &proxy, QAuthenticator* auth); +#endif + + //The request queues + QList<HttpMessagePair> highPriorityQueue; + QList<HttpMessagePair> lowPriorityQueue; + + int preConnectRequests = 0; + + QHttpNetworkConnection::ConnectionType connectionType; + +#ifndef QT_NO_SSL + std::shared_ptr<QSslContext> sslContext; +#endif + + QHttp2Configuration http2Parameters; + + QString peerVerifyName; + // If network status monitoring is enabled, we activate connectionMonitor + // as soons as one of channels managed to connect to host (and we + // have a pair of addresses (us,peer). + // NETMONTODO: consider activating a monitor on a change from + // HostLookUp state to ConnectingState (means we have both + // local/remote addresses known and can start monitoring this + // early). + QNetworkConnectionMonitor connectionMonitor; + + friend class QHttpNetworkConnectionChannel; +}; + + + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkconnectionchannel_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkconnectionchannel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d1e800f1fa1bbd9f082334b3b69d9884b2e5d78e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkconnectionchannel_p.h @@ -0,0 +1,193 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPNETWORKCONNECTIONCHANNEL_H +#define QHTTPNETWORKCONNECTIONCHANNEL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtNetwork/qnetworkrequest.h> +#include <QtNetwork/qnetworkreply.h> +#include <QtNetwork/qabstractsocket.h> + +#include <private/qobject_p.h> +#include <qauthenticator.h> +#include <qnetworkproxy.h> +#include <qbuffer.h> + +#include <private/qhttpnetworkheader_p.h> +#include <private/qhttpnetworkrequest_p.h> +#include <private/qhttpnetworkreply_p.h> + +#include <private/qhttpnetworkconnection_p.h> +#include <private/qabstractprotocolhandler_p.h> + +#ifndef QT_NO_SSL +# include <QtNetwork/qsslsocket.h> +# include <QtNetwork/qsslerror.h> +# include <QtNetwork/qsslconfiguration.h> +#else +# include <QtNetwork/qtcpsocket.h> +#endif +#if QT_CONFIG(localserver) +# include <QtNetwork/qlocalsocket.h> +#endif + + +#include <QtCore/qpointer.h> +#include <QtCore/qscopedpointer.h> + +#include <memory> + +QT_REQUIRE_CONFIG(http); + +QT_BEGIN_NAMESPACE + +class QHttpNetworkRequest; +class QHttpNetworkReply; +class QByteArray; + +#ifndef HttpMessagePair +typedef QPair<QHttpNetworkRequest, QHttpNetworkReply*> HttpMessagePair; +#endif + +class QHttpNetworkConnectionChannel : public QObject { + Q_OBJECT +public: + // TODO: Refactor this to add an EncryptingState (and remove pendingEncrypt). + // Also add an Unconnected state so IdleState does not have double meaning. + enum ChannelState { + IdleState = 0, // ready to send request + ConnectingState = 1, // connecting to host + WritingState = 2, // writing the data + WaitingState = 4, // waiting for reply + ReadingState = 8, // reading the reply + ClosingState = 16, + BusyState = (ConnectingState|WritingState|WaitingState|ReadingState|ClosingState) + }; + QIODevice *socket; + bool ssl; + bool isInitialized; + bool waitingForPotentialAbort = false; + bool needInvokeReceiveReply = false; + bool needInvokeReadyRead = false; + bool needInvokeSendRequest = false; + ChannelState state; + QHttpNetworkRequest request; // current request, only used for HTTP + QHttpNetworkReply *reply; // current reply for this request, only used for HTTP + qint64 written; + qint64 bytesTotal; + bool resendCurrent; + int lastStatus; // last status received on this channel + bool pendingEncrypt; // for https (send after encrypted) + int reconnectAttempts; // maximum 2 reconnection attempts + QAuthenticator authenticator; + QAuthenticator proxyAuthenticator; + bool authenticationCredentialsSent; + bool proxyCredentialsSent; + std::unique_ptr<QAbstractProtocolHandler> protocolHandler; + QMultiMap<int, HttpMessagePair> h2RequestsToSend; + bool switchedToHttp2 = false; +#ifndef QT_NO_SSL + bool ignoreAllSslErrors; + QList<QSslError> ignoreSslErrorsList; + QScopedPointer<QSslConfiguration> sslConfiguration; + void ignoreSslErrors(); + void ignoreSslErrors(const QList<QSslError> &errors); + void setSslConfiguration(const QSslConfiguration &config); + void requeueHttp2Requests(); // when we wanted HTTP/2 but got HTTP/1.1 +#endif + // to emit the signal for all in-flight replies: + void emitFinishedWithError(QNetworkReply::NetworkError error, const char *message); + + // HTTP pipelining -> http://en.wikipedia.org/wiki/Http_pipelining + enum PipeliningSupport { + PipeliningSupportUnknown, // default for a new connection + PipeliningProbablySupported, // after having received a server response that indicates support + PipeliningNotSupported // currently not used + }; + PipeliningSupport pipeliningSupported; + QList<HttpMessagePair> alreadyPipelinedRequests; + QByteArray pipeline; // temporary buffer that gets sent to socket in pipelineFlush + void pipelineInto(HttpMessagePair &pair); + void pipelineFlush(); + void requeueCurrentlyPipelinedRequests(); + void detectPipeliningSupport(); + + QHttpNetworkConnectionChannel(); + + QAbstractSocket::NetworkLayerProtocol networkLayerPreference; + + void setConnection(QHttpNetworkConnection *c); + QPointer<QHttpNetworkConnection> connection; + +#ifndef QT_NO_NETWORKPROXY + QNetworkProxy proxy; + void setProxy(const QNetworkProxy &networkProxy); +#endif + + void init(); + void close(); + void abort(); + + bool sendRequest(); + void sendRequestDelayed(); + + bool ensureConnection(); + + void allDone(); // reply header + body have been read + void handleStatus(); // called from allDone() + + bool resetUploadData(); // return true if resetting worked or there is no upload data + + void handleUnexpectedEOF(); + void closeAndResendCurrentRequest(); + void resendCurrentRequest(); + + void checkAndResumeCommunication(); + + bool isSocketBusy() const; + bool isSocketWriting() const; + bool isSocketWaiting() const; + bool isSocketReading() const; + + protected slots: + void _q_receiveReply(); + void _q_bytesWritten(qint64 bytes); // proceed sending + void _q_readyRead(); // pending data to read + void _q_disconnected(); // disconnected from host + void _q_connected_abstract_socket(QAbstractSocket *socket); +#if QT_CONFIG(localserver) + void _q_connected_local_socket(QLocalSocket *socket); +#endif + void _q_connected(); // start sending request + void _q_error(QAbstractSocket::SocketError); // error from socket +#ifndef QT_NO_NETWORKPROXY + void _q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); // from transparent proxy +#endif + + void _q_uploadDataReadyRead(); + +#ifndef QT_NO_SSL + void _q_encrypted(); // start sending request (https) + void _q_sslErrors(const QList<QSslError> &errors); // ssl errors from the socket + void _q_preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*); // tls-psk auth necessary + void _q_encryptedBytesWritten(qint64 bytes); // proceed sending +#endif + + friend class QHttpProtocolHandler; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkheader_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkheader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..267c79cc5302e626b3f3db340c572cc2f3187366 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkheader_p.h @@ -0,0 +1,79 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPNETWORKHEADER_H +#define QHTTPNETWORKHEADER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtNetwork/private/qhttpheaderparser_p.h> +#include <QtNetwork/qhttpheaders.h> + +#include <qshareddata.h> +#include <qurl.h> + +#ifndef Q_OS_WASM +QT_REQUIRE_CONFIG(http); +#endif + +QT_BEGIN_NAMESPACE + +class Q_AUTOTEST_EXPORT QHttpNetworkHeader +{ +public: + virtual ~QHttpNetworkHeader(); + virtual QUrl url() const = 0; + virtual void setUrl(const QUrl &url) = 0; + + virtual int majorVersion() const = 0; + virtual int minorVersion() const = 0; + + virtual qint64 contentLength() const = 0; + virtual void setContentLength(qint64 length) = 0; + + virtual QHttpHeaders header() const = 0; + virtual QByteArray headerField(QByteArrayView name, const QByteArray &defaultValue = QByteArray()) const = 0; + virtual void setHeaderField(const QByteArray &name, const QByteArray &data) = 0; +}; + +class Q_AUTOTEST_EXPORT QHttpNetworkHeaderPrivate : public QSharedData +{ +public: + QUrl url; + QHttpHeaderParser parser; + + QHttpNetworkHeaderPrivate(const QUrl &newUrl = QUrl()); + QHttpNetworkHeaderPrivate(const QHttpNetworkHeaderPrivate &other) = default; + qint64 contentLength() const; + void setContentLength(qint64 length); + + QByteArray headerField(QByteArrayView name, const QByteArray &defaultValue = QByteArray()) const; + QList<QByteArray> headerFieldValues(QByteArrayView name) const; + void setHeaderField(const QByteArray &name, const QByteArray &data); + void prependHeaderField(const QByteArray &name, const QByteArray &data); + void clearHeaders(); + QHttpHeaders headers() const; + bool operator==(const QHttpNetworkHeaderPrivate &other) const; + +}; + + +QT_END_NAMESPACE + +#endif // QHTTPNETWORKHEADER_H + + + + + + diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkreply_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkreply_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9bd85ab62e34589c264e892ebe8c2954f0826f6f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkreply_p.h @@ -0,0 +1,253 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPNETWORKREPLY_H +#define QHTTPNETWORKREPLY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include <qplatformdefs.h> + +#include <QtNetwork/qtcpsocket.h> +// it's safe to include these even if SSL support is not enabled +#include <QtNetwork/qsslsocket.h> +#include <QtNetwork/qsslerror.h> + +#include <QtNetwork/qnetworkrequest.h> +#include <QtNetwork/qnetworkreply.h> +#include <qbuffer.h> + +#include <private/qobject_p.h> +#include <private/qhttpnetworkheader_p.h> +#include <private/qhttpnetworkrequest_p.h> +#include <private/qauthenticator_p.h> +#include <private/qringbuffer_p.h> +#include <private/qbytedata_p.h> + +#ifndef QT_NO_NETWORKPROXY +Q_MOC_INCLUDE(<QtNetwork/QNetworkProxy>) +#endif +Q_MOC_INCLUDE(<QtNetwork/QAuthenticator>) + +#include <private/qdecompresshelper_p.h> +#include <QtNetwork/qhttpheaders.h> + +#include <QtCore/qpointer.h> + +QT_REQUIRE_CONFIG(http); + +QT_BEGIN_NAMESPACE + +class QHttpNetworkConnection; +class QHttpNetworkConnectionChannel; +class QHttpNetworkRequest; +class QHttpNetworkConnectionPrivate; +class QHttpNetworkReplyPrivate; +class Q_NETWORK_EXPORT QHttpNetworkReply : public QObject, public QHttpNetworkHeader +{ + Q_OBJECT +public: + + explicit QHttpNetworkReply(const QUrl &url = QUrl(), QObject *parent = nullptr); + ~QHttpNetworkReply() override; + + QUrl url() const override; + void setUrl(const QUrl &url) override; + + int majorVersion() const override; + int minorVersion() const override; + void setMajorVersion(int version); + void setMinorVersion(int version); + + qint64 contentLength() const override; + void setContentLength(qint64 length) override; + + QHttpHeaders header() const override; + QByteArray headerField(QByteArrayView name, const QByteArray &defaultValue = QByteArray()) const override; + void setHeaderField(const QByteArray &name, const QByteArray &data) override; + void appendHeaderField(const QByteArray &name, const QByteArray &data); + void parseHeader(QByteArrayView header); // used for testing + + QHttpNetworkRequest request() const; + void setRequest(const QHttpNetworkRequest &request); + + int statusCode() const; + void setStatusCode(int code); + + QString errorString() const; + void setErrorString(const QString &error); + + QNetworkReply::NetworkError errorCode() const; + + QString reasonPhrase() const; + void setReasonPhrase(const QString &reason); + + qint64 bytesAvailable() const; + qint64 bytesAvailableNextBlock() const; + bool readAnyAvailable() const; + QByteArray readAny(); + QByteArray readAll(); + QByteArray read(qint64 amount); + qint64 sizeNextBlock(); + void setDownstreamLimited(bool t); + void setReadBufferSize(qint64 size); + + bool supportsUserProvidedDownloadBuffer(); + void setUserProvidedDownloadBuffer(char*); + char* userProvidedDownloadBuffer(); + + void abort(); + + bool isAborted() const; + bool isFinished() const; + + bool isPipeliningUsed() const; + bool isHttp2Used() const; + void setHttp2WasUsed(bool h2Used); + qint64 removedContentLength() const; + + bool isRedirecting() const; + + QHttpNetworkConnection* connection(); + + QUrl redirectUrl() const; + void setRedirectUrl(const QUrl &url); + + static bool isHttpRedirect(int statusCode); + + bool isCompressed() const; + +#ifndef QT_NO_SSL + QSslConfiguration sslConfiguration() const; + void setSslConfiguration(const QSslConfiguration &config); + void ignoreSslErrors(); + void ignoreSslErrors(const QList<QSslError> &errors); + +Q_SIGNALS: + void encrypted(); + void sslErrors(const QList<QSslError> &errors); + void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator); +#endif + +Q_SIGNALS: + void socketStartedConnecting(); + void requestSent(); + void readyRead(); + void finished(); + void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail = QString()); + void headerChanged(); + void dataReadProgress(qint64 done, qint64 total); + void dataSendProgress(qint64 done, qint64 total); + void cacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *authenticator); +#ifndef QT_NO_NETWORKPROXY + void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator); +#endif + void authenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *authenticator); + void redirected(const QUrl &url, int httpStatus, int maxRedirectsRemaining); +private: + Q_DECLARE_PRIVATE(QHttpNetworkReply) + friend class QHttpSocketEngine; + friend class QHttpNetworkConnection; + friend class QHttpNetworkConnectionPrivate; + friend class QHttpNetworkConnectionChannel; + friend class QHttp2ProtocolHandler; + friend class QHttpProtocolHandler; + friend class QSpdyProtocolHandler; +}; + + +class Q_AUTOTEST_EXPORT QHttpNetworkReplyPrivate : public QObjectPrivate, public QHttpNetworkHeaderPrivate +{ +public: + QHttpNetworkReplyPrivate(const QUrl &newUrl = QUrl()); + ~QHttpNetworkReplyPrivate(); + qint64 readStatus(QIODevice *socket); + bool parseStatus(QByteArrayView status); + qint64 readHeader(QIODevice *socket); + void parseHeader(QByteArrayView header); + void appendHeaderField(const QByteArray &name, const QByteArray &data); + qint64 readBody(QIODevice *socket, QByteDataBuffer *out); + qint64 readBodyVeryFast(QIODevice *socket, char *b); + qint64 readBodyFast(QIODevice *socket, QByteDataBuffer *rb); + void clear(); + void clearHttpLayerInformation(); + + qint64 readReplyBodyRaw(QIODevice *in, QByteDataBuffer *out, qint64 size); + qint64 readReplyBodyChunked(QIODevice *in, QByteDataBuffer *out); + qint64 getChunkSize(QIODevice *in, qint64 *chunkSize); + + bool isRedirecting() const; + bool shouldEmitSignals(); + bool expectContent(); + void eraseData(); + + qint64 bytesAvailable() const; + bool isChunked(); + bool isConnectionCloseEnabled(); + + bool isCompressed() const; + void removeAutoDecompressHeader(); + + enum ReplyState { + NothingDoneState, + ReadingStatusState, + ReadingHeaderState, + ReadingDataState, + AllDoneState, + SPDYSYNSent, + SPDYUploading, + SPDYHalfClosed, + SPDYClosed, + Aborted + } state; + + QHttpNetworkRequest request; + bool ssl; + QString errorString; + qint64 bodyLength; + qint64 contentRead; + qint64 totalProgress; + QByteArray fragment; // used for header, status, chunk header etc, not for reply data + bool chunkedTransferEncoding; + bool connectionCloseEnabled; + bool forceConnectionCloseEnabled; + bool lastChunkRead; + qint64 currentChunkSize; + qint64 currentChunkRead; + qint64 readBufferMaxSize; + qint64 totallyUploadedData; // HTTP/2 + qint64 removedContentLength; + QPointer<QHttpNetworkConnection> connection; + QPointer<QHttpNetworkConnectionChannel> connectionChannel; + QNetworkReply::NetworkError httpErrorCode = QNetworkReply::NoError; + + bool autoDecompress; + + QByteDataBuffer responseData; // uncompressed body + bool requestIsPrepared; + + bool pipeliningUsed; + bool h2Used; + bool downstreamLimited; + + char* userProvidedDownloadBuffer; + QUrl redirectUrl; +}; + + + + +QT_END_NAMESPACE + +#endif // QHTTPNETWORKREPLY_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkrequest_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkrequest_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7a771994dd4ef6113d9793ea78bc747a29a017de --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpnetworkrequest_p.h @@ -0,0 +1,168 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPNETWORKREQUEST_H +#define QHTTPNETWORKREQUEST_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include <private/qhttpnetworkheader_p.h> +#include <QtNetwork/qnetworkrequest.h> +#include <qmetatype.h> + +#ifndef Q_OS_WASM +QT_REQUIRE_CONFIG(http); +#endif + +QT_BEGIN_NAMESPACE + +class QNonContiguousByteDevice; + +class QHttpNetworkRequestPrivate; +class Q_AUTOTEST_EXPORT QHttpNetworkRequest: public QHttpNetworkHeader +{ +public: + enum Operation { + Options, + Get, + Head, + Post, + Put, + Delete, + Trace, + Connect, + Custom + }; + + enum Priority { + HighPriority, + NormalPriority, + LowPriority + }; + + explicit QHttpNetworkRequest(const QUrl &url = QUrl(), Operation operation = Get, Priority priority = NormalPriority); + QHttpNetworkRequest(const QHttpNetworkRequest &other); + ~QHttpNetworkRequest() override; + QHttpNetworkRequest &operator=(const QHttpNetworkRequest &other); + bool operator==(const QHttpNetworkRequest &other) const; + + QUrl url() const override; + void setUrl(const QUrl &url) override; + + int majorVersion() const override; + int minorVersion() const override; + + qint64 contentLength() const override; + void setContentLength(qint64 length) override; + + QHttpHeaders header() const override; + QByteArray headerField(QByteArrayView name, const QByteArray &defaultValue = QByteArray()) const override; + void setHeaderField(const QByteArray &name, const QByteArray &data) override; + void prependHeaderField(const QByteArray &name, const QByteArray &data); + void clearHeaders(); + + Operation operation() const; + void setOperation(Operation operation); + + QByteArray customVerb() const; + void setCustomVerb(const QByteArray &customOperation); + + Priority priority() const; + void setPriority(Priority priority); + + bool isPipeliningAllowed() const; + void setPipeliningAllowed(bool b); + + bool isHTTP2Allowed() const; + void setHTTP2Allowed(bool b); + + bool isHTTP2Direct() const; + void setHTTP2Direct(bool b); + + bool isH2cAllowed() const; + void setH2cAllowed(bool b); + + bool withCredentials() const; + void setWithCredentials(bool b); + + bool isSsl() const; + void setSsl(bool); + + bool isPreConnect() const; + void setPreConnect(bool preConnect); + + bool isFollowRedirects() const; + void setRedirectPolicy(QNetworkRequest::RedirectPolicy policy); + QNetworkRequest::RedirectPolicy redirectPolicy() const; + + int redirectCount() const; + void setRedirectCount(int count); + + void setUploadByteDevice(QNonContiguousByteDevice *bd); + QNonContiguousByteDevice* uploadByteDevice() const; + + QByteArray methodName() const; + QByteArray uri(bool throughProxy) const; + + QString peerVerifyName() const; + void setPeerVerifyName(const QString &peerName); + + QString fullLocalServerName() const; + void setFullLocalServerName(const QString &fullServerName); + +private: + QSharedDataPointer<QHttpNetworkRequestPrivate> d; + friend class QHttpNetworkRequestPrivate; + friend class QHttpNetworkConnectionPrivate; + friend class QHttpNetworkConnectionChannel; + friend class QHttpProtocolHandler; + friend class QHttp2ProtocolHandler; + friend class QSpdyProtocolHandler; +}; + +class QHttpNetworkRequestPrivate : public QHttpNetworkHeaderPrivate +{ +public: + QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op, + QHttpNetworkRequest::Priority pri, const QUrl &newUrl = QUrl()); + QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other); + ~QHttpNetworkRequestPrivate(); + bool operator==(const QHttpNetworkRequestPrivate &other) const; + + static QByteArray header(const QHttpNetworkRequest &request, bool throughProxy); + + QHttpNetworkRequest::Operation operation; + QByteArray customVerb; + QString fullLocalServerName; // for local sockets + QHttpNetworkRequest::Priority priority; + mutable QNonContiguousByteDevice* uploadByteDevice; + bool autoDecompress; + bool pipeliningAllowed; + bool http2Allowed; + bool http2Direct; + bool h2cAllowed = false; + bool withCredentials; + bool ssl = false; + bool preConnect; + bool needResendWithCredentials = false; + int redirectCount; + QNetworkRequest::RedirectPolicy redirectPolicy; + QString peerVerifyName; +}; + + +QT_END_NAMESPACE + +QT_DECL_METATYPE_EXTERN(QHttpNetworkRequest, Q_AUTOTEST_EXPORT) + +#endif // QHTTPNETWORKREQUEST_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpprotocolhandler_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpprotocolhandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5a63ebff29c9a4ccaa2a094f244d9026a29fc310 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpprotocolhandler_p.h @@ -0,0 +1,42 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2014 BlackBerry Limited. All rights reserved. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPPROTOCOLHANDLER_H +#define QHTTPPROTOCOLHANDLER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <private/qabstractprotocolhandler_p.h> + +#include <QtCore/qbytearray.h> + +QT_REQUIRE_CONFIG(http); + +QT_BEGIN_NAMESPACE + +class QHttpProtocolHandler : public QAbstractProtocolHandler { +public: + QHttpProtocolHandler(QHttpNetworkConnectionChannel *channel); + +private: + virtual void _q_receiveReply() override; + virtual void _q_readyRead() override; + virtual bool sendRequest() override; + + QByteArray m_header; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpsocketengine_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpsocketengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3c691e9891d4b0fd8b1b0dc8a0bf48953145b664 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpsocketengine_p.h @@ -0,0 +1,173 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPSOCKETENGINE_P_H +#define QHTTPSOCKETENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include <QtNetwork/qnetworkproxy.h> + +#include "qabstractsocket.h" +#include "private/qauthenticator_p.h" +#include "private/qabstractsocketengine_p.h" + +QT_REQUIRE_CONFIG(http); + +QT_BEGIN_NAMESPACE + +#if !defined(QT_NO_NETWORKPROXY) + +class QTcpSocket; +class QHttpNetworkReply; +class QHttpSocketEnginePrivate; + +class Q_AUTOTEST_EXPORT QHttpSocketEngine : public QAbstractSocketEngine +{ + Q_OBJECT +public: + enum HttpState { + None, + ConnectSent, + Connected, + SendAuthentication, + ReadResponseContent, + ReadResponseHeader + }; + QHttpSocketEngine(QObject *parent = nullptr); + ~QHttpSocketEngine(); + + bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) override; + bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState) override; + + void setProxy(const QNetworkProxy &networkProxy); + + qintptr socketDescriptor() const override; + + bool isValid() const override; + + bool connectInternal(); + bool connectToHost(const QHostAddress &address, quint16 port) override; + bool connectToHostByName(const QString &name, quint16 port) override; + bool bind(const QHostAddress &address, quint16 port) override; + bool listen(int backlog) override; + qintptr accept() override; + void close() override; + + qint64 bytesAvailable() const override; + + qint64 read(char *data, qint64 maxlen) override; + qint64 write(const char *data, qint64 len) override; + +#ifndef QT_NO_UDPSOCKET +#ifndef QT_NO_NETWORKINTERFACE + bool joinMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &interface) override; + bool leaveMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &interface) override; + QNetworkInterface multicastInterface() const override; + bool setMulticastInterface(const QNetworkInterface &iface) override; +#endif // QT_NO_NETWORKINTERFACE + + bool hasPendingDatagrams() const override; + qint64 pendingDatagramSize() const override; +#endif // QT_NO_UDPSOCKET + + qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader *, + PacketHeaderOptions) override; + qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) override; + qint64 bytesToWrite() const override; + + int option(SocketOption option) const override; + bool setOption(SocketOption option, int value) override; + + bool waitForRead(QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) override; + bool waitForWrite(QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) override; + bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, + bool checkRead, bool checkWrite, + QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) override; + + void waitForProtocolHandshake(QDeadlineTimer deadline) const; + + bool isReadNotificationEnabled() const override; + void setReadNotificationEnabled(bool enable) override; + bool isWriteNotificationEnabled() const override; + void setWriteNotificationEnabled(bool enable) override; + bool isExceptionNotificationEnabled() const override; + void setExceptionNotificationEnabled(bool enable) override; + +public slots: + void slotSocketConnected(); + void slotSocketDisconnected(); + void slotSocketReadNotification(); + void slotSocketBytesWritten(); + void slotSocketError(QAbstractSocket::SocketError error); + void slotSocketStateChanged(QAbstractSocket::SocketState state); + +private slots: + void emitPendingReadNotification(); + void emitPendingWriteNotification(); + void emitPendingConnectionNotification(); + +private: + void emitReadNotification(); + void emitWriteNotification(); + void emitConnectionNotification(); + + bool readHttpHeader(); + + Q_DECLARE_PRIVATE(QHttpSocketEngine) + Q_DISABLE_COPY_MOVE(QHttpSocketEngine) + +}; + + +class QHttpSocketEnginePrivate : public QAbstractSocketEnginePrivate +{ + Q_DECLARE_PUBLIC(QHttpSocketEngine) +public: + QHttpSocketEnginePrivate(); + ~QHttpSocketEnginePrivate(); + + QNetworkProxy proxy; + QString peerName; + QTcpSocket *socket; + QHttpNetworkReply *reply; // only used for parsing the proxy response + QHttpSocketEngine::HttpState state; + QAuthenticator authenticator; + bool readNotificationEnabled; + bool writeNotificationEnabled; + bool exceptNotificationEnabled; + bool readNotificationPending; + bool writeNotificationPending; + bool connectionNotificationPending; + bool credentialsSent; + uint pendingResponseData; +}; + +class Q_AUTOTEST_EXPORT QHttpSocketEngineHandler : public QSocketEngineHandler +{ +public: + virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType, + const QNetworkProxy &, QObject *parent) override; + virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescripter, QObject *parent) override; +}; +#endif + +QT_END_NAMESPACE + +#endif // QHTTPSOCKETENGINE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpthreaddelegate_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpthreaddelegate_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dfdd03620ecc5645eee4ee2723fed92a60531971 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qhttpthreaddelegate_p.h @@ -0,0 +1,296 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHTTPTHREADDELEGATE_H +#define QHTTPTHREADDELEGATE_H + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QObject> +#include <QThreadStorage> +#include <QNetworkProxy> +#include <QSslConfiguration> +#include <QSslError> +#include <QList> +#include <QNetworkReply> +#include "qhttpnetworkrequest_p.h" +#include "qhttpnetworkconnection_p.h" +#include "qhttp1configuration.h" +#include "qhttp2configuration.h" +#include <QSharedPointer> +#include <QScopedPointer> +#include "private/qnoncontiguousbytedevice_p.h" +#include "qnetworkaccessauthenticationmanager_p.h" +#include <QtNetwork/private/http2protocol_p.h> +#include <QtNetwork/qhttpheaders.h> + +QT_REQUIRE_CONFIG(http); + +QT_BEGIN_NAMESPACE + +class QAuthenticator; +class QHttpNetworkReply; +class QEventLoop; +class QNetworkAccessCache; +class QNetworkAccessCachedHttpConnection; + +class QHttpThreadDelegate : public QObject +{ + Q_OBJECT +public: + explicit QHttpThreadDelegate(QObject *parent = nullptr); + + ~QHttpThreadDelegate(); + + // incoming + bool ssl; +#ifndef QT_NO_SSL + QScopedPointer<QSslConfiguration> incomingSslConfiguration; +#endif + QHttpNetworkRequest httpRequest; + qint64 downloadBufferMaximumSize; + qint64 readBufferMaxSize; + qint64 bytesEmitted; + // From backend, modified by us for signal compression + std::shared_ptr<QAtomicInt> pendingDownloadData; + std::shared_ptr<QAtomicInt> pendingDownloadProgress; +#ifndef QT_NO_NETWORKPROXY + QNetworkProxy cacheProxy; + QNetworkProxy transparentProxy; +#endif + std::shared_ptr<QNetworkAccessAuthenticationManager> authenticationManager; + bool synchronous; + qint64 connectionCacheExpiryTimeoutSeconds; + + // outgoing, Retrieved in the synchronous HTTP case + QByteArray synchronousDownloadData; + QHttpHeaders incomingHeaders; + int incomingStatusCode; + QString incomingReasonPhrase; + bool isPipeliningUsed; + bool isHttp2Used; + bool isCompressed = false; + qint64 incomingContentLength; + qint64 removedContentLength; + QNetworkReply::NetworkError incomingErrorCode; + QString incomingErrorDetail; + QHttp1Configuration http1Parameters; + QHttp2Configuration http2Parameters; + +protected: + // The zerocopy download buffer, if used: + QSharedPointer<char> downloadBuffer; + // The QHttpNetworkConnection that is used + QNetworkAccessCachedHttpConnection *httpConnection; + QByteArray cacheKey; + QHttpNetworkReply *httpReply; + + // Used for implementing the synchronous HTTP, see startRequestSynchronously() + QEventLoop *synchronousRequestLoop; + +signals: + void authenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *); +#ifndef QT_NO_NETWORKPROXY + void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *); +#endif +#ifndef QT_NO_SSL + void encrypted(); + void sslErrors(const QList<QSslError> &, bool *, QList<QSslError> *); + void sslConfigurationChanged(const QSslConfiguration &); + void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *); +#endif + void socketStartedConnecting(); + void requestSent(); + void downloadMetaData(const QHttpHeaders &, int, const QString &, bool, + QSharedPointer<char>, qint64, qint64, bool, bool); + void downloadProgress(qint64, qint64); + void downloadData(const QByteArray &); + void error(QNetworkReply::NetworkError, const QString &); + void downloadFinished(); + void redirected(const QUrl &url, int httpStatus, int maxRedirectsRemainig); + +public slots: + // This are called via QueuedConnection from user thread + void startRequest(); + void abortRequest(); + void readBufferSizeChanged(qint64 size); + void readBufferFreed(qint64 size); + + // This is called with a BlockingQueuedConnection from user thread + void startRequestSynchronously(); +protected slots: + // From QHttp* + void readyReadSlot(); + void finishedSlot(); + void finishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail = QString()); + void synchronousFinishedSlot(); + void synchronousFinishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail = QString()); + void headerChangedSlot(); + void synchronousHeaderChangedSlot(); + void dataReadProgressSlot(qint64 done, qint64 total); + void cacheCredentialsSlot(const QHttpNetworkRequest &request, QAuthenticator *authenticator); +#ifndef QT_NO_SSL + void encryptedSlot(); + void sslErrorsSlot(const QList<QSslError> &errors); + void preSharedKeyAuthenticationRequiredSlot(QSslPreSharedKeyAuthenticator *authenticator); +#endif + + void synchronousAuthenticationRequiredSlot(const QHttpNetworkRequest &request, QAuthenticator *); +#ifndef QT_NO_NETWORKPROXY + void synchronousProxyAuthenticationRequiredSlot(const QNetworkProxy &, QAuthenticator *); +#endif + +protected: + // Cache for all the QHttpNetworkConnection objects. + // This is per thread. + static QThreadStorage<QNetworkAccessCache *> connections; + +}; + +// This QNonContiguousByteDevice is connected to the QNetworkAccessHttpBackend +// and represents the PUT/POST data. +class QNonContiguousByteDeviceThreadForwardImpl : public QNonContiguousByteDevice +{ + Q_OBJECT +protected: + bool wantDataPending = false; + qint64 m_amount = 0; + char *m_data = nullptr; + QByteArray m_dataArray; + bool m_atEnd = false; + qint64 m_size = 0; + qint64 m_pos = 0; // to match calls of haveDataSlot with the expected position +public: + QNonContiguousByteDeviceThreadForwardImpl(bool aE, qint64 s) + : QNonContiguousByteDevice(), + m_atEnd(aE), + m_size(s) + { + } + + ~QNonContiguousByteDeviceThreadForwardImpl() + { + } + + qint64 pos() const override + { + return m_pos; + } + + const char* readPointer(qint64 maximumLength, qint64 &len) override + { + if (m_amount > 0) { + len = m_amount; + return m_data; + } + + if (m_atEnd) { + len = -1; + } else if (!wantDataPending) { + len = 0; + wantDataPending = true; + emit wantData(maximumLength); + } else { + // Do nothing, we already sent a wantData signal and wait for results + len = 0; + } + return nullptr; + } + + bool advanceReadPointer(qint64 a) override + { + if (m_data == nullptr) + return false; + + m_amount -= a; + m_data += a; + m_pos += a; + + // To main thread to inform about our state. The m_pos will be sent as a sanity check. + emit processedData(m_pos, a); + + return true; + } + + bool atEnd() const override + { + if (m_amount > 0) + return false; + else + return m_atEnd; + } + + bool reset() override + { + m_amount = 0; + m_data = nullptr; + m_dataArray.clear(); + + if (wantDataPending) { + // had requested the user thread to send some data (only 1 in-flight at any moment) + wantDataPending = false; + } + + // Communicate as BlockingQueuedConnection + bool b = false; + emit resetData(&b); + if (b) { + // the reset succeeded, we're at pos 0 again + m_pos = 0; + m_atEnd = false; + // the HTTP code will anyway abort the request if !b. + } + return b; + } + + qint64 size() const override + { + return m_size; + } + +public slots: + // From user thread: + void haveDataSlot(qint64 pos, const QByteArray &dataArray, bool dataAtEnd, qint64 dataSize) + { + if (pos != m_pos) { + // Sometimes when re-sending a request in the qhttpnetwork* layer there is a pending haveData from the + // user thread on the way to us. We need to ignore it since it is the data for the wrong(later) chunk. + return; + } + wantDataPending = false; + + m_dataArray = dataArray; + m_data = const_cast<char*>(m_dataArray.constData()); + m_amount = dataArray.size(); + + m_atEnd = dataAtEnd; + m_size = dataSize; + + // This will tell the HTTP code (QHttpNetworkConnectionChannel) that we have data available now + emit readyRead(); + } + +signals: + // void readyRead(); in parent class + // void readProgress(qint64 current, qint64 total); happens in the main thread with the real bytedevice + + // to main thread: + void wantData(qint64); + void processedData(qint64 pos, qint64 amount); + void resetData(bool *b); +}; + +QT_END_NAMESPACE + +#endif // QHTTPTHREADDELEGATE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qlocalserver_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qlocalserver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2dd7d2c407363c419e7f420fb152ba749918cf4d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qlocalserver_p.h @@ -0,0 +1,102 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QLOCALSERVER_P_H +#define QLOCALSERVER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLocalServer class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include "qlocalserver.h" +#include "private/qobject_p.h" +#include <qqueue.h> + +QT_REQUIRE_CONFIG(localserver); + +#if defined(QT_LOCALSOCKET_TCP) +# include <qtcpserver.h> +# include <QtCore/qmap.h> +#elif defined(Q_OS_WIN) +# include <qt_windows.h> +# include <qwineventnotifier.h> +#else +# include <private/qabstractsocketengine_p.h> +# include <qsocketnotifier.h> +#endif + +QT_BEGIN_NAMESPACE + +class QLocalServerPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QLocalServer) + +public: + QLocalServerPrivate() : +#if !defined(QT_LOCALSOCKET_TCP) && !defined(Q_OS_WIN) + listenSocket(-1), socketNotifier(nullptr), +#endif + maxPendingConnections(30), error(QAbstractSocket::UnknownSocketError), + socketOptions(QLocalServer::NoOptions) + { + } + + void init(); + bool listen(const QString &name); + bool listen(qintptr socketDescriptor); + static bool removeServer(const QString &name); + void closeServer(); + void waitForNewConnection(int msec, bool *timedOut); + void _q_onNewConnection(); + +#if defined(QT_LOCALSOCKET_TCP) + + QTcpServer tcpServer; + QMap<quintptr, QTcpSocket*> socketMap; +#elif defined(Q_OS_WIN) + struct Listener { + Listener() = default; + HANDLE handle = nullptr; + OVERLAPPED overlapped; + bool connected = false; + private: + Q_DISABLE_COPY(Listener) + }; + + void setError(const QString &function); + bool addListener(); + + std::vector<std::unique_ptr<Listener>> listeners; + HANDLE eventHandle; + QWinEventNotifier *connectionEventNotifier; +#else + void setError(const QString &function); + + int listenSocket; + QSocketNotifier *socketNotifier; +#endif + + QString serverName; + QString fullServerName; + int maxPendingConnections; + QQueue<QLocalSocket*> pendingConnections; + QString errorString; + QAbstractSocket::SocketError error; + int listenBacklog = 50; + + Q_OBJECT_BINDABLE_PROPERTY(QLocalServerPrivate, QLocalServer::SocketOptions, socketOptions) +}; + +QT_END_NAMESPACE + +#endif // QLOCALSERVER_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qlocalsocket_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qlocalsocket_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5bf5f2806e8e46911f4b5e8c96092c27b310c090 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qlocalsocket_p.h @@ -0,0 +1,141 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QLOCALSOCKET_P_H +#define QLOCALSOCKET_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLocalSocket class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include "qlocalsocket.h" +#include "private/qiodevice_p.h" + +#include <qtimer.h> + +QT_REQUIRE_CONFIG(localserver); + +#if defined(QT_LOCALSOCKET_TCP) +# include "qtcpsocket.h" +#elif defined(Q_OS_WIN) +# include "private/qwindowspipereader_p.h" +# include "private/qwindowspipewriter_p.h" +# include <qwineventnotifier.h> +#else +# include "private/qabstractsocketengine_p.h" +# include <qtcpsocket.h> +# include <qsocketnotifier.h> +# include <errno.h> +#endif + +struct sockaddr_un; + +QT_BEGIN_NAMESPACE + +#if !defined(Q_OS_WIN) || defined(QT_LOCALSOCKET_TCP) + +class QLocalUnixSocket : public QTcpSocket +{ + +public: + QLocalUnixSocket() : QTcpSocket() + { + }; + + inline void setSocketState(QAbstractSocket::SocketState state) + { + QTcpSocket::setSocketState(state); + }; + + inline void setErrorString(const QString &string) + { + QTcpSocket::setErrorString(string); + } + + inline void setSocketError(QAbstractSocket::SocketError error) + { + QTcpSocket::setSocketError(error); + } + + inline qint64 readData(char *data, qint64 maxSize) override + { + return QTcpSocket::readData(data, maxSize); + } + + inline qint64 writeData(const char *data, qint64 maxSize) override + { + return QTcpSocket::writeData(data, maxSize); + } +}; +#endif //#if !defined(Q_OS_WIN) || defined(QT_LOCALSOCKET_TCP) + +class QLocalSocketPrivate : public QIODevicePrivate +{ +public: + Q_DECLARE_PUBLIC(QLocalSocket) + + QLocalSocketPrivate(); + void init(); + +#if defined(QT_LOCALSOCKET_TCP) + QLocalUnixSocket* tcpSocket; + bool ownsTcpSocket; + void setSocket(QLocalUnixSocket*); + QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const; + void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function); + void _q_stateChanged(QAbstractSocket::SocketState newState); + void _q_errorOccurred(QAbstractSocket::SocketError newError); +#elif defined(Q_OS_WIN) + ~QLocalSocketPrivate(); + qint64 pipeWriterBytesToWrite() const; + void _q_canRead(); + void _q_bytesWritten(qint64 bytes); + void _q_pipeClosed(); + void _q_winError(ulong windowsError, const QString &function); + void _q_writeFailed(); + HANDLE handle; + QWindowsPipeWriter *pipeWriter; + QWindowsPipeReader *pipeReader; + QLocalSocket::LocalSocketError error; +#else + QLocalUnixSocket unixSocket; + QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const; + void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function); + void _q_stateChanged(QAbstractSocket::SocketState newState); + void _q_errorOccurred(QAbstractSocket::SocketError newError); + void _q_connectToSocket(); + void _q_abortConnectionAttempt(); + void cancelDelayedConnect(); + void describeSocket(qintptr socketDescriptor); + static bool parseSockaddr(const sockaddr_un &addr, uint len, + QString &fullServerName, QString &serverName, bool &abstractNamespace); + QSocketNotifier *delayConnect; + QTimer *connectTimer; + QString connectingName; + int connectingSocket; + QIODevice::OpenMode connectingOpenMode; +#endif + QLocalSocket::LocalSocketState state; + QString serverName; + QString fullServerName; +#if defined(Q_OS_WIN) && !defined(QT_LOCALSOCKET_TCP) + bool emittedReadyRead; + bool emittedBytesWritten; +#endif + + Q_OBJECT_BINDABLE_PROPERTY(QLocalSocketPrivate, QLocalSocket::SocketOptions, socketOptions) +}; + +QT_END_NAMESPACE + +#endif // QLOCALSOCKET_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnativesocketengine_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnativesocketengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9eead1347f16143b809a2e660753bc46407c753f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnativesocketengine_p.h @@ -0,0 +1,184 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNATIVESOCKETENGINE_P_H +#define QNATIVESOCKETENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "QtNetwork/qhostaddress.h" +#include "QtNetwork/qnetworkinterface.h" +#include "private/qabstractsocketengine_p.h" +#include "qplatformdefs.h" + +#ifndef Q_OS_WIN +# include <netinet/in.h> +#else +# include <winsock2.h> +# include <ws2tcpip.h> +# include <mswsock.h> +#endif + +QT_BEGIN_NAMESPACE + +#ifdef Q_OS_WIN +# define QT_SOCKLEN_T int +# define QT_SOCKOPTLEN_T int +#endif + +namespace { +namespace SetSALen { + template <typename T> void set(T *sa, typename std::enable_if<(&T::sa_len, true), QT_SOCKLEN_T>::type len) + { sa->sa_len = len; } + template <typename T> void set(T *sa, typename std::enable_if<(&T::sin_len, true), QT_SOCKLEN_T>::type len) + { sa->sin_len = len; } + template <typename T> void set(T *sin6, typename std::enable_if<(&T::sin6_len, true), QT_SOCKLEN_T>::type len) + { sin6->sin6_len = len; } + template <typename T> void set(T *, ...) {} +} + +inline QT_SOCKLEN_T setSockaddr(sockaddr_in *sin, const QHostAddress &addr, quint16 port = 0) +{ + *sin = {}; + SetSALen::set(sin, sizeof(*sin)); + sin->sin_family = AF_INET; + sin->sin_port = htons(port); + sin->sin_addr.s_addr = htonl(addr.toIPv4Address()); + return sizeof(*sin); +} + +inline QT_SOCKLEN_T setSockaddr(sockaddr_in6 *sin6, const QHostAddress &addr, quint16 port = 0) +{ + *sin6 = {}; + SetSALen::set(sin6, sizeof(*sin6)); + sin6->sin6_family = AF_INET6; + sin6->sin6_port = htons(port); + memcpy(sin6->sin6_addr.s6_addr, addr.toIPv6Address().c, sizeof(sin6->sin6_addr)); +#if QT_CONFIG(networkinterface) + sin6->sin6_scope_id = QNetworkInterface::interfaceIndexFromName(addr.scopeId()); +#else + // it had better be a number then, if it is not empty + sin6->sin6_scope_id = addr.scopeId().toUInt(); +#endif + return sizeof(*sin6); +} + +inline QT_SOCKLEN_T setSockaddr(sockaddr *sa, const QHostAddress &addr, quint16 port = 0) +{ + switch (addr.protocol()) { + case QHostAddress::IPv4Protocol: + return setSockaddr(reinterpret_cast<sockaddr_in *>(sa), addr, port); + + case QHostAddress::IPv6Protocol: + case QHostAddress::AnyIPProtocol: + return setSockaddr(reinterpret_cast<sockaddr_in6 *>(sa), addr, port); + + case QHostAddress::UnknownNetworkLayerProtocol: + break; + } + *sa = {}; + sa->sa_family = AF_UNSPEC; + return 0; +} +} // unnamed namespace + +class QNativeSocketEnginePrivate; +#ifndef QT_NO_NETWORKINTERFACE +class QNetworkInterface; +#endif + +class Q_AUTOTEST_EXPORT QNativeSocketEngine : public QAbstractSocketEngine +{ + Q_OBJECT +public: + QNativeSocketEngine(QObject *parent = nullptr); + ~QNativeSocketEngine(); + + bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) override; + bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState) override; + + qintptr socketDescriptor() const override; + + bool isValid() const override; + + bool connectToHost(const QHostAddress &address, quint16 port) override; + bool connectToHostByName(const QString &name, quint16 port) override; + bool bind(const QHostAddress &address, quint16 port) override; + bool listen(int backlog) override; + qintptr accept() override; + void close() override; + + qint64 bytesAvailable() const override; + + qint64 read(char *data, qint64 maxlen) override; + qint64 write(const char *data, qint64 len) override; + +#ifndef QT_NO_UDPSOCKET +#ifndef QT_NO_NETWORKINTERFACE + bool joinMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &iface) override; + bool leaveMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &iface) override; + QNetworkInterface multicastInterface() const override; + bool setMulticastInterface(const QNetworkInterface &iface) override; +#endif + + bool hasPendingDatagrams() const override; + qint64 pendingDatagramSize() const override; +#endif // QT_NO_UDPSOCKET + + qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader * = nullptr, + PacketHeaderOptions = WantNone) override; + qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) override; + qint64 bytesToWrite() const override; + +#if 0 // currently unused + qint64 receiveBufferSize() const; + void setReceiveBufferSize(qint64 bufferSize); + + qint64 sendBufferSize() const; + void setSendBufferSize(qint64 bufferSize); +#endif + + int option(SocketOption option) const override; + bool setOption(SocketOption option, int value) override; + + bool waitForRead(QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) override; + bool waitForWrite(QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) override; + bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, + bool checkRead, bool checkWrite, + QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) override; + + bool isReadNotificationEnabled() const override; + void setReadNotificationEnabled(bool enable) override; + bool isWriteNotificationEnabled() const override; + void setWriteNotificationEnabled(bool enable) override; + bool isExceptionNotificationEnabled() const override; + void setExceptionNotificationEnabled(bool enable) override; + +public Q_SLOTS: + // non-virtual override; + void connectionNotification(); + +private: + Q_DECLARE_PRIVATE(QNativeSocketEngine) + Q_DISABLE_COPY_MOVE(QNativeSocketEngine) +}; + +QT_END_NAMESPACE + +#endif // QNATIVESOCKETENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnativesocketengine_p_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnativesocketengine_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b7050e5af571d80d2a9e7744edf1863a4d70e9f8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnativesocketengine_p_p.h @@ -0,0 +1,189 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNATIVESOCKETENGINE_P_P_H +#define QNATIVESOCKETENGINE_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qabstractsocketengine_p.h" +#include "private/qnativesocketengine_p.h" + +#ifndef Q_OS_WIN +# include <netinet/in.h> +#else +# include <winsock2.h> +# include <ws2tcpip.h> +# include <mswsock.h> +#endif + +QT_BEGIN_NAMESPACE + +#ifdef Q_OS_WIN + +// The following definitions are copied from the MinGW header mswsock.h which +// was placed in the public domain. The WSASendMsg and WSARecvMsg functions +// were introduced with Windows Vista, so some Win32 headers are lacking them. +// There are no known versions of Windows CE or Embedded that contain them. +# ifndef WSAID_WSARECVMSG +typedef INT (WINAPI *LPFN_WSARECVMSG)(SOCKET s, LPWSAMSG lpMsg, + LPDWORD lpdwNumberOfBytesRecvd, + LPWSAOVERLAPPED lpOverlapped, + LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); +# define WSAID_WSARECVMSG {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}} +# endif // !WSAID_WSARECVMSG +# ifndef WSAID_WSASENDMSG +typedef struct { + LPWSAMSG lpMsg; + DWORD dwFlags; + LPDWORD lpNumberOfBytesSent; + LPWSAOVERLAPPED lpOverlapped; + LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine; +} WSASENDMSG, *LPWSASENDMSG; + +typedef INT (WSAAPI *LPFN_WSASENDMSG)(SOCKET s, LPWSAMSG lpMsg, DWORD dwFlags, + LPDWORD lpNumberOfBytesSent, + LPWSAOVERLAPPED lpOverlapped, + LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); + +# define WSAID_WSASENDMSG {0xa441e712,0x754f,0x43ca,{0x84,0xa7,0x0d,0xee,0x44,0xcf,0x60,0x6d}} +# endif // !WSAID_WSASENDMSG +#endif // Q_OS_WIN + +union qt_sockaddr { + sockaddr a; + sockaddr_in a4; + sockaddr_in6 a6; +}; + +class QSocketNotifier; + +class QNativeSocketEnginePrivate : public QAbstractSocketEnginePrivate +{ + Q_DECLARE_PUBLIC(QNativeSocketEngine) +public: + QNativeSocketEnginePrivate(); + ~QNativeSocketEnginePrivate(); + + qintptr socketDescriptor; + + QSocketNotifier *readNotifier, *writeNotifier, *exceptNotifier; + +#if defined(Q_OS_WIN) + LPFN_WSASENDMSG sendmsg; + LPFN_WSARECVMSG recvmsg; +# endif + enum ErrorString { + NonBlockingInitFailedErrorString, + BroadcastingInitFailedErrorString, + NoIpV6ErrorString, + RemoteHostClosedErrorString, + TimeOutErrorString, + ResourceErrorString, + OperationUnsupportedErrorString, + ProtocolUnsupportedErrorString, + InvalidSocketErrorString, + HostUnreachableErrorString, + NetworkUnreachableErrorString, + AccessErrorString, + ConnectionTimeOutErrorString, + ConnectionRefusedErrorString, + AddressInuseErrorString, + AddressNotAvailableErrorString, + AddressProtectedErrorString, + DatagramTooLargeErrorString, + SendDatagramErrorString, + ReceiveDatagramErrorString, + WriteErrorString, + ReadErrorString, + PortInuseErrorString, + NotSocketErrorString, + InvalidProxyTypeString, + TemporaryErrorString, + NetworkDroppedConnectionErrorString, + ConnectionResetErrorString, + + UnknownSocketErrorString = -1 + }; + + void setError(QAbstractSocket::SocketError error, ErrorString errorString) const; + QHostAddress adjustAddressProtocol(const QHostAddress &address) const; + + // native functions + int option(QNativeSocketEngine::SocketOption option) const; + bool setOption(QNativeSocketEngine::SocketOption option, int value); + + bool createNewSocket(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol &protocol); + + bool nativeConnect(const QHostAddress &address, quint16 port); + bool nativeBind(const QHostAddress &address, quint16 port); + bool nativeListen(int backlog); + qintptr nativeAccept(); +#ifndef QT_NO_NETWORKINTERFACE + bool nativeJoinMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &iface); + bool nativeLeaveMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &iface); + QNetworkInterface nativeMulticastInterface() const; + bool nativeSetMulticastInterface(const QNetworkInterface &iface); +#endif + qint64 nativeBytesAvailable() const; + + bool nativeHasPendingDatagrams() const; + qint64 nativePendingDatagramSize() const; + qint64 nativeReceiveDatagram(char *data, qint64 maxLength, QIpPacketHeader *header, + QAbstractSocketEngine::PacketHeaderOptions options); + qint64 nativeSendDatagram(const char *data, qint64 length, const QIpPacketHeader &header); + qint64 nativeRead(char *data, qint64 maxLength); + qint64 nativeWrite(const char *data, qint64 length); + int nativeSelect(QDeadlineTimer deadline, bool selectForRead) const; + int nativeSelect(QDeadlineTimer deadline, bool checkRead, bool checkWrite, + bool *selectForRead, bool *selectForWrite) const; + + void nativeClose(); + + bool checkProxy(const QHostAddress &address); + bool fetchConnectionParameters(); + + /*! \internal + Sets \a address and \a port in the \a aa sockaddr structure and the size in \a sockAddrSize. + The address \a is converted to IPv6 if the current socket protocol is also IPv6. + */ + void setPortAndAddress(quint16 port, const QHostAddress &address, qt_sockaddr *aa, QT_SOCKLEN_T *sockAddrSize) + { + switch (socketProtocol) { + case QHostAddress::IPv6Protocol: + case QHostAddress::AnyIPProtocol: + // force to IPv6 + setSockaddr(&aa->a6, address, port); + *sockAddrSize = sizeof(sockaddr_in6); + return; + + case QHostAddress::IPv4Protocol: + // force to IPv4 + setSockaddr(&aa->a4, address, port); + *sockAddrSize = sizeof(sockaddr_in); + return; + + case QHostAddress::UnknownNetworkLayerProtocol: + // don't force + break; + } + *sockAddrSize = setSockaddr(&aa->a, address, port); + } + +}; + +QT_END_NAMESPACE + +#endif // QNATIVESOCKETENGINE_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetconmonitor_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetconmonitor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d65e9e5abd978ba085d26feab38023813c8f7b38 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetconmonitor_p.h @@ -0,0 +1,71 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETCONMONITOR_P_H +#define QNETCONMONITOR_P_H + +#include <private/qtnetworkglobal_p.h> + +#include <QtCore/qloggingcategory.h> +#include <QtNetwork/qhostaddress.h> +#include <QtCore/qglobal.h> +#include <QtCore/qobject.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QNetworkConnectionMonitorPrivate; +class Q_NETWORK_EXPORT QNetworkConnectionMonitor : public QObject +{ + Q_OBJECT + +public: + QNetworkConnectionMonitor(); + QNetworkConnectionMonitor(const QHostAddress &local, const QHostAddress &remote = {}); + ~QNetworkConnectionMonitor(); + + bool setTargets(const QHostAddress &local, const QHostAddress &remote); + bool isReachable(); + +#ifdef QT_PLATFORM_UIKIT + bool isWwan() const; +#endif + + // Important: on Darwin you should not call isReachable/isWwan() after + // startMonitoring(), you have to listen to reachabilityChanged() + // signal instead. + bool startMonitoring(); + bool isMonitoring() const; + void stopMonitoring(); + + static bool isEnabled(); + +Q_SIGNALS: + // Important: connect to this using QueuedConnection. On Darwin + // callback is coming on a special dispatch queue. + void reachabilityChanged(bool isOnline); + +#ifdef QT_PLATFORM_UIKIT + void isWwanChanged(bool isWwan); +#endif + +private: + Q_DECLARE_PRIVATE(QNetworkConnectionMonitor) + Q_DISABLE_COPY_MOVE(QNetworkConnectionMonitor) +}; + +Q_DECLARE_LOGGING_CATEGORY(lcNetMon) + +QT_END_NAMESPACE + +#endif // QNETCONMONITOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessauthenticationmanager_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessauthenticationmanager_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1182de19bf8082cb5f510a649aab57edd641c578 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessauthenticationmanager_p.h @@ -0,0 +1,73 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKACCESSAUTHENTICATIONMANAGER_P_H +#define QNETWORKACCESSAUTHENTICATIONMANAGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qnetworkaccessmanager.h" +#include "qnetworkaccesscache_p.h" +#include "QtNetwork/qnetworkproxy.h" +#include "QtCore/QMutex" + +QT_BEGIN_NAMESPACE + +class QAuthenticator; +class QAbstractNetworkCache; +class QNetworkAuthenticationCredential; +class QNetworkCookieJar; + +class QNetworkAuthenticationCredential +{ +public: + QString domain; + QString user; + QString password; + bool isNull() const { + return domain.isNull() && user.isNull() && password.isNull(); + } +}; +Q_DECLARE_TYPEINFO(QNetworkAuthenticationCredential, Q_RELOCATABLE_TYPE); +inline bool operator<(const QNetworkAuthenticationCredential &t1, const QString &t2) +{ return t1.domain < t2; } +inline bool operator<(const QString &t1, const QNetworkAuthenticationCredential &t2) +{ return t1 < t2.domain; } +inline bool operator<(const QNetworkAuthenticationCredential &t1, const QNetworkAuthenticationCredential &t2) +{ return t1.domain < t2.domain; } + +class QNetworkAccessAuthenticationManager +{ +public: + QNetworkAccessAuthenticationManager() {} + + void cacheCredentials(const QUrl &url, const QAuthenticator *auth); + QNetworkAuthenticationCredential fetchCachedCredentials(const QUrl &url, + const QAuthenticator *auth = nullptr); + +#ifndef QT_NO_NETWORKPROXY + void cacheProxyCredentials(const QNetworkProxy &proxy, const QAuthenticator *auth); + QNetworkAuthenticationCredential fetchCachedProxyCredentials(const QNetworkProxy &proxy, + const QAuthenticator *auth = nullptr); +#endif + + void clearCache(); + +protected: + QNetworkAccessCache authenticationCache; + QMutex mutex; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessbackend_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessbackend_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1f283809d6e4fb6647f09efa81f4952d464862ad --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessbackend_p.h @@ -0,0 +1,160 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKACCESSBACKEND_P_H +#define QNETWORKACCESSBACKEND_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/qtnetworkglobal.h> + +#include <QtNetwork/qnetworkrequest.h> +#include <QtNetwork/qnetworkaccessmanager.h> +#include <QtNetwork/qnetworkreply.h> + +#include <QtCore/qobject.h> +#include <QtCore/qflags.h> +#include <QtCore/qbytearrayview.h> +#include <QtCore/private/qglobal_p.h> + +#if QT_CONFIG(ssl) +#include <QtNetwork/qsslconfiguration.h> +#endif + +QT_BEGIN_NAMESPACE + +class QNetworkReplyImplPrivate; +class QNetworkAccessManagerPrivate; +class QNetworkAccessBackendPrivate; +class Q_NETWORK_EXPORT QNetworkAccessBackend : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QNetworkAccessBackend); + +public: + enum class TargetType { + Networked = 0x1, // We need to query for proxy in case it is needed + Local = 0x2, // Local file, generated data or local device + }; + Q_ENUM(TargetType) + Q_DECLARE_FLAGS(TargetTypes, TargetType) + + enum class SecurityFeature { + None = 0x0, + TLS = 0x1, // We need to set QSslConfiguration + }; + Q_ENUM(SecurityFeature) + Q_DECLARE_FLAGS(SecurityFeatures, SecurityFeature) + + enum class IOFeature { + None = 0x0, + ZeroCopy = 0x1, // readPointer and advanceReadPointer() is available! + NeedResetableUpload = 0x2, // Need to buffer upload data + SupportsSynchronousMode = 0x4, // Used for XMLHttpRequest + }; + Q_ENUM(IOFeature) + Q_DECLARE_FLAGS(IOFeatures, IOFeature) + + QNetworkAccessBackend(TargetTypes targetTypes, SecurityFeatures securityFeatures, + IOFeatures ioFeatures); + QNetworkAccessBackend(TargetTypes targetTypes); + QNetworkAccessBackend(TargetTypes targetTypes, SecurityFeatures securityFeatures); + QNetworkAccessBackend(TargetTypes targetTypes, IOFeatures ioFeatures); + virtual ~QNetworkAccessBackend(); + + SecurityFeatures securityFeatures() const noexcept; + TargetTypes targetTypes() const noexcept; + IOFeatures ioFeatures() const noexcept; + + inline bool needsResetableUploadData() const noexcept + { + return ioFeatures() & IOFeature::NeedResetableUpload; + } + + virtual bool start(); + virtual void open() = 0; + virtual void close() = 0; +#if QT_CONFIG(ssl) + virtual void setSslConfiguration(const QSslConfiguration &configuration); + virtual QSslConfiguration sslConfiguration() const; +#endif + virtual void ignoreSslErrors(); + virtual void ignoreSslErrors(const QList<QSslError> &errors); + virtual qint64 bytesAvailable() const = 0; + virtual QByteArrayView readPointer(); + virtual void advanceReadPointer(qint64 distance); + virtual qint64 read(char *data, qint64 maxlen); + virtual bool wantToRead(); + +#if QT_CONFIG(networkproxy) + QList<QNetworkProxy> proxyList() const; +#endif + QUrl url() const; + void setUrl(const QUrl &url); + QVariant header(QNetworkRequest::KnownHeaders header) const; + void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value); + QByteArray rawHeader(const QByteArray &header) const; + void setRawHeader(const QByteArray &header, const QByteArray &value); + QHttpHeaders headers() const; + void setHeaders(const QHttpHeaders &newHeaders); + void setHeaders(QHttpHeaders &&newHeaders); + QNetworkAccessManager::Operation operation() const; + + bool isCachingEnabled() const; + void setCachingEnabled(bool canCache); + + void setAttribute(QNetworkRequest::Attribute attribute, const QVariant &value); + + QIODevice *createUploadByteDevice(); + QIODevice *uploadByteDevice(); + + QAbstractNetworkCache *networkCache() const; + +public slots: + void readyRead(); +protected slots: + void finished(); + void error(QNetworkReply::NetworkError code, const QString &errorString); +#ifndef QT_NO_NETWORKPROXY + void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); +#endif + void authenticationRequired(QAuthenticator *auth); + void metaDataChanged(); + void redirectionRequested(const QUrl &destination); + +private: + void setReplyPrivate(QNetworkReplyImplPrivate *reply); + void setManagerPrivate(QNetworkAccessManagerPrivate *manager); + bool isSynchronous() const; + void setSynchronous(bool synchronous); + + friend class QNetworkAccessManager; // for setReplyPrivate + friend class QNetworkAccessManagerPrivate; // for setManagerPrivate + friend class QNetworkReplyImplPrivate; // for {set,is}Synchronous() +}; + +class Q_NETWORK_EXPORT QNetworkAccessBackendFactory : public QObject +{ + Q_OBJECT +public: + QNetworkAccessBackendFactory(); + virtual ~QNetworkAccessBackendFactory(); + virtual QStringList supportedSchemes() const = 0; + virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op, + const QNetworkRequest &request) const = 0; +}; + +#define QNetworkAccessBackendFactory_iid "org.qt-project.Qt.NetworkAccessBackendFactory" +Q_DECLARE_INTERFACE(QNetworkAccessBackendFactory, QNetworkAccessBackendFactory_iid); + +QT_END_NAMESPACE +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccesscache_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccesscache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..85aab430e652d93f0085663ebdd9957e37866897 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccesscache_p.h @@ -0,0 +1,95 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKACCESSCACHE_P_H +#define QNETWORKACCESSCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "QtCore/qobject.h" +#include "QtCore/qbasictimer.h" +#include "QtCore/qbytearray.h" +#include <QtCore/qflags.h> +#include "QtCore/qhash.h" +#include "QtCore/qmetatype.h" + +QT_BEGIN_NAMESPACE + +class QNetworkRequest; +class QUrl; + +// this class is not about caching files but about +// caching objects used by QNetworkAccessManager, e.g. existing TCP connections +// or credentials. +class QNetworkAccessCache: public QObject +{ + Q_OBJECT +public: + struct Node; + typedef QHash<QByteArray, Node *> NodeHash; + class CacheableObject + { + friend class QNetworkAccessCache; + QByteArray key; + bool expires; + bool shareable; + qint64 expiryTimeoutSeconds = -1; + public: + enum class Option { + Expires = 0x01, + Shareable = 0x02, + }; + typedef QFlags<Option> Options; // #### QTBUG-127269 + + virtual ~CacheableObject(); + virtual void dispose() = 0; + inline QByteArray cacheKey() const { return key; } + protected: + explicit CacheableObject(Options options); + }; + + ~QNetworkAccessCache(); + + void clear(); + + void addEntry(const QByteArray &key, CacheableObject *entry, qint64 connectionCacheExpiryTimeoutSeconds = -1); + bool hasEntry(const QByteArray &key) const; + CacheableObject *requestEntryNow(const QByteArray &key); + void releaseEntry(const QByteArray &key); + void removeEntry(const QByteArray &key); + +signals: + void entryReady(QNetworkAccessCache::CacheableObject *); + +protected: + void timerEvent(QTimerEvent *) override; + +private: + // idea copied from qcache.h + NodeHash hash; + Node *firstExpiringNode = nullptr; + Node *lastExpiringNode = nullptr; + + QBasicTimer timer; + + void linkEntry(const QByteArray &key); + bool unlinkEntry(const QByteArray &key); + void updateTimer(); + bool emitEntryReady(Node *node, QObject *target, const char *member); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkAccessCache::CacheableObject::Options) + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccesscachebackend_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccesscachebackend_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0e3f15408bfa8ae5655c8590905326ae6e86fd2f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccesscachebackend_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKACCESSCACHEBACKEND_P_H +#define QNETWORKACCESSCACHEBACKEND_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qnetworkaccessbackend_p.h" +#include "qnetworkrequest.h" +#include "qnetworkreply.h" + +QT_BEGIN_NAMESPACE + +class QNetworkAccessCacheBackend : public QNetworkAccessBackend +{ + +public: + QNetworkAccessCacheBackend(); + ~QNetworkAccessCacheBackend(); + + void open() override; + void close() override; + bool start() override; + qint64 bytesAvailable() const override; + qint64 read(char *data, qint64 maxlen) override; + +private: + bool sendCacheContents(); + + QIODevice *device = nullptr; +}; + +QT_END_NAMESPACE + +#endif // QNETWORKACCESSCACHEBACKEND_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessfilebackend_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessfilebackend_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9f388d7fd21465c0eddd1c2a8956636b86d55ec5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessfilebackend_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKACCESSFILEBACKEND_P_H +#define QNETWORKACCESSFILEBACKEND_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qnetworkaccessbackend_p.h" +#include "qnetworkrequest.h" +#include "qnetworkreply.h" +#include "QtCore/qfile.h" + +QT_BEGIN_NAMESPACE + +class QNetworkAccessFileBackend: public QNetworkAccessBackend +{ + Q_OBJECT +public: + QNetworkAccessFileBackend(); + virtual ~QNetworkAccessFileBackend(); + + void open() override; + void close() override; + + qint64 bytesAvailable() const override; + qint64 read(char *data, qint64 maxlen) override; + +public slots: + void uploadReadyReadSlot(); +private: + QFile file; + qint64 totalBytes; + bool hasUploadFinished; + + bool loadFileInfo(); +}; + +class QNetworkAccessFileBackendFactory: public QNetworkAccessBackendFactory +{ +public: + virtual QStringList supportedSchemes() const override; + virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op, + const QNetworkRequest &request) const override; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessmanager_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessmanager_p.h new file mode 100644 index 0000000000000000000000000000000000000000..614bf89703ccbcab08eca9056580d878d8f7c89d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkaccessmanager_p.h @@ -0,0 +1,141 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKACCESSMANAGER_P_H +#define QNETWORKACCESSMANAGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qnetworkaccessmanager.h" +#include "qnetworkaccesscache_p.h" +#include "qnetworkaccessbackend_p.h" +#include "private/qnetconmonitor_p.h" +#include "qnetworkrequest.h" +#include "qhsts_p.h" +#include "private/qobject_p.h" +#include "QtNetwork/qnetworkproxy.h" +#include "qnetworkaccessauthenticationmanager_p.h" + +#if QT_CONFIG(settings) +#include "qhstsstore_p.h" +#endif // QT_CONFIG(settings) + +QT_BEGIN_NAMESPACE + +class QAuthenticator; +class QAbstractNetworkCache; +class QNetworkAuthenticationCredential; +class QNetworkCookieJar; + +class QNetworkAccessManagerPrivate: public QObjectPrivate +{ +public: + QNetworkAccessManagerPrivate() + : networkCache(nullptr), + cookieJar(nullptr), + thread(nullptr), +#ifndef QT_NO_NETWORKPROXY + proxyFactory(nullptr), +#endif + cookieJarCreated(false), + defaultAccessControl(true), + redirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy), + authenticationManager(std::make_shared<QNetworkAccessAuthenticationManager>()) + { + } + ~QNetworkAccessManagerPrivate(); + + QThread * createThread(); + void destroyThread(); + + void _q_replyFinished(QNetworkReply *reply); + void _q_replyEncrypted(QNetworkReply *reply); + void _q_replySslErrors(const QList<QSslError> &errors); + void _q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator); + QNetworkReply *postProcess(QNetworkReply *reply); + void createCookieJar() const; + + void authenticationRequired(QAuthenticator *authenticator, + QNetworkReply *reply, + bool synchronous, + QUrl &url, + QUrl *urlForLastAuthentication, + bool allowAuthenticationReuse = true); + void cacheCredentials(const QUrl &url, const QAuthenticator *auth); + QNetworkAuthenticationCredential *fetchCachedCredentials(const QUrl &url, + const QAuthenticator *auth = nullptr); + +#ifndef QT_NO_NETWORKPROXY + void proxyAuthenticationRequired(const QUrl &url, + const QNetworkProxy &proxy, + bool synchronous, + QAuthenticator *authenticator, + QNetworkProxy *lastProxyAuthentication); + void cacheProxyCredentials(const QNetworkProxy &proxy, const QAuthenticator *auth); + QNetworkAuthenticationCredential *fetchCachedProxyCredentials(const QNetworkProxy &proxy, + const QAuthenticator *auth = nullptr); + QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query); +#endif + + QNetworkAccessBackend *findBackend(QNetworkAccessManager::Operation op, const QNetworkRequest &request); + QStringList backendSupportedSchemes() const; + +#if QT_CONFIG(http) || defined(Q_OS_WASM) + QNetworkRequest prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart); +#endif + + void ensureBackendPluginsLoaded(); + + // this is the cache for storing downloaded files + QAbstractNetworkCache *networkCache; + + QNetworkCookieJar *cookieJar; + + QThread *thread; + + +#ifndef QT_NO_NETWORKPROXY + QNetworkProxy proxy; + QNetworkProxyFactory *proxyFactory; +#endif + + bool cookieJarCreated; + bool defaultAccessControl; + QNetworkRequest::RedirectPolicy redirectPolicy = QNetworkRequest::NoLessSafeRedirectPolicy; + + // The cache with authorization data: + std::shared_ptr<QNetworkAccessAuthenticationManager> authenticationManager; + + // this cache can be used by individual backends to cache e.g. their TCP connections to a server + // and use the connections for multiple requests. + QNetworkAccessCache objectCache; + + Q_AUTOTEST_EXPORT static void clearAuthenticationCache(QNetworkAccessManager *manager); + Q_AUTOTEST_EXPORT static void clearConnectionCache(QNetworkAccessManager *manager); + + QHstsCache stsCache; +#if QT_CONFIG(settings) + QScopedPointer<QHstsStore> stsStore; +#endif // QT_CONFIG(settings) + bool stsEnabled = false; + + bool autoDeleteReplies = false; + + std::chrono::milliseconds transferTimeout{0}; + + Q_DECLARE_PUBLIC(QNetworkAccessManager) +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkcookie_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkcookie_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e2f46a18291b5aa76d94ae2ef54ef62c7908cc5d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkcookie_p.h @@ -0,0 +1,65 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKCOOKIE_P_H +#define QNETWORKCOOKIE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access framework. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "QtCore/qdatetime.h" +#include "QtNetwork/qnetworkcookie.h" + +QT_BEGIN_NAMESPACE + +class QNetworkCookiePrivate: public QSharedData +{ +public: + QNetworkCookiePrivate() = default; + static QList<QNetworkCookie> parseSetCookieHeaderLine(QByteArrayView cookieString); + + QDateTime expirationDate; + QString domain; + QString path; + QString comment; + QByteArray name; + QByteArray value; + QNetworkCookie::SameSite sameSite = QNetworkCookie::SameSite::Default; + bool secure = false; + bool httpOnly = false; +}; + +static inline bool isLWS(char c) +{ + return c == ' ' || c == '\t' || c == '\r' || c == '\n'; +} + +static int nextNonWhitespace(QByteArrayView text, int from) +{ + // RFC 2616 defines linear whitespace as: + // LWS = [CRLF] 1*( SP | HT ) + // We ignore the fact that CRLF must come as a pair at this point + // It's an invalid HTTP header if that happens. + while (from < text.size()) { + if (isLWS(text.at(from))) + ++from; + else + return from; // non-whitespace + } + + // reached the end + return text.size(); +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkcookiejar_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkcookiejar_p.h new file mode 100644 index 0000000000000000000000000000000000000000..539e5c83919d27acac41233e8d596f0606ff8779 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkcookiejar_p.h @@ -0,0 +1,34 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKCOOKIEJAR_P_H +#define QNETWORKCOOKIEJAR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access framework. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "private/qobject_p.h" +#include "qnetworkcookie.h" + +QT_BEGIN_NAMESPACE + +class QNetworkCookieJarPrivate: public QObjectPrivate +{ +public: + QList<QNetworkCookie> allCookies; + + Q_DECLARE_PUBLIC(QNetworkCookieJar) +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkdatagram_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkdatagram_p.h new file mode 100644 index 0000000000000000000000000000000000000000..606c5e7257e3a05e1e5abb48f3b1aa520a83fd7b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkdatagram_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2015 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKDATAGRAM_P_H +#define QNETWORKDATAGRAM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtNetwork/qhostaddress.h> + +QT_BEGIN_NAMESPACE + +class QIpPacketHeader +{ +public: + QIpPacketHeader(const QHostAddress &dstAddr = QHostAddress(), quint16 port = 0) + : destinationAddress(dstAddr), destinationPort(port) + {} + + void clear() + { + senderAddress.clear(); + destinationAddress.clear(); + ifindex = 0; + hopLimit = -1; + streamNumber = -1; + endOfRecord = false; + } + + QHostAddress senderAddress; + QHostAddress destinationAddress; + + uint ifindex = 0; + int hopLimit = -1; + int streamNumber = -1; + quint16 senderPort = 0; + quint16 destinationPort; + bool endOfRecord = false; +}; + +class QNetworkDatagramPrivate +{ +public: + QNetworkDatagramPrivate(const QByteArray &data = QByteArray(), + const QHostAddress &dstAddr = QHostAddress(), quint16 port = 0) + : data(data), header(dstAddr, port) + {} + QNetworkDatagramPrivate(const QByteArray &data, const QIpPacketHeader &header) + : data(data), header(header) + {} + + QByteArray data; + QIpPacketHeader header; +}; + +QT_END_NAMESPACE + +#endif // QNETWORKDATAGRAM_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkdiskcache_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkdiskcache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a4e59e934b94a09d898cc23d72947880e154d8d0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkdiskcache_p.h @@ -0,0 +1,85 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKDISKCACHE_P_H +#define QNETWORKDISKCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "private/qabstractnetworkcache_p.h" + +#include <qbuffer.h> +#include <qhash.h> +#include <qsavefile.h> + +QT_REQUIRE_CONFIG(networkdiskcache); + +QT_BEGIN_NAMESPACE + +class QCacheItem +{ +public: + QCacheItem() = default; + ~QCacheItem() + { + reset(); + } + + QNetworkCacheMetaData metaData; + QBuffer data; + QSaveFile *file = nullptr; + inline qint64 size() const + { return file ? file->size() : data.size(); } + + inline void reset() { + metaData = QNetworkCacheMetaData(); + data.close(); + delete file; + file = nullptr; + } + void writeHeader(QFileDevice *device) const; + void writeCompressedData(QFileDevice *device) const; + bool read(QFileDevice *device, bool readData); + + bool canCompress() const; +}; + +class QNetworkDiskCachePrivate : public QAbstractNetworkCachePrivate +{ +public: + QNetworkDiskCachePrivate() + : QAbstractNetworkCachePrivate() + , maximumCacheSize(1024 * 1024 * 50) + , currentCacheSize(-1) + {} + + static QString uniqueFileName(const QUrl &url); + QString cacheFileName(const QUrl &url) const; + bool removeFile(const QString &file); + void storeItem(QCacheItem *item); + void prepareLayout(); + static quint32 crc32(const char *data, uint len); + + mutable QCacheItem lastItem; + QString cacheDirectory; + QString dataDirectory; + qint64 maximumCacheSize; + qint64 currentCacheSize; + + QHash<QIODevice*, QCacheItem*> inserting; + Q_DECLARE_PUBLIC(QNetworkDiskCache) +}; + +QT_END_NAMESPACE + +#endif // QNETWORKDISKCACHE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkfile_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkfile_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0469ba605aaf96696e6201f1dd7434af2d2e0ca1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkfile_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKFILE_H +#define QNETWORKFILE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QFile> +#include <qnetworkreply.h> + +QT_BEGIN_NAMESPACE + +class QNetworkFile : public QFile +{ + Q_OBJECT +public: + QNetworkFile(); + QNetworkFile(const QString &name); + using QFile::open; + +public Q_SLOTS: + void open(); + void close() override; + +Q_SIGNALS: + void finished(bool ok); + void headerRead(QHttpHeaders::WellKnownHeader, const QByteArray &value); + void networkError(QNetworkReply::NetworkError error, const QString &message); +}; + +QT_END_NAMESPACE + +#endif // QNETWORKFILE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkinformation_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkinformation_p.h new file mode 100644 index 0000000000000000000000000000000000000000..94109444197c1fc01c4527809c6321412f77c966 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkinformation_p.h @@ -0,0 +1,156 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKINFORMATION_P_H +#define QNETWORKINFORMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Information API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include <QtNetwork/qnetworkinformation.h> + +#include <QtCore/qloggingcategory.h> +#include <QtCore/qreadwritelock.h> + +QT_BEGIN_NAMESPACE + +class Q_NETWORK_EXPORT QNetworkInformationBackend : public QObject +{ + Q_OBJECT + + using Reachability = QNetworkInformation::Reachability; + using TransportMedium = QNetworkInformation::TransportMedium; + +public: + static inline const char16_t PluginNames[4][22] = { + { u"networklistmanager" }, + { u"scnetworkreachability" }, + { u"android" }, + { u"networkmanager" }, + }; + static constexpr int PluginNamesWindowsIndex = 0; + static constexpr int PluginNamesAppleIndex = 1; + static constexpr int PluginNamesAndroidIndex = 2; + static constexpr int PluginNamesLinuxIndex = 3; + + QNetworkInformationBackend() = default; + ~QNetworkInformationBackend() override; + + virtual QString name() const = 0; + virtual QNetworkInformation::Features featuresSupported() const = 0; + + Reachability reachability() const + { + QReadLocker locker(&m_lock); + return m_reachability; + } + + bool behindCaptivePortal() const + { + QReadLocker locker(&m_lock); + return m_behindCaptivePortal; + } + + TransportMedium transportMedium() const + { + QReadLocker locker(&m_lock); + return m_transportMedium; + } + + bool isMetered() const + { + QReadLocker locker(&m_lock); + return m_metered; + } + +Q_SIGNALS: + void reachabilityChanged(QNetworkInformation::Reachability reachability); + void behindCaptivePortalChanged(bool behindPortal); + void transportMediumChanged(QNetworkInformation::TransportMedium medium); + void isMeteredChanged(bool isMetered); + +protected: + void setReachability(QNetworkInformation::Reachability reachability) + { + QWriteLocker locker(&m_lock); + if (m_reachability != reachability) { + m_reachability = reachability; + locker.unlock(); + emit reachabilityChanged(reachability); + } + } + + void setBehindCaptivePortal(bool behindPortal) + { + QWriteLocker locker(&m_lock); + if (m_behindCaptivePortal != behindPortal) { + m_behindCaptivePortal = behindPortal; + locker.unlock(); + emit behindCaptivePortalChanged(behindPortal); + } + } + + void setTransportMedium(TransportMedium medium) + { + QWriteLocker locker(&m_lock); + if (m_transportMedium != medium) { + m_transportMedium = medium; + locker.unlock(); + emit transportMediumChanged(medium); + } + } + + void setMetered(bool isMetered) + { + QWriteLocker locker(&m_lock); + if (m_metered != isMetered) { + m_metered = isMetered; + locker.unlock(); + emit isMeteredChanged(isMetered); + } + } + +private: + mutable QReadWriteLock m_lock; + Reachability m_reachability = Reachability::Unknown; + TransportMedium m_transportMedium = TransportMedium::Unknown; + bool m_behindCaptivePortal = false; + bool m_metered = false; + + Q_DISABLE_COPY_MOVE(QNetworkInformationBackend) + friend class QNetworkInformation; + friend class QNetworkInformationPrivate; +}; + +class Q_NETWORK_EXPORT QNetworkInformationBackendFactory : public QObject +{ + Q_OBJECT + + using Features = QNetworkInformation::Features; + +public: + QNetworkInformationBackendFactory(); + virtual ~QNetworkInformationBackendFactory(); + virtual QString name() const = 0; + virtual QNetworkInformationBackend *create(Features requiredFeatures) const = 0; + virtual Features featuresSupported() const = 0; + +private: + Q_DISABLE_COPY_MOVE(QNetworkInformationBackendFactory) +}; +#define QNetworkInformationBackendFactory_iid "org.qt-project.Qt.NetworkInformationBackendFactory" +Q_DECLARE_INTERFACE(QNetworkInformationBackendFactory, QNetworkInformationBackendFactory_iid); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkinterface_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkinterface_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3da40ad1653e57023e74e235dea7af962d64869c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkinterface_p.h @@ -0,0 +1,112 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKINTERFACEPRIVATE_H +#define QNETWORKINTERFACEPRIVATE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtNetwork/qnetworkinterface.h> +#include <QtCore/qatomic.h> +#include <QtCore/qdeadlinetimer.h> +#include <QtCore/qlist.h> +#include <QtCore/qstring.h> +#include <QtNetwork/qhostaddress.h> +#include <QtNetwork/qabstractsocket.h> +#include <private/qhostaddress_p.h> + +#ifndef QT_NO_NETWORKINTERFACE + +QT_BEGIN_NAMESPACE + +class QNetworkAddressEntryPrivate +{ +public: + QHostAddress address; + QHostAddress broadcast; + QDeadlineTimer preferredLifetime = QDeadlineTimer::Forever; + QDeadlineTimer validityLifetime = QDeadlineTimer::Forever; + + QNetmask netmask; + bool lifetimeKnown = false; + QNetworkAddressEntry::DnsEligibilityStatus dnsEligibility = QNetworkAddressEntry::DnsEligibilityUnknown; +}; + +class QNetworkInterfacePrivate: public QSharedData +{ +public: + QNetworkInterfacePrivate() : index(0) + { } + ~QNetworkInterfacePrivate() + { } + + int index; // interface index, if know + int mtu = 0; + QNetworkInterface::InterfaceFlags flags; + QNetworkInterface::InterfaceType type = QNetworkInterface::Unknown; + + QString name; + QString friendlyName; + QString hardwareAddress; + + QList<QNetworkAddressEntry> addressEntries; + + static QString makeHwAddress(int len, uchar *data); + static void calculateDnsEligibility(QNetworkAddressEntry *entry, bool isTemporary, + bool isDeprecated) + { + // this implements an algorithm that yields the same results as Windows + // produces, for the same input (as far as I can test) + if (isTemporary || isDeprecated) { + entry->setDnsEligibility(QNetworkAddressEntry::DnsIneligible); + } else { + AddressClassification cl = QHostAddressPrivate::classify(entry->ip()); + if (cl == LoopbackAddress || cl == LinkLocalAddress) + entry->setDnsEligibility(QNetworkAddressEntry::DnsIneligible); + else + entry->setDnsEligibility(QNetworkAddressEntry::DnsEligible); + } + } + +private: + // disallow copying -- avoid detaching + QNetworkInterfacePrivate &operator=(const QNetworkInterfacePrivate &other); + QNetworkInterfacePrivate(const QNetworkInterfacePrivate &other); +}; + +class QNetworkInterfaceManager +{ +public: + QNetworkInterfaceManager(); + ~QNetworkInterfaceManager(); + + QSharedDataPointer<QNetworkInterfacePrivate> interfaceFromName(const QString &name); + QSharedDataPointer<QNetworkInterfacePrivate> interfaceFromIndex(int index); + QList<QSharedDataPointer<QNetworkInterfacePrivate> > allInterfaces(); + + static uint interfaceIndexFromName(const QString &name); + static QString interfaceNameFromIndex(uint index); + + // convenience: + QSharedDataPointer<QNetworkInterfacePrivate> empty; + +private: + QList<QNetworkInterfacePrivate *> scan(); +}; + + +QT_END_NAMESPACE + +#endif // QT_NO_NETWORKINTERFACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkinterface_unix_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkinterface_unix_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2791e403e618b4ace8f64e329fa0f777257c9ad1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkinterface_unix_p.h @@ -0,0 +1,66 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKINTERFACE_UNIX_P_H +#define QNETWORKINTERFACE_UNIX_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qnetworkinterface_p.h" +#include "private/qnet_unix_p.h" + +#ifndef QT_NO_NETWORKINTERFACE + +#define IP_MULTICAST // make AIX happy and define IFF_MULTICAST + +#include <sys/types.h> +#include <sys/socket.h> +#ifdef Q_OS_SOLARIS +# include <sys/sockio.h> +#endif +#ifdef Q_OS_HAIKU +# include <sys/sockio.h> +# define IFF_RUNNING 0x0001 +#endif +#if QT_CONFIG(linux_netlink) +// Same as net/if.h but contains other things we need in +// qnetworkinterface_linux.cpp. +# include <linux/if.h> +#else +# include <net/if.h> +#endif + +QT_BEGIN_NAMESPACE + +static QNetworkInterface::InterfaceFlags convertFlags(uint rawFlags) +{ + QNetworkInterface::InterfaceFlags flags; + flags |= (rawFlags & IFF_UP) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0); + flags |= (rawFlags & IFF_RUNNING) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0); + flags |= (rawFlags & IFF_BROADCAST) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0); + flags |= (rawFlags & IFF_LOOPBACK) ? QNetworkInterface::IsLoopBack : QNetworkInterface::InterfaceFlag(0); +#ifdef IFF_POINTOPOINT //cygwin doesn't define IFF_POINTOPOINT + flags |= (rawFlags & IFF_POINTOPOINT) ? QNetworkInterface::IsPointToPoint : QNetworkInterface::InterfaceFlag(0); +#endif + +#ifdef IFF_MULTICAST + flags |= (rawFlags & IFF_MULTICAST) ? QNetworkInterface::CanMulticast : QNetworkInterface::InterfaceFlag(0); +#endif + return flags; +} + +QT_END_NAMESPACE + +#endif // QT_NO_NETWORKINTERFACE + +#endif // QNETWORKINTERFACE_UNIX_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreply_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreply_p.h new file mode 100644 index 0000000000000000000000000000000000000000..60f2abbd5324cef9174e87fef758ffc0883f3fd4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreply_p.h @@ -0,0 +1,61 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKREPLY_P_H +#define QNETWORKREPLY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qnetworkrequest.h" +#include "qnetworkrequest_p.h" +#include "qnetworkreply.h" +#include "QtCore/qpointer.h" +#include <QtCore/QElapsedTimer> +#include "private/qiodevice_p.h" + +QT_BEGIN_NAMESPACE + +class QNetworkReplyPrivate: public QIODevicePrivate, public QNetworkHeadersPrivate +{ +public: + enum State { + Idle, // The reply is idle. + Buffering, // The reply is buffering outgoing data. + Working, // The reply is uploading/downloading data. + Finished, // The reply has finished. + Aborted, // The reply has been aborted. + }; + + QNetworkReplyPrivate(); + QNetworkRequest request; + QNetworkRequest originalRequest; + QUrl url; + QPointer<QNetworkAccessManager> manager; + qint64 readBufferMaxSize; + QElapsedTimer downloadProgressSignalChoke; + QElapsedTimer uploadProgressSignalChoke; + bool emitAllUploadProgressSignals; + const static int progressSignalInterval; + QNetworkAccessManager::Operation operation; + QNetworkReply::NetworkError errorCode; + bool isFinished; + + static inline void setManager(QNetworkReply *reply, QNetworkAccessManager *manager) + { reply->d_func()->manager = manager; } + + Q_DECLARE_PUBLIC(QNetworkReply) +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplydataimpl_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplydataimpl_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d787a3957c9bcc57c1ae2198957fa6050998bfd3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplydataimpl_p.h @@ -0,0 +1,60 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKREPLYDATAIMPL_H +#define QNETWORKREPLYDATAIMPL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qnetworkreply.h" +#include "qnetworkreply_p.h" +#include "qnetworkaccessmanager.h" +#include <QBuffer> + +QT_BEGIN_NAMESPACE + + +class QNetworkReplyDataImplPrivate; +class QNetworkReplyDataImpl: public QNetworkReply +{ + Q_OBJECT +public: + QNetworkReplyDataImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op); + ~QNetworkReplyDataImpl(); + virtual void abort() override; + + // reimplemented from QNetworkReply + virtual void close() override; + virtual qint64 bytesAvailable() const override; + virtual bool isSequential () const override; + qint64 size() const override; + + virtual qint64 readData(char *data, qint64 maxlen) override; + + Q_DECLARE_PRIVATE(QNetworkReplyDataImpl) +}; + +class QNetworkReplyDataImplPrivate: public QNetworkReplyPrivate +{ +public: + QNetworkReplyDataImplPrivate(); + ~QNetworkReplyDataImplPrivate(); + + QBuffer decodedData; + + Q_DECLARE_PUBLIC(QNetworkReplyDataImpl) +}; + +QT_END_NAMESPACE + +#endif // QNETWORKREPLYDATAIMPL_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplyfileimpl_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplyfileimpl_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cc1678c173f08d524ec45b4af2803d6f4b74bf31 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplyfileimpl_p.h @@ -0,0 +1,70 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKREPLYFILEIMPL_P_H +#define QNETWORKREPLYFILEIMPL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qnetworkreply.h" +#include "qnetworkreply_p.h" +#include "qnetworkaccessmanager.h" + +#include <QFile> +#include <QtCore/qpointer.h> +#include <private/qabstractfileengine_p.h> + +QT_BEGIN_NAMESPACE + +class QNetworkReplyFileImplPrivate; +class QNetworkReplyFileImpl: public QNetworkReply +{ + Q_OBJECT +public: + QNetworkReplyFileImpl(QNetworkAccessManager *manager, const QNetworkRequest &req, const QNetworkAccessManager::Operation op); + ~QNetworkReplyFileImpl(); + virtual void abort() override; + + // reimplemented from QNetworkReply + virtual void close() override; + virtual qint64 bytesAvailable() const override; + virtual bool isSequential () const override; + qint64 size() const override; + + virtual qint64 readData(char *data, qint64 maxlen) override; + +private Q_SLOTS: + void fileOpenFinished(bool isOpen); + +private: + Q_DECLARE_PRIVATE(QNetworkReplyFileImpl) +}; + +class QNetworkReplyFileImplPrivate: public QNetworkReplyPrivate +{ +public: + QNetworkReplyFileImplPrivate(); + + QNetworkAccessManagerPrivate *managerPrivate; + QPointer<QFile> realFile; + + Q_DECLARE_PUBLIC(QNetworkReplyFileImpl) +}; + +QT_END_NAMESPACE + +// ### move to qnetworkrequest.h +QT_DECL_METATYPE_EXTERN_TAGGED(QNetworkRequest::KnownHeaders, + QNetworkRequest__KnownHeaders, Q_NETWORK_EXPORT) + +#endif // QNETWORKREPLYFILEIMPL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplyhttpimpl_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplyhttpimpl_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0aef99c7778ee94668ef4b837521c99e9cee41ea --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplyhttpimpl_p.h @@ -0,0 +1,275 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKREPLYHTTPIMPL_P_H +#define QNETWORKREPLYHTTPIMPL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qnetworkrequest.h" +#include "qnetworkreply.h" + +#include "QtCore/qpointer.h" +#include "QtCore/qdatetime.h" +#include "QtCore/qsharedpointer.h" +#include "QtCore/qscopedpointer.h" +#include "QtCore/qtimer.h" +#include "qatomic.h" + +#include <QtNetwork/QNetworkCacheMetaData> +#include <private/qhttpnetworkrequest_p.h> +#include <private/qnetworkreply_p.h> +#include <QtNetwork/QNetworkProxy> + +#ifndef QT_NO_SSL +#include <QtNetwork/QSslConfiguration> +#endif + +Q_MOC_INCLUDE(<QtNetwork/QAuthenticator>) + +#include <private/qdecompresshelper_p.h> + +#include <memory> + +QT_REQUIRE_CONFIG(http); + +QT_BEGIN_NAMESPACE + +class QIODevice; + +class QNetworkReplyHttpImplPrivate; +class QNetworkReplyHttpImpl: public QNetworkReply +{ + Q_OBJECT +public: + QNetworkReplyHttpImpl(QNetworkAccessManager* const, const QNetworkRequest&, QNetworkAccessManager::Operation&, QIODevice* outgoingData); + virtual ~QNetworkReplyHttpImpl(); + + void close() override; + void abort() override; + qint64 bytesAvailable() const override; + bool isSequential () const override; + qint64 size() const override; + qint64 readData(char*, qint64) override; + void setReadBufferSize(qint64 size) override; + bool canReadLine () const override; + + Q_DECLARE_PRIVATE(QNetworkReplyHttpImpl) + Q_PRIVATE_SLOT(d_func(), void _q_startOperation()) + Q_PRIVATE_SLOT(d_func(), void _q_cacheLoadReadyRead()) + Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingData()) + Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingDataFinished()) + Q_PRIVATE_SLOT(d_func(), void _q_transferTimedOut()) + Q_PRIVATE_SLOT(d_func(), void _q_finished()) + Q_PRIVATE_SLOT(d_func(), void _q_error(QNetworkReply::NetworkError, const QString &)) + + // From reply + Q_PRIVATE_SLOT(d_func(), void replyDownloadData(QByteArray)) + Q_PRIVATE_SLOT(d_func(), void replyFinished()) + Q_PRIVATE_SLOT(d_func(), void replyDownloadProgressSlot(qint64,qint64)) + Q_PRIVATE_SLOT(d_func(), void httpAuthenticationRequired(const QHttpNetworkRequest &, QAuthenticator *)) + Q_PRIVATE_SLOT(d_func(), void httpError(QNetworkReply::NetworkError, const QString &)) +#ifndef QT_NO_SSL + Q_PRIVATE_SLOT(d_func(), void replyEncrypted()) + Q_PRIVATE_SLOT(d_func(), void replySslErrors(const QList<QSslError> &, bool *, QList<QSslError> *)) + Q_PRIVATE_SLOT(d_func(), void replySslConfigurationChanged(const QSslConfiguration&)) + Q_PRIVATE_SLOT(d_func(), void replyPreSharedKeyAuthenticationRequiredSlot(QSslPreSharedKeyAuthenticator *)) +#endif +#ifndef QT_NO_NETWORKPROXY + Q_PRIVATE_SLOT(d_func(), void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth)) +#endif + + Q_PRIVATE_SLOT(d_func(), void resetUploadDataSlot(bool *r)) + Q_PRIVATE_SLOT(d_func(), void wantUploadDataSlot(qint64)) + Q_PRIVATE_SLOT(d_func(), void sentUploadDataSlot(qint64,qint64)) + Q_PRIVATE_SLOT(d_func(), void uploadByteDeviceReadyReadSlot()) + Q_PRIVATE_SLOT(d_func(), void emitReplyUploadProgress(qint64, qint64)) + Q_PRIVATE_SLOT(d_func(), void _q_cacheSaveDeviceAboutToClose()) + Q_PRIVATE_SLOT(d_func(), void _q_metaDataChanged()) + Q_PRIVATE_SLOT(d_func(), void onRedirected(const QUrl &, int, int)) + Q_PRIVATE_SLOT(d_func(), void followRedirect()) + +#ifndef QT_NO_SSL +protected: + void ignoreSslErrors() override; + void ignoreSslErrorsImplementation(const QList<QSslError> &errors) override; + void setSslConfigurationImplementation(const QSslConfiguration &configuration) override; + void sslConfigurationImplementation(QSslConfiguration &configuration) const override; +#endif + +signals: + // To HTTP thread: + void startHttpRequest(); + void abortHttpRequest(); + void readBufferSizeChanged(qint64 size); + void readBufferFreed(qint64 size); + + void startHttpRequestSynchronously(); + + void haveUploadData(const qint64 pos, const QByteArray &dataArray, bool dataAtEnd, qint64 dataSize); +}; + +class QNetworkReplyHttpImplPrivate: public QNetworkReplyPrivate +{ +public: + + static QHttpNetworkRequest::Priority convert(QNetworkRequest::Priority prio); + + QNetworkReplyHttpImplPrivate(); + ~QNetworkReplyHttpImplPrivate(); + + void _q_startOperation(); + + void _q_cacheLoadReadyRead(); + + void _q_bufferOutgoingData(); + void _q_bufferOutgoingDataFinished(); + + void _q_cacheSaveDeviceAboutToClose(); + + void _q_transferTimedOut(); + void setupTransferTimeout(); + + void _q_finished(); + + void finished(); + void error(QNetworkReply::NetworkError code, const QString &errorString); + void _q_error(QNetworkReply::NetworkError code, const QString &errorString); + void _q_metaDataChanged(); + + void checkForRedirect(const int statusCode); + + // incoming from user + QNetworkAccessManager *manager; + QNetworkAccessManagerPrivate *managerPrivate; + QHttpNetworkRequest httpRequest; // There is also a copy in the HTTP thread + bool synchronous; + + State state; + + // from http thread + int statusCode; + QString reasonPhrase; + + // upload + QNonContiguousByteDevice* createUploadByteDevice(); + std::shared_ptr<QNonContiguousByteDevice> uploadByteDevice; + qint64 uploadByteDevicePosition; + bool uploadDeviceChoking; // if we couldn't readPointer() any data at the moment + QIODevice *outgoingData; + std::shared_ptr<QRingBuffer> outgoingDataBuffer; + void emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal); // dup? + void onRedirected(const QUrl &redirectUrl, int httpStatus, int maxRedirectsRemainig); + void followRedirect(); + qint64 bytesUploaded; + + + // cache + void createCache(); + void completeCacheSave(); + void setCachingEnabled(bool enable); + bool isCachingEnabled() const; + bool isCachingAllowed() const; + void initCacheSaveDevice(); + QIODevice *cacheLoadDevice; + bool loadingFromCache; + + QIODevice *cacheSaveDevice; + bool cacheEnabled; // is this for saving? + + + QUrl urlForLastAuthentication; +#ifndef QT_NO_NETWORKPROXY + QNetworkProxy lastProxyAuthentication; +#endif + + + bool canResume() const; + void setResumeOffset(quint64 offset); + quint64 resumeOffset; + + qint64 bytesDownloaded; + qint64 bytesBuffered; + // We use this to keep track of whether or not we need to emit readyRead + // when we deal with signal compression (delaying emission) + decompressing + // data (potentially receiving bytes that don't end up in the final output): + qint64 lastReadyReadEmittedSize = 0; + + QTimer *transferTimeout; + + // Only used when the "zero copy" style is used. + // Please note that the whole "zero copy" download buffer API is private right now. Do not use it. + qint64 downloadBufferReadPosition; + qint64 downloadBufferCurrentSize; + QSharedPointer<char> downloadBufferPointer; + char* downloadZerocopyBuffer; + + // Will be increased by HTTP thread: + std::shared_ptr<QAtomicInt> pendingDownloadDataEmissions; + std::shared_ptr<QAtomicInt> pendingDownloadProgressEmissions; + + +#ifndef QT_NO_SSL + QScopedPointer<QSslConfiguration> sslConfiguration; + bool pendingIgnoreAllSslErrors; + QList<QSslError> pendingIgnoreSslErrorsList; +#endif + + QNetworkRequest redirectRequest; + + QDecompressHelper decompressHelper; + + bool loadFromCacheIfAllowed(QHttpNetworkRequest &httpRequest); + void invalidateCache(); + bool sendCacheContents(const QNetworkCacheMetaData &metaData); + QNetworkCacheMetaData fetchCacheMetaData(const QNetworkCacheMetaData &metaData) const; + + + void postRequest(const QNetworkRequest& newHttpRequest); + QNetworkAccessManager::Operation getRedirectOperation(QNetworkAccessManager::Operation currentOp, int httpStatus); + QNetworkRequest createRedirectRequest(const QNetworkRequest &originalRequests, const QUrl &url, int maxRedirectsRemainig); + bool isHttpRedirectResponse() const; + +public: + // From HTTP thread: + void replyDownloadData(QByteArray); + void replyFinished(); + void replyDownloadMetaData(const QHttpHeaders &, int, const QString &, + bool, QSharedPointer<char>, qint64, qint64, bool, bool); + void replyDownloadProgressSlot(qint64,qint64); + void httpAuthenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *auth); + void httpError(QNetworkReply::NetworkError error, const QString &errorString); +#ifndef QT_NO_SSL + void replyEncrypted(); + void replySslErrors(const QList<QSslError> &, bool *, QList<QSslError> *); + void replySslConfigurationChanged(const QSslConfiguration &newSslConfiguration); + void replyPreSharedKeyAuthenticationRequiredSlot(QSslPreSharedKeyAuthenticator *); +#endif +#ifndef QT_NO_NETWORKPROXY + void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); +#endif + + // From QNonContiguousByteDeviceThreadForwardImpl in HTTP thread: + void resetUploadDataSlot(bool *r); + void wantUploadDataSlot(qint64); + void sentUploadDataSlot(qint64, qint64); + + // From user's QNonContiguousByteDevice + void uploadByteDeviceReadyReadSlot(); + + Q_DECLARE_PUBLIC(QNetworkReplyHttpImpl) +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplyimpl_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplyimpl_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f5893b1223ebd81531307a7b48b1cb152a54e841 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkreplyimpl_p.h @@ -0,0 +1,160 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKREPLYIMPL_P_H +#define QNETWORKREPLYIMPL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qnetworkreply.h" +#include "qnetworkreply_p.h" +#include "qnetworkaccessmanager.h" +#include "qnetworkproxy.h" +#include "QtCore/qmap.h" +#include "QtCore/qqueue.h" +#include "QtCore/qbuffer.h" +#include "private/qringbuffer_p.h" +#include "private/qbytedata_p.h" +#include <QSharedPointer> + +#include <memory> + +QT_BEGIN_NAMESPACE + +class QAbstractNetworkCache; +class QNetworkAccessBackend; + +class QNetworkReplyImplPrivate; +class QNetworkReplyImpl: public QNetworkReply +{ + Q_OBJECT +public: + QNetworkReplyImpl(QObject *parent = nullptr); + ~QNetworkReplyImpl(); + virtual void abort() override; + + // reimplemented from QNetworkReply / QIODevice + virtual void close() override; + virtual qint64 bytesAvailable() const override; + virtual void setReadBufferSize(qint64 size) override; + + virtual qint64 readData(char *data, qint64 maxlen) override; + virtual bool event(QEvent *) override; + + Q_DECLARE_PRIVATE(QNetworkReplyImpl) + Q_PRIVATE_SLOT(d_func(), void _q_startOperation()) + Q_PRIVATE_SLOT(d_func(), void _q_copyReadyRead()) + Q_PRIVATE_SLOT(d_func(), void _q_copyReadChannelFinished()) + Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingData()) + Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingDataFinished()) + +#ifndef QT_NO_SSL +protected: + void sslConfigurationImplementation(QSslConfiguration &configuration) const override; + void setSslConfigurationImplementation(const QSslConfiguration &configuration) override; + virtual void ignoreSslErrors() override; + virtual void ignoreSslErrorsImplementation(const QList<QSslError> &errors) override; +#endif +}; + +class QNetworkReplyImplPrivate: public QNetworkReplyPrivate +{ +public: + enum InternalNotifications { + NotifyDownstreamReadyWrite, + }; + + QNetworkReplyImplPrivate(); + + void _q_startOperation(); + void _q_copyReadyRead(); + void _q_copyReadChannelFinished(); + void _q_bufferOutgoingData(); + void _q_bufferOutgoingDataFinished(); + + void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request, + QIODevice *outgoingData); + + void pauseNotificationHandling(); + void resumeNotificationHandling(); + void backendNotify(InternalNotifications notification); + void handleNotifications(); + void createCache(); + void completeCacheSave(); + + // callbacks from the backend (through the manager): + void setCachingEnabled(bool enable); + bool isCachingEnabled() const; + void consume(qint64 count); + void emitUploadProgress(qint64 bytesSent, qint64 bytesTotal); + qint64 nextDownstreamBlockSize() const; + + void initCacheSaveDevice(); + void appendDownstreamDataSignalEmissions(); + void appendDownstreamData(QByteDataBuffer &data); + void appendDownstreamData(QIODevice *data); + + void setDownloadBuffer(QSharedPointer<char> sp, qint64 size); + char* getDownloadBuffer(qint64 size); + void appendDownstreamDataDownloadBuffer(qint64, qint64); + + void finished(); + void error(QNetworkReply::NetworkError code, const QString &errorString); + void metaDataChanged(); + void redirectionRequested(const QUrl &target); + void encrypted(); + void sslErrors(const QList<QSslError> &errors); + + void readFromBackend(); + + QNetworkAccessBackend *backend; + QIODevice *outgoingData; + std::shared_ptr<QRingBuffer> outgoingDataBuffer; + QIODevice *copyDevice; + QAbstractNetworkCache *networkCache() const; + + bool cacheEnabled; + QIODevice *cacheSaveDevice; + + std::vector<InternalNotifications> pendingNotifications; + bool notificationHandlingPaused; + + QUrl urlForLastAuthentication; +#ifndef QT_NO_NETWORKPROXY + QNetworkProxy lastProxyAuthentication; + QList<QNetworkProxy> proxyList; +#endif + + qint64 bytesDownloaded; + qint64 bytesUploaded; + + QString httpReasonPhrase; + int httpStatusCode; + + State state; + + // Only used when the "zero copy" style is used. + // Please note that the whole "zero copy" download buffer API is private right now. Do not use it. + qint64 downloadBufferReadPosition; + qint64 downloadBufferCurrentSize; + qint64 downloadBufferMaximumSize; + QSharedPointer<char> downloadBufferPointer; + char* downloadBuffer; + + Q_DECLARE_PUBLIC(QNetworkReplyImpl) +}; +Q_DECLARE_TYPEINFO(QNetworkReplyImplPrivate::InternalNotifications, Q_PRIMITIVE_TYPE); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkrequest_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkrequest_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fd9f57e5ac3b3b1ca61a7559e48cecb2a094ca3c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkrequest_p.h @@ -0,0 +1,91 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKREQUEST_P_H +#define QNETWORKREQUEST_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtNetwork/qhttpheaders.h> +#include "qnetworkrequest.h" +#include "QtCore/qbytearray.h" +#include "QtCore/qlist.h" +#include "QtCore/qhash.h" +#include "QtCore/qshareddata.h" +#include "QtCore/qsharedpointer.h" +#include "QtCore/qpointer.h" + +QT_BEGIN_NAMESPACE + +class QNetworkCookie; + +// this is the common part between QNetworkRequestPrivate, QNetworkReplyPrivate and QHttpPartPrivate +class QNetworkHeadersPrivate +{ +public: + typedef QPair<QByteArray, QByteArray> RawHeaderPair; + typedef QList<RawHeaderPair> RawHeadersList; + typedef QHash<QNetworkRequest::KnownHeaders, QVariant> CookedHeadersMap; + typedef QHash<QNetworkRequest::Attribute, QVariant> AttributesMap; + + mutable struct { + RawHeadersList headersList; + bool isCached = false; + } rawHeaderCache; + + QHttpHeaders httpHeaders; + CookedHeadersMap cookedHeaders; + AttributesMap attributes; + QPointer<QObject> originatingObject; + + const RawHeadersList &allRawHeaders() const; + QList<QByteArray> rawHeadersKeys() const; + QByteArray rawHeader(QAnyStringView headerName) const; + void setRawHeader(const QByteArray &key, const QByteArray &value); + void setCookedHeader(QNetworkRequest::KnownHeaders header, const QVariant &value); + + QHttpHeaders headers() const; + void setHeaders(const QHttpHeaders &newHeaders); + void setHeaders(QHttpHeaders &&newHeaders); + void setHeader(QHttpHeaders::WellKnownHeader name, QByteArrayView value); + + void clearHeaders(); + + static QDateTime fromHttpDate(QByteArrayView value); + static QByteArray toHttpDate(const QDateTime &dt); + + static std::optional<qint64> toInt(QByteArrayView value); + + typedef QList<QNetworkCookie> NetworkCookieList; + static QByteArray fromCookieList(const NetworkCookieList &cookies); + static std::optional<NetworkCookieList> toSetCookieList(const QList<QByteArray> &values); + static std::optional<NetworkCookieList> toCookieList(const QList<QByteArray> &values); + + static RawHeadersList fromHttpToRaw(const QHttpHeaders &headers); + static QHttpHeaders fromRawToHttp(const RawHeadersList &raw); + +private: + void invalidateHeaderCache(); + + void setCookedFromHttp(const QHttpHeaders &newHeaders); + void parseAndSetHeader(QByteArrayView key, QByteArrayView value); + void parseAndSetHeader(QNetworkRequest::KnownHeaders key, QByteArrayView value); + +}; + +Q_DECLARE_TYPEINFO(QNetworkHeadersPrivate::RawHeaderPair, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkrequestfactory_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkrequestfactory_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c74c2d299ec34384fec8481c2221bf7cb44d79af --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qnetworkrequestfactory_p.h @@ -0,0 +1,56 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QNETWORKREQUESTFACTORY_P_H +#define QNETWORKREQUESTFACTORY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access framework. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/qhttpheaders.h> +#include <QtNetwork/qnetworkrequest.h> +#if QT_CONFIG(ssl) +#include <QtNetwork/qsslconfiguration.h> +#endif +#include <QtCore/qhash.h> +#include <QtCore/qshareddata.h> +#include <QtCore/qurl.h> +#include <QtCore/qurlquery.h> +#include <QtCore/qvariant.h> + +QT_BEGIN_NAMESPACE + +class QNetworkRequestFactoryPrivate : public QSharedData +{ +public: + QNetworkRequestFactoryPrivate(); + explicit QNetworkRequestFactoryPrivate(const QUrl &baseUrl); + ~QNetworkRequestFactoryPrivate(); + QNetworkRequest newRequest(const QUrl &url) const; + QUrl requestUrl(const QString *path = nullptr, const QUrlQuery *query = nullptr) const; + +#if QT_CONFIG(ssl) + QSslConfiguration sslConfig; +#endif + QUrl baseUrl; + QHttpHeaders headers; + QByteArray bearerToken; + QString userName; + QString password; + QUrlQuery queryParameters; + QNetworkRequest::Priority priority = QNetworkRequest::NormalPriority; + std::chrono::milliseconds transferTimeout{0}; + QHash<QNetworkRequest::Attribute, QVariant> attributes; +}; + +QT_END_NAMESPACE + +#endif // QNETWORKREQUESTFACTORY_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qocsp_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qocsp_p.h new file mode 100644 index 0000000000000000000000000000000000000000..40cfc81d6a6986bcd572e808b66ba37f5feaf60d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qocsp_p.h @@ -0,0 +1,40 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOCSP_P_H +#define QOCSP_P_H + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// Note, this file is a workaround: on 64-bit Windows one of OpenSSL +// includes combined with openssl/ocsp.h results in macros from +// wincrypt.h exposed. OpenSSL's own very "unique" and "inventive" +// names like OCSP_RESPONSE or X509_NAME were asking to clash with +// other entities (presumably macros) with the same names. Normally, +// ossl_typ.h un-defines them, but due to a bug in OpenSSL, fails +// to do this on Win 64. Thus we have to do it here. We only undef +// 3 names, ossl_typ.h has more, but apparently we don't need them +// (no name clash so far). + +QT_REQUIRE_CONFIG(ocsp); + +#ifdef Q_OS_WIN +#undef X509_NAME +#undef OCSP_REQUEST +#undef OCSP_RESPONSE +#endif // Q_OS_WIN + +#include <openssl/ocsp.h> + +#endif // QOCSP_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qocspresponse_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qocspresponse_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7c5ab6ab9cb192b4949f5c70d8ffe12a5445ab18 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qocspresponse_p.h @@ -0,0 +1,49 @@ +// Copyright (C) 2011 Richard J. Moore <rich@kde.org> +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOCSPRESPONSE_P_H +#define QOCSPRESPONSE_P_H + +#include <private/qtnetworkglobal_p.h> + +#include <qsslcertificate.h> +#include <qocspresponse.h> + +#include <qshareddata.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QOcspResponsePrivate : public QSharedData +{ +public: + + QOcspCertificateStatus certificateStatus = QOcspCertificateStatus::Unknown; + QOcspRevocationReason revocationReason = QOcspRevocationReason::None; + + QSslCertificate signerCert; + QSslCertificate subjectCert; +}; + +inline bool operator==(const QOcspResponsePrivate &lhs, const QOcspResponsePrivate &rhs) +{ + return lhs.certificateStatus == rhs.certificateStatus + && lhs.revocationReason == rhs.revocationReason + && lhs.signerCert == rhs.signerCert + && lhs.subjectCert == rhs.subjectCert; +} + +QT_END_NAMESPACE + +#endif // QOCSPRESPONSE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qrestaccessmanager_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qrestaccessmanager_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ac1b07fed023f4b05289179bad8155ca0badc24d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qrestaccessmanager_p.h @@ -0,0 +1,93 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRESTACCESSMANAGER_P_H +#define QRESTACCESSMANAGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "qrestaccessmanager.h" +#include "private/qobject_p.h" + +#include <QtNetwork/qnetworkaccessmanager.h> + +#include <QtCore/qjsonarray.h> +#include <QtCore/qhash.h> +#include <QtCore/qjsondocument.h> +#include <QtCore/qjsonobject.h> +#include <QtCore/qxpfunctional.h> + +QT_BEGIN_NAMESPACE + +class QRestReply; +class QRestAccessManagerPrivate : public QObjectPrivate +{ +public: + QRestAccessManagerPrivate(); + ~QRestAccessManagerPrivate() override; + + QNetworkReply* createActiveRequest(QNetworkReply *reply, const QObject *contextObject, + QtPrivate::SlotObjUniquePtr slot); + void handleReplyFinished(QNetworkReply *reply); + + using ReqOpRef = qxp::function_ref<QNetworkReply*(QNetworkAccessManager*) const>; + QNetworkReply *executeRequest(ReqOpRef requestOperation, + const QObject *context, QtPrivate::QSlotObjectBase *rawSlot) + { + QtPrivate::SlotObjUniquePtr slot(rawSlot); + if (!qnam) + return warnNoAccessManager(); + verifyThreadAffinity(context); + QNetworkReply *reply = requestOperation(qnam); + return createActiveRequest(reply, context, std::move(slot)); + } + + using ReqOpRefJson = qxp::function_ref<QNetworkReply*(QNetworkAccessManager*, + const QNetworkRequest &, + const QByteArray &) const>; + QNetworkReply *executeRequest(ReqOpRefJson requestOperation, const QJsonDocument &jsonDoc, + const QNetworkRequest &request, + const QObject *context, QtPrivate::QSlotObjectBase *rawSlot) + { + QtPrivate::SlotObjUniquePtr slot(rawSlot); + if (!qnam) + return warnNoAccessManager(); + verifyThreadAffinity(context); + QNetworkRequest req(request); + auto h = req.headers(); + if (!h.contains(QHttpHeaders::WellKnownHeader::ContentType)) { + h.append(QHttpHeaders::WellKnownHeader::ContentType, + QLatin1StringView{"application/json"}); + } + req.setHeaders(std::move(h)); + QNetworkReply *reply = requestOperation(qnam, req, jsonDoc.toJson(QJsonDocument::Compact)); + return createActiveRequest(reply, context, std::move(slot)); + } + + void verifyThreadAffinity(const QObject *contextObject); + Q_DECL_COLD_FUNCTION + QNetworkReply* warnNoAccessManager(); + + struct CallerInfo { + QPointer<const QObject> contextObject = nullptr; + QtPrivate::SlotObjSharedPtr slot; + }; + QHash<QNetworkReply*, CallerInfo> activeRequests; + + QNetworkAccessManager *qnam = nullptr; + bool deletesRepliesOnFinished = true; + Q_DECLARE_PUBLIC(QRestAccessManager) +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qrestreply_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qrestreply_p.h new file mode 100644 index 0000000000000000000000000000000000000000..70873943c42509866f99390db22b6770e8256a3a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qrestreply_p.h @@ -0,0 +1,40 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRESTREPLY_P_H +#define QRESTREPLY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qstringconverter_p.h> + +#include <optional> + +QT_BEGIN_NAMESPACE + +class QByteArray; +class QNetworkReply; + +class QRestReplyPrivate +{ +public: + QRestReplyPrivate(); + ~QRestReplyPrivate(); + + std::optional<QStringDecoder> decoder; + + static QByteArray contentCharset(const QNetworkReply *reply); +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsocketabstraction_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsocketabstraction_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a85621d9c38e1f2b2003ebac8cd3a00e60790ede --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsocketabstraction_p.h @@ -0,0 +1,101 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSOCKETABSTRACTION_P_H +#define QSOCKETABSTRACTION_P_H + +#include <private/qtnetworkglobal_p.h> + +#include <QtNetwork/qabstractsocket.h> +#if QT_CONFIG(localserver) +# include <QtNetwork/qlocalsocket.h> +#endif + +#include <QtCore/qxpfunctional.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +// Helper functions to deal with a QIODevice that is either a socket or a local +// socket. +namespace QSocketAbstraction { +template <typename Fn, typename... Args> +auto visit(Fn &&fn, QIODevice *socket, Args &&...args) +{ + if (auto *s = qobject_cast<QAbstractSocket *>(socket)) + return std::forward<Fn>(fn)(s, std::forward<Args>(args)...); +#if QT_CONFIG(localserver) + if (auto *s = qobject_cast<QLocalSocket *>(socket)) + return std::forward<Fn>(fn)(s, std::forward<Args>(args)...); +#endif + Q_UNREACHABLE(); +} + +// Since QLocalSocket's LocalSocketState's values are defined as being equal +// to some of QAbstractSocket's SocketState's values, we can use the superset +// of the two as the return type. +inline QAbstractSocket::SocketState socketState(QIODevice *device) +{ + auto getState = [](auto *s) { + using T = std::remove_pointer_t<decltype(s)>; + if constexpr (std::is_same_v<T, QAbstractSocket>) { + return s->state(); +#if QT_CONFIG(localserver) + } else if constexpr (std::is_same_v<T, QLocalSocket>) { + QLocalSocket::LocalSocketState st = s->state(); + return static_cast<QAbstractSocket::SocketState>(st); +#endif + } + Q_UNREACHABLE(); + }; + return visit(getState, device); +} + +// Same as for socketState(), but for the errors +inline QAbstractSocket::SocketError socketError(QIODevice *device) +{ + auto getError = [](auto *s) { + using T = std::remove_pointer_t<decltype(s)>; + if constexpr (std::is_same_v<T, QAbstractSocket>) { + return s->error(); +#if QT_CONFIG(localserver) + } else if constexpr (std::is_same_v<T, QLocalSocket>) { + QLocalSocket::LocalSocketError st = s->error(); + return static_cast<QAbstractSocket::SocketError>(st); +#endif + } + Q_UNREACHABLE(); + }; + return visit(getError, device); +} + +inline QString socketPeerName(QIODevice *device) +{ + auto getPeerName = [](auto *s) { + using T = std::remove_pointer_t<decltype(s)>; + if constexpr (std::is_same_v<T, QAbstractSocket>) { + return s->peerName(); +#if QT_CONFIG(localserver) + } else if constexpr (std::is_same_v<T, QLocalSocket>) { + return s->serverName(); +#endif + } + Q_UNREACHABLE(); + }; + return visit(getPeerName, device); +} +} // namespace QSocketAbstraction + +QT_END_NAMESPACE + +#endif // QSOCKETABSTRACTION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsocks5socketengine_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsocks5socketengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c56509167e835f1319e9e3ed7497c85d16632268 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsocks5socketengine_p.h @@ -0,0 +1,265 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSOCKS5SOCKETENGINE_P_H +#define QSOCKS5SOCKETENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include <QtNetwork/qnetworkproxy.h> + +#include "qabstractsocketengine_p.h" + +QT_REQUIRE_CONFIG(socks5); + +QT_BEGIN_NAMESPACE + +class QSocks5SocketEnginePrivate; + +class Q_AUTOTEST_EXPORT QSocks5SocketEngine : public QAbstractSocketEngine +{ + Q_OBJECT +public: + QSocks5SocketEngine(QObject *parent = nullptr); + ~QSocks5SocketEngine(); + + bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) override; + bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState) override; + + void setProxy(const QNetworkProxy &networkProxy); + + qintptr socketDescriptor() const override; + + bool isValid() const override; + + bool connectInternal(); + bool connectToHost(const QHostAddress &address, quint16 port) override; + bool connectToHostByName(const QString &name, quint16 port) override; + bool bind(const QHostAddress &address, quint16 port) override; + bool listen(int backlog) override; + qintptr accept() override; + void close() override; + + qint64 bytesAvailable() const override; + + qint64 read(char *data, qint64 maxlen) override; + qint64 write(const char *data, qint64 len) override; + +#ifndef QT_NO_UDPSOCKET +#ifndef QT_NO_NETWORKINTERFACE + bool joinMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &interface) override; + bool leaveMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &interface) override; + QNetworkInterface multicastInterface() const override; + bool setMulticastInterface(const QNetworkInterface &iface) override; +#endif // QT_NO_NETWORKINTERFACE + + bool hasPendingDatagrams() const override; + qint64 pendingDatagramSize() const override; +#endif // QT_NO_UDPSOCKET + + qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader * = nullptr, + PacketHeaderOptions = WantNone) override; + qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) override; + qint64 bytesToWrite() const override; + + int option(SocketOption option) const override; + bool setOption(SocketOption option, int value) override; + + bool waitForRead(QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) override; + bool waitForWrite(QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) override; + bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, + bool checkRead, bool checkWrite, + QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, + bool *timedOut = nullptr) override; + + bool isReadNotificationEnabled() const override; + void setReadNotificationEnabled(bool enable) override; + bool isWriteNotificationEnabled() const override; + void setWriteNotificationEnabled(bool enable) override; + bool isExceptionNotificationEnabled() const override; + void setExceptionNotificationEnabled(bool enable) override; + +private: + Q_DECLARE_PRIVATE(QSocks5SocketEngine) + Q_DISABLE_COPY_MOVE(QSocks5SocketEngine) + Q_PRIVATE_SLOT(d_func(), void _q_controlSocketConnected()) + Q_PRIVATE_SLOT(d_func(), void _q_controlSocketReadNotification()) + Q_PRIVATE_SLOT(d_func(), void _q_controlSocketErrorOccurred(QAbstractSocket::SocketError)) +#ifndef QT_NO_UDPSOCKET + Q_PRIVATE_SLOT(d_func(), void _q_udpSocketReadNotification()) +#endif + Q_PRIVATE_SLOT(d_func(), void _q_controlSocketBytesWritten()) + Q_PRIVATE_SLOT(d_func(), void _q_emitPendingReadNotification()) + Q_PRIVATE_SLOT(d_func(), void _q_emitPendingWriteNotification()) + Q_PRIVATE_SLOT(d_func(), void _q_emitPendingConnectionNotification()) + Q_PRIVATE_SLOT(d_func(), void _q_controlSocketDisconnected()) + Q_PRIVATE_SLOT(d_func(), void _q_controlSocketStateChanged(QAbstractSocket::SocketState)) + +}; + + +class QTcpSocket; + +class QSocks5Authenticator +{ +public: + QSocks5Authenticator(); + virtual ~QSocks5Authenticator(); + virtual char methodId(); + virtual bool beginAuthenticate(QTcpSocket *socket, bool *completed); + virtual bool continueAuthenticate(QTcpSocket *socket, bool *completed); + + bool seal(const QByteArray &buf, QByteArray *sealedBuf); + bool unSeal(const QByteArray &sealedBuf, QByteArray *buf); + bool unSeal(QTcpSocket *sealedSocket, QByteArray *buf); + + virtual QString errorString() { return QString(); } +}; + +class QSocks5PasswordAuthenticator : public QSocks5Authenticator +{ +public: + QSocks5PasswordAuthenticator(const QString &userName, const QString &password); + char methodId() override; + bool beginAuthenticate(QTcpSocket *socket, bool *completed) override; + bool continueAuthenticate(QTcpSocket *socket, bool *completed) override; + + QString errorString() override; + +private: + QString userName; + QString password; +}; + +struct QSocks5Data; +struct QSocks5ConnectData; +struct QSocks5UdpAssociateData; +struct QSocks5BindData; + +class QSocks5SocketEnginePrivate : public QAbstractSocketEnginePrivate +{ + Q_DECLARE_PUBLIC(QSocks5SocketEngine) +public: + QSocks5SocketEnginePrivate(); + ~QSocks5SocketEnginePrivate(); + + enum Socks5State + { + Uninitialized = 0, + ConnectError, + AuthenticationMethodsSent, + Authenticating, + AuthenticatingError, + RequestMethodSent, + RequestError, + Connected, + UdpAssociateSuccess, + BindSuccess, + ControlSocketError, + SocksError, + HostNameLookupError + }; + Socks5State socks5State; + + enum Socks5Mode + { + NoMode, + ConnectMode, + BindMode, + UdpAssociateMode + }; + Socks5Mode mode; + + enum Socks5Error + { + SocksFailure = 0x01, + ConnectionNotAllowed = 0x02, + NetworkUnreachable = 0x03, + HostUnreachable = 0x04, + ConnectionRefused = 0x05, + TTLExpired = 0x06, + CommandNotSupported = 0x07, + AddressTypeNotSupported = 0x08, + LastKnownError = AddressTypeNotSupported, + UnknownError + }; + + void initialize(Socks5Mode socks5Mode); + + void setErrorState(Socks5State state, const QString &extraMessage = QString()); + void setErrorState(Socks5State state, Socks5Error socks5error); + + void reauthenticate(); + void parseAuthenticationMethodReply(); + void parseAuthenticatingReply(); + void sendRequestMethod(); + void parseRequestMethodReply(); + void parseNewConnection(); + + bool waitForConnected(QDeadlineTimer deadline, bool *timedOut); + + void _q_controlSocketConnected(); + void _q_controlSocketReadNotification(); + void _q_controlSocketErrorOccurred(QAbstractSocket::SocketError); +#ifndef QT_NO_UDPSOCKET + void _q_udpSocketReadNotification(); +#endif + void _q_controlSocketBytesWritten(); + void _q_controlSocketDisconnected(); + void _q_controlSocketStateChanged(QAbstractSocket::SocketState); + + QNetworkProxy proxyInfo; + + bool readNotificationEnabled, writeNotificationEnabled, exceptNotificationEnabled; + + qintptr socketDescriptor; + + QSocks5Data *data; + QSocks5ConnectData *connectData; +#ifndef QT_NO_UDPSOCKET + QSocks5UdpAssociateData *udpData; +#endif + QSocks5BindData *bindData; + QString peerName; + QByteArray receivedHeaderFragment; + + mutable bool readNotificationActivated; + mutable bool writeNotificationActivated; + + bool readNotificationPending; + void _q_emitPendingReadNotification(); + void emitReadNotification(); + bool writeNotificationPending; + void _q_emitPendingWriteNotification(); + void emitWriteNotification(); + bool connectionNotificationPending; + void _q_emitPendingConnectionNotification(); + void emitConnectionNotification(); +}; + +class Q_AUTOTEST_EXPORT QSocks5SocketEngineHandler : public QSocketEngineHandler +{ +public: + virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType, + const QNetworkProxy &, QObject *parent) override; + virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent) override; +}; + +QT_END_NAMESPACE + +#endif // QSOCKS5SOCKETENGINE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qssl_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qssl_p.h new file mode 100644 index 0000000000000000000000000000000000000000..74492aa7d242d7823b56282f7c2562abe83d2a31 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qssl_p.h @@ -0,0 +1,42 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QSSL_P_H +#define QSSL_P_H + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qsslcertificate.cpp. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtCore/QLoggingCategory> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcSsl) + +namespace QTlsPrivate { + +enum class Cipher { + DesCbc, + DesEde3Cbc, + Rc2Cbc, + Aes128Cbc, + Aes192Cbc, + Aes256Cbc +}; + +} // namespace QTlsPrivate + +QT_END_NAMESPACE + +#endif // QSSL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslcertificate_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslcertificate_p.h new file mode 100644 index 0000000000000000000000000000000000000000..35937a58aae68d3a011519a135f854f98ef01647 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslcertificate_p.h @@ -0,0 +1,47 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QSSLCERTIFICATE_P_H +#define QSSLCERTIFICATE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include "qsslcertificateextension.h" +#include "qsslcertificate.h" +#include "qtlsbackend_p.h" + +#include <qlist.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +class QSslCertificatePrivate +{ +public: + QSslCertificatePrivate(); + ~QSslCertificatePrivate(); + + QList<QSslCertificateExtension> extensions() const; + Q_NETWORK_EXPORT static bool isBlacklisted(const QSslCertificate &certificate); + Q_NETWORK_EXPORT static QByteArray subjectInfoToString(QSslCertificate::SubjectInfo info); + + QAtomicInt ref; + std::unique_ptr<QTlsPrivate::X509Certificate> backend; +}; + +QT_END_NAMESPACE + +#endif // QSSLCERTIFICATE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslcertificateextension_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslcertificateextension_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2a8278f8f6a8d9ff71f4e0e360b8b9b36cf79a2b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslcertificateextension_p.h @@ -0,0 +1,42 @@ +// Copyright (C) 2011 Richard J. Moore <rich@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSSLCERTIFICATEEXTENSION_P_H +#define QSSLCERTIFICATEEXTENSION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qsslcertificateextension.h" + +QT_BEGIN_NAMESPACE + +class QSslCertificateExtensionPrivate : public QSharedData +{ +public: + inline QSslCertificateExtensionPrivate() + : critical(false), + supported(false) + { + } + + QString oid; + QString name; + QVariant value; + bool critical; + bool supported; +}; + +QT_END_NAMESPACE + +#endif // QSSLCERTIFICATEEXTENSION_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslcipher_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslcipher_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b4e55b08aa0cc84df6fe1592a514f2014076b370 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslcipher_p.h @@ -0,0 +1,45 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSSLCIPHER_P_H +#define QSSLCIPHER_P_H + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qsslcipher.h" + +QT_BEGIN_NAMESPACE + +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +class QSslCipherPrivate +{ +public: + QSslCipherPrivate() + : isNull(true), supportedBits(0), bits(0), + exportable(false), protocol(QSsl::UnknownProtocol) + { + } + + bool isNull; + QString name; + int supportedBits; + int bits; + QString keyExchangeMethod; + QString authenticationMethod; + QString encryptionMethod; + bool exportable; + QString protocolString; + QSsl::SslProtocol protocol; +}; + +QT_END_NAMESPACE + +#endif // QSSLCIPHER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslconfiguration_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslconfiguration_p.h new file mode 100644 index 0000000000000000000000000000000000000000..15a831ec2f585ce96dade763f91d1927360c8380 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslconfiguration_p.h @@ -0,0 +1,141 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2014 BlackBerry Limited. All rights reserved. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +/**************************************************************************** +** +** In addition, as a special exception, the copyright holders listed above give +** permission to link the code of its release of Qt with the OpenSSL project's +** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the +** same license as the original version), and distribute the linked executables. +** +** You must comply with the GNU General Public License version 2 in all +** respects for all of the code used other than the "OpenSSL" code. If you +** modify this file, you may extend this exception to your version of the file, +** but you are not obligated to do so. If you do not wish to do so, delete +** this exception statement from your version of this file. +** +****************************************************************************/ + +#ifndef QSSLCONFIGURATION_P_H +#define QSSLCONFIGURATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QSslSocket API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qmap.h> +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "qsslconfiguration.h" +#include "qlist.h" +#include "qsslcertificate.h" +#include "qsslcipher.h" +#include "qsslkey.h" +#include "qsslellipticcurve.h" +#include "qssldiffiehellmanparameters.h" + +QT_BEGIN_NAMESPACE + +class QSslConfigurationPrivate: public QSharedData +{ +public: + QSslConfigurationPrivate() + : sessionProtocol(QSsl::UnknownProtocol), + protocol(QSsl::SecureProtocols), + peerVerifyMode(QSslSocket::AutoVerifyPeer), + peerVerifyDepth(0), + allowRootCertOnDemandLoading(true), + peerSessionShared(false), + sslOptions(QSslConfigurationPrivate::defaultSslOptions), + dhParams(QSslDiffieHellmanParameters::defaultParameters()), + sslSessionTicketLifeTimeHint(-1), + ephemeralServerKey(), + preSharedKeyIdentityHint(), + nextProtocolNegotiationStatus(QSslConfiguration::NextProtocolNegotiationNone) + { } + + QSslCertificate peerCertificate; + QList<QSslCertificate> peerCertificateChain; + + QList<QSslCertificate> localCertificateChain; + + QSslKey privateKey; + QSslCipher sessionCipher; + QSsl::SslProtocol sessionProtocol; + QList<QSslCipher> ciphers; + QList<QSslCertificate> caCertificates; + + QSsl::SslProtocol protocol; + QSslSocket::PeerVerifyMode peerVerifyMode; + int peerVerifyDepth; + bool allowRootCertOnDemandLoading; + bool peerSessionShared; + + Q_AUTOTEST_EXPORT static bool peerSessionWasShared(const QSslConfiguration &configuration); + + QSsl::SslOptions sslOptions; + + static const QSsl::SslOptions defaultSslOptions; + + QList<QSslEllipticCurve> ellipticCurves; + + QSslDiffieHellmanParameters dhParams; + + QMap<QByteArray, QVariant> backendConfig; + + QByteArray sslSession; + int sslSessionTicketLifeTimeHint; + + QSslKey ephemeralServerKey; + + QByteArray preSharedKeyIdentityHint; + + QList<QByteArray> nextAllowedProtocols; + QByteArray nextNegotiatedProtocol; + QSslConfiguration::NextProtocolNegotiationStatus nextProtocolNegotiationStatus; + +#if QT_CONFIG(dtls) + bool dtlsCookieEnabled = true; +#else + const bool dtlsCookieEnabled = false; +#endif // dtls + +#if QT_CONFIG(ocsp) + bool ocspStaplingEnabled = false; +#else + const bool ocspStaplingEnabled = false; +#endif + +#if QT_CONFIG(openssl) + bool reportFromCallback = false; + bool missingCertIsFatal = false; +#else + const bool reportFromCallback = false; + const bool missingCertIsFatal = false; +#endif // openssl + + // in qsslsocket.cpp: + static QSslConfiguration defaultConfiguration(); + static void setDefaultConfiguration(const QSslConfiguration &configuration); + static void deepCopyDefaultConfiguration(QSslConfigurationPrivate *config); + + static QSslConfiguration defaultDtlsConfiguration(); + static void setDefaultDtlsConfiguration(const QSslConfiguration &configuration); +}; + +// implemented here for inlining purposes +inline QSslConfiguration::QSslConfiguration(QSslConfigurationPrivate *dd) + : d(dd) +{ +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qssldiffiehellmanparameters_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qssldiffiehellmanparameters_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2f9d49f4e03d27ccdb569cc612f0c473915a29a2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qssldiffiehellmanparameters_p.h @@ -0,0 +1,39 @@ +// Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QSSLDIFFIEHELLMANPARAMETERS_P_H +#define QSSLDIFFIEHELLMANPARAMETERS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qssldiffiehellmanparameters.cpp. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include "qssldiffiehellmanparameters.h" + +#include <QSharedData> + +QT_BEGIN_NAMESPACE + +class QSslDiffieHellmanParametersPrivate : public QSharedData +{ +public: + void initFromDer(const QByteArray &der); + void initFromPem(const QByteArray &pem); + + QSslDiffieHellmanParameters::Error error = QSslDiffieHellmanParameters::NoError; + QByteArray derData; +}; + +QT_END_NAMESPACE + +#endif // QSSLDIFFIEHELLMANPARAMETERS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslkey_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslkey_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cd1dcac937b4b07be1230dbf4fe48589c3f03337 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslkey_p.h @@ -0,0 +1,52 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QSSLKEY_OPENSSL_P_H +#define QSSLKEY_OPENSSL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qsslcertificate.cpp. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include "qsslkey.h" +#include "qssl_p.h" + +#include <memory> + +QT_BEGIN_NAMESPACE + +namespace QTlsPrivate { +class TlsKey; +} + +class QSslKeyPrivate +{ +public: + QSslKeyPrivate(); + ~QSslKeyPrivate(); + + using Cipher = QTlsPrivate::Cipher; + + Q_NETWORK_EXPORT static QByteArray decrypt(Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv); + Q_NETWORK_EXPORT static QByteArray encrypt(Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv); + + std::unique_ptr<QTlsPrivate::TlsKey> backend; + QAtomicInt ref; + +private: + Q_DISABLE_COPY_MOVE(QSslKeyPrivate) +}; + +QT_END_NAMESPACE + +#endif // QSSLKEY_OPENSSL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslpresharedkeyauthenticator_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslpresharedkeyauthenticator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ca702e91890f0751d7b4b571aee7fabbab7cd6cf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslpresharedkeyauthenticator_p.h @@ -0,0 +1,39 @@ +// Copyright (C) 2014 Governikus GmbH & Co. KG. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSSLPRESHAREDKEYAUTHENTICATOR_P_H +#define QSSLPRESHAREDKEYAUTHENTICATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QSharedData> + +QT_BEGIN_NAMESPACE + +class QSslPreSharedKeyAuthenticatorPrivate : public QSharedData +{ +public: + QSslPreSharedKeyAuthenticatorPrivate(); + + QByteArray identityHint; + + QByteArray identity; + int maximumIdentityLength; + + QByteArray preSharedKey; + int maximumPreSharedKeyLength; +}; + +QT_END_NAMESPACE + +#endif // QSSLPRESHAREDKEYAUTHENTICATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslserver_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslserver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..861b46e2afb895d365686b16892b5eee4be49667 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslserver_p.h @@ -0,0 +1,71 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSSLSERVER_P_H +#define QSSLSERVER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include <QtCore/qhash.h> +#include <QtCore/qtimer.h> + +#include <QtNetwork/QSslConfiguration> +#include <QtNetwork/private/qtcpserver_p.h> +#include <utility> + +QT_BEGIN_NAMESPACE + +class Q_NETWORK_EXPORT QSslServerPrivate : public QTcpServerPrivate +{ + static constexpr int DefaultHandshakeTimeout = 5'000; // 5 seconds +public: + Q_DECLARE_PUBLIC(QSslServer) + + QSslServerPrivate(); + void checkClientHelloAndContinue(); + void initializeHandshakeProcess(QSslSocket *socket); + void removeSocketData(quintptr socket); + void handleHandshakeTimedOut(QSslSocket *socket); + int totalPendingConnections() const override; + + struct SocketData { + QMetaObject::Connection readyReadConnection; + QMetaObject::Connection destroyedConnection; + std::shared_ptr<QTimer> timeoutTimer; // shared_ptr because QHash demands copying + + SocketData(QMetaObject::Connection readyRead, QMetaObject::Connection destroyed, + std::shared_ptr<QTimer> &&timer) + : readyReadConnection(readyRead), + destroyedConnection(destroyed), + timeoutTimer(std::move(timer)) + { + } + + void disconnectSignals() + { + QObject::disconnect(std::exchange(readyReadConnection, {})); + QObject::disconnect(std::exchange(destroyedConnection, {})); + } + }; + QHash<quintptr, SocketData> socketData; + + QSslConfiguration sslConfiguration; + int handshakeTimeout = DefaultHandshakeTimeout; +}; + + +QT_END_NAMESPACE + +#endif // QSSLSERVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslsocket_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslsocket_p.h new file mode 100644 index 0000000000000000000000000000000000000000..da567bf64ae55948c3ac26d79b8a0e1c6ae72800 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qsslsocket_p.h @@ -0,0 +1,169 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QSSLSOCKET_P_H +#define QSSLSOCKET_P_H + +#include "qsslsocket.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include <private/qtcpsocket_p.h> + +#include "qocspresponse.h" +#include "qsslconfiguration_p.h" +#include "qsslkey.h" +#include "qtlsbackend_p.h" + +#include <QtCore/qlist.h> +#include <QtCore/qmutex.h> +#include <QtCore/qstringlist.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +class QSslContext; +class QTlsBackend; + +class Q_NETWORK_EXPORT QSslSocketPrivate : public QTcpSocketPrivate +{ + Q_DECLARE_PUBLIC(QSslSocket) +public: + QSslSocketPrivate(); + virtual ~QSslSocketPrivate(); + + void init(); + bool verifyProtocolSupported(const char *where); + bool initialized; + + QSslSocket::SslMode mode; + bool autoStartHandshake; + bool connectionEncrypted; + bool ignoreAllSslErrors; + QList<QSslError> ignoreErrorsList; + bool* readyReadEmittedPointer; + + QSslConfigurationPrivate configuration; + + // if set, this hostname is used for certificate validation instead of the hostname + // that was used for connecting to. + QString verificationPeerName; + + bool allowRootCertOnDemandLoading; + + static bool s_loadRootCertsOnDemand; + + static bool supportsSsl(); + static void ensureInitialized(); + + static QList<QSslCipher> defaultCiphers(); + static QList<QSslCipher> defaultDtlsCiphers(); + static QList<QSslCipher> supportedCiphers(); + static void setDefaultCiphers(const QList<QSslCipher> &ciphers); + static void setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers); + static void setDefaultSupportedCiphers(const QList<QSslCipher> &ciphers); + + static QList<QSslEllipticCurve> supportedEllipticCurves(); + static void setDefaultSupportedEllipticCurves(const QList<QSslEllipticCurve> &curves); + static void resetDefaultEllipticCurves(); + + static QList<QSslCertificate> defaultCaCertificates(); + static QList<QSslCertificate> systemCaCertificates(); + static void setDefaultCaCertificates(const QList<QSslCertificate> &certs); + static void addDefaultCaCertificate(const QSslCertificate &cert); + static void addDefaultCaCertificates(const QList<QSslCertificate> &certs); + static bool isMatchingHostname(const QSslCertificate &cert, const QString &peerName); + static bool isMatchingHostname(const QString &cn, const QString &hostname); + + // The socket itself, including private slots. + QTcpSocket *plainSocket = nullptr; + void createPlainSocket(QIODevice::OpenMode openMode); + static void pauseSocketNotifiers(QSslSocket*); + static void resumeSocketNotifiers(QSslSocket*); + // ### The 2 methods below should be made member methods once the QSslContext class is made public + static void checkSettingSslContext(QSslSocket*, std::shared_ptr<QSslContext>); + static std::shared_ptr<QSslContext> sslContext(QSslSocket *socket); + bool isPaused() const; + void setPaused(bool p); + bool bind(const QHostAddress &address, quint16, QAbstractSocket::BindMode) override; + void _q_connectedSlot(); + void _q_hostFoundSlot(); + void _q_disconnectedSlot(); + void _q_stateChangedSlot(QAbstractSocket::SocketState); + void _q_errorSlot(QAbstractSocket::SocketError); + void _q_readyReadSlot(); + void _q_channelReadyReadSlot(int); + void _q_bytesWrittenSlot(qint64); + void _q_channelBytesWrittenSlot(int, qint64); + void _q_readChannelFinishedSlot(); + void _q_flushWriteBuffer(); + void _q_flushReadBuffer(); + void _q_resumeImplementation(); + + static QList<QByteArray> unixRootCertDirectories(); // used also by QSslContext + + qint64 peek(char *data, qint64 maxSize) override; + QByteArray peek(qint64 maxSize) override; + bool flush() override; + + void startClientEncryption(); + void startServerEncryption(); + void transmit(); + void disconnectFromHost(); + void disconnected(); + QSslCipher sessionCipher() const; + QSsl::SslProtocol sessionProtocol() const; + void continueHandshake(); + + static bool rootCertOnDemandLoadingSupported(); + static void setRootCertOnDemandLoadingSupported(bool supported); + + static QTlsBackend *tlsBackendInUse(); + + // Needed by TlsCryptograph: + QSslSocket::SslMode tlsMode() const; + bool isRootsOnDemandAllowed() const; + QString verificationName() const; + QString tlsHostName() const; + QTcpSocket *plainTcpSocket() const; + bool verifyErrorsHaveBeenIgnored(); + bool isAutoStartingHandshake() const; + bool isPendingClose() const; + void setPendingClose(bool pc); + qint64 maxReadBufferSize() const; + void setMaxReadBufferSize(qint64 maxSize); + void setEncrypted(bool enc); + QRingBufferRef &tlsWriteBuffer(); + QRingBufferRef &tlsBuffer(); + bool &tlsEmittedBytesWritten(); + bool *readyReadPointer(); + +protected: + + bool hasUndecryptedData() const; + bool paused; + bool flushTriggered; + + static inline QMutex backendMutex; + static inline QString activeBackendName; + static inline QTlsBackend *tlsBackend = nullptr; + + std::unique_ptr<QTlsPrivate::TlsCryptograph> backend; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtcpserver_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtcpserver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..574a66aa3225dfbb0e2f18f29b4e92fcb8e7ac40 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtcpserver_p.h @@ -0,0 +1,75 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTCPSERVER_P_H +#define QTCPSERVER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "QtNetwork/qtcpserver.h" +#include "private/qobject_p.h" +#include "private/qabstractsocketengine_p.h" +#include "QtNetwork/qabstractsocket.h" +#include "qnetworkproxy.h" +#include "QtCore/qlist.h" +#include "qhostaddress.h" + +QT_BEGIN_NAMESPACE + +class Q_NETWORK_EXPORT QTcpServerPrivate : public QObjectPrivate, + public QAbstractSocketEngineReceiver +{ + Q_DECLARE_PUBLIC(QTcpServer) +public: + QTcpServerPrivate(); + ~QTcpServerPrivate(); + + QList<QTcpSocket *> pendingConnections; + + quint16 port; + QHostAddress address; + + QAbstractSocket::SocketType socketType; + QAbstractSocket::SocketState state; + QAbstractSocketEngine *socketEngine; + + QAbstractSocket::SocketError serverSocketError; + QString serverSocketErrorString; + + int listenBacklog = 50; + int maxConnections; + +#ifndef QT_NO_NETWORKPROXY + QNetworkProxy proxy; + QNetworkProxy resolveProxy(const QHostAddress &address, quint16 port); +#endif + + virtual void configureCreatedSocket(); + virtual int totalPendingConnections() const; + + // from QAbstractSocketEngineReceiver + void readNotification() override; + void closeNotification() override { readNotification(); } + void writeNotification() override {} + void exceptionNotification() override {} + void connectionNotification() override {} +#ifndef QT_NO_NETWORKPROXY + void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *) override {} +#endif + +}; + +QT_END_NAMESPACE + +#endif // QTCPSERVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtcpsocket_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtcpsocket_p.h new file mode 100644 index 0000000000000000000000000000000000000000..57c45c10841f01c27627c234202e07d67e0016e1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtcpsocket_p.h @@ -0,0 +1,31 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTCPSOCKET_P_H +#define QTCPSOCKET_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include <QtNetwork/qtcpsocket.h> +#include <private/qabstractsocket_p.h> + +QT_BEGIN_NAMESPACE + +class QTcpSocketPrivate : public QAbstractSocketPrivate +{ + Q_DECLARE_PUBLIC(QTcpSocket) +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtldurl_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtldurl_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dacaee312aa52fbf5964bf65c59ebc8a72932001 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtldurl_p.h @@ -0,0 +1,33 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTLDURL_P_H +#define QTLDURL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qDecodeDataUrl. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> +#include "QtCore/qstring.h" + +QT_REQUIRE_CONFIG(topleveldomain); + +QT_BEGIN_NAMESPACE + +Q_NETWORK_EXPORT bool qIsEffectiveTLD(QStringView domain); +inline bool qIsEffectiveTLD(const QString &domain) +{ + return qIsEffectiveTLD(qToStringViewIgnoringNull(domain)); +} + +QT_END_NAMESPACE + +#endif // QTLDURL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtlsbackend_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtlsbackend_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dc0e9ead51404d7dc8896a995a148986fa9f480c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtlsbackend_p.h @@ -0,0 +1,405 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTLSBACKEND_P_H +#define QTLSBACKEND_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qtnetworkglobal_p.h> + +#include "qsslconfiguration.h" +#include "qsslerror.h" +#include "qssl_p.h" + +#if QT_CONFIG(dtls) +#include "qdtls.h" +#endif + +#include <QtNetwork/qsslcertificate.h> +#include <QtNetwork/qsslcipher.h> +#include <QtNetwork/qsslkey.h> +#include <QtNetwork/qssl.h> + +#include <QtCore/qloggingcategory.h> +#include <QtCore/qnamespace.h> +#include <QtCore/qobject.h> +#include <QtCore/qglobal.h> +#include <QtCore/qstring.h> +#include <QtCore/qlist.h> +#include <QtCore/qmap.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +class QSslPreSharedKeyAuthenticator; +class QSslSocketPrivate; +class QHostAddress; +class QSslContext; + +class QSslSocket; +class QByteArray; +class QSslCipher; +class QUdpSocket; +class QIODevice; +class QSslError; +class QSslKey; + +namespace QTlsPrivate { + +class Q_NETWORK_EXPORT TlsKey { +public: + TlsKey() = default; + Q_DISABLE_COPY_MOVE(TlsKey) + + virtual ~TlsKey(); + + using KeyType = QSsl::KeyType; + using KeyAlgorithm = QSsl::KeyAlgorithm; + + virtual void decodeDer(KeyType type, KeyAlgorithm algorithm, const QByteArray &der, + const QByteArray &passPhrase, bool deepClear) = 0; + virtual void decodePem(KeyType type, KeyAlgorithm algorithm, const QByteArray &pem, + const QByteArray &passPhrase, bool deepClear) = 0; + + virtual QByteArray toPem(const QByteArray &passPhrase) const = 0; + virtual QByteArray derFromPem(const QByteArray &pem, QMap<QByteArray, QByteArray> *headers) const = 0; + virtual QByteArray pemFromDer(const QByteArray &der, const QMap<QByteArray, QByteArray> &headers) const = 0; + + virtual void fromHandle(Qt::HANDLE handle, KeyType type) = 0; + virtual Qt::HANDLE handle() const = 0; + + virtual bool isNull() const = 0; + virtual KeyType type() const = 0; + virtual KeyAlgorithm algorithm() const = 0; + virtual int length() const = 0; + + virtual void clear(bool deepClear) = 0; + + virtual bool isPkcs8() const = 0; + + virtual QByteArray decrypt(Cipher cipher, const QByteArray &data, + const QByteArray &passPhrase, const QByteArray &iv) const = 0; + virtual QByteArray encrypt(Cipher cipher, const QByteArray &data, + const QByteArray &key, const QByteArray &iv) const = 0; + + QByteArray pemHeader() const; + QByteArray pemFooter() const; +}; + +class Q_NETWORK_EXPORT X509Certificate +{ +public: + virtual ~X509Certificate(); + + virtual bool isEqual(const X509Certificate &other) const = 0; + virtual bool isNull() const = 0; + virtual bool isSelfSigned() const = 0; + virtual QByteArray version() const = 0; + virtual QByteArray serialNumber() const = 0; + virtual QStringList issuerInfo(QSslCertificate::SubjectInfo subject) const = 0; + virtual QStringList issuerInfo(const QByteArray &attribute) const = 0; + virtual QStringList subjectInfo(QSslCertificate::SubjectInfo subject) const = 0; + virtual QStringList subjectInfo(const QByteArray &attribute) const = 0; + + virtual QList<QByteArray> subjectInfoAttributes() const = 0; + virtual QList<QByteArray> issuerInfoAttributes() const = 0; + virtual QMultiMap<QSsl::AlternativeNameEntryType, QString> subjectAlternativeNames() const = 0; + virtual QDateTime effectiveDate() const = 0; + virtual QDateTime expiryDate() const = 0; + + virtual TlsKey *publicKey() const; + + // Extensions. Plugins do not expose internal representation + // and cannot rely on QSslCertificate's internals. Thus, + // we provide this information 'in pieces': + virtual qsizetype numberOfExtensions() const = 0; + virtual QString oidForExtension(qsizetype i) const = 0; + virtual QString nameForExtension(qsizetype i) const = 0; + virtual QVariant valueForExtension(qsizetype i) const = 0; + virtual bool isExtensionCritical(qsizetype i) const = 0; + virtual bool isExtensionSupported(qsizetype i) const = 0; + + virtual QByteArray toPem() const = 0; + virtual QByteArray toDer() const = 0; + virtual QString toText() const = 0; + + virtual Qt::HANDLE handle() const = 0; + + virtual size_t hash(size_t seed) const noexcept = 0; +}; + +// TLSTODO: consider making those into virtuals in QTlsBackend. After all, we ask the backend +// to return those pointers if the functionality is supported, but it's a bit odd to have +// this level of indirection. They are not parts of the classes above because ... +// you'd then have to ask backend to create a certificate to ... call those +// functions on a certificate. +using X509ChainVerifyPtr = QList<QSslError> (*)(const QList<QSslCertificate> &chain, + const QString &hostName); +using X509PemReaderPtr = QList<QSslCertificate> (*)(const QByteArray &pem, int count); +using X509DerReaderPtr = X509PemReaderPtr; +using X509Pkcs12ReaderPtr = bool (*)(QIODevice *device, QSslKey *key, QSslCertificate *cert, + QList<QSslCertificate> *caCertificates, + const QByteArray &passPhrase); + +#if QT_CONFIG(ssl) +// TLS over TCP. Handshake, encryption/decryption. +class Q_NETWORK_EXPORT TlsCryptograph : public QObject +{ +public: + virtual ~TlsCryptograph(); + + virtual void init(QSslSocket *q, QSslSocketPrivate *d) = 0; + virtual void checkSettingSslContext(std::shared_ptr<QSslContext> tlsContext); + virtual std::shared_ptr<QSslContext> sslContext() const; + + virtual QList<QSslError> tlsErrors() const = 0; + + virtual void startClientEncryption() = 0; + virtual void startServerEncryption() = 0; + virtual void continueHandshake() = 0; + virtual void enableHandshakeContinuation(); + virtual void disconnectFromHost() = 0; + virtual void disconnected() = 0; + virtual void cancelCAFetch(); + virtual QSslCipher sessionCipher() const = 0; + virtual QSsl::SslProtocol sessionProtocol() const = 0; + + virtual void transmit() = 0; + virtual bool hasUndecryptedData() const; + virtual QList<QOcspResponse> ocsps() const; + + static bool isMatchingHostname(const QSslCertificate &cert, const QString &peerName); + + void setErrorAndEmit(QSslSocketPrivate *d, QAbstractSocket::SocketError errorCode, + const QString &errorDescription) const; +}; +#else +class TlsCryptograph; +#endif // QT_CONFIG(ssl) + +#if QT_CONFIG(dtls) + +class Q_NETWORK_EXPORT DtlsBase +{ +public: + virtual ~DtlsBase(); + + virtual void setDtlsError(QDtlsError code, const QString &description) = 0; + + virtual QDtlsError error() const = 0; + virtual QString errorString() const = 0; + + virtual void clearDtlsError() = 0; + + virtual void setConfiguration(const QSslConfiguration &configuration) = 0; + virtual QSslConfiguration configuration() const = 0; + + using GenParams = QDtlsClientVerifier::GeneratorParameters; + virtual bool setCookieGeneratorParameters(const GenParams ¶ms) = 0; + virtual GenParams cookieGeneratorParameters() const = 0; +}; + +// DTLS cookie: generation and verification. +class Q_NETWORK_EXPORT DtlsCookieVerifier : virtual public DtlsBase +{ +public: + virtual bool verifyClient(QUdpSocket *socket, const QByteArray &dgram, + const QHostAddress &address, quint16 port) = 0; + virtual QByteArray verifiedHello() const = 0; +}; + +// TLS over UDP. Handshake, encryption/decryption. +class Q_NETWORK_EXPORT DtlsCryptograph : virtual public DtlsBase +{ +public: + + virtual QSslSocket::SslMode cryptographMode() const = 0; + virtual void setPeer(const QHostAddress &addr, quint16 port, const QString &name) = 0; + virtual QHostAddress peerAddress() const = 0; + virtual quint16 peerPort() const = 0; + virtual void setPeerVerificationName(const QString &name) = 0; + virtual QString peerVerificationName() const = 0; + + virtual void setDtlsMtuHint(quint16 mtu) = 0; + virtual quint16 dtlsMtuHint() const = 0; + + virtual QDtls::HandshakeState state() const = 0; + virtual bool isConnectionEncrypted() const = 0; + + virtual bool startHandshake(QUdpSocket *socket, const QByteArray &dgram) = 0; + virtual bool handleTimeout(QUdpSocket *socket) = 0; + virtual bool continueHandshake(QUdpSocket *socket, const QByteArray &dgram) = 0; + virtual bool resumeHandshake(QUdpSocket *socket) = 0; + virtual void abortHandshake(QUdpSocket *socket) = 0; + virtual void sendShutdownAlert(QUdpSocket *socket) = 0; + + virtual QList<QSslError> peerVerificationErrors() const = 0; + virtual void ignoreVerificationErrors(const QList<QSslError> &errorsToIgnore) = 0; + + virtual QSslCipher dtlsSessionCipher() const = 0; + virtual QSsl::SslProtocol dtlsSessionProtocol() const = 0; + + virtual qint64 writeDatagramEncrypted(QUdpSocket *socket, const QByteArray &dgram) = 0; + virtual QByteArray decryptDatagram(QUdpSocket *socket, const QByteArray &dgram) = 0; +}; + +#else + +class DtlsCookieVerifier; +class DtlsCryptograph; + +#endif // QT_CONFIG(dtls) + +} // namespace QTlsPrivate + +// Factory, creating back-end specific implementations of +// different entities QSslSocket is using. +class Q_NETWORK_EXPORT QTlsBackend : public QObject +{ + Q_OBJECT +public: + QTlsBackend(); + ~QTlsBackend() override; + + virtual bool isValid() const; + virtual long tlsLibraryVersionNumber() const; + virtual QString tlsLibraryVersionString() const; + virtual long tlsLibraryBuildVersionNumber() const; + virtual QString tlsLibraryBuildVersionString() const; + virtual void ensureInitialized() const; + + virtual QString backendName() const = 0; + virtual QList<QSsl::SslProtocol> supportedProtocols() const = 0; + virtual QList<QSsl::SupportedFeature> supportedFeatures() const = 0; + virtual QList<QSsl::ImplementedClass> implementedClasses() const = 0; + + // X509 and keys: + virtual QTlsPrivate::TlsKey *createKey() const; + virtual QTlsPrivate::X509Certificate *createCertificate() const; + + virtual QList<QSslCertificate> systemCaCertificates() const; + + // TLS and DTLS: + virtual QTlsPrivate::TlsCryptograph *createTlsCryptograph() const; + virtual QTlsPrivate::DtlsCryptograph *createDtlsCryptograph(class QDtls *qObject, int mode) const; + virtual QTlsPrivate::DtlsCookieVerifier *createDtlsCookieVerifier() const; + + // TLSTODO - get rid of these function pointers, make them virtuals in + // the backend itself. X509 machinery: + virtual QTlsPrivate::X509ChainVerifyPtr X509Verifier() const; + virtual QTlsPrivate::X509PemReaderPtr X509PemReader() const; + virtual QTlsPrivate::X509DerReaderPtr X509DerReader() const; + virtual QTlsPrivate::X509Pkcs12ReaderPtr X509Pkcs12Reader() const; + + // Elliptic curves: + virtual QList<int> ellipticCurvesIds() const; + virtual int curveIdFromShortName(const QString &name) const; + virtual int curveIdFromLongName(const QString &name) const; + virtual QString shortNameForId(int cid) const; + virtual QString longNameForId(int cid) const; + virtual bool isTlsNamedCurve(int cid) const; + + // Note: int and not QSslDiffieHellmanParameter::Error - because this class and + // its enum are QT_CONFIG(ssl)-conditioned. But not QTlsBackend and + // its virtual functions. DH decoding: + virtual int dhParametersFromDer(const QByteArray &derData, QByteArray *data) const; + virtual int dhParametersFromPem(const QByteArray &pemData, QByteArray *data) const; + + static QList<QString> availableBackendNames(); + static QString defaultBackendName(); + static QTlsBackend *findBackend(const QString &backendName); + static QTlsBackend *activeOrAnyBackend(); + + static QList<QSsl::SslProtocol> supportedProtocols(const QString &backendName); + static QList<QSsl::SupportedFeature> supportedFeatures(const QString &backendName); + static QList<QSsl::ImplementedClass> implementedClasses(const QString &backendName); + + // Built-in, this is what Qt provides out of the box (depending on OS): + static constexpr const int nameIndexSchannel = 0; + static constexpr const int nameIndexSecureTransport = 1; + static constexpr const int nameIndexOpenSSL = 2; + static constexpr const int nameIndexCertOnly = 3; + + static const QString builtinBackendNames[]; + + template<class DynamicType, class TLSObject> + static DynamicType *backend(const TLSObject &o) + { + return static_cast<DynamicType *>(o.d->backend.get()); + } + + static void resetBackend(QSslKey &key, QTlsPrivate::TlsKey *keyBackend); + + static void setupClientPskAuth(QSslPreSharedKeyAuthenticator *auth, const char *hint, + int hintLength, unsigned maxIdentityLen, unsigned maxPskLen); + static void setupServerPskAuth(QSslPreSharedKeyAuthenticator *auth, const char *identity, + const QByteArray &identityHint, unsigned maxPskLen); +#if QT_CONFIG(ssl) + static QSslCipher createCiphersuite(const QString &description, int bits, int supportedBits); + static QSslCipher createCiphersuite(const QString &suiteName, QSsl::SslProtocol protocol, + const QString &protocolString); + static QSslCipher createCiphersuite(const QString &name, const QString &keyExchangeMethod, + const QString &encryptionMethod, + const QString &authenticationMethod, + int bits, QSsl::SslProtocol protocol, + const QString &protocolString); + + // Those statics are implemented using QSslSocketPrivate (which is not exported, + // unlike QTlsBackend). + static QList<QSslCipher> defaultCiphers(); + static QList<QSslCipher> defaultDtlsCiphers(); + + static void setDefaultCiphers(const QList<QSslCipher> &ciphers); + static void setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers); + static void setDefaultSupportedCiphers(const QList<QSslCipher> &ciphers); + + static void resetDefaultEllipticCurves(); + + static void setDefaultCaCertificates(const QList<QSslCertificate> &certs); + + // Many thanks to people who designed QSslConfiguration with hidden + // data-members, that sneakily set by some 'friend' classes, having + // some twisted logic. + static bool rootLoadingOnDemandAllowed(const QSslConfiguration &configuration); + static void storePeerCertificate(QSslConfiguration &configuration, const QSslCertificate &peerCert); + static void storePeerCertificateChain(QSslConfiguration &configuration, + const QList<QSslCertificate> &peerCertificateChain); + static void clearPeerCertificates(QSslConfiguration &configuration); + // And those are even worse, this is where we don't have the original configuration, + // and can have only a copy. So instead we go to d->privateConfiguration.someMember: + static void clearPeerCertificates(QSslSocketPrivate *d); + static void setPeerSessionShared(QSslSocketPrivate *d, bool shared); + static void setSessionAsn1(QSslSocketPrivate *d, const QByteArray &asn1); + static void setSessionLifetimeHint(QSslSocketPrivate *d, int hint); + using AlpnNegotiationStatus = QSslConfiguration::NextProtocolNegotiationStatus; + static void setAlpnStatus(QSslSocketPrivate *d, AlpnNegotiationStatus st); + static void setNegotiatedProtocol(QSslSocketPrivate *d, const QByteArray &protocol); + static void storePeerCertificate(QSslSocketPrivate *d, const QSslCertificate &peerCert); + static void storePeerCertificateChain(QSslSocketPrivate *d, const QList<QSslCertificate> &peerChain); + static void addTustedRoot(QSslSocketPrivate *d, const QSslCertificate &rootCert);// TODO: "addTrusted..." + // The next one - is a "very important" feature! Kidding ... + static void setEphemeralKey(QSslSocketPrivate *d, const QSslKey &key); + + virtual void forceAutotestSecurityLevel(); +#endif // QT_CONFIG(ssl) + + Q_DISABLE_COPY_MOVE(QTlsBackend) +}; + +#define QTlsBackend_iid "org.qt-project.Qt.QTlsBackend" +Q_DECLARE_INTERFACE(QTlsBackend, QTlsBackend_iid); + +QT_END_NAMESPACE + +#endif // QTLSBACKEND_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtnetwork-config_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtnetwork-config_p.h new file mode 100644 index 0000000000000000000000000000000000000000..baba327bb2e104130b7e8ea1f1544b61cafe8bc7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtnetwork-config_p.h @@ -0,0 +1,16 @@ +#define QT_FEATURE_libresolv -1 + +#define QT_FEATURE_libproxy -1 + +#define QT_FEATURE_linux_netlink -1 + +#define QT_FEATURE_res_setservers -1 + +#define QT_FEATURE_system_proxies 1 + +#define QT_FEATURE_networklistmanager 1 + +#define QT_FEATURE_publicsuffix_qt 1 + +#define QT_FEATURE_publicsuffix_system -1 + diff --git a/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtnetworkglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtnetworkglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bb387b5337908a547ab4cbdd0546c65b2cd21b16 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtNetwork/6.8.1/QtNetwork/private/qtnetworkglobal_p.h @@ -0,0 +1,33 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTNETWORKGLOBAL_P_H +#define QTNETWORKGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/qtnetworkglobal.h> +#include <QtCore/private/qglobal_p.h> +#include <QtNetwork/private/qtnetwork-config_p.h> + +QT_BEGIN_NAMESPACE + +enum { +#if defined(Q_OS_LINUX) || defined(Q_OS_QNX) + PlatformSupportsAbstractNamespace = true +#else + PlatformSupportsAbstractNamespace = false +#endif +}; + +QT_END_NAMESPACE +#endif // QTNETWORKGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengl2pexvertexarray_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengl2pexvertexarray_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0bc04901f39608f81ff0402242ad301c3ad2524b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengl2pexvertexarray_p.h @@ -0,0 +1,133 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QOPENGL2PEXVERTEXARRAY_P_H +#define QOPENGL2PEXVERTEXARRAY_P_H + +#include <QRectF> + +#include <private/qdatabuffer_p.h> +#include <private/qvectorpath_p.h> +#include <private/qopenglcontext_p.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLPoint +{ +public: + QOpenGLPoint(GLfloat new_x, GLfloat new_y) : + x(new_x), y(new_y) {} + + QOpenGLPoint(const QPointF &p) : + x(p.x()), y(p.y()) {} + + QOpenGLPoint(const QPointF* p) : + x(p->x()), y(p->y()) {} + + GLfloat x; + GLfloat y; + + operator QPointF() {return QPointF(x,y);} + operator QPointF() const {return QPointF(x,y);} +}; +Q_DECLARE_TYPEINFO(QOpenGLPoint, Q_PRIMITIVE_TYPE); + +struct QOpenGLRect +{ + QOpenGLRect(const QRectF &r) + : left(r.left()), top(r.top()), right(r.right()), bottom(r.bottom()) {} + + QOpenGLRect(GLfloat l, GLfloat t, GLfloat r, GLfloat b) + : left(l), top(t), right(r), bottom(b) {} + + GLfloat left; + GLfloat top; + GLfloat right; + GLfloat bottom; + + operator QRectF() const {return QRectF(left, top, right-left, bottom-top);} +}; +Q_DECLARE_TYPEINFO(QOpenGLRect, Q_PRIMITIVE_TYPE); + +class QOpenGL2PEXVertexArray +{ +public: + QOpenGL2PEXVertexArray() : + vertexArray(0), vertexArrayStops(0), + maxX(-2e10), maxY(-2e10), minX(2e10), minY(2e10), + boundingRectDirty(true) + { } + + inline void addRect(const QRectF &rect) + { + qreal top = rect.top(); + qreal left = rect.left(); + qreal bottom = rect.bottom(); + qreal right = rect.right(); + + vertexArray << QOpenGLPoint(left, top) + << QOpenGLPoint(right, top) + << QOpenGLPoint(right, bottom) + << QOpenGLPoint(right, bottom) + << QOpenGLPoint(left, bottom) + << QOpenGLPoint(left, top); + } + + inline void addQuad(const QRectF &rect) + { + qreal top = rect.top(); + qreal left = rect.left(); + qreal bottom = rect.bottom(); + qreal right = rect.right(); + + vertexArray << QOpenGLPoint(left, top) + << QOpenGLPoint(right, top) + << QOpenGLPoint(left, bottom) + << QOpenGLPoint(right, bottom); + + } + + inline void addVertex(const GLfloat x, const GLfloat y) + { + vertexArray.add(QOpenGLPoint(x, y)); + } + + void addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline = true); + void clear(); + + QOpenGLPoint* data() {return vertexArray.data();} + int *stops() const { return vertexArrayStops.data(); } + int stopCount() const { return vertexArrayStops.size(); } + QOpenGLRect boundingRect() const; + + int vertexCount() const { return vertexArray.size(); } + + void lineToArray(const GLfloat x, const GLfloat y); + +private: + QDataBuffer<QOpenGLPoint> vertexArray; + QDataBuffer<int> vertexArrayStops; + + GLfloat maxX; + GLfloat maxY; + GLfloat minX; + GLfloat minY; + bool boundingRectDirty; + void addClosingLine(int index); + void addCentroid(const QVectorPath &path, int subPathIndex); +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglcustomshaderstage_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglcustomshaderstage_p.h new file mode 100644 index 0000000000000000000000000000000000000000..516e8b9a6a68fc6ff6439ac63444271476d83b5d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglcustomshaderstage_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGL_CUSTOM_SHADER_STAGE_H +#define QOPENGL_CUSTOM_SHADER_STAGE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtOpenGL/qtopenglglobal.h> +#include <QOpenGLShaderProgram> +#include <private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + + +class QPainter; +class QOpenGLCustomShaderStagePrivate; +class Q_OPENGL_EXPORT QOpenGLCustomShaderStage +{ + Q_DECLARE_PRIVATE(QOpenGLCustomShaderStage) +public: + QOpenGLCustomShaderStage(); + virtual ~QOpenGLCustomShaderStage(); + virtual void setUniforms(QOpenGLShaderProgram*) {} + + void setUniformsDirty(); + + bool setOnPainter(QPainter*); + void removeFromPainter(QPainter*); + QByteArray source() const; + + void setInactive(); +protected: + void setSource(const QByteArray&); + +private: + QOpenGLCustomShaderStagePrivate* d_ptr; + + Q_DISABLE_COPY_MOVE(QOpenGLCustomShaderStage) +}; + + +QT_END_NAMESPACE + + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglengineshadermanager_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglengineshadermanager_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5677a1e085e1d2b00b612e2234fb0ccd02875f31 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglengineshadermanager_p.h @@ -0,0 +1,470 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +/* + VERTEX SHADERS + ============== + + Vertex shaders are specified as multiple (partial) shaders. On desktop, + this works fine. On ES, QOpenGLShader & QOpenGLShaderProgram will make partial + shaders work by concatenating the source in each QOpenGLShader and compiling + it as a single shader. This is abstracted nicely by QOpenGLShaderProgram and + the GL2 engine doesn't need to worry about it. + + Generally, there's two vertex shader objects. The position shaders are + the ones which set gl_Position. There's also two "main" vertex shaders, + one which just calls the position shader and another which also passes + through some texture coordinates from a vertex attribute array to a + varying. These texture coordinates are used for mask position in text + rendering and for the source coordinates in drawImage/drawPixmap. There's + also a "Simple" vertex shader for rendering a solid colour (used to render + into the stencil buffer where the actual colour value is discarded). + + The position shaders for brushes look scary. This is because many of the + calculations which logically belong in the fragment shader have been moved + into the vertex shader to improve performance. This is why the position + calculation is in a separate shader. Not only does it calculate the + position, but it also calculates some data to be passed to the fragment + shader as a varying. It is optimal to move as much of the calculation as + possible into the vertex shader as this is executed less often. + + The varyings passed to the fragment shaders are interpolated (which is + cheap). Unfortunately, GL will apply perspective correction to the + interpolation calusing errors. To get around this, the vertex shader must + apply perspective correction itself and set the w-value of gl_Position to + zero. That way, GL will be tricked into thinking it doesn't need to apply a + perspective correction and use linear interpolation instead (which is what + we want). Of course, if the brush transform is affeine, no perspective + correction is needed and a simpler vertex shader can be used instead. + + So there are the following "main" vertex shaders: + qopenglslMainVertexShader + qopenglslMainWithTexCoordsVertexShader + + And the following position vertex shaders: + qopenglslPositionOnlyVertexShader + qopenglslPositionWithTextureBrushVertexShader + qopenglslPositionWithPatternBrushVertexShader + qopenglslPositionWithLinearGradientBrushVertexShader + qopenglslPositionWithRadialGradientBrushVertexShader + qopenglslPositionWithConicalGradientBrushVertexShader + qopenglslAffinePositionWithTextureBrushVertexShader + qopenglslAffinePositionWithPatternBrushVertexShader + qopenglslAffinePositionWithLinearGradientBrushVertexShader + qopenglslAffinePositionWithRadialGradientBrushVertexShader + qopenglslAffinePositionWithConicalGradientBrushVertexShader + + Leading to 23 possible vertex shaders + + + FRAGMENT SHADERS + ================ + + Fragment shaders are also specified as multiple (partial) shaders. The + different fragment shaders represent the different stages in Qt's fragment + pipeline. There are 1-3 stages in this pipeline: First stage is to get the + fragment's colour value. The next stage is to get the fragment's mask value + (coverage value for anti-aliasing) and the final stage is to blend the + incoming fragment with the background (for composition modes not supported + by GL). + + Of these, the first stage will always be present. If Qt doesn't need to + apply anti-aliasing (because it's off or handled by multisampling) then + the coverage value doesn't need to be applied. (Note: There are two types + of mask, one for regular anti-aliasing and one for sub-pixel anti- + aliasing.) If the composition mode is one which GL supports natively then + the blending stage doesn't need to be applied. + + As eash stage can have multiple implementations, they are abstracted as + GLSL function calls with the following signatures: + + Brushes & image drawing are implementations of "qcolorp vec4 srcPixel()": + qopenglslImageSrcFragShader + qopenglslImageSrcWithPatternFragShader + qopenglslNonPremultipliedImageSrcFragShader + qopenglslSolidBrushSrcFragShader + qopenglslTextureBrushSrcFragShader + qopenglslTextureBrushWithPatternFragShader + qopenglslPatternBrushSrcFragShader + qopenglslLinearGradientBrushSrcFragShader + qopenglslRadialGradientBrushSrcFragShader + qopenglslConicalGradientBrushSrcFragShader + NOTE: It is assumed the colour returned by srcPixel() is pre-multiplied + + Masks are implementations of "qcolorp vec4 applyMask(qcolorp vec4 src)": + qopenglslMaskFragmentShader + qopenglslRgbMaskFragmentShaderPass1 + qopenglslRgbMaskFragmentShaderPass2 + qopenglslRgbMaskWithGammaFragmentShader + + Composition modes are "qcolorp vec4 compose(qcolorp vec4 src)": + qopenglslColorBurnCompositionModeFragmentShader + qopenglslColorDodgeCompositionModeFragmentShader + qopenglslDarkenCompositionModeFragmentShader + qopenglslDifferenceCompositionModeFragmentShader + qopenglslExclusionCompositionModeFragmentShader + qopenglslHardLightCompositionModeFragmentShader + qopenglslLightenCompositionModeFragmentShader + qopenglslMultiplyCompositionModeFragmentShader + qopenglslOverlayCompositionModeFragmentShader + qopenglslScreenCompositionModeFragmentShader + qopenglslSoftLightCompositionModeFragmentShader + + + Note: In the future, some GLSL compilers will support an extension allowing + a new 'color' precision specifier. To support this, qcolorp is used for + all color components so it can be defined to colorp or lowp depending upon + the implementation. + + So there are different fragment shader main functions, depending on the + number & type of pipelines the fragment needs to go through. + + The choice of which main() fragment shader string to use depends on: + - Use of global opacity + - Brush style (some brushes apply opacity themselves) + - Use & type of mask (TODO: Need to support high quality anti-aliasing & text) + - Use of non-GL Composition mode + + Leading to the following fragment shader main functions: + gl_FragColor = compose(applyMask(srcPixel()*globalOpacity)); + gl_FragColor = compose(applyMask(srcPixel())); + gl_FragColor = applyMask(srcPixel()*globalOpacity); + gl_FragColor = applyMask(srcPixel()); + gl_FragColor = compose(srcPixel()*globalOpacity); + gl_FragColor = compose(srcPixel()); + gl_FragColor = srcPixel()*globalOpacity; + gl_FragColor = srcPixel(); + + Called: + qopenglslMainFragmentShader_CMO + qopenglslMainFragmentShader_CM + qopenglslMainFragmentShader_MO + qopenglslMainFragmentShader_M + qopenglslMainFragmentShader_CO + qopenglslMainFragmentShader_C + qopenglslMainFragmentShader_O + qopenglslMainFragmentShader + + Where: + M = Mask + C = Composition + O = Global Opacity + + + CUSTOM SHADER CODE + ================== + + The use of custom shader code is supported by the engine for drawImage and + drawPixmap calls. This is implemented via hooks in the fragment pipeline. + + The custom shader is passed to the engine as a partial fragment shader + (QOpenGLCustomShaderStage). The shader will implement a pre-defined method name + which Qt's fragment pipeline will call: + + lowp vec4 customShader(lowp sampler2d imageTexture, highp vec2 textureCoords) + + The provided src and srcCoords parameters can be used to sample from the + source image. + + Transformations, clipping, opacity, and composition modes set using QPainter + will be respected when using the custom shader hook. +*/ + +#ifndef QOPENGLENGINE_SHADER_MANAGER_H +#define QOPENGLENGINE_SHADER_MANAGER_H + +#include <QOpenGLShader> +#include <QOpenGLShaderProgram> +#include <QPainter> +#include <private/qopenglcontext_p.h> +#include <private/qopenglcustomshaderstage_p.h> + +QT_BEGIN_NAMESPACE + + + +/* +struct QOpenGLEngineCachedShaderProg +{ + QOpenGLEngineCachedShaderProg(QOpenGLEngineShaderManager::ShaderName vertexMain, + QOpenGLEngineShaderManager::ShaderName vertexPosition, + QOpenGLEngineShaderManager::ShaderName fragMain, + QOpenGLEngineShaderManager::ShaderName pixelSrc, + QOpenGLEngineShaderManager::ShaderName mask, + QOpenGLEngineShaderManager::ShaderName composition); + + int cacheKey; + QOpenGLShaderProgram* program; +} +*/ + +static const GLuint QT_VERTEX_COORDS_ATTR = 0; +static const GLuint QT_TEXTURE_COORDS_ATTR = 1; +static const GLuint QT_OPACITY_ATTR = 2; +static const GLuint QT_PMV_MATRIX_1_ATTR = 3; +static const GLuint QT_PMV_MATRIX_2_ATTR = 4; +static const GLuint QT_PMV_MATRIX_3_ATTR = 5; + +class QOpenGLEngineShaderProg; + +class Q_OPENGL_EXPORT QOpenGLEngineSharedShaders +{ + Q_GADGET +public: + + enum SnippetName { + MainVertexShader, + MainWithTexCoordsVertexShader, + MainWithTexCoordsAndOpacityVertexShader, + + // UntransformedPositionVertexShader must be first in the list: + UntransformedPositionVertexShader, + PositionOnlyVertexShader, + ComplexGeometryPositionOnlyVertexShader, + PositionWithPatternBrushVertexShader, + PositionWithLinearGradientBrushVertexShader, + PositionWithConicalGradientBrushVertexShader, + PositionWithRadialGradientBrushVertexShader, + PositionWithTextureBrushVertexShader, + AffinePositionWithPatternBrushVertexShader, + AffinePositionWithLinearGradientBrushVertexShader, + AffinePositionWithConicalGradientBrushVertexShader, + AffinePositionWithRadialGradientBrushVertexShader, + AffinePositionWithTextureBrushVertexShader, + + // MainFragmentShader_CMO must be first in the list: + MainFragmentShader_MO, + MainFragmentShader_M, + MainFragmentShader_O, + MainFragmentShader, + MainFragmentShader_ImageArrays, + + // ImageSrcFragmentShader must be first in the list:: + ImageSrcFragmentShader, + ImageSrcWithPatternFragmentShader, + NonPremultipliedImageSrcFragmentShader, + GrayscaleImageSrcFragmentShader, + AlphaImageSrcFragmentShader, + CustomImageSrcFragmentShader, + SolidBrushSrcFragmentShader, + TextureBrushSrcFragmentShader, + TextureBrushSrcWithPatternFragmentShader, + PatternBrushSrcFragmentShader, + LinearGradientBrushSrcFragmentShader, + RadialGradientBrushSrcFragmentShader, + ConicalGradientBrushSrcFragmentShader, + ShockingPinkSrcFragmentShader, + + // NoMaskFragmentShader must be first in the list: + NoMaskFragmentShader, + MaskFragmentShader, + RgbMaskFragmentShaderPass1, + RgbMaskFragmentShaderPass2, + RgbMaskWithGammaFragmentShader, + + // NoCompositionModeFragmentShader must be first in the list: + NoCompositionModeFragmentShader, + MultiplyCompositionModeFragmentShader, + ScreenCompositionModeFragmentShader, + OverlayCompositionModeFragmentShader, + DarkenCompositionModeFragmentShader, + LightenCompositionModeFragmentShader, + ColorDodgeCompositionModeFragmentShader, + ColorBurnCompositionModeFragmentShader, + HardLightCompositionModeFragmentShader, + SoftLightCompositionModeFragmentShader, + DifferenceCompositionModeFragmentShader, + ExclusionCompositionModeFragmentShader, + + TotalSnippetCount, InvalidSnippetName + }; +#if defined (QT_DEBUG) + Q_ENUM(SnippetName) + static QByteArray snippetNameStr(SnippetName snippetName); +#endif + +/* + // These allow the ShaderName enum to be used as a cache key + const int mainVertexOffset = 0; + const int positionVertexOffset = (1<<2) - PositionOnlyVertexShader; + const int mainFragOffset = (1<<6) - MainFragmentShader_CMO; + const int srcPixelOffset = (1<<10) - ImageSrcFragmentShader; + const int maskOffset = (1<<14) - NoMaskShader; + const int compositionOffset = (1 << 16) - MultiplyCompositionModeFragmentShader; +*/ + + QOpenGLEngineSharedShaders(QOpenGLContext *context); + ~QOpenGLEngineSharedShaders(); + + QOpenGLShaderProgram *simpleProgram() { return simpleShaderProg; } + QOpenGLShaderProgram *blitProgram() { return blitShaderProg; } + // Compile the program if it's not already in the cache, return the item in the cache. + QOpenGLEngineShaderProg *findProgramInCache(const QOpenGLEngineShaderProg &prog); + // Compile the custom shader if it's not already in the cache, return the item in the cache. + + static QOpenGLEngineSharedShaders *shadersForContext(QOpenGLContext *context); + + // Ideally, this would be static and cleanup all programs in all contexts which + // contain the custom code. Currently it is just a hint and we rely on deleted + // custom shaders being cleaned up by being kicked out of the cache when it's + // full. + void cleanupCustomStage(QOpenGLCustomShaderStage* stage); + +private: + QOpenGLShaderProgram *blitShaderProg; + QOpenGLShaderProgram *simpleShaderProg; + QList<QOpenGLEngineShaderProg*> cachedPrograms; + + static const char* qShaderSnippets[TotalSnippetCount]; +}; + + +class QOpenGLEngineShaderProg +{ +public: + QOpenGLEngineShaderProg() : program(nullptr) {} + + ~QOpenGLEngineShaderProg() { + if (program) + delete program; + } + + QOpenGLEngineSharedShaders::SnippetName mainVertexShader; + QOpenGLEngineSharedShaders::SnippetName positionVertexShader; + QOpenGLEngineSharedShaders::SnippetName mainFragShader; + QOpenGLEngineSharedShaders::SnippetName srcPixelFragShader; + QOpenGLEngineSharedShaders::SnippetName maskFragShader; + QOpenGLEngineSharedShaders::SnippetName compositionFragShader; + + QByteArray customStageSource; //TODO: Decent cache key for custom stages + QOpenGLShaderProgram* program; + + QList<uint> uniformLocations; + + bool useTextureCoords; + bool useOpacityAttribute; + bool usePmvMatrixAttribute; + + bool operator==(const QOpenGLEngineShaderProg& other) const { + // We don't care about the program + return ( mainVertexShader == other.mainVertexShader && + positionVertexShader == other.positionVertexShader && + mainFragShader == other.mainFragShader && + srcPixelFragShader == other.srcPixelFragShader && + maskFragShader == other.maskFragShader && + compositionFragShader == other.compositionFragShader && + customStageSource == other.customStageSource + ); + } +}; + +class Q_OPENGL_EXPORT QOpenGLEngineShaderManager : public QObject +{ + Q_OBJECT +public: + QOpenGLEngineShaderManager(QOpenGLContext* context); + ~QOpenGLEngineShaderManager(); + + enum MaskType {NoMask, PixelMask, SubPixelMaskPass1, SubPixelMaskPass2, SubPixelWithGammaMask}; + enum PixelSrcType { + ImageSrc = Qt::TexturePattern+1, + NonPremultipliedImageSrc = Qt::TexturePattern+2, + PatternSrc = Qt::TexturePattern+3, + TextureSrcWithPattern = Qt::TexturePattern+4, + GrayscaleImageSrc = Qt::TexturePattern+5, + AlphaImageSrc = Qt::TexturePattern+6, + }; + + enum Uniform { + ImageTexture, + PatternColor, + GlobalOpacity, + Depth, + MaskTexture, + FragmentColor, + LinearData, + Angle, + HalfViewportSize, + Fmp, + Fmp2MRadius2, + Inverse2Fmp2MRadius2, + SqrFr, + BRadius, + InvertedTextureSize, + BrushTransform, + BrushTexture, + Matrix, + NumUniforms + }; + + enum OpacityMode { + NoOpacity, + UniformOpacity, + AttributeOpacity + }; + + // There are optimizations we can do, depending on the brush transform: + // 1) May not have to apply perspective-correction + // 2) Can use lower precision for matrix + void optimiseForBrushTransform(QTransform::TransformationType transformType); + void setSrcPixelType(Qt::BrushStyle); + void setSrcPixelType(PixelSrcType); // For non-brush sources, like pixmaps & images + void setOpacityMode(OpacityMode); + void setMaskType(MaskType); + void setCompositionMode(QPainter::CompositionMode); + void setCustomStage(QOpenGLCustomShaderStage* stage); + void removeCustomStage(); + + GLuint getUniformLocation(Uniform id); + + void setDirty(); // someone has manually changed the current shader program + bool useCorrectShaderProg(); // returns true if the shader program needed to be changed + + void useSimpleProgram(); + void useBlitProgram(); + void setHasComplexGeometry(bool hasComplexGeometry) + { + complexGeometry = hasComplexGeometry; + shaderProgNeedsChanging = true; + } + bool hasComplexGeometry() const + { + return complexGeometry; + } + + QOpenGLShaderProgram* currentProgram(); // Returns pointer to the shader the manager has chosen + QOpenGLShaderProgram* simpleProgram(); // Used to draw into e.g. stencil buffers + QOpenGLShaderProgram* blitProgram(); // Used to blit a texture into the framebuffer + + QOpenGLEngineSharedShaders* sharedShaders; + +private: + QOpenGLContext* ctx; + bool shaderProgNeedsChanging; + bool complexGeometry; + + // Current state variables which influence the choice of shader: + QTransform brushTransform; + int srcPixelType; + OpacityMode opacityMode; + MaskType maskType; + QPainter::CompositionMode compositionMode; + QOpenGLCustomShaderStage* customSrcStage; + + QOpenGLEngineShaderProg* currentShaderProg; +}; + +QT_END_NAMESPACE + +#endif //QOPENGLENGINE_SHADER_MANAGER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglengineshadersource_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglengineshadersource_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9b7efccf7bb463b8ca91d07c9cad1352e1189f39 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglengineshadersource_p.h @@ -0,0 +1,933 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#ifndef QOPENGL_ENGINE_SHADER_SOURCE_H +#define QOPENGL_ENGINE_SHADER_SOURCE_H + +#include "qopenglengineshadermanager_p.h" + +QT_BEGIN_NAMESPACE + + +static const char* const qopenglslMainVertexShader = "\n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + }\n"; + +static const char* const qopenglslMainWithTexCoordsVertexShader = "\n\ + attribute highp vec2 textureCoordArray; \n\ + varying highp vec2 textureCoords; \n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + textureCoords = textureCoordArray; \n\ + }\n"; + +static const char* const qopenglslMainWithTexCoordsAndOpacityVertexShader = "\n\ + attribute highp vec2 textureCoordArray; \n\ + attribute lowp float opacityArray; \n\ + varying highp vec2 textureCoords; \n\ + varying lowp float opacity; \n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + textureCoords = textureCoordArray; \n\ + opacity = opacityArray; \n\ + }\n"; + +// NOTE: We let GL do the perspective correction so texture lookups in the fragment +// shader are also perspective corrected. +static const char* const qopenglslPositionOnlyVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \n\ + }\n"; + +static const char* const qopenglslComplexGeometryPositionOnlyVertexShader = "\n\ + uniform highp mat3 matrix; \n\ + attribute highp vec2 vertexCoordsArray; \n\ + void setPosition(void) \n\ + { \n\ + gl_Position = vec4(matrix * vec3(vertexCoordsArray, 1), 1);\n\ + } \n"; + +static const char* const qopenglslUntransformedPositionVertexShader = "\n\ + attribute highp vec4 vertexCoordsArray; \n\ + void setPosition(void) \n\ + { \n\ + gl_Position = vertexCoordsArray; \n\ + }\n"; + +// Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125 +static const char* const qopenglslPositionWithPatternBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp vec2 invertedTextureSize; \n\ + uniform highp mat3 brushTransform; \n\ + varying highp vec2 patternTexCoords; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \n\ + }\n"; + +static const char* const qopenglslAffinePositionWithPatternBrushVertexShader + = qopenglslPositionWithPatternBrushVertexShader; + +static const char* const qopenglslPatternBrushSrcFragmentShader = "\n\ + uniform sampler2D brushTexture; \n\ + uniform lowp vec4 patternColor; \n\ + varying highp vec2 patternTexCoords;\n\ + lowp vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture2D(brushTexture, patternTexCoords).r); \n\ + }\n"; + + +// Linear Gradient Brush +static const char* const qopenglslPositionWithLinearGradientBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp vec3 linearData; \n\ + uniform highp mat3 brushTransform; \n\ + varying mediump float index; \n\ + void setPosition() \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \n\ + }\n"; + +static const char* const qopenglslAffinePositionWithLinearGradientBrushVertexShader + = qopenglslPositionWithLinearGradientBrushVertexShader; + +static const char* const qopenglslLinearGradientBrushSrcFragmentShader = "\n\ + uniform sampler2D brushTexture; \n\ + varying mediump float index; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + mediump vec2 val = vec2(index, 0.5); \n\ + return texture2D(brushTexture, val); \n\ + }\n"; + + +// Conical Gradient Brush +static const char* const qopenglslPositionWithConicalGradientBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp mat3 brushTransform; \n\ + varying highp vec2 A; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + A = hTexCoords.xy * invertedHTexCoordsZ; \n\ + }\n"; + +static const char* const qopenglslAffinePositionWithConicalGradientBrushVertexShader + = qopenglslPositionWithConicalGradientBrushVertexShader; + +static const char* const qopenglslConicalGradientBrushSrcFragmentShader = "\n\ + #define INVERSE_2PI 0.1591549430918953358 \n\ + uniform sampler2D brushTexture; \n\ + uniform mediump float angle; \n\ + varying highp vec2 A; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + highp float t; \n\ + if (abs(A.y) == abs(A.x)) \n\ + t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \n\ + else \n\ + t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \n\ + return texture2D(brushTexture, vec2(t - floor(t), 0.5)); \n\ + }\n"; + + +// Radial Gradient Brush +static const char* const qopenglslPositionWithRadialGradientBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray;\n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp mat3 brushTransform; \n\ + uniform highp vec2 fmp; \n\ + uniform mediump vec3 bradius; \n\ + varying highp float b; \n\ + varying highp vec2 A; \n\ + void setPosition(void) \n\ + {\n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + A = hTexCoords.xy * invertedHTexCoordsZ; \n\ + b = bradius.x + 2.0 * dot(A, fmp); \n\ + }\n"; + +static const char* const qopenglslAffinePositionWithRadialGradientBrushVertexShader + = qopenglslPositionWithRadialGradientBrushVertexShader; + +static const char* const qopenglslRadialGradientBrushSrcFragmentShader = "\n\ + uniform sampler2D brushTexture; \n\ + uniform highp float fmp2_m_radius2; \n\ + uniform highp float inverse_2_fmp2_m_radius2; \n\ + uniform highp float sqrfr; \n\ + varying highp float b; \n\ + varying highp vec2 A; \n\ + uniform mediump vec3 bradius; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + highp float c = sqrfr-dot(A, A); \n\ + highp float det = b*b - 4.0*fmp2_m_radius2*c; \n\ + lowp vec4 result = vec4(0.0); \n\ + if (det >= 0.0) { \n\ + highp float detSqrt = sqrt(det); \n\ + highp float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2); \n\ + if (bradius.y + w * bradius.z >= 0.0) \n\ + result = texture2D(brushTexture, vec2(w, 0.5)); \n\ + } \n\ + return result; \n\ + }\n"; + + +// Texture Brush +static const char* const qopenglslPositionWithTextureBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp vec2 invertedTextureSize; \n\ + uniform highp mat3 brushTransform; \n\ + varying highp vec2 brushTextureCoords; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + brushTextureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \n\ + }\n"; + +static const char* const qopenglslAffinePositionWithTextureBrushVertexShader + = qopenglslPositionWithTextureBrushVertexShader; + +static const char* const qopenglslTextureBrushSrcFragmentShader = "\n\ + varying highp vec2 brushTextureCoords; \n\ + uniform sampler2D brushTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return texture2D(brushTexture, brushTextureCoords); \n\ + }\n"; + +static const char* const qopenglslTextureBrushSrcWithPatternFragmentShader = "\n\ + varying highp vec2 brushTextureCoords; \n\ + uniform lowp vec4 patternColor; \n\ + uniform sampler2D brushTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture2D(brushTexture, brushTextureCoords).r); \n\ + }\n"; + +// Solid Fill Brush +static const char* const qopenglslSolidBrushSrcFragmentShader = "\n\ + uniform lowp vec4 fragmentColor; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return fragmentColor; \n\ + }\n"; + +static const char* const qopenglslImageSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n" + "return texture2D(imageTexture, textureCoords); \n" + "}\n"; + +static const char* const qopenglslCustomSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return customShader(imageTexture, textureCoords); \n\ + }\n"; + +static const char* const qopenglslImageSrcWithPatternFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp vec4 patternColor; \n\ + uniform sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \n\ + }\n"; + +static const char* const qopenglslNonPremultipliedImageSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + lowp vec4 sample = texture2D(imageTexture, textureCoords); \n\ + sample.rgb = sample.rgb * sample.a; \n\ + return sample; \n\ + }\n"; + +static const char* const qopenglslGrayscaleImageSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return texture2D(imageTexture, textureCoords).rrra; \n\ + }\n"; + +static const char* const qopenglslAlphaImageSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return vec4(0, 0, 0, texture2D(imageTexture, textureCoords).r); \n\ + }\n"; + +static const char* const qopenglslShockingPinkSrcFragmentShader = "\n\ + lowp vec4 srcPixel() \n\ + { \n\ + return vec4(0.98, 0.06, 0.75, 1.0); \n\ + }\n"; + +static const char* const qopenglslMainFragmentShader_ImageArrays = "\n\ + varying lowp float opacity; \n\ + lowp vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + gl_FragColor = srcPixel() * opacity; \n\ + }\n"; + +static const char* const qopenglslMainFragmentShader_MO = "\n\ + uniform lowp float globalOpacity; \n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 applyMask(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = applyMask(srcPixel()*globalOpacity); \n\ + }\n"; + +static const char* const qopenglslMainFragmentShader_M = "\n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 applyMask(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = applyMask(srcPixel()); \n\ + }\n"; + +static const char* const qopenglslMainFragmentShader_O = "\n\ + uniform lowp float globalOpacity; \n\ + lowp vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + gl_FragColor = srcPixel()*globalOpacity; \n\ + }\n"; + +static const char* const qopenglslMainFragmentShader = "\n\ + lowp vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + gl_FragColor = srcPixel(); \n\ + }\n"; + +static const char* const qopenglslMaskFragmentShader = "\n\ + varying highp vec2 textureCoords;\n\ + uniform sampler2D maskTexture;\n\ + lowp vec4 applyMask(lowp vec4 src) \n\ + {\n\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ + return src * mask.a; \n\ + }\n"; + +// For source over with subpixel antialiasing, the final color is calculated per component as follows +// (.a is alpha component, .c is red, green or blue component): +// alpha = src.a * mask.c * opacity +// dest.c = dest.c * (1 - alpha) + src.c * alpha +// +// In the first pass, calculate: dest.c = dest.c * (1 - alpha) with blend funcs: zero, 1 - source color +// In the second pass, calculate: dest.c = dest.c + src.c * alpha with blend funcs: one, one +// +// If source is a solid color (src is constant), only the first pass is needed, with blend funcs: constant, 1 - source color + +// For source composition with subpixel antialiasing, the final color is calculated per component as follows: +// alpha = src.a * mask.c * opacity +// dest.c = dest.c * (1 - mask.c) + src.c * alpha +// + +static const char* const qopenglslRgbMaskFragmentShaderPass1 = "\n\ + varying highp vec2 textureCoords;\n\ + uniform sampler2D maskTexture;\n\ + lowp vec4 applyMask(lowp vec4 src) \n\ + { \n\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ + return src.a * mask; \n\ + }\n"; + +static const char* const qopenglslRgbMaskFragmentShaderPass2 = "\n\ + varying highp vec2 textureCoords;\n\ + uniform sampler2D maskTexture;\n\ + lowp vec4 applyMask(lowp vec4 src) \n\ + { \n\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ + return src * mask; \n\ + }\n"; + +static const char* const qopenglslMultiplyCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_multiply) out;\n\ + #endif\n"; + +static const char* const qopenglslScreenCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_screen) out;\n\ + #endif\n"; + +static const char* const qopenglslOverlayCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_overlay) out;\n\ + #endif\n"; + +static const char* const qopenglslDarkenCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_darken) out;\n\ + #endif\n"; + +static const char* const qopenglslLightenCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_lighten) out;\n\ + #endif\n"; + +static const char* const qopenglslColorDodgeCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_colordodge) out;\n\ + #endif\n"; + +static const char* const qopenglslColorBurnCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_colorburn) out;\n\ + #endif\n"; + +static const char* const qopenglslHardLightCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_hardlight) out;\n\ + #endif\n"; + +static const char* const qopenglslSoftLightCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_softlight) out;\n\ + #endif\n"; + +static const char* const qopenglslDifferenceCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_difference) out;\n\ + #endif\n"; + +static const char* const qopenglslExclusionCompositionModeFragmentShader = "\n\ + #ifdef GL_KHR_blend_equation_advanced\n\ + layout(blend_support_exclusion) out;\n\ + #endif\n"; + +/* + Left to implement: + RgbMaskFragmentShader, + RgbMaskWithGammaFragmentShader, +*/ + +/* + OpenGL 3.2+ Core Profile shaders + The following shader snippets are copies of the snippets above + but use the modern GLSL 1.5 keywords. New shaders should make + a snippet for both profiles and add them appropriately in the + shader manager. +*/ +static const char* const qopenglslMainVertexShader_core = + "#version 150 core\n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + }\n"; + +static const char* const qopenglslMainWithTexCoordsVertexShader_core = + "#version 150 core\n\ + in vec2 textureCoordArray; \n\ + out vec2 textureCoords; \n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + textureCoords = textureCoordArray; \n\ + }\n"; + +static const char* const qopenglslMainWithTexCoordsAndOpacityVertexShader_core = + "#version 150 core\n\ + in vec2 textureCoordArray; \n\ + in float opacityArray; \n\ + out vec2 textureCoords; \n\ + out float opacity; \n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + textureCoords = textureCoordArray; \n\ + opacity = opacityArray; \n\ + }\n"; + +// NOTE: We let GL do the perspective correction so texture lookups in the fragment +// shader are also perspective corrected. +static const char* const qopenglslPositionOnlyVertexShader_core = "\n\ + in vec2 vertexCoordsArray; \n\ + in vec3 pmvMatrix1; \n\ + in vec3 pmvMatrix2; \n\ + in vec3 pmvMatrix3; \n\ + void setPosition(void) \n\ + { \n\ + mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \n\ + }\n"; + +static const char* const qopenglslComplexGeometryPositionOnlyVertexShader_core = "\n\ + in vec2 vertexCoordsArray; \n\ + uniform mat3 matrix; \n\ + void setPosition(void) \n\ + { \n\ + gl_Position = vec4(matrix * vec3(vertexCoordsArray, 1), 1);\n\ + } \n"; + +static const char* const qopenglslUntransformedPositionVertexShader_core = "\n\ + in vec4 vertexCoordsArray; \n\ + void setPosition(void) \n\ + { \n\ + gl_Position = vertexCoordsArray; \n\ + }\n"; + +// Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125 +static const char* const qopenglslPositionWithPatternBrushVertexShader_core = "\n\ + in vec2 vertexCoordsArray; \n\ + in vec3 pmvMatrix1; \n\ + in vec3 pmvMatrix2; \n\ + in vec3 pmvMatrix3; \n\ + out vec2 patternTexCoords; \n\ + uniform vec2 halfViewportSize; \n\ + uniform vec2 invertedTextureSize; \n\ + uniform mat3 brushTransform; \n\ + void setPosition(void) \n\ + { \n\ + mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \n\ + float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \n\ + }\n"; + +static const char* const qopenglslAffinePositionWithPatternBrushVertexShader_core + = qopenglslPositionWithPatternBrushVertexShader_core; + +static const char* const qopenglslPatternBrushSrcFragmentShader_core = "\n\ + in vec2 patternTexCoords;\n\ + uniform sampler2D brushTexture; \n\ + uniform vec4 patternColor; \n\ + vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture(brushTexture, patternTexCoords).r); \n\ + }\n"; + + +// Linear Gradient Brush +static const char* const qopenglslPositionWithLinearGradientBrushVertexShader_core = "\n\ + in vec2 vertexCoordsArray; \n\ + in vec3 pmvMatrix1; \n\ + in vec3 pmvMatrix2; \n\ + in vec3 pmvMatrix3; \n\ + out float index; \n\ + uniform vec2 halfViewportSize; \n\ + uniform vec3 linearData; \n\ + uniform mat3 brushTransform; \n\ + void setPosition() \n\ + { \n\ + mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \n\ + }\n"; + +static const char* const qopenglslAffinePositionWithLinearGradientBrushVertexShader_core + = qopenglslPositionWithLinearGradientBrushVertexShader_core; + +static const char* const qopenglslLinearGradientBrushSrcFragmentShader_core = "\n\ + uniform sampler2D brushTexture; \n\ + in float index; \n\ + vec4 srcPixel() \n\ + { \n\ + vec2 val = vec2(index, 0.5); \n\ + return texture(brushTexture, val); \n\ + }\n"; + + +// Conical Gradient Brush +static const char* const qopenglslPositionWithConicalGradientBrushVertexShader_core = "\n\ + in vec2 vertexCoordsArray; \n\ + in vec3 pmvMatrix1; \n\ + in vec3 pmvMatrix2; \n\ + in vec3 pmvMatrix3; \n\ + out vec2 A; \n\ + uniform vec2 halfViewportSize; \n\ + uniform mat3 brushTransform; \n\ + void setPosition(void) \n\ + { \n\ + mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + A = hTexCoords.xy * invertedHTexCoordsZ; \n\ + }\n"; + +static const char* const qopenglslAffinePositionWithConicalGradientBrushVertexShader_core + = qopenglslPositionWithConicalGradientBrushVertexShader_core; + +static const char* const qopenglslConicalGradientBrushSrcFragmentShader_core = "\n\ + #define INVERSE_2PI 0.1591549430918953358 \n\ + in vec2 A; \n\ + uniform sampler2D brushTexture; \n\ + uniform float angle; \n\ + vec4 srcPixel() \n\ + { \n\ + float t; \n\ + if (abs(A.y) == abs(A.x)) \n\ + t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \n\ + else \n\ + t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \n\ + return texture(brushTexture, vec2(t - floor(t), 0.5)); \n\ + }\n"; + + +// Radial Gradient Brush +static const char* const qopenglslPositionWithRadialGradientBrushVertexShader_core = "\n\ + in vec2 vertexCoordsArray;\n\ + in vec3 pmvMatrix1; \n\ + in vec3 pmvMatrix2; \n\ + in vec3 pmvMatrix3; \n\ + out float b; \n\ + out vec2 A; \n\ + uniform vec2 halfViewportSize; \n\ + uniform mat3 brushTransform; \n\ + uniform vec2 fmp; \n\ + uniform vec3 bradius; \n\ + void setPosition(void) \n\ + {\n\ + mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + A = hTexCoords.xy * invertedHTexCoordsZ; \n\ + b = bradius.x + 2.0 * dot(A, fmp); \n\ + }\n"; + +static const char* const qopenglslAffinePositionWithRadialGradientBrushVertexShader_core + = qopenglslPositionWithRadialGradientBrushVertexShader_core; + +static const char* const qopenglslRadialGradientBrushSrcFragmentShader_core = "\n\ + in float b; \n\ + in vec2 A; \n\ + uniform sampler2D brushTexture; \n\ + uniform float fmp2_m_radius2; \n\ + uniform float inverse_2_fmp2_m_radius2; \n\ + uniform float sqrfr; \n\ + uniform vec3 bradius; \n\ + \n\ + vec4 srcPixel() \n\ + { \n\ + float c = sqrfr-dot(A, A); \n\ + float det = b*b - 4.0*fmp2_m_radius2*c; \n\ + vec4 result = vec4(0.0); \n\ + if (det >= 0.0) { \n\ + float detSqrt = sqrt(det); \n\ + float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2); \n\ + if (bradius.y + w * bradius.z >= 0.0) \n\ + result = texture(brushTexture, vec2(w, 0.5)); \n\ + } \n\ + return result; \n\ + }\n"; + + +// Texture Brush +static const char* const qopenglslPositionWithTextureBrushVertexShader_core = "\n\ + in vec2 vertexCoordsArray; \n\ + in vec3 pmvMatrix1; \n\ + in vec3 pmvMatrix2; \n\ + in vec3 pmvMatrix3; \n\ + out vec2 brushTextureCoords; \n\ + uniform vec2 halfViewportSize; \n\ + uniform vec2 invertedTextureSize; \n\ + uniform mat3 brushTransform; \n\ + \n\ + void setPosition(void) \n\ + { \n\ + mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + brushTextureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \n\ + }\n"; + +static const char* const qopenglslAffinePositionWithTextureBrushVertexShader_core + = qopenglslPositionWithTextureBrushVertexShader_core; + +static const char* const qopenglslTextureBrushSrcFragmentShader_core = "\n\ + in vec2 brushTextureCoords; \n\ + uniform sampler2D brushTexture; \n\ + vec4 srcPixel() \n\ + { \n\ + return texture(brushTexture, brushTextureCoords); \n\ + }\n"; + +static const char* const qopenglslTextureBrushSrcWithPatternFragmentShader_core = "\n\ + in vec2 brushTextureCoords; \n\ + uniform vec4 patternColor; \n\ + uniform sampler2D brushTexture; \n\ + vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture(brushTexture, brushTextureCoords).r); \n\ + }\n"; + +// Solid Fill Brush +static const char* const qopenglslSolidBrushSrcFragmentShader_core = "\n\ + uniform vec4 fragmentColor; \n\ + vec4 srcPixel() \n\ + { \n\ + return fragmentColor; \n\ + }\n"; + +static const char* const qopenglslImageSrcFragmentShader_core = "\n\ + in vec2 textureCoords; \n\ + uniform sampler2D imageTexture; \n\ + vec4 srcPixel() \n\ + { \n\ + return texture(imageTexture, textureCoords); \n\ + }\n"; + +static const char* const qopenglslCustomSrcFragmentShader_core = "\n\ + in vec2 textureCoords; \n\ + uniform sampler2D imageTexture; \n\ + vec4 srcPixel() \n\ + { \n\ + return customShader(imageTexture, textureCoords); \n\ + }\n"; + +static const char* const qopenglslImageSrcWithPatternFragmentShader_core = "\n\ + in vec2 textureCoords; \n\ + uniform vec4 patternColor; \n\ + uniform sampler2D imageTexture; \n\ + vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture(imageTexture, textureCoords).r); \n\ + }\n"; + +static const char* const qopenglslNonPremultipliedImageSrcFragmentShader_core = "\n\ + in vec2 textureCoords; \n\ + uniform sampler2D imageTexture; \n\ + vec4 srcPixel() \n\ + { \n\ + vec4 sample = texture(imageTexture, textureCoords); \n\ + sample.rgb = sample.rgb * sample.a; \n\ + return sample; \n\ + }\n"; + +static const char* const qopenglslGrayscaleImageSrcFragmentShader_core = "\n\ + in vec2 textureCoords; \n\ + uniform sampler2D imageTexture; \n\ + vec4 srcPixel() \n\ + { \n\ + return texture(imageTexture, textureCoords).rrra; \n\ + }\n"; + +static const char* const qopenglslAlphaImageSrcFragmentShader_core = "\n\ + in vec2 textureCoords; \n\ + uniform sampler2D imageTexture; \n\ + vec4 srcPixel() \n\ + { \n\ + return vec4(0, 0, 0, texture(imageTexture, textureCoords).r); \n\ + }\n"; + +static const char* const qopenglslShockingPinkSrcFragmentShader_core = "\n\ + vec4 srcPixel() \n\ + { \n\ + return vec4(0.98, 0.06, 0.75, 1.0); \n\ + }\n"; + +static const char* const qopenglslMainFragmentShader_ImageArrays_core = + "#version 150 core\n\ + in float opacity; \n\ + out vec4 fragColor; \n\ + vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + fragColor = srcPixel() * opacity; \n\ + }\n"; + +static const char* const qopenglslMainFragmentShader_MO_core = + "#version 150 core\n\ + out vec4 fragColor; \n\ + uniform float globalOpacity; \n\ + vec4 srcPixel(); \n\ + vec4 applyMask(vec4); \n\ + void main() \n\ + { \n\ + fragColor = applyMask(srcPixel()*globalOpacity); \n\ + }\n"; + +static const char* const qopenglslMainFragmentShader_M_core = + "#version 150 core\n\ + out vec4 fragColor; \n\ + vec4 srcPixel(); \n\ + vec4 applyMask(vec4); \n\ + void main() \n\ + { \n\ + fragColor = applyMask(srcPixel()); \n\ + }\n"; + +static const char* const qopenglslMainFragmentShader_O_core = + "#version 150 core\n\ + out vec4 fragColor; \n\ + uniform float globalOpacity; \n\ + vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + fragColor = srcPixel()*globalOpacity; \n\ + }\n"; + +static const char* const qopenglslMainFragmentShader_core = + "#version 150 core\n\ + out vec4 fragColor; \n\ + vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + fragColor = srcPixel(); \n\ + }\n"; + +static const char* const qopenglslMaskFragmentShader_core = "\n\ + in vec2 textureCoords;\n\ + uniform sampler2D maskTexture;\n\ + vec4 applyMask(vec4 src) \n\ + {\n\ + vec4 mask = texture(maskTexture, textureCoords); \n\ + return src * mask.r; \n\ + }\n"; + +// For source over with subpixel antialiasing, the final color is calculated per component as follows +// (.a is alpha component, .c is red, green or blue component): +// alpha = src.a * mask.c * opacity +// dest.c = dest.c * (1 - alpha) + src.c * alpha +// +// In the first pass, calculate: dest.c = dest.c * (1 - alpha) with blend funcs: zero, 1 - source color +// In the second pass, calculate: dest.c = dest.c + src.c * alpha with blend funcs: one, one +// +// If source is a solid color (src is constant), only the first pass is needed, with blend funcs: constant, 1 - source color + +// For source composition with subpixel antialiasing, the final color is calculated per component as follows: +// alpha = src.a * mask.c * opacity +// dest.c = dest.c * (1 - mask.c) + src.c * alpha +// + +static const char* const qopenglslRgbMaskFragmentShaderPass1_core = "\n\ + in vec2 textureCoords;\n\ + uniform sampler2D maskTexture;\n\ + vec4 applyMask(vec4 src) \n\ + { \n\ + vec4 mask = texture(maskTexture, textureCoords); \n\ + return src.a * mask; \n\ + }\n"; + +static const char* const qopenglslRgbMaskFragmentShaderPass2_core = "\n\ + in vec2 textureCoords;\n\ + uniform sampler2D maskTexture;\n\ + vec4 applyMask(vec4 src) \n\ + { \n\ + vec4 mask = texture(maskTexture, textureCoords); \n\ + return src * mask; \n\ + }\n"; + +/* + Left to implement: + RgbMaskFragmentShader_core, + RgbMaskWithGammaFragmentShader_core, +*/ + +QT_END_NAMESPACE + +#endif // GLGC_SHADER_SOURCE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglframebufferobject_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglframebufferobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4cbe66e00aec104569af6e3e7e776a242923327e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglframebufferobject_p.h @@ -0,0 +1,118 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGLFRAMEBUFFEROBJECT_P_H +#define QOPENGLFRAMEBUFFEROBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qvarlengtharray.h> +#include <qopenglframebufferobject.h> +#include <private/qopenglcontext_p.h> +#include <private/qopenglextensions_p.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLFramebufferObjectFormatPrivate +{ +public: + QOpenGLFramebufferObjectFormatPrivate() + : ref(1), + samples(0), + attachment(QOpenGLFramebufferObject::NoAttachment), + target(GL_TEXTURE_2D), + mipmap(false) + { +#if !QT_CONFIG(opengles2) + // There is nothing that says QOpenGLFramebufferObjectFormat needs a current + // context, so we need a fallback just to be safe, even though in practice there + // will usually be a current context. + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + const bool isES = ctx ? ctx->isOpenGLES() : QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL; + internal_format = isES ? GL_RGBA : GL_RGBA8; +#else + internal_format = GL_RGBA; +#endif + } + QOpenGLFramebufferObjectFormatPrivate + (const QOpenGLFramebufferObjectFormatPrivate *other) + : ref(1), + samples(other->samples), + attachment(other->attachment), + target(other->target), + internal_format(other->internal_format), + mipmap(other->mipmap) + { + } + bool equals(const QOpenGLFramebufferObjectFormatPrivate *other) + { + return samples == other->samples && + attachment == other->attachment && + target == other->target && + internal_format == other->internal_format && + mipmap == other->mipmap; + } + + QAtomicInt ref; + int samples; + QOpenGLFramebufferObject::Attachment attachment; + GLenum target; + GLenum internal_format; + uint mipmap : 1; +}; + +class QOpenGLFramebufferObjectPrivate +{ +public: + QOpenGLFramebufferObjectPrivate() : fbo_guard(nullptr), depth_buffer_guard(nullptr) + , stencil_buffer_guard(nullptr) + , valid(false) {} + ~QOpenGLFramebufferObjectPrivate() {} + + void init(QOpenGLFramebufferObject *q, const QSize &size, + QOpenGLFramebufferObject::Attachment attachment, + GLenum texture_target, GLenum internal_format, + GLint samples = 0, bool mipmap = false); + void initTexture(int idx); + void initColorBuffer(int idx, GLint *samples); + void initDepthStencilAttachments(QOpenGLContext *ctx, QOpenGLFramebufferObject::Attachment attachment); + + bool checkFramebufferStatus(QOpenGLContext *ctx) const; + QOpenGLSharedResourceGuard *fbo_guard; + QOpenGLSharedResourceGuard *depth_buffer_guard; + QOpenGLSharedResourceGuard *stencil_buffer_guard; + GLenum target; + QSize dsSize; + QOpenGLFramebufferObjectFormat format; + int requestedSamples; + uint valid : 1; + QOpenGLFramebufferObject::Attachment fbo_attachment; + QOpenGLExtensions funcs; + + struct ColorAttachment { + ColorAttachment() : internalFormat(0), guard(nullptr) { } + ColorAttachment(const QSize &size, GLenum internalFormat) + : size(size), internalFormat(internalFormat), guard(nullptr) { } + QSize size; + GLenum internalFormat; + QOpenGLSharedResourceGuard *guard; + }; + QVarLengthArray<ColorAttachment, 8> colorAttachments; + + inline GLuint fbo() const { return fbo_guard ? fbo_guard->id() : 0; } +}; + +Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); + +QT_END_NAMESPACE + +#endif // QOPENGLFRAMEBUFFEROBJECT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglgradientcache_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglgradientcache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5f0cf4d8fb7d34f5c84e42d8bfa754ea0e7276a6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglgradientcache_p.h @@ -0,0 +1,71 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGLGRADIENTCACHE_P_H +#define QOPENGLGRADIENTCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QMultiHash> +#include <QObject> +#include <private/qopenglcontext_p.h> +#include <QtCore/qmutex.h> +#include <QGradient> +#include <qrgba64.h> + +QT_BEGIN_NAMESPACE + +class QOpenGL2GradientCache : public QOpenGLSharedResource +{ + struct CacheInfo + { + inline CacheInfo(QGradientStops s, qreal op, QGradient::InterpolationMode mode) : + stops(std::move(s)), opacity(op), interpolationMode(mode) {} + + GLuint texId; + QGradientStops stops; + qreal opacity; + QGradient::InterpolationMode interpolationMode; + }; + + typedef QMultiHash<quint64, CacheInfo> QOpenGLGradientColorTableHash; + +public: + static QOpenGL2GradientCache *cacheForContext(QOpenGLContext *context); + + QOpenGL2GradientCache(QOpenGLContext *); + ~QOpenGL2GradientCache(); + + GLuint getBuffer(const QGradient &gradient, qreal opacity); + inline int paletteSize() const { return 1024; } + + void invalidateResource() override; + void freeResource(QOpenGLContext *ctx) override; + +private: + inline int maxCacheSize() const { return 60; } + inline void generateGradientColorTable(const QGradient& gradient, + QRgba64 *colorTable, + int size, qreal opacity) const; + inline void generateGradientColorTable(const QGradient& gradient, + uint *colorTable, + int size, qreal opacity) const; + GLuint addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity); + void cleanCache(); + + QOpenGLGradientColorTableHash cache; + QMutex m_mutex; +}; + +QT_END_NAMESPACE + +#endif // QOPENGLGRADIENTCACHE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglpaintdevice_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglpaintdevice_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9cf7ffa0d7ba9b53a8cc12d2092d2bb4b63b310c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglpaintdevice_p.h @@ -0,0 +1,52 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGL_PAINTDEVICE_P_H +#define QOPENGL_PAINTDEVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Qt OpenGL classes. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <qopenglpaintdevice.h> +#include <private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLContext; +class QPaintEngine; + +class Q_OPENGL_EXPORT QOpenGLPaintDevicePrivate +{ +public: + QOpenGLPaintDevicePrivate(const QSize &size); + virtual ~QOpenGLPaintDevicePrivate(); + + static QOpenGLPaintDevicePrivate *get(QOpenGLPaintDevice *dev) { return dev->d_func(); } + + virtual void beginPaint() { } + virtual void endPaint() { } + +public: + QSize size; + QOpenGLContext *ctx; + + qreal dpmx; + qreal dpmy; + qreal devicePixelRatio; + + bool flipped; + + QPaintEngine *engine; +}; + +QT_END_NAMESPACE + +#endif // QOPENGL_PAINTDEVICE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglpaintengine_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglpaintengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ee3d36c9e8271255fb23678f0bb13286f75a7ea4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglpaintengine_p.h @@ -0,0 +1,340 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGLPAINTENGINE_P_H +#define QOPENGLPAINTENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QDebug> + +#include <qopenglpaintdevice.h> + +#include <private/qpaintengineex_p.h> +#include <private/qopenglengineshadermanager_p.h> +#include <private/qopengl2pexvertexarray_p.h> +#include <private/qfontengine_p.h> +#include <private/qdatabuffer_p.h> +#include <private/qtriangulatingstroker_p.h> + +#include <private/qopenglextensions_p.h> + +#include <QOpenGLVertexArrayObject> +#include <QOpenGLBuffer> + +enum EngineMode { + ImageDrawingMode, + TextDrawingMode, + BrushDrawingMode, + ImageArrayDrawingMode, + ImageOpacityArrayDrawingMode +}; + +QT_BEGIN_NAMESPACE + +#define GL_STENCIL_HIGH_BIT GLuint(0x80) +#define QT_UNKNOWN_TEXTURE_UNIT GLuint(-1) +#define QT_DEFAULT_TEXTURE_UNIT GLuint(0) +#define QT_BRUSH_TEXTURE_UNIT GLuint(0) +#define QT_IMAGE_TEXTURE_UNIT GLuint(0) //Can be the same as brush texture unit +#define QT_MASK_TEXTURE_UNIT GLuint(1) +#define QT_BACKGROUND_TEXTURE_UNIT GLuint(2) + +class QOpenGL2PaintEngineExPrivate; + +class QOpenGL2PaintEngineState : public QPainterState +{ +public: + QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &other); + QOpenGL2PaintEngineState(); + ~QOpenGL2PaintEngineState(); + + uint isNew : 1; + uint needsClipBufferClear : 1; + uint clipTestEnabled : 1; + uint canRestoreClip : 1; + uint matrixChanged : 1; + uint compositionModeChanged : 1; + uint opacityChanged : 1; + uint renderHintsChanged : 1; + uint clipChanged : 1; + uint currentClip : 8; + + QRect rectangleClip; +}; + +class Q_OPENGL_EXPORT QOpenGL2PaintEngineEx : public QPaintEngineEx +{ + Q_DECLARE_PRIVATE(QOpenGL2PaintEngineEx) +public: + QOpenGL2PaintEngineEx(); + ~QOpenGL2PaintEngineEx(); + + bool begin(QPaintDevice *device) override; + void ensureActive(); + bool end() override; + + virtual void clipEnabledChanged() override; + virtual void penChanged() override; + virtual void brushChanged() override; + virtual void brushOriginChanged() override; + virtual void opacityChanged() override; + virtual void compositionModeChanged() override; + virtual void renderHintsChanged() override; + virtual void transformChanged() override; + + virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; + virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, + QPainter::PixmapFragmentHints hints) override; + virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, + Qt::ImageConversionFlags flags = Qt::AutoColor) override; + virtual void drawTextItem(const QPointF &p, const QTextItem &textItem) override; + virtual void fill(const QVectorPath &path, const QBrush &brush) override; + virtual void stroke(const QVectorPath &path, const QPen &pen) override; + virtual void clip(const QVectorPath &path, Qt::ClipOperation op) override; + + virtual void drawStaticTextItem(QStaticTextItem *textItem) override; + + bool drawTexture(const QRectF &r, GLuint textureId, const QSize &size, const QRectF &sr); + + Type type() const override { return OpenGL2; } + + virtual void setState(QPainterState *s) override; + virtual QPainterState *createState(QPainterState *orig) const override; + inline QOpenGL2PaintEngineState *state() { + return static_cast<QOpenGL2PaintEngineState *>(QPaintEngineEx::state()); + } + inline const QOpenGL2PaintEngineState *state() const { + return static_cast<const QOpenGL2PaintEngineState *>(QPaintEngineEx::state()); + } + + void beginNativePainting() override; + void endNativePainting() override; + + void invalidateState(); + + void setRenderTextActive(bool); + + bool isNativePaintingActive() const; + bool requiresPretransformedGlyphPositions(QFontEngine *, const QTransform &) const override { return false; } + bool shouldDrawCachedGlyphs(QFontEngine *, const QTransform &) const override; + +private: + Q_DISABLE_COPY_MOVE(QOpenGL2PaintEngineEx) + + friend class QOpenGLEngineShaderManager; +}; + +// This probably needs to grow to GL_MAX_VERTEX_ATTRIBS, but 3 is ok for now as that's +// all the GL2 engine uses: +#define QT_GL_VERTEX_ARRAY_TRACKED_COUNT 3 + +class QOpenGL2PaintEngineExPrivate : public QPaintEngineExPrivate +{ + Q_DECLARE_PUBLIC(QOpenGL2PaintEngineEx) +public: + enum StencilFillMode { + OddEvenFillMode, + WindingFillMode, + TriStripStrokeFillMode + }; + + QOpenGL2PaintEngineExPrivate(QOpenGL2PaintEngineEx *q_ptr) : + q(q_ptr), + shaderManager(nullptr), + width(0), height(0), + ctx(nullptr), + useSystemClip(true), + elementIndicesVBOId(0), + opacityArray(0), + snapToPixelGrid(false), + nativePaintingActive(false), + inverseScale(1), + lastTextureUnitUsed(QT_UNKNOWN_TEXTURE_UNIT), + vertexBuffer(QOpenGLBuffer::VertexBuffer), + texCoordBuffer(QOpenGLBuffer::VertexBuffer), + opacityBuffer(QOpenGLBuffer::VertexBuffer), + indexBuffer(QOpenGLBuffer::IndexBuffer) + { } + + ~QOpenGL2PaintEngineExPrivate(); + + void updateBrushTexture(); + void updateBrushUniforms(); + void updateMatrix(); + void updateCompositionMode(); + + enum TextureUpdateMode { UpdateIfNeeded, ForceUpdate }; + template<typename T> + void updateTexture(GLenum textureUnit, const T &texture, GLenum wrapMode, GLenum filterMode, TextureUpdateMode updateMode = UpdateIfNeeded); + template<typename T> + GLuint bindTexture(const T &texture, bool *newTextureCreated); + void activateTextureUnit(GLenum textureUnit); + + void resetGLState(); + + // fill, stroke, drawTexture, drawPixmaps & drawCachedGlyphs are the main rendering entry-points, + // however writeClip can also be thought of as en entry point as it does similar things. + void fill(const QVectorPath &path); + void stroke(const QVectorPath &path, const QPen &pen); + void drawTexture(const QOpenGLRect& dest, const QOpenGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false); + void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, + QPainter::PixmapFragmentHints hints); + void drawCachedGlyphs(QFontEngine::GlyphFormat glyphFormat, QStaticTextItem *staticTextItem); + + // Calls glVertexAttributePointer if the pointer has changed + inline void uploadData(unsigned int arrayIndex, const GLfloat *data, GLuint count); + inline bool uploadIndexData(const void *data, GLenum indexValueType, GLuint count); + + // draws whatever is in the vertex array: + void drawVertexArrays(const float *data, int *stops, int stopCount, GLenum primitive); + void drawVertexArrays(QOpenGL2PEXVertexArray &vertexArray, GLenum primitive) { + drawVertexArrays((const float *) vertexArray.data(), vertexArray.stops(), vertexArray.stopCount(), primitive); + } + + // Composites the bounding rect onto dest buffer: + void composite(const QOpenGLRect& boundingRect); + + // Calls drawVertexArrays to render into stencil buffer: + void fillStencilWithVertexArray(const float *data, int count, int *stops, int stopCount, const QOpenGLRect &bounds, StencilFillMode mode); + void fillStencilWithVertexArray(QOpenGL2PEXVertexArray& vertexArray, bool useWindingFill) { + fillStencilWithVertexArray((const float *) vertexArray.data(), 0, vertexArray.stops(), vertexArray.stopCount(), + vertexArray.boundingRect(), + useWindingFill ? WindingFillMode : OddEvenFillMode); + } + + void setBrush(const QBrush& brush); + void transferMode(EngineMode newMode); + bool prepareForDraw(bool srcPixelsAreOpaque); // returns true if the program has changed + bool prepareForCachedGlyphDraw(const QFontEngineGlyphCache &cache); + inline void useSimpleShader(); + inline GLuint location(const QOpenGLEngineShaderManager::Uniform uniform) { + return shaderManager->getUniformLocation(uniform); + } + + void clearClip(uint value); + void writeClip(const QVectorPath &path, uint value); + void resetClipIfNeeded(); + + void updateClipScissorTest(); + void setScissor(const QRect &rect); + void regenerateClip(); + void systemStateChanged() override; + + void setVertexAttribArrayEnabled(int arrayIndex, bool enabled = true); + void syncGlState(); + + static QOpenGLEngineShaderManager* shaderManagerForEngine(QOpenGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; } + static QOpenGL2PaintEngineExPrivate *getData(QOpenGL2PaintEngineEx *engine) { return engine->d_func(); } + static void cleanupVectorPath(QPaintEngineEx *engine, void *data); + + QOpenGLExtensions funcs; + + QOpenGL2PaintEngineEx* q; + QOpenGLEngineShaderManager* shaderManager; + QOpenGLPaintDevice* device; + int width, height; + QPointer<QOpenGLContext> ctx; + EngineMode mode; + QFontEngine::GlyphFormat glyphCacheFormat; + + bool vertexAttributeArraysEnabledState[QT_GL_VERTEX_ARRAY_TRACKED_COUNT]; + + // Dirty flags + bool matrixDirty; // Implies matrix uniforms are also dirty + bool compositionModeDirty; + bool brushTextureDirty; + bool brushUniformsDirty; + bool opacityUniformDirty; + bool matrixUniformDirty; + + bool stencilClean; // Has the stencil not been used for clipping so far? + bool useSystemClip; + QRegion dirtyStencilRegion; + QRect currentScissorBounds; + uint maxClip; + + QBrush currentBrush; // May not be the state's brush! + const QBrush noBrush; + + QImage currentBrushImage; + + QOpenGL2PEXVertexArray vertexCoordinateArray; + QOpenGL2PEXVertexArray textureCoordinateArray; + QList<GLushort> elementIndices; + GLuint elementIndicesVBOId; + QDataBuffer<GLfloat> opacityArray; + GLfloat staticVertexCoordinateArray[8]; + GLfloat staticTextureCoordinateArray[8]; + + bool snapToPixelGrid; + bool nativePaintingActive; + GLfloat pmvMatrix[3][3]; + GLfloat inverseScale; + + GLenum lastTextureUnitUsed; + GLuint lastTextureUsed; + + QOpenGLVertexArrayObject vao; + QOpenGLBuffer vertexBuffer; + QOpenGLBuffer texCoordBuffer; + QOpenGLBuffer opacityBuffer; + QOpenGLBuffer indexBuffer; + + bool needsSync; + bool multisamplingAlwaysEnabled; + + QTriangulatingStroker stroker; + QDashedStrokeProcessor dasher; + + QVarLengthArray<GLuint, 8> unusedVBOSToClean; + QVarLengthArray<GLuint, 8> unusedIBOSToClean; + + const GLfloat *vertexAttribPointers[3]; +}; + + +void QOpenGL2PaintEngineExPrivate::uploadData(unsigned int arrayIndex, const GLfloat *data, GLuint count) +{ + Q_ASSERT(arrayIndex < 3); + + if (arrayIndex == QT_VERTEX_COORDS_ATTR) { + vertexBuffer.bind(); + vertexBuffer.allocate(data, count * sizeof(float)); + } + if (arrayIndex == QT_TEXTURE_COORDS_ATTR) { + texCoordBuffer.bind(); + texCoordBuffer.allocate(data, count * sizeof(float)); + } + if (arrayIndex == QT_OPACITY_ATTR) { + opacityBuffer.bind(); + opacityBuffer.allocate(data, count * sizeof(float)); + + funcs.glVertexAttribPointer(arrayIndex, 1, GL_FLOAT, GL_FALSE, 0, nullptr); + } else { + funcs.glVertexAttribPointer(arrayIndex, 2, GL_FLOAT, GL_FALSE, 0, nullptr); + } +} + +bool QOpenGL2PaintEngineExPrivate::uploadIndexData(const void *data, GLenum indexValueType, GLuint count) +{ + Q_ASSERT(indexValueType == GL_UNSIGNED_SHORT || indexValueType == GL_UNSIGNED_INT); + indexBuffer.bind(); + indexBuffer.allocate( + data, + count * (indexValueType == GL_UNSIGNED_SHORT ? sizeof(quint16) : sizeof(quint32))); + return true; +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglqueryhelper_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglqueryhelper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..748cb1432ff16e93bbf89cf44ddfca050515d003 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglqueryhelper_p.h @@ -0,0 +1,150 @@ +// Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGLQUERYHELPER_P_H +#define QOPENGLQUERYHELPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> + +#if !QT_CONFIG(opengles2) + +#include <QtGui/QOpenGLContext> + +QT_BEGIN_NAMESPACE + +// Helper class used by QOpenGLTimerQuery and later will be used by +// QOpenGLOcclusionQuery +class QOpenGLQueryHelper +{ +public: + QOpenGLQueryHelper(QOpenGLContext *context) + : GetQueryObjectuiv(nullptr), + GetQueryObjectiv(nullptr), + GetQueryiv(nullptr), + EndQuery(nullptr), + BeginQuery(nullptr), + IsQuery(nullptr), + DeleteQueries(nullptr), + GenQueries(nullptr), + GetInteger64v(nullptr), + GetQueryObjectui64v(nullptr), + GetQueryObjecti64v(nullptr), + QueryCounter(nullptr) + { + Q_ASSERT(context); + + // Core in OpenGL >=1.5 + GetQueryObjectuiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint *)>(context->getProcAddress("glGetQueryObjectuiv")); + GetQueryObjectiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLint *)>(context->getProcAddress("glGetQueryObjectiv")); + GetQueryiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLint *)>(context->getProcAddress("glGetQueryiv")); + EndQuery = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum )>(context->getProcAddress("glEndQuery")); + BeginQuery = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLuint )>(context->getProcAddress("glBeginQuery")); + IsQuery = reinterpret_cast<GLboolean (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress("glIsQuery")); + DeleteQueries = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress("glDeleteQueries")); + GenQueries = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress("glGenQueries")); + + // Core in OpenGL >=3.2 + GetInteger64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint64 *)>(context->getProcAddress("glGetInteger64v")); + + // Core in OpenGL >=3.3 / ARB_timer_query + GetQueryObjectui64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint64 *)>(context->getProcAddress("glGetQueryObjectui64v")); + GetQueryObjecti64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLint64 *)>(context->getProcAddress("glGetQueryObjecti64v")); + QueryCounter = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum )>(context->getProcAddress("glQueryCounter")); + } + + inline void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) + { + GetQueryObjectuiv(id, pname, params); + } + + inline void glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) + { + GetQueryObjectiv(id, pname, params); + } + + inline void glGetQueryiv(GLenum target, GLenum pname, GLint *params) + { + GetQueryiv(target, pname, params); + } + + inline void glEndQuery(GLenum target) + { + EndQuery(target); + } + + inline void glBeginQuery(GLenum target, GLuint id) + { + BeginQuery(target, id); + } + + inline GLboolean glIsQuery(GLuint id) + { + return IsQuery(id); + } + + inline void glDeleteQueries(GLsizei n, const GLuint *ids) + { + DeleteQueries(n, ids); + } + + inline void glGenQueries(GLsizei n, GLuint *ids) + { + GenQueries(n, ids); + } + + inline void glGetInteger64v(GLenum pname, GLint64 *params) + { + GetInteger64v(pname, params); + } + + inline void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) + { + GetQueryObjectui64v(id, pname, params); + } + + inline void glGetQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) + { + GetQueryObjecti64v(id, pname, params); + } + + inline void glQueryCounter(GLuint id, GLenum target) + { + QueryCounter(id, target); + } + +private: + // Core in OpenGL >=1.5 + void (QOPENGLF_APIENTRYP GetQueryObjectuiv)(GLuint id, GLenum pname, GLuint *params); + void (QOPENGLF_APIENTRYP GetQueryObjectiv)(GLuint id, GLenum pname, GLint *params); + void (QOPENGLF_APIENTRYP GetQueryiv)(GLenum target, GLenum pname, GLint *params); + void (QOPENGLF_APIENTRYP EndQuery)(GLenum target); + void (QOPENGLF_APIENTRYP BeginQuery)(GLenum target, GLuint id); + GLboolean (QOPENGLF_APIENTRYP IsQuery)(GLuint id); + void (QOPENGLF_APIENTRYP DeleteQueries)(GLsizei n, const GLuint *ids); + void (QOPENGLF_APIENTRYP GenQueries)(GLsizei n, GLuint *ids); + + // Core in OpenGL >=3.2 + void (QOPENGLF_APIENTRYP GetInteger64v)(GLenum pname, GLint64 *params); + + // Core in OpenGL >=3.3 and provided by ARB_timer_query + void (QOPENGLF_APIENTRYP GetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 *params); + void (QOPENGLF_APIENTRYP GetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 *params); + void (QOPENGLF_APIENTRYP QueryCounter)(GLuint id, GLenum target); +}; + +QT_END_NAMESPACE + +#endif + +#endif // QOPENGLQUERYHELPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglshadercache_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglshadercache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2aa9986e0129443da5c13f454cad2dd7f1caf437 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglshadercache_p.h @@ -0,0 +1,51 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QOPENGLSHADERCACHE_P_H +#define QOPENGLSHADERCACHE_P_H + +#include <QtOpenGL/qtopenglglobal.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + + +class QOpenGLShaderProgram; +class QOpenGLContext; + +class CachedShader +{ +public: + inline CachedShader(const QByteArray &, const QByteArray &) + {} + + inline bool isCached() + { + return false; + } + + inline bool load(QOpenGLShaderProgram *, QOpenGLContext *) + { + return false; + } + + inline bool store(QOpenGLShaderProgram *, QOpenGLContext *) + { + return false; + } +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltexture_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltexture_p.h new file mode 100644 index 0000000000000000000000000000000000000000..319d74b51a73c07adff40192907ee0f4f1277699 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltexture_p.h @@ -0,0 +1,148 @@ +// Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTOPENGLTEXTURE_P_H +#define QABSTRACTOPENGLTEXTURE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QT_NO_OPENGL + +#include <QtOpenGL/qtopenglglobal.h> +#include "private/qobject_p.h" +#include "qopengltexture.h" +#include "qopengl.h" + +#include <cmath> + +namespace { +inline double qLog2(const double x) +{ + return std::log(x) / std::log(2.0); +} +} + +QT_BEGIN_NAMESPACE + +class QOpenGLContext; +class QOpenGLTextureHelper; +class QOpenGLFunctions; + +class QOpenGLTexturePrivate +{ +public: + QOpenGLTexturePrivate(QOpenGLTexture::Target textureTarget, + QOpenGLTexture *qq); + ~QOpenGLTexturePrivate(); + + Q_DECLARE_PUBLIC(QOpenGLTexture) + + void resetFuncs(QOpenGLTextureHelper *funcs); + void initializeOpenGLFunctions(); + + bool create(); + void destroy(); + + void bind(); + void bind(uint unit, QOpenGLTexture::TextureUnitReset reset = QOpenGLTexture::DontResetTextureUnit); + void release(); + void release(uint unit, QOpenGLTexture::TextureUnitReset reset = QOpenGLTexture::DontResetTextureUnit); + bool isBound() const; + bool isBound(uint unit) const; + + void allocateStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType); + void allocateMutableStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType); + void allocateImmutableStorage(); + void setData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, + QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options); + void setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, + int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, + QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options); + void setCompressedData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, + int dataSize, const void *data, + const QOpenGLPixelTransferOptions * const options); + + + void setWrapMode(QOpenGLTexture::WrapMode mode); + void setWrapMode(QOpenGLTexture::CoordinateDirection direction, QOpenGLTexture::WrapMode mode); + QOpenGLTexture::WrapMode wrapMode(QOpenGLTexture::CoordinateDirection direction) const; + + QOpenGLTexture *createTextureView(QOpenGLTexture::Target target, QOpenGLTexture::TextureFormat viewFormat, + int minimumMipmapLevel, int maximumMipmapLevel, + int minimumLayer, int maximumLayer) const; + + int evaluateMipLevels() const; + + inline int maximumMipLevelCount() const + { + return 1 + std::floor(qLog2(qMax(dimensions[0], qMax(dimensions[1], dimensions[2])))); + } + + static inline int mipLevelSize(int mipLevel, int baseLevelSize) + { + return std::floor(double(qMax(1, baseLevelSize >> mipLevel))); + } + + bool isUsingImmutableStorage() const; + + QOpenGLTexture *q_ptr; + QOpenGLContext *context; + QOpenGLTexture::Target target; + QOpenGLTexture::BindingTarget bindingTarget; + GLuint textureId; + QOpenGLTexture::TextureFormat format; + QOpenGLTexture::TextureFormatClass formatClass; + int dimensions[3]; + int requestedMipLevels; + int mipLevels; + int layers; + int faces; + + int samples; + bool fixedSamplePositions; + + int baseLevel; + int maxLevel; + + QOpenGLTexture::SwizzleValue swizzleMask[4]; + QOpenGLTexture::DepthStencilMode depthStencilMode; + QOpenGLTexture::ComparisonFunction comparisonFunction; + QOpenGLTexture::ComparisonMode comparisonMode; + + QOpenGLTexture::Filter minFilter; + QOpenGLTexture::Filter magFilter; + float maxAnisotropy; + QOpenGLTexture::WrapMode wrapModes[3]; + QVariantList borderColor; + float minLevelOfDetail; + float maxLevelOfDetail; + float levelOfDetailBias; + + bool textureView; + bool autoGenerateMipMaps; + bool storageAllocated; + + QOpenGLTextureHelper *texFuncs; + QOpenGLFunctions *functions; + + QOpenGLTexture::Features features; +}; + +QT_END_NAMESPACE + +#undef Q_CALL_MEMBER_FUNCTION + +#endif // QT_NO_OPENGL + +#endif // QABSTRACTOPENGLTEXTURE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltexturecache_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltexturecache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2cc0fc5ef1ac331c526853a2c57a2b595e2992cf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltexturecache_p.h @@ -0,0 +1,84 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QOPENGLTEXTURECACHE_P_H +#define QOPENGLTEXTURECACHE_P_H + +#include <QtOpenGL/qtopenglglobal.h> +#include <QHash> +#include <QObject> +#include <QCache> +#include <private/qopenglcontext_p.h> +#include <private/qopengltextureuploader_p.h> +#include <QtCore/qmutex.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLCachedTexture; + +class Q_OPENGL_EXPORT QOpenGLTextureCache : public QOpenGLSharedResource +{ +public: + static QOpenGLTextureCache *cacheForContext(QOpenGLContext *context); + + QOpenGLTextureCache(QOpenGLContext *); + ~QOpenGLTextureCache(); + + enum class BindResultFlag : quint8 { + NewTexture = 0x01 + }; + Q_DECLARE_FLAGS(BindResultFlags, BindResultFlag) + + struct BindResult { + GLuint id; + BindResultFlags flags; + }; + + BindResult bindTexture(QOpenGLContext *context, const QPixmap &pixmap, + QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption); + BindResult bindTexture(QOpenGLContext *context, const QImage &image, + QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption); + + void invalidate(qint64 key); + + void invalidateResource() override; + void freeResource(QOpenGLContext *ctx) override; + +private: + BindResult bindTexture(QOpenGLContext *context, qint64 key, const QImage &image, QOpenGLTextureUploader::BindOptions options); + + QMutex m_mutex; + QCache<quint64, QOpenGLCachedTexture> m_cache; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLTextureCache::BindResultFlags) + +class QOpenGLCachedTexture +{ +public: + QOpenGLCachedTexture(GLuint id, QOpenGLTextureUploader::BindOptions options, QOpenGLContext *context); + ~QOpenGLCachedTexture() { m_resource->free(); } + + GLuint id() const { return m_resource->id(); } + QOpenGLTextureUploader::BindOptions options() const { return m_options; } + +private: + QOpenGLSharedResourceGuard *m_resource; + QOpenGLTextureUploader::BindOptions m_options; +}; + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltextureglyphcache_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltextureglyphcache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9352d8d98c8a3e5dfd1e5899fe60e7e134fbec54 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltextureglyphcache_p.h @@ -0,0 +1,147 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGLTEXTUREGLYPHCACHE_P_H +#define QOPENGLTEXTUREGLYPHCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtOpenGL/qtopenglglobal.h> +#include <private/qtextureglyphcache_p.h> +#include <private/qopenglcontext_p.h> +#include <qopenglshaderprogram.h> +#include <qopenglfunctions.h> +#include <qopenglbuffer.h> +#include <qopenglvertexarrayobject.h> + +// #define QT_GL_TEXTURE_GLYPH_CACHE_DEBUG + +QT_BEGIN_NAMESPACE + +class QOpenGL2PaintEngineExPrivate; + +class QOpenGLGlyphTexture : public QOpenGLSharedResource +{ +public: + explicit QOpenGLGlyphTexture(QOpenGLContext *ctx) + : QOpenGLSharedResource(ctx->shareGroup()) + , m_width(0) + , m_height(0) + { + if (!ctx->d_func()->workaround_brokenFBOReadBack) + QOpenGLFunctions(ctx).glGenFramebuffers(1, &m_fbo); + +#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG + qDebug(" -> QOpenGLGlyphTexture() %p for context %p.", this, ctx); +#endif + } + + void freeResource(QOpenGLContext *context) override + { + QOpenGLContext *ctx = context; +#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG + qDebug("~QOpenGLGlyphTexture() %p for context %p.", this, ctx); +#endif + if (!ctx->d_func()->workaround_brokenFBOReadBack) + ctx->functions()->glDeleteFramebuffers(1, &m_fbo); + if (m_width || m_height) + ctx->functions()->glDeleteTextures(1, &m_texture); + } + + void invalidateResource() override + { + m_texture = 0; + m_fbo = 0; + m_width = 0; + m_height = 0; + } + + GLuint m_texture; + GLuint m_fbo; + int m_width; + int m_height; +}; + +class Q_OPENGL_EXPORT QOpenGLTextureGlyphCache : public QImageTextureGlyphCache +{ +public: + QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat glyphFormat, const QTransform &matrix, const QColor &color = QColor()); + ~QOpenGLTextureGlyphCache(); + + virtual void createTextureData(int width, int height) override; + virtual void resizeTextureData(int width, int height) override; + virtual void fillTexture(const Coord &c, + glyph_t glyph, + const QFixedPoint &subPixelPosition) override; + virtual int glyphPadding() const override; + virtual int maxTextureWidth() const override; + virtual int maxTextureHeight() const override; + + inline GLuint texture() const { + QOpenGLTextureGlyphCache *that = const_cast<QOpenGLTextureGlyphCache *>(this); + QOpenGLGlyphTexture *glyphTexture = that->m_textureResource; + return glyphTexture ? glyphTexture->m_texture : 0; + } + + inline int width() const { + QOpenGLTextureGlyphCache *that = const_cast<QOpenGLTextureGlyphCache *>(this); + QOpenGLGlyphTexture *glyphTexture = that->m_textureResource; + return glyphTexture ? glyphTexture->m_width : 0; + } + inline int height() const { + QOpenGLTextureGlyphCache *that = const_cast<QOpenGLTextureGlyphCache *>(this); + QOpenGLGlyphTexture *glyphTexture = that->m_textureResource; + return glyphTexture ? glyphTexture->m_height : 0; + } + + inline void setPaintEnginePrivate(QOpenGL2PaintEngineExPrivate *p) { pex = p; } + + inline const QOpenGLContextGroup *contextGroup() const { return m_textureResource ? m_textureResource->group() : nullptr; } + + inline int serialNumber() const { return m_serialNumber; } + + enum FilterMode { + Nearest, + Linear + }; + FilterMode filterMode() const { return m_filterMode; } + void setFilterMode(FilterMode m) { m_filterMode = m; } + + void clear(); + + QOpenGL2PaintEngineExPrivate *paintEnginePrivate() const + { + return pex; + } + +private: + void setupVertexAttribs(); + + QOpenGLGlyphTexture *m_textureResource; + + QOpenGL2PaintEngineExPrivate *pex; + QOpenGLShaderProgram *m_blitProgram; + FilterMode m_filterMode; + + GLfloat m_vertexCoordinateArray[8]; + GLfloat m_textureCoordinateArray[8]; + + int m_serialNumber; + + QOpenGLBuffer m_buffer; + QOpenGLVertexArrayObject m_vao; +}; + +QT_END_NAMESPACE + +#endif // QOPENGLTEXTUREGLYPHCACHE_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltexturehelper_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltexturehelper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8cc2de8efa1d9c141f3b3cc72d6d04cb7726cf60 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltexturehelper_p.h @@ -0,0 +1,762 @@ +// Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGLTEXTUREHELPER_P_H +#define QOPENGLTEXTUREHELPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtOpenGL/qtopenglglobal.h> +#include <QtCore/private/qglobal_p.h> + +#ifndef QT_NO_OPENGL + +#include "qopengl.h" +#include "qopenglpixeltransferoptions.h" +#include "qopengltexture.h" +#include "qopenglfunctions.h" + +QT_BEGIN_NAMESPACE + +// Constants for OpenGL and OpenGL ES 3.0+ which are not available with OpenGL ES 2.0. +#ifndef GL_TEXTURE_BASE_LEVEL +#define GL_TEXTURE_BASE_LEVEL 0x813C +#endif +#ifndef GL_TEXTURE_MAX_LEVEL +#define GL_TEXTURE_MAX_LEVEL 0x813D +#endif +#ifndef GL_TEXTURE_COMPARE_MODE +#define GL_TEXTURE_COMPARE_MODE 0x884C +#endif +#ifndef GL_TEXTURE_COMPARE_FUNC +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#endif + +// use GL_APICALL only on Android + __clang__ +#if !defined(Q_OS_ANDROID) || !defined(__clang__) +# undef GL_APICALL +# define GL_APICALL +#elif !defined(GL_APICALL) +# define GL_APICALL +#endif + +class QOpenGLContext; + +class QOpenGLTextureHelper +{ +public: + QOpenGLTextureHelper(QOpenGLContext *context); + + // DSA-like API. Will either use real DSA or our emulation + inline void glTextureParameteri(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLint param) + { + (this->*TextureParameteri)(texture, target, bindingTarget, pname, param); + } + + inline void glTextureParameteriv(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLint *params) + { + (this->*TextureParameteriv)(texture, target, bindingTarget, pname, params); + } + + inline void glTextureParameterf(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLfloat param) + { + (this->*TextureParameterf)(texture, target, bindingTarget, pname, param); + } + + inline void glTextureParameterfv(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLfloat *params) + { + (this->*TextureParameterfv)(texture, target, bindingTarget, pname, params); + } + + inline void glGenerateTextureMipmap(GLuint texture, GLenum target, GLenum bindingTarget) + { + (this->*GenerateTextureMipmap)(texture, target, bindingTarget); + } + + inline void glTextureStorage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth) + { + (this->*TextureStorage3D)(texture, target, bindingTarget, levels, internalFormat, width, height, depth); + } + + inline void glTextureStorage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, + GLsizei width, GLsizei height) + { + (this->*TextureStorage2D)(texture, target, bindingTarget, levels, internalFormat, width, height); + } + + inline void glTextureStorage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, + GLsizei width) + { + (this->*TextureStorage1D)(texture, target, bindingTarget, levels, internalFormat, width); + } + + inline void glTextureStorage3DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations) + { + (this->*TextureStorage3DMultisample)(texture, target, bindingTarget, samples, internalFormat, width, height, depth, fixedSampleLocations); + } + + inline void glTextureStorage2DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLenum internalFormat, + GLsizei width, GLsizei height, GLboolean fixedSampleLocations) + { + (this->*TextureStorage2DMultisample)(texture, target, bindingTarget, samples, internalFormat, width, height, fixedSampleLocations); + } + + inline void glTextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) + { + (this->*TextureImage3D)(texture, target, bindingTarget, level, internalFormat, width, height, depth, border, format, type, pixels); + } + + inline void glTextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) + { + (this->*TextureImage2D)(texture, target, bindingTarget, level, internalFormat, width, height, border, format, type, pixels); + } + + inline void glTextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels) + { + (this->*TextureImage1D)(texture, target, bindingTarget, level, internalFormat, width, border, format, type, pixels); + } + + inline void glTextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, + const GLvoid *pixels, const QOpenGLPixelTransferOptions * const options = nullptr) + { + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*TextureSubImage3D)(texture, target, bindingTarget, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); + setPixelUploadOptions(oldOptions); + } else { + (this->*TextureSubImage3D)(texture, target, bindingTarget, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); + } + } + + inline void glTextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, + const GLvoid *pixels, const QOpenGLPixelTransferOptions * const options = nullptr) + { + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*TextureSubImage2D)(texture, target, bindingTarget, level, xoffset, yoffset, width, height, format, type, pixels); + setPixelUploadOptions(oldOptions); + } else { + (this->*TextureSubImage2D)(texture, target, bindingTarget, level, xoffset, yoffset, width, height, format, type, pixels); + } + } + + inline void glTextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLenum type, + const GLvoid *pixels, const QOpenGLPixelTransferOptions * const options = nullptr) + { + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*TextureSubImage1D)(texture, target, bindingTarget, level, xoffset, width, format, type, pixels); + setPixelUploadOptions(oldOptions); + } else { + (this->*TextureSubImage1D)(texture, target, bindingTarget, level, xoffset, width, format, type, pixels); + } + } + + inline void glTextureImage3DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations) + { + (this->*TextureImage3DMultisample)(texture, target, bindingTarget, samples, internalFormat, width, height, depth, fixedSampleLocations); + } + + inline void glTextureImage2DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLint internalFormat, + GLsizei width, GLsizei height, GLboolean fixedSampleLocations) + { + (this->*TextureImage2DMultisample)(texture, target, bindingTarget, samples, internalFormat, width, height, fixedSampleLocations); + } + + inline void glCompressedTextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLsizei imageSize, const GLvoid *bits, + const QOpenGLPixelTransferOptions * const options = nullptr) + { + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*CompressedTextureSubImage1D)(texture, target, bindingTarget, level, xoffset, width, format, imageSize, bits); + setPixelUploadOptions(oldOptions); + } else { + (this->*CompressedTextureSubImage1D)(texture, target, bindingTarget, level, xoffset, width, format, imageSize, bits); + } + } + + inline void glCompressedTextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, const GLvoid *bits, + const QOpenGLPixelTransferOptions * const options = nullptr) + { + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*CompressedTextureSubImage2D)(texture, target, bindingTarget, level, xoffset, yoffset, width, height, format, imageSize, bits); + setPixelUploadOptions(oldOptions); + } else { + (this->*CompressedTextureSubImage2D)(texture, target, bindingTarget, level, xoffset, yoffset, width, height, format, imageSize, bits); + } + } + + inline void glCompressedTextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, const GLvoid *bits, + const QOpenGLPixelTransferOptions * const options = nullptr) + { + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*CompressedTextureSubImage3D)(texture, target, bindingTarget, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, bits); + setPixelUploadOptions(oldOptions); + } else { + (this->*CompressedTextureSubImage3D)(texture, target, bindingTarget, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, bits); + } + } + + inline void glCompressedTextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, const GLvoid *bits, + const QOpenGLPixelTransferOptions * const options = nullptr) + { + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*CompressedTextureImage1D)(texture, target, bindingTarget, level, internalFormat, width, border, imageSize, bits); + setPixelUploadOptions(oldOptions); + } else { + (this->*CompressedTextureImage1D)(texture, target, bindingTarget, level, internalFormat, width, border, imageSize, bits); + } + } + + inline void glCompressedTextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLenum internalFormat, GLsizei width, GLsizei height, + GLint border, GLsizei imageSize, const GLvoid *bits, + const QOpenGLPixelTransferOptions * const options = nullptr) + + { + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*CompressedTextureImage2D)(texture, target, bindingTarget, level, internalFormat, width, height, border, imageSize, bits); + setPixelUploadOptions(oldOptions); + } else { + (this->*CompressedTextureImage2D)(texture, target, bindingTarget, level, internalFormat, width, height, border, imageSize, bits); + } + } + + inline void glCompressedTextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLsizei imageSize, const GLvoid *bits, + const QOpenGLPixelTransferOptions * const options = nullptr) + { + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*CompressedTextureImage3D)(texture, target, bindingTarget, level, internalFormat, width, height, depth, border, imageSize, bits); + setPixelUploadOptions(oldOptions); + } else { + (this->*CompressedTextureImage3D)(texture, target, bindingTarget, level, internalFormat, width, height, depth, border, imageSize, bits); + } + } + +private: + // DSA wrapper (so we can use pointer to member function as switch) + void dsa_TextureParameteri(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLint param); + + void dsa_TextureParameteriv(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLint *params); + + void dsa_TextureParameterf(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLfloat param); + + void dsa_TextureParameterfv(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLfloat *params); + + void dsa_GenerateTextureMipmap(GLuint texture, GLenum target, GLenum bindingTarget); + + void dsa_TextureStorage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth); + + void dsa_TextureStorage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, + GLsizei width, GLsizei height); + + void dsa_TextureStorage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, + GLsizei width); + + void dsa_TextureStorage3DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + + void dsa_TextureStorage2DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLenum internalFormat, + GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + + void dsa_TextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + + void dsa_TextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + + void dsa_TextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + + void dsa_TextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + + void dsa_TextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); + + void dsa_TextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); + + void dsa_TextureImage3DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + + void dsa_TextureImage2DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLint internalFormat, + GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + + void dsa_CompressedTextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLsizei imageSize, const GLvoid *bits); + + void dsa_CompressedTextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, const GLvoid *bits); + + void dsa_CompressedTextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, const GLvoid *bits); + + void dsa_CompressedTextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, const GLvoid *bits); + + void dsa_CompressedTextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLenum internalFormat, GLsizei width, GLsizei height, + GLint border, GLsizei imageSize, const GLvoid *bits); + + void dsa_CompressedTextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLsizei imageSize, const GLvoid *bits); + + // DSA emulation API + void qt_TextureParameteri(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLint param); + + void qt_TextureParameteriv(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLint *params); + + void qt_TextureParameterf(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLfloat param); + + void qt_TextureParameterfv(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLfloat *params); + + void qt_GenerateTextureMipmap(GLuint texture, GLenum target, GLenum bindingTarget); + + void qt_TextureStorage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, + GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth); + + void qt_TextureStorage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, + GLenum internalFormat, GLsizei width, GLsizei height); + + void qt_TextureStorage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, + GLenum internalFormat, GLsizei width); + + void qt_TextureStorage3DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, + GLenum internalFormat, GLsizei width, GLsizei height, + GLsizei depth, GLboolean fixedSampleLocations); + + void qt_TextureStorage2DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, + GLenum internalFormat, GLsizei width, GLsizei height, + GLboolean fixedSampleLocations); + + void qt_TextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels); + + void qt_TextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels); + + void qt_TextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLint border, GLenum format, GLenum type, + const GLvoid *pixels); + + void qt_TextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels); + + void qt_TextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels); + + void qt_TextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, const GLvoid *pixels); + + void qt_TextureImage3DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, + GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, + GLboolean fixedSampleLocations); + + void qt_TextureImage2DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, + GLint internalFormat, GLsizei width, GLsizei height, + GLboolean fixedSampleLocations); + + void qt_CompressedTextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *bits); + + void qt_CompressedTextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, const GLvoid *bits); + + void qt_CompressedTextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, const GLvoid *bits); + + void qt_CompressedTextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLint border, + GLsizei imageSize, const GLvoid *bits); + + void qt_CompressedTextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const GLvoid *bits); + + void qt_CompressedTextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *bits); + +public: + // Raw OpenGL functions, resolved and used by our DSA-like static functions if no EXT_direct_state_access is available + + // OpenGL 1.0 + inline void glTexImage1D(GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels) + { + TexImage1D(target, level, internalFormat, width, border, format, type, pixels); + } + + // OpenGL 1.1 + inline void glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, + GLenum format, GLenum type, const GLvoid *pixels) + { + TexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + // OpenGL 1.2 + inline void glTexImage3D(GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels) + { + TexImage3D(target, level, internalFormat, width, height, depth, border, format, type, pixels); + } + + inline void glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) + { + TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); + } + + // OpenGL 1.3 + inline void glGetCompressedTexImage(GLenum target, GLint level, GLvoid *img) + { + GetCompressedTexImage(target, level, img); + } + + inline void glCompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, + GLenum format, GLsizei imageSize, const GLvoid *data) + { + CompressedTexSubImage1D(target, level, xoffset, width, format, imageSize, data); + } + + inline void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) + { + CompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); + } + + inline void glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data) + { + CompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); + } + + inline void glCompressedTexImage1D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, const GLvoid *data) + { + CompressedTexImage1D(target, level, internalFormat, width, border, imageSize, data); + } + + inline void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, + GLint border, GLsizei imageSize, const GLvoid *data) + { + CompressedTexImage2D(target, level, internalFormat, width, height, border, imageSize, data); + } + + inline void glCompressedTexImage3D(GLenum target, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLsizei imageSize, const GLvoid *data) + { + CompressedTexImage3D(target, level, internalFormat, width, height, depth, border, imageSize, data); + } + + inline void glActiveTexture(GLenum texture) + { + ActiveTexture(texture); + } + + // OpenGL 3.0 + inline void glGenerateMipmap(GLenum target) + { + GenerateMipmap(target); + } + + // OpenGL 3.2 + inline void glTexImage3DMultisample(GLenum target, GLsizei samples, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLboolean fixedSampleLocations) + { + TexImage3DMultisample(target, samples, internalFormat, width, height, depth, fixedSampleLocations); + } + + inline void glTexImage2DMultisample(GLenum target, GLsizei samples, GLint internalFormat, + GLsizei width, GLsizei height, + GLboolean fixedSampleLocations) + { + TexImage2DMultisample(target, samples, internalFormat, width, height, fixedSampleLocations); + } + + // OpenGL 4.2 + inline void glTexStorage3D(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth) + { + TexStorage3D(target, levels, internalFormat, width, height, depth); + } + + inline void glTexStorage2D(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height) + { + TexStorage2D(target, levels, internalFormat, width, height); + } + + inline void glTexStorage1D(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width) + { + TexStorage1D(target, levels, internalFormat, width); + } + + // OpenGL 4.3 + inline void glTexStorage3DMultisample(GLenum target, GLsizei samples, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations) + { + TexStorage3DMultisample(target, samples, internalFormat, width, height, depth, fixedSampleLocations); + } + + inline void glTexStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalFormat, + GLsizei width, GLsizei height, GLboolean fixedSampleLocations) + { + TexStorage2DMultisample(target, samples, internalFormat, width, height, fixedSampleLocations); + } + + inline void glTexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer, + GLintptr offset, GLsizeiptr size) + { + TexBufferRange(target, internalFormat, buffer, offset, size); + } + + inline void glTextureView(GLuint texture, GLenum target, GLuint origTexture, GLenum internalFormat, + GLuint minLevel, GLuint numLevels, GLuint minLayer, GLuint numLayers) + { + TextureView(texture, target, origTexture, internalFormat, minLevel, numLevels, minLayer, numLayers); + } + + // Helper functions + inline QOpenGLPixelTransferOptions savePixelUploadOptions() + { + QOpenGLPixelTransferOptions options; + int val = 0; + functions->glGetIntegerv(GL_UNPACK_ALIGNMENT, &val); + options.setAlignment(val); +#if !QT_CONFIG(opengles2) + functions->glGetIntegerv(GL_UNPACK_SKIP_IMAGES, &val); + options.setSkipImages(val); + functions->glGetIntegerv(GL_UNPACK_SKIP_ROWS, &val); + options.setSkipRows(val); + functions->glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &val); + options.setSkipPixels(val); + functions->glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &val); + options.setImageHeight(val); + functions->glGetIntegerv(GL_UNPACK_ROW_LENGTH, &val); + options.setRowLength(val); + GLboolean b = GL_FALSE; + functions->glGetBooleanv(GL_UNPACK_LSB_FIRST, &b); + options.setLeastSignificantByteFirst(b); + functions->glGetBooleanv(GL_UNPACK_SWAP_BYTES, &b); + options.setSwapBytesEnabled(b); +#endif + return options; + } + + inline void setPixelUploadOptions(const QOpenGLPixelTransferOptions &options) + { + functions->glPixelStorei(GL_UNPACK_ALIGNMENT, options.alignment()); +#if !QT_CONFIG(opengles2) + functions->glPixelStorei(GL_UNPACK_SKIP_IMAGES, options.skipImages()); + functions->glPixelStorei(GL_UNPACK_SKIP_ROWS, options.skipRows()); + functions->glPixelStorei(GL_UNPACK_SKIP_PIXELS, options.skipPixels()); + functions->glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, options.imageHeight()); + functions->glPixelStorei(GL_UNPACK_ROW_LENGTH, options.rowLength()); + functions->glPixelStorei(GL_UNPACK_LSB_FIRST, options.isLeastSignificantBitFirst()); + functions->glPixelStorei(GL_UNPACK_SWAP_BYTES, options.isSwapBytesEnabled()); +#endif + } + + QOpenGLFunctions *functions; +private: + // Typedefs and pointers to member functions used to switch between EXT_direct_state_access and our own emulated DSA. + // The argument match the corresponding GL function, but there's an extra "GLenum bindingTarget" which gets used with + // the DSA emulation -- it contains the right GL_BINDING_TEXTURE_X to use. + typedef void (QOpenGLTextureHelper::*TextureParameteriMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLint param); + typedef void (QOpenGLTextureHelper::*TextureParameterivMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLint *params); + typedef void (QOpenGLTextureHelper::*TextureParameterfMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLfloat param); + typedef void (QOpenGLTextureHelper::*TextureParameterfvMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLfloat *params); + typedef void (QOpenGLTextureHelper::*GenerateTextureMipmapMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget); + typedef void (QOpenGLTextureHelper::*TextureStorage3DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth); + typedef void (QOpenGLTextureHelper::*TextureStorage2DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height); + typedef void (QOpenGLTextureHelper::*TextureStorage1DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, GLsizei width); + typedef void (QOpenGLTextureHelper::*TextureStorage3DMultisampleMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + typedef void (QOpenGLTextureHelper::*TextureStorage2DMultisampleMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + typedef void (QOpenGLTextureHelper::*TextureImage3DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + typedef void (QOpenGLTextureHelper::*TextureImage2DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + typedef void (QOpenGLTextureHelper::*TextureImage1DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + typedef void (QOpenGLTextureHelper::*TextureSubImage3DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + typedef void (QOpenGLTextureHelper::*TextureSubImage2DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); + typedef void (QOpenGLTextureHelper::*TextureSubImage1DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); + typedef void (QOpenGLTextureHelper::*TextureImage3DMultisampleMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + typedef void (QOpenGLTextureHelper::*TextureImage2DMultisampleMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + typedef void (QOpenGLTextureHelper::*CompressedTextureSubImage1DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); + typedef void (QOpenGLTextureHelper::*CompressedTextureSubImage2DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); + typedef void (QOpenGLTextureHelper::*CompressedTextureSubImage3DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); + typedef void (QOpenGLTextureHelper::*CompressedTextureImage1DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); + typedef void (QOpenGLTextureHelper::*CompressedTextureImage2DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); + typedef void (QOpenGLTextureHelper::*CompressedTextureImage3DMemberFunc)(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); + + + TextureParameteriMemberFunc TextureParameteri; + TextureParameterivMemberFunc TextureParameteriv; + TextureParameterfMemberFunc TextureParameterf; + TextureParameterfvMemberFunc TextureParameterfv; + GenerateTextureMipmapMemberFunc GenerateTextureMipmap; + TextureStorage3DMemberFunc TextureStorage3D; + TextureStorage2DMemberFunc TextureStorage2D; + TextureStorage1DMemberFunc TextureStorage1D; + TextureStorage3DMultisampleMemberFunc TextureStorage3DMultisample; + TextureStorage2DMultisampleMemberFunc TextureStorage2DMultisample; + TextureImage3DMemberFunc TextureImage3D; + TextureImage2DMemberFunc TextureImage2D; + TextureImage1DMemberFunc TextureImage1D; + TextureSubImage3DMemberFunc TextureSubImage3D; + TextureSubImage2DMemberFunc TextureSubImage2D; + TextureSubImage1DMemberFunc TextureSubImage1D; + TextureImage3DMultisampleMemberFunc TextureImage3DMultisample; + TextureImage2DMultisampleMemberFunc TextureImage2DMultisample; + CompressedTextureSubImage1DMemberFunc CompressedTextureSubImage1D; + CompressedTextureSubImage2DMemberFunc CompressedTextureSubImage2D; + CompressedTextureSubImage3DMemberFunc CompressedTextureSubImage3D; + CompressedTextureImage1DMemberFunc CompressedTextureImage1D; + CompressedTextureImage2DMemberFunc CompressedTextureImage2D; + CompressedTextureImage3DMemberFunc CompressedTextureImage3D; + + // Raw function pointers for core and DSA functions + + // EXT_direct_state_access used when DSA is available + void (QOPENGLF_APIENTRYP TextureParameteriEXT)(GLuint texture, GLenum target, GLenum pname, GLint param); + void (QOPENGLF_APIENTRYP TextureParameterivEXT)(GLuint texture, GLenum target, GLenum pname, const GLint *params); + void (QOPENGLF_APIENTRYP TextureParameterfEXT)(GLuint texture, GLenum target, GLenum pname, GLfloat param); + void (QOPENGLF_APIENTRYP TextureParameterfvEXT)(GLuint texture, GLenum target, GLenum pname, const GLfloat *params); + void (QOPENGLF_APIENTRYP GenerateTextureMipmapEXT)(GLuint texture, GLenum target); + void (QOPENGLF_APIENTRYP TextureStorage3DEXT)(GLuint texture, GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth); + void (QOPENGLF_APIENTRYP TextureStorage2DEXT)(GLuint texture, GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height); + void (QOPENGLF_APIENTRYP TextureStorage1DEXT)(GLuint texture, GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width); + void (QOPENGLF_APIENTRYP TextureStorage3DMultisampleEXT)(GLuint texture, GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + void (QOPENGLF_APIENTRYP TextureStorage2DMultisampleEXT)(GLuint texture, GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + void (QOPENGLF_APIENTRYP TextureImage3DEXT)(GLuint texture, GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + void (QOPENGLF_APIENTRYP TextureImage2DEXT)(GLuint texture, GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + void (QOPENGLF_APIENTRYP TextureImage1DEXT)(GLuint texture, GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + void (QOPENGLF_APIENTRYP TextureSubImage3DEXT)(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + void (QOPENGLF_APIENTRYP TextureSubImage2DEXT)(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); + void (QOPENGLF_APIENTRYP TextureSubImage1DEXT)(GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); + void (QOPENGLF_APIENTRYP CompressedTextureSubImage1DEXT)(GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); + void (QOPENGLF_APIENTRYP CompressedTextureSubImage2DEXT)(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); + void (QOPENGLF_APIENTRYP CompressedTextureSubImage3DEXT)(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); + void (QOPENGLF_APIENTRYP CompressedTextureImage1DEXT)(GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); + void (QOPENGLF_APIENTRYP CompressedTextureImage2DEXT)(GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); + void (QOPENGLF_APIENTRYP CompressedTextureImage3DEXT)(GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); + + + // Plus some missing ones that are in the NV_texture_multisample extension instead + void (QOPENGLF_APIENTRYP TextureImage3DMultisampleNV)(GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + void (QOPENGLF_APIENTRYP TextureImage2DMultisampleNV)(GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + + // OpenGL 1.0 + void (QOPENGLF_APIENTRYP TexImage1D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + + // OpenGL 1.1 + void (QOPENGLF_APIENTRYP TexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); + + // OpenGL 1.2 + void (QOPENGLF_APIENTRYP TexImage3D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + void (QOPENGLF_APIENTRYP TexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + + // OpenGL 1.3 + void (QOPENGLF_APIENTRYP GetCompressedTexImage)(GLenum target, GLint level, GLvoid *img); + void (QOPENGLF_APIENTRYP CompressedTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); + GL_APICALL void (QOPENGLF_APIENTRYP CompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); + void (QOPENGLF_APIENTRYP CompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); + void (QOPENGLF_APIENTRYP CompressedTexImage1D)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); + GL_APICALL void (QOPENGLF_APIENTRYP CompressedTexImage2D)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); + void (QOPENGLF_APIENTRYP CompressedTexImage3D)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); + GL_APICALL void (QOPENGLF_APIENTRYP ActiveTexture)(GLenum texture); + + // OpenGL 3.0 + GL_APICALL void (QOPENGLF_APIENTRYP GenerateMipmap)(GLenum target); + + // OpenGL 3.2 + void (QOPENGLF_APIENTRYP TexImage3DMultisample)(GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + void (QOPENGLF_APIENTRYP TexImage2DMultisample)(GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + + // OpenGL 4.2 + void (QOPENGLF_APIENTRYP TexStorage3D)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth); + void (QOPENGLF_APIENTRYP TexStorage2D)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height); + void (QOPENGLF_APIENTRYP TexStorage1D)(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width); + + // OpenGL 4.3 + void (QOPENGLF_APIENTRYP TexStorage3DMultisample)(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); + void (QOPENGLF_APIENTRYP TexStorage2DMultisample)(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); + void (QOPENGLF_APIENTRYP TexBufferRange)(GLenum target, GLenum internalFormat, GLuint buffer, GLintptr offset, GLsizeiptr size); + void (QOPENGLF_APIENTRYP TextureView)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +}; + +QT_END_NAMESPACE + +#undef Q_CALL_MEMBER_FUNCTION + +#endif // QT_NO_OPENGL + +#endif // QOPENGLTEXTUREHELPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltextureuploader_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltextureuploader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d359420b79d1fe26becd3d3b1ff3fe43ab8c7ef6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopengltextureuploader_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QOPENGLTEXTUREUPLOADER_P_H +#define QOPENGLTEXTUREUPLOADER_P_H + +#include <QtCore/qsize.h> +#include <QtOpenGL/qtopenglglobal.h> +#include <QtGui/private/qopenglcontext_p.h> + +QT_BEGIN_NAMESPACE + +class QImage; + +class Q_OPENGL_EXPORT QOpenGLTextureUploader +{ +public: + enum BindOption { + NoBindOption = 0x0000, + PremultipliedAlphaBindOption = 0x0001, + UseRedForAlphaAndLuminanceBindOption = 0x0002, + SRgbBindOption = 0x0004, + PowerOfTwoBindOption = 0x0008 + }; + Q_DECLARE_FLAGS(BindOptions, BindOption) + Q_FLAGS(BindOptions) + + static qsizetype textureImage(GLenum target, const QImage &image, BindOptions options, QSize maxSize = QSize()); + +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLTextureUploader::BindOptions) + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglversionfunctions_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglversionfunctions_p.h new file mode 100644 index 0000000000000000000000000000000000000000..48566688cc068389fd02add9f91b5b5310beea9c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglversionfunctions_p.h @@ -0,0 +1,52 @@ +// Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB) +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +/*************************************************************************** +** This file was generated by glgen version 0.1 +** Command line was: glgen +** +** glgen is Copyright (C) 2012 Klaralvdalens Datakonsult AB (KDAB) +** +** This is an auto-generated file. +** Do not edit! All changes made to it will be lost. +** +****************************************************************************/ + +#ifndef QOPENGLVERSIONFUNCTIONS_P_H +#define QOPENGLVERSIONFUNCTIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qopenglversionfunctions.h" + +#include <QtGui/private/qopenglcontext_p.h> + +#include <QtOpenGL/qtopenglglobal.h> +#include <QtOpenGL/QOpenGLVersionProfile> +#include <QtCore/QSet> + +QT_BEGIN_NAMESPACE + +class QAbstractOpenGLFunctions; + +class QOpenGLContextVersionData : public QOpenGLContextVersionFunctionHelper +{ +public: + QHash<QOpenGLVersionProfile, QAbstractOpenGLFunctions *> functions; + QOpenGLVersionFunctionsStorage functionsStorage; + QSet<QAbstractOpenGLFunctions *> externalFunctions; + ~QOpenGLContextVersionData() override; + static QOpenGLContextVersionData *forContext(QOpenGLContext *context); +}; + +QT_END_NAMESPACE + +#endif // QOPENGLVERSIONFUNCTIONS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglvertexarrayobject_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglvertexarrayobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f271eed3bbb1f199797eee500a01afdcdac65f21 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qopenglvertexarrayobject_p.h @@ -0,0 +1,85 @@ +// Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Sean Harmer <sean.harmer@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QOPENGLVERTEXARRAYOBJECT_P_H +#define QOPENGLVERTEXARRAYOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Qt OpenGL classes. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtOpenGL/qtopenglglobal.h> + +#include <QtGui/qopengl.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLContext; + +class QOpenGLVertexArrayObjectHelper +{ + Q_DISABLE_COPY(QOpenGLVertexArrayObjectHelper) + +private: + explicit inline QOpenGLVertexArrayObjectHelper(QOpenGLContext *context) + : GenVertexArrays(nullptr) + , DeleteVertexArrays(nullptr) + , BindVertexArray(nullptr) + , IsVertexArray(nullptr) + { + initializeFromContext(context); + } + + void Q_OPENGL_EXPORT initializeFromContext(QOpenGLContext *context); + +public: + static Q_OPENGL_EXPORT QOpenGLVertexArrayObjectHelper *vertexArrayObjectHelperForContext(QOpenGLContext *context); + + inline bool isValid() const + { + return GenVertexArrays && DeleteVertexArrays && BindVertexArray && IsVertexArray; + } + + inline void glGenVertexArrays(GLsizei n, GLuint *arrays) const + { + GenVertexArrays(n, arrays); + } + + inline void glDeleteVertexArrays(GLsizei n, const GLuint *arrays) const + { + DeleteVertexArrays(n, arrays); + } + + inline void glBindVertexArray(GLuint array) const + { + BindVertexArray(array); + } + + inline GLboolean glIsVertexArray(GLuint array) const + { + return IsVertexArray(array); + } + + // Function signatures are equivalent between desktop core, ARB, APPLE, ES 3 and ES 2 extensions + typedef void (QOPENGLF_APIENTRYP qt_GenVertexArrays_t)(GLsizei n, GLuint *arrays); + typedef void (QOPENGLF_APIENTRYP qt_DeleteVertexArrays_t)(GLsizei n, const GLuint *arrays); + typedef void (QOPENGLF_APIENTRYP qt_BindVertexArray_t)(GLuint array); + typedef GLboolean (QOPENGLF_APIENTRYP qt_IsVertexArray_t)(GLuint array); + + qt_GenVertexArrays_t GenVertexArrays; + qt_DeleteVertexArrays_t DeleteVertexArrays; + qt_BindVertexArray_t BindVertexArray; + qt_IsVertexArray_t IsVertexArray; +}; + +QT_END_NAMESPACE + +#endif // QOPENGLVERTEXARRAYOBJECT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qvkconvenience_p.h b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qvkconvenience_p.h new file mode 100644 index 0000000000000000000000000000000000000000..da50e41f096e94a2d5d20e3973577d0ac626c33a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtOpenGL/6.8.1/QtOpenGL/private/qvkconvenience_p.h @@ -0,0 +1,34 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QVKCONVENIENCE_P_H +#define QVKCONVENIENCE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtOpenGL/qtopenglglobal.h> +#include <qvulkaninstance.h> +#include <private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class Q_OPENGL_EXPORT QVkConvenience +{ +public: +#if QT_CONFIG(opengl) + static VkFormat vkFormatFromGlFormat(uint glFormat); +#endif +}; + +QT_END_NAMESPACE + +#endif // QVKCONVENIENCE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPacketProtocol/6.8.1/QtPacketProtocol/private/qpacket_p.h b/qt/6.8.1/msvc2022_64/include/QtPacketProtocol/6.8.1/QtPacketProtocol/private/qpacket_p.h new file mode 100644 index 0000000000000000000000000000000000000000..807f424380160676c36e8989afb3872077175ca6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPacketProtocol/6.8.1/QtPacketProtocol/private/qpacket_p.h @@ -0,0 +1,39 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPACKET_H +#define QPACKET_H + +#include <QtCore/qdatastream.h> +#include <QtCore/qbuffer.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QPacket : public QDataStream +{ +public: + QPacket(int version); + explicit QPacket(int version, const QByteArray &ba); + const QByteArray &data() const; + QByteArray squeezedData() const; + void clear(); + +private: + void init(QIODevice::OpenMode mode); + QBuffer buf; +}; + +QT_END_NAMESPACE + +#endif // QPACKET_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPacketProtocol/6.8.1/QtPacketProtocol/private/qpacketprotocol_p.h b/qt/6.8.1/msvc2022_64/include/QtPacketProtocol/6.8.1/QtPacketProtocol/private/qpacketprotocol_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5ad420b6705cfea017726f54c73309689c593faa --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPacketProtocol/6.8.1/QtPacketProtocol/private/qpacketprotocol_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPACKETPROTOCOL_P_H +#define QPACKETPROTOCOL_P_H + +#include <QtCore/qobject.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QIODevice; + +class QPacketProtocolPrivate; +class QPacketProtocol : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QPacketProtocol) +public: + explicit QPacketProtocol(QIODevice *dev, QObject *parent = nullptr); + + void send(const QByteArray &data); + qint64 packetsAvailable() const; + QByteArray read(); + bool waitForReadyRead(int msecs = 3000); + +Q_SIGNALS: + void readyRead(); + void error(); + +private: + void bytesWritten(qint64 bytes); + void readyToRead(); +}; + +QT_END_NAMESPACE + +#endif // QPACKETPROTOCOL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPacketProtocol/6.8.1/QtPacketProtocol/private/qversionedpacket_p.h b/qt/6.8.1/msvc2022_64/include/QtPacketProtocol/6.8.1/QtPacketProtocol/private/qversionedpacket_p.h new file mode 100644 index 0000000000000000000000000000000000000000..af7bdd608148207f30201aa285fb0b9e819fdd10 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPacketProtocol/6.8.1/QtPacketProtocol/private/qversionedpacket_p.h @@ -0,0 +1,33 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QVERSIONEDPACKET_P_H +#define QVERSIONEDPACKET_P_H + +#include "qpacket_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +// QPacket with a fixed data stream version, centrally set by some Connector +template<class Connector> +class QVersionedPacket : public QPacket +{ +public: + QVersionedPacket(const QByteArray &ba) : QPacket(Connector::dataStreamVersion(), ba) {} + QVersionedPacket() : QPacket(Connector::dataStreamVersion()) {} +}; + +QT_END_NAMESPACE + +#endif // QVERSIONEDPACKET_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qabstractprintdialog_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qabstractprintdialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c1384714155adb4cdace8938614b7b7b9c60cf14 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qabstractprintdialog_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTPRINTDIALOG_P_H +#define QABSTRACTPRINTDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtPrintSupport/private/qtprintsupportglobal_p.h> + +#include "private/qdialog_p.h" +#include "QtPrintSupport/qabstractprintdialog.h" + +#include <QtCore/qpointer.h> + +QT_REQUIRE_CONFIG(printdialog); + +QT_BEGIN_NAMESPACE + +class QPrinter; +class QPrinterPrivate; + +class QAbstractPrintDialogPrivate : public QDialogPrivate +{ + Q_DECLARE_PUBLIC(QAbstractPrintDialog) + +public: + QAbstractPrintDialogPrivate() + : printer(nullptr), pd(nullptr) + , options(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintPageRange | + QAbstractPrintDialog::PrintCollateCopies | QAbstractPrintDialog::PrintShowPageSize), + minPage(0), maxPage(INT_MAX), ownsPrinter(false) + { + } + + QPrinter *printer; + QPrinterPrivate *pd; + QPointer<QObject> receiverToDisconnectOnClose; + QByteArray memberToDisconnectOnClose; + + QAbstractPrintDialog::PrintDialogOptions options; + + virtual void setTabs(const QList<QWidget *> &) {} + void setPrinter(QPrinter *newPrinter); + int minPage; + int maxPage; + + bool ownsPrinter; +}; + +QT_END_NAMESPACE + +#endif // QABSTRACTPRINTDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qpagesetupdialog_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qpagesetupdialog_p.h new file mode 100644 index 0000000000000000000000000000000000000000..04da983d79666c42575b1314f4b05e11f199bbae --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qpagesetupdialog_p.h @@ -0,0 +1,50 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAGESETUPDIALOG_P_H +#define QPAGESETUPDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// to version without notice, or even be removed. +// +// We mean it. +// +// + +#include <QtPrintSupport/private/qtprintsupportglobal_p.h> + +#include "private/qdialog_p.h" + +#include "qbytearray.h" +#include "qpagesetupdialog.h" +#include "qpointer.h" + +QT_REQUIRE_CONFIG(printdialog); + +QT_BEGIN_NAMESPACE + +class QPrinter; + +class QPageSetupDialogPrivate : public QDialogPrivate +{ + Q_DECLARE_PUBLIC(QPageSetupDialog) + +public: + explicit QPageSetupDialogPrivate(QPrinter *printer); + + void setPrinter(QPrinter *newPrinter); + + QPrinter *printer; + bool ownsPrinter; + QPointer<QObject> receiverToDisconnectOnClose; + QByteArray memberToDisconnectOnClose; +}; + +QT_END_NAMESPACE + +#endif // QPAGESETUPDIALOG_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qpaintengine_alpha_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qpaintengine_alpha_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6e9c500f9c2fe12ebb4011767f03ebc32f757ac2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qpaintengine_alpha_p.h @@ -0,0 +1,105 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAINTENGINE_ALPHA_P_H +#define QPAINTENGINE_ALPHA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtPrintSupport/private/qtprintsupportglobal_p.h> + +#ifndef QT_NO_PRINTER +#include "private/qpaintengine_p.h" +#include <QtPrintSupport/qtprintsupportglobal.h> + +QT_BEGIN_NAMESPACE + +class QAlphaPaintEnginePrivate; + +class Q_PRINTSUPPORT_EXPORT QAlphaPaintEngine : public QPaintEngine +{ + Q_DECLARE_PRIVATE(QAlphaPaintEngine) +public: + ~QAlphaPaintEngine(); + + bool begin(QPaintDevice *pdev) override; + bool end() override; + + void updateState(const QPaintEngineState &state) override; + + void drawPath(const QPainterPath &path) override; + + void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; + + void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; + void drawTextItem(const QPointF &p, const QTextItem &textItem) override; + void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override; + +protected: + QAlphaPaintEngine(QAlphaPaintEnginePrivate &data, PaintEngineFeatures devcaps = { }); + QRegion alphaClipping() const; + bool continueCall() const; + void flushAndInit(bool init = true); + void cleanUp(); +}; + +class QAlphaPaintEnginePrivate : public QPaintEnginePrivate +{ + Q_DECLARE_PUBLIC(QAlphaPaintEngine) +public: + QAlphaPaintEnginePrivate(); + ~QAlphaPaintEnginePrivate(); + + int m_pass; + QPicture *m_pic; + QPaintEngine *m_picengine; + QPainter *m_picpainter; + + QPaintEngine::PaintEngineFeatures m_savedcaps; + QPaintDevice *m_pdev; + + QRegion m_alphargn; + QRegion m_cliprgn; + mutable QRegion m_cachedDirtyRgn; + mutable int m_numberOfCachedRects; + QList<QRect> m_dirtyRects; + + bool m_hasalpha; + bool m_alphaPen; + bool m_alphaBrush; + bool m_alphaOpacity; + bool m_advancedPen; + bool m_advancedBrush; + bool m_complexTransform; + bool m_emulateProjectiveTransforms; + bool m_continueCall; + + QTransform m_transform; + QPen m_pen; + + void addAlphaRect(const QRectF &rect); + void addDirtyRect(const QRectF &rect) { m_dirtyRects.append(rect.toAlignedRect()); } + bool canSeeTroughBackground(bool somethingInRectHasAlpha, const QRectF &rect) const; + + QRectF addPenWidth(const QPainterPath &path); + void drawAlphaImage(const QRectF &rect); + QRect toRect(const QRectF &rect) const; + bool fullyContained(const QRectF &rect) const; + + void resetState(QPainter *p); +}; + +QT_END_NAMESPACE + +#endif // QT_NO_PRINTER + +#endif // QPAINTENGINE_ALPHA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qpaintengine_preview_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qpaintengine_preview_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a67d84b7ba5303bb256533f38b3a14905ffdd1f4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qpaintengine_preview_p.h @@ -0,0 +1,67 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAINTENGINE_PREVIEW_P_H +#define QPAINTENGINE_PREVIEW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of QPreviewPrinter and friends. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +// + +#include <QtPrintSupport/private/qtprintsupportglobal_p.h> +#include <QtGui/qpaintengine.h> +#include <QtPrintSupport/qprintengine.h> + +QT_REQUIRE_CONFIG(printpreviewwidget); + +QT_BEGIN_NAMESPACE + +class QPreviewPaintEnginePrivate; + +class QPreviewPaintEngine : public QPaintEngine, public QPrintEngine +{ + Q_DECLARE_PRIVATE(QPreviewPaintEngine) +public: + QPreviewPaintEngine(); + ~QPreviewPaintEngine(); + + bool begin(QPaintDevice *dev) override; + bool end() override; + + void updateState(const QPaintEngineState &state) override; + + void drawPath(const QPainterPath &path) override; + void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; + void drawTextItem(const QPointF &p, const QTextItem &textItem) override; + + void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; + void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &p) override; + + QList<const QPicture *> pages(); + + QPaintEngine::Type type() const override { return Picture; } + + void setProxyEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine); + + void setProperty(PrintEnginePropertyKey key, const QVariant &value) override; + QVariant property(PrintEnginePropertyKey key) const override; + + bool newPage() override; + bool abort() override; + + int metric(QPaintDevice::PaintDeviceMetric) const override; + + QPrinter::PrinterState printerState() const override; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprint_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprint_p.h new file mode 100644 index 0000000000000000000000000000000000000000..43c793c505fe5a54ccadc8fb75d0efc128500e17 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprint_p.h @@ -0,0 +1,161 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// Copyright (C) 2014 John Layt <jlayt@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPRINT_P_H +#define QPRINT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtPrintSupport/private/qtprintsupportglobal_p.h> +#include <QtPrintSupport/qprinter.h> + +#include <QtCore/qstring.h> +#include <QtCore/qlist.h> + +#if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups)) +#include <cups/ppd.h> // Use for type defs only, don't want to actually link in main module +// ### QT_DECL_METATYPE_EXTERN_TAGGED once there's a qprint.cpp TU +Q_DECLARE_METATYPE(ppd_file_t *) +#endif + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_PRINTER + +// From windgdi.h +#define DMBIN_UPPER 1 +#define DMBIN_ONLYONE 1 +#define DMBIN_LOWER 2 +#define DMBIN_MIDDLE 3 +#define DMBIN_MANUAL 4 +#define DMBIN_ENVELOPE 5 +#define DMBIN_ENVMANUAL 6 +#define DMBIN_AUTO 7 +#define DMBIN_TRACTOR 8 +#define DMBIN_SMALLFMT 9 +#define DMBIN_LARGEFMT 10 +#define DMBIN_LARGECAPACITY 11 +#define DMBIN_CASSETTE 14 +#define DMBIN_FORMSOURCE 15 +#define DMBIN_USER 256 + +namespace QPrint { + + // Note: Keep in sync with QPrinter::PrinterState for now + // Replace later with more detailed status reporting + enum DeviceState { + Idle, + Active, + Aborted, + Error + }; + + // Note: Keep in sync with QPrinter::DuplexMode + enum DuplexMode { + DuplexNone = 0, + DuplexAuto, + DuplexLongSide, + DuplexShortSide + }; + + // Note: Keep in sync with QPrinter::ColorMode + enum ColorMode { + GrayScale, + Color + }; + + // Note: Keep in sync with QPrinter::PaperSource for now + // If/when made public, rearrange and rename + enum InputSlotId { + Upper, + Lower, + Middle, + Manual, + Envelope, + EnvelopeManual, + Auto, + Tractor, + SmallFormat, + LargeFormat, + LargeCapacity, + Cassette, + FormSource, + MaxPageSource, // Deprecated, kept for compatibility to QPrinter + CustomInputSlot, + LastInputSlot = CustomInputSlot, + OnlyOne = Upper + }; + + struct InputSlot { + QByteArray key; + QString name; + QPrint::InputSlotId id; + int windowsId; + }; + + enum OutputBinId { + AutoOutputBin, + UpperBin, + LowerBin, + RearBin, + CustomOutputBin, + LastOutputBin = CustomOutputBin + }; + + struct OutputBin { + QByteArray key; + QString name; + QPrint::OutputBinId id; + }; + +} + +struct InputSlotMap { + QPrint::InputSlotId id; + int windowsId; + const char *key; +}; + +struct OutputBinMap { + QPrint::OutputBinId id; + const char *key; +}; + +// Print utilities shared by print plugins + +namespace QPrintUtils { + +Q_PRINTSUPPORT_EXPORT QPrint::InputSlotId inputSlotKeyToInputSlotId(const QByteArray &key); +Q_PRINTSUPPORT_EXPORT QByteArray inputSlotIdToInputSlotKey(QPrint::InputSlotId id); +Q_PRINTSUPPORT_EXPORT int inputSlotIdToWindowsId(QPrint::InputSlotId id); +Q_PRINTSUPPORT_EXPORT QPrint::OutputBinId outputBinKeyToOutputBinId(const QByteArray &key); +Q_PRINTSUPPORT_EXPORT QByteArray outputBinIdToOutputBinKey(QPrint::OutputBinId id); +Q_PRINTSUPPORT_EXPORT QPrint::InputSlot paperBinToInputSlot(int windowsId, const QString &name); + +# if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups)) +// PPD utilities shared by CUPS and Mac plugins requiring CUPS headers +// May turn into a proper internal QPpd class if enough shared between Mac and CUPS, +// but where would it live? Not in base module as don't want to link to CUPS. +// May have to have two copies in plugins to keep in sync. +Q_PRINTSUPPORT_EXPORT QPrint::InputSlot ppdChoiceToInputSlot(const ppd_choice_t &choice); +Q_PRINTSUPPORT_EXPORT QPrint::OutputBin ppdChoiceToOutputBin(const ppd_choice_t &choice); +Q_PRINTSUPPORT_EXPORT int parsePpdResolution(const QByteArray &value); +Q_PRINTSUPPORT_EXPORT QPrint::DuplexMode ppdChoiceToDuplexMode(const QByteArray &choice); +# endif // Mac and CUPS PPD Utilities +}; + +#endif // QT_NO_PRINTER + +QT_END_NAMESPACE + +#endif // QPRINT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprintdevice_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprintdevice_p.h new file mode 100644 index 0000000000000000000000000000000000000000..709ca9777cfde6a3d114dce545ff9dd96103b294 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprintdevice_p.h @@ -0,0 +1,128 @@ +// Copyright (C) 2014 John Layt <jlayt@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPRINTDEVICE_H +#define QPRINTDEVICE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include <QtPrintSupport/private/qtprintsupportglobal_p.h> +#include "private/qprint_p.h" + +#include <QtCore/qsharedpointer.h> +#include <QtGui/qpagelayout.h> + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_PRINTER + +class QPlatformPrintDevice; +class QMarginsF; +class QMimeType; +class QDebug; + +class Q_PRINTSUPPORT_EXPORT QPrintDevice +{ +public: + + QPrintDevice(); + QPrintDevice(const QString & id); + QPrintDevice(const QPrintDevice &other); + ~QPrintDevice(); + + QPrintDevice &operator=(const QPrintDevice &other); + QPrintDevice &operator=(QPrintDevice &&other) { swap(other); return *this; } + + void swap(QPrintDevice &other) { d.swap(other.d); } + + bool operator==(const QPrintDevice &other) const; + + QString id() const; + QString name() const; + QString location() const; + QString makeAndModel() const; + + bool isValid() const; + bool isDefault() const; + bool isRemote() const; + + QPrint::DeviceState state() const; + + bool isValidPageLayout(const QPageLayout &layout, int resolution) const; + + bool supportsMultipleCopies() const; + bool supportsCollateCopies() const; + + QPageSize defaultPageSize() const; + QList<QPageSize> supportedPageSizes() const; + + QPageSize supportedPageSize(const QPageSize &pageSize) const; + QPageSize supportedPageSize(QPageSize::PageSizeId pageSizeId) const; + QPageSize supportedPageSize(const QString &pageName) const; + QPageSize supportedPageSize(const QSize &pointSize) const; + QPageSize supportedPageSize(const QSizeF &size, QPageSize::Unit units = QPageSize::Point) const; + + bool supportsCustomPageSizes() const; + + QSize minimumPhysicalPageSize() const; + QSize maximumPhysicalPageSize() const; + + QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation, int resolution) const; + + int defaultResolution() const; + QList<int> supportedResolutions() const; + + QPrint::InputSlot defaultInputSlot() const; + QList<QPrint::InputSlot> supportedInputSlots() const; + + QPrint::OutputBin defaultOutputBin() const; + QList<QPrint::OutputBin> supportedOutputBins() const; + + QPrint::DuplexMode defaultDuplexMode() const; + QList<QPrint::DuplexMode> supportedDuplexModes() const; + + QPrint::ColorMode defaultColorMode() const; + QList<QPrint::ColorMode> supportedColorModes() const; + + enum PrintDevicePropertyKey { + PDPK_CustomBase = 0xff00 + }; + + QVariant property(PrintDevicePropertyKey key) const; + bool setProperty(PrintDevicePropertyKey key, const QVariant &value); + bool isFeatureAvailable(PrintDevicePropertyKey key, const QVariant ¶ms) const; + +#if QT_CONFIG(mimetype) + QList<QMimeType> supportedMimeTypes() const; +#endif + +# ifndef QT_NO_DEBUG_STREAM + void format(QDebug debug) const; +# endif + +private: + friend class QPlatformPrinterSupport; + friend class QPlatformPrintDevice; + QPrintDevice(QPlatformPrintDevice *dd); + QSharedPointer<QPlatformPrintDevice> d; +}; + +Q_DECLARE_SHARED(QPrintDevice) + +# ifndef QT_NO_DEBUG_STREAM +Q_PRINTSUPPORT_EXPORT QDebug operator<<(QDebug debug, const QPrintDevice &); +# endif +#endif // QT_NO_PRINTER + +QT_END_NAMESPACE + +#endif // QPLATFORMPRINTDEVICE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprintengine_pdf_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprintengine_pdf_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f3bd590ad1131353f1463bad67a1ea79d460fc71 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprintengine_pdf_p.h @@ -0,0 +1,109 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPRINTENGINE_PDF_P_H +#define QPRINTENGINE_PDF_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtPrintSupport/qprintengine.h" + +#ifndef QT_NO_PRINTER +#include "QtCore/qdatastream.h" +#include "QtCore/qmap.h" +#include "QtCore/qstring.h" +#include "QtGui/qpaintengine.h" +#include "QtGui/qpainterpath.h" + +#include "private/qfontengine_p.h" +#include "private/qpdf_p.h" +#include "private/qpaintengine_p.h" +#include "qprintengine.h" +#include "qprint_p.h" + +QT_BEGIN_NAMESPACE + +class QImage; +class QDataStream; +class QPen; +class QPointF; +class QRegion; +class QFile; + +class QPdfPrintEnginePrivate; + +class Q_PRINTSUPPORT_EXPORT QPdfPrintEngine : public QPdfEngine, public QPrintEngine +{ + Q_DECLARE_PRIVATE(QPdfPrintEngine) +public: + QPdfPrintEngine(QPrinter::PrinterMode m, QPdfEngine::PdfVersion version = QPdfEngine::Version_1_4); + virtual ~QPdfPrintEngine(); + + // reimplementations QPaintEngine + bool begin(QPaintDevice *pdev) override; + bool end() override; + // end reimplementations QPaintEngine + + // reimplementations QPrintEngine + bool abort() override {return false;} + QPrinter::PrinterState printerState() const override {return state;} + + bool newPage() override; + int metric(QPaintDevice::PaintDeviceMetric) const override; + virtual void setProperty(PrintEnginePropertyKey key, const QVariant &value) override; + virtual QVariant property(PrintEnginePropertyKey key) const override; + // end reimplementations QPrintEngine + + QPrinter::PrinterState state; + +protected: + QPdfPrintEngine(QPdfPrintEnginePrivate &p); + +private: + Q_DISABLE_COPY(QPdfPrintEngine) +}; + +class Q_PRINTSUPPORT_EXPORT QPdfPrintEnginePrivate : public QPdfEnginePrivate +{ + Q_DECLARE_PUBLIC(QPdfPrintEngine) +public: + QPdfPrintEnginePrivate(QPrinter::PrinterMode m); + ~QPdfPrintEnginePrivate(); + + QPrinter::ColorMode printerColorMode() const; + + virtual bool openPrintDevice(); + virtual void closePrintDevice(); + +private: + Q_DISABLE_COPY(QPdfPrintEnginePrivate) + + friend class QCupsPrintEngine; + friend class QCupsPrintEnginePrivate; + + QString printerName; + QString printProgram; + QString selectionOption; + + bool collate; + int copies; + QPrinter::PageOrder pageOrder; + QPrinter::PaperSource paperSource; + + int fd; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_PRINTER + +#endif // QPRINTENGINE_PDF_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprintengine_win_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprintengine_win_p.h new file mode 100644 index 0000000000000000000000000000000000000000..60bd3b31262e4fa2b937254006c356cb08245997 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprintengine_win_p.h @@ -0,0 +1,198 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPRINTENGINE_WIN_P_H +#define QPRINTENGINE_WIN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtPrintSupport/private/qtprintsupportglobal_p.h> + +#ifndef QT_NO_PRINTER + +#include <QtGui/qpaintengine.h> +#include <QtGui/qpagelayout.h> +#include <QtPrintSupport/QPrintEngine> +#include <QtPrintSupport/QPrinter> +#include <private/qpaintengine_alpha_p.h> +#include <private/qprintdevice_p.h> +#include <QtCore/qt_windows.h> + +QT_BEGIN_NAMESPACE + +class QWin32PrintEnginePrivate; +class QPrinterPrivate; +class QPainterState; + +class Q_PRINTSUPPORT_EXPORT QWin32PrintEngine : public QAlphaPaintEngine, public QPrintEngine +{ + Q_DECLARE_PRIVATE(QWin32PrintEngine) +public: + QWin32PrintEngine(QPrinter::PrinterMode mode, const QString &deviceId); + + // override QWin32PaintEngine + bool begin(QPaintDevice *dev) override; + bool end() override; + + void updateState(const QPaintEngineState &state) override; + + void updateMatrix(const QTransform &matrix); + void updateClipPath(const QPainterPath &clip, Qt::ClipOperation op); + + void drawPath(const QPainterPath &path) override; + void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; + void drawTextItem(const QPointF &p, const QTextItem &textItem) override; + + void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; + void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &p) override; + void setProperty(PrintEnginePropertyKey key, const QVariant &value) override; + QVariant property(PrintEnginePropertyKey key) const override; + + bool newPage() override; + bool abort() override; + int metric(QPaintDevice::PaintDeviceMetric) const override; + + QPrinter::PrinterState printerState() const override; + + QPaintEngine::Type type() const override { return Windows; } + + HDC getDC() const; + void releaseDC(HDC) const; + + /* Used by print/page setup dialogs */ + void setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalDevMode); + HGLOBAL *createGlobalDevNames(); + HGLOBAL globalDevMode(); + +private: + friend class QPrintDialog; + friend class QPageSetupDialog; +}; + +class QWin32PrintEnginePrivate : public QAlphaPaintEnginePrivate +{ + Q_DECLARE_PUBLIC(QWin32PrintEngine) +public: + QWin32PrintEnginePrivate() : + printToFile(false), reinit(false), + complex_xform(false), has_pen(false), has_brush(false), has_custom_paper_size(false), + embed_fonts(true) + { + } + + ~QWin32PrintEnginePrivate(); + + + /* Initializes the printer data based on the current printer name. This + function creates a DEVMODE struct, HDC and a printer handle. If these + structures are already in use, they are freed using release + */ + void initialize(); + + /* Initializes data in the print engine whenever the HDC has been renewed + */ + void initHDC(); + + /* Releases all the handles the printer currently holds, HDC, DEVMODE, + etc and resets the corresponding members to 0. */ + void release(); + + /* Resets the DC with changes in devmode. If the printer is active + this function only sets the reinit variable to true so it + is handled in the next begin or newpage. */ + void doReinit(); + + static void initializeDevMode(DEVMODE *); + + bool resetDC(); + + void strokePath(const QPainterPath &path, const QColor &color); + void fillPath(const QPainterPath &path, const QColor &color); + + void composeGdiPath(const QPainterPath &path); + void fillPath_dev(const QPainterPath &path, const QColor &color); + void strokePath_dev(const QPainterPath &path, const QColor &color, qreal width); + + void setPageSize(const QPageSize &pageSize); + void updatePageLayout(); + void updateMetrics(); + void debugMetrics() const; + + // Windows GDI printer references. + HANDLE hPrinter = nullptr; + + HGLOBAL globalDevMode = nullptr; + DEVMODE *devMode = nullptr; + PRINTER_INFO_2 *pInfo = nullptr; + HGLOBAL hMem = nullptr; + + HDC hdc = nullptr; + + // True if devMode was allocated separately from pInfo. + bool ownsDevMode = false; + + QPrinter::PrinterMode mode = QPrinter::ScreenResolution; + + // Print Device + QPrintDevice m_printDevice; + + // Document info + QString docName; + QString m_creator; + QString fileName; + + QPrinter::PrinterState state = QPrinter::Idle; + int resolution = 0; + + // Page Layout + QPageLayout m_pageLayout{QPageSize(QPageSize::A4), + QPageLayout::Portrait, QMarginsF{0, 0, 0, 0}}; + // Page metrics cache + QRect m_paintRectPixels; + QSize m_paintSizeMM; + + // Windows painting + qreal stretch_x = 1; + qreal stretch_y = 1; + int origin_x = 0; + int origin_y = 0; + + int dpi_x = 96; + int dpi_y = 96; + int dpi_display = 96; + int num_copies = 1; + + uint printToFile : 1; + uint reinit : 1; + + uint complex_xform : 1; + uint has_pen : 1; + uint has_brush : 1; + uint has_custom_paper_size : 1; + uint embed_fonts : 1; + + uint txop = 0; // QTransform::TxNone + + QColor brush_color; + QPen pen; + QColor pen_color; + QSizeF paper_size; // In points + + QTransform painterMatrix; + QTransform matrix; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_PRINTER + +#endif // QPRINTENGINE_WIN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprinter_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprinter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ea84a2707556e89d31019ed86da3f5bde6a6b6f4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprinter_p.h @@ -0,0 +1,108 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPRINTER_P_H +#define QPRINTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#include <QtPrintSupport/private/qtprintsupportglobal_p.h> + +#ifndef QT_NO_PRINTER + +#include "QtPrintSupport/qprinter.h" +#include "QtPrintSupport/qprinterinfo.h" +#include "QtPrintSupport/qprintengine.h" +#include "QtCore/qpointer.h" +#include "QtCore/qset.h" + +#include <limits.h> + +QT_BEGIN_NAMESPACE + +class QPrintEngine; +class QPreviewPaintEngine; +class QPicture; + +class Q_PRINTSUPPORT_EXPORT QPrinterPrivate +{ + Q_DECLARE_PUBLIC(QPrinter) +public: + QPrinterPrivate(QPrinter *printer) + : pdfVersion(QPrinter::PdfVersion_1_4), + printEngine(nullptr), + paintEngine(nullptr), + realPrintEngine(nullptr), + realPaintEngine(nullptr), +#if QT_CONFIG(printpreviewwidget) + previewEngine(nullptr), +#endif + q_ptr(printer), + printRange(QPrinter::AllPages), + use_default_engine(true), + validPrinter(false) + { + } + + ~QPrinterPrivate() { + + } + + static QPrinterPrivate *get(QPrinter *printer) { + return printer->d_ptr.get(); + } + + void init(const QPrinterInfo &printer, QPrinter::PrinterMode mode); + + QPrinterInfo findValidPrinter(const QPrinterInfo &printer = QPrinterInfo()); + void initEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer); + void changeEngines(QPrinter::OutputFormat format, const QPrinterInfo &printer); +#if QT_CONFIG(printpreviewwidget) + QList<const QPicture *> previewPages() const; + void setPreviewMode(bool); + bool previewMode() const; +#endif + + void setProperty(QPrintEngine::PrintEnginePropertyKey key, const QVariant &value); + + QPrinter::PrinterMode printerMode; + QPrinter::OutputFormat outputFormat; + QPrinter::PdfVersion pdfVersion; + QPrintEngine *printEngine; + QPaintEngine *paintEngine; + + QPrintEngine *realPrintEngine; + QPaintEngine *realPaintEngine; +#if QT_CONFIG(printpreviewwidget) + QPreviewPaintEngine *previewEngine; +#endif + + QPrinter *q_ptr; + + QPrinter::PrintRange printRange; + + uint use_default_engine : 1; + uint had_default_engines : 1; + + uint validPrinter : 1; + uint hasCustomPageMargins : 1; + + // Used to remember which properties have been manually set by the user. + QSet<QPrintEngine::PrintEnginePropertyKey> m_properties; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_PRINTER + +#endif // QPRINTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprinterinfo_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprinterinfo_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c92861bc5d278ee755660e3ffd939967f9ff3bd0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qprinterinfo_p.h @@ -0,0 +1,39 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPRINTERINFO_P_H +#define QPRINTERINFO_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtPrintSupport/private/qtprintsupportglobal_p.h> + +#ifndef QT_NO_PRINTER + +#include "qprintdevice_p.h" + +QT_BEGIN_NAMESPACE + +class QPrinterInfoPrivate +{ +public: + QPrinterInfoPrivate(const QString& id = QString()); + ~QPrinterInfoPrivate(); + + QPrintDevice m_printDevice; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_PRINTER + +#endif // QPRINTERINFO_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qtprintsupport-config_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qtprintsupport-config_p.h new file mode 100644 index 0000000000000000000000000000000000000000..aa02b9b461bc9235967a75627442aff0c97edd4e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qtprintsupport-config_p.h @@ -0,0 +1,6 @@ +#define QT_FEATURE_cups -1 + +#define QT_FEATURE_cupsjobwidget -1 + +#define QT_FEATURE_cupspassworddialog 1 + diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qtprintsupportglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qtprintsupportglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4bdde21de8df76322e3ac9141335f1f18ea055e7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qtprintsupportglobal_p.h @@ -0,0 +1,22 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTPRINTSUPPORTGLOBAL_P_H +#define QTPRINTSUPPORTGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtPrintSupport/qtprintsupportglobal.h> +#include <QtWidgets/private/qtwidgetsglobal_p.h> +#include <QtPrintSupport/private/qtprintsupport-config_p.h> + +#endif // QTPRINTSUPPORTGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qwindowsprintdevice_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qwindowsprintdevice_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8656fb89a6f5bb63afbfd5cd93c2a9d20c939815 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qwindowsprintdevice_p.h @@ -0,0 +1,119 @@ +// Copyright (C) 2014 John Layt <jlayt@kde.org> +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWINDOWSPRINTDEVICE_H +#define QWINDOWSPRINTDEVICE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include <qpa/qplatformprintdevice.h> + +#include <QtPrintSupport/qtprintsupportglobal.h> +#include <QtCore/qt_windows.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class Q_PRINTSUPPORT_EXPORT QWindowsPrinterInfo +{ +public: + bool operator==(const QWindowsPrinterInfo &other) const + { + // We only need to check if these are the same for matching up + return m_id == other.m_id && m_name == other.m_name && + m_location == other.m_location && + m_makeAndModel == other.m_makeAndModel && + m_isRemote == other.m_isRemote; + } + QString m_id; + QString m_name; + QString m_location; + QString m_makeAndModel; + QList<QPageSize> m_pageSizes; + QList<int> m_resolutions; + QList<QPrint::InputSlot> m_inputSlots; + QList<QPrint::OutputBin> m_outputBins; + QList<QPrint::DuplexMode> m_duplexModes; + QList<QPrint::ColorMode> m_colorModes; + QSize m_minimumPhysicalPageSize; + QSize m_maximumPhysicalPageSize; + bool m_isRemote = false; + bool m_havePageSizes = false; + bool m_haveResolutions = false; + bool m_haveCopies = false; + bool m_supportsMultipleCopies = false; + bool m_supportsCollateCopies = false; + bool m_haveMinMaxPageSizes = false; + bool m_supportsCustomPageSizes = false; + bool m_haveInputSlots = false; + bool m_haveOutputBins = false; + bool m_haveDuplexModes = false; + bool m_haveColorModes = false; +}; + +class Q_PRINTSUPPORT_EXPORT QWindowsPrintDevice : public QPlatformPrintDevice +{ +public: + QWindowsPrintDevice(); + explicit QWindowsPrintDevice(const QString &id); + virtual ~QWindowsPrintDevice(); + + bool isValid() const override; + bool isDefault() const override; + + QPrint::DeviceState state() const override; + + QPageSize defaultPageSize() const override; + + QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation, + int resolution) const override; + + int defaultResolution() const override; + + QPrint::InputSlot defaultInputSlot() const override; + + QPrint::DuplexMode defaultDuplexMode() const override; + + QPrint::ColorMode defaultColorMode() const override; + + static QStringList availablePrintDeviceIds(); + static QString defaultPrintDeviceId(); + + bool supportsCollateCopies() const override; + bool supportsMultipleCopies() const override; + bool supportsCustomPageSizes() const override; + QSize minimumPhysicalPageSize() const override; + QSize maximumPhysicalPageSize() const override; + +protected: + void loadPageSizes() const override; + void loadResolutions() const override; + void loadInputSlots() const override; + void loadOutputBins() const override; + void loadDuplexModes() const override; + void loadColorModes() const override; + void loadCopiesSupport() const; + void loadMinMaxPageSizes() const; + +private: + LPCWSTR wcharId() const { return reinterpret_cast<LPCWSTR>(m_id.utf16()); } + + HANDLE m_hPrinter; + mutable bool m_haveCopies; + mutable bool m_haveMinMaxPageSizes; + int m_infoIndex; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSPRINTDEVICE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qwindowsprintersupport_p.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qwindowsprintersupport_p.h new file mode 100644 index 0000000000000000000000000000000000000000..908c9215d77d373a73f3f90ac3161af3abb52355 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/private/qwindowsprintersupport_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef WINDOWSPRINTERSUPPORT_H +#define WINDOWSPRINTERSUPPORT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include <QtPrintSupport/qtprintsupportglobal.h> + +#include <qpa/qplatformprintersupport.h> +#include <private/qglobal_p.h> +#ifndef QT_NO_PRINTER + +QT_BEGIN_NAMESPACE + +class Q_PRINTSUPPORT_EXPORT QWindowsPrinterSupport : public QPlatformPrinterSupport +{ + Q_DISABLE_COPY_MOVE(QWindowsPrinterSupport) +public: + QWindowsPrinterSupport(); + ~QWindowsPrinterSupport() override; + + QPrintEngine *createNativePrintEngine(QPrinter::PrinterMode printerMode, const QString &deviceId = QString()) override; + QPaintEngine *createPaintEngine(QPrintEngine *printEngine, QPrinter::PrinterMode) override; + + QPrintDevice createPrintDevice(const QString &id) override; + QStringList availablePrintDeviceIds() const override; + QString defaultPrintDeviceId() const override; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_PRINTER +#endif // WINDOWSPRINTERSUPPORT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/qpa/qplatformprintdevice.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/qpa/qplatformprintdevice.h new file mode 100644 index 0000000000000000000000000000000000000000..c54f06a6e4d6e3000f9b68d03f7fa5e59a9b4ab7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/qpa/qplatformprintdevice.h @@ -0,0 +1,157 @@ +// Copyright (C) 2014 John Layt <jlayt@kde.org> +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMPRINTDEVICE_H +#define QPLATFORMPRINTDEVICE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include <QtPrintSupport/qtprintsupportglobal.h> +#include <private/qprint_p.h> +#include <private/qprintdevice_p.h> + +#include <QtCore/qlist.h> +#include <QtCore/qvariant.h> +#if QT_CONFIG(mimetype) +#include <QtCore/qmimetype.h> +#endif +#include <QtGui/qpagelayout.h> + + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_PRINTER + +class Q_PRINTSUPPORT_EXPORT QPlatformPrintDevice +{ + Q_DISABLE_COPY(QPlatformPrintDevice) +public: + explicit QPlatformPrintDevice(const QString &id = QString()); + virtual ~QPlatformPrintDevice(); + + virtual QString id() const; + virtual QString name() const; + virtual QString location() const; + virtual QString makeAndModel() const; + + virtual bool isValid() const; + virtual bool isDefault() const; + virtual bool isRemote() const; + + virtual QPrint::DeviceState state() const; + + virtual bool isValidPageLayout(const QPageLayout &layout, int resolution) const; + + virtual bool supportsMultipleCopies() const; + virtual bool supportsCollateCopies() const; + + virtual QPageSize defaultPageSize() const; + virtual QList<QPageSize> supportedPageSizes() const; + + virtual QPageSize supportedPageSize(const QPageSize &pageSize) const; + virtual QPageSize supportedPageSize(QPageSize::PageSizeId pageSizeId) const; + virtual QPageSize supportedPageSize(const QString &pageName) const; + virtual QPageSize supportedPageSize(const QSize &pointSize) const; + virtual QPageSize supportedPageSize(const QSizeF &size, QPageSize::Unit units) const; + + virtual bool supportsCustomPageSizes() const; + + virtual QSize minimumPhysicalPageSize() const; + virtual QSize maximumPhysicalPageSize() const; + + virtual QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation, + int resolution) const; + + virtual int defaultResolution() const; + virtual QList<int> supportedResolutions() const; + + virtual QPrint::InputSlot defaultInputSlot() const; + virtual QList<QPrint::InputSlot> supportedInputSlots() const; + + virtual QPrint::OutputBin defaultOutputBin() const; + virtual QList<QPrint::OutputBin> supportedOutputBins() const; + + virtual QPrint::DuplexMode defaultDuplexMode() const; + virtual QList<QPrint::DuplexMode> supportedDuplexModes() const; + + virtual QPrint::ColorMode defaultColorMode() const; + virtual QList<QPrint::ColorMode> supportedColorModes() const; + + virtual QVariant property(QPrintDevice::PrintDevicePropertyKey key) const; + virtual bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value); + virtual bool isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant ¶ms) const; + +#if QT_CONFIG(mimetype) + virtual QList<QMimeType> supportedMimeTypes() const; +#endif + + static QPageSize createPageSize(const QString &key, const QSize &size, const QString &localizedName); + static QPageSize createPageSize(int windowsId, const QSize &size, const QString &localizedName); + +protected: + virtual void loadPageSizes() const; + virtual void loadResolutions() const; + virtual void loadInputSlots() const; + virtual void loadOutputBins() const; + virtual void loadDuplexModes() const; + virtual void loadColorModes() const; +#if QT_CONFIG(mimetype) + virtual void loadMimeTypes() const; +#endif + + QPageSize supportedPageSizeMatch(const QPageSize &pageSize) const; + + QString m_id; + QString m_name; + QString m_location; + QString m_makeAndModel; + + bool m_isRemote; + + mutable bool m_supportsMultipleCopies; + mutable bool m_supportsCollateCopies; + + mutable bool m_havePageSizes; + mutable QList<QPageSize> m_pageSizes; + + mutable bool m_supportsCustomPageSizes; + + mutable QSize m_minimumPhysicalPageSize; + mutable QSize m_maximumPhysicalPageSize; + + mutable bool m_haveResolutions; + mutable QList<int> m_resolutions; + + mutable bool m_haveInputSlots; + mutable QList<QPrint::InputSlot> m_inputSlots; + + mutable bool m_haveOutputBins; + mutable QList<QPrint::OutputBin> m_outputBins; + + mutable bool m_haveDuplexModes; + mutable QList<QPrint::DuplexMode> m_duplexModes; + + mutable bool m_haveColorModes; + mutable QList<QPrint::ColorMode> m_colorModes; + +#if QT_CONFIG(mimetype) + mutable bool m_haveMimeTypes; + mutable QList<QMimeType> m_mimeTypes; +#endif +}; + +#endif // QT_NO_PRINTER + +QT_END_NAMESPACE + +#endif // QPLATFORMPRINTDEVICE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/qpa/qplatformprintersupport.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/qpa/qplatformprintersupport.h new file mode 100644 index 0000000000000000000000000000000000000000..c72f2de3842eed5b7e7da61578a2493f3a6071d7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/qpa/qplatformprintersupport.h @@ -0,0 +1,55 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMPRINTERSUPPORT_H +#define QPLATFORMPRINTERSUPPORT_H +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtPrintSupport/qtprintsupportglobal.h> +#include <QtPrintSupport/qprinter.h> + +#include <QtCore/qstringlist.h> +#include <QtCore/qlist.h> +#include <QtCore/qhash.h> + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_PRINTER + +typedef QHash<QString, QString> PrinterOptions; + +class QPageSize; +class QPlatformPrintDevice; +class QPrintDevice; +class QPrintEngine; + +class Q_PRINTSUPPORT_EXPORT QPlatformPrinterSupport +{ +public: + QPlatformPrinterSupport(); + virtual ~QPlatformPrinterSupport(); + + virtual QPrintEngine *createNativePrintEngine(QPrinter::PrinterMode printerMode, const QString &deviceId = QString()); + virtual QPaintEngine *createPaintEngine(QPrintEngine *, QPrinter::PrinterMode printerMode); + + virtual QPrintDevice createPrintDevice(const QString &id); + virtual QStringList availablePrintDeviceIds() const; + virtual QString defaultPrintDeviceId() const; + +protected: + static QPrintDevice createPrintDevice(QPlatformPrintDevice *device); + static QPageSize createPageSize(const QString &id, QSize size, const QString &localizedName); +}; + +#endif // QT_NO_PRINTER + +QT_END_NAMESPACE + +#endif // QPLATFORMPRINTERSUPPORT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/qpa/qplatformprintplugin.h b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/qpa/qplatformprintplugin.h new file mode 100644 index 0000000000000000000000000000000000000000..f56a1ba5340c0f01ec2a0aba463d06003a7c6829 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtPrintSupport/6.8.1/QtPrintSupport/qpa/qplatformprintplugin.h @@ -0,0 +1,45 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPLATFORMPRINTPLUGIN_H +#define QPLATFORMPRINTPLUGIN_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include <QtPrintSupport/qtprintsupportglobal.h> +#include <QtCore/qplugin.h> +#include <QtCore/qfactoryinterface.h> + +#ifndef QT_NO_PRINTER + +QT_BEGIN_NAMESPACE + + +class QPlatformPrinterSupport; + +#define QPlatformPrinterSupportFactoryInterface_iid "org.qt-project.QPlatformPrinterSupportFactoryInterface.5.1" + +class Q_PRINTSUPPORT_EXPORT QPlatformPrinterSupportPlugin : public QObject +{ + Q_OBJECT +public: + explicit QPlatformPrinterSupportPlugin(QObject *parent = nullptr); + ~QPlatformPrinterSupportPlugin(); + + virtual QPlatformPrinterSupport *create(const QString &key) = 0; + + static QPlatformPrinterSupport *get(); +}; + +QT_END_NAMESPACE + +#endif + +#endif // QPLATFORMPRINTPLUGIN_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatch/catch/catch.hpp b/qt/6.8.1/msvc2022_64/include/QtQDocCatch/catch/catch.hpp new file mode 100644 index 0000000000000000000000000000000000000000..304bbfcce58877b5d23dbbffcacf2cde31cb0ae6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatch/catch/catch.hpp @@ -0,0 +1,17976 @@ +/* + * Catch v2.13.10 + * Generated: 2022-10-16 11:01:23.452308 + * ---------------------------------------------------------- + * This file has been merged from multiple headers. Please don't edit it directly + * Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +// start catch.hpp + + +#define CATCH_VERSION_MAJOR 2 +#define CATCH_VERSION_MINOR 13 +#define CATCH_VERSION_PATCH 10 + +#ifdef __clang__ +# pragma clang system_header +#elif defined __GNUC__ +# pragma GCC system_header +#endif + +// start catch_suppress_warnings.h + +#ifdef __clang__ +# ifdef __ICC // icpc defines the __clang__ macro +# pragma warning(push) +# pragma warning(disable: 161 1682) +# else // __ICC +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +# pragma clang diagnostic ignored "-Wswitch-enum" +# pragma clang diagnostic ignored "-Wcovered-switch-default" +# endif +#elif defined __GNUC__ + // Because REQUIREs trigger GCC's -Wparentheses, and because still + // supported version of g++ have only buggy support for _Pragmas, + // Wparentheses have to be suppressed globally. +# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details + +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-variable" +# pragma GCC diagnostic ignored "-Wpadded" +#endif +// end catch_suppress_warnings.h +#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) +# define CATCH_IMPL +# define CATCH_CONFIG_ALL_PARTS +#endif + +// In the impl file, we want to have access to all parts of the headers +// Can also be used to sanely support PCHs +#if defined(CATCH_CONFIG_ALL_PARTS) +# define CATCH_CONFIG_EXTERNAL_INTERFACES +# if defined(CATCH_CONFIG_DISABLE_MATCHERS) +# undef CATCH_CONFIG_DISABLE_MATCHERS +# endif +# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +# endif +#endif + +#if !defined(CATCH_CONFIG_IMPL_ONLY) +// start catch_platform.h + +// See e.g.: +// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html +#ifdef __APPLE__ +# include <TargetConditionals.h> +# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ + (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) +# define CATCH_PLATFORM_MAC +# elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) +# define CATCH_PLATFORM_IPHONE +# endif + +#elif defined(linux) || defined(__linux) || defined(__linux__) +# define CATCH_PLATFORM_LINUX + +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) +# define CATCH_PLATFORM_WINDOWS +#endif + +// end catch_platform.h + +#ifdef CATCH_IMPL +# ifndef CLARA_CONFIG_MAIN +# define CLARA_CONFIG_MAIN_NOT_DEFINED +# define CLARA_CONFIG_MAIN +# endif +#endif + +// start catch_user_interfaces.h + +namespace Catch { + unsigned int rngSeed(); +} + +// end catch_user_interfaces.h +// start catch_tag_alias_autoregistrar.h + +// start catch_common.h + +// start catch_compiler_capabilities.h + +// Detect a number of compiler features - by compiler +// The following features are defined: +// +// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? +// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? +// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? +// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? +// **************** +// Note to maintainers: if new toggles are added please document them +// in configuration.md, too +// **************** + +// In general each macro has a _NO_<feature name> form +// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. +// Many features, at point of detection, define an _INTERNAL_ macro, so they +// can be combined, en-mass, with the _NO_ forms later. + +#ifdef __cplusplus + +# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) +# define CATCH_CPP14_OR_GREATER +# endif + +# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) +# define CATCH_CPP17_OR_GREATER +# endif + +#endif + +// Only GCC compiler should be used in this block, so other compilers trying to +// mask themselves as GCC should be ignored. +#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) + +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) + +#endif + +#if defined(__clang__) + +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) + +// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug +// which results in calls to destructors being emitted for each temporary, +// without a matching initialization. In practice, this can result in something +// like `std::string::~string` being called on an uninitialized value. +// +// For example, this code will likely segfault under IBM XL: +// ``` +// REQUIRE(std::string("12") + "34" == "1234") +// ``` +// +// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. +# if !defined(__ibmxl__) && !defined(__CUDACC__) +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ +# endif + +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ + _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") + +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) + +# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) + +#endif // __clang__ + +//////////////////////////////////////////////////////////////////////////////// +// Assume that non-Windows platforms support posix signals by default +#if !defined(CATCH_PLATFORM_WINDOWS) + #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS +#endif + +//////////////////////////////////////////////////////////////////////////////// +// We know some environments not to support full POSIX signals +#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) + #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +#endif + +#ifdef __OS400__ +# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +# define CATCH_CONFIG_COLOUR_NONE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Android somehow still does not support std::to_string +#if defined(__ANDROID__) +# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING +# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Not all Windows environments support SEH properly +#if defined(__MINGW32__) +# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH +#endif + +//////////////////////////////////////////////////////////////////////////////// +// PS4 +#if defined(__ORBIS__) +# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Cygwin +#ifdef __CYGWIN__ + +// Required for some versions of Cygwin to declare gettimeofday +// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin +# define _BSD_SOURCE +// some versions of cygwin (most) do not support std::to_string. Use the libstd check. +// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 +# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ + && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) + +# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING + +# endif +#endif // __CYGWIN__ + +//////////////////////////////////////////////////////////////////////////////// +// Visual C++ +#if defined(_MSC_VER) + +// Universal Windows platform does not support SEH +// Or console colours (or console at all...) +# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +# define CATCH_CONFIG_COLOUR_NONE +# else +# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH +# endif + +# if !defined(__clang__) // Handle Clang masquerading for msvc + +// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ +// _MSVC_TRADITIONAL == 0 means new conformant preprocessor +// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor +# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) +# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +# endif // MSVC_TRADITIONAL + +// Only do this if we're not using clang on Windows, which uses `diagnostic push` & `diagnostic pop` +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) +# endif // __clang__ + +#endif // _MSC_VER + +#if defined(_REENTRANT) || defined(_MSC_VER) +// Enable async processing, as -pthread is specified or no additional linking is required +# define CATCH_INTERNAL_CONFIG_USE_ASYNC +#endif // _MSC_VER + +//////////////////////////////////////////////////////////////////////////////// +// Check if we are compiled with -fno-exceptions or equivalent +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED +#endif + +//////////////////////////////////////////////////////////////////////////////// +// DJGPP +#ifdef __DJGPP__ +# define CATCH_INTERNAL_CONFIG_NO_WCHAR +#endif // __DJGPP__ + +//////////////////////////////////////////////////////////////////////////////// +// Embarcadero C++Build +#if defined(__BORLANDC__) + #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN +#endif + +//////////////////////////////////////////////////////////////////////////////// + +// Use of __COUNTER__ is suppressed during code analysis in +// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly +// handled by it. +// Otherwise all supported compilers support COUNTER macro, +// but user still might want to turn it off +#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) + #define CATCH_INTERNAL_CONFIG_COUNTER +#endif + +//////////////////////////////////////////////////////////////////////////////// + +// RTX is a special version of Windows that is real time. +// This means that it is detected as Windows, but does not provide +// the same set of capabilities as real Windows does. +#if defined(UNDER_RTSS) || defined(RTX64_BUILD) + #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH + #define CATCH_INTERNAL_CONFIG_NO_ASYNC + #define CATCH_CONFIG_COLOUR_NONE +#endif + +#if !defined(_GLIBCXX_USE_C99_MATH_TR1) +#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER +#endif + +// Various stdlib support checks that require __has_include +#if defined(__has_include) + // Check if string_view is available and usable + #if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW + #endif + + // Check if optional is available and usable + # if __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL + # endif // __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER) + + // Check if byte is available and usable + # if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER) + # include <cstddef> + # if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0) + # define CATCH_INTERNAL_CONFIG_CPP17_BYTE + # endif + # endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER) + + // Check if variant is available and usable + # if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER) + # if defined(__clang__) && (__clang_major__ < 8) + // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 + // fix should be in clang 8, workaround in libstdc++ 8.2 + # include <ciso646> + # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # define CATCH_CONFIG_NO_CPP17_VARIANT + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__clang__) && (__clang_major__ < 8) + # endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER) +#endif // defined(__has_include) + +#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) +# define CATCH_CONFIG_COUNTER +#endif +#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) +# define CATCH_CONFIG_WINDOWS_SEH +#endif +// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. +#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) +# define CATCH_CONFIG_POSIX_SIGNALS +#endif +// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. +#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) +# define CATCH_CONFIG_WCHAR +#endif + +#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) +# define CATCH_CONFIG_CPP11_TO_STRING +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) +# define CATCH_CONFIG_CPP17_OPTIONAL +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) +# define CATCH_CONFIG_CPP17_STRING_VIEW +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) +# define CATCH_CONFIG_CPP17_VARIANT +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) +# define CATCH_CONFIG_CPP17_BYTE +#endif + +#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) +# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) +# define CATCH_CONFIG_NEW_CAPTURE +#endif + +#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +# define CATCH_CONFIG_DISABLE_EXCEPTIONS +#endif + +#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) +# define CATCH_CONFIG_POLYFILL_ISNAN +#endif + +#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) +# define CATCH_CONFIG_USE_ASYNC +#endif + +#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) +# define CATCH_CONFIG_ANDROID_LOGWRITE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) +# define CATCH_CONFIG_GLOBAL_NEXTAFTER +#endif + +// Even if we do not think the compiler has that warning, we still have +// to provide a macro that can be used by the code. +#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +#endif +#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS +#endif + +// The goal of this macro is to avoid evaluation of the arguments, but +// still have the compiler warn on problems inside... +#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) +#endif + +#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) +# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#elif defined(__clang__) && (__clang_major__ < 5) +# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif + +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif + +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +#define CATCH_TRY if ((true)) +#define CATCH_CATCH_ALL if ((false)) +#define CATCH_CATCH_ANON(type) if ((false)) +#else +#define CATCH_TRY try +#define CATCH_CATCH_ALL catch (...) +#define CATCH_CATCH_ANON(type) catch (type) +#endif + +#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) +#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#endif + +// end catch_compiler_capabilities.h +#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line +#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) +#ifdef CATCH_CONFIG_COUNTER +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) +#else +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) +#endif + +#include <iosfwd> +#include <string> +#include <cstdint> + +// We need a dummy global operator<< so we can bring it into Catch namespace later +struct Catch_global_namespace_dummy {}; +std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); + +namespace Catch { + + struct CaseSensitive { enum Choice { + Yes, + No + }; }; + + class NonCopyable { + NonCopyable( NonCopyable const& ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable& operator = ( NonCopyable const& ) = delete; + NonCopyable& operator = ( NonCopyable && ) = delete; + + protected: + NonCopyable(); + virtual ~NonCopyable(); + }; + + struct SourceLineInfo { + + SourceLineInfo() = delete; + SourceLineInfo( char const* _file, std::size_t _line ) noexcept + : file( _file ), + line( _line ) + {} + + SourceLineInfo( SourceLineInfo const& other ) = default; + SourceLineInfo& operator = ( SourceLineInfo const& ) = default; + SourceLineInfo( SourceLineInfo&& ) noexcept = default; + SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; + + bool empty() const noexcept { return file[0] == '\0'; } + bool operator == ( SourceLineInfo const& other ) const noexcept; + bool operator < ( SourceLineInfo const& other ) const noexcept; + + char const* file; + std::size_t line; + }; + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); + + // Bring in operator<< from global namespace into Catch namespace + // This is necessary because the overload of operator<< above makes + // lookup stop at namespace Catch + using ::operator<<; + + // Use this in variadic streaming macros to allow + // >> +StreamEndStop + // as well as + // >> stuff +StreamEndStop + struct StreamEndStop { + std::string operator+() const; + }; + template<typename T> + T const& operator + ( T const& value, StreamEndStop ) { + return value; + } +} + +#define CATCH_INTERNAL_LINEINFO \ + ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) ) + +// end catch_common.h +namespace Catch { + + struct RegistrarForTagAliases { + RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); + }; + +} // end namespace Catch + +#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +// end catch_tag_alias_autoregistrar.h +// start catch_test_registry.h + +// start catch_interfaces_testcase.h + +#include <vector> + +namespace Catch { + + class TestSpec; + + struct ITestInvoker { + virtual void invoke () const = 0; + virtual ~ITestInvoker(); + }; + + class TestCase; + struct IConfig; + + struct ITestCaseRegistry { + virtual ~ITestCaseRegistry(); + virtual std::vector<TestCase> const& getAllTests() const = 0; + virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const = 0; + }; + + bool isThrowSafe( TestCase const& testCase, IConfig const& config ); + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); + std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ); + std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config ); + +} + +// end catch_interfaces_testcase.h +// start catch_stringref.h + +#include <cstddef> +#include <string> +#include <iosfwd> +#include <cassert> + +namespace Catch { + + /// A non-owning string class (similar to the forthcoming std::string_view) + /// Note that, because a StringRef may be a substring of another string, + /// it may not be null terminated. + class StringRef { + public: + using size_type = std::size_t; + using const_iterator = const char*; + + private: + static constexpr char const* const s_empty = ""; + + char const* m_start = s_empty; + size_type m_size = 0; + + public: // construction + constexpr StringRef() noexcept = default; + + StringRef( char const* rawChars ) noexcept; + + constexpr StringRef( char const* rawChars, size_type size ) noexcept + : m_start( rawChars ), + m_size( size ) + {} + + StringRef( std::string const& stdString ) noexcept + : m_start( stdString.c_str() ), + m_size( stdString.size() ) + {} + + explicit operator std::string() const { + return std::string(m_start, m_size); + } + + public: // operators + auto operator == ( StringRef const& other ) const noexcept -> bool; + auto operator != (StringRef const& other) const noexcept -> bool { + return !(*this == other); + } + + auto operator[] ( size_type index ) const noexcept -> char { + assert(index < m_size); + return m_start[index]; + } + + public: // named queries + constexpr auto empty() const noexcept -> bool { + return m_size == 0; + } + constexpr auto size() const noexcept -> size_type { + return m_size; + } + + // Returns the current start pointer. If the StringRef is not + // null-terminated, throws std::domain_exception + auto c_str() const -> char const*; + + public: // substrings and searches + // Returns a substring of [start, start + length). + // If start + length > size(), then the substring is [start, size()). + // If start > size(), then the substring is empty. + auto substr( size_type start, size_type length ) const noexcept -> StringRef; + + // Returns the current start pointer. May not be null-terminated. + auto data() const noexcept -> char const*; + + constexpr auto isNullTerminated() const noexcept -> bool { + return m_start[m_size] == '\0'; + } + + public: // iterators + constexpr const_iterator begin() const { return m_start; } + constexpr const_iterator end() const { return m_start + m_size; } + }; + + auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; + auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; + + constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { + return StringRef( rawChars, size ); + } +} // namespace Catch + +constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { + return Catch::StringRef( rawChars, size ); +} + +// end catch_stringref.h +// start catch_preprocessor.hpp + + +#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ +#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) + +#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ +// MSVC needs more evaluations +#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) +#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) +#else +#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) +#endif + +#define CATCH_REC_END(...) +#define CATCH_REC_OUT + +#define CATCH_EMPTY() +#define CATCH_DEFER(id) id CATCH_EMPTY() + +#define CATCH_REC_GET_END2() 0, CATCH_REC_END +#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 +#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 +#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT +#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) +#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) + +#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) + +#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) + +// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, +// and passes userdata as the first parameter to each invocation, +// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) +#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) +#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ +#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ +#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) +#else +// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) +#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) +#endif + +#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ +#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) + +#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>()) +#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) +#else +#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>())) +#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) +#endif + +#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ + CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) + +#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) +#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) +#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) +#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) +#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) +#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) +#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) +#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) +#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) +#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) +#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) + +#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N + +#define INTERNAL_CATCH_TYPE_GEN\ + template<typename...> struct TypeList {};\ + template<typename...Ts>\ + constexpr auto get_wrapper() noexcept -> TypeList<Ts...> { return {}; }\ + template<template<typename...> class...> struct TemplateTypeList{};\ + template<template<typename...> class...Cs>\ + constexpr auto get_wrapper() noexcept -> TemplateTypeList<Cs...> { return {}; }\ + template<typename...>\ + struct append;\ + template<typename...>\ + struct rewrap;\ + template<template<typename...> class, typename...>\ + struct create;\ + template<template<typename...> class, typename>\ + struct convert;\ + \ + template<typename T> \ + struct append<T> { using type = T; };\ + template< template<typename...> class L1, typename...E1, template<typename...> class L2, typename...E2, typename...Rest>\ + struct append<L1<E1...>, L2<E2...>, Rest...> { using type = typename append<L1<E1...,E2...>, Rest...>::type; };\ + template< template<typename...> class L1, typename...E1, typename...Rest>\ + struct append<L1<E1...>, TypeList<mpl_::na>, Rest...> { using type = L1<E1...>; };\ + \ + template< template<typename...> class Container, template<typename...> class List, typename...elems>\ + struct rewrap<TemplateTypeList<Container>, List<elems...>> { using type = TypeList<Container<elems...>>; };\ + template< template<typename...> class Container, template<typename...> class List, class...Elems, typename...Elements>\ + struct rewrap<TemplateTypeList<Container>, List<Elems...>, Elements...> { using type = typename append<TypeList<Container<Elems...>>, typename rewrap<TemplateTypeList<Container>, Elements...>::type>::type; };\ + \ + template<template <typename...> class Final, template< typename...> class...Containers, typename...Types>\ + struct create<Final, TemplateTypeList<Containers...>, TypeList<Types...>> { using type = typename append<Final<>, typename rewrap<TemplateTypeList<Containers>, Types...>::type...>::type; };\ + template<template <typename...> class Final, template <typename...> class List, typename...Ts>\ + struct convert<Final, List<Ts...>> { using type = typename append<Final<>,TypeList<Ts>...>::type; }; + +#define INTERNAL_CATCH_NTTP_1(signature, ...)\ + template<INTERNAL_CATCH_REMOVE_PARENS(signature)> struct Nttp{};\ + template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\ + constexpr auto get_wrapper() noexcept -> Nttp<__VA_ARGS__> { return {}; } \ + template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...> struct NttpTemplateTypeList{};\ + template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Cs>\ + constexpr auto get_wrapper() noexcept -> NttpTemplateTypeList<Cs...> { return {}; } \ + \ + template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature)>\ + struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>> { using type = TypeList<Container<__VA_ARGS__>>; };\ + template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature), typename...Elements>\ + struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>, Elements...> { using type = typename append<TypeList<Container<__VA_ARGS__>>, typename rewrap<NttpTemplateTypeList<Container>, Elements...>::type>::type; };\ + template<template <typename...> class Final, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Containers, typename...Types>\ + struct create<Final, NttpTemplateTypeList<Containers...>, TypeList<Types...>> { using type = typename append<Final<>, typename rewrap<NttpTemplateTypeList<Containers>, Types...>::type...>::type; }; + +#define INTERNAL_CATCH_DECLARE_SIG_TEST0(TestName) +#define INTERNAL_CATCH_DECLARE_SIG_TEST1(TestName, signature)\ + template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\ + static void TestName() +#define INTERNAL_CATCH_DECLARE_SIG_TEST_X(TestName, signature, ...)\ + template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\ + static void TestName() + +#define INTERNAL_CATCH_DEFINE_SIG_TEST0(TestName) +#define INTERNAL_CATCH_DEFINE_SIG_TEST1(TestName, signature)\ + template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\ + static void TestName() +#define INTERNAL_CATCH_DEFINE_SIG_TEST_X(TestName, signature,...)\ + template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\ + static void TestName() + +#define INTERNAL_CATCH_NTTP_REGISTER0(TestFunc, signature)\ + template<typename Type>\ + void reg_test(TypeList<Type>, Catch::NameAndTags nameAndTags)\ + {\ + Catch::AutoReg( Catch::makeTestInvoker(&TestFunc<Type>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags);\ + } + +#define INTERNAL_CATCH_NTTP_REGISTER(TestFunc, signature, ...)\ + template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\ + void reg_test(Nttp<__VA_ARGS__>, Catch::NameAndTags nameAndTags)\ + {\ + Catch::AutoReg( Catch::makeTestInvoker(&TestFunc<__VA_ARGS__>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags);\ + } + +#define INTERNAL_CATCH_NTTP_REGISTER_METHOD0(TestName, signature, ...)\ + template<typename Type>\ + void reg_test(TypeList<Type>, Catch::StringRef className, Catch::NameAndTags nameAndTags)\ + {\ + Catch::AutoReg( Catch::makeTestInvoker(&TestName<Type>::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags);\ + } + +#define INTERNAL_CATCH_NTTP_REGISTER_METHOD(TestName, signature, ...)\ + template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\ + void reg_test(Nttp<__VA_ARGS__>, Catch::StringRef className, Catch::NameAndTags nameAndTags)\ + {\ + Catch::AutoReg( Catch::makeTestInvoker(&TestName<__VA_ARGS__>::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags);\ + } + +#define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0(TestName, ClassName) +#define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1(TestName, ClassName, signature)\ + template<typename TestType> \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName)<TestType> { \ + void test();\ + } + +#define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X(TestName, ClassName, signature, ...)\ + template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName)<__VA_ARGS__> { \ + void test();\ + } + +#define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0(TestName) +#define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1(TestName, signature)\ + template<typename TestType> \ + void INTERNAL_CATCH_MAKE_NAMESPACE(TestName)::TestName<TestType>::test() +#define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X(TestName, signature, ...)\ + template<INTERNAL_CATCH_REMOVE_PARENS(signature)> \ + void INTERNAL_CATCH_MAKE_NAMESPACE(TestName)::TestName<__VA_ARGS__>::test() + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_NTTP_0 +#define INTERNAL_CATCH_NTTP_GEN(...) INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__),INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_0) +#define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0)(TestName, __VA_ARGS__) +#define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0)(TestName, ClassName, __VA_ARGS__) +#define INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD0, INTERNAL_CATCH_NTTP_REGISTER_METHOD0)(TestName, __VA_ARGS__) +#define INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER0, INTERNAL_CATCH_NTTP_REGISTER0)(TestFunc, __VA_ARGS__) +#define INTERNAL_CATCH_DEFINE_SIG_TEST(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST1, INTERNAL_CATCH_DEFINE_SIG_TEST0)(TestName, __VA_ARGS__) +#define INTERNAL_CATCH_DECLARE_SIG_TEST(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST1, INTERNAL_CATCH_DECLARE_SIG_TEST0)(TestName, __VA_ARGS__) +#define INTERNAL_CATCH_REMOVE_PARENS_GEN(...) INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_REMOVE_PARENS_11_ARG,INTERNAL_CATCH_REMOVE_PARENS_10_ARG,INTERNAL_CATCH_REMOVE_PARENS_9_ARG,INTERNAL_CATCH_REMOVE_PARENS_8_ARG,INTERNAL_CATCH_REMOVE_PARENS_7_ARG,INTERNAL_CATCH_REMOVE_PARENS_6_ARG,INTERNAL_CATCH_REMOVE_PARENS_5_ARG,INTERNAL_CATCH_REMOVE_PARENS_4_ARG,INTERNAL_CATCH_REMOVE_PARENS_3_ARG,INTERNAL_CATCH_REMOVE_PARENS_2_ARG,INTERNAL_CATCH_REMOVE_PARENS_1_ARG)(__VA_ARGS__) +#else +#define INTERNAL_CATCH_NTTP_0(signature) +#define INTERNAL_CATCH_NTTP_GEN(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1,INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_0)( __VA_ARGS__)) +#define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0)(TestName, __VA_ARGS__)) +#define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0)(TestName, ClassName, __VA_ARGS__)) +#define INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD0, INTERNAL_CATCH_NTTP_REGISTER_METHOD0)(TestName, __VA_ARGS__)) +#define INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER0, INTERNAL_CATCH_NTTP_REGISTER0)(TestFunc, __VA_ARGS__)) +#define INTERNAL_CATCH_DEFINE_SIG_TEST(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST1, INTERNAL_CATCH_DEFINE_SIG_TEST0)(TestName, __VA_ARGS__)) +#define INTERNAL_CATCH_DECLARE_SIG_TEST(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST1, INTERNAL_CATCH_DECLARE_SIG_TEST0)(TestName, __VA_ARGS__)) +#define INTERNAL_CATCH_REMOVE_PARENS_GEN(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_REMOVE_PARENS_11_ARG,INTERNAL_CATCH_REMOVE_PARENS_10_ARG,INTERNAL_CATCH_REMOVE_PARENS_9_ARG,INTERNAL_CATCH_REMOVE_PARENS_8_ARG,INTERNAL_CATCH_REMOVE_PARENS_7_ARG,INTERNAL_CATCH_REMOVE_PARENS_6_ARG,INTERNAL_CATCH_REMOVE_PARENS_5_ARG,INTERNAL_CATCH_REMOVE_PARENS_4_ARG,INTERNAL_CATCH_REMOVE_PARENS_3_ARG,INTERNAL_CATCH_REMOVE_PARENS_2_ARG,INTERNAL_CATCH_REMOVE_PARENS_1_ARG)(__VA_ARGS__)) +#endif + +// end catch_preprocessor.hpp +// start catch_meta.hpp + + +#include <type_traits> + +namespace Catch { + template<typename T> + struct always_false : std::false_type {}; + + template <typename> struct true_given : std::true_type {}; + struct is_callable_tester { + template <typename Fun, typename... Args> + true_given<decltype(std::declval<Fun>()(std::declval<Args>()...))> static test(int); + template <typename...> + std::false_type static test(...); + }; + + template <typename T> + struct is_callable; + + template <typename Fun, typename... Args> + struct is_callable<Fun(Args...)> : decltype(is_callable_tester::test<Fun, Args...>(0)) {}; + +#if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703 + // std::result_of is deprecated in C++17 and removed in C++20. Hence, it is + // replaced with std::invoke_result here. + template <typename Func, typename... U> + using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U...>>>; +#else + // Keep ::type here because we still support C++11 + template <typename Func, typename... U> + using FunctionReturnType = typename std::remove_reference<typename std::remove_cv<typename std::result_of<Func(U...)>::type>::type>::type; +#endif + +} // namespace Catch + +namespace mpl_{ + struct na; +} + +// end catch_meta.hpp +namespace Catch { + +template<typename C> +class TestInvokerAsMethod : public ITestInvoker { + void (C::*m_testAsMethod)(); +public: + TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {} + + void invoke() const override { + C obj; + (obj.*m_testAsMethod)(); + } +}; + +auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker*; + +template<typename C> +auto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInvoker* { + return new(std::nothrow) TestInvokerAsMethod<C>( testAsMethod ); +} + +struct NameAndTags { + NameAndTags( StringRef const& name_ = StringRef(), StringRef const& tags_ = StringRef() ) noexcept; + StringRef name; + StringRef tags; +}; + +struct AutoReg : NonCopyable { + AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept; + ~AutoReg(); +}; + +} // end namespace Catch + +#if defined(CATCH_CONFIG_DISABLE) + #define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \ + static void TestName() + #define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \ + namespace{ \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ + void test(); \ + }; \ + } \ + void TestName::test() + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( TestName, TestFunc, Name, Tags, Signature, ... ) \ + INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)) + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \ + namespace{ \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature));\ + } \ + } \ + INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) + + #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \ + INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename TestType, __VA_ARGS__ ) + #else + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename TestType, __VA_ARGS__ ) ) + #endif + + #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \ + INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__ ) + #else + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__ ) ) + #endif + + #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \ + INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) + #else + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) ) + #endif + + #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \ + INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) + #else + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) ) + #endif +#endif + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ + static void TestName(); \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + static void TestName() + #define INTERNAL_CATCH_TESTCASE( ... ) \ + INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ), __VA_ARGS__ ) + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ + void test(); \ + }; \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + void TestName::test() + #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ + INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ), ClassName, __VA_ARGS__ ) + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, Signature, ... )\ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + INTERNAL_CATCH_DECLARE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature));\ + namespace {\ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\ + INTERNAL_CATCH_TYPE_GEN\ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\ + INTERNAL_CATCH_NTTP_REG_GEN(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature))\ + template<typename...Types> \ + struct TestName{\ + TestName(){\ + int index = 0; \ + constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\ + using expander = int[];\ + (void)expander{(reg_test(Types{}, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++)... };/* NOLINT */ \ + }\ + };\ + static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ + TestName<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\ + return 0;\ + }();\ + }\ + }\ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature)) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \ + INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename TestType, __VA_ARGS__ ) +#else + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename TestType, __VA_ARGS__ ) ) +#endif + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \ + INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__ ) +#else + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__ ) ) +#endif + + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(TestName, TestFuncName, Name, Tags, Signature, TmplTypes, TypesList) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + template<typename TestType> static void TestFuncName(); \ + namespace {\ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + template<typename... Types> \ + struct TestName { \ + void reg_tests() { \ + int index = 0; \ + using expander = int[]; \ + constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\ + constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\ + constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++)... };/* NOLINT */\ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \ + using TestInit = typename create<TestName, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>()), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type; \ + TestInit t; \ + t.reg_tests(); \ + return 0; \ + }(); \ + } \ + } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + template<typename TestType> \ + static void TestFuncName() + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\ + INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename T,__VA_ARGS__) +#else + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, typename T, __VA_ARGS__ ) ) +#endif + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\ + INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__) +#else + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, Signature, __VA_ARGS__ ) ) +#endif + + #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2(TestName, TestFunc, Name, Tags, TmplList)\ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + template<typename TestType> static void TestFunc(); \ + namespace {\ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\ + INTERNAL_CATCH_TYPE_GEN\ + template<typename... Types> \ + struct TestName { \ + void reg_tests() { \ + int index = 0; \ + using expander = int[]; \ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */\ + } \ + };\ + static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \ + using TestInit = typename convert<TestName, TmplList>::type; \ + TestInit t; \ + t.reg_tests(); \ + return 0; \ + }(); \ + }}\ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + template<typename TestType> \ + static void TestFunc() + + #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(Name, Tags, TmplList) \ + INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), Name, Tags, TmplList ) + + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + namespace {\ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \ + INTERNAL_CATCH_TYPE_GEN\ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\ + INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature));\ + INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))\ + template<typename...Types> \ + struct TestNameClass{\ + TestNameClass(){\ + int index = 0; \ + constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\ + using expander = int[];\ + (void)expander{(reg_test(Types{}, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++)... };/* NOLINT */ \ + }\ + };\ + static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ + TestNameClass<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\ + return 0;\ + }();\ + }\ + }\ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \ + INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) +#else + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) ) +#endif + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \ + INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) +#else + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_C_L_A_S_S_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) ) +#endif + + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, Signature, TmplTypes, TypesList)\ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + template<typename TestType> \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \ + void test();\ + };\ + namespace {\ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestNameClass) {\ + INTERNAL_CATCH_TYPE_GEN \ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\ + template<typename...Types>\ + struct TestNameClass{\ + void reg_tests(){\ + int index = 0;\ + using expander = int[];\ + constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\ + constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\ + constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++)... };/* NOLINT */ \ + }\ + };\ + static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ + using TestInit = typename create<TestNameClass, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>()), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type;\ + TestInit t;\ + t.reg_tests();\ + return 0;\ + }(); \ + }\ + }\ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + template<typename TestType> \ + void TestName<TestType>::test() + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\ + INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), ClassName, Name, Tags, typename T, __VA_ARGS__ ) +#else + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), ClassName, Name, Tags, typename T,__VA_ARGS__ ) ) +#endif + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\ + INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), ClassName, Name, Tags, Signature, __VA_ARGS__ ) +#else + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), ClassName, Name, Tags, Signature,__VA_ARGS__ ) ) +#endif + + #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, TmplList) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + template<typename TestType> \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \ + void test();\ + };\ + namespace {\ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \ + INTERNAL_CATCH_TYPE_GEN\ + template<typename...Types>\ + struct TestNameClass{\ + void reg_tests(){\ + int index = 0;\ + using expander = int[];\ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */ \ + }\ + };\ + static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ + using TestInit = typename convert<TestNameClass, TmplList>::type;\ + TestInit t;\ + t.reg_tests();\ + return 0;\ + }(); \ + }}\ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + template<typename TestType> \ + void TestName<TestType>::test() + +#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(ClassName, Name, Tags, TmplList) \ + INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_ ), INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_ ), ClassName, Name, Tags, TmplList ) + +// end catch_test_registry.h +// start catch_capture.hpp + +// start catch_assertionhandler.h + +// start catch_assertioninfo.h + +// start catch_result_type.h + +namespace Catch { + + // ResultWas::OfType enum + struct ResultWas { enum OfType { + Unknown = -1, + Ok = 0, + Info = 1, + Warning = 2, + + FailureBit = 0x10, + + ExpressionFailed = FailureBit | 1, + ExplicitFailure = FailureBit | 2, + + Exception = 0x100 | FailureBit, + + ThrewException = Exception | 1, + DidntThrowException = Exception | 2, + + FatalErrorCondition = 0x200 | FailureBit + + }; }; + + bool isOk( ResultWas::OfType resultType ); + bool isJustInfo( int flags ); + + // ResultDisposition::Flags enum + struct ResultDisposition { enum Flags { + Normal = 0x01, + + ContinueOnFailure = 0x02, // Failures fail test, but execution continues + FalseTest = 0x04, // Prefix expression with ! + SuppressFail = 0x08 // Failures are reported but do not fail the test + }; }; + + ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ); + + bool shouldContinueOnFailure( int flags ); + inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } + bool shouldSuppressFailure( int flags ); + +} // end namespace Catch + +// end catch_result_type.h +namespace Catch { + + struct AssertionInfo + { + StringRef macroName; + SourceLineInfo lineInfo; + StringRef capturedExpression; + ResultDisposition::Flags resultDisposition; + + // We want to delete this constructor but a compiler bug in 4.8 means + // the struct is then treated as non-aggregate + //AssertionInfo() = delete; + }; + +} // end namespace Catch + +// end catch_assertioninfo.h +// start catch_decomposer.h + +// start catch_tostring.h + +#include <vector> +#include <cstddef> +#include <type_traits> +#include <string> +// start catch_stream.h + +#include <iosfwd> +#include <cstddef> +#include <ostream> + +namespace Catch { + + std::ostream& cout(); + std::ostream& cerr(); + std::ostream& clog(); + + class StringRef; + + struct IStream { + virtual ~IStream(); + virtual std::ostream& stream() const = 0; + }; + + auto makeStream( StringRef const &filename ) -> IStream const*; + + class ReusableStringStream : NonCopyable { + std::size_t m_index; + std::ostream* m_oss; + public: + ReusableStringStream(); + ~ReusableStringStream(); + + auto str() const -> std::string; + + template<typename T> + auto operator << ( T const& value ) -> ReusableStringStream& { + *m_oss << value; + return *this; + } + auto get() -> std::ostream& { return *m_oss; } + }; +} + +// end catch_stream.h +// start catch_interfaces_enum_values_registry.h + +#include <vector> + +namespace Catch { + + namespace Detail { + struct EnumInfo { + StringRef m_name; + std::vector<std::pair<int, StringRef>> m_values; + + ~EnumInfo(); + + StringRef lookup( int value ) const; + }; + } // namespace Detail + + struct IMutableEnumValuesRegistry { + virtual ~IMutableEnumValuesRegistry(); + + virtual Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values ) = 0; + + template<typename E> + Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::initializer_list<E> values ) { + static_assert(sizeof(int) >= sizeof(E), "Cannot serialize enum to int"); + std::vector<int> intValues; + intValues.reserve( values.size() ); + for( auto enumValue : values ) + intValues.push_back( static_cast<int>( enumValue ) ); + return registerEnum( enumName, allEnums, intValues ); + } + }; + +} // Catch + +// end catch_interfaces_enum_values_registry.h + +#ifdef CATCH_CONFIG_CPP17_STRING_VIEW +#include <string_view> +#endif + +#ifdef __OBJC__ +// start catch_objc_arc.hpp + +#import <Foundation/Foundation.h> + +#ifdef __has_feature +#define CATCH_ARC_ENABLED __has_feature(objc_arc) +#else +#define CATCH_ARC_ENABLED 0 +#endif + +void arcSafeRelease( NSObject* obj ); +id performOptionalSelector( id obj, SEL sel ); + +#if !CATCH_ARC_ENABLED +inline void arcSafeRelease( NSObject* obj ) { + [obj release]; +} +inline id performOptionalSelector( id obj, SEL sel ) { + if( [obj respondsToSelector: sel] ) + return [obj performSelector: sel]; + return nil; +} +#define CATCH_UNSAFE_UNRETAINED +#define CATCH_ARC_STRONG +#else +inline void arcSafeRelease( NSObject* ){} +inline id performOptionalSelector( id obj, SEL sel ) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" +#endif + if( [obj respondsToSelector: sel] ) + return [obj performSelector: sel]; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + return nil; +} +#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained +#define CATCH_ARC_STRONG __strong +#endif + +// end catch_objc_arc.hpp +#endif + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless +#endif + +namespace Catch { + namespace Detail { + + extern const std::string unprintableString; + + std::string rawMemoryToString( const void *object, std::size_t size ); + + template<typename T> + std::string rawMemoryToString( const T& object ) { + return rawMemoryToString( &object, sizeof(object) ); + } + + template<typename T> + class IsStreamInsertable { + template<typename Stream, typename U> + static auto test(int) + -> decltype(std::declval<Stream&>() << std::declval<U>(), std::true_type()); + + template<typename, typename> + static auto test(...)->std::false_type; + + public: + static const bool value = decltype(test<std::ostream, const T&>(0))::value; + }; + + template<typename E> + std::string convertUnknownEnumToString( E e ); + + template<typename T> + typename std::enable_if< + !std::is_enum<T>::value && !std::is_base_of<std::exception, T>::value, + std::string>::type convertUnstreamable( T const& ) { + return Detail::unprintableString; + } + template<typename T> + typename std::enable_if< + !std::is_enum<T>::value && std::is_base_of<std::exception, T>::value, + std::string>::type convertUnstreamable(T const& ex) { + return ex.what(); + } + + template<typename T> + typename std::enable_if< + std::is_enum<T>::value + , std::string>::type convertUnstreamable( T const& value ) { + return convertUnknownEnumToString( value ); + } + +#if defined(_MANAGED) + //! Convert a CLR string to a utf8 std::string + template<typename T> + std::string clrReferenceToString( T^ ref ) { + if (ref == nullptr) + return std::string("null"); + auto bytes = System::Text::Encoding::UTF8->GetBytes(ref->ToString()); + cli::pin_ptr<System::Byte> p = &bytes[0]; + return std::string(reinterpret_cast<char const *>(p), bytes->Length); + } +#endif + + } // namespace Detail + + // If we decide for C++14, change these to enable_if_ts + template <typename T, typename = void> + struct StringMaker { + template <typename Fake = T> + static + typename std::enable_if<::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>::type + convert(const Fake& value) { + ReusableStringStream rss; + // NB: call using the function-like syntax to avoid ambiguity with + // user-defined templated operator<< under clang. + rss.operator<<(value); + return rss.str(); + } + + template <typename Fake = T> + static + typename std::enable_if<!::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>::type + convert( const Fake& value ) { +#if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER) + return Detail::convertUnstreamable(value); +#else + return CATCH_CONFIG_FALLBACK_STRINGIFIER(value); +#endif + } + }; + + namespace Detail { + + // This function dispatches all stringification requests inside of Catch. + // Should be preferably called fully qualified, like ::Catch::Detail::stringify + template <typename T> + std::string stringify(const T& e) { + return ::Catch::StringMaker<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::convert(e); + } + + template<typename E> + std::string convertUnknownEnumToString( E e ) { + return ::Catch::Detail::stringify(static_cast<typename std::underlying_type<E>::type>(e)); + } + +#if defined(_MANAGED) + template <typename T> + std::string stringify( T^ e ) { + return ::Catch::StringMaker<T^>::convert(e); + } +#endif + + } // namespace Detail + + // Some predefined specializations + + template<> + struct StringMaker<std::string> { + static std::string convert(const std::string& str); + }; + +#ifdef CATCH_CONFIG_CPP17_STRING_VIEW + template<> + struct StringMaker<std::string_view> { + static std::string convert(std::string_view str); + }; +#endif + + template<> + struct StringMaker<char const *> { + static std::string convert(char const * str); + }; + template<> + struct StringMaker<char *> { + static std::string convert(char * str); + }; + +#ifdef CATCH_CONFIG_WCHAR + template<> + struct StringMaker<std::wstring> { + static std::string convert(const std::wstring& wstr); + }; + +# ifdef CATCH_CONFIG_CPP17_STRING_VIEW + template<> + struct StringMaker<std::wstring_view> { + static std::string convert(std::wstring_view str); + }; +# endif + + template<> + struct StringMaker<wchar_t const *> { + static std::string convert(wchar_t const * str); + }; + template<> + struct StringMaker<wchar_t *> { + static std::string convert(wchar_t * str); + }; +#endif + + // TBD: Should we use `strnlen` to ensure that we don't go out of the buffer, + // while keeping string semantics? + template<int SZ> + struct StringMaker<char[SZ]> { + static std::string convert(char const* str) { + return ::Catch::Detail::stringify(std::string{ str }); + } + }; + template<int SZ> + struct StringMaker<signed char[SZ]> { + static std::string convert(signed char const* str) { + return ::Catch::Detail::stringify(std::string{ reinterpret_cast<char const *>(str) }); + } + }; + template<int SZ> + struct StringMaker<unsigned char[SZ]> { + static std::string convert(unsigned char const* str) { + return ::Catch::Detail::stringify(std::string{ reinterpret_cast<char const *>(str) }); + } + }; + +#if defined(CATCH_CONFIG_CPP17_BYTE) + template<> + struct StringMaker<std::byte> { + static std::string convert(std::byte value); + }; +#endif // defined(CATCH_CONFIG_CPP17_BYTE) + template<> + struct StringMaker<int> { + static std::string convert(int value); + }; + template<> + struct StringMaker<long> { + static std::string convert(long value); + }; + template<> + struct StringMaker<long long> { + static std::string convert(long long value); + }; + template<> + struct StringMaker<unsigned int> { + static std::string convert(unsigned int value); + }; + template<> + struct StringMaker<unsigned long> { + static std::string convert(unsigned long value); + }; + template<> + struct StringMaker<unsigned long long> { + static std::string convert(unsigned long long value); + }; + + template<> + struct StringMaker<bool> { + static std::string convert(bool b); + }; + + template<> + struct StringMaker<char> { + static std::string convert(char c); + }; + template<> + struct StringMaker<signed char> { + static std::string convert(signed char c); + }; + template<> + struct StringMaker<unsigned char> { + static std::string convert(unsigned char c); + }; + + template<> + struct StringMaker<std::nullptr_t> { + static std::string convert(std::nullptr_t); + }; + + template<> + struct StringMaker<float> { + static std::string convert(float value); + static int precision; + }; + + template<> + struct StringMaker<double> { + static std::string convert(double value); + static int precision; + }; + + template <typename T> + struct StringMaker<T*> { + template <typename U> + static std::string convert(U* p) { + if (p) { + return ::Catch::Detail::rawMemoryToString(p); + } else { + return "nullptr"; + } + } + }; + + template <typename R, typename C> + struct StringMaker<R C::*> { + static std::string convert(R C::* p) { + if (p) { + return ::Catch::Detail::rawMemoryToString(p); + } else { + return "nullptr"; + } + } + }; + +#if defined(_MANAGED) + template <typename T> + struct StringMaker<T^> { + static std::string convert( T^ ref ) { + return ::Catch::Detail::clrReferenceToString(ref); + } + }; +#endif + + namespace Detail { + template<typename InputIterator, typename Sentinel = InputIterator> + std::string rangeToString(InputIterator first, Sentinel last) { + ReusableStringStream rss; + rss << "{ "; + if (first != last) { + rss << ::Catch::Detail::stringify(*first); + for (++first; first != last; ++first) + rss << ", " << ::Catch::Detail::stringify(*first); + } + rss << " }"; + return rss.str(); + } + } + +#ifdef __OBJC__ + template<> + struct StringMaker<NSString*> { + static std::string convert(NSString * nsstring) { + if (!nsstring) + return "nil"; + return std::string("@") + [nsstring UTF8String]; + } + }; + template<> + struct StringMaker<NSObject*> { + static std::string convert(NSObject* nsObject) { + return ::Catch::Detail::stringify([nsObject description]); + } + + }; + namespace Detail { + inline std::string stringify( NSString* nsstring ) { + return StringMaker<NSString*>::convert( nsstring ); + } + + } // namespace Detail +#endif // __OBJC__ + +} // namespace Catch + +////////////////////////////////////////////////////// +// Separate std-lib types stringification, so it can be selectively enabled +// This means that we do not bring in + +#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS) +# define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER +# define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER +# define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER +# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +# define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER +#endif + +// Separate std::pair specialization +#if defined(CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER) +#include <utility> +namespace Catch { + template<typename T1, typename T2> + struct StringMaker<std::pair<T1, T2> > { + static std::string convert(const std::pair<T1, T2>& pair) { + ReusableStringStream rss; + rss << "{ " + << ::Catch::Detail::stringify(pair.first) + << ", " + << ::Catch::Detail::stringify(pair.second) + << " }"; + return rss.str(); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER + +#if defined(CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_OPTIONAL) +#include <optional> +namespace Catch { + template<typename T> + struct StringMaker<std::optional<T> > { + static std::string convert(const std::optional<T>& optional) { + ReusableStringStream rss; + if (optional.has_value()) { + rss << ::Catch::Detail::stringify(*optional); + } else { + rss << "{ }"; + } + return rss.str(); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER + +// Separate std::tuple specialization +#if defined(CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER) +#include <tuple> +namespace Catch { + namespace Detail { + template< + typename Tuple, + std::size_t N = 0, + bool = (N < std::tuple_size<Tuple>::value) + > + struct TupleElementPrinter { + static void print(const Tuple& tuple, std::ostream& os) { + os << (N ? ", " : " ") + << ::Catch::Detail::stringify(std::get<N>(tuple)); + TupleElementPrinter<Tuple, N + 1>::print(tuple, os); + } + }; + + template< + typename Tuple, + std::size_t N + > + struct TupleElementPrinter<Tuple, N, false> { + static void print(const Tuple&, std::ostream&) {} + }; + + } + + template<typename ...Types> + struct StringMaker<std::tuple<Types...>> { + static std::string convert(const std::tuple<Types...>& tuple) { + ReusableStringStream rss; + rss << '{'; + Detail::TupleElementPrinter<std::tuple<Types...>>::print(tuple, rss.get()); + rss << " }"; + return rss.str(); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER + +#if defined(CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_VARIANT) +#include <variant> +namespace Catch { + template<> + struct StringMaker<std::monostate> { + static std::string convert(const std::monostate&) { + return "{ }"; + } + }; + + template<typename... Elements> + struct StringMaker<std::variant<Elements...>> { + static std::string convert(const std::variant<Elements...>& variant) { + if (variant.valueless_by_exception()) { + return "{valueless variant}"; + } else { + return std::visit( + [](const auto& value) { + return ::Catch::Detail::stringify(value); + }, + variant + ); + } + } + }; +} +#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER + +namespace Catch { + // Import begin/ end from std here + using std::begin; + using std::end; + + namespace detail { + template <typename...> + struct void_type { + using type = void; + }; + + template <typename T, typename = void> + struct is_range_impl : std::false_type { + }; + + template <typename T> + struct is_range_impl<T, typename void_type<decltype(begin(std::declval<T>()))>::type> : std::true_type { + }; + } // namespace detail + + template <typename T> + struct is_range : detail::is_range_impl<T> { + }; + +#if defined(_MANAGED) // Managed types are never ranges + template <typename T> + struct is_range<T^> { + static const bool value = false; + }; +#endif + + template<typename Range> + std::string rangeToString( Range const& range ) { + return ::Catch::Detail::rangeToString( begin( range ), end( range ) ); + } + + // Handle vector<bool> specially + template<typename Allocator> + std::string rangeToString( std::vector<bool, Allocator> const& v ) { + ReusableStringStream rss; + rss << "{ "; + bool first = true; + for( bool b : v ) { + if( first ) + first = false; + else + rss << ", "; + rss << ::Catch::Detail::stringify( b ); + } + rss << " }"; + return rss.str(); + } + + template<typename R> + struct StringMaker<R, typename std::enable_if<is_range<R>::value && !::Catch::Detail::IsStreamInsertable<R>::value>::type> { + static std::string convert( R const& range ) { + return rangeToString( range ); + } + }; + + template <typename T, int SZ> + struct StringMaker<T[SZ]> { + static std::string convert(T const(&arr)[SZ]) { + return rangeToString(arr); + } + }; + +} // namespace Catch + +// Separate std::chrono::duration specialization +#if defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +#include <ctime> +#include <ratio> +#include <chrono> + +namespace Catch { + +template <class Ratio> +struct ratio_string { + static std::string symbol(); +}; + +template <class Ratio> +std::string ratio_string<Ratio>::symbol() { + Catch::ReusableStringStream rss; + rss << '[' << Ratio::num << '/' + << Ratio::den << ']'; + return rss.str(); +} +template <> +struct ratio_string<std::atto> { + static std::string symbol(); +}; +template <> +struct ratio_string<std::femto> { + static std::string symbol(); +}; +template <> +struct ratio_string<std::pico> { + static std::string symbol(); +}; +template <> +struct ratio_string<std::nano> { + static std::string symbol(); +}; +template <> +struct ratio_string<std::micro> { + static std::string symbol(); +}; +template <> +struct ratio_string<std::milli> { + static std::string symbol(); +}; + + //////////// + // std::chrono::duration specializations + template<typename Value, typename Ratio> + struct StringMaker<std::chrono::duration<Value, Ratio>> { + static std::string convert(std::chrono::duration<Value, Ratio> const& duration) { + ReusableStringStream rss; + rss << duration.count() << ' ' << ratio_string<Ratio>::symbol() << 's'; + return rss.str(); + } + }; + template<typename Value> + struct StringMaker<std::chrono::duration<Value, std::ratio<1>>> { + static std::string convert(std::chrono::duration<Value, std::ratio<1>> const& duration) { + ReusableStringStream rss; + rss << duration.count() << " s"; + return rss.str(); + } + }; + template<typename Value> + struct StringMaker<std::chrono::duration<Value, std::ratio<60>>> { + static std::string convert(std::chrono::duration<Value, std::ratio<60>> const& duration) { + ReusableStringStream rss; + rss << duration.count() << " m"; + return rss.str(); + } + }; + template<typename Value> + struct StringMaker<std::chrono::duration<Value, std::ratio<3600>>> { + static std::string convert(std::chrono::duration<Value, std::ratio<3600>> const& duration) { + ReusableStringStream rss; + rss << duration.count() << " h"; + return rss.str(); + } + }; + + //////////// + // std::chrono::time_point specialization + // Generic time_point cannot be specialized, only std::chrono::time_point<system_clock> + template<typename Clock, typename Duration> + struct StringMaker<std::chrono::time_point<Clock, Duration>> { + static std::string convert(std::chrono::time_point<Clock, Duration> const& time_point) { + return ::Catch::Detail::stringify(time_point.time_since_epoch()) + " since epoch"; + } + }; + // std::chrono::time_point<system_clock> specialization + template<typename Duration> + struct StringMaker<std::chrono::time_point<std::chrono::system_clock, Duration>> { + static std::string convert(std::chrono::time_point<std::chrono::system_clock, Duration> const& time_point) { + auto converted = std::chrono::system_clock::to_time_t(time_point); + +#ifdef _MSC_VER + std::tm timeInfo = {}; + gmtime_s(&timeInfo, &converted); +#else + std::tm* timeInfo = std::gmtime(&converted); +#endif + + auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); + char timeStamp[timeStampSize]; + const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; + +#ifdef _MSC_VER + std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); +#else + std::strftime(timeStamp, timeStampSize, fmt, timeInfo); +#endif + return std::string(timeStamp); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER + +#define INTERNAL_CATCH_REGISTER_ENUM( enumName, ... ) \ +namespace Catch { \ + template<> struct StringMaker<enumName> { \ + static std::string convert( enumName value ) { \ + static const auto& enumInfo = ::Catch::getMutableRegistryHub().getMutableEnumValuesRegistry().registerEnum( #enumName, #__VA_ARGS__, { __VA_ARGS__ } ); \ + return static_cast<std::string>(enumInfo.lookup( static_cast<int>( value ) )); \ + } \ + }; \ +} + +#define CATCH_REGISTER_ENUM( enumName, ... ) INTERNAL_CATCH_REGISTER_ENUM( enumName, __VA_ARGS__ ) + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +// end catch_tostring.h +#include <iosfwd> + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4389) // '==' : signed/unsigned mismatch +#pragma warning(disable:4018) // more "signed/unsigned mismatch" +#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) +#pragma warning(disable:4180) // qualifier applied to function type has no meaning +#pragma warning(disable:4800) // Forcing result to true or false +#endif + +namespace Catch { + + struct ITransientExpression { + auto isBinaryExpression() const -> bool { return m_isBinaryExpression; } + auto getResult() const -> bool { return m_result; } + virtual void streamReconstructedExpression( std::ostream &os ) const = 0; + + ITransientExpression( bool isBinaryExpression, bool result ) + : m_isBinaryExpression( isBinaryExpression ), + m_result( result ) + {} + + // We don't actually need a virtual destructor, but many static analysers + // complain if it's not here :-( + virtual ~ITransientExpression(); + + bool m_isBinaryExpression; + bool m_result; + + }; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ); + + template<typename LhsT, typename RhsT> + class BinaryExpr : public ITransientExpression { + LhsT m_lhs; + StringRef m_op; + RhsT m_rhs; + + void streamReconstructedExpression( std::ostream &os ) const override { + formatReconstructedExpression + ( os, Catch::Detail::stringify( m_lhs ), m_op, Catch::Detail::stringify( m_rhs ) ); + } + + public: + BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) + : ITransientExpression{ true, comparisonResult }, + m_lhs( lhs ), + m_op( op ), + m_rhs( rhs ) + {} + + template<typename T> + auto operator && ( T ) const -> BinaryExpr<LhsT, RhsT const&> const { + static_assert(always_false<T>::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template<typename T> + auto operator || ( T ) const -> BinaryExpr<LhsT, RhsT const&> const { + static_assert(always_false<T>::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template<typename T> + auto operator == ( T ) const -> BinaryExpr<LhsT, RhsT const&> const { + static_assert(always_false<T>::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template<typename T> + auto operator != ( T ) const -> BinaryExpr<LhsT, RhsT const&> const { + static_assert(always_false<T>::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template<typename T> + auto operator > ( T ) const -> BinaryExpr<LhsT, RhsT const&> const { + static_assert(always_false<T>::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template<typename T> + auto operator < ( T ) const -> BinaryExpr<LhsT, RhsT const&> const { + static_assert(always_false<T>::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template<typename T> + auto operator >= ( T ) const -> BinaryExpr<LhsT, RhsT const&> const { + static_assert(always_false<T>::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template<typename T> + auto operator <= ( T ) const -> BinaryExpr<LhsT, RhsT const&> const { + static_assert(always_false<T>::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + }; + + template<typename LhsT> + class UnaryExpr : public ITransientExpression { + LhsT m_lhs; + + void streamReconstructedExpression( std::ostream &os ) const override { + os << Catch::Detail::stringify( m_lhs ); + } + + public: + explicit UnaryExpr( LhsT lhs ) + : ITransientExpression{ false, static_cast<bool>(lhs) }, + m_lhs( lhs ) + {} + }; + + // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int) + template<typename LhsT, typename RhsT> + auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast<bool>(lhs == rhs); } + template<typename T> + auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); } + template<typename T> + auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); } + template<typename T> + auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; } + template<typename T> + auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; } + + template<typename LhsT, typename RhsT> + auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast<bool>(lhs != rhs); } + template<typename T> + auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); } + template<typename T> + auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); } + template<typename T> + auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; } + template<typename T> + auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; } + + template<typename LhsT> + class ExprLhs { + LhsT m_lhs; + public: + explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} + + template<typename RhsT> + auto operator == ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const { + return { compareEqual( m_lhs, rhs ), m_lhs, "==", rhs }; + } + auto operator == ( bool rhs ) -> BinaryExpr<LhsT, bool> const { + return { m_lhs == rhs, m_lhs, "==", rhs }; + } + + template<typename RhsT> + auto operator != ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const { + return { compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs }; + } + auto operator != ( bool rhs ) -> BinaryExpr<LhsT, bool> const { + return { m_lhs != rhs, m_lhs, "!=", rhs }; + } + + template<typename RhsT> + auto operator > ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const { + return { static_cast<bool>(m_lhs > rhs), m_lhs, ">", rhs }; + } + template<typename RhsT> + auto operator < ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const { + return { static_cast<bool>(m_lhs < rhs), m_lhs, "<", rhs }; + } + template<typename RhsT> + auto operator >= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const { + return { static_cast<bool>(m_lhs >= rhs), m_lhs, ">=", rhs }; + } + template<typename RhsT> + auto operator <= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const { + return { static_cast<bool>(m_lhs <= rhs), m_lhs, "<=", rhs }; + } + template <typename RhsT> + auto operator | (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const { + return { static_cast<bool>(m_lhs | rhs), m_lhs, "|", rhs }; + } + template <typename RhsT> + auto operator & (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const { + return { static_cast<bool>(m_lhs & rhs), m_lhs, "&", rhs }; + } + template <typename RhsT> + auto operator ^ (RhsT const& rhs) -> BinaryExpr<LhsT, RhsT const&> const { + return { static_cast<bool>(m_lhs ^ rhs), m_lhs, "^", rhs }; + } + + template<typename RhsT> + auto operator && ( RhsT const& ) -> BinaryExpr<LhsT, RhsT const&> const { + static_assert(always_false<RhsT>::value, + "operator&& is not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template<typename RhsT> + auto operator || ( RhsT const& ) -> BinaryExpr<LhsT, RhsT const&> const { + static_assert(always_false<RhsT>::value, + "operator|| is not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + auto makeUnaryExpr() const -> UnaryExpr<LhsT> { + return UnaryExpr<LhsT>{ m_lhs }; + } + }; + + void handleExpression( ITransientExpression const& expr ); + + template<typename T> + void handleExpression( ExprLhs<T> const& expr ) { + handleExpression( expr.makeUnaryExpr() ); + } + + struct Decomposer { + template<typename T> + auto operator <= ( T const& lhs ) -> ExprLhs<T const&> { + return ExprLhs<T const&>{ lhs }; + } + + auto operator <=( bool value ) -> ExprLhs<bool> { + return ExprLhs<bool>{ value }; + } + }; + +} // end namespace Catch + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +// end catch_decomposer.h +// start catch_interfaces_capture.h + +#include <string> +#include <chrono> + +namespace Catch { + + class AssertionResult; + struct AssertionInfo; + struct SectionInfo; + struct SectionEndInfo; + struct MessageInfo; + struct MessageBuilder; + struct Counts; + struct AssertionReaction; + struct SourceLineInfo; + + struct ITransientExpression; + struct IGeneratorTracker; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + struct BenchmarkInfo; + template <typename Duration = std::chrono::duration<double, std::nano>> + struct BenchmarkStats; +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + struct IResultCapture { + + virtual ~IResultCapture(); + + virtual bool sectionStarted( SectionInfo const& sectionInfo, + Counts& assertions ) = 0; + virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; + virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; + + virtual auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + virtual void benchmarkPreparing( std::string const& name ) = 0; + virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0; + virtual void benchmarkEnded( BenchmarkStats<> const& stats ) = 0; + virtual void benchmarkFailed( std::string const& error ) = 0; +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + virtual void pushScopedMessage( MessageInfo const& message ) = 0; + virtual void popScopedMessage( MessageInfo const& message ) = 0; + + virtual void emplaceUnscopedMessage( MessageBuilder const& builder ) = 0; + + virtual void handleFatalErrorCondition( StringRef message ) = 0; + + virtual void handleExpr + ( AssertionInfo const& info, + ITransientExpression const& expr, + AssertionReaction& reaction ) = 0; + virtual void handleMessage + ( AssertionInfo const& info, + ResultWas::OfType resultType, + StringRef const& message, + AssertionReaction& reaction ) = 0; + virtual void handleUnexpectedExceptionNotThrown + ( AssertionInfo const& info, + AssertionReaction& reaction ) = 0; + virtual void handleUnexpectedInflightException + ( AssertionInfo const& info, + std::string const& message, + AssertionReaction& reaction ) = 0; + virtual void handleIncomplete + ( AssertionInfo const& info ) = 0; + virtual void handleNonExpr + ( AssertionInfo const &info, + ResultWas::OfType resultType, + AssertionReaction &reaction ) = 0; + + virtual bool lastAssertionPassed() = 0; + virtual void assertionPassed() = 0; + + // Deprecated, do not use: + virtual std::string getCurrentTestName() const = 0; + virtual const AssertionResult* getLastResult() const = 0; + virtual void exceptionEarlyReported() = 0; + }; + + IResultCapture& getResultCapture(); +} + +// end catch_interfaces_capture.h +namespace Catch { + + struct TestFailureException{}; + struct AssertionResultData; + struct IResultCapture; + class RunContext; + + class LazyExpression { + friend class AssertionHandler; + friend struct AssertionStats; + friend class RunContext; + + ITransientExpression const* m_transientExpression = nullptr; + bool m_isNegated; + public: + LazyExpression( bool isNegated ); + LazyExpression( LazyExpression const& other ); + LazyExpression& operator = ( LazyExpression const& ) = delete; + + explicit operator bool() const; + + friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; + }; + + struct AssertionReaction { + bool shouldDebugBreak = false; + bool shouldThrow = false; + }; + + class AssertionHandler { + AssertionInfo m_assertionInfo; + AssertionReaction m_reaction; + bool m_completed = false; + IResultCapture& m_resultCapture; + + public: + AssertionHandler + ( StringRef const& macroName, + SourceLineInfo const& lineInfo, + StringRef capturedExpression, + ResultDisposition::Flags resultDisposition ); + ~AssertionHandler() { + if ( !m_completed ) { + m_resultCapture.handleIncomplete( m_assertionInfo ); + } + } + + template<typename T> + void handleExpr( ExprLhs<T> const& expr ) { + handleExpr( expr.makeUnaryExpr() ); + } + void handleExpr( ITransientExpression const& expr ); + + void handleMessage(ResultWas::OfType resultType, StringRef const& message); + + void handleExceptionThrownAsExpected(); + void handleUnexpectedExceptionNotThrown(); + void handleExceptionNotThrownAsExpected(); + void handleThrowingCallSkipped(); + void handleUnexpectedInflightException(); + + void complete(); + void setCompleted(); + + // query + auto allowThrows() const -> bool; + }; + + void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString ); + +} // namespace Catch + +// end catch_assertionhandler.h +// start catch_message.h + +#include <string> +#include <vector> + +namespace Catch { + + struct MessageInfo { + MessageInfo( StringRef const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ); + + StringRef macroName; + std::string message; + SourceLineInfo lineInfo; + ResultWas::OfType type; + unsigned int sequence; + + bool operator == ( MessageInfo const& other ) const; + bool operator < ( MessageInfo const& other ) const; + private: + static unsigned int globalCount; + }; + + struct MessageStream { + + template<typename T> + MessageStream& operator << ( T const& value ) { + m_stream << value; + return *this; + } + + ReusableStringStream m_stream; + }; + + struct MessageBuilder : MessageStream { + MessageBuilder( StringRef const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ); + + template<typename T> + MessageBuilder& operator << ( T const& value ) { + m_stream << value; + return *this; + } + + MessageInfo m_info; + }; + + class ScopedMessage { + public: + explicit ScopedMessage( MessageBuilder const& builder ); + ScopedMessage( ScopedMessage& duplicate ) = delete; + ScopedMessage( ScopedMessage&& old ); + ~ScopedMessage(); + + MessageInfo m_info; + bool m_moved; + }; + + class Capturer { + std::vector<MessageInfo> m_messages; + IResultCapture& m_resultCapture = getResultCapture(); + size_t m_captured = 0; + public: + Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ); + ~Capturer(); + + void captureValue( size_t index, std::string const& value ); + + template<typename T> + void captureValues( size_t index, T const& value ) { + captureValue( index, Catch::Detail::stringify( value ) ); + } + + template<typename T, typename... Ts> + void captureValues( size_t index, T const& value, Ts const&... values ) { + captureValue( index, Catch::Detail::stringify(value) ); + captureValues( index+1, values... ); + } + }; + +} // end namespace Catch + +// end catch_message.h +#if !defined(CATCH_CONFIG_DISABLE) + +#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) + #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__ +#else + #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION" +#endif + +#if defined(CATCH_CONFIG_FAST_COMPILE) || defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + +/////////////////////////////////////////////////////////////////////////////// +// Another way to speed-up compilation is to omit local try-catch for REQUIRE* +// macros. +#define INTERNAL_CATCH_TRY +#define INTERNAL_CATCH_CATCH( capturer ) + +#else // CATCH_CONFIG_FAST_COMPILE + +#define INTERNAL_CATCH_TRY try +#define INTERNAL_CATCH_CATCH( handler ) catch(...) { handler.handleUnexpectedInflightException(); } + +#endif + +#define INTERNAL_CATCH_REACT( handler ) handler.complete(); + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \ + do { \ + CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + INTERNAL_CATCH_TRY { \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( (void)0, (false) && static_cast<bool>( !!(__VA_ARGS__) ) ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \ + INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ + if( Catch::getResultCapture().lastAssertionPassed() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, ... ) \ + INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ + if( !Catch::getResultCapture().lastAssertionPassed() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + try { \ + static_cast<void>(__VA_ARGS__); \ + catchAssertionHandler.handleExceptionNotThrownAsExpected(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast<void>(__VA_ARGS__); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleExceptionThrownAsExpected(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast<void>(expr); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( exceptionType const& ) { \ + catchAssertionHandler.handleExceptionThrownAsExpected(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition ); \ + catchAssertionHandler.handleMessage( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_CAPTURE( varName, macroName, ... ) \ + auto varName = Catch::Capturer( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info, #__VA_ARGS__ ); \ + varName.captureValues( 0, __VA_ARGS__ ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_INFO( macroName, log ) \ + Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ); + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_UNSCOPED_INFO( macroName, log ) \ + Catch::getResultCapture().emplaceUnscopedMessage( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) + +/////////////////////////////////////////////////////////////////////////////// +// Although this is matcher-based, it can be used with just a string +#define INTERNAL_CATCH_THROWS_STR_MATCHES( macroName, resultDisposition, matcher, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast<void>(__VA_ARGS__); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( ... ) { \ + Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher##_catch_sr ); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +#endif // CATCH_CONFIG_DISABLE + +// end catch_capture.hpp +// start catch_section.h + +// start catch_section_info.h + +// start catch_totals.h + +#include <cstddef> + +namespace Catch { + + struct Counts { + Counts operator - ( Counts const& other ) const; + Counts& operator += ( Counts const& other ); + + std::size_t total() const; + bool allPassed() const; + bool allOk() const; + + std::size_t passed = 0; + std::size_t failed = 0; + std::size_t failedButOk = 0; + }; + + struct Totals { + + Totals operator - ( Totals const& other ) const; + Totals& operator += ( Totals const& other ); + + Totals delta( Totals const& prevTotals ) const; + + int error = 0; + Counts assertions; + Counts testCases; + }; +} + +// end catch_totals.h +#include <string> + +namespace Catch { + + struct SectionInfo { + SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name ); + + // Deprecated + SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name, + std::string const& ) : SectionInfo( _lineInfo, _name ) {} + + std::string name; + std::string description; // !Deprecated: this will always be empty + SourceLineInfo lineInfo; + }; + + struct SectionEndInfo { + SectionInfo sectionInfo; + Counts prevAssertions; + double durationInSeconds; + }; + +} // end namespace Catch + +// end catch_section_info.h +// start catch_timer.h + +#include <cstdint> + +namespace Catch { + + auto getCurrentNanosecondsSinceEpoch() -> uint64_t; + auto getEstimatedClockResolution() -> uint64_t; + + class Timer { + uint64_t m_nanoseconds = 0; + public: + void start(); + auto getElapsedNanoseconds() const -> uint64_t; + auto getElapsedMicroseconds() const -> uint64_t; + auto getElapsedMilliseconds() const -> unsigned int; + auto getElapsedSeconds() const -> double; + }; + +} // namespace Catch + +// end catch_timer.h +#include <string> + +namespace Catch { + + class Section : NonCopyable { + public: + Section( SectionInfo const& info ); + ~Section(); + + // This indicates whether the section should be executed or not + explicit operator bool() const; + + private: + SectionInfo m_info; + + std::string m_name; + Counts m_assertions; + bool m_sectionIncluded; + Timer m_timer; + }; + +} // end namespace Catch + +#define INTERNAL_CATCH_SECTION( ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +#define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +// end catch_section.h +// start catch_interfaces_exception.h + +// start catch_interfaces_registry_hub.h + +#include <string> +#include <memory> + +namespace Catch { + + class TestCase; + struct ITestCaseRegistry; + struct IExceptionTranslatorRegistry; + struct IExceptionTranslator; + struct IReporterRegistry; + struct IReporterFactory; + struct ITagAliasRegistry; + struct IMutableEnumValuesRegistry; + + class StartupExceptionRegistry; + + using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>; + + struct IRegistryHub { + virtual ~IRegistryHub(); + + virtual IReporterRegistry const& getReporterRegistry() const = 0; + virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; + virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; + virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0; + + virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; + }; + + struct IMutableRegistryHub { + virtual ~IMutableRegistryHub(); + virtual void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) = 0; + virtual void registerListener( IReporterFactoryPtr const& factory ) = 0; + virtual void registerTest( TestCase const& testInfo ) = 0; + virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; + virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; + virtual void registerStartupException() noexcept = 0; + virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0; + }; + + IRegistryHub const& getRegistryHub(); + IMutableRegistryHub& getMutableRegistryHub(); + void cleanUp(); + std::string translateActiveException(); + +} + +// end catch_interfaces_registry_hub.h +#if defined(CATCH_CONFIG_DISABLE) + #define INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( translatorName, signature) \ + static std::string translatorName( signature ) +#endif + +#include <exception> +#include <string> +#include <vector> + +namespace Catch { + using exceptionTranslateFunction = std::string(*)(); + + struct IExceptionTranslator; + using ExceptionTranslators = std::vector<std::unique_ptr<IExceptionTranslator const>>; + + struct IExceptionTranslator { + virtual ~IExceptionTranslator(); + virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; + }; + + struct IExceptionTranslatorRegistry { + virtual ~IExceptionTranslatorRegistry(); + + virtual std::string translateActiveException() const = 0; + }; + + class ExceptionTranslatorRegistrar { + template<typename T> + class ExceptionTranslator : public IExceptionTranslator { + public: + + ExceptionTranslator( std::string(*translateFunction)( T& ) ) + : m_translateFunction( translateFunction ) + {} + + std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override { +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + return ""; +#else + try { + if( it == itEnd ) + std::rethrow_exception(std::current_exception()); + else + return (*it)->translate( it+1, itEnd ); + } + catch( T& ex ) { + return m_translateFunction( ex ); + } +#endif + } + + protected: + std::string(*m_translateFunction)( T& ); + }; + + public: + template<typename T> + ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) { + getMutableRegistryHub().registerTranslator + ( new ExceptionTranslator<T>( translateFunction ) ); + } + }; +} + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \ + static std::string translatorName( signature ); \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + static std::string translatorName( signature ) + +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) + +// end catch_interfaces_exception.h +// start catch_approx.h + +#include <type_traits> + +namespace Catch { +namespace Detail { + + class Approx { + private: + bool equalityComparisonImpl(double other) const; + // Validates the new margin (margin >= 0) + // out-of-line to avoid including stdexcept in the header + void setMargin(double margin); + // Validates the new epsilon (0 < epsilon < 1) + // out-of-line to avoid including stdexcept in the header + void setEpsilon(double epsilon); + + public: + explicit Approx ( double value ); + + static Approx custom(); + + Approx operator-() const; + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + Approx operator()( T const& value ) const { + Approx approx( static_cast<double>(value) ); + approx.m_epsilon = m_epsilon; + approx.m_margin = m_margin; + approx.m_scale = m_scale; + return approx; + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + explicit Approx( T const& value ): Approx(static_cast<double>(value)) + {} + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + friend bool operator == ( const T& lhs, Approx const& rhs ) { + auto lhs_v = static_cast<double>(lhs); + return rhs.equalityComparisonImpl(lhs_v); + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + friend bool operator == ( Approx const& lhs, const T& rhs ) { + return operator==( rhs, lhs ); + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + friend bool operator != ( T const& lhs, Approx const& rhs ) { + return !operator==( lhs, rhs ); + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + friend bool operator != ( Approx const& lhs, T const& rhs ) { + return !operator==( rhs, lhs ); + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + friend bool operator <= ( T const& lhs, Approx const& rhs ) { + return static_cast<double>(lhs) < rhs.m_value || lhs == rhs; + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + friend bool operator <= ( Approx const& lhs, T const& rhs ) { + return lhs.m_value < static_cast<double>(rhs) || lhs == rhs; + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + friend bool operator >= ( T const& lhs, Approx const& rhs ) { + return static_cast<double>(lhs) > rhs.m_value || lhs == rhs; + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + friend bool operator >= ( Approx const& lhs, T const& rhs ) { + return lhs.m_value > static_cast<double>(rhs) || lhs == rhs; + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + Approx& epsilon( T const& newEpsilon ) { + double epsilonAsDouble = static_cast<double>(newEpsilon); + setEpsilon(epsilonAsDouble); + return *this; + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + Approx& margin( T const& newMargin ) { + double marginAsDouble = static_cast<double>(newMargin); + setMargin(marginAsDouble); + return *this; + } + + template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + Approx& scale( T const& newScale ) { + m_scale = static_cast<double>(newScale); + return *this; + } + + std::string toString() const; + + private: + double m_epsilon; + double m_margin; + double m_scale; + double m_value; + }; +} // end namespace Detail + +namespace literals { + Detail::Approx operator "" _a(long double val); + Detail::Approx operator "" _a(unsigned long long val); +} // end namespace literals + +template<> +struct StringMaker<Catch::Detail::Approx> { + static std::string convert(Catch::Detail::Approx const& value); +}; + +} // end namespace Catch + +// end catch_approx.h +// start catch_string_manip.h + +#include <string> +#include <iosfwd> +#include <vector> + +namespace Catch { + + bool startsWith( std::string const& s, std::string const& prefix ); + bool startsWith( std::string const& s, char prefix ); + bool endsWith( std::string const& s, std::string const& suffix ); + bool endsWith( std::string const& s, char suffix ); + bool contains( std::string const& s, std::string const& infix ); + void toLowerInPlace( std::string& s ); + std::string toLower( std::string const& s ); + //! Returns a new string without whitespace at the start/end + std::string trim( std::string const& str ); + //! Returns a substring of the original ref without whitespace. Beware lifetimes! + StringRef trim(StringRef ref); + + // !!! Be aware, returns refs into original string - make sure original string outlives them + std::vector<StringRef> splitStringRef( StringRef str, char delimiter ); + bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ); + + struct pluralise { + pluralise( std::size_t count, std::string const& label ); + + friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); + + std::size_t m_count; + std::string m_label; + }; +} + +// end catch_string_manip.h +#ifndef CATCH_CONFIG_DISABLE_MATCHERS +// start catch_capture_matchers.h + +// start catch_matchers.h + +#include <string> +#include <vector> + +namespace Catch { +namespace Matchers { + namespace Impl { + + template<typename ArgT> struct MatchAllOf; + template<typename ArgT> struct MatchAnyOf; + template<typename ArgT> struct MatchNotOf; + + class MatcherUntypedBase { + public: + MatcherUntypedBase() = default; + MatcherUntypedBase ( MatcherUntypedBase const& ) = default; + MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = delete; + std::string toString() const; + + protected: + virtual ~MatcherUntypedBase(); + virtual std::string describe() const = 0; + mutable std::string m_cachedToString; + }; + +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#endif + + template<typename ObjectT> + struct MatcherMethod { + virtual bool match( ObjectT const& arg ) const = 0; + }; + +#if defined(__OBJC__) + // Hack to fix Catch GH issue #1661. Could use id for generic Object support. + // use of const for Object pointers is very uncommon and under ARC it causes some kind of signature mismatch that breaks compilation + template<> + struct MatcherMethod<NSString*> { + virtual bool match( NSString* arg ) const = 0; + }; +#endif + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + + template<typename T> + struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> { + + MatchAllOf<T> operator && ( MatcherBase const& other ) const; + MatchAnyOf<T> operator || ( MatcherBase const& other ) const; + MatchNotOf<T> operator ! () const; + }; + + template<typename ArgT> + struct MatchAllOf : MatcherBase<ArgT> { + bool match( ArgT const& arg ) const override { + for( auto matcher : m_matchers ) { + if (!matcher->match(arg)) + return false; + } + return true; + } + std::string describe() const override { + std::string description; + description.reserve( 4 + m_matchers.size()*32 ); + description += "( "; + bool first = true; + for( auto matcher : m_matchers ) { + if( first ) + first = false; + else + description += " and "; + description += matcher->toString(); + } + description += " )"; + return description; + } + + MatchAllOf<ArgT> operator && ( MatcherBase<ArgT> const& other ) { + auto copy(*this); + copy.m_matchers.push_back( &other ); + return copy; + } + + std::vector<MatcherBase<ArgT> const*> m_matchers; + }; + template<typename ArgT> + struct MatchAnyOf : MatcherBase<ArgT> { + + bool match( ArgT const& arg ) const override { + for( auto matcher : m_matchers ) { + if (matcher->match(arg)) + return true; + } + return false; + } + std::string describe() const override { + std::string description; + description.reserve( 4 + m_matchers.size()*32 ); + description += "( "; + bool first = true; + for( auto matcher : m_matchers ) { + if( first ) + first = false; + else + description += " or "; + description += matcher->toString(); + } + description += " )"; + return description; + } + + MatchAnyOf<ArgT> operator || ( MatcherBase<ArgT> const& other ) { + auto copy(*this); + copy.m_matchers.push_back( &other ); + return copy; + } + + std::vector<MatcherBase<ArgT> const*> m_matchers; + }; + + template<typename ArgT> + struct MatchNotOf : MatcherBase<ArgT> { + + MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {} + + bool match( ArgT const& arg ) const override { + return !m_underlyingMatcher.match( arg ); + } + + std::string describe() const override { + return "not " + m_underlyingMatcher.toString(); + } + MatcherBase<ArgT> const& m_underlyingMatcher; + }; + + template<typename T> + MatchAllOf<T> MatcherBase<T>::operator && ( MatcherBase const& other ) const { + return MatchAllOf<T>() && *this && other; + } + template<typename T> + MatchAnyOf<T> MatcherBase<T>::operator || ( MatcherBase const& other ) const { + return MatchAnyOf<T>() || *this || other; + } + template<typename T> + MatchNotOf<T> MatcherBase<T>::operator ! () const { + return MatchNotOf<T>( *this ); + } + + } // namespace Impl + +} // namespace Matchers + +using namespace Matchers; +using Matchers::Impl::MatcherBase; + +} // namespace Catch + +// end catch_matchers.h +// start catch_matchers_exception.hpp + +namespace Catch { +namespace Matchers { +namespace Exception { + +class ExceptionMessageMatcher : public MatcherBase<std::exception> { + std::string m_message; +public: + + ExceptionMessageMatcher(std::string const& message): + m_message(message) + {} + + bool match(std::exception const& ex) const override; + + std::string describe() const override; +}; + +} // namespace Exception + +Exception::ExceptionMessageMatcher Message(std::string const& message); + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_exception.hpp +// start catch_matchers_floating.h + +namespace Catch { +namespace Matchers { + + namespace Floating { + + enum class FloatingPointKind : uint8_t; + + struct WithinAbsMatcher : MatcherBase<double> { + WithinAbsMatcher(double target, double margin); + bool match(double const& matchee) const override; + std::string describe() const override; + private: + double m_target; + double m_margin; + }; + + struct WithinUlpsMatcher : MatcherBase<double> { + WithinUlpsMatcher(double target, uint64_t ulps, FloatingPointKind baseType); + bool match(double const& matchee) const override; + std::string describe() const override; + private: + double m_target; + uint64_t m_ulps; + FloatingPointKind m_type; + }; + + // Given IEEE-754 format for floats and doubles, we can assume + // that float -> double promotion is lossless. Given this, we can + // assume that if we do the standard relative comparison of + // |lhs - rhs| <= epsilon * max(fabs(lhs), fabs(rhs)), then we get + // the same result if we do this for floats, as if we do this for + // doubles that were promoted from floats. + struct WithinRelMatcher : MatcherBase<double> { + WithinRelMatcher(double target, double epsilon); + bool match(double const& matchee) const override; + std::string describe() const override; + private: + double m_target; + double m_epsilon; + }; + + } // namespace Floating + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + Floating::WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff); + Floating::WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff); + Floating::WithinAbsMatcher WithinAbs(double target, double margin); + Floating::WithinRelMatcher WithinRel(double target, double eps); + // defaults epsilon to 100*numeric_limits<double>::epsilon() + Floating::WithinRelMatcher WithinRel(double target); + Floating::WithinRelMatcher WithinRel(float target, float eps); + // defaults epsilon to 100*numeric_limits<float>::epsilon() + Floating::WithinRelMatcher WithinRel(float target); + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_floating.h +// start catch_matchers_generic.hpp + +#include <functional> +#include <string> + +namespace Catch { +namespace Matchers { +namespace Generic { + +namespace Detail { + std::string finalizeDescription(const std::string& desc); +} + +template <typename T> +class PredicateMatcher : public MatcherBase<T> { + std::function<bool(T const&)> m_predicate; + std::string m_description; +public: + + PredicateMatcher(std::function<bool(T const&)> const& elem, std::string const& descr) + :m_predicate(std::move(elem)), + m_description(Detail::finalizeDescription(descr)) + {} + + bool match( T const& item ) const override { + return m_predicate(item); + } + + std::string describe() const override { + return m_description; + } +}; + +} // namespace Generic + + // The following functions create the actual matcher objects. + // The user has to explicitly specify type to the function, because + // inferring std::function<bool(T const&)> is hard (but possible) and + // requires a lot of TMP. + template<typename T> + Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)> const& predicate, std::string const& description = "") { + return Generic::PredicateMatcher<T>(predicate, description); + } + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_generic.hpp +// start catch_matchers_string.h + +#include <string> + +namespace Catch { +namespace Matchers { + + namespace StdString { + + struct CasedString + { + CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ); + std::string adjustString( std::string const& str ) const; + std::string caseSensitivitySuffix() const; + + CaseSensitive::Choice m_caseSensitivity; + std::string m_str; + }; + + struct StringMatcherBase : MatcherBase<std::string> { + StringMatcherBase( std::string const& operation, CasedString const& comparator ); + std::string describe() const override; + + CasedString m_comparator; + std::string m_operation; + }; + + struct EqualsMatcher : StringMatcherBase { + EqualsMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct ContainsMatcher : StringMatcherBase { + ContainsMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct StartsWithMatcher : StringMatcherBase { + StartsWithMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct EndsWithMatcher : StringMatcherBase { + EndsWithMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + + struct RegexMatcher : MatcherBase<std::string> { + RegexMatcher( std::string regex, CaseSensitive::Choice caseSensitivity ); + bool match( std::string const& matchee ) const override; + std::string describe() const override; + + private: + std::string m_regex; + CaseSensitive::Choice m_caseSensitivity; + }; + + } // namespace StdString + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + + StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::RegexMatcher Matches( std::string const& regex, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_string.h +// start catch_matchers_vector.h + +#include <algorithm> + +namespace Catch { +namespace Matchers { + + namespace Vector { + template<typename T, typename Alloc> + struct ContainsElementMatcher : MatcherBase<std::vector<T, Alloc>> { + + ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} + + bool match(std::vector<T, Alloc> const &v) const override { + for (auto const& el : v) { + if (el == m_comparator) { + return true; + } + } + return false; + } + + std::string describe() const override { + return "Contains: " + ::Catch::Detail::stringify( m_comparator ); + } + + T const& m_comparator; + }; + + template<typename T, typename AllocComp, typename AllocMatch> + struct ContainsMatcher : MatcherBase<std::vector<T, AllocMatch>> { + + ContainsMatcher(std::vector<T, AllocComp> const &comparator) : m_comparator( comparator ) {} + + bool match(std::vector<T, AllocMatch> const &v) const override { + // !TBD: see note in EqualsMatcher + if (m_comparator.size() > v.size()) + return false; + for (auto const& comparator : m_comparator) { + auto present = false; + for (const auto& el : v) { + if (el == comparator) { + present = true; + break; + } + } + if (!present) { + return false; + } + } + return true; + } + std::string describe() const override { + return "Contains: " + ::Catch::Detail::stringify( m_comparator ); + } + + std::vector<T, AllocComp> const& m_comparator; + }; + + template<typename T, typename AllocComp, typename AllocMatch> + struct EqualsMatcher : MatcherBase<std::vector<T, AllocMatch>> { + + EqualsMatcher(std::vector<T, AllocComp> const &comparator) : m_comparator( comparator ) {} + + bool match(std::vector<T, AllocMatch> const &v) const override { + // !TBD: This currently works if all elements can be compared using != + // - a more general approach would be via a compare template that defaults + // to using !=. but could be specialised for, e.g. std::vector<T, Alloc> etc + // - then just call that directly + if (m_comparator.size() != v.size()) + return false; + for (std::size_t i = 0; i < v.size(); ++i) + if (m_comparator[i] != v[i]) + return false; + return true; + } + std::string describe() const override { + return "Equals: " + ::Catch::Detail::stringify( m_comparator ); + } + std::vector<T, AllocComp> const& m_comparator; + }; + + template<typename T, typename AllocComp, typename AllocMatch> + struct ApproxMatcher : MatcherBase<std::vector<T, AllocMatch>> { + + ApproxMatcher(std::vector<T, AllocComp> const& comparator) : m_comparator( comparator ) {} + + bool match(std::vector<T, AllocMatch> const &v) const override { + if (m_comparator.size() != v.size()) + return false; + for (std::size_t i = 0; i < v.size(); ++i) + if (m_comparator[i] != approx(v[i])) + return false; + return true; + } + std::string describe() const override { + return "is approx: " + ::Catch::Detail::stringify( m_comparator ); + } + template <typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + ApproxMatcher& epsilon( T const& newEpsilon ) { + approx.epsilon(newEpsilon); + return *this; + } + template <typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + ApproxMatcher& margin( T const& newMargin ) { + approx.margin(newMargin); + return *this; + } + template <typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> + ApproxMatcher& scale( T const& newScale ) { + approx.scale(newScale); + return *this; + } + + std::vector<T, AllocComp> const& m_comparator; + mutable Catch::Detail::Approx approx = Catch::Detail::Approx::custom(); + }; + + template<typename T, typename AllocComp, typename AllocMatch> + struct UnorderedEqualsMatcher : MatcherBase<std::vector<T, AllocMatch>> { + UnorderedEqualsMatcher(std::vector<T, AllocComp> const& target) : m_target(target) {} + bool match(std::vector<T, AllocMatch> const& vec) const override { + if (m_target.size() != vec.size()) { + return false; + } + return std::is_permutation(m_target.begin(), m_target.end(), vec.begin()); + } + + std::string describe() const override { + return "UnorderedEquals: " + ::Catch::Detail::stringify(m_target); + } + private: + std::vector<T, AllocComp> const& m_target; + }; + + } // namespace Vector + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + + template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp> + Vector::ContainsMatcher<T, AllocComp, AllocMatch> Contains( std::vector<T, AllocComp> const& comparator ) { + return Vector::ContainsMatcher<T, AllocComp, AllocMatch>( comparator ); + } + + template<typename T, typename Alloc = std::allocator<T>> + Vector::ContainsElementMatcher<T, Alloc> VectorContains( T const& comparator ) { + return Vector::ContainsElementMatcher<T, Alloc>( comparator ); + } + + template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp> + Vector::EqualsMatcher<T, AllocComp, AllocMatch> Equals( std::vector<T, AllocComp> const& comparator ) { + return Vector::EqualsMatcher<T, AllocComp, AllocMatch>( comparator ); + } + + template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp> + Vector::ApproxMatcher<T, AllocComp, AllocMatch> Approx( std::vector<T, AllocComp> const& comparator ) { + return Vector::ApproxMatcher<T, AllocComp, AllocMatch>( comparator ); + } + + template<typename T, typename AllocComp = std::allocator<T>, typename AllocMatch = AllocComp> + Vector::UnorderedEqualsMatcher<T, AllocComp, AllocMatch> UnorderedEquals(std::vector<T, AllocComp> const& target) { + return Vector::UnorderedEqualsMatcher<T, AllocComp, AllocMatch>( target ); + } + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_vector.h +namespace Catch { + + template<typename ArgT, typename MatcherT> + class MatchExpr : public ITransientExpression { + ArgT const& m_arg; + MatcherT m_matcher; + StringRef m_matcherString; + public: + MatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef const& matcherString ) + : ITransientExpression{ true, matcher.match( arg ) }, + m_arg( arg ), + m_matcher( matcher ), + m_matcherString( matcherString ) + {} + + void streamReconstructedExpression( std::ostream &os ) const override { + auto matcherAsString = m_matcher.toString(); + os << Catch::Detail::stringify( m_arg ) << ' '; + if( matcherAsString == Detail::unprintableString ) + os << m_matcherString; + else + os << matcherAsString; + } + }; + + using StringMatcher = Matchers::Impl::MatcherBase<std::string>; + + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString ); + + template<typename ArgT, typename MatcherT> + auto makeMatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef const& matcherString ) -> MatchExpr<ArgT, MatcherT> { + return MatchExpr<ArgT, MatcherT>( arg, matcher, matcherString ); + } + +} // namespace Catch + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + INTERNAL_CATCH_TRY { \ + catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher##_catch_sr ) ); \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS_MATCHES( macroName, exceptionType, resultDisposition, matcher, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast<void>(__VA_ARGS__ ); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( exceptionType const& ex ) { \ + catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher##_catch_sr ) ); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +// end catch_capture_matchers.h +#endif +// start catch_generators.hpp + +// start catch_interfaces_generatortracker.h + + +#include <memory> + +namespace Catch { + + namespace Generators { + class GeneratorUntypedBase { + public: + GeneratorUntypedBase() = default; + virtual ~GeneratorUntypedBase(); + // Attempts to move the generator to the next element + // + // Returns true iff the move succeeded (and a valid element + // can be retrieved). + virtual bool next() = 0; + }; + using GeneratorBasePtr = std::unique_ptr<GeneratorUntypedBase>; + + } // namespace Generators + + struct IGeneratorTracker { + virtual ~IGeneratorTracker(); + virtual auto hasGenerator() const -> bool = 0; + virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0; + virtual void setGenerator( Generators::GeneratorBasePtr&& generator ) = 0; + }; + +} // namespace Catch + +// end catch_interfaces_generatortracker.h +// start catch_enforce.h + +#include <exception> + +namespace Catch { +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + template <typename Ex> + [[noreturn]] + void throw_exception(Ex const& e) { + throw e; + } +#else // ^^ Exceptions are enabled // Exceptions are disabled vv + [[noreturn]] + void throw_exception(std::exception const& e); +#endif + + [[noreturn]] + void throw_logic_error(std::string const& msg); + [[noreturn]] + void throw_domain_error(std::string const& msg); + [[noreturn]] + void throw_runtime_error(std::string const& msg); + +} // namespace Catch; + +#define CATCH_MAKE_MSG(...) \ + (Catch::ReusableStringStream() << __VA_ARGS__).str() + +#define CATCH_INTERNAL_ERROR(...) \ + Catch::throw_logic_error(CATCH_MAKE_MSG( CATCH_INTERNAL_LINEINFO << ": Internal Catch2 error: " << __VA_ARGS__)) + +#define CATCH_ERROR(...) \ + Catch::throw_domain_error(CATCH_MAKE_MSG( __VA_ARGS__ )) + +#define CATCH_RUNTIME_ERROR(...) \ + Catch::throw_runtime_error(CATCH_MAKE_MSG( __VA_ARGS__ )) + +#define CATCH_ENFORCE( condition, ... ) \ + do{ if( !(condition) ) CATCH_ERROR( __VA_ARGS__ ); } while(false) + +// end catch_enforce.h +#include <memory> +#include <vector> +#include <cassert> + +#include <utility> +#include <exception> + +namespace Catch { + +class GeneratorException : public std::exception { + const char* const m_msg = ""; + +public: + GeneratorException(const char* msg): + m_msg(msg) + {} + + const char* what() const noexcept override final; +}; + +namespace Generators { + + // !TBD move this into its own location? + namespace pf{ + template<typename T, typename... Args> + std::unique_ptr<T> make_unique( Args&&... args ) { + return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); + } + } + + template<typename T> + struct IGenerator : GeneratorUntypedBase { + virtual ~IGenerator() = default; + + // Returns the current element of the generator + // + // \Precondition The generator is either freshly constructed, + // or the last call to `next()` returned true + virtual T const& get() const = 0; + using type = T; + }; + + template<typename T> + class SingleValueGenerator final : public IGenerator<T> { + T m_value; + public: + SingleValueGenerator(T&& value) : m_value(std::move(value)) {} + + T const& get() const override { + return m_value; + } + bool next() override { + return false; + } + }; + + template<typename T> + class FixedValuesGenerator final : public IGenerator<T> { + static_assert(!std::is_same<T, bool>::value, + "FixedValuesGenerator does not support bools because of std::vector<bool>" + "specialization, use SingleValue Generator instead."); + std::vector<T> m_values; + size_t m_idx = 0; + public: + FixedValuesGenerator( std::initializer_list<T> values ) : m_values( values ) {} + + T const& get() const override { + return m_values[m_idx]; + } + bool next() override { + ++m_idx; + return m_idx < m_values.size(); + } + }; + + template <typename T> + class GeneratorWrapper final { + std::unique_ptr<IGenerator<T>> m_generator; + public: + GeneratorWrapper(std::unique_ptr<IGenerator<T>> generator): + m_generator(std::move(generator)) + {} + T const& get() const { + return m_generator->get(); + } + bool next() { + return m_generator->next(); + } + }; + + template <typename T> + GeneratorWrapper<T> value(T&& value) { + return GeneratorWrapper<T>(pf::make_unique<SingleValueGenerator<T>>(std::forward<T>(value))); + } + template <typename T> + GeneratorWrapper<T> values(std::initializer_list<T> values) { + return GeneratorWrapper<T>(pf::make_unique<FixedValuesGenerator<T>>(values)); + } + + template<typename T> + class Generators : public IGenerator<T> { + std::vector<GeneratorWrapper<T>> m_generators; + size_t m_current = 0; + + void populate(GeneratorWrapper<T>&& generator) { + m_generators.emplace_back(std::move(generator)); + } + void populate(T&& val) { + m_generators.emplace_back(value(std::forward<T>(val))); + } + template<typename U> + void populate(U&& val) { + populate(T(std::forward<U>(val))); + } + template<typename U, typename... Gs> + void populate(U&& valueOrGenerator, Gs &&... moreGenerators) { + populate(std::forward<U>(valueOrGenerator)); + populate(std::forward<Gs>(moreGenerators)...); + } + + public: + template <typename... Gs> + Generators(Gs &&... moreGenerators) { + m_generators.reserve(sizeof...(Gs)); + populate(std::forward<Gs>(moreGenerators)...); + } + + T const& get() const override { + return m_generators[m_current].get(); + } + + bool next() override { + if (m_current >= m_generators.size()) { + return false; + } + const bool current_status = m_generators[m_current].next(); + if (!current_status) { + ++m_current; + } + return m_current < m_generators.size(); + } + }; + + template<typename... Ts> + GeneratorWrapper<std::tuple<Ts...>> table( std::initializer_list<std::tuple<typename std::decay<Ts>::type...>> tuples ) { + return values<std::tuple<Ts...>>( tuples ); + } + + // Tag type to signal that a generator sequence should convert arguments to a specific type + template <typename T> + struct as {}; + + template<typename T, typename... Gs> + auto makeGenerators( GeneratorWrapper<T>&& generator, Gs &&... moreGenerators ) -> Generators<T> { + return Generators<T>(std::move(generator), std::forward<Gs>(moreGenerators)...); + } + template<typename T> + auto makeGenerators( GeneratorWrapper<T>&& generator ) -> Generators<T> { + return Generators<T>(std::move(generator)); + } + template<typename T, typename... Gs> + auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators<T> { + return makeGenerators( value( std::forward<T>( val ) ), std::forward<Gs>( moreGenerators )... ); + } + template<typename T, typename U, typename... Gs> + auto makeGenerators( as<T>, U&& val, Gs &&... moreGenerators ) -> Generators<T> { + return makeGenerators( value( T( std::forward<U>( val ) ) ), std::forward<Gs>( moreGenerators )... ); + } + + auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker&; + + template<typename L> + // Note: The type after -> is weird, because VS2015 cannot parse + // the expression used in the typedef inside, when it is in + // return type. Yeah. + auto generate( StringRef generatorName, SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) { + using UnderlyingType = typename decltype(generatorExpression())::type; + + IGeneratorTracker& tracker = acquireGeneratorTracker( generatorName, lineInfo ); + if (!tracker.hasGenerator()) { + tracker.setGenerator(pf::make_unique<Generators<UnderlyingType>>(generatorExpression())); + } + + auto const& generator = static_cast<IGenerator<UnderlyingType> const&>( *tracker.getGenerator() ); + return generator.get(); + } + +} // namespace Generators +} // namespace Catch + +#define GENERATE( ... ) \ + Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ + CATCH_INTERNAL_LINEINFO, \ + [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) +#define GENERATE_COPY( ... ) \ + Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ + CATCH_INTERNAL_LINEINFO, \ + [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) +#define GENERATE_REF( ... ) \ + Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ + CATCH_INTERNAL_LINEINFO, \ + [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) + +// end catch_generators.hpp +// start catch_generators_generic.hpp + +namespace Catch { +namespace Generators { + + template <typename T> + class TakeGenerator : public IGenerator<T> { + GeneratorWrapper<T> m_generator; + size_t m_returned = 0; + size_t m_target; + public: + TakeGenerator(size_t target, GeneratorWrapper<T>&& generator): + m_generator(std::move(generator)), + m_target(target) + { + assert(target != 0 && "Empty generators are not allowed"); + } + T const& get() const override { + return m_generator.get(); + } + bool next() override { + ++m_returned; + if (m_returned >= m_target) { + return false; + } + + const auto success = m_generator.next(); + // If the underlying generator does not contain enough values + // then we cut short as well + if (!success) { + m_returned = m_target; + } + return success; + } + }; + + template <typename T> + GeneratorWrapper<T> take(size_t target, GeneratorWrapper<T>&& generator) { + return GeneratorWrapper<T>(pf::make_unique<TakeGenerator<T>>(target, std::move(generator))); + } + + template <typename T, typename Predicate> + class FilterGenerator : public IGenerator<T> { + GeneratorWrapper<T> m_generator; + Predicate m_predicate; + public: + template <typename P = Predicate> + FilterGenerator(P&& pred, GeneratorWrapper<T>&& generator): + m_generator(std::move(generator)), + m_predicate(std::forward<P>(pred)) + { + if (!m_predicate(m_generator.get())) { + // It might happen that there are no values that pass the + // filter. In that case we throw an exception. + auto has_initial_value = nextImpl(); + if (!has_initial_value) { + Catch::throw_exception(GeneratorException("No valid value found in filtered generator")); + } + } + } + + T const& get() const override { + return m_generator.get(); + } + + bool next() override { + return nextImpl(); + } + + private: + bool nextImpl() { + bool success = m_generator.next(); + if (!success) { + return false; + } + while (!m_predicate(m_generator.get()) && (success = m_generator.next()) == true); + return success; + } + }; + + template <typename T, typename Predicate> + GeneratorWrapper<T> filter(Predicate&& pred, GeneratorWrapper<T>&& generator) { + return GeneratorWrapper<T>(std::unique_ptr<IGenerator<T>>(pf::make_unique<FilterGenerator<T, Predicate>>(std::forward<Predicate>(pred), std::move(generator)))); + } + + template <typename T> + class RepeatGenerator : public IGenerator<T> { + static_assert(!std::is_same<T, bool>::value, + "RepeatGenerator currently does not support bools" + "because of std::vector<bool> specialization"); + GeneratorWrapper<T> m_generator; + mutable std::vector<T> m_returned; + size_t m_target_repeats; + size_t m_current_repeat = 0; + size_t m_repeat_index = 0; + public: + RepeatGenerator(size_t repeats, GeneratorWrapper<T>&& generator): + m_generator(std::move(generator)), + m_target_repeats(repeats) + { + assert(m_target_repeats > 0 && "Repeat generator must repeat at least once"); + } + + T const& get() const override { + if (m_current_repeat == 0) { + m_returned.push_back(m_generator.get()); + return m_returned.back(); + } + return m_returned[m_repeat_index]; + } + + bool next() override { + // There are 2 basic cases: + // 1) We are still reading the generator + // 2) We are reading our own cache + + // In the first case, we need to poke the underlying generator. + // If it happily moves, we are left in that state, otherwise it is time to start reading from our cache + if (m_current_repeat == 0) { + const auto success = m_generator.next(); + if (!success) { + ++m_current_repeat; + } + return m_current_repeat < m_target_repeats; + } + + // In the second case, we need to move indices forward and check that we haven't run up against the end + ++m_repeat_index; + if (m_repeat_index == m_returned.size()) { + m_repeat_index = 0; + ++m_current_repeat; + } + return m_current_repeat < m_target_repeats; + } + }; + + template <typename T> + GeneratorWrapper<T> repeat(size_t repeats, GeneratorWrapper<T>&& generator) { + return GeneratorWrapper<T>(pf::make_unique<RepeatGenerator<T>>(repeats, std::move(generator))); + } + + template <typename T, typename U, typename Func> + class MapGenerator : public IGenerator<T> { + // TBD: provide static assert for mapping function, for friendly error message + GeneratorWrapper<U> m_generator; + Func m_function; + // To avoid returning dangling reference, we have to save the values + T m_cache; + public: + template <typename F2 = Func> + MapGenerator(F2&& function, GeneratorWrapper<U>&& generator) : + m_generator(std::move(generator)), + m_function(std::forward<F2>(function)), + m_cache(m_function(m_generator.get())) + {} + + T const& get() const override { + return m_cache; + } + bool next() override { + const auto success = m_generator.next(); + if (success) { + m_cache = m_function(m_generator.get()); + } + return success; + } + }; + + template <typename Func, typename U, typename T = FunctionReturnType<Func, U>> + GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) { + return GeneratorWrapper<T>( + pf::make_unique<MapGenerator<T, U, Func>>(std::forward<Func>(function), std::move(generator)) + ); + } + + template <typename T, typename U, typename Func> + GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) { + return GeneratorWrapper<T>( + pf::make_unique<MapGenerator<T, U, Func>>(std::forward<Func>(function), std::move(generator)) + ); + } + + template <typename T> + class ChunkGenerator final : public IGenerator<std::vector<T>> { + std::vector<T> m_chunk; + size_t m_chunk_size; + GeneratorWrapper<T> m_generator; + bool m_used_up = false; + public: + ChunkGenerator(size_t size, GeneratorWrapper<T> generator) : + m_chunk_size(size), m_generator(std::move(generator)) + { + m_chunk.reserve(m_chunk_size); + if (m_chunk_size != 0) { + m_chunk.push_back(m_generator.get()); + for (size_t i = 1; i < m_chunk_size; ++i) { + if (!m_generator.next()) { + Catch::throw_exception(GeneratorException("Not enough values to initialize the first chunk")); + } + m_chunk.push_back(m_generator.get()); + } + } + } + std::vector<T> const& get() const override { + return m_chunk; + } + bool next() override { + m_chunk.clear(); + for (size_t idx = 0; idx < m_chunk_size; ++idx) { + if (!m_generator.next()) { + return false; + } + m_chunk.push_back(m_generator.get()); + } + return true; + } + }; + + template <typename T> + GeneratorWrapper<std::vector<T>> chunk(size_t size, GeneratorWrapper<T>&& generator) { + return GeneratorWrapper<std::vector<T>>( + pf::make_unique<ChunkGenerator<T>>(size, std::move(generator)) + ); + } + +} // namespace Generators +} // namespace Catch + +// end catch_generators_generic.hpp +// start catch_generators_specific.hpp + +// start catch_context.h + +#include <memory> + +namespace Catch { + + struct IResultCapture; + struct IRunner; + struct IConfig; + struct IMutableContext; + + using IConfigPtr = std::shared_ptr<IConfig const>; + + struct IContext + { + virtual ~IContext(); + + virtual IResultCapture* getResultCapture() = 0; + virtual IRunner* getRunner() = 0; + virtual IConfigPtr const& getConfig() const = 0; + }; + + struct IMutableContext : IContext + { + virtual ~IMutableContext(); + virtual void setResultCapture( IResultCapture* resultCapture ) = 0; + virtual void setRunner( IRunner* runner ) = 0; + virtual void setConfig( IConfigPtr const& config ) = 0; + + private: + static IMutableContext *currentContext; + friend IMutableContext& getCurrentMutableContext(); + friend void cleanUpContext(); + static void createContext(); + }; + + inline IMutableContext& getCurrentMutableContext() + { + if( !IMutableContext::currentContext ) + IMutableContext::createContext(); + // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) + return *IMutableContext::currentContext; + } + + inline IContext& getCurrentContext() + { + return getCurrentMutableContext(); + } + + void cleanUpContext(); + + class SimplePcg32; + SimplePcg32& rng(); +} + +// end catch_context.h +// start catch_interfaces_config.h + +// start catch_option.hpp + +namespace Catch { + + // An optional type + template<typename T> + class Option { + public: + Option() : nullableValue( nullptr ) {} + Option( T const& _value ) + : nullableValue( new( storage ) T( _value ) ) + {} + Option( Option const& _other ) + : nullableValue( _other ? new( storage ) T( *_other ) : nullptr ) + {} + + ~Option() { + reset(); + } + + Option& operator= ( Option const& _other ) { + if( &_other != this ) { + reset(); + if( _other ) + nullableValue = new( storage ) T( *_other ); + } + return *this; + } + Option& operator = ( T const& _value ) { + reset(); + nullableValue = new( storage ) T( _value ); + return *this; + } + + void reset() { + if( nullableValue ) + nullableValue->~T(); + nullableValue = nullptr; + } + + T& operator*() { return *nullableValue; } + T const& operator*() const { return *nullableValue; } + T* operator->() { return nullableValue; } + const T* operator->() const { return nullableValue; } + + T valueOr( T const& defaultValue ) const { + return nullableValue ? *nullableValue : defaultValue; + } + + bool some() const { return nullableValue != nullptr; } + bool none() const { return nullableValue == nullptr; } + + bool operator !() const { return nullableValue == nullptr; } + explicit operator bool() const { + return some(); + } + + private: + T *nullableValue; + alignas(alignof(T)) char storage[sizeof(T)]; + }; + +} // end namespace Catch + +// end catch_option.hpp +#include <chrono> +#include <iosfwd> +#include <string> +#include <vector> +#include <memory> + +namespace Catch { + + enum class Verbosity { + Quiet = 0, + Normal, + High + }; + + struct WarnAbout { enum What { + Nothing = 0x00, + NoAssertions = 0x01, + NoTests = 0x02 + }; }; + + struct ShowDurations { enum OrNot { + DefaultForReporter, + Always, + Never + }; }; + struct RunTests { enum InWhatOrder { + InDeclarationOrder, + InLexicographicalOrder, + InRandomOrder + }; }; + struct UseColour { enum YesOrNo { + Auto, + Yes, + No + }; }; + struct WaitForKeypress { enum When { + Never, + BeforeStart = 1, + BeforeExit = 2, + BeforeStartAndExit = BeforeStart | BeforeExit + }; }; + + class TestSpec; + + struct IConfig : NonCopyable { + + virtual ~IConfig(); + + virtual bool allowThrows() const = 0; + virtual std::ostream& stream() const = 0; + virtual std::string name() const = 0; + virtual bool includeSuccessfulResults() const = 0; + virtual bool shouldDebugBreak() const = 0; + virtual bool warnAboutMissingAssertions() const = 0; + virtual bool warnAboutNoTests() const = 0; + virtual int abortAfter() const = 0; + virtual bool showInvisibles() const = 0; + virtual ShowDurations::OrNot showDurations() const = 0; + virtual double minDuration() const = 0; + virtual TestSpec const& testSpec() const = 0; + virtual bool hasTestFilters() const = 0; + virtual std::vector<std::string> const& getTestsOrTags() const = 0; + virtual RunTests::InWhatOrder runOrder() const = 0; + virtual unsigned int rngSeed() const = 0; + virtual UseColour::YesOrNo useColour() const = 0; + virtual std::vector<std::string> const& getSectionsToRun() const = 0; + virtual Verbosity verbosity() const = 0; + + virtual bool benchmarkNoAnalysis() const = 0; + virtual int benchmarkSamples() const = 0; + virtual double benchmarkConfidenceInterval() const = 0; + virtual unsigned int benchmarkResamples() const = 0; + virtual std::chrono::milliseconds benchmarkWarmupTime() const = 0; + }; + + using IConfigPtr = std::shared_ptr<IConfig const>; +} + +// end catch_interfaces_config.h +// start catch_random_number_generator.h + +#include <cstdint> + +namespace Catch { + + // This is a simple implementation of C++11 Uniform Random Number + // Generator. It does not provide all operators, because Catch2 + // does not use it, but it should behave as expected inside stdlib's + // distributions. + // The implementation is based on the PCG family (http://pcg-random.org) + class SimplePcg32 { + using state_type = std::uint64_t; + public: + using result_type = std::uint32_t; + static constexpr result_type (min)() { + return 0; + } + static constexpr result_type (max)() { + return static_cast<result_type>(-1); + } + + // Provide some default initial state for the default constructor + SimplePcg32():SimplePcg32(0xed743cc4U) {} + + explicit SimplePcg32(result_type seed_); + + void seed(result_type seed_); + void discard(uint64_t skip); + + result_type operator()(); + + private: + friend bool operator==(SimplePcg32 const& lhs, SimplePcg32 const& rhs); + friend bool operator!=(SimplePcg32 const& lhs, SimplePcg32 const& rhs); + + // In theory we also need operator<< and operator>> + // In practice we do not use them, so we will skip them for now + + std::uint64_t m_state; + // This part of the state determines which "stream" of the numbers + // is chosen -- we take it as a constant for Catch2, so we only + // need to deal with seeding the main state. + // Picked by reading 8 bytes from `/dev/random` :-) + static const std::uint64_t s_inc = (0x13ed0cc53f939476ULL << 1ULL) | 1ULL; + }; + +} // end namespace Catch + +// end catch_random_number_generator.h +#include <random> + +namespace Catch { +namespace Generators { + +template <typename Float> +class RandomFloatingGenerator final : public IGenerator<Float> { + Catch::SimplePcg32& m_rng; + std::uniform_real_distribution<Float> m_dist; + Float m_current_number; +public: + + RandomFloatingGenerator(Float a, Float b): + m_rng(rng()), + m_dist(a, b) { + static_cast<void>(next()); + } + + Float const& get() const override { + return m_current_number; + } + bool next() override { + m_current_number = m_dist(m_rng); + return true; + } +}; + +template <typename Integer> +class RandomIntegerGenerator final : public IGenerator<Integer> { + Catch::SimplePcg32& m_rng; + std::uniform_int_distribution<Integer> m_dist; + Integer m_current_number; +public: + + RandomIntegerGenerator(Integer a, Integer b): + m_rng(rng()), + m_dist(a, b) { + static_cast<void>(next()); + } + + Integer const& get() const override { + return m_current_number; + } + bool next() override { + m_current_number = m_dist(m_rng); + return true; + } +}; + +// TODO: Ideally this would be also constrained against the various char types, +// but I don't expect users to run into that in practice. +template <typename T> +typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, bool>::value, +GeneratorWrapper<T>>::type +random(T a, T b) { + return GeneratorWrapper<T>( + pf::make_unique<RandomIntegerGenerator<T>>(a, b) + ); +} + +template <typename T> +typename std::enable_if<std::is_floating_point<T>::value, +GeneratorWrapper<T>>::type +random(T a, T b) { + return GeneratorWrapper<T>( + pf::make_unique<RandomFloatingGenerator<T>>(a, b) + ); +} + +template <typename T> +class RangeGenerator final : public IGenerator<T> { + T m_current; + T m_end; + T m_step; + bool m_positive; + +public: + RangeGenerator(T const& start, T const& end, T const& step): + m_current(start), + m_end(end), + m_step(step), + m_positive(m_step > T(0)) + { + assert(m_current != m_end && "Range start and end cannot be equal"); + assert(m_step != T(0) && "Step size cannot be zero"); + assert(((m_positive && m_current <= m_end) || (!m_positive && m_current >= m_end)) && "Step moves away from end"); + } + + RangeGenerator(T const& start, T const& end): + RangeGenerator(start, end, (start < end) ? T(1) : T(-1)) + {} + + T const& get() const override { + return m_current; + } + + bool next() override { + m_current += m_step; + return (m_positive) ? (m_current < m_end) : (m_current > m_end); + } +}; + +template <typename T> +GeneratorWrapper<T> range(T const& start, T const& end, T const& step) { + static_assert(std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, "Type must be numeric"); + return GeneratorWrapper<T>(pf::make_unique<RangeGenerator<T>>(start, end, step)); +} + +template <typename T> +GeneratorWrapper<T> range(T const& start, T const& end) { + static_assert(std::is_integral<T>::value && !std::is_same<T, bool>::value, "Type must be an integer"); + return GeneratorWrapper<T>(pf::make_unique<RangeGenerator<T>>(start, end)); +} + +template <typename T> +class IteratorGenerator final : public IGenerator<T> { + static_assert(!std::is_same<T, bool>::value, + "IteratorGenerator currently does not support bools" + "because of std::vector<bool> specialization"); + + std::vector<T> m_elems; + size_t m_current = 0; +public: + template <typename InputIterator, typename InputSentinel> + IteratorGenerator(InputIterator first, InputSentinel last):m_elems(first, last) { + if (m_elems.empty()) { + Catch::throw_exception(GeneratorException("IteratorGenerator received no valid values")); + } + } + + T const& get() const override { + return m_elems[m_current]; + } + + bool next() override { + ++m_current; + return m_current != m_elems.size(); + } +}; + +template <typename InputIterator, + typename InputSentinel, + typename ResultType = typename std::iterator_traits<InputIterator>::value_type> +GeneratorWrapper<ResultType> from_range(InputIterator from, InputSentinel to) { + return GeneratorWrapper<ResultType>(pf::make_unique<IteratorGenerator<ResultType>>(from, to)); +} + +template <typename Container, + typename ResultType = typename Container::value_type> +GeneratorWrapper<ResultType> from_range(Container const& cnt) { + return GeneratorWrapper<ResultType>(pf::make_unique<IteratorGenerator<ResultType>>(cnt.begin(), cnt.end())); +} + +} // namespace Generators +} // namespace Catch + +// end catch_generators_specific.hpp + +// These files are included here so the single_include script doesn't put them +// in the conditionally compiled sections +// start catch_test_case_info.h + +#include <string> +#include <vector> +#include <memory> + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + + struct ITestInvoker; + + struct TestCaseInfo { + enum SpecialProperties{ + None = 0, + IsHidden = 1 << 1, + ShouldFail = 1 << 2, + MayFail = 1 << 3, + Throws = 1 << 4, + NonPortable = 1 << 5, + Benchmark = 1 << 6 + }; + + TestCaseInfo( std::string const& _name, + std::string const& _className, + std::string const& _description, + std::vector<std::string> const& _tags, + SourceLineInfo const& _lineInfo ); + + friend void setTags( TestCaseInfo& testCaseInfo, std::vector<std::string> tags ); + + bool isHidden() const; + bool throws() const; + bool okToFail() const; + bool expectedToFail() const; + + std::string tagsAsString() const; + + std::string name; + std::string className; + std::string description; + std::vector<std::string> tags; + std::vector<std::string> lcaseTags; + SourceLineInfo lineInfo; + SpecialProperties properties; + }; + + class TestCase : public TestCaseInfo { + public: + + TestCase( ITestInvoker* testCase, TestCaseInfo&& info ); + + TestCase withName( std::string const& _newName ) const; + + void invoke() const; + + TestCaseInfo const& getTestCaseInfo() const; + + bool operator == ( TestCase const& other ) const; + bool operator < ( TestCase const& other ) const; + + private: + std::shared_ptr<ITestInvoker> test; + }; + + TestCase makeTestCase( ITestInvoker* testCase, + std::string const& className, + NameAndTags const& nameAndTags, + SourceLineInfo const& lineInfo ); +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_test_case_info.h +// start catch_interfaces_runner.h + +namespace Catch { + + struct IRunner { + virtual ~IRunner(); + virtual bool aborting() const = 0; + }; +} + +// end catch_interfaces_runner.h + +#ifdef __OBJC__ +// start catch_objc.hpp + +#import <objc/runtime.h> + +#include <string> + +// NB. Any general catch headers included here must be included +// in catch.hpp first to make sure they are included by the single +// header for non obj-usage + +/////////////////////////////////////////////////////////////////////////////// +// This protocol is really only here for (self) documenting purposes, since +// all its methods are optional. +@protocol OcFixture + +@optional + +-(void) setUp; +-(void) tearDown; + +@end + +namespace Catch { + + class OcMethod : public ITestInvoker { + + public: + OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {} + + virtual void invoke() const { + id obj = [[m_cls alloc] init]; + + performOptionalSelector( obj, @selector(setUp) ); + performOptionalSelector( obj, m_sel ); + performOptionalSelector( obj, @selector(tearDown) ); + + arcSafeRelease( obj ); + } + private: + virtual ~OcMethod() {} + + Class m_cls; + SEL m_sel; + }; + + namespace Detail{ + + inline std::string getAnnotation( Class cls, + std::string const& annotationName, + std::string const& testCaseName ) { + NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()]; + SEL sel = NSSelectorFromString( selStr ); + arcSafeRelease( selStr ); + id value = performOptionalSelector( cls, sel ); + if( value ) + return [(NSString*)value UTF8String]; + return ""; + } + } + + inline std::size_t registerTestMethods() { + std::size_t noTestMethods = 0; + int noClasses = objc_getClassList( nullptr, 0 ); + + Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); + objc_getClassList( classes, noClasses ); + + for( int c = 0; c < noClasses; c++ ) { + Class cls = classes[c]; + { + u_int count; + Method* methods = class_copyMethodList( cls, &count ); + for( u_int m = 0; m < count ; m++ ) { + SEL selector = method_getName(methods[m]); + std::string methodName = sel_getName(selector); + if( startsWith( methodName, "Catch_TestCase_" ) ) { + std::string testCaseName = methodName.substr( 15 ); + std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); + std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); + const char* className = class_getName( cls ); + + getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, NameAndTags( name.c_str(), desc.c_str() ), SourceLineInfo("",0) ) ); + noTestMethods++; + } + } + free(methods); + } + } + return noTestMethods; + } + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) + + namespace Matchers { + namespace Impl { + namespace NSStringMatchers { + + struct StringHolder : MatcherBase<NSString*>{ + StringHolder( NSString* substr ) : m_substr( [substr copy] ){} + StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} + StringHolder() { + arcSafeRelease( m_substr ); + } + + bool match( NSString* str ) const override { + return false; + } + + NSString* CATCH_ARC_STRONG m_substr; + }; + + struct Equals : StringHolder { + Equals( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str isEqualToString:m_substr]; + } + + std::string describe() const override { + return "equals string: " + Catch::Detail::stringify( m_substr ); + } + }; + + struct Contains : StringHolder { + Contains( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location != NSNotFound; + } + + std::string describe() const override { + return "contains string: " + Catch::Detail::stringify( m_substr ); + } + }; + + struct StartsWith : StringHolder { + StartsWith( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location == 0; + } + + std::string describe() const override { + return "starts with: " + Catch::Detail::stringify( m_substr ); + } + }; + struct EndsWith : StringHolder { + EndsWith( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location == [str length] - [m_substr length]; + } + + std::string describe() const override { + return "ends with: " + Catch::Detail::stringify( m_substr ); + } + }; + + } // namespace NSStringMatchers + } // namespace Impl + + inline Impl::NSStringMatchers::Equals + Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); } + + inline Impl::NSStringMatchers::Contains + Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); } + + inline Impl::NSStringMatchers::StartsWith + StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); } + + inline Impl::NSStringMatchers::EndsWith + EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); } + + } // namespace Matchers + + using namespace Matchers; + +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +} // namespace Catch + +/////////////////////////////////////////////////////////////////////////////// +#define OC_MAKE_UNIQUE_NAME( root, uniqueSuffix ) root##uniqueSuffix +#define OC_TEST_CASE2( name, desc, uniqueSuffix ) \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Name_test_, uniqueSuffix ) \ +{ \ +return @ name; \ +} \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Description_test_, uniqueSuffix ) \ +{ \ +return @ desc; \ +} \ +-(void) OC_MAKE_UNIQUE_NAME( Catch_TestCase_test_, uniqueSuffix ) + +#define OC_TEST_CASE( name, desc ) OC_TEST_CASE2( name, desc, __LINE__ ) + +// end catch_objc.hpp +#endif + +// Benchmarking needs the externally-facing parts of reporters to work +#if defined(CATCH_CONFIG_EXTERNAL_INTERFACES) || defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +// start catch_external_interfaces.h + +// start catch_reporter_bases.hpp + +// start catch_interfaces_reporter.h + +// start catch_config.hpp + +// start catch_test_spec_parser.h + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +// start catch_test_spec.h + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +// start catch_wildcard_pattern.h + +namespace Catch +{ + class WildcardPattern { + enum WildcardPosition { + NoWildcard = 0, + WildcardAtStart = 1, + WildcardAtEnd = 2, + WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd + }; + + public: + + WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity ); + virtual ~WildcardPattern() = default; + virtual bool matches( std::string const& str ) const; + + private: + std::string normaliseString( std::string const& str ) const; + CaseSensitive::Choice m_caseSensitivity; + WildcardPosition m_wildcard = NoWildcard; + std::string m_pattern; + }; +} + +// end catch_wildcard_pattern.h +#include <string> +#include <vector> +#include <memory> + +namespace Catch { + + struct IConfig; + + class TestSpec { + class Pattern { + public: + explicit Pattern( std::string const& name ); + virtual ~Pattern(); + virtual bool matches( TestCaseInfo const& testCase ) const = 0; + std::string const& name() const; + private: + std::string const m_name; + }; + using PatternPtr = std::shared_ptr<Pattern>; + + class NamePattern : public Pattern { + public: + explicit NamePattern( std::string const& name, std::string const& filterString ); + bool matches( TestCaseInfo const& testCase ) const override; + private: + WildcardPattern m_wildcardPattern; + }; + + class TagPattern : public Pattern { + public: + explicit TagPattern( std::string const& tag, std::string const& filterString ); + bool matches( TestCaseInfo const& testCase ) const override; + private: + std::string m_tag; + }; + + class ExcludedPattern : public Pattern { + public: + explicit ExcludedPattern( PatternPtr const& underlyingPattern ); + bool matches( TestCaseInfo const& testCase ) const override; + private: + PatternPtr m_underlyingPattern; + }; + + struct Filter { + std::vector<PatternPtr> m_patterns; + + bool matches( TestCaseInfo const& testCase ) const; + std::string name() const; + }; + + public: + struct FilterMatch { + std::string name; + std::vector<TestCase const*> tests; + }; + using Matches = std::vector<FilterMatch>; + using vectorStrings = std::vector<std::string>; + + bool hasFilters() const; + bool matches( TestCaseInfo const& testCase ) const; + Matches matchesByFilter( std::vector<TestCase> const& testCases, IConfig const& config ) const; + const vectorStrings & getInvalidArgs() const; + + private: + std::vector<Filter> m_filters; + std::vector<std::string> m_invalidArgs; + friend class TestSpecParser; + }; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_test_spec.h +// start catch_interfaces_tag_alias_registry.h + +#include <string> + +namespace Catch { + + struct TagAlias; + + struct ITagAliasRegistry { + virtual ~ITagAliasRegistry(); + // Nullptr if not present + virtual TagAlias const* find( std::string const& alias ) const = 0; + virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; + + static ITagAliasRegistry const& get(); + }; + +} // end namespace Catch + +// end catch_interfaces_tag_alias_registry.h +namespace Catch { + + class TestSpecParser { + enum Mode{ None, Name, QuotedName, Tag, EscapedName }; + Mode m_mode = None; + Mode lastMode = None; + bool m_exclusion = false; + std::size_t m_pos = 0; + std::size_t m_realPatternPos = 0; + std::string m_arg; + std::string m_substring; + std::string m_patternName; + std::vector<std::size_t> m_escapeChars; + TestSpec::Filter m_currentFilter; + TestSpec m_testSpec; + ITagAliasRegistry const* m_tagAliases = nullptr; + + public: + TestSpecParser( ITagAliasRegistry const& tagAliases ); + + TestSpecParser& parse( std::string const& arg ); + TestSpec testSpec(); + + private: + bool visitChar( char c ); + void startNewMode( Mode mode ); + bool processNoneChar( char c ); + void processNameChar( char c ); + bool processOtherChar( char c ); + void endMode(); + void escape(); + bool isControlChar( char c ) const; + void saveLastMode(); + void revertBackToLastMode(); + void addFilter(); + bool separate(); + + // Handles common preprocessing of the pattern for name/tag patterns + std::string preprocessPattern(); + // Adds the current pattern as a test name + void addNamePattern(); + // Adds the current pattern as a tag + void addTagPattern(); + + inline void addCharToPattern(char c) { + m_substring += c; + m_patternName += c; + m_realPatternPos++; + } + + }; + TestSpec parseTestSpec( std::string const& arg ); + +} // namespace Catch + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_test_spec_parser.h +// Libstdc++ doesn't like incomplete classes for unique_ptr + +#include <memory> +#include <vector> +#include <string> + +#ifndef CATCH_CONFIG_CONSOLE_WIDTH +#define CATCH_CONFIG_CONSOLE_WIDTH 80 +#endif + +namespace Catch { + + struct IStream; + + struct ConfigData { + bool listTests = false; + bool listTags = false; + bool listReporters = false; + bool listTestNamesOnly = false; + + bool showSuccessfulTests = false; + bool shouldDebugBreak = false; + bool noThrow = false; + bool showHelp = false; + bool showInvisibles = false; + bool filenamesAsTags = false; + bool libIdentify = false; + + int abortAfter = -1; + unsigned int rngSeed = 0; + + bool benchmarkNoAnalysis = false; + unsigned int benchmarkSamples = 100; + double benchmarkConfidenceInterval = 0.95; + unsigned int benchmarkResamples = 100000; + std::chrono::milliseconds::rep benchmarkWarmupTime = 100; + + Verbosity verbosity = Verbosity::Normal; + WarnAbout::What warnings = WarnAbout::Nothing; + ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter; + double minDuration = -1; + RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder; + UseColour::YesOrNo useColour = UseColour::Auto; + WaitForKeypress::When waitForKeypress = WaitForKeypress::Never; + + std::string outputFilename; + std::string name; + std::string processName; +#ifndef CATCH_CONFIG_DEFAULT_REPORTER +#define CATCH_CONFIG_DEFAULT_REPORTER "console" +#endif + std::string reporterName = CATCH_CONFIG_DEFAULT_REPORTER; +#undef CATCH_CONFIG_DEFAULT_REPORTER + + std::vector<std::string> testsOrTags; + std::vector<std::string> sectionsToRun; + }; + + class Config : public IConfig { + public: + + Config() = default; + Config( ConfigData const& data ); + virtual ~Config() = default; + + std::string const& getFilename() const; + + bool listTests() const; + bool listTestNamesOnly() const; + bool listTags() const; + bool listReporters() const; + + std::string getProcessName() const; + std::string const& getReporterName() const; + + std::vector<std::string> const& getTestsOrTags() const override; + std::vector<std::string> const& getSectionsToRun() const override; + + TestSpec const& testSpec() const override; + bool hasTestFilters() const override; + + bool showHelp() const; + + // IConfig interface + bool allowThrows() const override; + std::ostream& stream() const override; + std::string name() const override; + bool includeSuccessfulResults() const override; + bool warnAboutMissingAssertions() const override; + bool warnAboutNoTests() const override; + ShowDurations::OrNot showDurations() const override; + double minDuration() const override; + RunTests::InWhatOrder runOrder() const override; + unsigned int rngSeed() const override; + UseColour::YesOrNo useColour() const override; + bool shouldDebugBreak() const override; + int abortAfter() const override; + bool showInvisibles() const override; + Verbosity verbosity() const override; + bool benchmarkNoAnalysis() const override; + int benchmarkSamples() const override; + double benchmarkConfidenceInterval() const override; + unsigned int benchmarkResamples() const override; + std::chrono::milliseconds benchmarkWarmupTime() const override; + + private: + + IStream const* openStream(); + ConfigData m_data; + + std::unique_ptr<IStream const> m_stream; + TestSpec m_testSpec; + bool m_hasTestFilters = false; + }; + +} // end namespace Catch + +// end catch_config.hpp +// start catch_assertionresult.h + +#include <string> + +namespace Catch { + + struct AssertionResultData + { + AssertionResultData() = delete; + + AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); + + std::string message; + mutable std::string reconstructedExpression; + LazyExpression lazyExpression; + ResultWas::OfType resultType; + + std::string reconstructExpression() const; + }; + + class AssertionResult { + public: + AssertionResult() = delete; + AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); + + bool isOk() const; + bool succeeded() const; + ResultWas::OfType getResultType() const; + bool hasExpression() const; + bool hasMessage() const; + std::string getExpression() const; + std::string getExpressionInMacro() const; + bool hasExpandedExpression() const; + std::string getExpandedExpression() const; + std::string getMessage() const; + SourceLineInfo getSourceInfo() const; + StringRef getTestMacroName() const; + + //protected: + AssertionInfo m_info; + AssertionResultData m_resultData; + }; + +} // end namespace Catch + +// end catch_assertionresult.h +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +// start catch_estimate.hpp + + // Statistics estimates + + +namespace Catch { + namespace Benchmark { + template <typename Duration> + struct Estimate { + Duration point; + Duration lower_bound; + Duration upper_bound; + double confidence_interval; + + template <typename Duration2> + operator Estimate<Duration2>() const { + return { point, lower_bound, upper_bound, confidence_interval }; + } + }; + } // namespace Benchmark +} // namespace Catch + +// end catch_estimate.hpp +// start catch_outlier_classification.hpp + +// Outlier information + +namespace Catch { + namespace Benchmark { + struct OutlierClassification { + int samples_seen = 0; + int low_severe = 0; // more than 3 times IQR below Q1 + int low_mild = 0; // 1.5 to 3 times IQR below Q1 + int high_mild = 0; // 1.5 to 3 times IQR above Q3 + int high_severe = 0; // more than 3 times IQR above Q3 + + int total() const { + return low_severe + low_mild + high_mild + high_severe; + } + }; + } // namespace Benchmark +} // namespace Catch + +// end catch_outlier_classification.hpp + +#include <iterator> +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + +#include <string> +#include <iosfwd> +#include <map> +#include <set> +#include <memory> +#include <algorithm> + +namespace Catch { + + struct ReporterConfig { + explicit ReporterConfig( IConfigPtr const& _fullConfig ); + + ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ); + + std::ostream& stream() const; + IConfigPtr fullConfig() const; + + private: + std::ostream* m_stream; + IConfigPtr m_fullConfig; + }; + + struct ReporterPreferences { + bool shouldRedirectStdOut = false; + bool shouldReportAllAssertions = false; + }; + + template<typename T> + struct LazyStat : Option<T> { + LazyStat& operator=( T const& _value ) { + Option<T>::operator=( _value ); + used = false; + return *this; + } + void reset() { + Option<T>::reset(); + used = false; + } + bool used = false; + }; + + struct TestRunInfo { + TestRunInfo( std::string const& _name ); + std::string name; + }; + struct GroupInfo { + GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ); + + std::string name; + std::size_t groupIndex; + std::size_t groupsCounts; + }; + + struct AssertionStats { + AssertionStats( AssertionResult const& _assertionResult, + std::vector<MessageInfo> const& _infoMessages, + Totals const& _totals ); + + AssertionStats( AssertionStats const& ) = default; + AssertionStats( AssertionStats && ) = default; + AssertionStats& operator = ( AssertionStats const& ) = delete; + AssertionStats& operator = ( AssertionStats && ) = delete; + virtual ~AssertionStats(); + + AssertionResult assertionResult; + std::vector<MessageInfo> infoMessages; + Totals totals; + }; + + struct SectionStats { + SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ); + SectionStats( SectionStats const& ) = default; + SectionStats( SectionStats && ) = default; + SectionStats& operator = ( SectionStats const& ) = default; + SectionStats& operator = ( SectionStats && ) = default; + virtual ~SectionStats(); + + SectionInfo sectionInfo; + Counts assertions; + double durationInSeconds; + bool missingAssertions; + }; + + struct TestCaseStats { + TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ); + + TestCaseStats( TestCaseStats const& ) = default; + TestCaseStats( TestCaseStats && ) = default; + TestCaseStats& operator = ( TestCaseStats const& ) = default; + TestCaseStats& operator = ( TestCaseStats && ) = default; + virtual ~TestCaseStats(); + + TestCaseInfo testInfo; + Totals totals; + std::string stdOut; + std::string stdErr; + bool aborting; + }; + + struct TestGroupStats { + TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ); + TestGroupStats( GroupInfo const& _groupInfo ); + + TestGroupStats( TestGroupStats const& ) = default; + TestGroupStats( TestGroupStats && ) = default; + TestGroupStats& operator = ( TestGroupStats const& ) = default; + TestGroupStats& operator = ( TestGroupStats && ) = default; + virtual ~TestGroupStats(); + + GroupInfo groupInfo; + Totals totals; + bool aborting; + }; + + struct TestRunStats { + TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ); + + TestRunStats( TestRunStats const& ) = default; + TestRunStats( TestRunStats && ) = default; + TestRunStats& operator = ( TestRunStats const& ) = default; + TestRunStats& operator = ( TestRunStats && ) = default; + virtual ~TestRunStats(); + + TestRunInfo runInfo; + Totals totals; + bool aborting; + }; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + struct BenchmarkInfo { + std::string name; + double estimatedDuration; + int iterations; + int samples; + unsigned int resamples; + double clockResolution; + double clockCost; + }; + + template <class Duration> + struct BenchmarkStats { + BenchmarkInfo info; + + std::vector<Duration> samples; + Benchmark::Estimate<Duration> mean; + Benchmark::Estimate<Duration> standardDeviation; + Benchmark::OutlierClassification outliers; + double outlierVariance; + + template <typename Duration2> + operator BenchmarkStats<Duration2>() const { + std::vector<Duration2> samples2; + samples2.reserve(samples.size()); + std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); }); + return { + info, + std::move(samples2), + mean, + standardDeviation, + outliers, + outlierVariance, + }; + } + }; +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + struct IStreamingReporter { + virtual ~IStreamingReporter() = default; + + // Implementing class must also provide the following static methods: + // static std::string getDescription(); + // static std::set<Verbosity> getSupportedVerbosities() + + virtual ReporterPreferences getPreferences() const = 0; + + virtual void noMatchingTestCases( std::string const& spec ) = 0; + + virtual void reportInvalidArguments(std::string const&) {} + + virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; + virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; + + virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; + virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + virtual void benchmarkPreparing( std::string const& ) {} + virtual void benchmarkStarting( BenchmarkInfo const& ) {} + virtual void benchmarkEnded( BenchmarkStats<> const& ) {} + virtual void benchmarkFailed( std::string const& ) {} +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; + + // The return value indicates if the messages buffer should be cleared: + virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; + + virtual void sectionEnded( SectionStats const& sectionStats ) = 0; + virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; + virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; + virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; + + virtual void skipTest( TestCaseInfo const& testInfo ) = 0; + + // Default empty implementation provided + virtual void fatalErrorEncountered( StringRef name ); + + virtual bool isMulti() const; + }; + using IStreamingReporterPtr = std::unique_ptr<IStreamingReporter>; + + struct IReporterFactory { + virtual ~IReporterFactory(); + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const = 0; + virtual std::string getDescription() const = 0; + }; + using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>; + + struct IReporterRegistry { + using FactoryMap = std::map<std::string, IReporterFactoryPtr>; + using Listeners = std::vector<IReporterFactoryPtr>; + + virtual ~IReporterRegistry(); + virtual IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const = 0; + virtual FactoryMap const& getFactories() const = 0; + virtual Listeners const& getListeners() const = 0; + }; + +} // end namespace Catch + +// end catch_interfaces_reporter.h +#include <algorithm> +#include <cstring> +#include <cfloat> +#include <cstdio> +#include <cassert> +#include <memory> +#include <ostream> + +namespace Catch { + void prepareExpandedExpression(AssertionResult& result); + + // Returns double formatted as %.3f (format expected on output) + std::string getFormattedDuration( double duration ); + + //! Should the reporter show + bool shouldShowDuration( IConfig const& config, double duration ); + + std::string serializeFilters( std::vector<std::string> const& container ); + + template<typename DerivedT> + struct StreamingReporterBase : IStreamingReporter { + + StreamingReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = false; + if( !DerivedT::getSupportedVerbosities().count( m_config->verbosity() ) ) + CATCH_ERROR( "Verbosity level not supported by this reporter" ); + } + + ReporterPreferences getPreferences() const override { + return m_reporterPrefs; + } + + static std::set<Verbosity> getSupportedVerbosities() { + return { Verbosity::Normal }; + } + + ~StreamingReporterBase() override = default; + + void noMatchingTestCases(std::string const&) override {} + + void reportInvalidArguments(std::string const&) override {} + + void testRunStarting(TestRunInfo const& _testRunInfo) override { + currentTestRunInfo = _testRunInfo; + } + + void testGroupStarting(GroupInfo const& _groupInfo) override { + currentGroupInfo = _groupInfo; + } + + void testCaseStarting(TestCaseInfo const& _testInfo) override { + currentTestCaseInfo = _testInfo; + } + void sectionStarting(SectionInfo const& _sectionInfo) override { + m_sectionStack.push_back(_sectionInfo); + } + + void sectionEnded(SectionStats const& /* _sectionStats */) override { + m_sectionStack.pop_back(); + } + void testCaseEnded(TestCaseStats const& /* _testCaseStats */) override { + currentTestCaseInfo.reset(); + } + void testGroupEnded(TestGroupStats const& /* _testGroupStats */) override { + currentGroupInfo.reset(); + } + void testRunEnded(TestRunStats const& /* _testRunStats */) override { + currentTestCaseInfo.reset(); + currentGroupInfo.reset(); + currentTestRunInfo.reset(); + } + + void skipTest(TestCaseInfo const&) override { + // Don't do anything with this by default. + // It can optionally be overridden in the derived class. + } + + IConfigPtr m_config; + std::ostream& stream; + + LazyStat<TestRunInfo> currentTestRunInfo; + LazyStat<GroupInfo> currentGroupInfo; + LazyStat<TestCaseInfo> currentTestCaseInfo; + + std::vector<SectionInfo> m_sectionStack; + ReporterPreferences m_reporterPrefs; + }; + + template<typename DerivedT> + struct CumulativeReporterBase : IStreamingReporter { + template<typename T, typename ChildNodeT> + struct Node { + explicit Node( T const& _value ) : value( _value ) {} + virtual ~Node() {} + + using ChildNodes = std::vector<std::shared_ptr<ChildNodeT>>; + T value; + ChildNodes children; + }; + struct SectionNode { + explicit SectionNode(SectionStats const& _stats) : stats(_stats) {} + virtual ~SectionNode() = default; + + bool operator == (SectionNode const& other) const { + return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; + } + bool operator == (std::shared_ptr<SectionNode> const& other) const { + return operator==(*other); + } + + SectionStats stats; + using ChildSections = std::vector<std::shared_ptr<SectionNode>>; + using Assertions = std::vector<AssertionStats>; + ChildSections childSections; + Assertions assertions; + std::string stdOut; + std::string stdErr; + }; + + struct BySectionInfo { + BySectionInfo( SectionInfo const& other ) : m_other( other ) {} + BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {} + bool operator() (std::shared_ptr<SectionNode> const& node) const { + return ((node->stats.sectionInfo.name == m_other.name) && + (node->stats.sectionInfo.lineInfo == m_other.lineInfo)); + } + void operator=(BySectionInfo const&) = delete; + + private: + SectionInfo const& m_other; + }; + + using TestCaseNode = Node<TestCaseStats, SectionNode>; + using TestGroupNode = Node<TestGroupStats, TestCaseNode>; + using TestRunNode = Node<TestRunStats, TestGroupNode>; + + CumulativeReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = false; + if( !DerivedT::getSupportedVerbosities().count( m_config->verbosity() ) ) + CATCH_ERROR( "Verbosity level not supported by this reporter" ); + } + ~CumulativeReporterBase() override = default; + + ReporterPreferences getPreferences() const override { + return m_reporterPrefs; + } + + static std::set<Verbosity> getSupportedVerbosities() { + return { Verbosity::Normal }; + } + + void testRunStarting( TestRunInfo const& ) override {} + void testGroupStarting( GroupInfo const& ) override {} + + void testCaseStarting( TestCaseInfo const& ) override {} + + void sectionStarting( SectionInfo const& sectionInfo ) override { + SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); + std::shared_ptr<SectionNode> node; + if( m_sectionStack.empty() ) { + if( !m_rootSection ) + m_rootSection = std::make_shared<SectionNode>( incompleteStats ); + node = m_rootSection; + } + else { + SectionNode& parentNode = *m_sectionStack.back(); + auto it = + std::find_if( parentNode.childSections.begin(), + parentNode.childSections.end(), + BySectionInfo( sectionInfo ) ); + if( it == parentNode.childSections.end() ) { + node = std::make_shared<SectionNode>( incompleteStats ); + parentNode.childSections.push_back( node ); + } + else + node = *it; + } + m_sectionStack.push_back( node ); + m_deepestSection = std::move(node); + } + + void assertionStarting(AssertionInfo const&) override {} + + bool assertionEnded(AssertionStats const& assertionStats) override { + assert(!m_sectionStack.empty()); + // AssertionResult holds a pointer to a temporary DecomposedExpression, + // which getExpandedExpression() calls to build the expression string. + // Our section stack copy of the assertionResult will likely outlive the + // temporary, so it must be expanded or discarded now to avoid calling + // a destroyed object later. + prepareExpandedExpression(const_cast<AssertionResult&>( assertionStats.assertionResult ) ); + SectionNode& sectionNode = *m_sectionStack.back(); + sectionNode.assertions.push_back(assertionStats); + return true; + } + void sectionEnded(SectionStats const& sectionStats) override { + assert(!m_sectionStack.empty()); + SectionNode& node = *m_sectionStack.back(); + node.stats = sectionStats; + m_sectionStack.pop_back(); + } + void testCaseEnded(TestCaseStats const& testCaseStats) override { + auto node = std::make_shared<TestCaseNode>(testCaseStats); + assert(m_sectionStack.size() == 0); + node->children.push_back(m_rootSection); + m_testCases.push_back(node); + m_rootSection.reset(); + + assert(m_deepestSection); + m_deepestSection->stdOut = testCaseStats.stdOut; + m_deepestSection->stdErr = testCaseStats.stdErr; + } + void testGroupEnded(TestGroupStats const& testGroupStats) override { + auto node = std::make_shared<TestGroupNode>(testGroupStats); + node->children.swap(m_testCases); + m_testGroups.push_back(node); + } + void testRunEnded(TestRunStats const& testRunStats) override { + auto node = std::make_shared<TestRunNode>(testRunStats); + node->children.swap(m_testGroups); + m_testRuns.push_back(node); + testRunEndedCumulative(); + } + virtual void testRunEndedCumulative() = 0; + + void skipTest(TestCaseInfo const&) override {} + + IConfigPtr m_config; + std::ostream& stream; + std::vector<AssertionStats> m_assertions; + std::vector<std::vector<std::shared_ptr<SectionNode>>> m_sections; + std::vector<std::shared_ptr<TestCaseNode>> m_testCases; + std::vector<std::shared_ptr<TestGroupNode>> m_testGroups; + + std::vector<std::shared_ptr<TestRunNode>> m_testRuns; + + std::shared_ptr<SectionNode> m_rootSection; + std::shared_ptr<SectionNode> m_deepestSection; + std::vector<std::shared_ptr<SectionNode>> m_sectionStack; + ReporterPreferences m_reporterPrefs; + }; + + template<char C> + char const* getLineOfChars() { + static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0}; + if( !*line ) { + std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 ); + line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0; + } + return line; + } + + struct TestEventListenerBase : StreamingReporterBase<TestEventListenerBase> { + TestEventListenerBase( ReporterConfig const& _config ); + + static std::set<Verbosity> getSupportedVerbosities(); + + void assertionStarting(AssertionInfo const&) override; + bool assertionEnded(AssertionStats const&) override; + }; + +} // end namespace Catch + +// end catch_reporter_bases.hpp +// start catch_console_colour.h + +namespace Catch { + + struct Colour { + enum Code { + None = 0, + + White, + Red, + Green, + Blue, + Cyan, + Yellow, + Grey, + + Bright = 0x10, + + BrightRed = Bright | Red, + BrightGreen = Bright | Green, + LightGrey = Bright | Grey, + BrightWhite = Bright | White, + BrightYellow = Bright | Yellow, + + // By intention + FileName = LightGrey, + Warning = BrightYellow, + ResultError = BrightRed, + ResultSuccess = BrightGreen, + ResultExpectedFailure = Warning, + + Error = BrightRed, + Success = Green, + + OriginalExpression = Cyan, + ReconstructedExpression = BrightYellow, + + SecondaryText = LightGrey, + Headers = White + }; + + // Use constructed object for RAII guard + Colour( Code _colourCode ); + Colour( Colour&& other ) noexcept; + Colour& operator=( Colour&& other ) noexcept; + ~Colour(); + + // Use static method for one-shot changes + static void use( Code _colourCode ); + + private: + bool m_moved = false; + }; + + std::ostream& operator << ( std::ostream& os, Colour const& ); + +} // end namespace Catch + +// end catch_console_colour.h +// start catch_reporter_registrars.hpp + + +namespace Catch { + + template<typename T> + class ReporterRegistrar { + + class ReporterFactory : public IReporterFactory { + + IStreamingReporterPtr create( ReporterConfig const& config ) const override { + return std::unique_ptr<T>( new T( config ) ); + } + + std::string getDescription() const override { + return T::getDescription(); + } + }; + + public: + + explicit ReporterRegistrar( std::string const& name ) { + getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() ); + } + }; + + template<typename T> + class ListenerRegistrar { + + class ListenerFactory : public IReporterFactory { + + IStreamingReporterPtr create( ReporterConfig const& config ) const override { + return std::unique_ptr<T>( new T( config ) ); + } + std::string getDescription() const override { + return std::string(); + } + }; + + public: + + ListenerRegistrar() { + getMutableRegistryHub().registerListener( std::make_shared<ListenerFactory>() ); + } + }; +} + +#if !defined(CATCH_CONFIG_DISABLE) + +#define CATCH_REGISTER_REPORTER( name, reporterType ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +#define CATCH_REGISTER_LISTENER( listenerType ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +#else // CATCH_CONFIG_DISABLE + +#define CATCH_REGISTER_REPORTER(name, reporterType) +#define CATCH_REGISTER_LISTENER(listenerType) + +#endif // CATCH_CONFIG_DISABLE + +// end catch_reporter_registrars.hpp +// Allow users to base their work off existing reporters +// start catch_reporter_compact.h + +namespace Catch { + + struct CompactReporter : StreamingReporterBase<CompactReporter> { + + using StreamingReporterBase::StreamingReporterBase; + + ~CompactReporter() override; + + static std::string getDescription(); + + void noMatchingTestCases(std::string const& spec) override; + + void assertionStarting(AssertionInfo const&) override; + + bool assertionEnded(AssertionStats const& _assertionStats) override; + + void sectionEnded(SectionStats const& _sectionStats) override; + + void testRunEnded(TestRunStats const& _testRunStats) override; + + }; + +} // end namespace Catch + +// end catch_reporter_compact.h +// start catch_reporter_console.h + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled + // and default is missing) is enabled +#endif + +namespace Catch { + // Fwd decls + struct SummaryColumn; + class TablePrinter; + + struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> { + std::unique_ptr<TablePrinter> m_tablePrinter; + + ConsoleReporter(ReporterConfig const& config); + ~ConsoleReporter() override; + static std::string getDescription(); + + void noMatchingTestCases(std::string const& spec) override; + + void reportInvalidArguments(std::string const&arg) override; + + void assertionStarting(AssertionInfo const&) override; + + bool assertionEnded(AssertionStats const& _assertionStats) override; + + void sectionStarting(SectionInfo const& _sectionInfo) override; + void sectionEnded(SectionStats const& _sectionStats) override; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + void benchmarkPreparing(std::string const& name) override; + void benchmarkStarting(BenchmarkInfo const& info) override; + void benchmarkEnded(BenchmarkStats<> const& stats) override; + void benchmarkFailed(std::string const& error) override; +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + void testCaseEnded(TestCaseStats const& _testCaseStats) override; + void testGroupEnded(TestGroupStats const& _testGroupStats) override; + void testRunEnded(TestRunStats const& _testRunStats) override; + void testRunStarting(TestRunInfo const& _testRunInfo) override; + private: + + void lazyPrint(); + + void lazyPrintWithoutClosingBenchmarkTable(); + void lazyPrintRunInfo(); + void lazyPrintGroupInfo(); + void printTestCaseAndSectionHeader(); + + void printClosedHeader(std::string const& _name); + void printOpenHeader(std::string const& _name); + + // if string has a : in first line will set indent to follow it on + // subsequent lines + void printHeaderString(std::string const& _string, std::size_t indent = 0); + + void printTotals(Totals const& totals); + void printSummaryRow(std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row); + + void printTotalsDivider(Totals const& totals); + void printSummaryDivider(); + void printTestFilters(); + + private: + bool m_headerPrinted = false; + }; + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + +// end catch_reporter_console.h +// start catch_reporter_junit.h + +// start catch_xmlwriter.h + +#include <vector> + +namespace Catch { + enum class XmlFormatting { + None = 0x00, + Indent = 0x01, + Newline = 0x02, + }; + + XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs); + XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs); + + class XmlEncode { + public: + enum ForWhat { ForTextNodes, ForAttributes }; + + XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ); + + void encodeTo( std::ostream& os ) const; + + friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ); + + private: + std::string m_str; + ForWhat m_forWhat; + }; + + class XmlWriter { + public: + + class ScopedElement { + public: + ScopedElement( XmlWriter* writer, XmlFormatting fmt ); + + ScopedElement( ScopedElement&& other ) noexcept; + ScopedElement& operator=( ScopedElement&& other ) noexcept; + + ~ScopedElement(); + + ScopedElement& writeText( std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent ); + + template<typename T> + ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { + m_writer->writeAttribute( name, attribute ); + return *this; + } + + private: + mutable XmlWriter* m_writer = nullptr; + XmlFormatting m_fmt; + }; + + XmlWriter( std::ostream& os = Catch::cout() ); + ~XmlWriter(); + + XmlWriter( XmlWriter const& ) = delete; + XmlWriter& operator=( XmlWriter const& ) = delete; + + XmlWriter& startElement( std::string const& name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); + + ScopedElement scopedElement( std::string const& name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); + + XmlWriter& endElement(XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); + + XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ); + + XmlWriter& writeAttribute( std::string const& name, bool attribute ); + + template<typename T> + XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { + ReusableStringStream rss; + rss << attribute; + return writeAttribute( name, rss.str() ); + } + + XmlWriter& writeText( std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); + + XmlWriter& writeComment(std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); + + void writeStylesheetRef( std::string const& url ); + + XmlWriter& writeBlankLine(); + + void ensureTagClosed(); + + private: + + void applyFormatting(XmlFormatting fmt); + + void writeDeclaration(); + + void newlineIfNecessary(); + + bool m_tagIsOpen = false; + bool m_needsNewline = false; + std::vector<std::string> m_tags; + std::string m_indent; + std::ostream& m_os; + }; + +} + +// end catch_xmlwriter.h +namespace Catch { + + class JunitReporter : public CumulativeReporterBase<JunitReporter> { + public: + JunitReporter(ReporterConfig const& _config); + + ~JunitReporter() override; + + static std::string getDescription(); + + void noMatchingTestCases(std::string const& /*spec*/) override; + + void testRunStarting(TestRunInfo const& runInfo) override; + + void testGroupStarting(GroupInfo const& groupInfo) override; + + void testCaseStarting(TestCaseInfo const& testCaseInfo) override; + bool assertionEnded(AssertionStats const& assertionStats) override; + + void testCaseEnded(TestCaseStats const& testCaseStats) override; + + void testGroupEnded(TestGroupStats const& testGroupStats) override; + + void testRunEndedCumulative() override; + + void writeGroup(TestGroupNode const& groupNode, double suiteTime); + + void writeTestCase(TestCaseNode const& testCaseNode); + + void writeSection( std::string const& className, + std::string const& rootName, + SectionNode const& sectionNode, + bool testOkToFail ); + + void writeAssertions(SectionNode const& sectionNode); + void writeAssertion(AssertionStats const& stats); + + XmlWriter xml; + Timer suiteTimer; + std::string stdOutForSuite; + std::string stdErrForSuite; + unsigned int unexpectedExceptions = 0; + bool m_okToFail = false; + }; + +} // end namespace Catch + +// end catch_reporter_junit.h +// start catch_reporter_xml.h + +namespace Catch { + class XmlReporter : public StreamingReporterBase<XmlReporter> { + public: + XmlReporter(ReporterConfig const& _config); + + ~XmlReporter() override; + + static std::string getDescription(); + + virtual std::string getStylesheetRef() const; + + void writeSourceInfo(SourceLineInfo const& sourceInfo); + + public: // StreamingReporterBase + + void noMatchingTestCases(std::string const& s) override; + + void testRunStarting(TestRunInfo const& testInfo) override; + + void testGroupStarting(GroupInfo const& groupInfo) override; + + void testCaseStarting(TestCaseInfo const& testInfo) override; + + void sectionStarting(SectionInfo const& sectionInfo) override; + + void assertionStarting(AssertionInfo const&) override; + + bool assertionEnded(AssertionStats const& assertionStats) override; + + void sectionEnded(SectionStats const& sectionStats) override; + + void testCaseEnded(TestCaseStats const& testCaseStats) override; + + void testGroupEnded(TestGroupStats const& testGroupStats) override; + + void testRunEnded(TestRunStats const& testRunStats) override; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + void benchmarkPreparing(std::string const& name) override; + void benchmarkStarting(BenchmarkInfo const&) override; + void benchmarkEnded(BenchmarkStats<> const&) override; + void benchmarkFailed(std::string const&) override; +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + private: + Timer m_testCaseTimer; + XmlWriter m_xml; + int m_sectionDepth = 0; + }; + +} // end namespace Catch + +// end catch_reporter_xml.h + +// end catch_external_interfaces.h +#endif + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +// start catch_benchmarking_all.hpp + +// A proxy header that includes all of the benchmarking headers to allow +// concise include of the benchmarking features. You should prefer the +// individual includes in standard use. + +// start catch_benchmark.hpp + + // Benchmark + +// start catch_chronometer.hpp + +// User-facing chronometer + + +// start catch_clock.hpp + +// Clocks + + +#include <chrono> +#include <ratio> + +namespace Catch { + namespace Benchmark { + template <typename Clock> + using ClockDuration = typename Clock::duration; + template <typename Clock> + using FloatDuration = std::chrono::duration<double, typename Clock::period>; + + template <typename Clock> + using TimePoint = typename Clock::time_point; + + using default_clock = std::chrono::steady_clock; + + template <typename Clock> + struct now { + TimePoint<Clock> operator()() const { + return Clock::now(); + } + }; + + using fp_seconds = std::chrono::duration<double, std::ratio<1>>; + } // namespace Benchmark +} // namespace Catch + +// end catch_clock.hpp +// start catch_optimizer.hpp + + // Hinting the optimizer + + +#if defined(_MSC_VER) +# include <atomic> // atomic_thread_fence +#endif + +namespace Catch { + namespace Benchmark { +#if defined(__GNUC__) || defined(__clang__) + template <typename T> + inline void keep_memory(T* p) { + asm volatile("" : : "g"(p) : "memory"); + } + inline void keep_memory() { + asm volatile("" : : : "memory"); + } + + namespace Detail { + inline void optimizer_barrier() { keep_memory(); } + } // namespace Detail +#elif defined(_MSC_VER) + +#pragma optimize("", off) + template <typename T> + inline void keep_memory(T* p) { + // thanks @milleniumbug + *reinterpret_cast<char volatile*>(p) = *reinterpret_cast<char const volatile*>(p); + } + // TODO equivalent keep_memory() +#pragma optimize("", on) + + namespace Detail { + inline void optimizer_barrier() { + std::atomic_thread_fence(std::memory_order_seq_cst); + } + } // namespace Detail + +#endif + + template <typename T> + inline void deoptimize_value(T&& x) { + keep_memory(&x); + } + + template <typename Fn, typename... Args> + inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<!std::is_same<void, decltype(fn(args...))>::value>::type { + deoptimize_value(std::forward<Fn>(fn) (std::forward<Args...>(args...))); + } + + template <typename Fn, typename... Args> + inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<std::is_same<void, decltype(fn(args...))>::value>::type { + std::forward<Fn>(fn) (std::forward<Args...>(args...)); + } + } // namespace Benchmark +} // namespace Catch + +// end catch_optimizer.hpp +// start catch_complete_invoke.hpp + +// Invoke with a special case for void + + +#include <type_traits> +#include <utility> + +namespace Catch { + namespace Benchmark { + namespace Detail { + template <typename T> + struct CompleteType { using type = T; }; + template <> + struct CompleteType<void> { struct type {}; }; + + template <typename T> + using CompleteType_t = typename CompleteType<T>::type; + + template <typename Result> + struct CompleteInvoker { + template <typename Fun, typename... Args> + static Result invoke(Fun&& fun, Args&&... args) { + return std::forward<Fun>(fun)(std::forward<Args>(args)...); + } + }; + template <> + struct CompleteInvoker<void> { + template <typename Fun, typename... Args> + static CompleteType_t<void> invoke(Fun&& fun, Args&&... args) { + std::forward<Fun>(fun)(std::forward<Args>(args)...); + return {}; + } + }; + + // invoke and not return void :( + template <typename Fun, typename... Args> + CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) { + return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...); + } + + const std::string benchmarkErrorMsg = "a benchmark failed to run successfully"; + } // namespace Detail + + template <typename Fun> + Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) { + CATCH_TRY{ + return Detail::complete_invoke(std::forward<Fun>(fun)); + } CATCH_CATCH_ALL{ + getResultCapture().benchmarkFailed(translateActiveException()); + CATCH_RUNTIME_ERROR(Detail::benchmarkErrorMsg); + } + } + } // namespace Benchmark +} // namespace Catch + +// end catch_complete_invoke.hpp +namespace Catch { + namespace Benchmark { + namespace Detail { + struct ChronometerConcept { + virtual void start() = 0; + virtual void finish() = 0; + virtual ~ChronometerConcept() = default; + }; + template <typename Clock> + struct ChronometerModel final : public ChronometerConcept { + void start() override { started = Clock::now(); } + void finish() override { finished = Clock::now(); } + + ClockDuration<Clock> elapsed() const { return finished - started; } + + TimePoint<Clock> started; + TimePoint<Clock> finished; + }; + } // namespace Detail + + struct Chronometer { + public: + template <typename Fun> + void measure(Fun&& fun) { measure(std::forward<Fun>(fun), is_callable<Fun(int)>()); } + + int runs() const { return k; } + + Chronometer(Detail::ChronometerConcept& meter, int k) + : impl(&meter) + , k(k) {} + + private: + template <typename Fun> + void measure(Fun&& fun, std::false_type) { + measure([&fun](int) { return fun(); }, std::true_type()); + } + + template <typename Fun> + void measure(Fun&& fun, std::true_type) { + Detail::optimizer_barrier(); + impl->start(); + for (int i = 0; i < k; ++i) invoke_deoptimized(fun, i); + impl->finish(); + Detail::optimizer_barrier(); + } + + Detail::ChronometerConcept* impl; + int k; + }; + } // namespace Benchmark +} // namespace Catch + +// end catch_chronometer.hpp +// start catch_environment.hpp + +// Environment information + + +namespace Catch { + namespace Benchmark { + template <typename Duration> + struct EnvironmentEstimate { + Duration mean; + OutlierClassification outliers; + + template <typename Duration2> + operator EnvironmentEstimate<Duration2>() const { + return { mean, outliers }; + } + }; + template <typename Clock> + struct Environment { + using clock_type = Clock; + EnvironmentEstimate<FloatDuration<Clock>> clock_resolution; + EnvironmentEstimate<FloatDuration<Clock>> clock_cost; + }; + } // namespace Benchmark +} // namespace Catch + +// end catch_environment.hpp +// start catch_execution_plan.hpp + + // Execution plan + + +// start catch_benchmark_function.hpp + + // Dumb std::function implementation for consistent call overhead + + +#include <cassert> +#include <type_traits> +#include <utility> +#include <memory> + +namespace Catch { + namespace Benchmark { + namespace Detail { + template <typename T> + using Decay = typename std::decay<T>::type; + template <typename T, typename U> + struct is_related + : std::is_same<Decay<T>, Decay<U>> {}; + + /// We need to reinvent std::function because every piece of code that might add overhead + /// in a measurement context needs to have consistent performance characteristics so that we + /// can account for it in the measurement. + /// Implementations of std::function with optimizations that aren't always applicable, like + /// small buffer optimizations, are not uncommon. + /// This is effectively an implementation of std::function without any such optimizations; + /// it may be slow, but it is consistently slow. + struct BenchmarkFunction { + private: + struct callable { + virtual void call(Chronometer meter) const = 0; + virtual callable* clone() const = 0; + virtual ~callable() = default; + }; + template <typename Fun> + struct model : public callable { + model(Fun&& fun) : fun(std::move(fun)) {} + model(Fun const& fun) : fun(fun) {} + + model<Fun>* clone() const override { return new model<Fun>(*this); } + + void call(Chronometer meter) const override { + call(meter, is_callable<Fun(Chronometer)>()); + } + void call(Chronometer meter, std::true_type) const { + fun(meter); + } + void call(Chronometer meter, std::false_type) const { + meter.measure(fun); + } + + Fun fun; + }; + + struct do_nothing { void operator()() const {} }; + + template <typename T> + BenchmarkFunction(model<T>* c) : f(c) {} + + public: + BenchmarkFunction() + : f(new model<do_nothing>{ {} }) {} + + template <typename Fun, + typename std::enable_if<!is_related<Fun, BenchmarkFunction>::value, int>::type = 0> + BenchmarkFunction(Fun&& fun) + : f(new model<typename std::decay<Fun>::type>(std::forward<Fun>(fun))) {} + + BenchmarkFunction(BenchmarkFunction&& that) + : f(std::move(that.f)) {} + + BenchmarkFunction(BenchmarkFunction const& that) + : f(that.f->clone()) {} + + BenchmarkFunction& operator=(BenchmarkFunction&& that) { + f = std::move(that.f); + return *this; + } + + BenchmarkFunction& operator=(BenchmarkFunction const& that) { + f.reset(that.f->clone()); + return *this; + } + + void operator()(Chronometer meter) const { f->call(meter); } + + private: + std::unique_ptr<callable> f; + }; + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +// end catch_benchmark_function.hpp +// start catch_repeat.hpp + +// repeat algorithm + + +#include <type_traits> +#include <utility> + +namespace Catch { + namespace Benchmark { + namespace Detail { + template <typename Fun> + struct repeater { + void operator()(int k) const { + for (int i = 0; i < k; ++i) { + fun(); + } + } + Fun fun; + }; + template <typename Fun> + repeater<typename std::decay<Fun>::type> repeat(Fun&& fun) { + return { std::forward<Fun>(fun) }; + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +// end catch_repeat.hpp +// start catch_run_for_at_least.hpp + +// Run a function for a minimum amount of time + + +// start catch_measure.hpp + +// Measure + + +// start catch_timing.hpp + +// Timing + + +#include <tuple> +#include <type_traits> + +namespace Catch { + namespace Benchmark { + template <typename Duration, typename Result> + struct Timing { + Duration elapsed; + Result result; + int iterations; + }; + template <typename Clock, typename Func, typename... Args> + using TimingOf = Timing<ClockDuration<Clock>, Detail::CompleteType_t<FunctionReturnType<Func, Args...>>>; + } // namespace Benchmark +} // namespace Catch + +// end catch_timing.hpp +#include <utility> + +namespace Catch { + namespace Benchmark { + namespace Detail { + template <typename Clock, typename Fun, typename... Args> + TimingOf<Clock, Fun, Args...> measure(Fun&& fun, Args&&... args) { + auto start = Clock::now(); + auto&& r = Detail::complete_invoke(fun, std::forward<Args>(args)...); + auto end = Clock::now(); + auto delta = end - start; + return { delta, std::forward<decltype(r)>(r), 1 }; + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +// end catch_measure.hpp +#include <utility> +#include <type_traits> + +namespace Catch { + namespace Benchmark { + namespace Detail { + template <typename Clock, typename Fun> + TimingOf<Clock, Fun, int> measure_one(Fun&& fun, int iters, std::false_type) { + return Detail::measure<Clock>(fun, iters); + } + template <typename Clock, typename Fun> + TimingOf<Clock, Fun, Chronometer> measure_one(Fun&& fun, int iters, std::true_type) { + Detail::ChronometerModel<Clock> meter; + auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); + + return { meter.elapsed(), std::move(result), iters }; + } + + template <typename Clock, typename Fun> + using run_for_at_least_argument_t = typename std::conditional<is_callable<Fun(Chronometer)>::value, Chronometer, int>::type; + + struct optimized_away_error : std::exception { + const char* what() const noexcept override { + return "could not measure benchmark, maybe it was optimized away"; + } + }; + + template <typename Clock, typename Fun> + TimingOf<Clock, Fun, run_for_at_least_argument_t<Clock, Fun>> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) { + auto iters = seed; + while (iters < (1 << 30)) { + auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>()); + + if (Timing.elapsed >= how_long) { + return { Timing.elapsed, std::move(Timing.result), iters }; + } + iters *= 2; + } + Catch::throw_exception(optimized_away_error{}); + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +// end catch_run_for_at_least.hpp +#include <algorithm> +#include <iterator> + +namespace Catch { + namespace Benchmark { + template <typename Duration> + struct ExecutionPlan { + int iterations_per_sample; + Duration estimated_duration; + Detail::BenchmarkFunction benchmark; + Duration warmup_time; + int warmup_iterations; + + template <typename Duration2> + operator ExecutionPlan<Duration2>() const { + return { iterations_per_sample, estimated_duration, benchmark, warmup_time, warmup_iterations }; + } + + template <typename Clock> + std::vector<FloatDuration<Clock>> run(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const { + // warmup a bit + Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_iterations, Detail::repeat(now<Clock>{})); + + std::vector<FloatDuration<Clock>> times; + times.reserve(cfg.benchmarkSamples()); + std::generate_n(std::back_inserter(times), cfg.benchmarkSamples(), [this, env] { + Detail::ChronometerModel<Clock> model; + this->benchmark(Chronometer(model, iterations_per_sample)); + auto sample_time = model.elapsed() - env.clock_cost.mean; + if (sample_time < FloatDuration<Clock>::zero()) sample_time = FloatDuration<Clock>::zero(); + return sample_time / iterations_per_sample; + }); + return times; + } + }; + } // namespace Benchmark +} // namespace Catch + +// end catch_execution_plan.hpp +// start catch_estimate_clock.hpp + + // Environment measurement + + +// start catch_stats.hpp + +// Statistical analysis tools + + +#include <algorithm> +#include <functional> +#include <vector> +#include <iterator> +#include <numeric> +#include <tuple> +#include <cmath> +#include <utility> +#include <cstddef> +#include <random> + +namespace Catch { + namespace Benchmark { + namespace Detail { + using sample = std::vector<double>; + + double weighted_average_quantile(int k, int q, std::vector<double>::iterator first, std::vector<double>::iterator last); + + template <typename Iterator> + OutlierClassification classify_outliers(Iterator first, Iterator last) { + std::vector<double> copy(first, last); + + auto q1 = weighted_average_quantile(1, 4, copy.begin(), copy.end()); + auto q3 = weighted_average_quantile(3, 4, copy.begin(), copy.end()); + auto iqr = q3 - q1; + auto los = q1 - (iqr * 3.); + auto lom = q1 - (iqr * 1.5); + auto him = q3 + (iqr * 1.5); + auto his = q3 + (iqr * 3.); + + OutlierClassification o; + for (; first != last; ++first) { + auto&& t = *first; + if (t < los) ++o.low_severe; + else if (t < lom) ++o.low_mild; + else if (t > his) ++o.high_severe; + else if (t > him) ++o.high_mild; + ++o.samples_seen; + } + return o; + } + + template <typename Iterator> + double mean(Iterator first, Iterator last) { + auto count = last - first; + double sum = std::accumulate(first, last, 0.); + return sum / count; + } + + template <typename URng, typename Iterator, typename Estimator> + sample resample(URng& rng, int resamples, Iterator first, Iterator last, Estimator& estimator) { + auto n = last - first; + std::uniform_int_distribution<decltype(n)> dist(0, n - 1); + + sample out; + out.reserve(resamples); + std::generate_n(std::back_inserter(out), resamples, [n, first, &estimator, &dist, &rng] { + std::vector<double> resampled; + resampled.reserve(n); + std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[dist(rng)]; }); + return estimator(resampled.begin(), resampled.end()); + }); + std::sort(out.begin(), out.end()); + return out; + } + + template <typename Estimator, typename Iterator> + sample jackknife(Estimator&& estimator, Iterator first, Iterator last) { + auto n = last - first; + auto second = std::next(first); + sample results; + results.reserve(n); + + for (auto it = first; it != last; ++it) { + std::iter_swap(it, first); + results.push_back(estimator(second, last)); + } + + return results; + } + + inline double normal_cdf(double x) { + return std::erfc(-x / std::sqrt(2.0)) / 2.0; + } + + double erfc_inv(double x); + + double normal_quantile(double p); + + template <typename Iterator, typename Estimator> + Estimate<double> bootstrap(double confidence_level, Iterator first, Iterator last, sample const& resample, Estimator&& estimator) { + auto n_samples = last - first; + + double point = estimator(first, last); + // Degenerate case with a single sample + if (n_samples == 1) return { point, point, point, confidence_level }; + + sample jack = jackknife(estimator, first, last); + double jack_mean = mean(jack.begin(), jack.end()); + double sum_squares, sum_cubes; + std::tie(sum_squares, sum_cubes) = std::accumulate(jack.begin(), jack.end(), std::make_pair(0., 0.), [jack_mean](std::pair<double, double> sqcb, double x) -> std::pair<double, double> { + auto d = jack_mean - x; + auto d2 = d * d; + auto d3 = d2 * d; + return { sqcb.first + d2, sqcb.second + d3 }; + }); + + double accel = sum_cubes / (6 * std::pow(sum_squares, 1.5)); + int n = static_cast<int>(resample.size()); + double prob_n = std::count_if(resample.begin(), resample.end(), [point](double x) { return x < point; }) / (double)n; + // degenerate case with uniform samples + if (prob_n == 0) return { point, point, point, confidence_level }; + + double bias = normal_quantile(prob_n); + double z1 = normal_quantile((1. - confidence_level) / 2.); + + auto cumn = [n](double x) -> int { + return std::lround(normal_cdf(x) * n); }; + auto a = [bias, accel](double b) { return bias + b / (1. - accel * b); }; + double b1 = bias + z1; + double b2 = bias - z1; + double a1 = a(b1); + double a2 = a(b2); + auto lo = (std::max)(cumn(a1), 0); + auto hi = (std::min)(cumn(a2), n - 1); + + return { point, resample[lo], resample[hi], confidence_level }; + } + + double outlier_variance(Estimate<double> mean, Estimate<double> stddev, int n); + + struct bootstrap_analysis { + Estimate<double> mean; + Estimate<double> standard_deviation; + double outlier_variance; + }; + + bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last); + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +// end catch_stats.hpp +#include <algorithm> +#include <iterator> +#include <tuple> +#include <vector> +#include <cmath> + +namespace Catch { + namespace Benchmark { + namespace Detail { + template <typename Clock> + std::vector<double> resolution(int k) { + std::vector<TimePoint<Clock>> times; + times.reserve(k + 1); + std::generate_n(std::back_inserter(times), k + 1, now<Clock>{}); + + std::vector<double> deltas; + deltas.reserve(k); + std::transform(std::next(times.begin()), times.end(), times.begin(), + std::back_inserter(deltas), + [](TimePoint<Clock> a, TimePoint<Clock> b) { return static_cast<double>((a - b).count()); }); + + return deltas; + } + + const auto warmup_iterations = 10000; + const auto warmup_time = std::chrono::milliseconds(100); + const auto minimum_ticks = 1000; + const auto warmup_seed = 10000; + const auto clock_resolution_estimation_time = std::chrono::milliseconds(500); + const auto clock_cost_estimation_time_limit = std::chrono::seconds(1); + const auto clock_cost_estimation_tick_limit = 100000; + const auto clock_cost_estimation_time = std::chrono::milliseconds(10); + const auto clock_cost_estimation_iterations = 10000; + + template <typename Clock> + int warmup() { + return run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_seed, &resolution<Clock>) + .iterations; + } + template <typename Clock> + EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_resolution(int iterations) { + auto r = run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(clock_resolution_estimation_time), iterations, &resolution<Clock>) + .result; + return { + FloatDuration<Clock>(mean(r.begin(), r.end())), + classify_outliers(r.begin(), r.end()), + }; + } + template <typename Clock> + EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_cost(FloatDuration<Clock> resolution) { + auto time_limit = (std::min)( + resolution * clock_cost_estimation_tick_limit, + FloatDuration<Clock>(clock_cost_estimation_time_limit)); + auto time_clock = [](int k) { + return Detail::measure<Clock>([k] { + for (int i = 0; i < k; ++i) { + volatile auto ignored = Clock::now(); + (void)ignored; + } + }).elapsed; + }; + time_clock(1); + int iters = clock_cost_estimation_iterations; + auto&& r = run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(clock_cost_estimation_time), iters, time_clock); + std::vector<double> times; + int nsamples = static_cast<int>(std::ceil(time_limit / r.elapsed)); + times.reserve(nsamples); + std::generate_n(std::back_inserter(times), nsamples, [time_clock, &r] { + return static_cast<double>((time_clock(r.iterations) / r.iterations).count()); + }); + return { + FloatDuration<Clock>(mean(times.begin(), times.end())), + classify_outliers(times.begin(), times.end()), + }; + } + + template <typename Clock> + Environment<FloatDuration<Clock>> measure_environment() { + static Environment<FloatDuration<Clock>>* env = nullptr; + if (env) { + return *env; + } + + auto iters = Detail::warmup<Clock>(); + auto resolution = Detail::estimate_clock_resolution<Clock>(iters); + auto cost = Detail::estimate_clock_cost<Clock>(resolution.mean); + + env = new Environment<FloatDuration<Clock>>{ resolution, cost }; + return *env; + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +// end catch_estimate_clock.hpp +// start catch_analyse.hpp + + // Run and analyse one benchmark + + +// start catch_sample_analysis.hpp + +// Benchmark results + + +#include <algorithm> +#include <vector> +#include <string> +#include <iterator> + +namespace Catch { + namespace Benchmark { + template <typename Duration> + struct SampleAnalysis { + std::vector<Duration> samples; + Estimate<Duration> mean; + Estimate<Duration> standard_deviation; + OutlierClassification outliers; + double outlier_variance; + + template <typename Duration2> + operator SampleAnalysis<Duration2>() const { + std::vector<Duration2> samples2; + samples2.reserve(samples.size()); + std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); }); + return { + std::move(samples2), + mean, + standard_deviation, + outliers, + outlier_variance, + }; + } + }; + } // namespace Benchmark +} // namespace Catch + +// end catch_sample_analysis.hpp +#include <algorithm> +#include <iterator> +#include <vector> + +namespace Catch { + namespace Benchmark { + namespace Detail { + template <typename Duration, typename Iterator> + SampleAnalysis<Duration> analyse(const IConfig &cfg, Environment<Duration>, Iterator first, Iterator last) { + if (!cfg.benchmarkNoAnalysis()) { + std::vector<double> samples; + samples.reserve(last - first); + std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); }); + + auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end()); + auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end()); + + auto wrap_estimate = [](Estimate<double> e) { + return Estimate<Duration> { + Duration(e.point), + Duration(e.lower_bound), + Duration(e.upper_bound), + e.confidence_interval, + }; + }; + std::vector<Duration> samples2; + samples2.reserve(samples.size()); + std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); }); + return { + std::move(samples2), + wrap_estimate(analysis.mean), + wrap_estimate(analysis.standard_deviation), + outliers, + analysis.outlier_variance, + }; + } else { + std::vector<Duration> samples; + samples.reserve(last - first); + + Duration mean = Duration(0); + int i = 0; + for (auto it = first; it < last; ++it, ++i) { + samples.push_back(Duration(*it)); + mean += Duration(*it); + } + mean /= i; + + return { + std::move(samples), + Estimate<Duration>{mean, mean, mean, 0.0}, + Estimate<Duration>{Duration(0), Duration(0), Duration(0), 0.0}, + OutlierClassification{}, + 0.0 + }; + } + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +// end catch_analyse.hpp +#include <algorithm> +#include <functional> +#include <string> +#include <vector> +#include <cmath> + +namespace Catch { + namespace Benchmark { + struct Benchmark { + Benchmark(std::string &&name) + : name(std::move(name)) {} + + template <class FUN> + Benchmark(std::string &&name, FUN &&func) + : fun(std::move(func)), name(std::move(name)) {} + + template <typename Clock> + ExecutionPlan<FloatDuration<Clock>> prepare(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const { + auto min_time = env.clock_resolution.mean * Detail::minimum_ticks; + auto run_time = std::max(min_time, std::chrono::duration_cast<decltype(min_time)>(cfg.benchmarkWarmupTime())); + auto&& test = Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(run_time), 1, fun); + int new_iters = static_cast<int>(std::ceil(min_time * test.iterations / test.elapsed)); + return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast<FloatDuration<Clock>>(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; + } + + template <typename Clock = default_clock> + void run() { + IConfigPtr cfg = getCurrentContext().getConfig(); + + auto env = Detail::measure_environment<Clock>(); + + getResultCapture().benchmarkPreparing(name); + CATCH_TRY{ + auto plan = user_code([&] { + return prepare<Clock>(*cfg, env); + }); + + BenchmarkInfo info { + name, + plan.estimated_duration.count(), + plan.iterations_per_sample, + cfg->benchmarkSamples(), + cfg->benchmarkResamples(), + env.clock_resolution.mean.count(), + env.clock_cost.mean.count() + }; + + getResultCapture().benchmarkStarting(info); + + auto samples = user_code([&] { + return plan.template run<Clock>(*cfg, env); + }); + + auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end()); + BenchmarkStats<FloatDuration<Clock>> stats{ info, analysis.samples, analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; + getResultCapture().benchmarkEnded(stats); + + } CATCH_CATCH_ALL{ + if (translateActiveException() != Detail::benchmarkErrorMsg) // benchmark errors have been reported, otherwise rethrow. + std::rethrow_exception(std::current_exception()); + } + } + + // sets lambda to be used in fun *and* executes benchmark! + template <typename Fun, + typename std::enable_if<!Detail::is_related<Fun, Benchmark>::value, int>::type = 0> + Benchmark & operator=(Fun func) { + fun = Detail::BenchmarkFunction(func); + run(); + return *this; + } + + explicit operator bool() { + return true; + } + + private: + Detail::BenchmarkFunction fun; + std::string name; + }; + } +} // namespace Catch + +#define INTERNAL_CATCH_GET_1_ARG(arg1, arg2, ...) arg1 +#define INTERNAL_CATCH_GET_2_ARG(arg1, arg2, ...) arg2 + +#define INTERNAL_CATCH_BENCHMARK(BenchmarkName, name, benchmarkIndex)\ + if( Catch::Benchmark::Benchmark BenchmarkName{name} ) \ + BenchmarkName = [&](int benchmarkIndex) + +#define INTERNAL_CATCH_BENCHMARK_ADVANCED(BenchmarkName, name)\ + if( Catch::Benchmark::Benchmark BenchmarkName{name} ) \ + BenchmarkName = [&] + +// end catch_benchmark.hpp +// start catch_constructor.hpp + +// Constructor and destructor helpers + + +#include <type_traits> + +namespace Catch { + namespace Benchmark { + namespace Detail { + template <typename T, bool Destruct> + struct ObjectStorage + { + ObjectStorage() : data() {} + + ObjectStorage(const ObjectStorage& other) + { + new(&data) T(other.stored_object()); + } + + ObjectStorage(ObjectStorage&& other) + { + new(&data) T(std::move(other.stored_object())); + } + + ~ObjectStorage() { destruct_on_exit<T>(); } + + template <typename... Args> + void construct(Args&&... args) + { + new (&data) T(std::forward<Args>(args)...); + } + + template <bool AllowManualDestruction = !Destruct> + typename std::enable_if<AllowManualDestruction>::type destruct() + { + stored_object().~T(); + } + + private: + // If this is a constructor benchmark, destruct the underlying object + template <typename U> + void destruct_on_exit(typename std::enable_if<Destruct, U>::type* = 0) { destruct<true>(); } + // Otherwise, don't + template <typename U> + void destruct_on_exit(typename std::enable_if<!Destruct, U>::type* = 0) { } + + T& stored_object() { + return *static_cast<T*>(static_cast<void*>(&data)); + } + + T const& stored_object() const { + return *static_cast<T*>(static_cast<void*>(&data)); + } + + struct { alignas(T) unsigned char data[sizeof(T)]; } data; + }; + } + + template <typename T> + using storage_for = Detail::ObjectStorage<T, true>; + + template <typename T> + using destructable_object = Detail::ObjectStorage<T, false>; + } +} + +// end catch_constructor.hpp +// end catch_benchmarking_all.hpp +#endif + +#endif // ! CATCH_CONFIG_IMPL_ONLY + +#ifdef CATCH_IMPL +// start catch_impl.hpp + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +// Keep these here for external reporters +// start catch_test_case_tracker.h + +#include <string> +#include <vector> +#include <memory> + +namespace Catch { +namespace TestCaseTracking { + + struct NameAndLocation { + std::string name; + SourceLineInfo location; + + NameAndLocation( std::string const& _name, SourceLineInfo const& _location ); + friend bool operator==(NameAndLocation const& lhs, NameAndLocation const& rhs) { + return lhs.name == rhs.name + && lhs.location == rhs.location; + } + }; + + class ITracker; + + using ITrackerPtr = std::shared_ptr<ITracker>; + + class ITracker { + NameAndLocation m_nameAndLocation; + + public: + ITracker(NameAndLocation const& nameAndLoc) : + m_nameAndLocation(nameAndLoc) + {} + + // static queries + NameAndLocation const& nameAndLocation() const { + return m_nameAndLocation; + } + + virtual ~ITracker(); + + // dynamic queries + virtual bool isComplete() const = 0; // Successfully completed or failed + virtual bool isSuccessfullyCompleted() const = 0; + virtual bool isOpen() const = 0; // Started but not complete + virtual bool hasChildren() const = 0; + virtual bool hasStarted() const = 0; + + virtual ITracker& parent() = 0; + + // actions + virtual void close() = 0; // Successfully complete + virtual void fail() = 0; + virtual void markAsNeedingAnotherRun() = 0; + + virtual void addChild( ITrackerPtr const& child ) = 0; + virtual ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) = 0; + virtual void openChild() = 0; + + // Debug/ checking + virtual bool isSectionTracker() const = 0; + virtual bool isGeneratorTracker() const = 0; + }; + + class TrackerContext { + + enum RunState { + NotStarted, + Executing, + CompletedCycle + }; + + ITrackerPtr m_rootTracker; + ITracker* m_currentTracker = nullptr; + RunState m_runState = NotStarted; + + public: + + ITracker& startRun(); + void endRun(); + + void startCycle(); + void completeCycle(); + + bool completedCycle() const; + ITracker& currentTracker(); + void setCurrentTracker( ITracker* tracker ); + }; + + class TrackerBase : public ITracker { + protected: + enum CycleState { + NotStarted, + Executing, + ExecutingChildren, + NeedsAnotherRun, + CompletedSuccessfully, + Failed + }; + + using Children = std::vector<ITrackerPtr>; + TrackerContext& m_ctx; + ITracker* m_parent; + Children m_children; + CycleState m_runState = NotStarted; + + public: + TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); + + bool isComplete() const override; + bool isSuccessfullyCompleted() const override; + bool isOpen() const override; + bool hasChildren() const override; + bool hasStarted() const override { + return m_runState != NotStarted; + } + + void addChild( ITrackerPtr const& child ) override; + + ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) override; + ITracker& parent() override; + + void openChild() override; + + bool isSectionTracker() const override; + bool isGeneratorTracker() const override; + + void open(); + + void close() override; + void fail() override; + void markAsNeedingAnotherRun() override; + + private: + void moveToParent(); + void moveToThis(); + }; + + class SectionTracker : public TrackerBase { + std::vector<std::string> m_filters; + std::string m_trimmed_name; + public: + SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); + + bool isSectionTracker() const override; + + bool isComplete() const override; + + static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ); + + void tryOpen(); + + void addInitialFilters( std::vector<std::string> const& filters ); + void addNextFilters( std::vector<std::string> const& filters ); + //! Returns filters active in this tracker + std::vector<std::string> const& getFilters() const; + //! Returns whitespace-trimmed name of the tracked section + std::string const& trimmedName() const; + }; + +} // namespace TestCaseTracking + +using TestCaseTracking::ITracker; +using TestCaseTracking::TrackerContext; +using TestCaseTracking::SectionTracker; + +} // namespace Catch + +// end catch_test_case_tracker.h + +// start catch_leak_detector.h + +namespace Catch { + + struct LeakDetector { + LeakDetector(); + ~LeakDetector(); + }; + +} +// end catch_leak_detector.h +// Cpp files will be included in the single-header file here +// start catch_stats.cpp + +// Statistical analysis tools + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + +#include <cassert> +#include <random> + +#if defined(CATCH_CONFIG_USE_ASYNC) +#include <future> +#endif + +namespace { + double erf_inv(double x) { + // Code accompanying the article "Approximating the erfinv function" in GPU Computing Gems, Volume 2 + double w, p; + + w = -log((1.0 - x) * (1.0 + x)); + + if (w < 6.250000) { + w = w - 3.125000; + p = -3.6444120640178196996e-21; + p = -1.685059138182016589e-19 + p * w; + p = 1.2858480715256400167e-18 + p * w; + p = 1.115787767802518096e-17 + p * w; + p = -1.333171662854620906e-16 + p * w; + p = 2.0972767875968561637e-17 + p * w; + p = 6.6376381343583238325e-15 + p * w; + p = -4.0545662729752068639e-14 + p * w; + p = -8.1519341976054721522e-14 + p * w; + p = 2.6335093153082322977e-12 + p * w; + p = -1.2975133253453532498e-11 + p * w; + p = -5.4154120542946279317e-11 + p * w; + p = 1.051212273321532285e-09 + p * w; + p = -4.1126339803469836976e-09 + p * w; + p = -2.9070369957882005086e-08 + p * w; + p = 4.2347877827932403518e-07 + p * w; + p = -1.3654692000834678645e-06 + p * w; + p = -1.3882523362786468719e-05 + p * w; + p = 0.0001867342080340571352 + p * w; + p = -0.00074070253416626697512 + p * w; + p = -0.0060336708714301490533 + p * w; + p = 0.24015818242558961693 + p * w; + p = 1.6536545626831027356 + p * w; + } else if (w < 16.000000) { + w = sqrt(w) - 3.250000; + p = 2.2137376921775787049e-09; + p = 9.0756561938885390979e-08 + p * w; + p = -2.7517406297064545428e-07 + p * w; + p = 1.8239629214389227755e-08 + p * w; + p = 1.5027403968909827627e-06 + p * w; + p = -4.013867526981545969e-06 + p * w; + p = 2.9234449089955446044e-06 + p * w; + p = 1.2475304481671778723e-05 + p * w; + p = -4.7318229009055733981e-05 + p * w; + p = 6.8284851459573175448e-05 + p * w; + p = 2.4031110387097893999e-05 + p * w; + p = -0.0003550375203628474796 + p * w; + p = 0.00095328937973738049703 + p * w; + p = -0.0016882755560235047313 + p * w; + p = 0.0024914420961078508066 + p * w; + p = -0.0037512085075692412107 + p * w; + p = 0.005370914553590063617 + p * w; + p = 1.0052589676941592334 + p * w; + p = 3.0838856104922207635 + p * w; + } else { + w = sqrt(w) - 5.000000; + p = -2.7109920616438573243e-11; + p = -2.5556418169965252055e-10 + p * w; + p = 1.5076572693500548083e-09 + p * w; + p = -3.7894654401267369937e-09 + p * w; + p = 7.6157012080783393804e-09 + p * w; + p = -1.4960026627149240478e-08 + p * w; + p = 2.9147953450901080826e-08 + p * w; + p = -6.7711997758452339498e-08 + p * w; + p = 2.2900482228026654717e-07 + p * w; + p = -9.9298272942317002539e-07 + p * w; + p = 4.5260625972231537039e-06 + p * w; + p = -1.9681778105531670567e-05 + p * w; + p = 7.5995277030017761139e-05 + p * w; + p = -0.00021503011930044477347 + p * w; + p = -0.00013871931833623122026 + p * w; + p = 1.0103004648645343977 + p * w; + p = 4.8499064014085844221 + p * w; + } + return p * x; + } + + double standard_deviation(std::vector<double>::iterator first, std::vector<double>::iterator last) { + auto m = Catch::Benchmark::Detail::mean(first, last); + double variance = std::accumulate(first, last, 0., [m](double a, double b) { + double diff = b - m; + return a + diff * diff; + }) / (last - first); + return std::sqrt(variance); + } + +} + +namespace Catch { + namespace Benchmark { + namespace Detail { + + double weighted_average_quantile(int k, int q, std::vector<double>::iterator first, std::vector<double>::iterator last) { + auto count = last - first; + double idx = (count - 1) * k / static_cast<double>(q); + int j = static_cast<int>(idx); + double g = idx - j; + std::nth_element(first, first + j, last); + auto xj = first[j]; + if (g == 0) return xj; + + auto xj1 = *std::min_element(first + (j + 1), last); + return xj + g * (xj1 - xj); + } + + double erfc_inv(double x) { + return erf_inv(1.0 - x); + } + + double normal_quantile(double p) { + static const double ROOT_TWO = std::sqrt(2.0); + + double result = 0.0; + assert(p >= 0 && p <= 1); + if (p < 0 || p > 1) { + return result; + } + + result = -erfc_inv(2.0 * p); + // result *= normal distribution standard deviation (1.0) * sqrt(2) + result *= /*sd * */ ROOT_TWO; + // result += normal disttribution mean (0) + return result; + } + + double outlier_variance(Estimate<double> mean, Estimate<double> stddev, int n) { + double sb = stddev.point; + double mn = mean.point / n; + double mg_min = mn / 2.; + double sg = (std::min)(mg_min / 4., sb / std::sqrt(n)); + double sg2 = sg * sg; + double sb2 = sb * sb; + + auto c_max = [n, mn, sb2, sg2](double x) -> double { + double k = mn - x; + double d = k * k; + double nd = n * d; + double k0 = -n * nd; + double k1 = sb2 - n * sg2 + nd; + double det = k1 * k1 - 4 * sg2 * k0; + return (int)(-2. * k0 / (k1 + std::sqrt(det))); + }; + + auto var_out = [n, sb2, sg2](double c) { + double nc = n - c; + return (nc / n) * (sb2 - nc * sg2); + }; + + return (std::min)(var_out(1), var_out((std::min)(c_max(0.), c_max(mg_min)))) / sb2; + } + + bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last) { + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS + static std::random_device entropy; + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + + auto n = static_cast<int>(last - first); // seriously, one can't use integral types without hell in C++ + + auto mean = &Detail::mean<std::vector<double>::iterator>; + auto stddev = &standard_deviation; + +#if defined(CATCH_CONFIG_USE_ASYNC) + auto Estimate = [=](double(*f)(std::vector<double>::iterator, std::vector<double>::iterator)) { + auto seed = entropy(); + return std::async(std::launch::async, [=] { + std::mt19937 rng(seed); + auto resampled = resample(rng, n_resamples, first, last, f); + return bootstrap(confidence_level, first, last, resampled, f); + }); + }; + + auto mean_future = Estimate(mean); + auto stddev_future = Estimate(stddev); + + auto mean_estimate = mean_future.get(); + auto stddev_estimate = stddev_future.get(); +#else + auto Estimate = [=](double(*f)(std::vector<double>::iterator, std::vector<double>::iterator)) { + auto seed = entropy(); + std::mt19937 rng(seed); + auto resampled = resample(rng, n_resamples, first, last, f); + return bootstrap(confidence_level, first, last, resampled, f); + }; + + auto mean_estimate = Estimate(mean); + auto stddev_estimate = Estimate(stddev); +#endif // CATCH_USE_ASYNC + + double outlier_variance = Detail::outlier_variance(mean_estimate, stddev_estimate, n); + + return { mean_estimate, stddev_estimate, outlier_variance }; + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING +// end catch_stats.cpp +// start catch_approx.cpp + +#include <cmath> +#include <limits> + +namespace { + +// Performs equivalent check of std::fabs(lhs - rhs) <= margin +// But without the subtraction to allow for INFINITY in comparison +bool marginComparison(double lhs, double rhs, double margin) { + return (lhs + margin >= rhs) && (rhs + margin >= lhs); +} + +} + +namespace Catch { +namespace Detail { + + Approx::Approx ( double value ) + : m_epsilon( std::numeric_limits<float>::epsilon()*100 ), + m_margin( 0.0 ), + m_scale( 0.0 ), + m_value( value ) + {} + + Approx Approx::custom() { + return Approx( 0 ); + } + + Approx Approx::operator-() const { + auto temp(*this); + temp.m_value = -temp.m_value; + return temp; + } + + std::string Approx::toString() const { + ReusableStringStream rss; + rss << "Approx( " << ::Catch::Detail::stringify( m_value ) << " )"; + return rss.str(); + } + + bool Approx::equalityComparisonImpl(const double other) const { + // First try with fixed margin, then compute margin based on epsilon, scale and Approx's value + // Thanks to Richard Harris for his help refining the scaled margin value + return marginComparison(m_value, other, m_margin) + || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(std::isinf(m_value)? 0 : m_value))); + } + + void Approx::setMargin(double newMargin) { + CATCH_ENFORCE(newMargin >= 0, + "Invalid Approx::margin: " << newMargin << '.' + << " Approx::Margin has to be non-negative."); + m_margin = newMargin; + } + + void Approx::setEpsilon(double newEpsilon) { + CATCH_ENFORCE(newEpsilon >= 0 && newEpsilon <= 1.0, + "Invalid Approx::epsilon: " << newEpsilon << '.' + << " Approx::epsilon has to be in [0, 1]"); + m_epsilon = newEpsilon; + } + +} // end namespace Detail + +namespace literals { + Detail::Approx operator "" _a(long double val) { + return Detail::Approx(val); + } + Detail::Approx operator "" _a(unsigned long long val) { + return Detail::Approx(val); + } +} // end namespace literals + +std::string StringMaker<Catch::Detail::Approx>::convert(Catch::Detail::Approx const& value) { + return value.toString(); +} + +} // end namespace Catch +// end catch_approx.cpp +// start catch_assertionhandler.cpp + +// start catch_debugger.h + +namespace Catch { + bool isDebuggerActive(); +} + +#ifdef CATCH_PLATFORM_MAC + + #if defined(__i386__) || defined(__x86_64__) + #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ + #elif defined(__aarch64__) + #define CATCH_TRAP() __asm__(".inst 0xd43e0000") + #endif + +#elif defined(CATCH_PLATFORM_IPHONE) + + // use inline assembler + #if defined(__i386__) || defined(__x86_64__) + #define CATCH_TRAP() __asm__("int $3") + #elif defined(__aarch64__) + #define CATCH_TRAP() __asm__(".inst 0xd4200000") + #elif defined(__arm__) && !defined(__thumb__) + #define CATCH_TRAP() __asm__(".inst 0xe7f001f0") + #elif defined(__arm__) && defined(__thumb__) + #define CATCH_TRAP() __asm__(".inst 0xde01") + #endif + +#elif defined(CATCH_PLATFORM_LINUX) + // If we can use inline assembler, do it because this allows us to break + // directly at the location of the failing check instead of breaking inside + // raise() called from it, i.e. one stack frame below. + #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64)) + #define CATCH_TRAP() asm volatile ("int $3") /* NOLINT */ + #else // Fall back to the generic way. + #include <signal.h> + + #define CATCH_TRAP() raise(SIGTRAP) + #endif +#elif defined(_MSC_VER) + #define CATCH_TRAP() __debugbreak() +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) void __stdcall DebugBreak(); + #define CATCH_TRAP() DebugBreak() +#endif + +#ifndef CATCH_BREAK_INTO_DEBUGGER + #ifdef CATCH_TRAP + #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }() + #else + #define CATCH_BREAK_INTO_DEBUGGER() []{}() + #endif +#endif + +// end catch_debugger.h +// start catch_run_context.h + +// start catch_fatal_condition.h + +#include <cassert> + +namespace Catch { + + // Wrapper for platform-specific fatal error (signals/SEH) handlers + // + // Tries to be cooperative with other handlers, and not step over + // other handlers. This means that unknown structured exceptions + // are passed on, previous signal handlers are called, and so on. + // + // Can only be instantiated once, and assumes that once a signal + // is caught, the binary will end up terminating. Thus, there + class FatalConditionHandler { + bool m_started = false; + + // Install/disengage implementation for specific platform. + // Should be if-defed to work on current platform, can assume + // engage-disengage 1:1 pairing. + void engage_platform(); + void disengage_platform(); + public: + // Should also have platform-specific implementations as needed + FatalConditionHandler(); + ~FatalConditionHandler(); + + void engage() { + assert(!m_started && "Handler cannot be installed twice."); + m_started = true; + engage_platform(); + } + + void disengage() { + assert(m_started && "Handler cannot be uninstalled without being installed first"); + m_started = false; + disengage_platform(); + } + }; + + //! Simple RAII guard for (dis)engaging the FatalConditionHandler + class FatalConditionHandlerGuard { + FatalConditionHandler* m_handler; + public: + FatalConditionHandlerGuard(FatalConditionHandler* handler): + m_handler(handler) { + m_handler->engage(); + } + ~FatalConditionHandlerGuard() { + m_handler->disengage(); + } + }; + +} // end namespace Catch + +// end catch_fatal_condition.h +#include <string> + +namespace Catch { + + struct IMutableContext; + + /////////////////////////////////////////////////////////////////////////// + + class RunContext : public IResultCapture, public IRunner { + + public: + RunContext( RunContext const& ) = delete; + RunContext& operator =( RunContext const& ) = delete; + + explicit RunContext( IConfigPtr const& _config, IStreamingReporterPtr&& reporter ); + + ~RunContext() override; + + void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ); + void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ); + + Totals runTest(TestCase const& testCase); + + IConfigPtr config() const; + IStreamingReporter& reporter() const; + + public: // IResultCapture + + // Assertion handlers + void handleExpr + ( AssertionInfo const& info, + ITransientExpression const& expr, + AssertionReaction& reaction ) override; + void handleMessage + ( AssertionInfo const& info, + ResultWas::OfType resultType, + StringRef const& message, + AssertionReaction& reaction ) override; + void handleUnexpectedExceptionNotThrown + ( AssertionInfo const& info, + AssertionReaction& reaction ) override; + void handleUnexpectedInflightException + ( AssertionInfo const& info, + std::string const& message, + AssertionReaction& reaction ) override; + void handleIncomplete + ( AssertionInfo const& info ) override; + void handleNonExpr + ( AssertionInfo const &info, + ResultWas::OfType resultType, + AssertionReaction &reaction ) override; + + bool sectionStarted( SectionInfo const& sectionInfo, Counts& assertions ) override; + + void sectionEnded( SectionEndInfo const& endInfo ) override; + void sectionEndedEarly( SectionEndInfo const& endInfo ) override; + + auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& override; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + void benchmarkPreparing( std::string const& name ) override; + void benchmarkStarting( BenchmarkInfo const& info ) override; + void benchmarkEnded( BenchmarkStats<> const& stats ) override; + void benchmarkFailed( std::string const& error ) override; +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + void pushScopedMessage( MessageInfo const& message ) override; + void popScopedMessage( MessageInfo const& message ) override; + + void emplaceUnscopedMessage( MessageBuilder const& builder ) override; + + std::string getCurrentTestName() const override; + + const AssertionResult* getLastResult() const override; + + void exceptionEarlyReported() override; + + void handleFatalErrorCondition( StringRef message ) override; + + bool lastAssertionPassed() override; + + void assertionPassed() override; + + public: + // !TBD We need to do this another way! + bool aborting() const final; + + private: + + void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ); + void invokeActiveTestCase(); + + void resetAssertionInfo(); + bool testForMissingAssertions( Counts& assertions ); + + void assertionEnded( AssertionResult const& result ); + void reportExpr + ( AssertionInfo const &info, + ResultWas::OfType resultType, + ITransientExpression const *expr, + bool negated ); + + void populateReaction( AssertionReaction& reaction ); + + private: + + void handleUnfinishedSections(); + + TestRunInfo m_runInfo; + IMutableContext& m_context; + TestCase const* m_activeTestCase = nullptr; + ITracker* m_testCaseTracker = nullptr; + Option<AssertionResult> m_lastResult; + + IConfigPtr m_config; + Totals m_totals; + IStreamingReporterPtr m_reporter; + std::vector<MessageInfo> m_messages; + std::vector<ScopedMessage> m_messageScopes; /* Keeps owners of so-called unscoped messages. */ + AssertionInfo m_lastAssertionInfo; + std::vector<SectionEndInfo> m_unfinishedSections; + std::vector<ITracker*> m_activeSections; + TrackerContext m_trackerContext; + FatalConditionHandler m_fatalConditionhandler; + bool m_lastAssertionPassed = false; + bool m_shouldReportUnexpected = true; + bool m_includeSuccessfulResults; + }; + + void seedRng(IConfig const& config); + unsigned int rngSeed(); +} // end namespace Catch + +// end catch_run_context.h +namespace Catch { + + namespace { + auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& { + expr.streamReconstructedExpression( os ); + return os; + } + } + + LazyExpression::LazyExpression( bool isNegated ) + : m_isNegated( isNegated ) + {} + + LazyExpression::LazyExpression( LazyExpression const& other ) : m_isNegated( other.m_isNegated ) {} + + LazyExpression::operator bool() const { + return m_transientExpression != nullptr; + } + + auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream& { + if( lazyExpr.m_isNegated ) + os << "!"; + + if( lazyExpr ) { + if( lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression() ) + os << "(" << *lazyExpr.m_transientExpression << ")"; + else + os << *lazyExpr.m_transientExpression; + } + else { + os << "{** error - unchecked empty expression requested **}"; + } + return os; + } + + AssertionHandler::AssertionHandler + ( StringRef const& macroName, + SourceLineInfo const& lineInfo, + StringRef capturedExpression, + ResultDisposition::Flags resultDisposition ) + : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }, + m_resultCapture( getResultCapture() ) + {} + + void AssertionHandler::handleExpr( ITransientExpression const& expr ) { + m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); + } + void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef const& message) { + m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction ); + } + + auto AssertionHandler::allowThrows() const -> bool { + return getCurrentContext().getConfig()->allowThrows(); + } + + void AssertionHandler::complete() { + setCompleted(); + if( m_reaction.shouldDebugBreak ) { + + // If you find your debugger stopping you here then go one level up on the + // call-stack for the code that caused it (typically a failed assertion) + + // (To go back to the test and change execution, jump over the throw, next) + CATCH_BREAK_INTO_DEBUGGER(); + } + if (m_reaction.shouldThrow) { +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + throw Catch::TestFailureException(); +#else + CATCH_ERROR( "Test failure requires aborting test!" ); +#endif + } + } + void AssertionHandler::setCompleted() { + m_completed = true; + } + + void AssertionHandler::handleUnexpectedInflightException() { + m_resultCapture.handleUnexpectedInflightException( m_assertionInfo, Catch::translateActiveException(), m_reaction ); + } + + void AssertionHandler::handleExceptionThrownAsExpected() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + void AssertionHandler::handleExceptionNotThrownAsExpected() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + + void AssertionHandler::handleUnexpectedExceptionNotThrown() { + m_resultCapture.handleUnexpectedExceptionNotThrown( m_assertionInfo, m_reaction ); + } + + void AssertionHandler::handleThrowingCallSkipped() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + + // This is the overload that takes a string and infers the Equals matcher from it + // The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp + void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString ) { + handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString ); + } + +} // namespace Catch +// end catch_assertionhandler.cpp +// start catch_assertionresult.cpp + +namespace Catch { + AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression): + lazyExpression(_lazyExpression), + resultType(_resultType) {} + + std::string AssertionResultData::reconstructExpression() const { + + if( reconstructedExpression.empty() ) { + if( lazyExpression ) { + ReusableStringStream rss; + rss << lazyExpression; + reconstructedExpression = rss.str(); + } + } + return reconstructedExpression; + } + + AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) + : m_info( info ), + m_resultData( data ) + {} + + // Result was a success + bool AssertionResult::succeeded() const { + return Catch::isOk( m_resultData.resultType ); + } + + // Result was a success, or failure is suppressed + bool AssertionResult::isOk() const { + return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); + } + + ResultWas::OfType AssertionResult::getResultType() const { + return m_resultData.resultType; + } + + bool AssertionResult::hasExpression() const { + return !m_info.capturedExpression.empty(); + } + + bool AssertionResult::hasMessage() const { + return !m_resultData.message.empty(); + } + + std::string AssertionResult::getExpression() const { + // Possibly overallocating by 3 characters should be basically free + std::string expr; expr.reserve(m_info.capturedExpression.size() + 3); + if (isFalseTest(m_info.resultDisposition)) { + expr += "!("; + } + expr += m_info.capturedExpression; + if (isFalseTest(m_info.resultDisposition)) { + expr += ')'; + } + return expr; + } + + std::string AssertionResult::getExpressionInMacro() const { + std::string expr; + if( m_info.macroName.empty() ) + expr = static_cast<std::string>(m_info.capturedExpression); + else { + expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 ); + expr += m_info.macroName; + expr += "( "; + expr += m_info.capturedExpression; + expr += " )"; + } + return expr; + } + + bool AssertionResult::hasExpandedExpression() const { + return hasExpression() && getExpandedExpression() != getExpression(); + } + + std::string AssertionResult::getExpandedExpression() const { + std::string expr = m_resultData.reconstructExpression(); + return expr.empty() + ? getExpression() + : expr; + } + + std::string AssertionResult::getMessage() const { + return m_resultData.message; + } + SourceLineInfo AssertionResult::getSourceInfo() const { + return m_info.lineInfo; + } + + StringRef AssertionResult::getTestMacroName() const { + return m_info.macroName; + } + +} // end namespace Catch +// end catch_assertionresult.cpp +// start catch_capture_matchers.cpp + +namespace Catch { + + using StringMatcher = Matchers::Impl::MatcherBase<std::string>; + + // This is the general overload that takes a any string matcher + // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers + // the Equals matcher (so the header does not mention matchers) + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString ) { + std::string exceptionMessage = Catch::translateActiveException(); + MatchExpr<std::string, StringMatcher const&> expr( exceptionMessage, matcher, matcherString ); + handler.handleExpr( expr ); + } + +} // namespace Catch +// end catch_capture_matchers.cpp +// start catch_commandline.cpp + +// start catch_commandline.h + +// start catch_clara.h + +// Use Catch's value for console width (store Clara's off to the side, if present) +#ifdef CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#undef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#endif +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH-1 + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#pragma clang diagnostic ignored "-Wexit-time-destructors" +#pragma clang diagnostic ignored "-Wshadow" +#endif + +// start clara.hpp +// Copyright 2017 Two Blue Cubes Ltd. All rights reserved. +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See https://github.com/philsquared/Clara for more details + +// Clara v1.1.5 + + +#ifndef CATCH_CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_CONFIG_CONSOLE_WIDTH 80 +#endif + +#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CLARA_CONFIG_CONSOLE_WIDTH +#endif + +#ifndef CLARA_CONFIG_OPTIONAL_TYPE +#ifdef __has_include +#if __has_include(<optional>) && __cplusplus >= 201703L +#include <optional> +#define CLARA_CONFIG_OPTIONAL_TYPE std::optional +#endif +#endif +#endif + +// ----------- #included from clara_textflow.hpp ----------- + +// TextFlowCpp +// +// A single-header library for wrapping and laying out basic text, by Phil Nash +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This project is hosted at https://github.com/philsquared/textflowcpp + + +#include <cassert> +#include <ostream> +#include <sstream> +#include <vector> + +#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80 +#endif + +namespace Catch { +namespace clara { +namespace TextFlow { + +inline auto isWhitespace(char c) -> bool { + static std::string chars = " \t\n\r"; + return chars.find(c) != std::string::npos; +} +inline auto isBreakableBefore(char c) -> bool { + static std::string chars = "[({<|"; + return chars.find(c) != std::string::npos; +} +inline auto isBreakableAfter(char c) -> bool { + static std::string chars = "])}>.,:;*+-=&/\\"; + return chars.find(c) != std::string::npos; +} + +class Columns; + +class Column { + std::vector<std::string> m_strings; + size_t m_width = CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH; + size_t m_indent = 0; + size_t m_initialIndent = std::string::npos; + +public: + class iterator { + friend Column; + + Column const& m_column; + size_t m_stringIndex = 0; + size_t m_pos = 0; + + size_t m_len = 0; + size_t m_end = 0; + bool m_suffix = false; + + iterator(Column const& column, size_t stringIndex) + : m_column(column), + m_stringIndex(stringIndex) {} + + auto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; } + + auto isBoundary(size_t at) const -> bool { + assert(at > 0); + assert(at <= line().size()); + + return at == line().size() || + (isWhitespace(line()[at]) && !isWhitespace(line()[at - 1])) || + isBreakableBefore(line()[at]) || + isBreakableAfter(line()[at - 1]); + } + + void calcLength() { + assert(m_stringIndex < m_column.m_strings.size()); + + m_suffix = false; + auto width = m_column.m_width - indent(); + m_end = m_pos; + if (line()[m_pos] == '\n') { + ++m_end; + } + while (m_end < line().size() && line()[m_end] != '\n') + ++m_end; + + if (m_end < m_pos + width) { + m_len = m_end - m_pos; + } else { + size_t len = width; + while (len > 0 && !isBoundary(m_pos + len)) + --len; + while (len > 0 && isWhitespace(line()[m_pos + len - 1])) + --len; + + if (len > 0) { + m_len = len; + } else { + m_suffix = true; + m_len = width - 1; + } + } + } + + auto indent() const -> size_t { + auto initial = m_pos == 0 && m_stringIndex == 0 ? m_column.m_initialIndent : std::string::npos; + return initial == std::string::npos ? m_column.m_indent : initial; + } + + auto addIndentAndSuffix(std::string const &plain) const -> std::string { + return std::string(indent(), ' ') + (m_suffix ? plain + "-" : plain); + } + + public: + using difference_type = std::ptrdiff_t; + using value_type = std::string; + using pointer = value_type * ; + using reference = value_type & ; + using iterator_category = std::forward_iterator_tag; + + explicit iterator(Column const& column) : m_column(column) { + assert(m_column.m_width > m_column.m_indent); + assert(m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent); + calcLength(); + if (m_len == 0) + m_stringIndex++; // Empty string + } + + auto operator *() const -> std::string { + assert(m_stringIndex < m_column.m_strings.size()); + assert(m_pos <= m_end); + return addIndentAndSuffix(line().substr(m_pos, m_len)); + } + + auto operator ++() -> iterator& { + m_pos += m_len; + if (m_pos < line().size() && line()[m_pos] == '\n') + m_pos += 1; + else + while (m_pos < line().size() && isWhitespace(line()[m_pos])) + ++m_pos; + + if (m_pos == line().size()) { + m_pos = 0; + ++m_stringIndex; + } + if (m_stringIndex < m_column.m_strings.size()) + calcLength(); + return *this; + } + auto operator ++(int) -> iterator { + iterator prev(*this); + operator++(); + return prev; + } + + auto operator ==(iterator const& other) const -> bool { + return + m_pos == other.m_pos && + m_stringIndex == other.m_stringIndex && + &m_column == &other.m_column; + } + auto operator !=(iterator const& other) const -> bool { + return !operator==(other); + } + }; + using const_iterator = iterator; + + explicit Column(std::string const& text) { m_strings.push_back(text); } + + auto width(size_t newWidth) -> Column& { + assert(newWidth > 0); + m_width = newWidth; + return *this; + } + auto indent(size_t newIndent) -> Column& { + m_indent = newIndent; + return *this; + } + auto initialIndent(size_t newIndent) -> Column& { + m_initialIndent = newIndent; + return *this; + } + + auto width() const -> size_t { return m_width; } + auto begin() const -> iterator { return iterator(*this); } + auto end() const -> iterator { return { *this, m_strings.size() }; } + + inline friend std::ostream& operator << (std::ostream& os, Column const& col) { + bool first = true; + for (auto line : col) { + if (first) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto operator + (Column const& other)->Columns; + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } +}; + +class Spacer : public Column { + +public: + explicit Spacer(size_t spaceWidth) : Column("") { + width(spaceWidth); + } +}; + +class Columns { + std::vector<Column> m_columns; + +public: + + class iterator { + friend Columns; + struct EndTag {}; + + std::vector<Column> const& m_columns; + std::vector<Column::iterator> m_iterators; + size_t m_activeIterators; + + iterator(Columns const& columns, EndTag) + : m_columns(columns.m_columns), + m_activeIterators(0) { + m_iterators.reserve(m_columns.size()); + + for (auto const& col : m_columns) + m_iterators.push_back(col.end()); + } + + public: + using difference_type = std::ptrdiff_t; + using value_type = std::string; + using pointer = value_type * ; + using reference = value_type & ; + using iterator_category = std::forward_iterator_tag; + + explicit iterator(Columns const& columns) + : m_columns(columns.m_columns), + m_activeIterators(m_columns.size()) { + m_iterators.reserve(m_columns.size()); + + for (auto const& col : m_columns) + m_iterators.push_back(col.begin()); + } + + auto operator ==(iterator const& other) const -> bool { + return m_iterators == other.m_iterators; + } + auto operator !=(iterator const& other) const -> bool { + return m_iterators != other.m_iterators; + } + auto operator *() const -> std::string { + std::string row, padding; + + for (size_t i = 0; i < m_columns.size(); ++i) { + auto width = m_columns[i].width(); + if (m_iterators[i] != m_columns[i].end()) { + std::string col = *m_iterators[i]; + row += padding + col; + if (col.size() < width) + padding = std::string(width - col.size(), ' '); + else + padding = ""; + } else { + padding += std::string(width, ' '); + } + } + return row; + } + auto operator ++() -> iterator& { + for (size_t i = 0; i < m_columns.size(); ++i) { + if (m_iterators[i] != m_columns[i].end()) + ++m_iterators[i]; + } + return *this; + } + auto operator ++(int) -> iterator { + iterator prev(*this); + operator++(); + return prev; + } + }; + using const_iterator = iterator; + + auto begin() const -> iterator { return iterator(*this); } + auto end() const -> iterator { return { *this, iterator::EndTag() }; } + + auto operator += (Column const& col) -> Columns& { + m_columns.push_back(col); + return *this; + } + auto operator + (Column const& col) -> Columns { + Columns combined = *this; + combined += col; + return combined; + } + + inline friend std::ostream& operator << (std::ostream& os, Columns const& cols) { + + bool first = true; + for (auto line : cols) { + if (first) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } +}; + +inline auto Column::operator + (Column const& other) -> Columns { + Columns cols; + cols += *this; + cols += other; + return cols; +} +} + +} +} + +// ----------- end of #include from clara_textflow.hpp ----------- +// ........... back in clara.hpp + +#include <cctype> +#include <string> +#include <memory> +#include <set> +#include <algorithm> + +#if !defined(CATCH_PLATFORM_WINDOWS) && ( defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) ) +#define CATCH_PLATFORM_WINDOWS +#endif + +namespace Catch { namespace clara { +namespace detail { + + // Traits for extracting arg and return type of lambdas (for single argument lambdas) + template<typename L> + struct UnaryLambdaTraits : UnaryLambdaTraits<decltype( &L::operator() )> {}; + + template<typename ClassT, typename ReturnT, typename... Args> + struct UnaryLambdaTraits<ReturnT( ClassT::* )( Args... ) const> { + static const bool isValid = false; + }; + + template<typename ClassT, typename ReturnT, typename ArgT> + struct UnaryLambdaTraits<ReturnT( ClassT::* )( ArgT ) const> { + static const bool isValid = true; + using ArgType = typename std::remove_const<typename std::remove_reference<ArgT>::type>::type; + using ReturnType = ReturnT; + }; + + class TokenStream; + + // Transport for raw args (copied from main args, or supplied via init list for testing) + class Args { + friend TokenStream; + std::string m_exeName; + std::vector<std::string> m_args; + + public: + Args( int argc, char const* const* argv ) + : m_exeName(argv[0]), + m_args(argv + 1, argv + argc) {} + + Args( std::initializer_list<std::string> args ) + : m_exeName( *args.begin() ), + m_args( args.begin()+1, args.end() ) + {} + + auto exeName() const -> std::string { + return m_exeName; + } + }; + + // Wraps a token coming from a token stream. These may not directly correspond to strings as a single string + // may encode an option + its argument if the : or = form is used + enum class TokenType { + Option, Argument + }; + struct Token { + TokenType type; + std::string token; + }; + + inline auto isOptPrefix( char c ) -> bool { + return c == '-' +#ifdef CATCH_PLATFORM_WINDOWS + || c == '/' +#endif + ; + } + + // Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled + class TokenStream { + using Iterator = std::vector<std::string>::const_iterator; + Iterator it; + Iterator itEnd; + std::vector<Token> m_tokenBuffer; + + void loadBuffer() { + m_tokenBuffer.resize( 0 ); + + // Skip any empty strings + while( it != itEnd && it->empty() ) + ++it; + + if( it != itEnd ) { + auto const &next = *it; + if( isOptPrefix( next[0] ) ) { + auto delimiterPos = next.find_first_of( " :=" ); + if( delimiterPos != std::string::npos ) { + m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); + m_tokenBuffer.push_back( { TokenType::Argument, next.substr( delimiterPos + 1 ) } ); + } else { + if( next[1] != '-' && next.size() > 2 ) { + std::string opt = "- "; + for( size_t i = 1; i < next.size(); ++i ) { + opt[1] = next[i]; + m_tokenBuffer.push_back( { TokenType::Option, opt } ); + } + } else { + m_tokenBuffer.push_back( { TokenType::Option, next } ); + } + } + } else { + m_tokenBuffer.push_back( { TokenType::Argument, next } ); + } + } + } + + public: + explicit TokenStream( Args const &args ) : TokenStream( args.m_args.begin(), args.m_args.end() ) {} + + TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( itEnd ) { + loadBuffer(); + } + + explicit operator bool() const { + return !m_tokenBuffer.empty() || it != itEnd; + } + + auto count() const -> size_t { return m_tokenBuffer.size() + (itEnd - it); } + + auto operator*() const -> Token { + assert( !m_tokenBuffer.empty() ); + return m_tokenBuffer.front(); + } + + auto operator->() const -> Token const * { + assert( !m_tokenBuffer.empty() ); + return &m_tokenBuffer.front(); + } + + auto operator++() -> TokenStream & { + if( m_tokenBuffer.size() >= 2 ) { + m_tokenBuffer.erase( m_tokenBuffer.begin() ); + } else { + if( it != itEnd ) + ++it; + loadBuffer(); + } + return *this; + } + }; + + class ResultBase { + public: + enum Type { + Ok, LogicError, RuntimeError + }; + + protected: + ResultBase( Type type ) : m_type( type ) {} + virtual ~ResultBase() = default; + + virtual void enforceOk() const = 0; + + Type m_type; + }; + + template<typename T> + class ResultValueBase : public ResultBase { + public: + auto value() const -> T const & { + enforceOk(); + return m_value; + } + + protected: + ResultValueBase( Type type ) : ResultBase( type ) {} + + ResultValueBase( ResultValueBase const &other ) : ResultBase( other ) { + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + } + + ResultValueBase( Type, T const &value ) : ResultBase( Ok ) { + new( &m_value ) T( value ); + } + + auto operator=( ResultValueBase const &other ) -> ResultValueBase & { + if( m_type == ResultBase::Ok ) + m_value.~T(); + ResultBase::operator=(other); + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + return *this; + } + + ~ResultValueBase() override { + if( m_type == Ok ) + m_value.~T(); + } + + union { + T m_value; + }; + }; + + template<> + class ResultValueBase<void> : public ResultBase { + protected: + using ResultBase::ResultBase; + }; + + template<typename T = void> + class BasicResult : public ResultValueBase<T> { + public: + template<typename U> + explicit BasicResult( BasicResult<U> const &other ) + : ResultValueBase<T>( other.type() ), + m_errorMessage( other.errorMessage() ) + { + assert( type() != ResultBase::Ok ); + } + + template<typename U> + static auto ok( U const &value ) -> BasicResult { return { ResultBase::Ok, value }; } + static auto ok() -> BasicResult { return { ResultBase::Ok }; } + static auto logicError( std::string const &message ) -> BasicResult { return { ResultBase::LogicError, message }; } + static auto runtimeError( std::string const &message ) -> BasicResult { return { ResultBase::RuntimeError, message }; } + + explicit operator bool() const { return m_type == ResultBase::Ok; } + auto type() const -> ResultBase::Type { return m_type; } + auto errorMessage() const -> std::string { return m_errorMessage; } + + protected: + void enforceOk() const override { + + // Errors shouldn't reach this point, but if they do + // the actual error message will be in m_errorMessage + assert( m_type != ResultBase::LogicError ); + assert( m_type != ResultBase::RuntimeError ); + if( m_type != ResultBase::Ok ) + std::abort(); + } + + std::string m_errorMessage; // Only populated if resultType is an error + + BasicResult( ResultBase::Type type, std::string const &message ) + : ResultValueBase<T>(type), + m_errorMessage(message) + { + assert( m_type != ResultBase::Ok ); + } + + using ResultValueBase<T>::ResultValueBase; + using ResultBase::m_type; + }; + + enum class ParseResultType { + Matched, NoMatch, ShortCircuitAll, ShortCircuitSame + }; + + class ParseState { + public: + + ParseState( ParseResultType type, TokenStream const &remainingTokens ) + : m_type(type), + m_remainingTokens( remainingTokens ) + {} + + auto type() const -> ParseResultType { return m_type; } + auto remainingTokens() const -> TokenStream { return m_remainingTokens; } + + private: + ParseResultType m_type; + TokenStream m_remainingTokens; + }; + + using Result = BasicResult<void>; + using ParserResult = BasicResult<ParseResultType>; + using InternalParseResult = BasicResult<ParseState>; + + struct HelpColumns { + std::string left; + std::string right; + }; + + template<typename T> + inline auto convertInto( std::string const &source, T& target ) -> ParserResult { + std::stringstream ss; + ss << source; + ss >> target; + if( ss.fail() ) + return ParserResult::runtimeError( "Unable to convert '" + source + "' to destination type" ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, std::string& target ) -> ParserResult { + target = source; + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { + std::string srcLC = source; + std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( unsigned char c ) { return static_cast<char>( std::tolower(c) ); } ); + if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") + target = true; + else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") + target = false; + else + return ParserResult::runtimeError( "Expected a boolean value but did not recognise: '" + source + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + } +#ifdef CLARA_CONFIG_OPTIONAL_TYPE + template<typename T> + inline auto convertInto( std::string const &source, CLARA_CONFIG_OPTIONAL_TYPE<T>& target ) -> ParserResult { + T temp; + auto result = convertInto( source, temp ); + if( result ) + target = std::move(temp); + return result; + } +#endif // CLARA_CONFIG_OPTIONAL_TYPE + + struct NonCopyable { + NonCopyable() = default; + NonCopyable( NonCopyable const & ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable &operator=( NonCopyable const & ) = delete; + NonCopyable &operator=( NonCopyable && ) = delete; + }; + + struct BoundRef : NonCopyable { + virtual ~BoundRef() = default; + virtual auto isContainer() const -> bool { return false; } + virtual auto isFlag() const -> bool { return false; } + }; + struct BoundValueRefBase : BoundRef { + virtual auto setValue( std::string const &arg ) -> ParserResult = 0; + }; + struct BoundFlagRefBase : BoundRef { + virtual auto setFlag( bool flag ) -> ParserResult = 0; + virtual auto isFlag() const -> bool { return true; } + }; + + template<typename T> + struct BoundValueRef : BoundValueRefBase { + T &m_ref; + + explicit BoundValueRef( T &ref ) : m_ref( ref ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return convertInto( arg, m_ref ); + } + }; + + template<typename T> + struct BoundValueRef<std::vector<T>> : BoundValueRefBase { + std::vector<T> &m_ref; + + explicit BoundValueRef( std::vector<T> &ref ) : m_ref( ref ) {} + + auto isContainer() const -> bool override { return true; } + + auto setValue( std::string const &arg ) -> ParserResult override { + T temp; + auto result = convertInto( arg, temp ); + if( result ) + m_ref.push_back( temp ); + return result; + } + }; + + struct BoundFlagRef : BoundFlagRefBase { + bool &m_ref; + + explicit BoundFlagRef( bool &ref ) : m_ref( ref ) {} + + auto setFlag( bool flag ) -> ParserResult override { + m_ref = flag; + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template<typename ReturnType> + struct LambdaInvoker { + static_assert( std::is_same<ReturnType, ParserResult>::value, "Lambda must return void or clara::ParserResult" ); + + template<typename L, typename ArgType> + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + return lambda( arg ); + } + }; + + template<> + struct LambdaInvoker<void> { + template<typename L, typename ArgType> + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + lambda( arg ); + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template<typename ArgType, typename L> + inline auto invokeLambda( L const &lambda, std::string const &arg ) -> ParserResult { + ArgType temp{}; + auto result = convertInto( arg, temp ); + return !result + ? result + : LambdaInvoker<typename UnaryLambdaTraits<L>::ReturnType>::invoke( lambda, temp ); + } + + template<typename L> + struct BoundLambda : BoundValueRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits<L>::isValid, "Supplied lambda must take exactly one argument" ); + explicit BoundLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return invokeLambda<typename UnaryLambdaTraits<L>::ArgType>( m_lambda, arg ); + } + }; + + template<typename L> + struct BoundFlagLambda : BoundFlagRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits<L>::isValid, "Supplied lambda must take exactly one argument" ); + static_assert( std::is_same<typename UnaryLambdaTraits<L>::ArgType, bool>::value, "flags must be boolean" ); + + explicit BoundFlagLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setFlag( bool flag ) -> ParserResult override { + return LambdaInvoker<typename UnaryLambdaTraits<L>::ReturnType>::invoke( m_lambda, flag ); + } + }; + + enum class Optionality { Optional, Required }; + + struct Parser; + + class ParserBase { + public: + virtual ~ParserBase() = default; + virtual auto validate() const -> Result { return Result::ok(); } + virtual auto parse( std::string const& exeName, TokenStream const &tokens) const -> InternalParseResult = 0; + virtual auto cardinality() const -> size_t { return 1; } + + auto parse( Args const &args ) const -> InternalParseResult { + return parse( args.exeName(), TokenStream( args ) ); + } + }; + + template<typename DerivedT> + class ComposableParserImpl : public ParserBase { + public: + template<typename T> + auto operator|( T const &other ) const -> Parser; + + template<typename T> + auto operator+( T const &other ) const -> Parser; + }; + + // Common code and state for Args and Opts + template<typename DerivedT> + class ParserRefImpl : public ComposableParserImpl<DerivedT> { + protected: + Optionality m_optionality = Optionality::Optional; + std::shared_ptr<BoundRef> m_ref; + std::string m_hint; + std::string m_description; + + explicit ParserRefImpl( std::shared_ptr<BoundRef> const &ref ) : m_ref( ref ) {} + + public: + template<typename T> + ParserRefImpl( T &ref, std::string const &hint ) + : m_ref( std::make_shared<BoundValueRef<T>>( ref ) ), + m_hint( hint ) + {} + + template<typename LambdaT> + ParserRefImpl( LambdaT const &ref, std::string const &hint ) + : m_ref( std::make_shared<BoundLambda<LambdaT>>( ref ) ), + m_hint(hint) + {} + + auto operator()( std::string const &description ) -> DerivedT & { + m_description = description; + return static_cast<DerivedT &>( *this ); + } + + auto optional() -> DerivedT & { + m_optionality = Optionality::Optional; + return static_cast<DerivedT &>( *this ); + }; + + auto required() -> DerivedT & { + m_optionality = Optionality::Required; + return static_cast<DerivedT &>( *this ); + }; + + auto isOptional() const -> bool { + return m_optionality == Optionality::Optional; + } + + auto cardinality() const -> size_t override { + if( m_ref->isContainer() ) + return 0; + else + return 1; + } + + auto hint() const -> std::string { return m_hint; } + }; + + class ExeName : public ComposableParserImpl<ExeName> { + std::shared_ptr<std::string> m_name; + std::shared_ptr<BoundValueRefBase> m_ref; + + template<typename LambdaT> + static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundValueRefBase> { + return std::make_shared<BoundLambda<LambdaT>>( lambda) ; + } + + public: + ExeName() : m_name( std::make_shared<std::string>( "<executable>" ) ) {} + + explicit ExeName( std::string &ref ) : ExeName() { + m_ref = std::make_shared<BoundValueRef<std::string>>( ref ); + } + + template<typename LambdaT> + explicit ExeName( LambdaT const& lambda ) : ExeName() { + m_ref = std::make_shared<BoundLambda<LambdaT>>( lambda ); + } + + // The exe name is not parsed out of the normal tokens, but is handled specially + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + } + + auto name() const -> std::string { return *m_name; } + auto set( std::string const& newName ) -> ParserResult { + + auto lastSlash = newName.find_last_of( "\\/" ); + auto filename = ( lastSlash == std::string::npos ) + ? newName + : newName.substr( lastSlash+1 ); + + *m_name = filename; + if( m_ref ) + return m_ref->setValue( filename ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + class Arg : public ParserRefImpl<Arg> { + public: + using ParserRefImpl::ParserRefImpl; + + auto parse( std::string const &, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + auto const &token = *remainingTokens; + if( token.type != TokenType::Argument ) + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + + assert( !m_ref->isFlag() ); + auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() ); + + auto result = valueRef->setValue( remainingTokens->token ); + if( !result ) + return InternalParseResult( result ); + else + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + }; + + inline auto normaliseOpt( std::string const &optName ) -> std::string { +#ifdef CATCH_PLATFORM_WINDOWS + if( optName[0] == '/' ) + return "-" + optName.substr( 1 ); + else +#endif + return optName; + } + + class Opt : public ParserRefImpl<Opt> { + protected: + std::vector<std::string> m_optNames; + + public: + template<typename LambdaT> + explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_shared<BoundFlagLambda<LambdaT>>( ref ) ) {} + + explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared<BoundFlagRef>( ref ) ) {} + + template<typename LambdaT> + Opt( LambdaT const &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + template<typename T> + Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + auto operator[]( std::string const &optName ) -> Opt & { + m_optNames.push_back( optName ); + return *this; + } + + auto getHelpColumns() const -> std::vector<HelpColumns> { + std::ostringstream oss; + bool first = true; + for( auto const &opt : m_optNames ) { + if (first) + first = false; + else + oss << ", "; + oss << opt; + } + if( !m_hint.empty() ) + oss << " <" << m_hint << ">"; + return { { oss.str(), m_description } }; + } + + auto isMatch( std::string const &optToken ) const -> bool { + auto normalisedToken = normaliseOpt( optToken ); + for( auto const &name : m_optNames ) { + if( normaliseOpt( name ) == normalisedToken ) + return true; + } + return false; + } + + using ParserBase::parse; + + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + if( remainingTokens && remainingTokens->type == TokenType::Option ) { + auto const &token = *remainingTokens; + if( isMatch(token.token ) ) { + if( m_ref->isFlag() ) { + auto flagRef = static_cast<detail::BoundFlagRefBase*>( m_ref.get() ); + auto result = flagRef->setFlag( true ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } else { + auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() ); + ++remainingTokens; + if( !remainingTokens ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto const &argToken = *remainingTokens; + if( argToken.type != TokenType::Argument ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto result = valueRef->setValue( argToken.token ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + } + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + } + + auto validate() const -> Result override { + if( m_optNames.empty() ) + return Result::logicError( "No options supplied to Opt" ); + for( auto const &name : m_optNames ) { + if( name.empty() ) + return Result::logicError( "Option name cannot be empty" ); +#ifdef CATCH_PLATFORM_WINDOWS + if( name[0] != '-' && name[0] != '/' ) + return Result::logicError( "Option name must begin with '-' or '/'" ); +#else + if( name[0] != '-' ) + return Result::logicError( "Option name must begin with '-'" ); +#endif + } + return ParserRefImpl::validate(); + } + }; + + struct Help : Opt { + Help( bool &showHelpFlag ) + : Opt([&]( bool flag ) { + showHelpFlag = flag; + return ParserResult::ok( ParseResultType::ShortCircuitAll ); + }) + { + static_cast<Opt &>( *this ) + ("display usage information") + ["-?"]["-h"]["--help"] + .optional(); + } + }; + + struct Parser : ParserBase { + + mutable ExeName m_exeName; + std::vector<Opt> m_options; + std::vector<Arg> m_args; + + auto operator|=( ExeName const &exeName ) -> Parser & { + m_exeName = exeName; + return *this; + } + + auto operator|=( Arg const &arg ) -> Parser & { + m_args.push_back(arg); + return *this; + } + + auto operator|=( Opt const &opt ) -> Parser & { + m_options.push_back(opt); + return *this; + } + + auto operator|=( Parser const &other ) -> Parser & { + m_options.insert(m_options.end(), other.m_options.begin(), other.m_options.end()); + m_args.insert(m_args.end(), other.m_args.begin(), other.m_args.end()); + return *this; + } + + template<typename T> + auto operator|( T const &other ) const -> Parser { + return Parser( *this ) |= other; + } + + // Forward deprecated interface with '+' instead of '|' + template<typename T> + auto operator+=( T const &other ) -> Parser & { return operator|=( other ); } + template<typename T> + auto operator+( T const &other ) const -> Parser { return operator|( other ); } + + auto getHelpColumns() const -> std::vector<HelpColumns> { + std::vector<HelpColumns> cols; + for (auto const &o : m_options) { + auto childCols = o.getHelpColumns(); + cols.insert( cols.end(), childCols.begin(), childCols.end() ); + } + return cols; + } + + void writeToStream( std::ostream &os ) const { + if (!m_exeName.name().empty()) { + os << "usage:\n" << " " << m_exeName.name() << " "; + bool required = true, first = true; + for( auto const &arg : m_args ) { + if (first) + first = false; + else + os << " "; + if( arg.isOptional() && required ) { + os << "["; + required = false; + } + os << "<" << arg.hint() << ">"; + if( arg.cardinality() == 0 ) + os << " ... "; + } + if( !required ) + os << "]"; + if( !m_options.empty() ) + os << " options"; + os << "\n\nwhere options are:" << std::endl; + } + + auto rows = getHelpColumns(); + size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH; + size_t optWidth = 0; + for( auto const &cols : rows ) + optWidth = (std::max)(optWidth, cols.left.size() + 2); + + optWidth = (std::min)(optWidth, consoleWidth/2); + + for( auto const &cols : rows ) { + auto row = + TextFlow::Column( cols.left ).width( optWidth ).indent( 2 ) + + TextFlow::Spacer(4) + + TextFlow::Column( cols.right ).width( consoleWidth - 7 - optWidth ); + os << row << std::endl; + } + } + + friend auto operator<<( std::ostream &os, Parser const &parser ) -> std::ostream& { + parser.writeToStream( os ); + return os; + } + + auto validate() const -> Result override { + for( auto const &opt : m_options ) { + auto result = opt.validate(); + if( !result ) + return result; + } + for( auto const &arg : m_args ) { + auto result = arg.validate(); + if( !result ) + return result; + } + return Result::ok(); + } + + using ParserBase::parse; + + auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override { + + struct ParserInfo { + ParserBase const* parser = nullptr; + size_t count = 0; + }; + const size_t totalParsers = m_options.size() + m_args.size(); + assert( totalParsers < 512 ); + // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do + ParserInfo parseInfos[512]; + + { + size_t i = 0; + for (auto const &opt : m_options) parseInfos[i++].parser = &opt; + for (auto const &arg : m_args) parseInfos[i++].parser = &arg; + } + + m_exeName.set( exeName ); + + auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + while( result.value().remainingTokens() ) { + bool tokenParsed = false; + + for( size_t i = 0; i < totalParsers; ++i ) { + auto& parseInfo = parseInfos[i]; + if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { + result = parseInfo.parser->parse(exeName, result.value().remainingTokens()); + if (!result) + return result; + if (result.value().type() != ParseResultType::NoMatch) { + tokenParsed = true; + ++parseInfo.count; + break; + } + } + } + + if( result.value().type() == ParseResultType::ShortCircuitAll ) + return result; + if( !tokenParsed ) + return InternalParseResult::runtimeError( "Unrecognised token: " + result.value().remainingTokens()->token ); + } + // !TBD Check missing required options + return result; + } + }; + + template<typename DerivedT> + template<typename T> + auto ComposableParserImpl<DerivedT>::operator|( T const &other ) const -> Parser { + return Parser() | static_cast<DerivedT const &>( *this ) | other; + } +} // namespace detail + +// A Combined parser +using detail::Parser; + +// A parser for options +using detail::Opt; + +// A parser for arguments +using detail::Arg; + +// Wrapper for argc, argv from main() +using detail::Args; + +// Specifies the name of the executable +using detail::ExeName; + +// Convenience wrapper for option parser that specifies the help option +using detail::Help; + +// enum of result types from a parse +using detail::ParseResultType; + +// Result type for parser operation +using detail::ParserResult; + +}} // namespace Catch::clara + +// end clara.hpp +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// Restore Clara's value for console width, if present +#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#endif + +// end catch_clara.h +namespace Catch { + + clara::Parser makeCommandLineParser( ConfigData& config ); + +} // end namespace Catch + +// end catch_commandline.h +#include <fstream> +#include <ctime> + +namespace Catch { + + clara::Parser makeCommandLineParser( ConfigData& config ) { + + using namespace clara; + + auto const setWarning = [&]( std::string const& warning ) { + auto warningSet = [&]() { + if( warning == "NoAssertions" ) + return WarnAbout::NoAssertions; + + if ( warning == "NoTests" ) + return WarnAbout::NoTests; + + return WarnAbout::Nothing; + }(); + + if (warningSet == WarnAbout::Nothing) + return ParserResult::runtimeError( "Unrecognised warning: '" + warning + "'" ); + config.warnings = static_cast<WarnAbout::What>( config.warnings | warningSet ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const loadTestNamesFromFile = [&]( std::string const& filename ) { + std::ifstream f( filename.c_str() ); + if( !f.is_open() ) + return ParserResult::runtimeError( "Unable to load input file: '" + filename + "'" ); + + std::string line; + while( std::getline( f, line ) ) { + line = trim(line); + if( !line.empty() && !startsWith( line, '#' ) ) { + if( !startsWith( line, '"' ) ) + line = '"' + line + '"'; + config.testsOrTags.push_back( line ); + config.testsOrTags.emplace_back( "," ); + } + } + //Remove comma in the end + if(!config.testsOrTags.empty()) + config.testsOrTags.erase( config.testsOrTags.end()-1 ); + + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setTestOrder = [&]( std::string const& order ) { + if( startsWith( "declared", order ) ) + config.runOrder = RunTests::InDeclarationOrder; + else if( startsWith( "lexical", order ) ) + config.runOrder = RunTests::InLexicographicalOrder; + else if( startsWith( "random", order ) ) + config.runOrder = RunTests::InRandomOrder; + else + return clara::ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setRngSeed = [&]( std::string const& seed ) { + if( seed != "time" ) + return clara::detail::convertInto( seed, config.rngSeed ); + config.rngSeed = static_cast<unsigned int>( std::time(nullptr) ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setColourUsage = [&]( std::string const& useColour ) { + auto mode = toLower( useColour ); + + if( mode == "yes" ) + config.useColour = UseColour::Yes; + else if( mode == "no" ) + config.useColour = UseColour::No; + else if( mode == "auto" ) + config.useColour = UseColour::Auto; + else + return ParserResult::runtimeError( "colour mode must be one of: auto, yes or no. '" + useColour + "' not recognised" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setWaitForKeypress = [&]( std::string const& keypress ) { + auto keypressLc = toLower( keypress ); + if (keypressLc == "never") + config.waitForKeypress = WaitForKeypress::Never; + else if( keypressLc == "start" ) + config.waitForKeypress = WaitForKeypress::BeforeStart; + else if( keypressLc == "exit" ) + config.waitForKeypress = WaitForKeypress::BeforeExit; + else if( keypressLc == "both" ) + config.waitForKeypress = WaitForKeypress::BeforeStartAndExit; + else + return ParserResult::runtimeError( "keypress argument must be one of: never, start, exit or both. '" + keypress + "' not recognised" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setVerbosity = [&]( std::string const& verbosity ) { + auto lcVerbosity = toLower( verbosity ); + if( lcVerbosity == "quiet" ) + config.verbosity = Verbosity::Quiet; + else if( lcVerbosity == "normal" ) + config.verbosity = Verbosity::Normal; + else if( lcVerbosity == "high" ) + config.verbosity = Verbosity::High; + else + return ParserResult::runtimeError( "Unrecognised verbosity, '" + verbosity + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setReporter = [&]( std::string const& reporter ) { + IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); + + auto lcReporter = toLower( reporter ); + auto result = factories.find( lcReporter ); + + if( factories.end() != result ) + config.reporterName = lcReporter; + else + return ParserResult::runtimeError( "Unrecognized reporter, '" + reporter + "'. Check available with --list-reporters" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + + auto cli + = ExeName( config.processName ) + | Help( config.showHelp ) + | Opt( config.listTests ) + ["-l"]["--list-tests"] + ( "list all/matching test cases" ) + | Opt( config.listTags ) + ["-t"]["--list-tags"] + ( "list all/matching tags" ) + | Opt( config.showSuccessfulTests ) + ["-s"]["--success"] + ( "include successful tests in output" ) + | Opt( config.shouldDebugBreak ) + ["-b"]["--break"] + ( "break into debugger on failure" ) + | Opt( config.noThrow ) + ["-e"]["--nothrow"] + ( "skip exception tests" ) + | Opt( config.showInvisibles ) + ["-i"]["--invisibles"] + ( "show invisibles (tabs, newlines)" ) + | Opt( config.outputFilename, "filename" ) + ["-o"]["--out"] + ( "output filename" ) + | Opt( setReporter, "name" ) + ["-r"]["--reporter"] + ( "reporter to use (defaults to console)" ) + | Opt( config.name, "name" ) + ["-n"]["--name"] + ( "suite name" ) + | Opt( [&]( bool ){ config.abortAfter = 1; } ) + ["-a"]["--abort"] + ( "abort at first failure" ) + | Opt( [&]( int x ){ config.abortAfter = x; }, "no. failures" ) + ["-x"]["--abortx"] + ( "abort after x failures" ) + | Opt( setWarning, "warning name" ) + ["-w"]["--warn"] + ( "enable warnings" ) + | Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" ) + ["-d"]["--durations"] + ( "show test durations" ) + | Opt( config.minDuration, "seconds" ) + ["-D"]["--min-duration"] + ( "show test durations for tests taking at least the given number of seconds" ) + | Opt( loadTestNamesFromFile, "filename" ) + ["-f"]["--input-file"] + ( "load test names to run from a file" ) + | Opt( config.filenamesAsTags ) + ["-#"]["--filenames-as-tags"] + ( "adds a tag for the filename" ) + | Opt( config.sectionsToRun, "section name" ) + ["-c"]["--section"] + ( "specify section to run" ) + | Opt( setVerbosity, "quiet|normal|high" ) + ["-v"]["--verbosity"] + ( "set output verbosity" ) + | Opt( config.listTestNamesOnly ) + ["--list-test-names-only"] + ( "list all/matching test cases names only" ) + | Opt( config.listReporters ) + ["--list-reporters"] + ( "list all reporters" ) + | Opt( setTestOrder, "decl|lex|rand" ) + ["--order"] + ( "test case order (defaults to decl)" ) + | Opt( setRngSeed, "'time'|number" ) + ["--rng-seed"] + ( "set a specific seed for random numbers" ) + | Opt( setColourUsage, "yes|no" ) + ["--use-colour"] + ( "should output be colourised" ) + | Opt( config.libIdentify ) + ["--libidentify"] + ( "report name and version according to libidentify standard" ) + | Opt( setWaitForKeypress, "never|start|exit|both" ) + ["--wait-for-keypress"] + ( "waits for a keypress before exiting" ) + | Opt( config.benchmarkSamples, "samples" ) + ["--benchmark-samples"] + ( "number of samples to collect (default: 100)" ) + | Opt( config.benchmarkResamples, "resamples" ) + ["--benchmark-resamples"] + ( "number of resamples for the bootstrap (default: 100000)" ) + | Opt( config.benchmarkConfidenceInterval, "confidence interval" ) + ["--benchmark-confidence-interval"] + ( "confidence interval for the bootstrap (between 0 and 1, default: 0.95)" ) + | Opt( config.benchmarkNoAnalysis ) + ["--benchmark-no-analysis"] + ( "perform only measurements; do not perform any analysis" ) + | Opt( config.benchmarkWarmupTime, "benchmarkWarmupTime" ) + ["--benchmark-warmup-time"] + ( "amount of time in milliseconds spent on warming up each test (default: 100)" ) + | Arg( config.testsOrTags, "test name|pattern|tags" ) + ( "which test or tests to use" ); + + return cli; + } + +} // end namespace Catch +// end catch_commandline.cpp +// start catch_common.cpp + +#include <cstring> +#include <ostream> + +namespace Catch { + + bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept { + return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); + } + bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept { + // We can assume that the same file will usually have the same pointer. + // Thus, if the pointers are the same, there is no point in calling the strcmp + return line < other.line || ( line == other.line && file != other.file && (std::strcmp(file, other.file) < 0)); + } + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { +#ifndef __GNUG__ + os << info.file << '(' << info.line << ')'; +#else + os << info.file << ':' << info.line; +#endif + return os; + } + + std::string StreamEndStop::operator+() const { + return std::string(); + } + + NonCopyable::NonCopyable() = default; + NonCopyable::~NonCopyable() = default; + +} +// end catch_common.cpp +// start catch_config.cpp + +namespace Catch { + + Config::Config( ConfigData const& data ) + : m_data( data ), + m_stream( openStream() ) + { + // We need to trim filter specs to avoid trouble with superfluous + // whitespace (esp. important for bdd macros, as those are manually + // aligned with whitespace). + + for (auto& elem : m_data.testsOrTags) { + elem = trim(elem); + } + for (auto& elem : m_data.sectionsToRun) { + elem = trim(elem); + } + + TestSpecParser parser(ITagAliasRegistry::get()); + if (!m_data.testsOrTags.empty()) { + m_hasTestFilters = true; + for (auto const& testOrTags : m_data.testsOrTags) { + parser.parse(testOrTags); + } + } + m_testSpec = parser.testSpec(); + } + + std::string const& Config::getFilename() const { + return m_data.outputFilename ; + } + + bool Config::listTests() const { return m_data.listTests; } + bool Config::listTestNamesOnly() const { return m_data.listTestNamesOnly; } + bool Config::listTags() const { return m_data.listTags; } + bool Config::listReporters() const { return m_data.listReporters; } + + std::string Config::getProcessName() const { return m_data.processName; } + std::string const& Config::getReporterName() const { return m_data.reporterName; } + + std::vector<std::string> const& Config::getTestsOrTags() const { return m_data.testsOrTags; } + std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; } + + TestSpec const& Config::testSpec() const { return m_testSpec; } + bool Config::hasTestFilters() const { return m_hasTestFilters; } + + bool Config::showHelp() const { return m_data.showHelp; } + + // IConfig interface + bool Config::allowThrows() const { return !m_data.noThrow; } + std::ostream& Config::stream() const { return m_stream->stream(); } + std::string Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } + bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; } + bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); } + bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); } + ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; } + double Config::minDuration() const { return m_data.minDuration; } + RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; } + unsigned int Config::rngSeed() const { return m_data.rngSeed; } + UseColour::YesOrNo Config::useColour() const { return m_data.useColour; } + bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; } + int Config::abortAfter() const { return m_data.abortAfter; } + bool Config::showInvisibles() const { return m_data.showInvisibles; } + Verbosity Config::verbosity() const { return m_data.verbosity; } + + bool Config::benchmarkNoAnalysis() const { return m_data.benchmarkNoAnalysis; } + int Config::benchmarkSamples() const { return m_data.benchmarkSamples; } + double Config::benchmarkConfidenceInterval() const { return m_data.benchmarkConfidenceInterval; } + unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; } + std::chrono::milliseconds Config::benchmarkWarmupTime() const { return std::chrono::milliseconds(m_data.benchmarkWarmupTime); } + + IStream const* Config::openStream() { + return Catch::makeStream(m_data.outputFilename); + } + +} // end namespace Catch +// end catch_config.cpp +// start catch_console_colour.cpp + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +// start catch_errno_guard.h + +namespace Catch { + + class ErrnoGuard { + public: + ErrnoGuard(); + ~ErrnoGuard(); + private: + int m_oldErrno; + }; + +} + +// end catch_errno_guard.h +// start catch_windows_h_proxy.h + + +#if defined(CATCH_PLATFORM_WINDOWS) + +#if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX) +# define CATCH_DEFINED_NOMINMAX +# define NOMINMAX +#endif +#if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN) +# define CATCH_DEFINED_WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif + +#ifdef __AFXDLL +#include <AfxWin.h> +#else +#include <windows.h> +#endif + +#ifdef CATCH_DEFINED_NOMINMAX +# undef NOMINMAX +#endif +#ifdef CATCH_DEFINED_WIN32_LEAN_AND_MEAN +# undef WIN32_LEAN_AND_MEAN +#endif + +#endif // defined(CATCH_PLATFORM_WINDOWS) + +// end catch_windows_h_proxy.h +#include <sstream> + +namespace Catch { + namespace { + + struct IColourImpl { + virtual ~IColourImpl() = default; + virtual void use( Colour::Code _colourCode ) = 0; + }; + + struct NoColourImpl : IColourImpl { + void use( Colour::Code ) override {} + + static IColourImpl* instance() { + static NoColourImpl s_instance; + return &s_instance; + } + }; + + } // anon namespace +} // namespace Catch + +#if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI ) +# ifdef CATCH_PLATFORM_WINDOWS +# define CATCH_CONFIG_COLOUR_WINDOWS +# else +# define CATCH_CONFIG_COLOUR_ANSI +# endif +#endif + +#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) ///////////////////////////////////////// + +namespace Catch { +namespace { + + class Win32ColourImpl : public IColourImpl { + public: + Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) ) + { + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); + originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY ); + originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY ); + } + + void use( Colour::Code _colourCode ) override { + switch( _colourCode ) { + case Colour::None: return setTextAttribute( originalForegroundAttributes ); + case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); + case Colour::Red: return setTextAttribute( FOREGROUND_RED ); + case Colour::Green: return setTextAttribute( FOREGROUND_GREEN ); + case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE ); + case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN ); + case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN ); + case Colour::Grey: return setTextAttribute( 0 ); + + case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY ); + case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED ); + case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN ); + case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); + case Colour::BrightYellow: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN ); + + case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" ); + + default: + CATCH_ERROR( "Unknown colour requested" ); + } + } + + private: + void setTextAttribute( WORD _textAttribute ) { + SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes ); + } + HANDLE stdoutHandle; + WORD originalForegroundAttributes; + WORD originalBackgroundAttributes; + }; + + IColourImpl* platformColourInstance() { + static Win32ColourImpl s_instance; + + IConfigPtr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = config + ? config->useColour() + : UseColour::Auto; + if( colourMode == UseColour::Auto ) + colourMode = UseColour::Yes; + return colourMode == UseColour::Yes + ? &s_instance + : NoColourImpl::instance(); + } + +} // end anon namespace +} // end namespace Catch + +#elif defined( CATCH_CONFIG_COLOUR_ANSI ) ////////////////////////////////////// + +#include <unistd.h> + +namespace Catch { +namespace { + + // use POSIX/ ANSI console terminal codes + // Thanks to Adam Strzelecki for original contribution + // (http://github.com/nanoant) + // https://github.com/philsquared/Catch/pull/131 + class PosixColourImpl : public IColourImpl { + public: + void use( Colour::Code _colourCode ) override { + switch( _colourCode ) { + case Colour::None: + case Colour::White: return setColour( "[0m" ); + case Colour::Red: return setColour( "[0;31m" ); + case Colour::Green: return setColour( "[0;32m" ); + case Colour::Blue: return setColour( "[0;34m" ); + case Colour::Cyan: return setColour( "[0;36m" ); + case Colour::Yellow: return setColour( "[0;33m" ); + case Colour::Grey: return setColour( "[1;30m" ); + + case Colour::LightGrey: return setColour( "[0;37m" ); + case Colour::BrightRed: return setColour( "[1;31m" ); + case Colour::BrightGreen: return setColour( "[1;32m" ); + case Colour::BrightWhite: return setColour( "[1;37m" ); + case Colour::BrightYellow: return setColour( "[1;33m" ); + + case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" ); + default: CATCH_INTERNAL_ERROR( "Unknown colour requested" ); + } + } + static IColourImpl* instance() { + static PosixColourImpl s_instance; + return &s_instance; + } + + private: + void setColour( const char* _escapeCode ) { + getCurrentContext().getConfig()->stream() + << '\033' << _escapeCode; + } + }; + + bool useColourOnPlatform() { + return +#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) + !isDebuggerActive() && +#endif +#if !(defined(__DJGPP__) && defined(__STRICT_ANSI__)) + isatty(STDOUT_FILENO) +#else + false +#endif + ; + } + IColourImpl* platformColourInstance() { + ErrnoGuard guard; + IConfigPtr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = config + ? config->useColour() + : UseColour::Auto; + if( colourMode == UseColour::Auto ) + colourMode = useColourOnPlatform() + ? UseColour::Yes + : UseColour::No; + return colourMode == UseColour::Yes + ? PosixColourImpl::instance() + : NoColourImpl::instance(); + } + +} // end anon namespace +} // end namespace Catch + +#else // not Windows or ANSI /////////////////////////////////////////////// + +namespace Catch { + + static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); } + +} // end namespace Catch + +#endif // Windows/ ANSI/ None + +namespace Catch { + + Colour::Colour( Code _colourCode ) { use( _colourCode ); } + Colour::Colour( Colour&& other ) noexcept { + m_moved = other.m_moved; + other.m_moved = true; + } + Colour& Colour::operator=( Colour&& other ) noexcept { + m_moved = other.m_moved; + other.m_moved = true; + return *this; + } + + Colour::~Colour(){ if( !m_moved ) use( None ); } + + void Colour::use( Code _colourCode ) { + static IColourImpl* impl = platformColourInstance(); + // Strictly speaking, this cannot possibly happen. + // However, under some conditions it does happen (see #1626), + // and this change is small enough that we can let practicality + // triumph over purity in this case. + if (impl != nullptr) { + impl->use( _colourCode ); + } + } + + std::ostream& operator << ( std::ostream& os, Colour const& ) { + return os; + } + +} // end namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + +// end catch_console_colour.cpp +// start catch_context.cpp + +namespace Catch { + + class Context : public IMutableContext, NonCopyable { + + public: // IContext + IResultCapture* getResultCapture() override { + return m_resultCapture; + } + IRunner* getRunner() override { + return m_runner; + } + + IConfigPtr const& getConfig() const override { + return m_config; + } + + ~Context() override; + + public: // IMutableContext + void setResultCapture( IResultCapture* resultCapture ) override { + m_resultCapture = resultCapture; + } + void setRunner( IRunner* runner ) override { + m_runner = runner; + } + void setConfig( IConfigPtr const& config ) override { + m_config = config; + } + + friend IMutableContext& getCurrentMutableContext(); + + private: + IConfigPtr m_config; + IRunner* m_runner = nullptr; + IResultCapture* m_resultCapture = nullptr; + }; + + IMutableContext *IMutableContext::currentContext = nullptr; + + void IMutableContext::createContext() + { + currentContext = new Context(); + } + + void cleanUpContext() { + delete IMutableContext::currentContext; + IMutableContext::currentContext = nullptr; + } + IContext::~IContext() = default; + IMutableContext::~IMutableContext() = default; + Context::~Context() = default; + + SimplePcg32& rng() { + static SimplePcg32 s_rng; + return s_rng; + } + +} +// end catch_context.cpp +// start catch_debug_console.cpp + +// start catch_debug_console.h + +#include <string> + +namespace Catch { + void writeToDebugConsole( std::string const& text ); +} + +// end catch_debug_console.h +#if defined(CATCH_CONFIG_ANDROID_LOGWRITE) +#include <android/log.h> + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + __android_log_write( ANDROID_LOG_DEBUG, "Catch", text.c_str() ); + } + } + +#elif defined(CATCH_PLATFORM_WINDOWS) + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + ::OutputDebugStringA( text.c_str() ); + } + } + +#else + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + // !TBD: Need a version for Mac/ XCode and other IDEs + Catch::cout() << text; + } + } + +#endif // Platform +// end catch_debug_console.cpp +// start catch_debugger.cpp + +#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) + +# include <cassert> +# include <sys/types.h> +# include <unistd.h> +# include <cstddef> +# include <ostream> + +#ifdef __apple_build_version__ + // These headers will only compile with AppleClang (XCode) + // For other compilers (Clang, GCC, ... ) we need to exclude them +# include <sys/sysctl.h> +#endif + + namespace Catch { + #ifdef __apple_build_version__ + // The following function is taken directly from the following technical note: + // https://developer.apple.com/library/archive/qa/qa1361/_index.html + + // Returns true if the current process is being debugged (either + // running under the debugger or has a debugger attached post facto). + bool isDebuggerActive(){ + int mib[4]; + struct kinfo_proc info; + std::size_t size; + + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. + + info.kp_proc.p_flag = 0; + + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + + // Call sysctl. + + size = sizeof(info); + if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) { + Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; + return false; + } + + // We're being debugged if the P_TRACED flag is set. + + return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); + } + #else + bool isDebuggerActive() { + // We need to find another way to determine this for non-appleclang compilers on macOS + return false; + } + #endif + } // namespace Catch + +#elif defined(CATCH_PLATFORM_LINUX) + #include <fstream> + #include <string> + + namespace Catch{ + // The standard POSIX way of detecting a debugger is to attempt to + // ptrace() the process, but this needs to be done from a child and not + // this process itself to still allow attaching to this process later + // if wanted, so is rather heavy. Under Linux we have the PID of the + // "debugger" (which doesn't need to be gdb, of course, it could also + // be strace, for example) in /proc/$PID/status, so just get it from + // there instead. + bool isDebuggerActive(){ + // Libstdc++ has a bug, where std::ifstream sets errno to 0 + // This way our users can properly assert over errno values + ErrnoGuard guard; + std::ifstream in("/proc/self/status"); + for( std::string line; std::getline(in, line); ) { + static const int PREFIX_LEN = 11; + if( line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0 ) { + // We're traced if the PID is not 0 and no other PID starts + // with 0 digit, so it's enough to check for just a single + // character. + return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0'; + } + } + + return false; + } + } // namespace Catch +#elif defined(_MSC_VER) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#else + namespace Catch { + bool isDebuggerActive() { return false; } + } +#endif // Platform +// end catch_debugger.cpp +// start catch_decomposer.cpp + +namespace Catch { + + ITransientExpression::~ITransientExpression() = default; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { + if( lhs.size() + rhs.size() < 40 && + lhs.find('\n') == std::string::npos && + rhs.find('\n') == std::string::npos ) + os << lhs << " " << op << " " << rhs; + else + os << lhs << "\n" << op << "\n" << rhs; + } +} +// end catch_decomposer.cpp +// start catch_enforce.cpp + +#include <stdexcept> + +namespace Catch { +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER) + [[noreturn]] + void throw_exception(std::exception const& e) { + Catch::cerr() << "Catch will terminate because it needed to throw an exception.\n" + << "The message was: " << e.what() << '\n'; + std::terminate(); + } +#endif + + [[noreturn]] + void throw_logic_error(std::string const& msg) { + throw_exception(std::logic_error(msg)); + } + + [[noreturn]] + void throw_domain_error(std::string const& msg) { + throw_exception(std::domain_error(msg)); + } + + [[noreturn]] + void throw_runtime_error(std::string const& msg) { + throw_exception(std::runtime_error(msg)); + } + +} // namespace Catch; +// end catch_enforce.cpp +// start catch_enum_values_registry.cpp +// start catch_enum_values_registry.h + +#include <vector> +#include <memory> + +namespace Catch { + + namespace Detail { + + std::unique_ptr<EnumInfo> makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ); + + class EnumValuesRegistry : public IMutableEnumValuesRegistry { + + std::vector<std::unique_ptr<EnumInfo>> m_enumInfos; + + EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values) override; + }; + + std::vector<StringRef> parseEnums( StringRef enums ); + + } // Detail + +} // Catch + +// end catch_enum_values_registry.h + +#include <map> +#include <cassert> + +namespace Catch { + + IMutableEnumValuesRegistry::~IMutableEnumValuesRegistry() {} + + namespace Detail { + + namespace { + // Extracts the actual name part of an enum instance + // In other words, it returns the Blue part of Bikeshed::Colour::Blue + StringRef extractInstanceName(StringRef enumInstance) { + // Find last occurrence of ":" + size_t name_start = enumInstance.size(); + while (name_start > 0 && enumInstance[name_start - 1] != ':') { + --name_start; + } + return enumInstance.substr(name_start, enumInstance.size() - name_start); + } + } + + std::vector<StringRef> parseEnums( StringRef enums ) { + auto enumValues = splitStringRef( enums, ',' ); + std::vector<StringRef> parsed; + parsed.reserve( enumValues.size() ); + for( auto const& enumValue : enumValues ) { + parsed.push_back(trim(extractInstanceName(enumValue))); + } + return parsed; + } + + EnumInfo::~EnumInfo() {} + + StringRef EnumInfo::lookup( int value ) const { + for( auto const& valueToName : m_values ) { + if( valueToName.first == value ) + return valueToName.second; + } + return "{** unexpected enum value **}"_sr; + } + + std::unique_ptr<EnumInfo> makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) { + std::unique_ptr<EnumInfo> enumInfo( new EnumInfo ); + enumInfo->m_name = enumName; + enumInfo->m_values.reserve( values.size() ); + + const auto valueNames = Catch::Detail::parseEnums( allValueNames ); + assert( valueNames.size() == values.size() ); + std::size_t i = 0; + for( auto value : values ) + enumInfo->m_values.emplace_back(value, valueNames[i++]); + + return enumInfo; + } + + EnumInfo const& EnumValuesRegistry::registerEnum( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) { + m_enumInfos.push_back(makeEnumInfo(enumName, allValueNames, values)); + return *m_enumInfos.back(); + } + + } // Detail +} // Catch + +// end catch_enum_values_registry.cpp +// start catch_errno_guard.cpp + +#include <cerrno> + +namespace Catch { + ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} + ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } +} +// end catch_errno_guard.cpp +// start catch_exception_translator_registry.cpp + +// start catch_exception_translator_registry.h + +#include <vector> +#include <string> +#include <memory> + +namespace Catch { + + class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { + public: + ~ExceptionTranslatorRegistry(); + virtual void registerTranslator( const IExceptionTranslator* translator ); + std::string translateActiveException() const override; + std::string tryTranslators() const; + + private: + std::vector<std::unique_ptr<IExceptionTranslator const>> m_translators; + }; +} + +// end catch_exception_translator_registry.h +#ifdef __OBJC__ +#import "Foundation/Foundation.h" +#endif + +namespace Catch { + + ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() { + } + + void ExceptionTranslatorRegistry::registerTranslator( const IExceptionTranslator* translator ) { + m_translators.push_back( std::unique_ptr<const IExceptionTranslator>( translator ) ); + } + +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + std::string ExceptionTranslatorRegistry::translateActiveException() const { + try { +#ifdef __OBJC__ + // In Objective-C try objective-c exceptions first + @try { + return tryTranslators(); + } + @catch (NSException *exception) { + return Catch::Detail::stringify( [exception description] ); + } +#else + // Compiling a mixed mode project with MSVC means that CLR + // exceptions will be caught in (...) as well. However, these + // do not fill-in std::current_exception and thus lead to crash + // when attempting rethrow. + // /EHa switch also causes structured exceptions to be caught + // here, but they fill-in current_exception properly, so + // at worst the output should be a little weird, instead of + // causing a crash. + if (std::current_exception() == nullptr) { + return "Non C++ exception. Possibly a CLR exception."; + } + return tryTranslators(); +#endif + } + catch( TestFailureException& ) { + std::rethrow_exception(std::current_exception()); + } + catch( std::exception& ex ) { + return ex.what(); + } + catch( std::string& msg ) { + return msg; + } + catch( const char* msg ) { + return msg; + } + catch(...) { + return "Unknown exception"; + } + } + + std::string ExceptionTranslatorRegistry::tryTranslators() const { + if (m_translators.empty()) { + std::rethrow_exception(std::current_exception()); + } else { + return m_translators[0]->translate(m_translators.begin() + 1, m_translators.end()); + } + } + +#else // ^^ Exceptions are enabled // Exceptions are disabled vv + std::string ExceptionTranslatorRegistry::translateActiveException() const { + CATCH_INTERNAL_ERROR("Attempted to translate active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); + } + + std::string ExceptionTranslatorRegistry::tryTranslators() const { + CATCH_INTERNAL_ERROR("Attempted to use exception translators under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); + } +#endif + +} +// end catch_exception_translator_registry.cpp +// start catch_fatal_condition.cpp + +#include <algorithm> + +#if !defined( CATCH_CONFIG_WINDOWS_SEH ) && !defined( CATCH_CONFIG_POSIX_SIGNALS ) + +namespace Catch { + + // If neither SEH nor signal handling is required, the handler impls + // do not have to do anything, and can be empty. + void FatalConditionHandler::engage_platform() {} + void FatalConditionHandler::disengage_platform() {} + FatalConditionHandler::FatalConditionHandler() = default; + FatalConditionHandler::~FatalConditionHandler() = default; + +} // end namespace Catch + +#endif // !CATCH_CONFIG_WINDOWS_SEH && !CATCH_CONFIG_POSIX_SIGNALS + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) && defined( CATCH_CONFIG_POSIX_SIGNALS ) +#error "Inconsistent configuration: Windows' SEH handling and POSIX signals cannot be enabled at the same time" +#endif // CATCH_CONFIG_WINDOWS_SEH && CATCH_CONFIG_POSIX_SIGNALS + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) || defined( CATCH_CONFIG_POSIX_SIGNALS ) + +namespace { + //! Signals fatal error message to the run context + void reportFatal( char const * const message ) { + Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message ); + } + + //! Minimal size Catch2 needs for its own fatal error handling. + //! Picked anecdotally, so it might not be sufficient on all + //! platforms, and for all configurations. + constexpr std::size_t minStackSizeForErrors = 32 * 1024; +} // end unnamed namespace + +#endif // CATCH_CONFIG_WINDOWS_SEH || CATCH_CONFIG_POSIX_SIGNALS + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) + +namespace Catch { + + struct SignalDefs { DWORD id; const char* name; }; + + // There is no 1-1 mapping between signals and windows exceptions. + // Windows can easily distinguish between SO and SigSegV, + // but SigInt, SigTerm, etc are handled differently. + static SignalDefs signalDefs[] = { + { static_cast<DWORD>(EXCEPTION_ILLEGAL_INSTRUCTION), "SIGILL - Illegal instruction signal" }, + { static_cast<DWORD>(EXCEPTION_STACK_OVERFLOW), "SIGSEGV - Stack overflow" }, + { static_cast<DWORD>(EXCEPTION_ACCESS_VIOLATION), "SIGSEGV - Segmentation violation signal" }, + { static_cast<DWORD>(EXCEPTION_INT_DIVIDE_BY_ZERO), "Divide by zero error" }, + }; + + static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { + for (auto const& def : signalDefs) { + if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) { + reportFatal(def.name); + } + } + // If its not an exception we care about, pass it along. + // This stops us from eating debugger breaks etc. + return EXCEPTION_CONTINUE_SEARCH; + } + + // Since we do not support multiple instantiations, we put these + // into global variables and rely on cleaning them up in outlined + // constructors/destructors + static PVOID exceptionHandlerHandle = nullptr; + + // For MSVC, we reserve part of the stack memory for handling + // memory overflow structured exception. + FatalConditionHandler::FatalConditionHandler() { + ULONG guaranteeSize = static_cast<ULONG>(minStackSizeForErrors); + if (!SetThreadStackGuarantee(&guaranteeSize)) { + // We do not want to fully error out, because needing + // the stack reserve should be rare enough anyway. + Catch::cerr() + << "Failed to reserve piece of stack." + << " Stack overflows will not be reported successfully."; + } + } + + // We do not attempt to unset the stack guarantee, because + // Windows does not support lowering the stack size guarantee. + FatalConditionHandler::~FatalConditionHandler() = default; + + void FatalConditionHandler::engage_platform() { + // Register as first handler in current chain + exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); + if (!exceptionHandlerHandle) { + CATCH_RUNTIME_ERROR("Could not register vectored exception handler"); + } + } + + void FatalConditionHandler::disengage_platform() { + if (!RemoveVectoredExceptionHandler(exceptionHandlerHandle)) { + CATCH_RUNTIME_ERROR("Could not unregister vectored exception handler"); + } + exceptionHandlerHandle = nullptr; + } + +} // end namespace Catch + +#endif // CATCH_CONFIG_WINDOWS_SEH + +#if defined( CATCH_CONFIG_POSIX_SIGNALS ) + +#include <signal.h> + +namespace Catch { + + struct SignalDefs { + int id; + const char* name; + }; + + static SignalDefs signalDefs[] = { + { SIGINT, "SIGINT - Terminal interrupt signal" }, + { SIGILL, "SIGILL - Illegal instruction signal" }, + { SIGFPE, "SIGFPE - Floating point error signal" }, + { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, + { SIGTERM, "SIGTERM - Termination request signal" }, + { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } + }; + +// Older GCCs trigger -Wmissing-field-initializers for T foo = {} +// which is zero initialization, but not explicit. We want to avoid +// that. +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + + static char* altStackMem = nullptr; + static std::size_t altStackSize = 0; + static stack_t oldSigStack{}; + static struct sigaction oldSigActions[sizeof(signalDefs) / sizeof(SignalDefs)]{}; + + static void restorePreviousSignalHandlers() { + // We set signal handlers back to the previous ones. Hopefully + // nobody overwrote them in the meantime, and doesn't expect + // their signal handlers to live past ours given that they + // installed them after ours.. + for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { + sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); + } + // Return the old stack + sigaltstack(&oldSigStack, nullptr); + } + + static void handleSignal( int sig ) { + char const * name = "<unknown signal>"; + for (auto const& def : signalDefs) { + if (sig == def.id) { + name = def.name; + break; + } + } + // We need to restore previous signal handlers and let them do + // their thing, so that the users can have the debugger break + // when a signal is raised, and so on. + restorePreviousSignalHandlers(); + reportFatal( name ); + raise( sig ); + } + + FatalConditionHandler::FatalConditionHandler() { + assert(!altStackMem && "Cannot initialize POSIX signal handler when one already exists"); + if (altStackSize == 0) { + altStackSize = std::max(static_cast<size_t>(SIGSTKSZ), minStackSizeForErrors); + } + altStackMem = new char[altStackSize](); + } + + FatalConditionHandler::~FatalConditionHandler() { + delete[] altStackMem; + // We signal that another instance can be constructed by zeroing + // out the pointer. + altStackMem = nullptr; + } + + void FatalConditionHandler::engage_platform() { + stack_t sigStack; + sigStack.ss_sp = altStackMem; + sigStack.ss_size = altStackSize; + sigStack.ss_flags = 0; + sigaltstack(&sigStack, &oldSigStack); + struct sigaction sa = { }; + + sa.sa_handler = handleSignal; + sa.sa_flags = SA_ONSTACK; + for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) { + sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); + } + } + +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif + + void FatalConditionHandler::disengage_platform() { + restorePreviousSignalHandlers(); + } + +} // end namespace Catch + +#endif // CATCH_CONFIG_POSIX_SIGNALS +// end catch_fatal_condition.cpp +// start catch_generators.cpp + +#include <limits> +#include <set> + +namespace Catch { + +IGeneratorTracker::~IGeneratorTracker() {} + +const char* GeneratorException::what() const noexcept { + return m_msg; +} + +namespace Generators { + + GeneratorUntypedBase::~GeneratorUntypedBase() {} + + auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { + return getResultCapture().acquireGeneratorTracker( generatorName, lineInfo ); + } + +} // namespace Generators +} // namespace Catch +// end catch_generators.cpp +// start catch_interfaces_capture.cpp + +namespace Catch { + IResultCapture::~IResultCapture() = default; +} +// end catch_interfaces_capture.cpp +// start catch_interfaces_config.cpp + +namespace Catch { + IConfig::~IConfig() = default; +} +// end catch_interfaces_config.cpp +// start catch_interfaces_exception.cpp + +namespace Catch { + IExceptionTranslator::~IExceptionTranslator() = default; + IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; +} +// end catch_interfaces_exception.cpp +// start catch_interfaces_registry_hub.cpp + +namespace Catch { + IRegistryHub::~IRegistryHub() = default; + IMutableRegistryHub::~IMutableRegistryHub() = default; +} +// end catch_interfaces_registry_hub.cpp +// start catch_interfaces_reporter.cpp + +// start catch_reporter_listening.h + +namespace Catch { + + class ListeningReporter : public IStreamingReporter { + using Reporters = std::vector<IStreamingReporterPtr>; + Reporters m_listeners; + IStreamingReporterPtr m_reporter = nullptr; + ReporterPreferences m_preferences; + + public: + ListeningReporter(); + + void addListener( IStreamingReporterPtr&& listener ); + void addReporter( IStreamingReporterPtr&& reporter ); + + public: // IStreamingReporter + + ReporterPreferences getPreferences() const override; + + void noMatchingTestCases( std::string const& spec ) override; + + void reportInvalidArguments(std::string const&arg) override; + + static std::set<Verbosity> getSupportedVerbosities(); + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + void benchmarkPreparing(std::string const& name) override; + void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override; + void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) override; + void benchmarkFailed(std::string const&) override; +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + void testRunStarting( TestRunInfo const& testRunInfo ) override; + void testGroupStarting( GroupInfo const& groupInfo ) override; + void testCaseStarting( TestCaseInfo const& testInfo ) override; + void sectionStarting( SectionInfo const& sectionInfo ) override; + void assertionStarting( AssertionInfo const& assertionInfo ) override; + + // The return value indicates if the messages buffer should be cleared: + bool assertionEnded( AssertionStats const& assertionStats ) override; + void sectionEnded( SectionStats const& sectionStats ) override; + void testCaseEnded( TestCaseStats const& testCaseStats ) override; + void testGroupEnded( TestGroupStats const& testGroupStats ) override; + void testRunEnded( TestRunStats const& testRunStats ) override; + + void skipTest( TestCaseInfo const& testInfo ) override; + bool isMulti() const override; + + }; + +} // end namespace Catch + +// end catch_reporter_listening.h +namespace Catch { + + ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig ) + : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} + + ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ) + : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} + + std::ostream& ReporterConfig::stream() const { return *m_stream; } + IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; } + + TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {} + + GroupInfo::GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ) + : name( _name ), + groupIndex( _groupIndex ), + groupsCounts( _groupsCount ) + {} + + AssertionStats::AssertionStats( AssertionResult const& _assertionResult, + std::vector<MessageInfo> const& _infoMessages, + Totals const& _totals ) + : assertionResult( _assertionResult ), + infoMessages( _infoMessages ), + totals( _totals ) + { + assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression; + + if( assertionResult.hasMessage() ) { + // Copy message into messages list. + // !TBD This should have been done earlier, somewhere + MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); + builder << assertionResult.getMessage(); + builder.m_info.message = builder.m_stream.str(); + + infoMessages.push_back( builder.m_info ); + } + } + + AssertionStats::~AssertionStats() = default; + + SectionStats::SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ) + : sectionInfo( _sectionInfo ), + assertions( _assertions ), + durationInSeconds( _durationInSeconds ), + missingAssertions( _missingAssertions ) + {} + + SectionStats::~SectionStats() = default; + + TestCaseStats::TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ) + : testInfo( _testInfo ), + totals( _totals ), + stdOut( _stdOut ), + stdErr( _stdErr ), + aborting( _aborting ) + {} + + TestCaseStats::~TestCaseStats() = default; + + TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ) + : groupInfo( _groupInfo ), + totals( _totals ), + aborting( _aborting ) + {} + + TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo ) + : groupInfo( _groupInfo ), + aborting( false ) + {} + + TestGroupStats::~TestGroupStats() = default; + + TestRunStats::TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ) + : runInfo( _runInfo ), + totals( _totals ), + aborting( _aborting ) + {} + + TestRunStats::~TestRunStats() = default; + + void IStreamingReporter::fatalErrorEncountered( StringRef ) {} + bool IStreamingReporter::isMulti() const { return false; } + + IReporterFactory::~IReporterFactory() = default; + IReporterRegistry::~IReporterRegistry() = default; + +} // end namespace Catch +// end catch_interfaces_reporter.cpp +// start catch_interfaces_runner.cpp + +namespace Catch { + IRunner::~IRunner() = default; +} +// end catch_interfaces_runner.cpp +// start catch_interfaces_testcase.cpp + +namespace Catch { + ITestInvoker::~ITestInvoker() = default; + ITestCaseRegistry::~ITestCaseRegistry() = default; +} +// end catch_interfaces_testcase.cpp +// start catch_leak_detector.cpp + +#ifdef CATCH_CONFIG_WINDOWS_CRTDBG +#include <crtdbg.h> + +namespace Catch { + + LeakDetector::LeakDetector() { + int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + flag |= _CRTDBG_LEAK_CHECK_DF; + flag |= _CRTDBG_ALLOC_MEM_DF; + _CrtSetDbgFlag(flag); + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + // Change this to leaking allocation's number to break there + _CrtSetBreakAlloc(-1); + } +} + +#else + + Catch::LeakDetector::LeakDetector() {} + +#endif + +Catch::LeakDetector::~LeakDetector() { + Catch::cleanUp(); +} +// end catch_leak_detector.cpp +// start catch_list.cpp + +// start catch_list.h + +#include <set> + +namespace Catch { + + std::size_t listTests( Config const& config ); + + std::size_t listTestsNamesOnly( Config const& config ); + + struct TagInfo { + void add( std::string const& spelling ); + std::string all() const; + + std::set<std::string> spellings; + std::size_t count = 0; + }; + + std::size_t listTags( Config const& config ); + + std::size_t listReporters(); + + Option<std::size_t> list( std::shared_ptr<Config> const& config ); + +} // end namespace Catch + +// end catch_list.h +// start catch_text.h + +namespace Catch { + using namespace clara::TextFlow; +} + +// end catch_text.h +#include <limits> +#include <algorithm> +#include <iomanip> + +namespace Catch { + + std::size_t listTests( Config const& config ) { + TestSpec const& testSpec = config.testSpec(); + if( config.hasTestFilters() ) + Catch::cout() << "Matching test cases:\n"; + else { + Catch::cout() << "All available test cases:\n"; + } + + auto matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCaseInfo : matchedTestCases ) { + Colour::Code colour = testCaseInfo.isHidden() + ? Colour::SecondaryText + : Colour::None; + Colour colourGuard( colour ); + + Catch::cout() << Column( testCaseInfo.name ).initialIndent( 2 ).indent( 4 ) << "\n"; + if( config.verbosity() >= Verbosity::High ) { + Catch::cout() << Column( Catch::Detail::stringify( testCaseInfo.lineInfo ) ).indent(4) << std::endl; + std::string description = testCaseInfo.description; + if( description.empty() ) + description = "(NO DESCRIPTION)"; + Catch::cout() << Column( description ).indent(4) << std::endl; + } + if( !testCaseInfo.tags.empty() ) + Catch::cout() << Column( testCaseInfo.tagsAsString() ).indent( 6 ) << "\n"; + } + + if( !config.hasTestFilters() ) + Catch::cout() << pluralise( matchedTestCases.size(), "test case" ) << '\n' << std::endl; + else + Catch::cout() << pluralise( matchedTestCases.size(), "matching test case" ) << '\n' << std::endl; + return matchedTestCases.size(); + } + + std::size_t listTestsNamesOnly( Config const& config ) { + TestSpec const& testSpec = config.testSpec(); + std::size_t matchedTests = 0; + std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCaseInfo : matchedTestCases ) { + matchedTests++; + if( startsWith( testCaseInfo.name, '#' ) ) + Catch::cout() << '"' << testCaseInfo.name << '"'; + else + Catch::cout() << testCaseInfo.name; + if ( config.verbosity() >= Verbosity::High ) + Catch::cout() << "\t@" << testCaseInfo.lineInfo; + Catch::cout() << std::endl; + } + return matchedTests; + } + + void TagInfo::add( std::string const& spelling ) { + ++count; + spellings.insert( spelling ); + } + + std::string TagInfo::all() const { + size_t size = 0; + for (auto const& spelling : spellings) { + // Add 2 for the brackes + size += spelling.size() + 2; + } + + std::string out; out.reserve(size); + for (auto const& spelling : spellings) { + out += '['; + out += spelling; + out += ']'; + } + return out; + } + + std::size_t listTags( Config const& config ) { + TestSpec const& testSpec = config.testSpec(); + if( config.hasTestFilters() ) + Catch::cout() << "Tags for matching test cases:\n"; + else { + Catch::cout() << "All available tags:\n"; + } + + std::map<std::string, TagInfo> tagCounts; + + std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCase : matchedTestCases ) { + for( auto const& tagName : testCase.getTestCaseInfo().tags ) { + std::string lcaseTagName = toLower( tagName ); + auto countIt = tagCounts.find( lcaseTagName ); + if( countIt == tagCounts.end() ) + countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first; + countIt->second.add( tagName ); + } + } + + for( auto const& tagCount : tagCounts ) { + ReusableStringStream rss; + rss << " " << std::setw(2) << tagCount.second.count << " "; + auto str = rss.str(); + auto wrapper = Column( tagCount.second.all() ) + .initialIndent( 0 ) + .indent( str.size() ) + .width( CATCH_CONFIG_CONSOLE_WIDTH-10 ); + Catch::cout() << str << wrapper << '\n'; + } + Catch::cout() << pluralise( tagCounts.size(), "tag" ) << '\n' << std::endl; + return tagCounts.size(); + } + + std::size_t listReporters() { + Catch::cout() << "Available reporters:\n"; + IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); + std::size_t maxNameLen = 0; + for( auto const& factoryKvp : factories ) + maxNameLen = (std::max)( maxNameLen, factoryKvp.first.size() ); + + for( auto const& factoryKvp : factories ) { + Catch::cout() + << Column( factoryKvp.first + ":" ) + .indent(2) + .width( 5+maxNameLen ) + + Column( factoryKvp.second->getDescription() ) + .initialIndent(0) + .indent(2) + .width( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) + << "\n"; + } + Catch::cout() << std::endl; + return factories.size(); + } + + Option<std::size_t> list( std::shared_ptr<Config> const& config ) { + Option<std::size_t> listedCount; + getCurrentMutableContext().setConfig( config ); + if( config->listTests() ) + listedCount = listedCount.valueOr(0) + listTests( *config ); + if( config->listTestNamesOnly() ) + listedCount = listedCount.valueOr(0) + listTestsNamesOnly( *config ); + if( config->listTags() ) + listedCount = listedCount.valueOr(0) + listTags( *config ); + if( config->listReporters() ) + listedCount = listedCount.valueOr(0) + listReporters(); + return listedCount; + } + +} // end namespace Catch +// end catch_list.cpp +// start catch_matchers.cpp + +namespace Catch { +namespace Matchers { + namespace Impl { + + std::string MatcherUntypedBase::toString() const { + if( m_cachedToString.empty() ) + m_cachedToString = describe(); + return m_cachedToString; + } + + MatcherUntypedBase::~MatcherUntypedBase() = default; + + } // namespace Impl +} // namespace Matchers + +using namespace Matchers; +using Matchers::Impl::MatcherBase; + +} // namespace Catch +// end catch_matchers.cpp +// start catch_matchers_exception.cpp + +namespace Catch { +namespace Matchers { +namespace Exception { + +bool ExceptionMessageMatcher::match(std::exception const& ex) const { + return ex.what() == m_message; +} + +std::string ExceptionMessageMatcher::describe() const { + return "exception message matches \"" + m_message + "\""; +} + +} +Exception::ExceptionMessageMatcher Message(std::string const& message) { + return Exception::ExceptionMessageMatcher(message); +} + +// namespace Exception +} // namespace Matchers +} // namespace Catch +// end catch_matchers_exception.cpp +// start catch_matchers_floating.cpp + +// start catch_polyfills.hpp + +namespace Catch { + bool isnan(float f); + bool isnan(double d); +} + +// end catch_polyfills.hpp +// start catch_to_string.hpp + +#include <string> + +namespace Catch { + template <typename T> + std::string to_string(T const& t) { +#if defined(CATCH_CONFIG_CPP11_TO_STRING) + return std::to_string(t); +#else + ReusableStringStream rss; + rss << t; + return rss.str(); +#endif + } +} // end namespace Catch + +// end catch_to_string.hpp +#include <algorithm> +#include <cmath> +#include <cstdlib> +#include <cstdint> +#include <cstring> +#include <sstream> +#include <type_traits> +#include <iomanip> +#include <limits> + +namespace Catch { +namespace { + + int32_t convert(float f) { + static_assert(sizeof(float) == sizeof(int32_t), "Important ULP matcher assumption violated"); + int32_t i; + std::memcpy(&i, &f, sizeof(f)); + return i; + } + + int64_t convert(double d) { + static_assert(sizeof(double) == sizeof(int64_t), "Important ULP matcher assumption violated"); + int64_t i; + std::memcpy(&i, &d, sizeof(d)); + return i; + } + + template <typename FP> + bool almostEqualUlps(FP lhs, FP rhs, uint64_t maxUlpDiff) { + // Comparison with NaN should always be false. + // This way we can rule it out before getting into the ugly details + if (Catch::isnan(lhs) || Catch::isnan(rhs)) { + return false; + } + + auto lc = convert(lhs); + auto rc = convert(rhs); + + if ((lc < 0) != (rc < 0)) { + // Potentially we can have +0 and -0 + return lhs == rhs; + } + + // static cast as a workaround for IBM XLC + auto ulpDiff = std::abs(static_cast<FP>(lc - rc)); + return static_cast<uint64_t>(ulpDiff) <= maxUlpDiff; + } + +#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) + + float nextafter(float x, float y) { + return ::nextafterf(x, y); + } + + double nextafter(double x, double y) { + return ::nextafter(x, y); + } + +#endif // ^^^ CATCH_CONFIG_GLOBAL_NEXTAFTER ^^^ + +template <typename FP> +FP step(FP start, FP direction, uint64_t steps) { + for (uint64_t i = 0; i < steps; ++i) { +#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) + start = Catch::nextafter(start, direction); +#else + start = std::nextafter(start, direction); +#endif + } + return start; +} + +// Performs equivalent check of std::fabs(lhs - rhs) <= margin +// But without the subtraction to allow for INFINITY in comparison +bool marginComparison(double lhs, double rhs, double margin) { + return (lhs + margin >= rhs) && (rhs + margin >= lhs); +} + +template <typename FloatingPoint> +void write(std::ostream& out, FloatingPoint num) { + out << std::scientific + << std::setprecision(std::numeric_limits<FloatingPoint>::max_digits10 - 1) + << num; +} + +} // end anonymous namespace + +namespace Matchers { +namespace Floating { + + enum class FloatingPointKind : uint8_t { + Float, + Double + }; + + WithinAbsMatcher::WithinAbsMatcher(double target, double margin) + :m_target{ target }, m_margin{ margin } { + CATCH_ENFORCE(margin >= 0, "Invalid margin: " << margin << '.' + << " Margin has to be non-negative."); + } + + // Performs equivalent check of std::fabs(lhs - rhs) <= margin + // But without the subtraction to allow for INFINITY in comparison + bool WithinAbsMatcher::match(double const& matchee) const { + return (matchee + m_margin >= m_target) && (m_target + m_margin >= matchee); + } + + std::string WithinAbsMatcher::describe() const { + return "is within " + ::Catch::Detail::stringify(m_margin) + " of " + ::Catch::Detail::stringify(m_target); + } + + WithinUlpsMatcher::WithinUlpsMatcher(double target, uint64_t ulps, FloatingPointKind baseType) + :m_target{ target }, m_ulps{ ulps }, m_type{ baseType } { + CATCH_ENFORCE(m_type == FloatingPointKind::Double + || m_ulps < (std::numeric_limits<uint32_t>::max)(), + "Provided ULP is impossibly large for a float comparison."); + } + +#if defined(__clang__) +#pragma clang diagnostic push +// Clang <3.5 reports on the default branch in the switch below +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + + bool WithinUlpsMatcher::match(double const& matchee) const { + switch (m_type) { + case FloatingPointKind::Float: + return almostEqualUlps<float>(static_cast<float>(matchee), static_cast<float>(m_target), m_ulps); + case FloatingPointKind::Double: + return almostEqualUlps<double>(matchee, m_target, m_ulps); + default: + CATCH_INTERNAL_ERROR( "Unknown FloatingPointKind value" ); + } + } + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + + std::string WithinUlpsMatcher::describe() const { + std::stringstream ret; + + ret << "is within " << m_ulps << " ULPs of "; + + if (m_type == FloatingPointKind::Float) { + write(ret, static_cast<float>(m_target)); + ret << 'f'; + } else { + write(ret, m_target); + } + + ret << " (["; + if (m_type == FloatingPointKind::Double) { + write(ret, step(m_target, static_cast<double>(-INFINITY), m_ulps)); + ret << ", "; + write(ret, step(m_target, static_cast<double>( INFINITY), m_ulps)); + } else { + // We have to cast INFINITY to float because of MinGW, see #1782 + write(ret, step(static_cast<float>(m_target), static_cast<float>(-INFINITY), m_ulps)); + ret << ", "; + write(ret, step(static_cast<float>(m_target), static_cast<float>( INFINITY), m_ulps)); + } + ret << "])"; + + return ret.str(); + } + + WithinRelMatcher::WithinRelMatcher(double target, double epsilon): + m_target(target), + m_epsilon(epsilon){ + CATCH_ENFORCE(m_epsilon >= 0., "Relative comparison with epsilon < 0 does not make sense."); + CATCH_ENFORCE(m_epsilon < 1., "Relative comparison with epsilon >= 1 does not make sense."); + } + + bool WithinRelMatcher::match(double const& matchee) const { + const auto relMargin = m_epsilon * (std::max)(std::fabs(matchee), std::fabs(m_target)); + return marginComparison(matchee, m_target, + std::isinf(relMargin)? 0 : relMargin); + } + + std::string WithinRelMatcher::describe() const { + Catch::ReusableStringStream sstr; + sstr << "and " << m_target << " are within " << m_epsilon * 100. << "% of each other"; + return sstr.str(); + } + +}// namespace Floating + +Floating::WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff) { + return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Double); +} + +Floating::WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff) { + return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Float); +} + +Floating::WithinAbsMatcher WithinAbs(double target, double margin) { + return Floating::WithinAbsMatcher(target, margin); +} + +Floating::WithinRelMatcher WithinRel(double target, double eps) { + return Floating::WithinRelMatcher(target, eps); +} + +Floating::WithinRelMatcher WithinRel(double target) { + return Floating::WithinRelMatcher(target, std::numeric_limits<double>::epsilon() * 100); +} + +Floating::WithinRelMatcher WithinRel(float target, float eps) { + return Floating::WithinRelMatcher(target, eps); +} + +Floating::WithinRelMatcher WithinRel(float target) { + return Floating::WithinRelMatcher(target, std::numeric_limits<float>::epsilon() * 100); +} + +} // namespace Matchers +} // namespace Catch +// end catch_matchers_floating.cpp +// start catch_matchers_generic.cpp + +std::string Catch::Matchers::Generic::Detail::finalizeDescription(const std::string& desc) { + if (desc.empty()) { + return "matches undescribed predicate"; + } else { + return "matches predicate: \"" + desc + '"'; + } +} +// end catch_matchers_generic.cpp +// start catch_matchers_string.cpp + +#include <regex> + +namespace Catch { +namespace Matchers { + + namespace StdString { + + CasedString::CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ) + : m_caseSensitivity( caseSensitivity ), + m_str( adjustString( str ) ) + {} + std::string CasedString::adjustString( std::string const& str ) const { + return m_caseSensitivity == CaseSensitive::No + ? toLower( str ) + : str; + } + std::string CasedString::caseSensitivitySuffix() const { + return m_caseSensitivity == CaseSensitive::No + ? " (case insensitive)" + : std::string(); + } + + StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator ) + : m_comparator( comparator ), + m_operation( operation ) { + } + + std::string StringMatcherBase::describe() const { + std::string description; + description.reserve(5 + m_operation.size() + m_comparator.m_str.size() + + m_comparator.caseSensitivitySuffix().size()); + description += m_operation; + description += ": \""; + description += m_comparator.m_str; + description += "\""; + description += m_comparator.caseSensitivitySuffix(); + return description; + } + + EqualsMatcher::EqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals", comparator ) {} + + bool EqualsMatcher::match( std::string const& source ) const { + return m_comparator.adjustString( source ) == m_comparator.m_str; + } + + ContainsMatcher::ContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains", comparator ) {} + + bool ContainsMatcher::match( std::string const& source ) const { + return contains( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with", comparator ) {} + + bool StartsWithMatcher::match( std::string const& source ) const { + return startsWith( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with", comparator ) {} + + bool EndsWithMatcher::match( std::string const& source ) const { + return endsWith( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + RegexMatcher::RegexMatcher(std::string regex, CaseSensitive::Choice caseSensitivity): m_regex(std::move(regex)), m_caseSensitivity(caseSensitivity) {} + + bool RegexMatcher::match(std::string const& matchee) const { + auto flags = std::regex::ECMAScript; // ECMAScript is the default syntax option anyway + if (m_caseSensitivity == CaseSensitive::Choice::No) { + flags |= std::regex::icase; + } + auto reg = std::regex(m_regex, flags); + return std::regex_match(matchee, reg); + } + + std::string RegexMatcher::describe() const { + return "matches " + ::Catch::Detail::stringify(m_regex) + ((m_caseSensitivity == CaseSensitive::Choice::Yes)? " case sensitively" : " case insensitively"); + } + + } // namespace StdString + + StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::EqualsMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::ContainsMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::EndsWithMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::StartsWithMatcher( StdString::CasedString( str, caseSensitivity) ); + } + + StdString::RegexMatcher Matches(std::string const& regex, CaseSensitive::Choice caseSensitivity) { + return StdString::RegexMatcher(regex, caseSensitivity); + } + +} // namespace Matchers +} // namespace Catch +// end catch_matchers_string.cpp +// start catch_message.cpp + +// start catch_uncaught_exceptions.h + +namespace Catch { + bool uncaught_exceptions(); +} // end namespace Catch + +// end catch_uncaught_exceptions.h +#include <cassert> +#include <stack> + +namespace Catch { + + MessageInfo::MessageInfo( StringRef const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ) + : macroName( _macroName ), + lineInfo( _lineInfo ), + type( _type ), + sequence( ++globalCount ) + {} + + bool MessageInfo::operator==( MessageInfo const& other ) const { + return sequence == other.sequence; + } + + bool MessageInfo::operator<( MessageInfo const& other ) const { + return sequence < other.sequence; + } + + // This may need protecting if threading support is added + unsigned int MessageInfo::globalCount = 0; + + //////////////////////////////////////////////////////////////////////////// + + Catch::MessageBuilder::MessageBuilder( StringRef const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ) + :m_info(macroName, lineInfo, type) {} + + //////////////////////////////////////////////////////////////////////////// + + ScopedMessage::ScopedMessage( MessageBuilder const& builder ) + : m_info( builder.m_info ), m_moved() + { + m_info.message = builder.m_stream.str(); + getResultCapture().pushScopedMessage( m_info ); + } + + ScopedMessage::ScopedMessage( ScopedMessage&& old ) + : m_info( old.m_info ), m_moved() + { + old.m_moved = true; + } + + ScopedMessage::~ScopedMessage() { + if ( !uncaught_exceptions() && !m_moved ){ + getResultCapture().popScopedMessage(m_info); + } + } + + Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) { + auto trimmed = [&] (size_t start, size_t end) { + while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) { + ++start; + } + while (names[end] == ',' || isspace(static_cast<unsigned char>(names[end]))) { + --end; + } + return names.substr(start, end - start + 1); + }; + auto skipq = [&] (size_t start, char quote) { + for (auto i = start + 1; i < names.size() ; ++i) { + if (names[i] == quote) + return i; + if (names[i] == '\\') + ++i; + } + CATCH_INTERNAL_ERROR("CAPTURE parsing encountered unmatched quote"); + }; + + size_t start = 0; + std::stack<char> openings; + for (size_t pos = 0; pos < names.size(); ++pos) { + char c = names[pos]; + switch (c) { + case '[': + case '{': + case '(': + // It is basically impossible to disambiguate between + // comparison and start of template args in this context +// case '<': + openings.push(c); + break; + case ']': + case '}': + case ')': +// case '>': + openings.pop(); + break; + case '"': + case '\'': + pos = skipq(pos, c); + break; + case ',': + if (start != pos && openings.empty()) { + m_messages.emplace_back(macroName, lineInfo, resultType); + m_messages.back().message = static_cast<std::string>(trimmed(start, pos)); + m_messages.back().message += " := "; + start = pos; + } + } + } + assert(openings.empty() && "Mismatched openings"); + m_messages.emplace_back(macroName, lineInfo, resultType); + m_messages.back().message = static_cast<std::string>(trimmed(start, names.size() - 1)); + m_messages.back().message += " := "; + } + Capturer::~Capturer() { + if ( !uncaught_exceptions() ){ + assert( m_captured == m_messages.size() ); + for( size_t i = 0; i < m_captured; ++i ) + m_resultCapture.popScopedMessage( m_messages[i] ); + } + } + + void Capturer::captureValue( size_t index, std::string const& value ) { + assert( index < m_messages.size() ); + m_messages[index].message += value; + m_resultCapture.pushScopedMessage( m_messages[index] ); + m_captured++; + } + +} // end namespace Catch +// end catch_message.cpp +// start catch_output_redirect.cpp + +// start catch_output_redirect.h +#ifndef TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H +#define TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H + +#include <cstdio> +#include <iosfwd> +#include <string> + +namespace Catch { + + class RedirectedStream { + std::ostream& m_originalStream; + std::ostream& m_redirectionStream; + std::streambuf* m_prevBuf; + + public: + RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ); + ~RedirectedStream(); + }; + + class RedirectedStdOut { + ReusableStringStream m_rss; + RedirectedStream m_cout; + public: + RedirectedStdOut(); + auto str() const -> std::string; + }; + + // StdErr has two constituent streams in C++, std::cerr and std::clog + // This means that we need to redirect 2 streams into 1 to keep proper + // order of writes + class RedirectedStdErr { + ReusableStringStream m_rss; + RedirectedStream m_cerr; + RedirectedStream m_clog; + public: + RedirectedStdErr(); + auto str() const -> std::string; + }; + + class RedirectedStreams { + public: + RedirectedStreams(RedirectedStreams const&) = delete; + RedirectedStreams& operator=(RedirectedStreams const&) = delete; + RedirectedStreams(RedirectedStreams&&) = delete; + RedirectedStreams& operator=(RedirectedStreams&&) = delete; + + RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr); + ~RedirectedStreams(); + private: + std::string& m_redirectedCout; + std::string& m_redirectedCerr; + RedirectedStdOut m_redirectedStdOut; + RedirectedStdErr m_redirectedStdErr; + }; + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + + // Windows's implementation of std::tmpfile is terrible (it tries + // to create a file inside system folder, thus requiring elevated + // privileges for the binary), so we have to use tmpnam(_s) and + // create the file ourselves there. + class TempFile { + public: + TempFile(TempFile const&) = delete; + TempFile& operator=(TempFile const&) = delete; + TempFile(TempFile&&) = delete; + TempFile& operator=(TempFile&&) = delete; + + TempFile(); + ~TempFile(); + + std::FILE* getFile(); + std::string getContents(); + + private: + std::FILE* m_file = nullptr; + #if defined(_MSC_VER) + char m_buffer[L_tmpnam] = { 0 }; + #endif + }; + + class OutputRedirect { + public: + OutputRedirect(OutputRedirect const&) = delete; + OutputRedirect& operator=(OutputRedirect const&) = delete; + OutputRedirect(OutputRedirect&&) = delete; + OutputRedirect& operator=(OutputRedirect&&) = delete; + + OutputRedirect(std::string& stdout_dest, std::string& stderr_dest); + ~OutputRedirect(); + + private: + int m_originalStdout = -1; + int m_originalStderr = -1; + TempFile m_stdoutFile; + TempFile m_stderrFile; + std::string& m_stdoutDest; + std::string& m_stderrDest; + }; + +#endif + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H +// end catch_output_redirect.h +#include <cstdio> +#include <cstring> +#include <fstream> +#include <sstream> +#include <stdexcept> + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + #if defined(_MSC_VER) + #include <io.h> //_dup and _dup2 + #define dup _dup + #define dup2 _dup2 + #define fileno _fileno + #else + #include <unistd.h> // dup and dup2 + #endif +#endif + +namespace Catch { + + RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ) + : m_originalStream( originalStream ), + m_redirectionStream( redirectionStream ), + m_prevBuf( m_originalStream.rdbuf() ) + { + m_originalStream.rdbuf( m_redirectionStream.rdbuf() ); + } + + RedirectedStream::~RedirectedStream() { + m_originalStream.rdbuf( m_prevBuf ); + } + + RedirectedStdOut::RedirectedStdOut() : m_cout( Catch::cout(), m_rss.get() ) {} + auto RedirectedStdOut::str() const -> std::string { return m_rss.str(); } + + RedirectedStdErr::RedirectedStdErr() + : m_cerr( Catch::cerr(), m_rss.get() ), + m_clog( Catch::clog(), m_rss.get() ) + {} + auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); } + + RedirectedStreams::RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr) + : m_redirectedCout(redirectedCout), + m_redirectedCerr(redirectedCerr) + {} + + RedirectedStreams::~RedirectedStreams() { + m_redirectedCout += m_redirectedStdOut.str(); + m_redirectedCerr += m_redirectedStdErr.str(); + } + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + +#if defined(_MSC_VER) + TempFile::TempFile() { + if (tmpnam_s(m_buffer)) { + CATCH_RUNTIME_ERROR("Could not get a temp filename"); + } + if (fopen_s(&m_file, m_buffer, "w+")) { + char buffer[100]; + if (strerror_s(buffer, errno)) { + CATCH_RUNTIME_ERROR("Could not translate errno to a string"); + } + CATCH_RUNTIME_ERROR("Could not open the temp file: '" << m_buffer << "' because: " << buffer); + } + } +#else + TempFile::TempFile() { + m_file = std::tmpfile(); + if (!m_file) { + CATCH_RUNTIME_ERROR("Could not create a temp file."); + } + } + +#endif + + TempFile::~TempFile() { + // TBD: What to do about errors here? + std::fclose(m_file); + // We manually create the file on Windows only, on Linux + // it will be autodeleted +#if defined(_MSC_VER) + std::remove(m_buffer); +#endif + } + + FILE* TempFile::getFile() { + return m_file; + } + + std::string TempFile::getContents() { + std::stringstream sstr; + char buffer[100] = {}; + std::rewind(m_file); + while (std::fgets(buffer, sizeof(buffer), m_file)) { + sstr << buffer; + } + return sstr.str(); + } + + OutputRedirect::OutputRedirect(std::string& stdout_dest, std::string& stderr_dest) : + m_originalStdout(dup(1)), + m_originalStderr(dup(2)), + m_stdoutDest(stdout_dest), + m_stderrDest(stderr_dest) { + dup2(fileno(m_stdoutFile.getFile()), 1); + dup2(fileno(m_stderrFile.getFile()), 2); + } + + OutputRedirect::~OutputRedirect() { + Catch::cout() << std::flush; + fflush(stdout); + // Since we support overriding these streams, we flush cerr + // even though std::cerr is unbuffered + Catch::cerr() << std::flush; + Catch::clog() << std::flush; + fflush(stderr); + + dup2(m_originalStdout, 1); + dup2(m_originalStderr, 2); + + m_stdoutDest += m_stdoutFile.getContents(); + m_stderrDest += m_stderrFile.getContents(); + } + +#endif // CATCH_CONFIG_NEW_CAPTURE + +} // namespace Catch + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + #if defined(_MSC_VER) + #undef dup + #undef dup2 + #undef fileno + #endif +#endif +// end catch_output_redirect.cpp +// start catch_polyfills.cpp + +#include <cmath> + +namespace Catch { + +#if !defined(CATCH_CONFIG_POLYFILL_ISNAN) + bool isnan(float f) { + return std::isnan(f); + } + bool isnan(double d) { + return std::isnan(d); + } +#else + // For now we only use this for embarcadero + bool isnan(float f) { + return std::_isnan(f); + } + bool isnan(double d) { + return std::_isnan(d); + } +#endif + +} // end namespace Catch +// end catch_polyfills.cpp +// start catch_random_number_generator.cpp + +namespace Catch { + +namespace { + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4146) // we negate uint32 during the rotate +#endif + // Safe rotr implementation thanks to John Regehr + uint32_t rotate_right(uint32_t val, uint32_t count) { + const uint32_t mask = 31; + count &= mask; + return (val >> count) | (val << (-count & mask)); + } + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + +} + + SimplePcg32::SimplePcg32(result_type seed_) { + seed(seed_); + } + + void SimplePcg32::seed(result_type seed_) { + m_state = 0; + (*this)(); + m_state += seed_; + (*this)(); + } + + void SimplePcg32::discard(uint64_t skip) { + // We could implement this to run in O(log n) steps, but this + // should suffice for our use case. + for (uint64_t s = 0; s < skip; ++s) { + static_cast<void>((*this)()); + } + } + + SimplePcg32::result_type SimplePcg32::operator()() { + // prepare the output value + const uint32_t xorshifted = static_cast<uint32_t>(((m_state >> 18u) ^ m_state) >> 27u); + const auto output = rotate_right(xorshifted, m_state >> 59u); + + // advance state + m_state = m_state * 6364136223846793005ULL + s_inc; + + return output; + } + + bool operator==(SimplePcg32 const& lhs, SimplePcg32 const& rhs) { + return lhs.m_state == rhs.m_state; + } + + bool operator!=(SimplePcg32 const& lhs, SimplePcg32 const& rhs) { + return lhs.m_state != rhs.m_state; + } +} +// end catch_random_number_generator.cpp +// start catch_registry_hub.cpp + +// start catch_test_case_registry_impl.h + +#include <vector> +#include <set> +#include <algorithm> +#include <ios> + +namespace Catch { + + class TestCase; + struct IConfig; + + std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ); + + bool isThrowSafe( TestCase const& testCase, IConfig const& config ); + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); + + void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions ); + + std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ); + std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config ); + + class TestRegistry : public ITestCaseRegistry { + public: + virtual ~TestRegistry() = default; + + virtual void registerTest( TestCase const& testCase ); + + std::vector<TestCase> const& getAllTests() const override; + std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const override; + + private: + std::vector<TestCase> m_functions; + mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder; + mutable std::vector<TestCase> m_sortedFunctions; + std::size_t m_unnamedCount = 0; + std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised + }; + + /////////////////////////////////////////////////////////////////////////// + + class TestInvokerAsFunction : public ITestInvoker { + void(*m_testAsFunction)(); + public: + TestInvokerAsFunction( void(*testAsFunction)() ) noexcept; + + void invoke() const override; + }; + + std::string extractClassName( StringRef const& classOrQualifiedMethodName ); + + /////////////////////////////////////////////////////////////////////////// + +} // end namespace Catch + +// end catch_test_case_registry_impl.h +// start catch_reporter_registry.h + +#include <map> + +namespace Catch { + + class ReporterRegistry : public IReporterRegistry { + + public: + + ~ReporterRegistry() override; + + IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override; + + void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ); + void registerListener( IReporterFactoryPtr const& factory ); + + FactoryMap const& getFactories() const override; + Listeners const& getListeners() const override; + + private: + FactoryMap m_factories; + Listeners m_listeners; + }; +} + +// end catch_reporter_registry.h +// start catch_tag_alias_registry.h + +// start catch_tag_alias.h + +#include <string> + +namespace Catch { + + struct TagAlias { + TagAlias(std::string const& _tag, SourceLineInfo _lineInfo); + + std::string tag; + SourceLineInfo lineInfo; + }; + +} // end namespace Catch + +// end catch_tag_alias.h +#include <map> + +namespace Catch { + + class TagAliasRegistry : public ITagAliasRegistry { + public: + ~TagAliasRegistry() override; + TagAlias const* find( std::string const& alias ) const override; + std::string expandAliases( std::string const& unexpandedTestSpec ) const override; + void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ); + + private: + std::map<std::string, TagAlias> m_registry; + }; + +} // end namespace Catch + +// end catch_tag_alias_registry.h +// start catch_startup_exception_registry.h + +#include <vector> +#include <exception> + +namespace Catch { + + class StartupExceptionRegistry { +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + public: + void add(std::exception_ptr const& exception) noexcept; + std::vector<std::exception_ptr> const& getExceptions() const noexcept; + private: + std::vector<std::exception_ptr> m_exceptions; +#endif + }; + +} // end namespace Catch + +// end catch_startup_exception_registry.h +// start catch_singletons.hpp + +namespace Catch { + + struct ISingleton { + virtual ~ISingleton(); + }; + + void addSingleton( ISingleton* singleton ); + void cleanupSingletons(); + + template<typename SingletonImplT, typename InterfaceT = SingletonImplT, typename MutableInterfaceT = InterfaceT> + class Singleton : SingletonImplT, public ISingleton { + + static auto getInternal() -> Singleton* { + static Singleton* s_instance = nullptr; + if( !s_instance ) { + s_instance = new Singleton; + addSingleton( s_instance ); + } + return s_instance; + } + + public: + static auto get() -> InterfaceT const& { + return *getInternal(); + } + static auto getMutable() -> MutableInterfaceT& { + return *getInternal(); + } + }; + +} // namespace Catch + +// end catch_singletons.hpp +namespace Catch { + + namespace { + + class RegistryHub : public IRegistryHub, public IMutableRegistryHub, + private NonCopyable { + + public: // IRegistryHub + RegistryHub() = default; + IReporterRegistry const& getReporterRegistry() const override { + return m_reporterRegistry; + } + ITestCaseRegistry const& getTestCaseRegistry() const override { + return m_testCaseRegistry; + } + IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const override { + return m_exceptionTranslatorRegistry; + } + ITagAliasRegistry const& getTagAliasRegistry() const override { + return m_tagAliasRegistry; + } + StartupExceptionRegistry const& getStartupExceptionRegistry() const override { + return m_exceptionRegistry; + } + + public: // IMutableRegistryHub + void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) override { + m_reporterRegistry.registerReporter( name, factory ); + } + void registerListener( IReporterFactoryPtr const& factory ) override { + m_reporterRegistry.registerListener( factory ); + } + void registerTest( TestCase const& testInfo ) override { + m_testCaseRegistry.registerTest( testInfo ); + } + void registerTranslator( const IExceptionTranslator* translator ) override { + m_exceptionTranslatorRegistry.registerTranslator( translator ); + } + void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override { + m_tagAliasRegistry.add( alias, tag, lineInfo ); + } + void registerStartupException() noexcept override { +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + m_exceptionRegistry.add(std::current_exception()); +#else + CATCH_INTERNAL_ERROR("Attempted to register active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); +#endif + } + IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() override { + return m_enumValuesRegistry; + } + + private: + TestRegistry m_testCaseRegistry; + ReporterRegistry m_reporterRegistry; + ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; + TagAliasRegistry m_tagAliasRegistry; + StartupExceptionRegistry m_exceptionRegistry; + Detail::EnumValuesRegistry m_enumValuesRegistry; + }; + } + + using RegistryHubSingleton = Singleton<RegistryHub, IRegistryHub, IMutableRegistryHub>; + + IRegistryHub const& getRegistryHub() { + return RegistryHubSingleton::get(); + } + IMutableRegistryHub& getMutableRegistryHub() { + return RegistryHubSingleton::getMutable(); + } + void cleanUp() { + cleanupSingletons(); + cleanUpContext(); + } + std::string translateActiveException() { + return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException(); + } + +} // end namespace Catch +// end catch_registry_hub.cpp +// start catch_reporter_registry.cpp + +namespace Catch { + + ReporterRegistry::~ReporterRegistry() = default; + + IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfigPtr const& config ) const { + auto it = m_factories.find( name ); + if( it == m_factories.end() ) + return nullptr; + return it->second->create( ReporterConfig( config ) ); + } + + void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) { + m_factories.emplace(name, factory); + } + void ReporterRegistry::registerListener( IReporterFactoryPtr const& factory ) { + m_listeners.push_back( factory ); + } + + IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const { + return m_factories; + } + IReporterRegistry::Listeners const& ReporterRegistry::getListeners() const { + return m_listeners; + } + +} +// end catch_reporter_registry.cpp +// start catch_result_type.cpp + +namespace Catch { + + bool isOk( ResultWas::OfType resultType ) { + return ( resultType & ResultWas::FailureBit ) == 0; + } + bool isJustInfo( int flags ) { + return flags == ResultWas::Info; + } + + ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { + return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) ); + } + + bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } + bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } + +} // end namespace Catch +// end catch_result_type.cpp +// start catch_run_context.cpp + +#include <cassert> +#include <algorithm> +#include <sstream> + +namespace Catch { + + namespace Generators { + struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorTracker { + GeneratorBasePtr m_generator; + + GeneratorTracker( TestCaseTracking::NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) + : TrackerBase( nameAndLocation, ctx, parent ) + {} + ~GeneratorTracker(); + + static GeneratorTracker& acquire( TrackerContext& ctx, TestCaseTracking::NameAndLocation const& nameAndLocation ) { + std::shared_ptr<GeneratorTracker> tracker; + + ITracker& currentTracker = ctx.currentTracker(); + // Under specific circumstances, the generator we want + // to acquire is also the current tracker. If this is + // the case, we have to avoid looking through current + // tracker's children, and instead return the current + // tracker. + // A case where this check is important is e.g. + // for (int i = 0; i < 5; ++i) { + // int n = GENERATE(1, 2); + // } + // + // without it, the code above creates 5 nested generators. + if (currentTracker.nameAndLocation() == nameAndLocation) { + auto thisTracker = currentTracker.parent().findChild(nameAndLocation); + assert(thisTracker); + assert(thisTracker->isGeneratorTracker()); + tracker = std::static_pointer_cast<GeneratorTracker>(thisTracker); + } else if ( TestCaseTracking::ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { + assert( childTracker ); + assert( childTracker->isGeneratorTracker() ); + tracker = std::static_pointer_cast<GeneratorTracker>( childTracker ); + } else { + tracker = std::make_shared<GeneratorTracker>( nameAndLocation, ctx, ¤tTracker ); + currentTracker.addChild( tracker ); + } + + if( !tracker->isComplete() ) { + tracker->open(); + } + + return *tracker; + } + + // TrackerBase interface + bool isGeneratorTracker() const override { return true; } + auto hasGenerator() const -> bool override { + return !!m_generator; + } + void close() override { + TrackerBase::close(); + // If a generator has a child (it is followed by a section) + // and none of its children have started, then we must wait + // until later to start consuming its values. + // This catches cases where `GENERATE` is placed between two + // `SECTION`s. + // **The check for m_children.empty cannot be removed**. + // doing so would break `GENERATE` _not_ followed by `SECTION`s. + const bool should_wait_for_child = [&]() { + // No children -> nobody to wait for + if ( m_children.empty() ) { + return false; + } + // If at least one child started executing, don't wait + if ( std::find_if( + m_children.begin(), + m_children.end(), + []( TestCaseTracking::ITrackerPtr tracker ) { + return tracker->hasStarted(); + } ) != m_children.end() ) { + return false; + } + + // No children have started. We need to check if they _can_ + // start, and thus we should wait for them, or they cannot + // start (due to filters), and we shouldn't wait for them + auto* parent = m_parent; + // This is safe: there is always at least one section + // tracker in a test case tracking tree + while ( !parent->isSectionTracker() ) { + parent = &( parent->parent() ); + } + assert( parent && + "Missing root (test case) level section" ); + + auto const& parentSection = + static_cast<SectionTracker&>( *parent ); + auto const& filters = parentSection.getFilters(); + // No filters -> no restrictions on running sections + if ( filters.empty() ) { + return true; + } + + for ( auto const& child : m_children ) { + if ( child->isSectionTracker() && + std::find( filters.begin(), + filters.end(), + static_cast<SectionTracker&>( *child ) + .trimmedName() ) != + filters.end() ) { + return true; + } + } + return false; + }(); + + // This check is a bit tricky, because m_generator->next() + // has a side-effect, where it consumes generator's current + // value, but we do not want to invoke the side-effect if + // this generator is still waiting for any child to start. + if ( should_wait_for_child || + ( m_runState == CompletedSuccessfully && + m_generator->next() ) ) { + m_children.clear(); + m_runState = Executing; + } + } + + // IGeneratorTracker interface + auto getGenerator() const -> GeneratorBasePtr const& override { + return m_generator; + } + void setGenerator( GeneratorBasePtr&& generator ) override { + m_generator = std::move( generator ); + } + }; + GeneratorTracker::~GeneratorTracker() {} + } + + RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter) + : m_runInfo(_config->name()), + m_context(getCurrentMutableContext()), + m_config(_config), + m_reporter(std::move(reporter)), + m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, + m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) + { + m_context.setRunner(this); + m_context.setConfig(m_config); + m_context.setResultCapture(this); + m_reporter->testRunStarting(m_runInfo); + } + + RunContext::~RunContext() { + m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, aborting())); + } + + void RunContext::testGroupStarting(std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount) { + m_reporter->testGroupStarting(GroupInfo(testSpec, groupIndex, groupsCount)); + } + + void RunContext::testGroupEnded(std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount) { + m_reporter->testGroupEnded(TestGroupStats(GroupInfo(testSpec, groupIndex, groupsCount), totals, aborting())); + } + + Totals RunContext::runTest(TestCase const& testCase) { + Totals prevTotals = m_totals; + + std::string redirectedCout; + std::string redirectedCerr; + + auto const& testInfo = testCase.getTestCaseInfo(); + + m_reporter->testCaseStarting(testInfo); + + m_activeTestCase = &testCase; + + ITracker& rootTracker = m_trackerContext.startRun(); + assert(rootTracker.isSectionTracker()); + static_cast<SectionTracker&>(rootTracker).addInitialFilters(m_config->getSectionsToRun()); + do { + m_trackerContext.startCycle(); + m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(testInfo.name, testInfo.lineInfo)); + runCurrentTest(redirectedCout, redirectedCerr); + } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting()); + + Totals deltaTotals = m_totals.delta(prevTotals); + if (testInfo.expectedToFail() && deltaTotals.testCases.passed > 0) { + deltaTotals.assertions.failed++; + deltaTotals.testCases.passed--; + deltaTotals.testCases.failed++; + } + m_totals.testCases += deltaTotals.testCases; + m_reporter->testCaseEnded(TestCaseStats(testInfo, + deltaTotals, + redirectedCout, + redirectedCerr, + aborting())); + + m_activeTestCase = nullptr; + m_testCaseTracker = nullptr; + + return deltaTotals; + } + + IConfigPtr RunContext::config() const { + return m_config; + } + + IStreamingReporter& RunContext::reporter() const { + return *m_reporter; + } + + void RunContext::assertionEnded(AssertionResult const & result) { + if (result.getResultType() == ResultWas::Ok) { + m_totals.assertions.passed++; + m_lastAssertionPassed = true; + } else if (!result.isOk()) { + m_lastAssertionPassed = false; + if( m_activeTestCase->getTestCaseInfo().okToFail() ) + m_totals.assertions.failedButOk++; + else + m_totals.assertions.failed++; + } + else { + m_lastAssertionPassed = true; + } + + // We have no use for the return value (whether messages should be cleared), because messages were made scoped + // and should be let to clear themselves out. + static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals))); + + if (result.getResultType() != ResultWas::Warning) + m_messageScopes.clear(); + + // Reset working state + resetAssertionInfo(); + m_lastResult = result; + } + void RunContext::resetAssertionInfo() { + m_lastAssertionInfo.macroName = StringRef(); + m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"_sr; + } + + bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) { + ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo)); + if (!sectionTracker.isOpen()) + return false; + m_activeSections.push_back(§ionTracker); + + m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; + + m_reporter->sectionStarting(sectionInfo); + + assertions = m_totals.assertions; + + return true; + } + auto RunContext::acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { + using namespace Generators; + GeneratorTracker& tracker = GeneratorTracker::acquire(m_trackerContext, + TestCaseTracking::NameAndLocation( static_cast<std::string>(generatorName), lineInfo ) ); + m_lastAssertionInfo.lineInfo = lineInfo; + return tracker; + } + + bool RunContext::testForMissingAssertions(Counts& assertions) { + if (assertions.total() != 0) + return false; + if (!m_config->warnAboutMissingAssertions()) + return false; + if (m_trackerContext.currentTracker().hasChildren()) + return false; + m_totals.assertions.failed++; + assertions.failed++; + return true; + } + + void RunContext::sectionEnded(SectionEndInfo const & endInfo) { + Counts assertions = m_totals.assertions - endInfo.prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); + + if (!m_activeSections.empty()) { + m_activeSections.back()->close(); + m_activeSections.pop_back(); + } + + m_reporter->sectionEnded(SectionStats(endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions)); + m_messages.clear(); + m_messageScopes.clear(); + } + + void RunContext::sectionEndedEarly(SectionEndInfo const & endInfo) { + if (m_unfinishedSections.empty()) + m_activeSections.back()->fail(); + else + m_activeSections.back()->close(); + m_activeSections.pop_back(); + + m_unfinishedSections.push_back(endInfo); + } + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + void RunContext::benchmarkPreparing(std::string const& name) { + m_reporter->benchmarkPreparing(name); + } + void RunContext::benchmarkStarting( BenchmarkInfo const& info ) { + m_reporter->benchmarkStarting( info ); + } + void RunContext::benchmarkEnded( BenchmarkStats<> const& stats ) { + m_reporter->benchmarkEnded( stats ); + } + void RunContext::benchmarkFailed(std::string const & error) { + m_reporter->benchmarkFailed(error); + } +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + void RunContext::pushScopedMessage(MessageInfo const & message) { + m_messages.push_back(message); + } + + void RunContext::popScopedMessage(MessageInfo const & message) { + m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end()); + } + + void RunContext::emplaceUnscopedMessage( MessageBuilder const& builder ) { + m_messageScopes.emplace_back( builder ); + } + + std::string RunContext::getCurrentTestName() const { + return m_activeTestCase + ? m_activeTestCase->getTestCaseInfo().name + : std::string(); + } + + const AssertionResult * RunContext::getLastResult() const { + return &(*m_lastResult); + } + + void RunContext::exceptionEarlyReported() { + m_shouldReportUnexpected = false; + } + + void RunContext::handleFatalErrorCondition( StringRef message ) { + // First notify reporter that bad things happened + m_reporter->fatalErrorEncountered(message); + + // Don't rebuild the result -- the stringification itself can cause more fatal errors + // Instead, fake a result data. + AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } ); + tempResult.message = static_cast<std::string>(message); + AssertionResult result(m_lastAssertionInfo, tempResult); + + assertionEnded(result); + + handleUnfinishedSections(); + + // Recreate section for test case (as we will lose the one that was in scope) + auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); + SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); + + Counts assertions; + assertions.failed = 1; + SectionStats testCaseSectionStats(testCaseSection, assertions, 0, false); + m_reporter->sectionEnded(testCaseSectionStats); + + auto const& testInfo = m_activeTestCase->getTestCaseInfo(); + + Totals deltaTotals; + deltaTotals.testCases.failed = 1; + deltaTotals.assertions.failed = 1; + m_reporter->testCaseEnded(TestCaseStats(testInfo, + deltaTotals, + std::string(), + std::string(), + false)); + m_totals.testCases.failed++; + testGroupEnded(std::string(), m_totals, 1, 1); + m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, false)); + } + + bool RunContext::lastAssertionPassed() { + return m_lastAssertionPassed; + } + + void RunContext::assertionPassed() { + m_lastAssertionPassed = true; + ++m_totals.assertions.passed; + resetAssertionInfo(); + m_messageScopes.clear(); + } + + bool RunContext::aborting() const { + return m_totals.assertions.failed >= static_cast<std::size_t>(m_config->abortAfter()); + } + + void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) { + auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); + SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); + m_reporter->sectionStarting(testCaseSection); + Counts prevAssertions = m_totals.assertions; + double duration = 0; + m_shouldReportUnexpected = true; + m_lastAssertionInfo = { "TEST_CASE"_sr, testCaseInfo.lineInfo, StringRef(), ResultDisposition::Normal }; + + seedRng(*m_config); + + Timer timer; + CATCH_TRY { + if (m_reporter->getPreferences().shouldRedirectStdOut) { +#if !defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) + RedirectedStreams redirectedStreams(redirectedCout, redirectedCerr); + + timer.start(); + invokeActiveTestCase(); +#else + OutputRedirect r(redirectedCout, redirectedCerr); + timer.start(); + invokeActiveTestCase(); +#endif + } else { + timer.start(); + invokeActiveTestCase(); + } + duration = timer.getElapsedSeconds(); + } CATCH_CATCH_ANON (TestFailureException&) { + // This just means the test was aborted due to failure + } CATCH_CATCH_ALL { + // Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions + // are reported without translation at the point of origin. + if( m_shouldReportUnexpected ) { + AssertionReaction dummyReaction; + handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction ); + } + } + Counts assertions = m_totals.assertions - prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); + + m_testCaseTracker->close(); + handleUnfinishedSections(); + m_messages.clear(); + m_messageScopes.clear(); + + SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions); + m_reporter->sectionEnded(testCaseSectionStats); + } + + void RunContext::invokeActiveTestCase() { + FatalConditionHandlerGuard _(&m_fatalConditionhandler); + m_activeTestCase->invoke(); + } + + void RunContext::handleUnfinishedSections() { + // If sections ended prematurely due to an exception we stored their + // infos here so we can tear them down outside the unwind process. + for (auto it = m_unfinishedSections.rbegin(), + itEnd = m_unfinishedSections.rend(); + it != itEnd; + ++it) + sectionEnded(*it); + m_unfinishedSections.clear(); + } + + void RunContext::handleExpr( + AssertionInfo const& info, + ITransientExpression const& expr, + AssertionReaction& reaction + ) { + m_reporter->assertionStarting( info ); + + bool negated = isFalseTest( info.resultDisposition ); + bool result = expr.getResult() != negated; + + if( result ) { + if (!m_includeSuccessfulResults) { + assertionPassed(); + } + else { + reportExpr(info, ResultWas::Ok, &expr, negated); + } + } + else { + reportExpr(info, ResultWas::ExpressionFailed, &expr, negated ); + populateReaction( reaction ); + } + } + void RunContext::reportExpr( + AssertionInfo const &info, + ResultWas::OfType resultType, + ITransientExpression const *expr, + bool negated ) { + + m_lastAssertionInfo = info; + AssertionResultData data( resultType, LazyExpression( negated ) ); + + AssertionResult assertionResult{ info, data }; + assertionResult.m_resultData.lazyExpression.m_transientExpression = expr; + + assertionEnded( assertionResult ); + } + + void RunContext::handleMessage( + AssertionInfo const& info, + ResultWas::OfType resultType, + StringRef const& message, + AssertionReaction& reaction + ) { + m_reporter->assertionStarting( info ); + + m_lastAssertionInfo = info; + + AssertionResultData data( resultType, LazyExpression( false ) ); + data.message = static_cast<std::string>(message); + AssertionResult assertionResult{ m_lastAssertionInfo, data }; + assertionEnded( assertionResult ); + if( !assertionResult.isOk() ) + populateReaction( reaction ); + } + void RunContext::handleUnexpectedExceptionNotThrown( + AssertionInfo const& info, + AssertionReaction& reaction + ) { + handleNonExpr(info, Catch::ResultWas::DidntThrowException, reaction); + } + + void RunContext::handleUnexpectedInflightException( + AssertionInfo const& info, + std::string const& message, + AssertionReaction& reaction + ) { + m_lastAssertionInfo = info; + + AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); + data.message = message; + AssertionResult assertionResult{ info, data }; + assertionEnded( assertionResult ); + populateReaction( reaction ); + } + + void RunContext::populateReaction( AssertionReaction& reaction ) { + reaction.shouldDebugBreak = m_config->shouldDebugBreak(); + reaction.shouldThrow = aborting() || (m_lastAssertionInfo.resultDisposition & ResultDisposition::Normal); + } + + void RunContext::handleIncomplete( + AssertionInfo const& info + ) { + m_lastAssertionInfo = info; + + AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); + data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"; + AssertionResult assertionResult{ info, data }; + assertionEnded( assertionResult ); + } + void RunContext::handleNonExpr( + AssertionInfo const &info, + ResultWas::OfType resultType, + AssertionReaction &reaction + ) { + m_lastAssertionInfo = info; + + AssertionResultData data( resultType, LazyExpression( false ) ); + AssertionResult assertionResult{ info, data }; + assertionEnded( assertionResult ); + + if( !assertionResult.isOk() ) + populateReaction( reaction ); + } + + IResultCapture& getResultCapture() { + if (auto* capture = getCurrentContext().getResultCapture()) + return *capture; + else + CATCH_INTERNAL_ERROR("No result capture instance"); + } + + void seedRng(IConfig const& config) { + if (config.rngSeed() != 0) { + std::srand(config.rngSeed()); + rng().seed(config.rngSeed()); + } + } + + unsigned int rngSeed() { + return getCurrentContext().getConfig()->rngSeed(); + } + +} +// end catch_run_context.cpp +// start catch_section.cpp + +namespace Catch { + + Section::Section( SectionInfo const& info ) + : m_info( info ), + m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) + { + m_timer.start(); + } + + Section::~Section() { + if( m_sectionIncluded ) { + SectionEndInfo endInfo{ m_info, m_assertions, m_timer.getElapsedSeconds() }; + if( uncaught_exceptions() ) + getResultCapture().sectionEndedEarly( endInfo ); + else + getResultCapture().sectionEnded( endInfo ); + } + } + + // This indicates whether the section should be executed or not + Section::operator bool() const { + return m_sectionIncluded; + } + +} // end namespace Catch +// end catch_section.cpp +// start catch_section_info.cpp + +namespace Catch { + + SectionInfo::SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name ) + : name( _name ), + lineInfo( _lineInfo ) + {} + +} // end namespace Catch +// end catch_section_info.cpp +// start catch_session.cpp + +// start catch_session.h + +#include <memory> + +namespace Catch { + + class Session : NonCopyable { + public: + + Session(); + ~Session() override; + + void showHelp() const; + void libIdentify(); + + int applyCommandLine( int argc, char const * const * argv ); + #if defined(CATCH_CONFIG_WCHAR) && defined(_WIN32) && defined(UNICODE) + int applyCommandLine( int argc, wchar_t const * const * argv ); + #endif + + void useConfigData( ConfigData const& configData ); + + template<typename CharT> + int run(int argc, CharT const * const argv[]) { + if (m_startupExceptions) + return 1; + int returnCode = applyCommandLine(argc, argv); + if (returnCode == 0) + returnCode = run(); + return returnCode; + } + + int run(); + + clara::Parser const& cli() const; + void cli( clara::Parser const& newParser ); + ConfigData& configData(); + Config& config(); + private: + int runInternal(); + + clara::Parser m_cli; + ConfigData m_configData; + std::shared_ptr<Config> m_config; + bool m_startupExceptions = false; + }; + +} // end namespace Catch + +// end catch_session.h +// start catch_version.h + +#include <iosfwd> + +namespace Catch { + + // Versioning information + struct Version { + Version( Version const& ) = delete; + Version& operator=( Version const& ) = delete; + Version( unsigned int _majorVersion, + unsigned int _minorVersion, + unsigned int _patchNumber, + char const * const _branchName, + unsigned int _buildNumber ); + + unsigned int const majorVersion; + unsigned int const minorVersion; + unsigned int const patchNumber; + + // buildNumber is only used if branchName is not null + char const * const branchName; + unsigned int const buildNumber; + + friend std::ostream& operator << ( std::ostream& os, Version const& version ); + }; + + Version const& libraryVersion(); +} + +// end catch_version.h +#include <cstdlib> +#include <iomanip> +#include <set> +#include <iterator> + +namespace Catch { + + namespace { + const int MaxExitCode = 255; + + IStreamingReporterPtr createReporter(std::string const& reporterName, IConfigPtr const& config) { + auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, config); + CATCH_ENFORCE(reporter, "No reporter registered with name: '" << reporterName << "'"); + + return reporter; + } + + IStreamingReporterPtr makeReporter(std::shared_ptr<Config> const& config) { + if (Catch::getRegistryHub().getReporterRegistry().getListeners().empty()) { + return createReporter(config->getReporterName(), config); + } + + // On older platforms, returning std::unique_ptr<ListeningReporter> + // when the return type is std::unique_ptr<IStreamingReporter> + // doesn't compile without a std::move call. However, this causes + // a warning on newer platforms. Thus, we have to work around + // it a bit and downcast the pointer manually. + auto ret = std::unique_ptr<IStreamingReporter>(new ListeningReporter); + auto& multi = static_cast<ListeningReporter&>(*ret); + auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners(); + for (auto const& listener : listeners) { + multi.addListener(listener->create(Catch::ReporterConfig(config))); + } + multi.addReporter(createReporter(config->getReporterName(), config)); + return ret; + } + + class TestGroup { + public: + explicit TestGroup(std::shared_ptr<Config> const& config) + : m_config{config} + , m_context{config, makeReporter(config)} + { + auto const& allTestCases = getAllTestCasesSorted(*m_config); + m_matches = m_config->testSpec().matchesByFilter(allTestCases, *m_config); + auto const& invalidArgs = m_config->testSpec().getInvalidArgs(); + + if (m_matches.empty() && invalidArgs.empty()) { + for (auto const& test : allTestCases) + if (!test.isHidden()) + m_tests.emplace(&test); + } else { + for (auto const& match : m_matches) + m_tests.insert(match.tests.begin(), match.tests.end()); + } + } + + Totals execute() { + auto const& invalidArgs = m_config->testSpec().getInvalidArgs(); + Totals totals; + m_context.testGroupStarting(m_config->name(), 1, 1); + for (auto const& testCase : m_tests) { + if (!m_context.aborting()) + totals += m_context.runTest(*testCase); + else + m_context.reporter().skipTest(*testCase); + } + + for (auto const& match : m_matches) { + if (match.tests.empty()) { + m_context.reporter().noMatchingTestCases(match.name); + totals.error = -1; + } + } + + if (!invalidArgs.empty()) { + for (auto const& invalidArg: invalidArgs) + m_context.reporter().reportInvalidArguments(invalidArg); + } + + m_context.testGroupEnded(m_config->name(), totals, 1, 1); + return totals; + } + + private: + using Tests = std::set<TestCase const*>; + + std::shared_ptr<Config> m_config; + RunContext m_context; + Tests m_tests; + TestSpec::Matches m_matches; + }; + + void applyFilenamesAsTags(Catch::IConfig const& config) { + auto& tests = const_cast<std::vector<TestCase>&>(getAllTestCasesSorted(config)); + for (auto& testCase : tests) { + auto tags = testCase.tags; + + std::string filename = testCase.lineInfo.file; + auto lastSlash = filename.find_last_of("\\/"); + if (lastSlash != std::string::npos) { + filename.erase(0, lastSlash); + filename[0] = '#'; + } + else + { + filename.insert(0, "#"); + } + + auto lastDot = filename.find_last_of('.'); + if (lastDot != std::string::npos) { + filename.erase(lastDot); + } + + tags.push_back(std::move(filename)); + setTags(testCase, tags); + } + } + + } // anon namespace + + Session::Session() { + static bool alreadyInstantiated = false; + if( alreadyInstantiated ) { + CATCH_TRY { CATCH_INTERNAL_ERROR( "Only one instance of Catch::Session can ever be used" ); } + CATCH_CATCH_ALL { getMutableRegistryHub().registerStartupException(); } + } + + // There cannot be exceptions at startup in no-exception mode. +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + const auto& exceptions = getRegistryHub().getStartupExceptionRegistry().getExceptions(); + if ( !exceptions.empty() ) { + config(); + getCurrentMutableContext().setConfig(m_config); + + m_startupExceptions = true; + Colour colourGuard( Colour::Red ); + Catch::cerr() << "Errors occurred during startup!" << '\n'; + // iterate over all exceptions and notify user + for ( const auto& ex_ptr : exceptions ) { + try { + std::rethrow_exception(ex_ptr); + } catch ( std::exception const& ex ) { + Catch::cerr() << Column( ex.what() ).indent(2) << '\n'; + } + } + } +#endif + + alreadyInstantiated = true; + m_cli = makeCommandLineParser( m_configData ); + } + Session::~Session() { + Catch::cleanUp(); + } + + void Session::showHelp() const { + Catch::cout() + << "\nCatch v" << libraryVersion() << "\n" + << m_cli << std::endl + << "For more detailed usage please see the project docs\n" << std::endl; + } + void Session::libIdentify() { + Catch::cout() + << std::left << std::setw(16) << "description: " << "A Catch2 test executable\n" + << std::left << std::setw(16) << "category: " << "testframework\n" + << std::left << std::setw(16) << "framework: " << "Catch Test\n" + << std::left << std::setw(16) << "version: " << libraryVersion() << std::endl; + } + + int Session::applyCommandLine( int argc, char const * const * argv ) { + if( m_startupExceptions ) + return 1; + + auto result = m_cli.parse( clara::Args( argc, argv ) ); + if( !result ) { + config(); + getCurrentMutableContext().setConfig(m_config); + Catch::cerr() + << Colour( Colour::Red ) + << "\nError(s) in input:\n" + << Column( result.errorMessage() ).indent( 2 ) + << "\n\n"; + Catch::cerr() << "Run with -? for usage\n" << std::endl; + return MaxExitCode; + } + + if( m_configData.showHelp ) + showHelp(); + if( m_configData.libIdentify ) + libIdentify(); + m_config.reset(); + return 0; + } + +#if defined(CATCH_CONFIG_WCHAR) && defined(_WIN32) && defined(UNICODE) + int Session::applyCommandLine( int argc, wchar_t const * const * argv ) { + + char **utf8Argv = new char *[ argc ]; + + for ( int i = 0; i < argc; ++i ) { + int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, nullptr, 0, nullptr, nullptr ); + + utf8Argv[ i ] = new char[ bufSize ]; + + WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, nullptr, nullptr ); + } + + int returnCode = applyCommandLine( argc, utf8Argv ); + + for ( int i = 0; i < argc; ++i ) + delete [] utf8Argv[ i ]; + + delete [] utf8Argv; + + return returnCode; + } +#endif + + void Session::useConfigData( ConfigData const& configData ) { + m_configData = configData; + m_config.reset(); + } + + int Session::run() { + if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) { + Catch::cout() << "...waiting for enter/ return before starting" << std::endl; + static_cast<void>(std::getchar()); + } + int exitCode = runInternal(); + if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) { + Catch::cout() << "...waiting for enter/ return before exiting, with code: " << exitCode << std::endl; + static_cast<void>(std::getchar()); + } + return exitCode; + } + + clara::Parser const& Session::cli() const { + return m_cli; + } + void Session::cli( clara::Parser const& newParser ) { + m_cli = newParser; + } + ConfigData& Session::configData() { + return m_configData; + } + Config& Session::config() { + if( !m_config ) + m_config = std::make_shared<Config>( m_configData ); + return *m_config; + } + + int Session::runInternal() { + if( m_startupExceptions ) + return 1; + + if (m_configData.showHelp || m_configData.libIdentify) { + return 0; + } + + CATCH_TRY { + config(); // Force config to be constructed + + seedRng( *m_config ); + + if( m_configData.filenamesAsTags ) + applyFilenamesAsTags( *m_config ); + + // Handle list request + if( Option<std::size_t> listed = list( m_config ) ) + return (std::min) (MaxExitCode, static_cast<int>(*listed)); + + TestGroup tests { m_config }; + auto const totals = tests.execute(); + + if( m_config->warnAboutNoTests() && totals.error == -1 ) + return 2; + + // Note that on unices only the lower 8 bits are usually used, clamping + // the return value to 255 prevents false negative when some multiple + // of 256 tests has failed + return (std::min) (MaxExitCode, (std::max) (totals.error, static_cast<int>(totals.assertions.failed))); + } +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + catch( std::exception& ex ) { + Catch::cerr() << ex.what() << std::endl; + return MaxExitCode; + } +#endif + } + +} // end namespace Catch +// end catch_session.cpp +// start catch_singletons.cpp + +#include <vector> + +namespace Catch { + + namespace { + static auto getSingletons() -> std::vector<ISingleton*>*& { + static std::vector<ISingleton*>* g_singletons = nullptr; + if( !g_singletons ) + g_singletons = new std::vector<ISingleton*>(); + return g_singletons; + } + } + + ISingleton::~ISingleton() {} + + void addSingleton(ISingleton* singleton ) { + getSingletons()->push_back( singleton ); + } + void cleanupSingletons() { + auto& singletons = getSingletons(); + for( auto singleton : *singletons ) + delete singleton; + delete singletons; + singletons = nullptr; + } + +} // namespace Catch +// end catch_singletons.cpp +// start catch_startup_exception_registry.cpp + +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +namespace Catch { +void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { + CATCH_TRY { + m_exceptions.push_back(exception); + } CATCH_CATCH_ALL { + // If we run out of memory during start-up there's really not a lot more we can do about it + std::terminate(); + } + } + + std::vector<std::exception_ptr> const& StartupExceptionRegistry::getExceptions() const noexcept { + return m_exceptions; + } + +} // end namespace Catch +#endif +// end catch_startup_exception_registry.cpp +// start catch_stream.cpp + +#include <cstdio> +#include <iostream> +#include <fstream> +#include <sstream> +#include <vector> +#include <memory> + +namespace Catch { + + Catch::IStream::~IStream() = default; + + namespace Detail { namespace { + template<typename WriterF, std::size_t bufferSize=256> + class StreamBufImpl : public std::streambuf { + char data[bufferSize]; + WriterF m_writer; + + public: + StreamBufImpl() { + setp( data, data + sizeof(data) ); + } + + ~StreamBufImpl() noexcept { + StreamBufImpl::sync(); + } + + private: + int overflow( int c ) override { + sync(); + + if( c != EOF ) { + if( pbase() == epptr() ) + m_writer( std::string( 1, static_cast<char>( c ) ) ); + else + sputc( static_cast<char>( c ) ); + } + return 0; + } + + int sync() override { + if( pbase() != pptr() ) { + m_writer( std::string( pbase(), static_cast<std::string::size_type>( pptr() - pbase() ) ) ); + setp( pbase(), epptr() ); + } + return 0; + } + }; + + /////////////////////////////////////////////////////////////////////////// + + struct OutputDebugWriter { + + void operator()( std::string const&str ) { + writeToDebugConsole( str ); + } + }; + + /////////////////////////////////////////////////////////////////////////// + + class FileStream : public IStream { + mutable std::ofstream m_ofs; + public: + FileStream( StringRef filename ) { + m_ofs.open( filename.c_str() ); + CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << "'" ); + } + ~FileStream() override = default; + public: // IStream + std::ostream& stream() const override { + return m_ofs; + } + }; + + /////////////////////////////////////////////////////////////////////////// + + class CoutStream : public IStream { + mutable std::ostream m_os; + public: + // Store the streambuf from cout up-front because + // cout may get redirected when running tests + CoutStream() : m_os( Catch::cout().rdbuf() ) {} + ~CoutStream() override = default; + + public: // IStream + std::ostream& stream() const override { return m_os; } + }; + + /////////////////////////////////////////////////////////////////////////// + + class DebugOutStream : public IStream { + std::unique_ptr<StreamBufImpl<OutputDebugWriter>> m_streamBuf; + mutable std::ostream m_os; + public: + DebugOutStream() + : m_streamBuf( new StreamBufImpl<OutputDebugWriter>() ), + m_os( m_streamBuf.get() ) + {} + + ~DebugOutStream() override = default; + + public: // IStream + std::ostream& stream() const override { return m_os; } + }; + + }} // namespace anon::detail + + /////////////////////////////////////////////////////////////////////////// + + auto makeStream( StringRef const &filename ) -> IStream const* { + if( filename.empty() ) + return new Detail::CoutStream(); + else if( filename[0] == '%' ) { + if( filename == "%debug" ) + return new Detail::DebugOutStream(); + else + CATCH_ERROR( "Unrecognised stream: '" << filename << "'" ); + } + else + return new Detail::FileStream( filename ); + } + + // This class encapsulates the idea of a pool of ostringstreams that can be reused. + struct StringStreams { + std::vector<std::unique_ptr<std::ostringstream>> m_streams; + std::vector<std::size_t> m_unused; + std::ostringstream m_referenceStream; // Used for copy state/ flags from + + auto add() -> std::size_t { + if( m_unused.empty() ) { + m_streams.push_back( std::unique_ptr<std::ostringstream>( new std::ostringstream ) ); + return m_streams.size()-1; + } + else { + auto index = m_unused.back(); + m_unused.pop_back(); + return index; + } + } + + void release( std::size_t index ) { + m_streams[index]->copyfmt( m_referenceStream ); // Restore initial flags and other state + m_unused.push_back(index); + } + }; + + ReusableStringStream::ReusableStringStream() + : m_index( Singleton<StringStreams>::getMutable().add() ), + m_oss( Singleton<StringStreams>::getMutable().m_streams[m_index].get() ) + {} + + ReusableStringStream::~ReusableStringStream() { + static_cast<std::ostringstream*>( m_oss )->str(""); + m_oss->clear(); + Singleton<StringStreams>::getMutable().release( m_index ); + } + + auto ReusableStringStream::str() const -> std::string { + return static_cast<std::ostringstream*>( m_oss )->str(); + } + + /////////////////////////////////////////////////////////////////////////// + +#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions + std::ostream& cout() { return std::cout; } + std::ostream& cerr() { return std::cerr; } + std::ostream& clog() { return std::clog; } +#endif +} +// end catch_stream.cpp +// start catch_string_manip.cpp + +#include <algorithm> +#include <ostream> +#include <cstring> +#include <cctype> +#include <vector> + +namespace Catch { + + namespace { + char toLowerCh(char c) { + return static_cast<char>( std::tolower( static_cast<unsigned char>(c) ) ); + } + } + + bool startsWith( std::string const& s, std::string const& prefix ) { + return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin()); + } + bool startsWith( std::string const& s, char prefix ) { + return !s.empty() && s[0] == prefix; + } + bool endsWith( std::string const& s, std::string const& suffix ) { + return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin()); + } + bool endsWith( std::string const& s, char suffix ) { + return !s.empty() && s[s.size()-1] == suffix; + } + bool contains( std::string const& s, std::string const& infix ) { + return s.find( infix ) != std::string::npos; + } + void toLowerInPlace( std::string& s ) { + std::transform( s.begin(), s.end(), s.begin(), toLowerCh ); + } + std::string toLower( std::string const& s ) { + std::string lc = s; + toLowerInPlace( lc ); + return lc; + } + std::string trim( std::string const& str ) { + static char const* whitespaceChars = "\n\r\t "; + std::string::size_type start = str.find_first_not_of( whitespaceChars ); + std::string::size_type end = str.find_last_not_of( whitespaceChars ); + + return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string(); + } + + StringRef trim(StringRef ref) { + const auto is_ws = [](char c) { + return c == ' ' || c == '\t' || c == '\n' || c == '\r'; + }; + size_t real_begin = 0; + while (real_begin < ref.size() && is_ws(ref[real_begin])) { ++real_begin; } + size_t real_end = ref.size(); + while (real_end > real_begin && is_ws(ref[real_end - 1])) { --real_end; } + + return ref.substr(real_begin, real_end - real_begin); + } + + bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { + bool replaced = false; + std::size_t i = str.find( replaceThis ); + while( i != std::string::npos ) { + replaced = true; + str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() ); + if( i < str.size()-withThis.size() ) + i = str.find( replaceThis, i+withThis.size() ); + else + i = std::string::npos; + } + return replaced; + } + + std::vector<StringRef> splitStringRef( StringRef str, char delimiter ) { + std::vector<StringRef> subStrings; + std::size_t start = 0; + for(std::size_t pos = 0; pos < str.size(); ++pos ) { + if( str[pos] == delimiter ) { + if( pos - start > 1 ) + subStrings.push_back( str.substr( start, pos-start ) ); + start = pos+1; + } + } + if( start < str.size() ) + subStrings.push_back( str.substr( start, str.size()-start ) ); + return subStrings; + } + + pluralise::pluralise( std::size_t count, std::string const& label ) + : m_count( count ), + m_label( label ) + {} + + std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { + os << pluraliser.m_count << ' ' << pluraliser.m_label; + if( pluraliser.m_count != 1 ) + os << 's'; + return os; + } + +} +// end catch_string_manip.cpp +// start catch_stringref.cpp + +#include <algorithm> +#include <ostream> +#include <cstring> +#include <cstdint> + +namespace Catch { + StringRef::StringRef( char const* rawChars ) noexcept + : StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) ) + {} + + auto StringRef::c_str() const -> char const* { + CATCH_ENFORCE(isNullTerminated(), "Called StringRef::c_str() on a non-null-terminated instance"); + return m_start; + } + auto StringRef::data() const noexcept -> char const* { + return m_start; + } + + auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef { + if (start < m_size) { + return StringRef(m_start + start, (std::min)(m_size - start, size)); + } else { + return StringRef(); + } + } + auto StringRef::operator == ( StringRef const& other ) const noexcept -> bool { + return m_size == other.m_size + && (std::memcmp( m_start, other.m_start, m_size ) == 0); + } + + auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& { + return os.write(str.data(), str.size()); + } + + auto operator+=( std::string& lhs, StringRef const& rhs ) -> std::string& { + lhs.append(rhs.data(), rhs.size()); + return lhs; + } + +} // namespace Catch +// end catch_stringref.cpp +// start catch_tag_alias.cpp + +namespace Catch { + TagAlias::TagAlias(std::string const & _tag, SourceLineInfo _lineInfo): tag(_tag), lineInfo(_lineInfo) {} +} +// end catch_tag_alias.cpp +// start catch_tag_alias_autoregistrar.cpp + +namespace Catch { + + RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) { + CATCH_TRY { + getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo); + } CATCH_CATCH_ALL { + // Do not throw when constructing global objects, instead register the exception to be processed later + getMutableRegistryHub().registerStartupException(); + } + } + +} +// end catch_tag_alias_autoregistrar.cpp +// start catch_tag_alias_registry.cpp + +#include <sstream> + +namespace Catch { + + TagAliasRegistry::~TagAliasRegistry() {} + + TagAlias const* TagAliasRegistry::find( std::string const& alias ) const { + auto it = m_registry.find( alias ); + if( it != m_registry.end() ) + return &(it->second); + else + return nullptr; + } + + std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const { + std::string expandedTestSpec = unexpandedTestSpec; + for( auto const& registryKvp : m_registry ) { + std::size_t pos = expandedTestSpec.find( registryKvp.first ); + if( pos != std::string::npos ) { + expandedTestSpec = expandedTestSpec.substr( 0, pos ) + + registryKvp.second.tag + + expandedTestSpec.substr( pos + registryKvp.first.size() ); + } + } + return expandedTestSpec; + } + + void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) { + CATCH_ENFORCE( startsWith(alias, "[@") && endsWith(alias, ']'), + "error: tag alias, '" << alias << "' is not of the form [@alias name].\n" << lineInfo ); + + CATCH_ENFORCE( m_registry.insert(std::make_pair(alias, TagAlias(tag, lineInfo))).second, + "error: tag alias, '" << alias << "' already registered.\n" + << "\tFirst seen at: " << find(alias)->lineInfo << "\n" + << "\tRedefined at: " << lineInfo ); + } + + ITagAliasRegistry::~ITagAliasRegistry() {} + + ITagAliasRegistry const& ITagAliasRegistry::get() { + return getRegistryHub().getTagAliasRegistry(); + } + +} // end namespace Catch +// end catch_tag_alias_registry.cpp +// start catch_test_case_info.cpp + +#include <cctype> +#include <exception> +#include <algorithm> +#include <sstream> + +namespace Catch { + + namespace { + TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) { + if( startsWith( tag, '.' ) || + tag == "!hide" ) + return TestCaseInfo::IsHidden; + else if( tag == "!throws" ) + return TestCaseInfo::Throws; + else if( tag == "!shouldfail" ) + return TestCaseInfo::ShouldFail; + else if( tag == "!mayfail" ) + return TestCaseInfo::MayFail; + else if( tag == "!nonportable" ) + return TestCaseInfo::NonPortable; + else if( tag == "!benchmark" ) + return static_cast<TestCaseInfo::SpecialProperties>( TestCaseInfo::Benchmark | TestCaseInfo::IsHidden ); + else + return TestCaseInfo::None; + } + bool isReservedTag( std::string const& tag ) { + return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( static_cast<unsigned char>(tag[0]) ); + } + void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { + CATCH_ENFORCE( !isReservedTag(tag), + "Tag name: [" << tag << "] is not allowed.\n" + << "Tag names starting with non alphanumeric characters are reserved\n" + << _lineInfo ); + } + } + + TestCase makeTestCase( ITestInvoker* _testCase, + std::string const& _className, + NameAndTags const& nameAndTags, + SourceLineInfo const& _lineInfo ) + { + bool isHidden = false; + + // Parse out tags + std::vector<std::string> tags; + std::string desc, tag; + bool inTag = false; + for (char c : nameAndTags.tags) { + if( !inTag ) { + if( c == '[' ) + inTag = true; + else + desc += c; + } + else { + if( c == ']' ) { + TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag ); + if( ( prop & TestCaseInfo::IsHidden ) != 0 ) + isHidden = true; + else if( prop == TestCaseInfo::None ) + enforceNotReservedTag( tag, _lineInfo ); + + // Merged hide tags like `[.approvals]` should be added as + // `[.][approvals]`. The `[.]` is added at later point, so + // we only strip the prefix + if (startsWith(tag, '.') && tag.size() > 1) { + tag.erase(0, 1); + } + tags.push_back( tag ); + tag.clear(); + inTag = false; + } + else + tag += c; + } + } + if( isHidden ) { + // Add all "hidden" tags to make them behave identically + tags.insert( tags.end(), { ".", "!hide" } ); + } + + TestCaseInfo info( static_cast<std::string>(nameAndTags.name), _className, desc, tags, _lineInfo ); + return TestCase( _testCase, std::move(info) ); + } + + void setTags( TestCaseInfo& testCaseInfo, std::vector<std::string> tags ) { + std::sort(begin(tags), end(tags)); + tags.erase(std::unique(begin(tags), end(tags)), end(tags)); + testCaseInfo.lcaseTags.clear(); + + for( auto const& tag : tags ) { + std::string lcaseTag = toLower( tag ); + testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) ); + testCaseInfo.lcaseTags.push_back( lcaseTag ); + } + testCaseInfo.tags = std::move(tags); + } + + TestCaseInfo::TestCaseInfo( std::string const& _name, + std::string const& _className, + std::string const& _description, + std::vector<std::string> const& _tags, + SourceLineInfo const& _lineInfo ) + : name( _name ), + className( _className ), + description( _description ), + lineInfo( _lineInfo ), + properties( None ) + { + setTags( *this, _tags ); + } + + bool TestCaseInfo::isHidden() const { + return ( properties & IsHidden ) != 0; + } + bool TestCaseInfo::throws() const { + return ( properties & Throws ) != 0; + } + bool TestCaseInfo::okToFail() const { + return ( properties & (ShouldFail | MayFail ) ) != 0; + } + bool TestCaseInfo::expectedToFail() const { + return ( properties & (ShouldFail ) ) != 0; + } + + std::string TestCaseInfo::tagsAsString() const { + std::string ret; + // '[' and ']' per tag + std::size_t full_size = 2 * tags.size(); + for (const auto& tag : tags) { + full_size += tag.size(); + } + ret.reserve(full_size); + for (const auto& tag : tags) { + ret.push_back('['); + ret.append(tag); + ret.push_back(']'); + } + + return ret; + } + + TestCase::TestCase( ITestInvoker* testCase, TestCaseInfo&& info ) : TestCaseInfo( std::move(info) ), test( testCase ) {} + + TestCase TestCase::withName( std::string const& _newName ) const { + TestCase other( *this ); + other.name = _newName; + return other; + } + + void TestCase::invoke() const { + test->invoke(); + } + + bool TestCase::operator == ( TestCase const& other ) const { + return test.get() == other.test.get() && + name == other.name && + className == other.className; + } + + bool TestCase::operator < ( TestCase const& other ) const { + return name < other.name; + } + + TestCaseInfo const& TestCase::getTestCaseInfo() const + { + return *this; + } + +} // end namespace Catch +// end catch_test_case_info.cpp +// start catch_test_case_registry_impl.cpp + +#include <algorithm> +#include <sstream> + +namespace Catch { + + namespace { + struct TestHasher { + using hash_t = uint64_t; + + explicit TestHasher( hash_t hashSuffix ): + m_hashSuffix{ hashSuffix } {} + + uint32_t operator()( TestCase const& t ) const { + // FNV-1a hash with multiplication fold. + const hash_t prime = 1099511628211u; + hash_t hash = 14695981039346656037u; + for ( const char c : t.name ) { + hash ^= c; + hash *= prime; + } + hash ^= m_hashSuffix; + hash *= prime; + const uint32_t low{ static_cast<uint32_t>( hash ) }; + const uint32_t high{ static_cast<uint32_t>( hash >> 32 ) }; + return low * high; + } + + private: + hash_t m_hashSuffix; + }; + } // end unnamed namespace + + std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) { + switch( config.runOrder() ) { + case RunTests::InDeclarationOrder: + // already in declaration order + break; + + case RunTests::InLexicographicalOrder: { + std::vector<TestCase> sorted = unsortedTestCases; + std::sort( sorted.begin(), sorted.end() ); + return sorted; + } + + case RunTests::InRandomOrder: { + seedRng( config ); + TestHasher h{ config.rngSeed() }; + + using hashedTest = std::pair<TestHasher::hash_t, TestCase const*>; + std::vector<hashedTest> indexed_tests; + indexed_tests.reserve( unsortedTestCases.size() ); + + for (auto const& testCase : unsortedTestCases) { + indexed_tests.emplace_back(h(testCase), &testCase); + } + + std::sort(indexed_tests.begin(), indexed_tests.end(), + [](hashedTest const& lhs, hashedTest const& rhs) { + if (lhs.first == rhs.first) { + return lhs.second->name < rhs.second->name; + } + return lhs.first < rhs.first; + }); + + std::vector<TestCase> sorted; + sorted.reserve( indexed_tests.size() ); + + for (auto const& hashed : indexed_tests) { + sorted.emplace_back(*hashed.second); + } + + return sorted; + } + } + return unsortedTestCases; + } + + bool isThrowSafe( TestCase const& testCase, IConfig const& config ) { + return !testCase.throws() || config.allowThrows(); + } + + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) { + return testSpec.matches( testCase ) && isThrowSafe( testCase, config ); + } + + void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions ) { + std::set<TestCase> seenFunctions; + for( auto const& function : functions ) { + auto prev = seenFunctions.insert( function ); + CATCH_ENFORCE( prev.second, + "error: TEST_CASE( \"" << function.name << "\" ) already defined.\n" + << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n" + << "\tRedefined at " << function.getTestCaseInfo().lineInfo ); + } + } + + std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ) { + std::vector<TestCase> filtered; + filtered.reserve( testCases.size() ); + for (auto const& testCase : testCases) { + if ((!testSpec.hasFilters() && !testCase.isHidden()) || + (testSpec.hasFilters() && matchTest(testCase, testSpec, config))) { + filtered.push_back(testCase); + } + } + return filtered; + } + std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config ) { + return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config ); + } + + void TestRegistry::registerTest( TestCase const& testCase ) { + std::string name = testCase.getTestCaseInfo().name; + if( name.empty() ) { + ReusableStringStream rss; + rss << "Anonymous test case " << ++m_unnamedCount; + return registerTest( testCase.withName( rss.str() ) ); + } + m_functions.push_back( testCase ); + } + + std::vector<TestCase> const& TestRegistry::getAllTests() const { + return m_functions; + } + std::vector<TestCase> const& TestRegistry::getAllTestsSorted( IConfig const& config ) const { + if( m_sortedFunctions.empty() ) + enforceNoDuplicateTestCases( m_functions ); + + if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) { + m_sortedFunctions = sortTests( config, m_functions ); + m_currentSortOrder = config.runOrder(); + } + return m_sortedFunctions; + } + + /////////////////////////////////////////////////////////////////////////// + TestInvokerAsFunction::TestInvokerAsFunction( void(*testAsFunction)() ) noexcept : m_testAsFunction( testAsFunction ) {} + + void TestInvokerAsFunction::invoke() const { + m_testAsFunction(); + } + + std::string extractClassName( StringRef const& classOrQualifiedMethodName ) { + std::string className(classOrQualifiedMethodName); + if( startsWith( className, '&' ) ) + { + std::size_t lastColons = className.rfind( "::" ); + std::size_t penultimateColons = className.rfind( "::", lastColons-1 ); + if( penultimateColons == std::string::npos ) + penultimateColons = 1; + className = className.substr( penultimateColons, lastColons-penultimateColons ); + } + return className; + } + +} // end namespace Catch +// end catch_test_case_registry_impl.cpp +// start catch_test_case_tracker.cpp + +#include <algorithm> +#include <cassert> +#include <stdexcept> +#include <memory> +#include <sstream> + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +namespace Catch { +namespace TestCaseTracking { + + NameAndLocation::NameAndLocation( std::string const& _name, SourceLineInfo const& _location ) + : name( _name ), + location( _location ) + {} + + ITracker::~ITracker() = default; + + ITracker& TrackerContext::startRun() { + m_rootTracker = std::make_shared<SectionTracker>( NameAndLocation( "{root}", CATCH_INTERNAL_LINEINFO ), *this, nullptr ); + m_currentTracker = nullptr; + m_runState = Executing; + return *m_rootTracker; + } + + void TrackerContext::endRun() { + m_rootTracker.reset(); + m_currentTracker = nullptr; + m_runState = NotStarted; + } + + void TrackerContext::startCycle() { + m_currentTracker = m_rootTracker.get(); + m_runState = Executing; + } + void TrackerContext::completeCycle() { + m_runState = CompletedCycle; + } + + bool TrackerContext::completedCycle() const { + return m_runState == CompletedCycle; + } + ITracker& TrackerContext::currentTracker() { + return *m_currentTracker; + } + void TrackerContext::setCurrentTracker( ITracker* tracker ) { + m_currentTracker = tracker; + } + + TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ): + ITracker(nameAndLocation), + m_ctx( ctx ), + m_parent( parent ) + {} + + bool TrackerBase::isComplete() const { + return m_runState == CompletedSuccessfully || m_runState == Failed; + } + bool TrackerBase::isSuccessfullyCompleted() const { + return m_runState == CompletedSuccessfully; + } + bool TrackerBase::isOpen() const { + return m_runState != NotStarted && !isComplete(); + } + bool TrackerBase::hasChildren() const { + return !m_children.empty(); + } + + void TrackerBase::addChild( ITrackerPtr const& child ) { + m_children.push_back( child ); + } + + ITrackerPtr TrackerBase::findChild( NameAndLocation const& nameAndLocation ) { + auto it = std::find_if( m_children.begin(), m_children.end(), + [&nameAndLocation]( ITrackerPtr const& tracker ){ + return + tracker->nameAndLocation().location == nameAndLocation.location && + tracker->nameAndLocation().name == nameAndLocation.name; + } ); + return( it != m_children.end() ) + ? *it + : nullptr; + } + ITracker& TrackerBase::parent() { + assert( m_parent ); // Should always be non-null except for root + return *m_parent; + } + + void TrackerBase::openChild() { + if( m_runState != ExecutingChildren ) { + m_runState = ExecutingChildren; + if( m_parent ) + m_parent->openChild(); + } + } + + bool TrackerBase::isSectionTracker() const { return false; } + bool TrackerBase::isGeneratorTracker() const { return false; } + + void TrackerBase::open() { + m_runState = Executing; + moveToThis(); + if( m_parent ) + m_parent->openChild(); + } + + void TrackerBase::close() { + + // Close any still open children (e.g. generators) + while( &m_ctx.currentTracker() != this ) + m_ctx.currentTracker().close(); + + switch( m_runState ) { + case NeedsAnotherRun: + break; + + case Executing: + m_runState = CompletedSuccessfully; + break; + case ExecutingChildren: + if( std::all_of(m_children.begin(), m_children.end(), [](ITrackerPtr const& t){ return t->isComplete(); }) ) + m_runState = CompletedSuccessfully; + break; + + case NotStarted: + case CompletedSuccessfully: + case Failed: + CATCH_INTERNAL_ERROR( "Illogical state: " << m_runState ); + + default: + CATCH_INTERNAL_ERROR( "Unknown state: " << m_runState ); + } + moveToParent(); + m_ctx.completeCycle(); + } + void TrackerBase::fail() { + m_runState = Failed; + if( m_parent ) + m_parent->markAsNeedingAnotherRun(); + moveToParent(); + m_ctx.completeCycle(); + } + void TrackerBase::markAsNeedingAnotherRun() { + m_runState = NeedsAnotherRun; + } + + void TrackerBase::moveToParent() { + assert( m_parent ); + m_ctx.setCurrentTracker( m_parent ); + } + void TrackerBase::moveToThis() { + m_ctx.setCurrentTracker( this ); + } + + SectionTracker::SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) + : TrackerBase( nameAndLocation, ctx, parent ), + m_trimmed_name(trim(nameAndLocation.name)) + { + if( parent ) { + while( !parent->isSectionTracker() ) + parent = &parent->parent(); + + SectionTracker& parentSection = static_cast<SectionTracker&>( *parent ); + addNextFilters( parentSection.m_filters ); + } + } + + bool SectionTracker::isComplete() const { + bool complete = true; + + if (m_filters.empty() + || m_filters[0] == "" + || std::find(m_filters.begin(), m_filters.end(), m_trimmed_name) != m_filters.end()) { + complete = TrackerBase::isComplete(); + } + return complete; + } + + bool SectionTracker::isSectionTracker() const { return true; } + + SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) { + std::shared_ptr<SectionTracker> section; + + ITracker& currentTracker = ctx.currentTracker(); + if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { + assert( childTracker ); + assert( childTracker->isSectionTracker() ); + section = std::static_pointer_cast<SectionTracker>( childTracker ); + } + else { + section = std::make_shared<SectionTracker>( nameAndLocation, ctx, ¤tTracker ); + currentTracker.addChild( section ); + } + if( !ctx.completedCycle() ) + section->tryOpen(); + return *section; + } + + void SectionTracker::tryOpen() { + if( !isComplete() ) + open(); + } + + void SectionTracker::addInitialFilters( std::vector<std::string> const& filters ) { + if( !filters.empty() ) { + m_filters.reserve( m_filters.size() + filters.size() + 2 ); + m_filters.emplace_back(""); // Root - should never be consulted + m_filters.emplace_back(""); // Test Case - not a section filter + m_filters.insert( m_filters.end(), filters.begin(), filters.end() ); + } + } + void SectionTracker::addNextFilters( std::vector<std::string> const& filters ) { + if( filters.size() > 1 ) + m_filters.insert( m_filters.end(), filters.begin()+1, filters.end() ); + } + + std::vector<std::string> const& SectionTracker::getFilters() const { + return m_filters; + } + + std::string const& SectionTracker::trimmedName() const { + return m_trimmed_name; + } + +} // namespace TestCaseTracking + +using TestCaseTracking::ITracker; +using TestCaseTracking::TrackerContext; +using TestCaseTracking::SectionTracker; + +} // namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +// end catch_test_case_tracker.cpp +// start catch_test_registry.cpp + +namespace Catch { + + auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker* { + return new(std::nothrow) TestInvokerAsFunction( testAsFunction ); + } + + NameAndTags::NameAndTags( StringRef const& name_ , StringRef const& tags_ ) noexcept : name( name_ ), tags( tags_ ) {} + + AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept { + CATCH_TRY { + getMutableRegistryHub() + .registerTest( + makeTestCase( + invoker, + extractClassName( classOrMethod ), + nameAndTags, + lineInfo)); + } CATCH_CATCH_ALL { + // Do not throw when constructing global objects, instead register the exception to be processed later + getMutableRegistryHub().registerStartupException(); + } + } + + AutoReg::~AutoReg() = default; +} +// end catch_test_registry.cpp +// start catch_test_spec.cpp + +#include <algorithm> +#include <string> +#include <vector> +#include <memory> + +namespace Catch { + + TestSpec::Pattern::Pattern( std::string const& name ) + : m_name( name ) + {} + + TestSpec::Pattern::~Pattern() = default; + + std::string const& TestSpec::Pattern::name() const { + return m_name; + } + + TestSpec::NamePattern::NamePattern( std::string const& name, std::string const& filterString ) + : Pattern( filterString ) + , m_wildcardPattern( toLower( name ), CaseSensitive::No ) + {} + + bool TestSpec::NamePattern::matches( TestCaseInfo const& testCase ) const { + return m_wildcardPattern.matches( testCase.name ); + } + + TestSpec::TagPattern::TagPattern( std::string const& tag, std::string const& filterString ) + : Pattern( filterString ) + , m_tag( toLower( tag ) ) + {} + + bool TestSpec::TagPattern::matches( TestCaseInfo const& testCase ) const { + return std::find(begin(testCase.lcaseTags), + end(testCase.lcaseTags), + m_tag) != end(testCase.lcaseTags); + } + + TestSpec::ExcludedPattern::ExcludedPattern( PatternPtr const& underlyingPattern ) + : Pattern( underlyingPattern->name() ) + , m_underlyingPattern( underlyingPattern ) + {} + + bool TestSpec::ExcludedPattern::matches( TestCaseInfo const& testCase ) const { + return !m_underlyingPattern->matches( testCase ); + } + + bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const { + return std::all_of( m_patterns.begin(), m_patterns.end(), [&]( PatternPtr const& p ){ return p->matches( testCase ); } ); + } + + std::string TestSpec::Filter::name() const { + std::string name; + for( auto const& p : m_patterns ) + name += p->name(); + return name; + } + + bool TestSpec::hasFilters() const { + return !m_filters.empty(); + } + + bool TestSpec::matches( TestCaseInfo const& testCase ) const { + return std::any_of( m_filters.begin(), m_filters.end(), [&]( Filter const& f ){ return f.matches( testCase ); } ); + } + + TestSpec::Matches TestSpec::matchesByFilter( std::vector<TestCase> const& testCases, IConfig const& config ) const + { + Matches matches( m_filters.size() ); + std::transform( m_filters.begin(), m_filters.end(), matches.begin(), [&]( Filter const& filter ){ + std::vector<TestCase const*> currentMatches; + for( auto const& test : testCases ) + if( isThrowSafe( test, config ) && filter.matches( test ) ) + currentMatches.emplace_back( &test ); + return FilterMatch{ filter.name(), currentMatches }; + } ); + return matches; + } + + const TestSpec::vectorStrings& TestSpec::getInvalidArgs() const{ + return (m_invalidArgs); + } + +} +// end catch_test_spec.cpp +// start catch_test_spec_parser.cpp + +namespace Catch { + + TestSpecParser::TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {} + + TestSpecParser& TestSpecParser::parse( std::string const& arg ) { + m_mode = None; + m_exclusion = false; + m_arg = m_tagAliases->expandAliases( arg ); + m_escapeChars.clear(); + m_substring.reserve(m_arg.size()); + m_patternName.reserve(m_arg.size()); + m_realPatternPos = 0; + + for( m_pos = 0; m_pos < m_arg.size(); ++m_pos ) + //if visitChar fails + if( !visitChar( m_arg[m_pos] ) ){ + m_testSpec.m_invalidArgs.push_back(arg); + break; + } + endMode(); + return *this; + } + TestSpec TestSpecParser::testSpec() { + addFilter(); + return m_testSpec; + } + bool TestSpecParser::visitChar( char c ) { + if( (m_mode != EscapedName) && (c == '\\') ) { + escape(); + addCharToPattern(c); + return true; + }else if((m_mode != EscapedName) && (c == ',') ) { + return separate(); + } + + switch( m_mode ) { + case None: + if( processNoneChar( c ) ) + return true; + break; + case Name: + processNameChar( c ); + break; + case EscapedName: + endMode(); + addCharToPattern(c); + return true; + default: + case Tag: + case QuotedName: + if( processOtherChar( c ) ) + return true; + break; + } + + m_substring += c; + if( !isControlChar( c ) ) { + m_patternName += c; + m_realPatternPos++; + } + return true; + } + // Two of the processing methods return true to signal the caller to return + // without adding the given character to the current pattern strings + bool TestSpecParser::processNoneChar( char c ) { + switch( c ) { + case ' ': + return true; + case '~': + m_exclusion = true; + return false; + case '[': + startNewMode( Tag ); + return false; + case '"': + startNewMode( QuotedName ); + return false; + default: + startNewMode( Name ); + return false; + } + } + void TestSpecParser::processNameChar( char c ) { + if( c == '[' ) { + if( m_substring == "exclude:" ) + m_exclusion = true; + else + endMode(); + startNewMode( Tag ); + } + } + bool TestSpecParser::processOtherChar( char c ) { + if( !isControlChar( c ) ) + return false; + m_substring += c; + endMode(); + return true; + } + void TestSpecParser::startNewMode( Mode mode ) { + m_mode = mode; + } + void TestSpecParser::endMode() { + switch( m_mode ) { + case Name: + case QuotedName: + return addNamePattern(); + case Tag: + return addTagPattern(); + case EscapedName: + revertBackToLastMode(); + return; + case None: + default: + return startNewMode( None ); + } + } + void TestSpecParser::escape() { + saveLastMode(); + m_mode = EscapedName; + m_escapeChars.push_back(m_realPatternPos); + } + bool TestSpecParser::isControlChar( char c ) const { + switch( m_mode ) { + default: + return false; + case None: + return c == '~'; + case Name: + return c == '['; + case EscapedName: + return true; + case QuotedName: + return c == '"'; + case Tag: + return c == '[' || c == ']'; + } + } + + void TestSpecParser::addFilter() { + if( !m_currentFilter.m_patterns.empty() ) { + m_testSpec.m_filters.push_back( m_currentFilter ); + m_currentFilter = TestSpec::Filter(); + } + } + + void TestSpecParser::saveLastMode() { + lastMode = m_mode; + } + + void TestSpecParser::revertBackToLastMode() { + m_mode = lastMode; + } + + bool TestSpecParser::separate() { + if( (m_mode==QuotedName) || (m_mode==Tag) ){ + //invalid argument, signal failure to previous scope. + m_mode = None; + m_pos = m_arg.size(); + m_substring.clear(); + m_patternName.clear(); + m_realPatternPos = 0; + return false; + } + endMode(); + addFilter(); + return true; //success + } + + std::string TestSpecParser::preprocessPattern() { + std::string token = m_patternName; + for (std::size_t i = 0; i < m_escapeChars.size(); ++i) + token = token.substr(0, m_escapeChars[i] - i) + token.substr(m_escapeChars[i] - i + 1); + m_escapeChars.clear(); + if (startsWith(token, "exclude:")) { + m_exclusion = true; + token = token.substr(8); + } + + m_patternName.clear(); + m_realPatternPos = 0; + + return token; + } + + void TestSpecParser::addNamePattern() { + auto token = preprocessPattern(); + + if (!token.empty()) { + TestSpec::PatternPtr pattern = std::make_shared<TestSpec::NamePattern>(token, m_substring); + if (m_exclusion) + pattern = std::make_shared<TestSpec::ExcludedPattern>(pattern); + m_currentFilter.m_patterns.push_back(pattern); + } + m_substring.clear(); + m_exclusion = false; + m_mode = None; + } + + void TestSpecParser::addTagPattern() { + auto token = preprocessPattern(); + + if (!token.empty()) { + // If the tag pattern is the "hide and tag" shorthand (e.g. [.foo]) + // we have to create a separate hide tag and shorten the real one + if (token.size() > 1 && token[0] == '.') { + token.erase(token.begin()); + TestSpec::PatternPtr pattern = std::make_shared<TestSpec::TagPattern>(".", m_substring); + if (m_exclusion) { + pattern = std::make_shared<TestSpec::ExcludedPattern>(pattern); + } + m_currentFilter.m_patterns.push_back(pattern); + } + + TestSpec::PatternPtr pattern = std::make_shared<TestSpec::TagPattern>(token, m_substring); + + if (m_exclusion) { + pattern = std::make_shared<TestSpec::ExcludedPattern>(pattern); + } + m_currentFilter.m_patterns.push_back(pattern); + } + m_substring.clear(); + m_exclusion = false; + m_mode = None; + } + + TestSpec parseTestSpec( std::string const& arg ) { + return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec(); + } + +} // namespace Catch +// end catch_test_spec_parser.cpp +// start catch_timer.cpp + +#include <chrono> + +static const uint64_t nanosecondsInSecond = 1000000000; + +namespace Catch { + + auto getCurrentNanosecondsSinceEpoch() -> uint64_t { + return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count(); + } + + namespace { + auto estimateClockResolution() -> uint64_t { + uint64_t sum = 0; + static const uint64_t iterations = 1000000; + + auto startTime = getCurrentNanosecondsSinceEpoch(); + + for( std::size_t i = 0; i < iterations; ++i ) { + + uint64_t ticks; + uint64_t baseTicks = getCurrentNanosecondsSinceEpoch(); + do { + ticks = getCurrentNanosecondsSinceEpoch(); + } while( ticks == baseTicks ); + + auto delta = ticks - baseTicks; + sum += delta; + + // If we have been calibrating for over 3 seconds -- the clock + // is terrible and we should move on. + // TBD: How to signal that the measured resolution is probably wrong? + if (ticks > startTime + 3 * nanosecondsInSecond) { + return sum / ( i + 1u ); + } + } + + // We're just taking the mean, here. To do better we could take the std. dev and exclude outliers + // - and potentially do more iterations if there's a high variance. + return sum/iterations; + } + } + auto getEstimatedClockResolution() -> uint64_t { + static auto s_resolution = estimateClockResolution(); + return s_resolution; + } + + void Timer::start() { + m_nanoseconds = getCurrentNanosecondsSinceEpoch(); + } + auto Timer::getElapsedNanoseconds() const -> uint64_t { + return getCurrentNanosecondsSinceEpoch() - m_nanoseconds; + } + auto Timer::getElapsedMicroseconds() const -> uint64_t { + return getElapsedNanoseconds()/1000; + } + auto Timer::getElapsedMilliseconds() const -> unsigned int { + return static_cast<unsigned int>(getElapsedMicroseconds()/1000); + } + auto Timer::getElapsedSeconds() const -> double { + return getElapsedMicroseconds()/1000000.0; + } + +} // namespace Catch +// end catch_timer.cpp +// start catch_tostring.cpp + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +# pragma clang diagnostic ignored "-Wglobal-constructors" +#endif + +// Enable specific decls locally +#if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +#endif + +#include <cmath> +#include <iomanip> + +namespace Catch { + +namespace Detail { + + const std::string unprintableString = "{?}"; + + namespace { + const int hexThreshold = 255; + + struct Endianness { + enum Arch { Big, Little }; + + static Arch which() { + int one = 1; + // If the lowest byte we read is non-zero, we can assume + // that little endian format is used. + auto value = *reinterpret_cast<char*>(&one); + return value ? Little : Big; + } + }; + } + + std::string rawMemoryToString( const void *object, std::size_t size ) { + // Reverse order for little endian architectures + int i = 0, end = static_cast<int>( size ), inc = 1; + if( Endianness::which() == Endianness::Little ) { + i = end-1; + end = inc = -1; + } + + unsigned char const *bytes = static_cast<unsigned char const *>(object); + ReusableStringStream rss; + rss << "0x" << std::setfill('0') << std::hex; + for( ; i != end; i += inc ) + rss << std::setw(2) << static_cast<unsigned>(bytes[i]); + return rss.str(); + } +} + +template<typename T> +std::string fpToString( T value, int precision ) { + if (Catch::isnan(value)) { + return "nan"; + } + + ReusableStringStream rss; + rss << std::setprecision( precision ) + << std::fixed + << value; + std::string d = rss.str(); + std::size_t i = d.find_last_not_of( '0' ); + if( i != std::string::npos && i != d.size()-1 ) { + if( d[i] == '.' ) + i++; + d = d.substr( 0, i+1 ); + } + return d; +} + +//// ======================================================= //// +// +// Out-of-line defs for full specialization of StringMaker +// +//// ======================================================= //// + +std::string StringMaker<std::string>::convert(const std::string& str) { + if (!getCurrentContext().getConfig()->showInvisibles()) { + return '"' + str + '"'; + } + + std::string s("\""); + for (char c : str) { + switch (c) { + case '\n': + s.append("\\n"); + break; + case '\t': + s.append("\\t"); + break; + default: + s.push_back(c); + break; + } + } + s.append("\""); + return s; +} + +#ifdef CATCH_CONFIG_CPP17_STRING_VIEW +std::string StringMaker<std::string_view>::convert(std::string_view str) { + return ::Catch::Detail::stringify(std::string{ str }); +} +#endif + +std::string StringMaker<char const*>::convert(char const* str) { + if (str) { + return ::Catch::Detail::stringify(std::string{ str }); + } else { + return{ "{null string}" }; + } +} +std::string StringMaker<char*>::convert(char* str) { + if (str) { + return ::Catch::Detail::stringify(std::string{ str }); + } else { + return{ "{null string}" }; + } +} + +#ifdef CATCH_CONFIG_WCHAR +std::string StringMaker<std::wstring>::convert(const std::wstring& wstr) { + std::string s; + s.reserve(wstr.size()); + for (auto c : wstr) { + s += (c <= 0xff) ? static_cast<char>(c) : '?'; + } + return ::Catch::Detail::stringify(s); +} + +# ifdef CATCH_CONFIG_CPP17_STRING_VIEW +std::string StringMaker<std::wstring_view>::convert(std::wstring_view str) { + return StringMaker<std::wstring>::convert(std::wstring(str)); +} +# endif + +std::string StringMaker<wchar_t const*>::convert(wchar_t const * str) { + if (str) { + return ::Catch::Detail::stringify(std::wstring{ str }); + } else { + return{ "{null string}" }; + } +} +std::string StringMaker<wchar_t *>::convert(wchar_t * str) { + if (str) { + return ::Catch::Detail::stringify(std::wstring{ str }); + } else { + return{ "{null string}" }; + } +} +#endif + +#if defined(CATCH_CONFIG_CPP17_BYTE) +#include <cstddef> +std::string StringMaker<std::byte>::convert(std::byte value) { + return ::Catch::Detail::stringify(std::to_integer<unsigned long long>(value)); +} +#endif // defined(CATCH_CONFIG_CPP17_BYTE) + +std::string StringMaker<int>::convert(int value) { + return ::Catch::Detail::stringify(static_cast<long long>(value)); +} +std::string StringMaker<long>::convert(long value) { + return ::Catch::Detail::stringify(static_cast<long long>(value)); +} +std::string StringMaker<long long>::convert(long long value) { + ReusableStringStream rss; + rss << value; + if (value > Detail::hexThreshold) { + rss << " (0x" << std::hex << value << ')'; + } + return rss.str(); +} + +std::string StringMaker<unsigned int>::convert(unsigned int value) { + return ::Catch::Detail::stringify(static_cast<unsigned long long>(value)); +} +std::string StringMaker<unsigned long>::convert(unsigned long value) { + return ::Catch::Detail::stringify(static_cast<unsigned long long>(value)); +} +std::string StringMaker<unsigned long long>::convert(unsigned long long value) { + ReusableStringStream rss; + rss << value; + if (value > Detail::hexThreshold) { + rss << " (0x" << std::hex << value << ')'; + } + return rss.str(); +} + +std::string StringMaker<bool>::convert(bool b) { + return b ? "true" : "false"; +} + +std::string StringMaker<signed char>::convert(signed char value) { + if (value == '\r') { + return "'\\r'"; + } else if (value == '\f') { + return "'\\f'"; + } else if (value == '\n') { + return "'\\n'"; + } else if (value == '\t') { + return "'\\t'"; + } else if ('\0' <= value && value < ' ') { + return ::Catch::Detail::stringify(static_cast<unsigned int>(value)); + } else { + char chstr[] = "' '"; + chstr[1] = value; + return chstr; + } +} +std::string StringMaker<char>::convert(char c) { + return ::Catch::Detail::stringify(static_cast<signed char>(c)); +} +std::string StringMaker<unsigned char>::convert(unsigned char c) { + return ::Catch::Detail::stringify(static_cast<char>(c)); +} + +std::string StringMaker<std::nullptr_t>::convert(std::nullptr_t) { + return "nullptr"; +} + +int StringMaker<float>::precision = 5; + +std::string StringMaker<float>::convert(float value) { + return fpToString(value, precision) + 'f'; +} + +int StringMaker<double>::precision = 10; + +std::string StringMaker<double>::convert(double value) { + return fpToString(value, precision); +} + +std::string ratio_string<std::atto>::symbol() { return "a"; } +std::string ratio_string<std::femto>::symbol() { return "f"; } +std::string ratio_string<std::pico>::symbol() { return "p"; } +std::string ratio_string<std::nano>::symbol() { return "n"; } +std::string ratio_string<std::micro>::symbol() { return "u"; } +std::string ratio_string<std::milli>::symbol() { return "m"; } + +} // end namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + +// end catch_tostring.cpp +// start catch_totals.cpp + +namespace Catch { + + Counts Counts::operator - ( Counts const& other ) const { + Counts diff; + diff.passed = passed - other.passed; + diff.failed = failed - other.failed; + diff.failedButOk = failedButOk - other.failedButOk; + return diff; + } + + Counts& Counts::operator += ( Counts const& other ) { + passed += other.passed; + failed += other.failed; + failedButOk += other.failedButOk; + return *this; + } + + std::size_t Counts::total() const { + return passed + failed + failedButOk; + } + bool Counts::allPassed() const { + return failed == 0 && failedButOk == 0; + } + bool Counts::allOk() const { + return failed == 0; + } + + Totals Totals::operator - ( Totals const& other ) const { + Totals diff; + diff.assertions = assertions - other.assertions; + diff.testCases = testCases - other.testCases; + return diff; + } + + Totals& Totals::operator += ( Totals const& other ) { + assertions += other.assertions; + testCases += other.testCases; + return *this; + } + + Totals Totals::delta( Totals const& prevTotals ) const { + Totals diff = *this - prevTotals; + if( diff.assertions.failed > 0 ) + ++diff.testCases.failed; + else if( diff.assertions.failedButOk > 0 ) + ++diff.testCases.failedButOk; + else + ++diff.testCases.passed; + return diff; + } + +} +// end catch_totals.cpp +// start catch_uncaught_exceptions.cpp + +// start catch_config_uncaught_exceptions.hpp + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP +#define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP + +#if defined(_MSC_VER) +# if _MSC_VER >= 1900 // Visual Studio 2015 or newer +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +# endif +#endif + +#include <exception> + +#if defined(__cpp_lib_uncaught_exceptions) \ + && !defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif // __cpp_lib_uncaught_exceptions + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) \ + && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) \ + && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + +# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif + +#endif // CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP +// end catch_config_uncaught_exceptions.hpp +#include <exception> + +namespace Catch { + bool uncaught_exceptions() { +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + return false; +#elif defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + return std::uncaught_exceptions() > 0; +#else + return std::uncaught_exception(); +#endif + } +} // end namespace Catch +// end catch_uncaught_exceptions.cpp +// start catch_version.cpp + +#include <ostream> + +namespace Catch { + + Version::Version + ( unsigned int _majorVersion, + unsigned int _minorVersion, + unsigned int _patchNumber, + char const * const _branchName, + unsigned int _buildNumber ) + : majorVersion( _majorVersion ), + minorVersion( _minorVersion ), + patchNumber( _patchNumber ), + branchName( _branchName ), + buildNumber( _buildNumber ) + {} + + std::ostream& operator << ( std::ostream& os, Version const& version ) { + os << version.majorVersion << '.' + << version.minorVersion << '.' + << version.patchNumber; + // branchName is never null -> 0th char is \0 if it is empty + if (version.branchName[0]) { + os << '-' << version.branchName + << '.' << version.buildNumber; + } + return os; + } + + Version const& libraryVersion() { + static Version version( 2, 13, 10, "", 0 ); + return version; + } + +} +// end catch_version.cpp +// start catch_wildcard_pattern.cpp + +namespace Catch { + + WildcardPattern::WildcardPattern( std::string const& pattern, + CaseSensitive::Choice caseSensitivity ) + : m_caseSensitivity( caseSensitivity ), + m_pattern( normaliseString( pattern ) ) + { + if( startsWith( m_pattern, '*' ) ) { + m_pattern = m_pattern.substr( 1 ); + m_wildcard = WildcardAtStart; + } + if( endsWith( m_pattern, '*' ) ) { + m_pattern = m_pattern.substr( 0, m_pattern.size()-1 ); + m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd ); + } + } + + bool WildcardPattern::matches( std::string const& str ) const { + switch( m_wildcard ) { + case NoWildcard: + return m_pattern == normaliseString( str ); + case WildcardAtStart: + return endsWith( normaliseString( str ), m_pattern ); + case WildcardAtEnd: + return startsWith( normaliseString( str ), m_pattern ); + case WildcardAtBothEnds: + return contains( normaliseString( str ), m_pattern ); + default: + CATCH_INTERNAL_ERROR( "Unknown enum" ); + } + } + + std::string WildcardPattern::normaliseString( std::string const& str ) const { + return trim( m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str ); + } +} +// end catch_wildcard_pattern.cpp +// start catch_xmlwriter.cpp + +#include <iomanip> +#include <type_traits> + +namespace Catch { + +namespace { + + size_t trailingBytes(unsigned char c) { + if ((c & 0xE0) == 0xC0) { + return 2; + } + if ((c & 0xF0) == 0xE0) { + return 3; + } + if ((c & 0xF8) == 0xF0) { + return 4; + } + CATCH_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered"); + } + + uint32_t headerValue(unsigned char c) { + if ((c & 0xE0) == 0xC0) { + return c & 0x1F; + } + if ((c & 0xF0) == 0xE0) { + return c & 0x0F; + } + if ((c & 0xF8) == 0xF0) { + return c & 0x07; + } + CATCH_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered"); + } + + void hexEscapeChar(std::ostream& os, unsigned char c) { + std::ios_base::fmtflags f(os.flags()); + os << "\\x" + << std::uppercase << std::hex << std::setfill('0') << std::setw(2) + << static_cast<int>(c); + os.flags(f); + } + + bool shouldNewline(XmlFormatting fmt) { + return !!(static_cast<std::underlying_type<XmlFormatting>::type>(fmt & XmlFormatting::Newline)); + } + + bool shouldIndent(XmlFormatting fmt) { + return !!(static_cast<std::underlying_type<XmlFormatting>::type>(fmt & XmlFormatting::Indent)); + } + +} // anonymous namespace + + XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) { + return static_cast<XmlFormatting>( + static_cast<std::underlying_type<XmlFormatting>::type>(lhs) | + static_cast<std::underlying_type<XmlFormatting>::type>(rhs) + ); + } + + XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) { + return static_cast<XmlFormatting>( + static_cast<std::underlying_type<XmlFormatting>::type>(lhs) & + static_cast<std::underlying_type<XmlFormatting>::type>(rhs) + ); + } + + XmlEncode::XmlEncode( std::string const& str, ForWhat forWhat ) + : m_str( str ), + m_forWhat( forWhat ) + {} + + void XmlEncode::encodeTo( std::ostream& os ) const { + // Apostrophe escaping not necessary if we always use " to write attributes + // (see: http://www.w3.org/TR/xml/#syntax) + + for( std::size_t idx = 0; idx < m_str.size(); ++ idx ) { + unsigned char c = m_str[idx]; + switch (c) { + case '<': os << "<"; break; + case '&': os << "&"; break; + + case '>': + // See: http://www.w3.org/TR/xml/#syntax + if (idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']') + os << ">"; + else + os << c; + break; + + case '\"': + if (m_forWhat == ForAttributes) + os << """; + else + os << c; + break; + + default: + // Check for control characters and invalid utf-8 + + // Escape control characters in standard ascii + // see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0 + if (c < 0x09 || (c > 0x0D && c < 0x20) || c == 0x7F) { + hexEscapeChar(os, c); + break; + } + + // Plain ASCII: Write it to stream + if (c < 0x7F) { + os << c; + break; + } + + // UTF-8 territory + // Check if the encoding is valid and if it is not, hex escape bytes. + // Important: We do not check the exact decoded values for validity, only the encoding format + // First check that this bytes is a valid lead byte: + // This means that it is not encoded as 1111 1XXX + // Or as 10XX XXXX + if (c < 0xC0 || + c >= 0xF8) { + hexEscapeChar(os, c); + break; + } + + auto encBytes = trailingBytes(c); + // Are there enough bytes left to avoid accessing out-of-bounds memory? + if (idx + encBytes - 1 >= m_str.size()) { + hexEscapeChar(os, c); + break; + } + // The header is valid, check data + // The next encBytes bytes must together be a valid utf-8 + // This means: bitpattern 10XX XXXX and the extracted value is sane (ish) + bool valid = true; + uint32_t value = headerValue(c); + for (std::size_t n = 1; n < encBytes; ++n) { + unsigned char nc = m_str[idx + n]; + valid &= ((nc & 0xC0) == 0x80); + value = (value << 6) | (nc & 0x3F); + } + + if ( + // Wrong bit pattern of following bytes + (!valid) || + // Overlong encodings + (value < 0x80) || + (0x80 <= value && value < 0x800 && encBytes > 2) || + (0x800 < value && value < 0x10000 && encBytes > 3) || + // Encoded value out of range + (value >= 0x110000) + ) { + hexEscapeChar(os, c); + break; + } + + // If we got here, this is in fact a valid(ish) utf-8 sequence + for (std::size_t n = 0; n < encBytes; ++n) { + os << m_str[idx + n]; + } + idx += encBytes - 1; + break; + } + } + } + + std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) { + xmlEncode.encodeTo( os ); + return os; + } + + XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer, XmlFormatting fmt ) + : m_writer( writer ), + m_fmt(fmt) + {} + + XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) noexcept + : m_writer( other.m_writer ), + m_fmt(other.m_fmt) + { + other.m_writer = nullptr; + other.m_fmt = XmlFormatting::None; + } + XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) noexcept { + if ( m_writer ) { + m_writer->endElement(); + } + m_writer = other.m_writer; + other.m_writer = nullptr; + m_fmt = other.m_fmt; + other.m_fmt = XmlFormatting::None; + return *this; + } + + XmlWriter::ScopedElement::~ScopedElement() { + if (m_writer) { + m_writer->endElement(m_fmt); + } + } + + XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, XmlFormatting fmt ) { + m_writer->writeText( text, fmt ); + return *this; + } + + XmlWriter::XmlWriter( std::ostream& os ) : m_os( os ) + { + writeDeclaration(); + } + + XmlWriter::~XmlWriter() { + while (!m_tags.empty()) { + endElement(); + } + newlineIfNecessary(); + } + + XmlWriter& XmlWriter::startElement( std::string const& name, XmlFormatting fmt ) { + ensureTagClosed(); + newlineIfNecessary(); + if (shouldIndent(fmt)) { + m_os << m_indent; + m_indent += " "; + } + m_os << '<' << name; + m_tags.push_back( name ); + m_tagIsOpen = true; + applyFormatting(fmt); + return *this; + } + + XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name, XmlFormatting fmt ) { + ScopedElement scoped( this, fmt ); + startElement( name, fmt ); + return scoped; + } + + XmlWriter& XmlWriter::endElement(XmlFormatting fmt) { + m_indent = m_indent.substr(0, m_indent.size() - 2); + + if( m_tagIsOpen ) { + m_os << "/>"; + m_tagIsOpen = false; + } else { + newlineIfNecessary(); + if (shouldIndent(fmt)) { + m_os << m_indent; + } + m_os << "</" << m_tags.back() << ">"; + } + m_os << std::flush; + applyFormatting(fmt); + m_tags.pop_back(); + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, std::string const& attribute ) { + if( !name.empty() && !attribute.empty() ) + m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, bool attribute ) { + m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeText( std::string const& text, XmlFormatting fmt) { + if( !text.empty() ){ + bool tagWasOpen = m_tagIsOpen; + ensureTagClosed(); + if (tagWasOpen && shouldIndent(fmt)) { + m_os << m_indent; + } + m_os << XmlEncode( text ); + applyFormatting(fmt); + } + return *this; + } + + XmlWriter& XmlWriter::writeComment( std::string const& text, XmlFormatting fmt) { + ensureTagClosed(); + if (shouldIndent(fmt)) { + m_os << m_indent; + } + m_os << "<!--" << text << "-->"; + applyFormatting(fmt); + return *this; + } + + void XmlWriter::writeStylesheetRef( std::string const& url ) { + m_os << "<?xml-stylesheet type=\"text/xsl\" href=\"" << url << "\"?>\n"; + } + + XmlWriter& XmlWriter::writeBlankLine() { + ensureTagClosed(); + m_os << '\n'; + return *this; + } + + void XmlWriter::ensureTagClosed() { + if( m_tagIsOpen ) { + m_os << '>' << std::flush; + newlineIfNecessary(); + m_tagIsOpen = false; + } + } + + void XmlWriter::applyFormatting(XmlFormatting fmt) { + m_needsNewline = shouldNewline(fmt); + } + + void XmlWriter::writeDeclaration() { + m_os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + } + + void XmlWriter::newlineIfNecessary() { + if( m_needsNewline ) { + m_os << std::endl; + m_needsNewline = false; + } + } +} +// end catch_xmlwriter.cpp +// start catch_reporter_bases.cpp + +#include <cstring> +#include <cfloat> +#include <cstdio> +#include <cassert> +#include <memory> + +namespace Catch { + void prepareExpandedExpression(AssertionResult& result) { + result.getExpandedExpression(); + } + + // Because formatting using c++ streams is stateful, drop down to C is required + // Alternatively we could use stringstream, but its performance is... not good. + std::string getFormattedDuration( double duration ) { + // Max exponent + 1 is required to represent the whole part + // + 1 for decimal point + // + 3 for the 3 decimal places + // + 1 for null terminator + const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1; + char buffer[maxDoubleSize]; + + // Save previous errno, to prevent sprintf from overwriting it + ErrnoGuard guard; +#ifdef _MSC_VER + sprintf_s(buffer, "%.3f", duration); +#else + std::sprintf(buffer, "%.3f", duration); +#endif + return std::string(buffer); + } + + bool shouldShowDuration( IConfig const& config, double duration ) { + if ( config.showDurations() == ShowDurations::Always ) { + return true; + } + if ( config.showDurations() == ShowDurations::Never ) { + return false; + } + const double min = config.minDuration(); + return min >= 0 && duration >= min; + } + + std::string serializeFilters( std::vector<std::string> const& container ) { + ReusableStringStream oss; + bool first = true; + for (auto&& filter : container) + { + if (!first) + oss << ' '; + else + first = false; + + oss << filter; + } + return oss.str(); + } + + TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config) + :StreamingReporterBase(_config) {} + + std::set<Verbosity> TestEventListenerBase::getSupportedVerbosities() { + return { Verbosity::Quiet, Verbosity::Normal, Verbosity::High }; + } + + void TestEventListenerBase::assertionStarting(AssertionInfo const &) {} + + bool TestEventListenerBase::assertionEnded(AssertionStats const &) { + return false; + } + +} // end namespace Catch +// end catch_reporter_bases.cpp +// start catch_reporter_compact.cpp + +namespace { + +#ifdef CATCH_PLATFORM_MAC + const char* failedString() { return "FAILED"; } + const char* passedString() { return "PASSED"; } +#else + const char* failedString() { return "failed"; } + const char* passedString() { return "passed"; } +#endif + + // Colour::LightGrey + Catch::Colour::Code dimColour() { return Catch::Colour::FileName; } + + std::string bothOrAll( std::size_t count ) { + return count == 1 ? std::string() : + count == 2 ? "both " : "all " ; + } + +} // anon namespace + +namespace Catch { +namespace { +// Colour, message variants: +// - white: No tests ran. +// - red: Failed [both/all] N test cases, failed [both/all] M assertions. +// - white: Passed [both/all] N test cases (no assertions). +// - red: Failed N tests cases, failed M assertions. +// - green: Passed [both/all] N tests cases with M assertions. +void printTotals(std::ostream& out, const Totals& totals) { + if (totals.testCases.total() == 0) { + out << "No tests ran."; + } else if (totals.testCases.failed == totals.testCases.total()) { + Colour colour(Colour::ResultError); + const std::string qualify_assertions_failed = + totals.assertions.failed == totals.assertions.total() ? + bothOrAll(totals.assertions.failed) : std::string(); + out << + "Failed " << bothOrAll(totals.testCases.failed) + << pluralise(totals.testCases.failed, "test case") << ", " + "failed " << qualify_assertions_failed << + pluralise(totals.assertions.failed, "assertion") << '.'; + } else if (totals.assertions.total() == 0) { + out << + "Passed " << bothOrAll(totals.testCases.total()) + << pluralise(totals.testCases.total(), "test case") + << " (no assertions)."; + } else if (totals.assertions.failed) { + Colour colour(Colour::ResultError); + out << + "Failed " << pluralise(totals.testCases.failed, "test case") << ", " + "failed " << pluralise(totals.assertions.failed, "assertion") << '.'; + } else { + Colour colour(Colour::ResultSuccess); + out << + "Passed " << bothOrAll(totals.testCases.passed) + << pluralise(totals.testCases.passed, "test case") << + " with " << pluralise(totals.assertions.passed, "assertion") << '.'; + } +} + +// Implementation of CompactReporter formatting +class AssertionPrinter { +public: + AssertionPrinter& operator= (AssertionPrinter const&) = delete; + AssertionPrinter(AssertionPrinter const&) = delete; + AssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages) + : stream(_stream) + , result(_stats.assertionResult) + , messages(_stats.infoMessages) + , itMessage(_stats.infoMessages.begin()) + , printInfoMessages(_printInfoMessages) {} + + void print() { + printSourceInfo(); + + itMessage = messages.begin(); + + switch (result.getResultType()) { + case ResultWas::Ok: + printResultType(Colour::ResultSuccess, passedString()); + printOriginalExpression(); + printReconstructedExpression(); + if (!result.hasExpression()) + printRemainingMessages(Colour::None); + else + printRemainingMessages(); + break; + case ResultWas::ExpressionFailed: + if (result.isOk()) + printResultType(Colour::ResultSuccess, failedString() + std::string(" - but was ok")); + else + printResultType(Colour::Error, failedString()); + printOriginalExpression(); + printReconstructedExpression(); + printRemainingMessages(); + break; + case ResultWas::ThrewException: + printResultType(Colour::Error, failedString()); + printIssue("unexpected exception with message:"); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::FatalErrorCondition: + printResultType(Colour::Error, failedString()); + printIssue("fatal error condition with message:"); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::DidntThrowException: + printResultType(Colour::Error, failedString()); + printIssue("expected exception, got none"); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::Info: + printResultType(Colour::None, "info"); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::Warning: + printResultType(Colour::None, "warning"); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::ExplicitFailure: + printResultType(Colour::Error, failedString()); + printIssue("explicitly"); + printRemainingMessages(Colour::None); + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + printResultType(Colour::Error, "** internal error **"); + break; + } + } + +private: + void printSourceInfo() const { + Colour colourGuard(Colour::FileName); + stream << result.getSourceInfo() << ':'; + } + + void printResultType(Colour::Code colour, std::string const& passOrFail) const { + if (!passOrFail.empty()) { + { + Colour colourGuard(colour); + stream << ' ' << passOrFail; + } + stream << ':'; + } + } + + void printIssue(std::string const& issue) const { + stream << ' ' << issue; + } + + void printExpressionWas() { + if (result.hasExpression()) { + stream << ';'; + { + Colour colour(dimColour()); + stream << " expression was:"; + } + printOriginalExpression(); + } + } + + void printOriginalExpression() const { + if (result.hasExpression()) { + stream << ' ' << result.getExpression(); + } + } + + void printReconstructedExpression() const { + if (result.hasExpandedExpression()) { + { + Colour colour(dimColour()); + stream << " for: "; + } + stream << result.getExpandedExpression(); + } + } + + void printMessage() { + if (itMessage != messages.end()) { + stream << " '" << itMessage->message << '\''; + ++itMessage; + } + } + + void printRemainingMessages(Colour::Code colour = dimColour()) { + if (itMessage == messages.end()) + return; + + const auto itEnd = messages.cend(); + const auto N = static_cast<std::size_t>(std::distance(itMessage, itEnd)); + + { + Colour colourGuard(colour); + stream << " with " << pluralise(N, "message") << ':'; + } + + while (itMessage != itEnd) { + // If this assertion is a warning ignore any INFO messages + if (printInfoMessages || itMessage->type != ResultWas::Info) { + printMessage(); + if (itMessage != itEnd) { + Colour colourGuard(dimColour()); + stream << " and"; + } + continue; + } + ++itMessage; + } + } + +private: + std::ostream& stream; + AssertionResult const& result; + std::vector<MessageInfo> messages; + std::vector<MessageInfo>::const_iterator itMessage; + bool printInfoMessages; +}; + +} // anon namespace + + std::string CompactReporter::getDescription() { + return "Reports test results on a single line, suitable for IDEs"; + } + + void CompactReporter::noMatchingTestCases( std::string const& spec ) { + stream << "No test cases matched '" << spec << '\'' << std::endl; + } + + void CompactReporter::assertionStarting( AssertionInfo const& ) {} + + bool CompactReporter::assertionEnded( AssertionStats const& _assertionStats ) { + AssertionResult const& result = _assertionStats.assertionResult; + + bool printInfoMessages = true; + + // Drop out if result was successful and we're not printing those + if( !m_config->includeSuccessfulResults() && result.isOk() ) { + if( result.getResultType() != ResultWas::Warning ) + return false; + printInfoMessages = false; + } + + AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); + printer.print(); + + stream << std::endl; + return true; + } + + void CompactReporter::sectionEnded(SectionStats const& _sectionStats) { + double dur = _sectionStats.durationInSeconds; + if ( shouldShowDuration( *m_config, dur ) ) { + stream << getFormattedDuration( dur ) << " s: " << _sectionStats.sectionInfo.name << std::endl; + } + } + + void CompactReporter::testRunEnded( TestRunStats const& _testRunStats ) { + printTotals( stream, _testRunStats.totals ); + stream << '\n' << std::endl; + StreamingReporterBase::testRunEnded( _testRunStats ); + } + + CompactReporter::~CompactReporter() {} + + CATCH_REGISTER_REPORTER( "compact", CompactReporter ) + +} // end namespace Catch +// end catch_reporter_compact.cpp +// start catch_reporter_console.cpp + +#include <cfloat> +#include <cstdio> + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled and default is missing) is enabled +#endif + +#if defined(__clang__) +# pragma clang diagnostic push +// For simplicity, benchmarking-only helpers are always enabled +# pragma clang diagnostic ignored "-Wunused-function" +#endif + +namespace Catch { + +namespace { + +// Formatter impl for ConsoleReporter +class ConsoleAssertionPrinter { +public: + ConsoleAssertionPrinter& operator= (ConsoleAssertionPrinter const&) = delete; + ConsoleAssertionPrinter(ConsoleAssertionPrinter const&) = delete; + ConsoleAssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages) + : stream(_stream), + stats(_stats), + result(_stats.assertionResult), + colour(Colour::None), + message(result.getMessage()), + messages(_stats.infoMessages), + printInfoMessages(_printInfoMessages) { + switch (result.getResultType()) { + case ResultWas::Ok: + colour = Colour::Success; + passOrFail = "PASSED"; + //if( result.hasMessage() ) + if (_stats.infoMessages.size() == 1) + messageLabel = "with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "with messages"; + break; + case ResultWas::ExpressionFailed: + if (result.isOk()) { + colour = Colour::Success; + passOrFail = "FAILED - but was ok"; + } else { + colour = Colour::Error; + passOrFail = "FAILED"; + } + if (_stats.infoMessages.size() == 1) + messageLabel = "with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "with messages"; + break; + case ResultWas::ThrewException: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "due to unexpected exception with "; + if (_stats.infoMessages.size() == 1) + messageLabel += "message"; + if (_stats.infoMessages.size() > 1) + messageLabel += "messages"; + break; + case ResultWas::FatalErrorCondition: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "due to a fatal error condition"; + break; + case ResultWas::DidntThrowException: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "because no exception was thrown where one was expected"; + break; + case ResultWas::Info: + messageLabel = "info"; + break; + case ResultWas::Warning: + messageLabel = "warning"; + break; + case ResultWas::ExplicitFailure: + passOrFail = "FAILED"; + colour = Colour::Error; + if (_stats.infoMessages.size() == 1) + messageLabel = "explicitly with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "explicitly with messages"; + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + passOrFail = "** internal error **"; + colour = Colour::Error; + break; + } + } + + void print() const { + printSourceInfo(); + if (stats.totals.assertions.total() > 0) { + printResultType(); + printOriginalExpression(); + printReconstructedExpression(); + } else { + stream << '\n'; + } + printMessage(); + } + +private: + void printResultType() const { + if (!passOrFail.empty()) { + Colour colourGuard(colour); + stream << passOrFail << ":\n"; + } + } + void printOriginalExpression() const { + if (result.hasExpression()) { + Colour colourGuard(Colour::OriginalExpression); + stream << " "; + stream << result.getExpressionInMacro(); + stream << '\n'; + } + } + void printReconstructedExpression() const { + if (result.hasExpandedExpression()) { + stream << "with expansion:\n"; + Colour colourGuard(Colour::ReconstructedExpression); + stream << Column(result.getExpandedExpression()).indent(2) << '\n'; + } + } + void printMessage() const { + if (!messageLabel.empty()) + stream << messageLabel << ':' << '\n'; + for (auto const& msg : messages) { + // If this assertion is a warning ignore any INFO messages + if (printInfoMessages || msg.type != ResultWas::Info) + stream << Column(msg.message).indent(2) << '\n'; + } + } + void printSourceInfo() const { + Colour colourGuard(Colour::FileName); + stream << result.getSourceInfo() << ": "; + } + + std::ostream& stream; + AssertionStats const& stats; + AssertionResult const& result; + Colour::Code colour; + std::string passOrFail; + std::string messageLabel; + std::string message; + std::vector<MessageInfo> messages; + bool printInfoMessages; +}; + +std::size_t makeRatio(std::size_t number, std::size_t total) { + std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number / total : 0; + return (ratio == 0 && number > 0) ? 1 : ratio; +} + +std::size_t& findMax(std::size_t& i, std::size_t& j, std::size_t& k) { + if (i > j && i > k) + return i; + else if (j > k) + return j; + else + return k; +} + +struct ColumnInfo { + enum Justification { Left, Right }; + std::string name; + int width; + Justification justification; +}; +struct ColumnBreak {}; +struct RowBreak {}; + +class Duration { + enum class Unit { + Auto, + Nanoseconds, + Microseconds, + Milliseconds, + Seconds, + Minutes + }; + static const uint64_t s_nanosecondsInAMicrosecond = 1000; + static const uint64_t s_nanosecondsInAMillisecond = 1000 * s_nanosecondsInAMicrosecond; + static const uint64_t s_nanosecondsInASecond = 1000 * s_nanosecondsInAMillisecond; + static const uint64_t s_nanosecondsInAMinute = 60 * s_nanosecondsInASecond; + + double m_inNanoseconds; + Unit m_units; + +public: + explicit Duration(double inNanoseconds, Unit units = Unit::Auto) + : m_inNanoseconds(inNanoseconds), + m_units(units) { + if (m_units == Unit::Auto) { + if (m_inNanoseconds < s_nanosecondsInAMicrosecond) + m_units = Unit::Nanoseconds; + else if (m_inNanoseconds < s_nanosecondsInAMillisecond) + m_units = Unit::Microseconds; + else if (m_inNanoseconds < s_nanosecondsInASecond) + m_units = Unit::Milliseconds; + else if (m_inNanoseconds < s_nanosecondsInAMinute) + m_units = Unit::Seconds; + else + m_units = Unit::Minutes; + } + + } + + auto value() const -> double { + switch (m_units) { + case Unit::Microseconds: + return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMicrosecond); + case Unit::Milliseconds: + return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMillisecond); + case Unit::Seconds: + return m_inNanoseconds / static_cast<double>(s_nanosecondsInASecond); + case Unit::Minutes: + return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMinute); + default: + return m_inNanoseconds; + } + } + auto unitsAsString() const -> std::string { + switch (m_units) { + case Unit::Nanoseconds: + return "ns"; + case Unit::Microseconds: + return "us"; + case Unit::Milliseconds: + return "ms"; + case Unit::Seconds: + return "s"; + case Unit::Minutes: + return "m"; + default: + return "** internal error **"; + } + + } + friend auto operator << (std::ostream& os, Duration const& duration) -> std::ostream& { + return os << duration.value() << ' ' << duration.unitsAsString(); + } +}; +} // end anon namespace + +class TablePrinter { + std::ostream& m_os; + std::vector<ColumnInfo> m_columnInfos; + std::ostringstream m_oss; + int m_currentColumn = -1; + bool m_isOpen = false; + +public: + TablePrinter( std::ostream& os, std::vector<ColumnInfo> columnInfos ) + : m_os( os ), + m_columnInfos( std::move( columnInfos ) ) {} + + auto columnInfos() const -> std::vector<ColumnInfo> const& { + return m_columnInfos; + } + + void open() { + if (!m_isOpen) { + m_isOpen = true; + *this << RowBreak(); + + Columns headerCols; + Spacer spacer(2); + for (auto const& info : m_columnInfos) { + headerCols += Column(info.name).width(static_cast<std::size_t>(info.width - 2)); + headerCols += spacer; + } + m_os << headerCols << '\n'; + + m_os << Catch::getLineOfChars<'-'>() << '\n'; + } + } + void close() { + if (m_isOpen) { + *this << RowBreak(); + m_os << std::endl; + m_isOpen = false; + } + } + + template<typename T> + friend TablePrinter& operator << (TablePrinter& tp, T const& value) { + tp.m_oss << value; + return tp; + } + + friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) { + auto colStr = tp.m_oss.str(); + const auto strSize = colStr.size(); + tp.m_oss.str(""); + tp.open(); + if (tp.m_currentColumn == static_cast<int>(tp.m_columnInfos.size() - 1)) { + tp.m_currentColumn = -1; + tp.m_os << '\n'; + } + tp.m_currentColumn++; + + auto colInfo = tp.m_columnInfos[tp.m_currentColumn]; + auto padding = (strSize + 1 < static_cast<std::size_t>(colInfo.width)) + ? std::string(colInfo.width - (strSize + 1), ' ') + : std::string(); + if (colInfo.justification == ColumnInfo::Left) + tp.m_os << colStr << padding << ' '; + else + tp.m_os << padding << colStr << ' '; + return tp; + } + + friend TablePrinter& operator << (TablePrinter& tp, RowBreak) { + if (tp.m_currentColumn > 0) { + tp.m_os << '\n'; + tp.m_currentColumn = -1; + } + return tp; + } +}; + +ConsoleReporter::ConsoleReporter(ReporterConfig const& config) + : StreamingReporterBase(config), + m_tablePrinter(new TablePrinter(config.stream(), + [&config]() -> std::vector<ColumnInfo> { + if (config.fullConfig()->benchmarkNoAnalysis()) + { + return{ + { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left }, + { " samples", 14, ColumnInfo::Right }, + { " iterations", 14, ColumnInfo::Right }, + { " mean", 14, ColumnInfo::Right } + }; + } + else + { + return{ + { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left }, + { "samples mean std dev", 14, ColumnInfo::Right }, + { "iterations low mean low std dev", 14, ColumnInfo::Right }, + { "estimated high mean high std dev", 14, ColumnInfo::Right } + }; + } + }())) {} +ConsoleReporter::~ConsoleReporter() = default; + +std::string ConsoleReporter::getDescription() { + return "Reports test results as plain lines of text"; +} + +void ConsoleReporter::noMatchingTestCases(std::string const& spec) { + stream << "No test cases matched '" << spec << '\'' << std::endl; +} + +void ConsoleReporter::reportInvalidArguments(std::string const&arg){ + stream << "Invalid Filter: " << arg << std::endl; +} + +void ConsoleReporter::assertionStarting(AssertionInfo const&) {} + +bool ConsoleReporter::assertionEnded(AssertionStats const& _assertionStats) { + AssertionResult const& result = _assertionStats.assertionResult; + + bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); + + // Drop out if result was successful but we're not printing them. + if (!includeResults && result.getResultType() != ResultWas::Warning) + return false; + + lazyPrint(); + + ConsoleAssertionPrinter printer(stream, _assertionStats, includeResults); + printer.print(); + stream << std::endl; + return true; +} + +void ConsoleReporter::sectionStarting(SectionInfo const& _sectionInfo) { + m_tablePrinter->close(); + m_headerPrinted = false; + StreamingReporterBase::sectionStarting(_sectionInfo); +} +void ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) { + m_tablePrinter->close(); + if (_sectionStats.missingAssertions) { + lazyPrint(); + Colour colour(Colour::ResultError); + if (m_sectionStack.size() > 1) + stream << "\nNo assertions in section"; + else + stream << "\nNo assertions in test case"; + stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; + } + double dur = _sectionStats.durationInSeconds; + if (shouldShowDuration(*m_config, dur)) { + stream << getFormattedDuration(dur) << " s: " << _sectionStats.sectionInfo.name << std::endl; + } + if (m_headerPrinted) { + m_headerPrinted = false; + } + StreamingReporterBase::sectionEnded(_sectionStats); +} + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +void ConsoleReporter::benchmarkPreparing(std::string const& name) { + lazyPrintWithoutClosingBenchmarkTable(); + + auto nameCol = Column(name).width(static_cast<std::size_t>(m_tablePrinter->columnInfos()[0].width - 2)); + + bool firstLine = true; + for (auto line : nameCol) { + if (!firstLine) + (*m_tablePrinter) << ColumnBreak() << ColumnBreak() << ColumnBreak(); + else + firstLine = false; + + (*m_tablePrinter) << line << ColumnBreak(); + } +} + +void ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) { + (*m_tablePrinter) << info.samples << ColumnBreak() + << info.iterations << ColumnBreak(); + if (!m_config->benchmarkNoAnalysis()) + (*m_tablePrinter) << Duration(info.estimatedDuration) << ColumnBreak(); +} +void ConsoleReporter::benchmarkEnded(BenchmarkStats<> const& stats) { + if (m_config->benchmarkNoAnalysis()) + { + (*m_tablePrinter) << Duration(stats.mean.point.count()) << ColumnBreak(); + } + else + { + (*m_tablePrinter) << ColumnBreak() + << Duration(stats.mean.point.count()) << ColumnBreak() + << Duration(stats.mean.lower_bound.count()) << ColumnBreak() + << Duration(stats.mean.upper_bound.count()) << ColumnBreak() << ColumnBreak() + << Duration(stats.standardDeviation.point.count()) << ColumnBreak() + << Duration(stats.standardDeviation.lower_bound.count()) << ColumnBreak() + << Duration(stats.standardDeviation.upper_bound.count()) << ColumnBreak() << ColumnBreak() << ColumnBreak() << ColumnBreak() << ColumnBreak(); + } +} + +void ConsoleReporter::benchmarkFailed(std::string const& error) { + Colour colour(Colour::Red); + (*m_tablePrinter) + << "Benchmark failed (" << error << ')' + << ColumnBreak() << RowBreak(); +} +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + +void ConsoleReporter::testCaseEnded(TestCaseStats const& _testCaseStats) { + m_tablePrinter->close(); + StreamingReporterBase::testCaseEnded(_testCaseStats); + m_headerPrinted = false; +} +void ConsoleReporter::testGroupEnded(TestGroupStats const& _testGroupStats) { + if (currentGroupInfo.used) { + printSummaryDivider(); + stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n"; + printTotals(_testGroupStats.totals); + stream << '\n' << std::endl; + } + StreamingReporterBase::testGroupEnded(_testGroupStats); +} +void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) { + printTotalsDivider(_testRunStats.totals); + printTotals(_testRunStats.totals); + stream << std::endl; + StreamingReporterBase::testRunEnded(_testRunStats); +} +void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) { + StreamingReporterBase::testRunStarting(_testInfo); + printTestFilters(); +} + +void ConsoleReporter::lazyPrint() { + + m_tablePrinter->close(); + lazyPrintWithoutClosingBenchmarkTable(); +} + +void ConsoleReporter::lazyPrintWithoutClosingBenchmarkTable() { + + if (!currentTestRunInfo.used) + lazyPrintRunInfo(); + if (!currentGroupInfo.used) + lazyPrintGroupInfo(); + + if (!m_headerPrinted) { + printTestCaseAndSectionHeader(); + m_headerPrinted = true; + } +} +void ConsoleReporter::lazyPrintRunInfo() { + stream << '\n' << getLineOfChars<'~'>() << '\n'; + Colour colour(Colour::SecondaryText); + stream << currentTestRunInfo->name + << " is a Catch v" << libraryVersion() << " host application.\n" + << "Run with -? for options\n\n"; + + if (m_config->rngSeed() != 0) + stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n"; + + currentTestRunInfo.used = true; +} +void ConsoleReporter::lazyPrintGroupInfo() { + if (!currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1) { + printClosedHeader("Group: " + currentGroupInfo->name); + currentGroupInfo.used = true; + } +} +void ConsoleReporter::printTestCaseAndSectionHeader() { + assert(!m_sectionStack.empty()); + printOpenHeader(currentTestCaseInfo->name); + + if (m_sectionStack.size() > 1) { + Colour colourGuard(Colour::Headers); + + auto + it = m_sectionStack.begin() + 1, // Skip first section (test case) + itEnd = m_sectionStack.end(); + for (; it != itEnd; ++it) + printHeaderString(it->name, 2); + } + + SourceLineInfo lineInfo = m_sectionStack.back().lineInfo; + + stream << getLineOfChars<'-'>() << '\n'; + Colour colourGuard(Colour::FileName); + stream << lineInfo << '\n'; + stream << getLineOfChars<'.'>() << '\n' << std::endl; +} + +void ConsoleReporter::printClosedHeader(std::string const& _name) { + printOpenHeader(_name); + stream << getLineOfChars<'.'>() << '\n'; +} +void ConsoleReporter::printOpenHeader(std::string const& _name) { + stream << getLineOfChars<'-'>() << '\n'; + { + Colour colourGuard(Colour::Headers); + printHeaderString(_name); + } +} + +// if string has a : in first line will set indent to follow it on +// subsequent lines +void ConsoleReporter::printHeaderString(std::string const& _string, std::size_t indent) { + std::size_t i = _string.find(": "); + if (i != std::string::npos) + i += 2; + else + i = 0; + stream << Column(_string).indent(indent + i).initialIndent(indent) << '\n'; +} + +struct SummaryColumn { + + SummaryColumn( std::string _label, Colour::Code _colour ) + : label( std::move( _label ) ), + colour( _colour ) {} + SummaryColumn addRow( std::size_t count ) { + ReusableStringStream rss; + rss << count; + std::string row = rss.str(); + for (auto& oldRow : rows) { + while (oldRow.size() < row.size()) + oldRow = ' ' + oldRow; + while (oldRow.size() > row.size()) + row = ' ' + row; + } + rows.push_back(row); + return *this; + } + + std::string label; + Colour::Code colour; + std::vector<std::string> rows; + +}; + +void ConsoleReporter::printTotals( Totals const& totals ) { + if (totals.testCases.total() == 0) { + stream << Colour(Colour::Warning) << "No tests ran\n"; + } else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) { + stream << Colour(Colour::ResultSuccess) << "All tests passed"; + stream << " (" + << pluralise(totals.assertions.passed, "assertion") << " in " + << pluralise(totals.testCases.passed, "test case") << ')' + << '\n'; + } else { + + std::vector<SummaryColumn> columns; + columns.push_back(SummaryColumn("", Colour::None) + .addRow(totals.testCases.total()) + .addRow(totals.assertions.total())); + columns.push_back(SummaryColumn("passed", Colour::Success) + .addRow(totals.testCases.passed) + .addRow(totals.assertions.passed)); + columns.push_back(SummaryColumn("failed", Colour::ResultError) + .addRow(totals.testCases.failed) + .addRow(totals.assertions.failed)); + columns.push_back(SummaryColumn("failed as expected", Colour::ResultExpectedFailure) + .addRow(totals.testCases.failedButOk) + .addRow(totals.assertions.failedButOk)); + + printSummaryRow("test cases", columns, 0); + printSummaryRow("assertions", columns, 1); + } +} +void ConsoleReporter::printSummaryRow(std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row) { + for (auto col : cols) { + std::string value = col.rows[row]; + if (col.label.empty()) { + stream << label << ": "; + if (value != "0") + stream << value; + else + stream << Colour(Colour::Warning) << "- none -"; + } else if (value != "0") { + stream << Colour(Colour::LightGrey) << " | "; + stream << Colour(col.colour) + << value << ' ' << col.label; + } + } + stream << '\n'; +} + +void ConsoleReporter::printTotalsDivider(Totals const& totals) { + if (totals.testCases.total() > 0) { + std::size_t failedRatio = makeRatio(totals.testCases.failed, totals.testCases.total()); + std::size_t failedButOkRatio = makeRatio(totals.testCases.failedButOk, totals.testCases.total()); + std::size_t passedRatio = makeRatio(totals.testCases.passed, totals.testCases.total()); + while (failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH - 1) + findMax(failedRatio, failedButOkRatio, passedRatio)++; + while (failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH - 1) + findMax(failedRatio, failedButOkRatio, passedRatio)--; + + stream << Colour(Colour::Error) << std::string(failedRatio, '='); + stream << Colour(Colour::ResultExpectedFailure) << std::string(failedButOkRatio, '='); + if (totals.testCases.allPassed()) + stream << Colour(Colour::ResultSuccess) << std::string(passedRatio, '='); + else + stream << Colour(Colour::Success) << std::string(passedRatio, '='); + } else { + stream << Colour(Colour::Warning) << std::string(CATCH_CONFIG_CONSOLE_WIDTH - 1, '='); + } + stream << '\n'; +} +void ConsoleReporter::printSummaryDivider() { + stream << getLineOfChars<'-'>() << '\n'; +} + +void ConsoleReporter::printTestFilters() { + if (m_config->testSpec().hasFilters()) { + Colour guard(Colour::BrightYellow); + stream << "Filters: " << serializeFilters(m_config->getTestsOrTags()) << '\n'; + } +} + +CATCH_REGISTER_REPORTER("console", ConsoleReporter) + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +// end catch_reporter_console.cpp +// start catch_reporter_junit.cpp + +#include <cassert> +#include <sstream> +#include <ctime> +#include <algorithm> +#include <iomanip> + +namespace Catch { + + namespace { + std::string getCurrentTimestamp() { + // Beware, this is not reentrant because of backward compatibility issues + // Also, UTC only, again because of backward compatibility (%z is C++11) + time_t rawtime; + std::time(&rawtime); + auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); + +#ifdef _MSC_VER + std::tm timeInfo = {}; + gmtime_s(&timeInfo, &rawtime); +#else + std::tm* timeInfo; + timeInfo = std::gmtime(&rawtime); +#endif + + char timeStamp[timeStampSize]; + const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; + +#ifdef _MSC_VER + std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); +#else + std::strftime(timeStamp, timeStampSize, fmt, timeInfo); +#endif + return std::string(timeStamp, timeStampSize-1); + } + + std::string fileNameTag(const std::vector<std::string> &tags) { + auto it = std::find_if(begin(tags), + end(tags), + [] (std::string const& tag) {return tag.front() == '#'; }); + if (it != tags.end()) + return it->substr(1); + return std::string(); + } + + // Formats the duration in seconds to 3 decimal places. + // This is done because some genius defined Maven Surefire schema + // in a way that only accepts 3 decimal places, and tools like + // Jenkins use that schema for validation JUnit reporter output. + std::string formatDuration( double seconds ) { + ReusableStringStream rss; + rss << std::fixed << std::setprecision( 3 ) << seconds; + return rss.str(); + } + + } // anonymous namespace + + JunitReporter::JunitReporter( ReporterConfig const& _config ) + : CumulativeReporterBase( _config ), + xml( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = true; + m_reporterPrefs.shouldReportAllAssertions = true; + } + + JunitReporter::~JunitReporter() {} + + std::string JunitReporter::getDescription() { + return "Reports test results in an XML format that looks like Ant's junitreport target"; + } + + void JunitReporter::noMatchingTestCases( std::string const& /*spec*/ ) {} + + void JunitReporter::testRunStarting( TestRunInfo const& runInfo ) { + CumulativeReporterBase::testRunStarting( runInfo ); + xml.startElement( "testsuites" ); + } + + void JunitReporter::testGroupStarting( GroupInfo const& groupInfo ) { + suiteTimer.start(); + stdOutForSuite.clear(); + stdErrForSuite.clear(); + unexpectedExceptions = 0; + CumulativeReporterBase::testGroupStarting( groupInfo ); + } + + void JunitReporter::testCaseStarting( TestCaseInfo const& testCaseInfo ) { + m_okToFail = testCaseInfo.okToFail(); + } + + bool JunitReporter::assertionEnded( AssertionStats const& assertionStats ) { + if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail ) + unexpectedExceptions++; + return CumulativeReporterBase::assertionEnded( assertionStats ); + } + + void JunitReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { + stdOutForSuite += testCaseStats.stdOut; + stdErrForSuite += testCaseStats.stdErr; + CumulativeReporterBase::testCaseEnded( testCaseStats ); + } + + void JunitReporter::testGroupEnded( TestGroupStats const& testGroupStats ) { + double suiteTime = suiteTimer.getElapsedSeconds(); + CumulativeReporterBase::testGroupEnded( testGroupStats ); + writeGroup( *m_testGroups.back(), suiteTime ); + } + + void JunitReporter::testRunEndedCumulative() { + xml.endElement(); + } + + void JunitReporter::writeGroup( TestGroupNode const& groupNode, double suiteTime ) { + XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" ); + + TestGroupStats const& stats = groupNode.value; + xml.writeAttribute( "name", stats.groupInfo.name ); + xml.writeAttribute( "errors", unexpectedExceptions ); + xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions ); + xml.writeAttribute( "tests", stats.totals.assertions.total() ); + xml.writeAttribute( "hostname", "tbd" ); // !TBD + if( m_config->showDurations() == ShowDurations::Never ) + xml.writeAttribute( "time", "" ); + else + xml.writeAttribute( "time", formatDuration( suiteTime ) ); + xml.writeAttribute( "timestamp", getCurrentTimestamp() ); + + // Write properties if there are any + if (m_config->hasTestFilters() || m_config->rngSeed() != 0) { + auto properties = xml.scopedElement("properties"); + if (m_config->hasTestFilters()) { + xml.scopedElement("property") + .writeAttribute("name", "filters") + .writeAttribute("value", serializeFilters(m_config->getTestsOrTags())); + } + if (m_config->rngSeed() != 0) { + xml.scopedElement("property") + .writeAttribute("name", "random-seed") + .writeAttribute("value", m_config->rngSeed()); + } + } + + // Write test cases + for( auto const& child : groupNode.children ) + writeTestCase( *child ); + + xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite ), XmlFormatting::Newline ); + xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite ), XmlFormatting::Newline ); + } + + void JunitReporter::writeTestCase( TestCaseNode const& testCaseNode ) { + TestCaseStats const& stats = testCaseNode.value; + + // All test cases have exactly one section - which represents the + // test case itself. That section may have 0-n nested sections + assert( testCaseNode.children.size() == 1 ); + SectionNode const& rootSection = *testCaseNode.children.front(); + + std::string className = stats.testInfo.className; + + if( className.empty() ) { + className = fileNameTag(stats.testInfo.tags); + if ( className.empty() ) + className = "global"; + } + + if ( !m_config->name().empty() ) + className = m_config->name() + "." + className; + + writeSection( className, "", rootSection, stats.testInfo.okToFail() ); + } + + void JunitReporter::writeSection( std::string const& className, + std::string const& rootName, + SectionNode const& sectionNode, + bool testOkToFail) { + std::string name = trim( sectionNode.stats.sectionInfo.name ); + if( !rootName.empty() ) + name = rootName + '/' + name; + + if( !sectionNode.assertions.empty() || + !sectionNode.stdOut.empty() || + !sectionNode.stdErr.empty() ) { + XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); + if( className.empty() ) { + xml.writeAttribute( "classname", name ); + xml.writeAttribute( "name", "root" ); + } + else { + xml.writeAttribute( "classname", className ); + xml.writeAttribute( "name", name ); + } + xml.writeAttribute( "time", formatDuration( sectionNode.stats.durationInSeconds ) ); + // This is not ideal, but it should be enough to mimic gtest's + // junit output. + // Ideally the JUnit reporter would also handle `skipTest` + // events and write those out appropriately. + xml.writeAttribute( "status", "run" ); + + if (sectionNode.stats.assertions.failedButOk) { + xml.scopedElement("skipped") + .writeAttribute("message", "TEST_CASE tagged with !mayfail"); + } + + writeAssertions( sectionNode ); + + if( !sectionNode.stdOut.empty() ) + xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), XmlFormatting::Newline ); + if( !sectionNode.stdErr.empty() ) + xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), XmlFormatting::Newline ); + } + for( auto const& childNode : sectionNode.childSections ) + if( className.empty() ) + writeSection( name, "", *childNode, testOkToFail ); + else + writeSection( className, name, *childNode, testOkToFail ); + } + + void JunitReporter::writeAssertions( SectionNode const& sectionNode ) { + for( auto const& assertion : sectionNode.assertions ) + writeAssertion( assertion ); + } + + void JunitReporter::writeAssertion( AssertionStats const& stats ) { + AssertionResult const& result = stats.assertionResult; + if( !result.isOk() ) { + std::string elementName; + switch( result.getResultType() ) { + case ResultWas::ThrewException: + case ResultWas::FatalErrorCondition: + elementName = "error"; + break; + case ResultWas::ExplicitFailure: + case ResultWas::ExpressionFailed: + case ResultWas::DidntThrowException: + elementName = "failure"; + break; + + // We should never see these here: + case ResultWas::Info: + case ResultWas::Warning: + case ResultWas::Ok: + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + elementName = "internalError"; + break; + } + + XmlWriter::ScopedElement e = xml.scopedElement( elementName ); + + xml.writeAttribute( "message", result.getExpression() ); + xml.writeAttribute( "type", result.getTestMacroName() ); + + ReusableStringStream rss; + if (stats.totals.assertions.total() > 0) { + rss << "FAILED" << ":\n"; + if (result.hasExpression()) { + rss << " "; + rss << result.getExpressionInMacro(); + rss << '\n'; + } + if (result.hasExpandedExpression()) { + rss << "with expansion:\n"; + rss << Column(result.getExpandedExpression()).indent(2) << '\n'; + } + } else { + rss << '\n'; + } + + if( !result.getMessage().empty() ) + rss << result.getMessage() << '\n'; + for( auto const& msg : stats.infoMessages ) + if( msg.type == ResultWas::Info ) + rss << msg.message << '\n'; + + rss << "at " << result.getSourceInfo(); + xml.writeText( rss.str(), XmlFormatting::Newline ); + } + } + + CATCH_REGISTER_REPORTER( "junit", JunitReporter ) + +} // end namespace Catch +// end catch_reporter_junit.cpp +// start catch_reporter_listening.cpp + +#include <cassert> + +namespace Catch { + + ListeningReporter::ListeningReporter() { + // We will assume that listeners will always want all assertions + m_preferences.shouldReportAllAssertions = true; + } + + void ListeningReporter::addListener( IStreamingReporterPtr&& listener ) { + m_listeners.push_back( std::move( listener ) ); + } + + void ListeningReporter::addReporter(IStreamingReporterPtr&& reporter) { + assert(!m_reporter && "Listening reporter can wrap only 1 real reporter"); + m_reporter = std::move( reporter ); + m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut; + } + + ReporterPreferences ListeningReporter::getPreferences() const { + return m_preferences; + } + + std::set<Verbosity> ListeningReporter::getSupportedVerbosities() { + return std::set<Verbosity>{ }; + } + + void ListeningReporter::noMatchingTestCases( std::string const& spec ) { + for ( auto const& listener : m_listeners ) { + listener->noMatchingTestCases( spec ); + } + m_reporter->noMatchingTestCases( spec ); + } + + void ListeningReporter::reportInvalidArguments(std::string const&arg){ + for ( auto const& listener : m_listeners ) { + listener->reportInvalidArguments( arg ); + } + m_reporter->reportInvalidArguments( arg ); + } + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + void ListeningReporter::benchmarkPreparing( std::string const& name ) { + for (auto const& listener : m_listeners) { + listener->benchmarkPreparing(name); + } + m_reporter->benchmarkPreparing(name); + } + void ListeningReporter::benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) { + for ( auto const& listener : m_listeners ) { + listener->benchmarkStarting( benchmarkInfo ); + } + m_reporter->benchmarkStarting( benchmarkInfo ); + } + void ListeningReporter::benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) { + for ( auto const& listener : m_listeners ) { + listener->benchmarkEnded( benchmarkStats ); + } + m_reporter->benchmarkEnded( benchmarkStats ); + } + + void ListeningReporter::benchmarkFailed( std::string const& error ) { + for (auto const& listener : m_listeners) { + listener->benchmarkFailed(error); + } + m_reporter->benchmarkFailed(error); + } +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + void ListeningReporter::testRunStarting( TestRunInfo const& testRunInfo ) { + for ( auto const& listener : m_listeners ) { + listener->testRunStarting( testRunInfo ); + } + m_reporter->testRunStarting( testRunInfo ); + } + + void ListeningReporter::testGroupStarting( GroupInfo const& groupInfo ) { + for ( auto const& listener : m_listeners ) { + listener->testGroupStarting( groupInfo ); + } + m_reporter->testGroupStarting( groupInfo ); + } + + void ListeningReporter::testCaseStarting( TestCaseInfo const& testInfo ) { + for ( auto const& listener : m_listeners ) { + listener->testCaseStarting( testInfo ); + } + m_reporter->testCaseStarting( testInfo ); + } + + void ListeningReporter::sectionStarting( SectionInfo const& sectionInfo ) { + for ( auto const& listener : m_listeners ) { + listener->sectionStarting( sectionInfo ); + } + m_reporter->sectionStarting( sectionInfo ); + } + + void ListeningReporter::assertionStarting( AssertionInfo const& assertionInfo ) { + for ( auto const& listener : m_listeners ) { + listener->assertionStarting( assertionInfo ); + } + m_reporter->assertionStarting( assertionInfo ); + } + + // The return value indicates if the messages buffer should be cleared: + bool ListeningReporter::assertionEnded( AssertionStats const& assertionStats ) { + for( auto const& listener : m_listeners ) { + static_cast<void>( listener->assertionEnded( assertionStats ) ); + } + return m_reporter->assertionEnded( assertionStats ); + } + + void ListeningReporter::sectionEnded( SectionStats const& sectionStats ) { + for ( auto const& listener : m_listeners ) { + listener->sectionEnded( sectionStats ); + } + m_reporter->sectionEnded( sectionStats ); + } + + void ListeningReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { + for ( auto const& listener : m_listeners ) { + listener->testCaseEnded( testCaseStats ); + } + m_reporter->testCaseEnded( testCaseStats ); + } + + void ListeningReporter::testGroupEnded( TestGroupStats const& testGroupStats ) { + for ( auto const& listener : m_listeners ) { + listener->testGroupEnded( testGroupStats ); + } + m_reporter->testGroupEnded( testGroupStats ); + } + + void ListeningReporter::testRunEnded( TestRunStats const& testRunStats ) { + for ( auto const& listener : m_listeners ) { + listener->testRunEnded( testRunStats ); + } + m_reporter->testRunEnded( testRunStats ); + } + + void ListeningReporter::skipTest( TestCaseInfo const& testInfo ) { + for ( auto const& listener : m_listeners ) { + listener->skipTest( testInfo ); + } + m_reporter->skipTest( testInfo ); + } + + bool ListeningReporter::isMulti() const { + return true; + } + +} // end namespace Catch +// end catch_reporter_listening.cpp +// start catch_reporter_xml.cpp + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled + // and default is missing) is enabled +#endif + +namespace Catch { + XmlReporter::XmlReporter( ReporterConfig const& _config ) + : StreamingReporterBase( _config ), + m_xml(_config.stream()) + { + m_reporterPrefs.shouldRedirectStdOut = true; + m_reporterPrefs.shouldReportAllAssertions = true; + } + + XmlReporter::~XmlReporter() = default; + + std::string XmlReporter::getDescription() { + return "Reports test results as an XML document"; + } + + std::string XmlReporter::getStylesheetRef() const { + return std::string(); + } + + void XmlReporter::writeSourceInfo( SourceLineInfo const& sourceInfo ) { + m_xml + .writeAttribute( "filename", sourceInfo.file ) + .writeAttribute( "line", sourceInfo.line ); + } + + void XmlReporter::noMatchingTestCases( std::string const& s ) { + StreamingReporterBase::noMatchingTestCases( s ); + } + + void XmlReporter::testRunStarting( TestRunInfo const& testInfo ) { + StreamingReporterBase::testRunStarting( testInfo ); + std::string stylesheetRef = getStylesheetRef(); + if( !stylesheetRef.empty() ) + m_xml.writeStylesheetRef( stylesheetRef ); + m_xml.startElement( "Catch" ); + if( !m_config->name().empty() ) + m_xml.writeAttribute( "name", m_config->name() ); + if (m_config->testSpec().hasFilters()) + m_xml.writeAttribute( "filters", serializeFilters( m_config->getTestsOrTags() ) ); + if( m_config->rngSeed() != 0 ) + m_xml.scopedElement( "Randomness" ) + .writeAttribute( "seed", m_config->rngSeed() ); + } + + void XmlReporter::testGroupStarting( GroupInfo const& groupInfo ) { + StreamingReporterBase::testGroupStarting( groupInfo ); + m_xml.startElement( "Group" ) + .writeAttribute( "name", groupInfo.name ); + } + + void XmlReporter::testCaseStarting( TestCaseInfo const& testInfo ) { + StreamingReporterBase::testCaseStarting(testInfo); + m_xml.startElement( "TestCase" ) + .writeAttribute( "name", trim( testInfo.name ) ) + .writeAttribute( "description", testInfo.description ) + .writeAttribute( "tags", testInfo.tagsAsString() ); + + writeSourceInfo( testInfo.lineInfo ); + + if ( m_config->showDurations() == ShowDurations::Always ) + m_testCaseTimer.start(); + m_xml.ensureTagClosed(); + } + + void XmlReporter::sectionStarting( SectionInfo const& sectionInfo ) { + StreamingReporterBase::sectionStarting( sectionInfo ); + if( m_sectionDepth++ > 0 ) { + m_xml.startElement( "Section" ) + .writeAttribute( "name", trim( sectionInfo.name ) ); + writeSourceInfo( sectionInfo.lineInfo ); + m_xml.ensureTagClosed(); + } + } + + void XmlReporter::assertionStarting( AssertionInfo const& ) { } + + bool XmlReporter::assertionEnded( AssertionStats const& assertionStats ) { + + AssertionResult const& result = assertionStats.assertionResult; + + bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); + + if( includeResults || result.getResultType() == ResultWas::Warning ) { + // Print any info messages in <Info> tags. + for( auto const& msg : assertionStats.infoMessages ) { + if( msg.type == ResultWas::Info && includeResults ) { + m_xml.scopedElement( "Info" ) + .writeText( msg.message ); + } else if ( msg.type == ResultWas::Warning ) { + m_xml.scopedElement( "Warning" ) + .writeText( msg.message ); + } + } + } + + // Drop out if result was successful but we're not printing them. + if( !includeResults && result.getResultType() != ResultWas::Warning ) + return true; + + // Print the expression if there is one. + if( result.hasExpression() ) { + m_xml.startElement( "Expression" ) + .writeAttribute( "success", result.succeeded() ) + .writeAttribute( "type", result.getTestMacroName() ); + + writeSourceInfo( result.getSourceInfo() ); + + m_xml.scopedElement( "Original" ) + .writeText( result.getExpression() ); + m_xml.scopedElement( "Expanded" ) + .writeText( result.getExpandedExpression() ); + } + + // And... Print a result applicable to each result type. + switch( result.getResultType() ) { + case ResultWas::ThrewException: + m_xml.startElement( "Exception" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + case ResultWas::FatalErrorCondition: + m_xml.startElement( "FatalErrorCondition" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + case ResultWas::Info: + m_xml.scopedElement( "Info" ) + .writeText( result.getMessage() ); + break; + case ResultWas::Warning: + // Warning will already have been written + break; + case ResultWas::ExplicitFailure: + m_xml.startElement( "Failure" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + default: + break; + } + + if( result.hasExpression() ) + m_xml.endElement(); + + return true; + } + + void XmlReporter::sectionEnded( SectionStats const& sectionStats ) { + StreamingReporterBase::sectionEnded( sectionStats ); + if( --m_sectionDepth > 0 ) { + XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" ); + e.writeAttribute( "successes", sectionStats.assertions.passed ); + e.writeAttribute( "failures", sectionStats.assertions.failed ); + e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk ); + + if ( m_config->showDurations() == ShowDurations::Always ) + e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds ); + + m_xml.endElement(); + } + } + + void XmlReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { + StreamingReporterBase::testCaseEnded( testCaseStats ); + XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" ); + e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() ); + + if ( m_config->showDurations() == ShowDurations::Always ) + e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); + + if( !testCaseStats.stdOut.empty() ) + m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), XmlFormatting::Newline ); + if( !testCaseStats.stdErr.empty() ) + m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), XmlFormatting::Newline ); + + m_xml.endElement(); + } + + void XmlReporter::testGroupEnded( TestGroupStats const& testGroupStats ) { + StreamingReporterBase::testGroupEnded( testGroupStats ); + // TODO: Check testGroupStats.aborting and act accordingly. + m_xml.scopedElement( "OverallResults" ) + .writeAttribute( "successes", testGroupStats.totals.assertions.passed ) + .writeAttribute( "failures", testGroupStats.totals.assertions.failed ) + .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk ); + m_xml.scopedElement( "OverallResultsCases") + .writeAttribute( "successes", testGroupStats.totals.testCases.passed ) + .writeAttribute( "failures", testGroupStats.totals.testCases.failed ) + .writeAttribute( "expectedFailures", testGroupStats.totals.testCases.failedButOk ); + m_xml.endElement(); + } + + void XmlReporter::testRunEnded( TestRunStats const& testRunStats ) { + StreamingReporterBase::testRunEnded( testRunStats ); + m_xml.scopedElement( "OverallResults" ) + .writeAttribute( "successes", testRunStats.totals.assertions.passed ) + .writeAttribute( "failures", testRunStats.totals.assertions.failed ) + .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk ); + m_xml.scopedElement( "OverallResultsCases") + .writeAttribute( "successes", testRunStats.totals.testCases.passed ) + .writeAttribute( "failures", testRunStats.totals.testCases.failed ) + .writeAttribute( "expectedFailures", testRunStats.totals.testCases.failedButOk ); + m_xml.endElement(); + } + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + void XmlReporter::benchmarkPreparing(std::string const& name) { + m_xml.startElement("BenchmarkResults") + .writeAttribute("name", name); + } + + void XmlReporter::benchmarkStarting(BenchmarkInfo const &info) { + m_xml.writeAttribute("samples", info.samples) + .writeAttribute("resamples", info.resamples) + .writeAttribute("iterations", info.iterations) + .writeAttribute("clockResolution", info.clockResolution) + .writeAttribute("estimatedDuration", info.estimatedDuration) + .writeComment("All values in nano seconds"); + } + + void XmlReporter::benchmarkEnded(BenchmarkStats<> const& benchmarkStats) { + m_xml.startElement("mean") + .writeAttribute("value", benchmarkStats.mean.point.count()) + .writeAttribute("lowerBound", benchmarkStats.mean.lower_bound.count()) + .writeAttribute("upperBound", benchmarkStats.mean.upper_bound.count()) + .writeAttribute("ci", benchmarkStats.mean.confidence_interval); + m_xml.endElement(); + m_xml.startElement("standardDeviation") + .writeAttribute("value", benchmarkStats.standardDeviation.point.count()) + .writeAttribute("lowerBound", benchmarkStats.standardDeviation.lower_bound.count()) + .writeAttribute("upperBound", benchmarkStats.standardDeviation.upper_bound.count()) + .writeAttribute("ci", benchmarkStats.standardDeviation.confidence_interval); + m_xml.endElement(); + m_xml.startElement("outliers") + .writeAttribute("variance", benchmarkStats.outlierVariance) + .writeAttribute("lowMild", benchmarkStats.outliers.low_mild) + .writeAttribute("lowSevere", benchmarkStats.outliers.low_severe) + .writeAttribute("highMild", benchmarkStats.outliers.high_mild) + .writeAttribute("highSevere", benchmarkStats.outliers.high_severe); + m_xml.endElement(); + m_xml.endElement(); + } + + void XmlReporter::benchmarkFailed(std::string const &error) { + m_xml.scopedElement("failed"). + writeAttribute("message", error); + m_xml.endElement(); + } +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + CATCH_REGISTER_REPORTER( "xml", XmlReporter ) + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif +// end catch_reporter_xml.cpp + +namespace Catch { + LeakDetector leakDetector; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_impl.hpp +#endif + +#ifdef CATCH_CONFIG_MAIN +// start catch_default_main.hpp + +#ifndef __OBJC__ + +#ifndef CATCH_INTERNAL_CDECL +#ifdef _MSC_VER +#define CATCH_INTERNAL_CDECL __cdecl +#else +#define CATCH_INTERNAL_CDECL +#endif +#endif + +#if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) +// Standard C/C++ Win32 Unicode wmain entry point +extern "C" int CATCH_INTERNAL_CDECL wmain (int argc, wchar_t * argv[], wchar_t * []) { +#else +// Standard C/C++ main entry point +int CATCH_INTERNAL_CDECL main (int argc, char * argv[]) { +#endif + + return Catch::Session().run( argc, argv ); +} + +#else // __OBJC__ + +// Objective-C entry point +int main (int argc, char * const argv[]) { +#if !CATCH_ARC_ENABLED + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; +#endif + + Catch::registerTestMethods(); + int result = Catch::Session().run( argc, (char**)argv ); + +#if !CATCH_ARC_ENABLED + [pool drain]; +#endif + + return result; +} + +#endif // __OBJC__ + +// end catch_default_main.hpp +#endif + +#if !defined(CATCH_CONFIG_IMPL_ONLY) + +#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED +# undef CLARA_CONFIG_MAIN +#endif + +#if !defined(CATCH_CONFIG_DISABLE) +////// +// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +#ifdef CATCH_CONFIG_PREFIX_ALL + +#define CATCH_REQUIRE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) + +#define CATCH_REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) +#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) +#endif// CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + +#define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) +#define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) + +#define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) +#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) + +#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) +#define CATCH_UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "CATCH_UNSCOPED_INFO", msg ) +#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) +#define CATCH_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_CAPTURE",__VA_ARGS__ ) + +#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) +#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) +#define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) +#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) +#define CATCH_DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) +#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) +#else +#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) ) +#endif + +#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE) +#define CATCH_STATIC_REQUIRE( ... ) static_assert( __VA_ARGS__ , #__VA_ARGS__ ); CATCH_SUCCEED( #__VA_ARGS__ ) +#define CATCH_STATIC_REQUIRE_FALSE( ... ) static_assert( !(__VA_ARGS__), "!(" #__VA_ARGS__ ")" ); CATCH_SUCCEED( #__VA_ARGS__ ) +#else +#define CATCH_STATIC_REQUIRE( ... ) CATCH_REQUIRE( __VA_ARGS__ ) +#define CATCH_STATIC_REQUIRE_FALSE( ... ) CATCH_REQUIRE_FALSE( __VA_ARGS__ ) +#endif + +// "BDD-style" convenience wrappers +#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) +#define CATCH_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc ) +#define CATCH_AND_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And given: " << desc ) +#define CATCH_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc ) +#define CATCH_AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And when: " << desc ) +#define CATCH_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc ) +#define CATCH_AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc ) + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +#define CATCH_BENCHMARK(...) \ + INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(C_A_T_C_H_B_E_N_C_H_), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,)) +#define CATCH_BENCHMARK_ADVANCED(name) \ + INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(C_A_T_C_H_B_E_N_C_H_), name) +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#else + +#define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) + +#define REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) +#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + +#define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) +#define CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) + +#define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) +#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) + +#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) +#define UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "UNSCOPED_INFO", msg ) +#define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) +#define CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CAPTURE",__VA_ARGS__ ) + +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) +#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) +#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) +#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) +#define DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) +#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) +#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) +#define TEMPLATE_LIST_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(__VA_ARGS__) +#define TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#else +#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) ) +#define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) ) +#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) ) +#define TEMPLATE_LIST_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE( __VA_ARGS__ ) ) +#define TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#endif + +#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE) +#define STATIC_REQUIRE( ... ) static_assert( __VA_ARGS__, #__VA_ARGS__ ); SUCCEED( #__VA_ARGS__ ) +#define STATIC_REQUIRE_FALSE( ... ) static_assert( !(__VA_ARGS__), "!(" #__VA_ARGS__ ")" ); SUCCEED( "!(" #__VA_ARGS__ ")" ) +#else +#define STATIC_REQUIRE( ... ) REQUIRE( __VA_ARGS__ ) +#define STATIC_REQUIRE_FALSE( ... ) REQUIRE_FALSE( __VA_ARGS__ ) +#endif + +#endif + +#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) + +// "BDD-style" convenience wrappers +#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) + +#define GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc ) +#define AND_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And given: " << desc ) +#define WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc ) +#define AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And when: " << desc ) +#define THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc ) +#define AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc ) + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +#define BENCHMARK(...) \ + INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(C_A_T_C_H_B_E_N_C_H_), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,)) +#define BENCHMARK_ADVANCED(name) \ + INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(C_A_T_C_H_B_E_N_C_H_), name) +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + +using Catch::Detail::Approx; + +#else // CATCH_CONFIG_DISABLE + +////// +// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +#ifdef CATCH_CONFIG_PREFIX_ALL + +#define CATCH_REQUIRE( ... ) (void)(0) +#define CATCH_REQUIRE_FALSE( ... ) (void)(0) + +#define CATCH_REQUIRE_THROWS( ... ) (void)(0) +#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0) +#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif// CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_REQUIRE_NOTHROW( ... ) (void)(0) + +#define CATCH_CHECK( ... ) (void)(0) +#define CATCH_CHECK_FALSE( ... ) (void)(0) +#define CATCH_CHECKED_IF( ... ) if (__VA_ARGS__) +#define CATCH_CHECKED_ELSE( ... ) if (!(__VA_ARGS__)) +#define CATCH_CHECK_NOFAIL( ... ) (void)(0) + +#define CATCH_CHECK_THROWS( ... ) (void)(0) +#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) (void)(0) +#define CATCH_CHECK_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_CHECK_NOTHROW( ... ) (void)(0) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THAT( arg, matcher ) (void)(0) + +#define CATCH_REQUIRE_THAT( arg, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define CATCH_INFO( msg ) (void)(0) +#define CATCH_UNSCOPED_INFO( msg ) (void)(0) +#define CATCH_WARN( msg ) (void)(0) +#define CATCH_CAPTURE( msg ) (void)(0) + +#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) +#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) +#define CATCH_METHOD_AS_TEST_CASE( method, ... ) +#define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0) +#define CATCH_SECTION( ... ) +#define CATCH_DYNAMIC_SECTION( ... ) +#define CATCH_FAIL( ... ) (void)(0) +#define CATCH_FAIL_CHECK( ... ) (void)(0) +#define CATCH_SUCCEED( ... ) (void)(0) + +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) +#define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) +#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__) +#define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#else +#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) ) +#define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#endif + +// "BDD-style" convenience wrappers +#define CATCH_SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ), className ) +#define CATCH_GIVEN( desc ) +#define CATCH_AND_GIVEN( desc ) +#define CATCH_WHEN( desc ) +#define CATCH_AND_WHEN( desc ) +#define CATCH_THEN( desc ) +#define CATCH_AND_THEN( desc ) + +#define CATCH_STATIC_REQUIRE( ... ) (void)(0) +#define CATCH_STATIC_REQUIRE_FALSE( ... ) (void)(0) + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#else + +#define REQUIRE( ... ) (void)(0) +#define REQUIRE_FALSE( ... ) (void)(0) + +#define REQUIRE_THROWS( ... ) (void)(0) +#define REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0) +#define REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define REQUIRE_NOTHROW( ... ) (void)(0) + +#define CHECK( ... ) (void)(0) +#define CHECK_FALSE( ... ) (void)(0) +#define CHECKED_IF( ... ) if (__VA_ARGS__) +#define CHECKED_ELSE( ... ) if (!(__VA_ARGS__)) +#define CHECK_NOFAIL( ... ) (void)(0) + +#define CHECK_THROWS( ... ) (void)(0) +#define CHECK_THROWS_AS( expr, exceptionType ) (void)(0) +#define CHECK_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CHECK_NOTHROW( ... ) (void)(0) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THAT( arg, matcher ) (void)(0) + +#define REQUIRE_THAT( arg, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define INFO( msg ) (void)(0) +#define UNSCOPED_INFO( msg ) (void)(0) +#define WARN( msg ) (void)(0) +#define CAPTURE( ... ) (void)(0) + +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) +#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) +#define METHOD_AS_TEST_CASE( method, ... ) +#define REGISTER_TEST_CASE( Function, ... ) (void)(0) +#define SECTION( ... ) +#define DYNAMIC_SECTION( ... ) +#define FAIL( ... ) (void)(0) +#define FAIL_CHECK( ... ) (void)(0) +#define SUCCEED( ... ) (void)(0) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ )) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) +#define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) +#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__) +#define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#else +#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) ) +#define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) ) +#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__ ) ) +#define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#endif + +#define STATIC_REQUIRE( ... ) (void)(0) +#define STATIC_REQUIRE_FALSE( ... ) (void)(0) + +#endif + +#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) + +// "BDD-style" convenience wrappers +#define SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ) ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( C_A_T_C_H_T_E_S_T_ ), className ) + +#define GIVEN( desc ) +#define AND_GIVEN( desc ) +#define WHEN( desc ) +#define AND_WHEN( desc ) +#define THEN( desc ) +#define AND_THEN( desc ) + +using Catch::Detail::Approx; + +#endif + +#endif // ! CATCH_CONFIG_IMPL_ONLY + +// start catch_reenable_warnings.h + + +#ifdef __clang__ +# ifdef __ICC // icpc defines the __clang__ macro +# pragma warning(pop) +# else +# pragma clang diagnostic pop +# endif +#elif defined __GNUC__ +# pragma GCC diagnostic pop +#endif + +// end catch_reenable_warnings.h +// end catch.hpp +#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED + diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchConversions/catch_conversions/qdoc_catch_conversions.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchConversions/catch_conversions/qdoc_catch_conversions.h new file mode 100644 index 0000000000000000000000000000000000000000..51e46722c8693873088ecb0105b8d3d63a3a418f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchConversions/catch_conversions/qdoc_catch_conversions.h @@ -0,0 +1,24 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "qt_catch_conversions.h" + +#include <qdoc/boundaries/filesystem/directorypath.h> +#include <qdoc/boundaries/filesystem/filepath.h> +#include <qdoc/boundaries/filesystem/resolvedfile.h> + +#include <ostream> + +inline std::ostream& operator<<(std::ostream& os, const DirectoryPath& dirpath) { + return os << dirpath.value().toStdString(); +} + +inline std::ostream& operator<<(std::ostream& os, const FilePath& filepath) { + return os << filepath.value().toStdString(); +} + +inline std::ostream& operator<<(std::ostream& os, const ResolvedFile& resolved_file) { + return os << "ResolvedFile{ query: " << resolved_file.get_query().toStdString() << ", " << "filepath: " << resolved_file.get_path() << " }"; +} diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchConversions/catch_conversions/qt_catch_conversions.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchConversions/catch_conversions/qt_catch_conversions.h new file mode 100644 index 0000000000000000000000000000000000000000..f9662a9fd077b54b61da139c88bc7218fb89cdb9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchConversions/catch_conversions/qt_catch_conversions.h @@ -0,0 +1,19 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "std_catch_conversions.h" + +#include <ostream> + +#include <QChar> +#include <QString> + +inline std::ostream& operator<<(std::ostream& os, const QChar& character) { + return os << QString{character}.toStdString(); +} + +inline std::ostream& operator<<(std::ostream& os, const QString& string) { + return os << string.toStdString(); +} diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchConversions/catch_conversions/std_catch_conversions.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchConversions/catch_conversions/std_catch_conversions.h new file mode 100644 index 0000000000000000000000000000000000000000..6370466b2e0f038a229190005a27f8ed458f6390 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchConversions/catch_conversions/std_catch_conversions.h @@ -0,0 +1,16 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include <ostream> +#include <optional> + +template<typename T> +inline std::ostream& operator<<(std::ostream& os, const std::optional<T>& optional) { + os << "std::optional{\n\t"; + if (optional) os << optional.value(); + else os <<"nullopt"; + + return os << "\n};"; +} diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/combinators/cycle_generator.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/combinators/cycle_generator.h new file mode 100644 index 0000000000000000000000000000000000000000..338432f2db256328964753e6081b937567aebb7b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/combinators/cycle_generator.h @@ -0,0 +1,80 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../../namespaces.h" +#include "../../utilities/semantics/generator_handler.h" + +#include <catch/catch.hpp> + +#include <vector> + +namespace QDOC_CATCH_GENERATORS_ROOT_NAMESPACE { + namespace QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE { + + template<typename T> + class CycleGenerator : public Catch::Generators::IGenerator<T> { + public: + CycleGenerator(Catch::Generators::GeneratorWrapper<T>&& generator) + : generator{std::move(generator)}, + cache{}, + cache_index{0} + { + // REMARK: We generally handle extracting the first + // value by using an handler, to avoid code + // duplication and the possibility of an error. + // In this specific case, we turn to a more "manual" + // approach as it better models the cache-based + // implementation, removing the need to not increment + // cache_index the first time that next is called. + cache.emplace_back(this->generator.get()); + } + + T const& get() const override { return cache[cache_index]; } + + bool next() override { + if (generator.next()) { + cache.emplace_back(generator.get()); + ++cache_index; + } else { + cache_index = (cache_index + 1) % cache.size(); + } + + return true; + } + + private: + Catch::Generators::GeneratorWrapper<T> generator; + + std::vector<T> cache; + std::size_t cache_index; + }; + + } // end QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE + + /*! + * Returns a generator that behaves like \a generator until \a + * generator is exhausted, repeating the same generation that \a + * generator produced, infinitely, afterwards. + * + * This is generally intended to produce infinite generators from + * finite ones. + * + * For example, consider a generator that produces values based on + * another generator that it owns. + * If the owning generator needs to produce more values that the + * owned generator can support, it might fail at some point. + * By cycling over the owned generator, we can extend the sequence + * of produced values so that enough are generated, in a controlled + * way. + * + * The type T should generally be copyable for this generator to + * work. + */ + template<typename T> + inline Catch::Generators::GeneratorWrapper<T> cycle(Catch::Generators::GeneratorWrapper<T>&& generator) { + return Catch::Generators::GeneratorWrapper<T>(std::unique_ptr<Catch::Generators::IGenerator<T>>(new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::CycleGenerator(std::move(generator)))); + } + +} // end QDOC_CATCH_GENERATORS_ROOT_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/combinators/oneof_generator.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/combinators/oneof_generator.h new file mode 100644 index 0000000000000000000000000000000000000000..f82b26a988056bcd9e4cdf8673c9f65237dab66d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/combinators/oneof_generator.h @@ -0,0 +1,185 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../../namespaces.h" +#include "../../utilities/statistics/percentages.h" +#include "../../utilities/semantics/generator_handler.h" + +#include <catch/catch.hpp> + +#include <vector> +#include <random> +#include <algorithm> +#include <numeric> + +namespace QDOC_CATCH_GENERATORS_ROOT_NAMESPACE { + namespace QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE { + + template<typename T> + class OneOfGenerator : public Catch::Generators::IGenerator<T> { + public: + OneOfGenerator( + std::vector<Catch::Generators::GeneratorWrapper<T>>&& generators, + const std::vector<double>& weights + ) : generators{std::move(generators)}, + random_engine{std::random_device{}()}, + choice_distribution{weights.cbegin(), weights.cend()} + { + assert(weights.size() == this->generators.size()); + assert(std::reduce(weights.cbegin(), weights.cend()) == Approx(100.0)); + + std::transform( + this->generators.begin(), this->generators.end(), this->generators.begin(), + [](auto& generator){ return QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::handler(std::move(generator)); } + ); + + static_cast<void>(next()); + } + + T const& get() const override { return current_value; } + + bool next() override { + std::size_t generator_index{choice_distribution(random_engine)}; + + if (!generators[generator_index].next()) return false; + current_value = generators[generator_index].get(); + + return true; + } + + private: + std::vector<Catch::Generators::GeneratorWrapper<T>> generators; + + std::mt19937 random_engine; + std::discrete_distribution<std::size_t> choice_distribution; + + T current_value; + }; + + } // end QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE + + /*! + * Returns a generator whose set of elements is the union of the + * set of elements of the generators in \a generators. + * + * Each time the generator produces a value, a generator from \a + * generators is randomly chosen to produce the value. + * + * The distribution for the choice is given by \a weights. + * The \e {ith} element in \a weights represent the percentage + * probability of the \e {ith} element of \a generators to be + * chosen. + * + * It follows that the size of \a weights must be the same as the + * size of \a generators. + * + * Furthermore, the sum of elements in \a weights should be a + * hundred. + * + * The generator produces values until a generator that is chosen + * to produce a value is unable to do so. + * The first such generator to do so will stop the generation + * independently of the availability of the other generators. + * + * Similarly, values will be produced as long as the chosen + * generator can produce a value, independently of the other + * generators being exhausted already. + */ + template<typename T> + inline Catch::Generators::GeneratorWrapper<T> oneof( + std::vector<Catch::Generators::GeneratorWrapper<T>>&& generators, + const std::vector<double>& weights + ) { + return Catch::Generators::GeneratorWrapper<T>(std::unique_ptr<Catch::Generators::IGenerator<T>>(new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::OneOfGenerator(std::move(generators), weights))); + } + + + /*! + * Returns a generator whose set of elements is the union of the + * set of elements of the generators in \a generators and in which + * the distribution of the generated elements is uniform over \a + * generators. + * + * Each time the generator produces a value, a generator from \a + * generators is randomly chosen to produce the value. + * + * Each generator from \a generators has the same chance of being + * chosen. + * + * Do note that the distribution over the set of values is not + * necessarily uniform. + * + * The generator produces values until a generator that is chosen + * to produce a value is unable to do so. + * The first such generator to do so will stop the generation + * independently of the availability of the other generators. + * + * Similarly, values will be produced as long as the chosen + * generator can produce a value, independently of the other + * generators being exhausted already. + */ + template<typename T> + inline Catch::Generators::GeneratorWrapper<T> uniform_oneof( + std::vector<Catch::Generators::GeneratorWrapper<T>>&& generators + ) { + std::vector<double> weights( + generators.size(), + QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::uniform_probability(generators.size()) + ); + return oneof(std::move(generators), std::move(weights)); + } + + /*! + * Returns a generator whose set of elements is the union of the + * set of elements of the generators in \a generators and in which + * the distribution of the generated elements is uniform over the + * elements of \a generators. + * + * The generators in \a generator should have a uniform + * distribution and be finite. + * If the set of elements that the generators in \a generator is + * not disjoint, the distribution will be skewed towards repeated + * elements. + * + * Each time the generator produces a value, a generator from \a + * generators is randomly chosen to produce the value. + * + * Each generator from \a generators has a probability of being + * chosen based on the proportion of the cardinality of the subset + * it produces. + * + * The \e {ith} element of \a amounts should contain the + * cardinality of the set produced by the \e {ith} generator in \a + * generators. + * + * The generator produces values until a generator that is chosen + * to produce a value is unable to do so. + * The first such generator to do so will stop the generation + * independently of the availability of the other generators. + * + * Similarly, values will be produced as long as the chosen + * generator can produce a value, independently of the other + * generators being exhausted already. + */ + template<typename T> + inline Catch::Generators::GeneratorWrapper<T> uniformly_valued_oneof( + std::vector<Catch::Generators::GeneratorWrapper<T>>&& generators, + const std::vector<std::size_t>& amounts + ) { + std::size_t total_amount{std::accumulate(amounts.cbegin(), amounts.cend(), std::size_t{0})}; + + std::vector<double> weights; + weights.reserve(amounts.size()); + + std::transform( + amounts.cbegin(), amounts.cend(), + std::back_inserter(weights), + [total_amount](auto element){ return QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::percent_of(static_cast<double>(element), static_cast<double>(total_amount)); } + ); + + return oneof(std::move(generators), std::move(weights)); + } + +} // end QDOC_CATCH_GENERATORS_ROOT_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/k_partition_of_r_generator.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/k_partition_of_r_generator.h new file mode 100644 index 0000000000000000000000000000000000000000..ca48c7e94ca08afc7855b1f1c3577121af451347 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/k_partition_of_r_generator.h @@ -0,0 +1,113 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../namespaces.h" + +#include <catch/catch.hpp> + +#include <random> +#include <numeric> +#include <algorithm> + +namespace QDOC_CATCH_GENERATORS_ROOT_NAMESPACE { + namespace QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE { + + class KPartitionOfRGenerator : public Catch::Generators::IGenerator<std::vector<double>> { + public: + KPartitionOfRGenerator(double r, std::size_t k) + : random_engine{std::random_device{}()}, + interval_distribution{0.0, r}, + k{k}, + r{r}, + current_partition(k) + { + assert(r >= 0.0); + assert(k >= 1); + + static_cast<void>(next()); + } + + std::vector<double> const& get() const override { return current_partition; } + + bool next() override { + if (k == 1) current_partition[0] = r; + else { + // REMARK: The following wasn't formally proved + // but is based on intuition. + // It is probably erroneous but is expected to be + // good enough for our case. + + // REMARK: We aim to provide a non skewed + // distribution for the elements of the partition. + // + // The reasoning for this is to ensure that our + // testing surface has a good chance of hitting + // many of the available elements between the many + // runs. + // + // To approximate this, a specific algorithm was chosen. + // The following code can be intuitively seen as doing the following: + // + // Consider an interval [0.0, r] on the real line, where r > 0.0. + // + // k - 1 > 0 elements of the interval are chosen, + // partitioning the interval into disjoint + // sub-intervals. + // + // --------------------------------------------------------------------------------------------------------------------- + // | | | | | + // 0 k_1 k_2 k_3 r + // | | | | | + // _______--------------------_______________________________________________________----------------------------------- + // k_1 - 0 k_2 - k_1 k_3 - k_2 r - k_3 + // p1 p2 p3 p4 + // + // The length of each sub interval is chosen as one of the elements of the partition. + // + // Trivially, the sum of the chosen elements is r. + // + // Furthermore, as long as the distribution used + // to choose the elements of the original interval + // is uniform, the probability of each partition + // being produced should tend to being uniform + // itself. + std::generate(current_partition.begin(), current_partition.end() - 1, [this](){ return interval_distribution(random_engine); }); + + current_partition.back() = r; + + std::sort(current_partition.begin(), current_partition.end()); + std::adjacent_difference(current_partition.begin(), current_partition.end(), current_partition.begin()); + } + + return true; + } + + private: + std::mt19937 random_engine; + std::uniform_real_distribution<double> interval_distribution; + + std::size_t k; + double r; + + std::vector<double> current_partition; + }; + + } // end QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE + + /*! + * Returns a generator that generates collections of \a k elements + * whose sum is \a r. + * + * \a r must be a real number greater or euqal to zero and \a k + * must be a natural number greater than zero. + * + * The generated partitions tends to be uniformely distributed + * over the set of partitions of r. + */ + inline Catch::Generators::GeneratorWrapper<std::vector<double>> k_partition_of_r(double r, std::size_t k) { + return Catch::Generators::GeneratorWrapper<std::vector<double>>(std::unique_ptr<Catch::Generators::IGenerator<std::vector<double>>>(new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::KPartitionOfRGenerator(r, k))); + } + +} // end QDOC_CATCH_GENERATORS_ROOT_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/path_generator.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/path_generator.h new file mode 100644 index 0000000000000000000000000000000000000000..7e50c18179b72f8a8f84be8c331154f2ede848c0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/path_generator.h @@ -0,0 +1,853 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +// TODO: Change the include paths to implicitly consider +// `catch_generators` a root directory and change the CMakeLists.txt +// file to make this possible. + +#include "../namespaces.h" +#include "qchar_generator.h" +#include "qstring_generator.h" +#include "../utilities/semantics/move_into_vector.h" +#include "../utilities/semantics/generator_handler.h" + +#if defined(Q_OS_WINDOWS) + + #include "combinators/cycle_generator.h" + +#endif + +#include <catch/catch.hpp> + +#include <random> + +#include <QChar> +#include <QString> +#include <QStringList> +#include <QRegularExpression> + +#if defined(Q_OS_WINDOWS) + + #include <QStorageInfo> + +#endif + +namespace QDOC_CATCH_GENERATORS_ROOT_NAMESPACE { + + + struct PathGeneratorConfiguration { + double multi_device_path_probability{0.5}; + double absolute_path_probability{0.5}; + double directory_path_probability{0.5}; + double has_trailing_separator_probability{0.5}; + std::size_t minimum_components_amount{1}; + std::size_t maximum_components_amount{10}; + + PathGeneratorConfiguration& set_multi_device_path_probability(double amount) { + multi_device_path_probability = amount; + return *this; + } + + PathGeneratorConfiguration& set_absolute_path_probability(double amount) { + absolute_path_probability = amount; + return *this; + } + + PathGeneratorConfiguration& set_directory_path_probability(double amount) { + directory_path_probability = amount; + return *this; + } + + PathGeneratorConfiguration& set_has_trailing_separator_probability(double amount) { + has_trailing_separator_probability = amount; + return *this; + } + + PathGeneratorConfiguration& set_minimum_components_amount(std::size_t amount) { + minimum_components_amount = amount; + return *this; + } + + PathGeneratorConfiguration& set_maximum_components_amount(std::size_t amount) { + maximum_components_amount = amount; + return *this; + } + }; + + /*! + * \class PathGeneratorConfiguration + * \brief Defines some parameters to customize the generation of + * paths by a PathGenerator. + */ + + /*! + * \variable PathGeneratorConfiguration::multi_device_path_probability + * + * Every path produced by a PathGenerator configured with a + * mutli_device_path_probability of n has a probability of n to be + * \e {Multi-Device} and a probability of 1.0 - n to not be \a + * {Multi-Device}. + * + * multi_device_path_probability should be a value in the range [0.0, + * 1.0]. + */ + + /*! + * \variable PathGeneratorConfiguration::absolute_path_probability + * + * Every path produced by a PathGenerator configured with an + * absolute_path_probability of n has a probability of n to be \e + * {Absolute} and a probability of 1.0 - n to be \e {Relative}. + * + * absolute_path_probability should be a value in the range [0.0, + * 1.0]. + */ + + /*! + * \variable PathGeneratorConfiguration::directory_path_probability + * + * Every path produced by a PathGenerator configured with a + * directory_path_probability of n has a probability of n to be \e + * {To a Directory} and a probability of 1.0 - n to be \e {To a + * File}. + * + * directory_path_probability should be a value in the range [0.0, + * 1.0]. + */ + + /*! + * \variable PathGeneratorConfiguration::has_trailing_separator_probability + * + * Every path produced by a PathGenerator configured with an + * has_trailing_separator_probability of n has a probability of n + * to \e {Have a Trailing Separator} and a probability of 1.0 - n + * to not \e {Have a Trailing Separator}, when this is applicable. + * + * has_trailing_separator_probability should be a value in the + * range [0.0, 1.0]. + */ + + /*! + * \variable PathGeneratorConfiguration::minimum_components_amount + * + * Every path produced by a PathGenerator configured with a + * minimum_components_amount of n will be the concatenation of at + * least n non \e {device}, non \e {root}, non \e {separator} + * components. + * + * minimum_components_amount should be greater than zero and less + * than maximum_components_amount. + */ + + /*! + * \variable PathGeneratorConfiguration::maximum_components_amount + * + * Every path produced by a PathGenerator configured with a + * maximum_components_amount of n will be the concatenation of at + * most n non \e {device}, non \e {root}, non \e {separator} components. + * + * maximum_components_amount should be greater than or equal to + * minimum_components_amount. + */ + + + namespace QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE { + + class PathGenerator : public Catch::Generators::IGenerator<QString> { + public: + PathGenerator( + Catch::Generators::GeneratorWrapper<QString>&& device_component_generator, + Catch::Generators::GeneratorWrapper<QString>&& root_component_generator, + Catch::Generators::GeneratorWrapper<QString>&& directory_component_generator, + Catch::Generators::GeneratorWrapper<QString>&& filename_component_generator, + Catch::Generators::GeneratorWrapper<QString>&& separator_component_generator, + PathGeneratorConfiguration configuration = PathGeneratorConfiguration{} + ) : device_component_generator{QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::handler(std::move(device_component_generator))}, + root_component_generator{QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::handler(std::move(root_component_generator))}, + directory_component_generator{QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::handler(std::move(directory_component_generator))}, + filename_component_generator{QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::handler(std::move(filename_component_generator))}, + separator_component_generator{QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::handler(std::move(separator_component_generator))}, + random_engine{std::random_device{}()}, + components_amount_distribution{configuration.minimum_components_amount, configuration.maximum_components_amount}, + is_multi_device_distribution{configuration.multi_device_path_probability}, + is_absolute_path_distribution{configuration.absolute_path_probability}, + is_directory_path_distribution{configuration.directory_path_probability}, + has_trailing_separator{configuration.has_trailing_separator_probability}, + current_path{} + { + assert(configuration.minimum_components_amount > 0); + assert(configuration.minimum_components_amount <= configuration.maximum_components_amount); + + if (!next()) + Catch::throw_exception("Not enough values to initialize the first string"); + } + + QString const& get() const override { return current_path; } + + bool next() override { + std::size_t components_amount{components_amount_distribution(random_engine)}; + + current_path = ""; + + // REMARK: As per our specification of a path, we + // do not count device components, and separators, + // when considering the amount of components in a + // path. + // This is a tradeoff that is not necessarily + // precise. + // Counting those kinds of components, on one + // hand, would allow a device component to stands + // on its own as a path, for example "C:", which + // might actually be correct in some path format. + // On the other hand, counting those kinds of + // components makes the construction of paths for + // our model much more complex with regards, for + // example, to the amount of component. + // + // Counting device components, since they can + // appear both in relative and absolute paths, + // makes the minimum amount of components + // different for different kinds of paths. + // + // Since absolute paths always require a root + // component, the minimum amount of components for + // a multi-device absolute path is 2. + // + // But an absolute path that is not multi-device + // would only require one minimum component. + // + // Similarly, problems arise with the existence of + // Windows' relative multi-device path, which + // require a leading separator component after a + // device component. + // + // This problem mostly comes from our model + // simplifying the definition of paths quite a bit + // into binary-forms. + // This simplifies the code and its structure, + // sacrificing some precision. + // The lost precision is almost none for POSIX + // based paths, but is graver for DOS paths, since + // they have a more complex specification. + // + // Currently, we expect that the paths that QDoc + // will encounter will mostly be in POSIX-like + // forms, even on Windows, and aim to support + // that, such that the simplification of code is + // considered a better tradeoff compared to the + // loss of precision. + // + // If this changes, the model should be changed to + // pursue a Windows-first modeling, moving the + // categorization of paths from the current binary + // model to the absolute, drive-relative and + // relative triptych that Windows uses. + // This more complex model should be able to + // completely describe posix paths too, making it + // a superior choice as long as the complexity is + // warranted. + // + // Do note that the model similarly can become + // inconsistent when used to generate format of + // paths such as the one used in some resource + // systems. + // Those are considered out-of-scope for our needs + // and were not taken into account when developing + // this generator. + if (is_multi_device_distribution(random_engine)) { + if (!device_component_generator.next()) return false; + current_path += device_component_generator.get(); + } + + // REMARK: Similarly to not counting other form of + // components, we do not count root components + // towards the amounts of components that the path + // has to simplify the code. + // To support the "special" root path on, for + // example, posix systems, we require a more + // complex branching logic that changes based on + // the path being absolute or not. + // + // We don't expect root to be a particularly + // useful path for QDoc purposes and expect to not + // have to consider it for our tests. + // If consideration for it become required, it is + // possible to test it directly in the affected + // systemss as a special case. + // + // If most systems are affected by the handling of + // a root path, then the model should be slightly + // changed to accommodate its generation. + if (is_absolute_path_distribution(random_engine)) { + if (!root_component_generator.next()) return false; + + current_path += root_component_generator.get(); + } + + std::size_t prefix_components_amount{std::max(std::size_t{1}, components_amount) - 1}; + while (prefix_components_amount > 0) { + if (!directory_component_generator.next()) return false; + if (!separator_component_generator.next()) return false; + + current_path += directory_component_generator.get() + separator_component_generator.get(); + --prefix_components_amount; + } + + if (is_directory_path_distribution(random_engine)) { + if (!directory_component_generator.next()) return false; + current_path += directory_component_generator.get(); + + if (has_trailing_separator(random_engine)) { + if (!separator_component_generator.next()) return false; + current_path += separator_component_generator.get(); + } + } else { + if (!filename_component_generator.next()) return false; + current_path += filename_component_generator.get(); + } + + return true; + } + + private: + Catch::Generators::GeneratorWrapper<QString> device_component_generator; + Catch::Generators::GeneratorWrapper<QString> root_component_generator; + Catch::Generators::GeneratorWrapper<QString> directory_component_generator; + Catch::Generators::GeneratorWrapper<QString> filename_component_generator; + Catch::Generators::GeneratorWrapper<QString> separator_component_generator; + + std::mt19937 random_engine; + std::uniform_int_distribution<std::size_t> components_amount_distribution; + std::bernoulli_distribution is_multi_device_distribution; + std::bernoulli_distribution is_absolute_path_distribution; + std::bernoulli_distribution is_directory_path_distribution; + std::bernoulli_distribution has_trailing_separator; + + QString current_path; + }; + + } // end QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE + +/*! + * Returns a generator that produces QStrings that represent a + * path in a filesystem. + * + * A path is formed by the following components, loosely based + * on the abstraction that is used by std::filesystem::path: + * + * \list + * \li \b {device}: + * Represents the device on the filesystem that + * the path should be considered in terms of. + * This is an optional components that is sometimes + * present on multi-device systems, such as Windows, to + * distinguish which device the path refers to. + * When present, it always appears before any other + * component. + * \li \b {root}: + * A special sequence that marks the path as absolute. + * This is an optional component that is present, always, + * in absolute paths. + * \li \b {directory}: + * A component that represents a directory on the + * filesystem that the path "passes-trough". + * Zero or more of this components can be present in the + * path. + * A path pointing to a directory on the filesystem that + * is not \e {root} always ends with a component of this + * type. + * \li \b {filename}: + * A component that represents a file on the + * filesystem. + * When this component is present, it is present only once + * and always as the last component of the path. + * A path that has such a component is a path that points + * to a file on the filesystem. + * For some path formats, there is no difference in the + * format of a \e {filename} and a \e {directory}. + * \li \b {separator}: + * A component that is interleaved between other types of + * components to separate them so that they are + * recognizable. + * A path that points to a directory on the filesystem may + * sometimes have a \e {separator} at the end, after the + * ending \e {directory} component. + * \endlist + * + * Each component is representable as a string and a path is a + * concatenation of the string representation of some + * components, with the following rules: + * + * \list + * \li There is at most one \e {device} component. + * \li If a \e {device} component is present it always + * precedes all other components. + * \li There is at most one \e {root} component. + * \li If a \e {root} component is present it: + * \list + * \li Succeeds the \e {device} component if it is present. + * \li Precedes every other components if the \e {device} + * component is not present. + * \endlist + * \li There are zero or more \e {directory} component. + * \li There is at most one \e {filename} component. + * \li If a \e {filename} component is present it always + * succeeds all other components. + * \li Between any two successive \e {directory} components + * there is a \e {separator} component. + * \li Between each successive \e {directory} and \e + * {filename} component there is a \e {separator} component. + * \li If the last component is a \e {directory} component it + * can be optionally followed by a \e {separator} component. + * \li At least one component that is not a \e {device}, a \e + * {root} or \e {separator} component is present. + * \endlist + * + * For example, if "C:" is a \e {device} component, "\\" is a + * \e {root} component, "\\" is a \e {separator} component, + * "directory" is a \e {directory} component and "filename" is + * a \e {filename} component, the following are all paths: + * + * "C:\\directory", "C:\\directory\\directory", "C:filename", + * "directory\\directory\\", "\\directory\\filename", "filename". + * + * While the following aren't: + * + * "C:", "C:\\", "directory\\C:", "foo", "C:filename\\", + * "filename\\directory\\filename", "filename\\filename", + * "directorydirectory"." + * + * The format of different components type can be the same. + * For example, the \e {root} and \e {separator} component in + * the above example. + * For the purpose of generation, we do not care about the + * format itself and consider a component of a certain type + * depending only on how it is generated/where it is generated + * from. + * + * For example, if every component is formatted as the string + * "a", the string "aaa" could be a generated path. + * By the string alone, it is not possible to simply discern + * which components form it, but it would be possible to + * generate it if the first "a" is a \a {device} component, + * the second "a" is a \e {root} component and the third "a" + * is a \e {directory} or \e {filename} component. + * + * A path, is further said to have some properties, pairs of + * which are exclusive to each other. + * + * A path is said to be: + * + * \list + * \li \b {Multi-Device}: + * When it contains a \e {device} component. + * \li \b {Absolute}: + * When it contains a \e {root} component. + * If the path is \e {Absolute} it is not \e {Relative}. + * \li \b {Relative}: + * When it does not contain a \e {root} component. + * If the path is \e {Relative} it is not \e {Absolute}. + * \li \b {To a Directory}: + * When its last component is a \e {directory} component + * or a \e {directory} component followed by a \e + * {separator} component. + * If the path is \e {To a Directory} it is not \e {To a + * File}. + * \li \b {To a File}: + * When its last component is a \e {filename}. + * If the path is \e {To a File} it is not \e {To a + * Directory}. + * \endlist + * + * All path are \e {Relative/Absolute}, \e {To a + * Directory/To a File} and \e {Multi-Device} or not. + * + * Furthermore, a path that is \e {To a Directory} and whose + * last component is a \e {separator} component is said to \e + * {Have a Trailing Separator}. + */ + inline Catch::Generators::GeneratorWrapper<QString> path( + Catch::Generators::GeneratorWrapper<QString>&& device_generator, + Catch::Generators::GeneratorWrapper<QString>&& root_component_generator, + Catch::Generators::GeneratorWrapper<QString>&& directory_generator, + Catch::Generators::GeneratorWrapper<QString>&& filename_generator, + Catch::Generators::GeneratorWrapper<QString>&& separator_generator, + PathGeneratorConfiguration configuration = PathGeneratorConfiguration{} + ) { + return Catch::Generators::GeneratorWrapper<QString>( + std::unique_ptr<Catch::Generators::IGenerator<QString>>( + new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::PathGenerator(std::move(device_generator), std::move(root_component_generator), std::move(directory_generator), std::move(filename_generator), std::move(separator_generator), configuration) + ) + ); + } + + namespace QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE { + + // REMARK: We need a bounded length for the generation of path + // components as strings. + // We trivially do not want components to be the empty string, + // such that we have a minimum length of 1, but the maximum + // length is more malleable. + // We don't want components that are too long to avoid + // incurring in a big performance overhead, as we may generate + // many of them. + // At the same time, we want some freedom in having diffent + // length components. + // The value that was chosen is based on the general value for + // POSIX's NAME_MAX, which seems to tend to be 14 on many systems. + // We see this value as a small enough but not too much value + // that further brings with itself a relation to paths, + // increasing our portability even if it is out of scope, as + // almost no modern respects NAME_MAX. + // We don't use POSIX's NAME_MAX directly as it may not be available + // on all systems. + inline static constexpr std::size_t minimum_component_length{1}; + inline static constexpr std::size_t maximum_component_length{14}; + + /*! + * Returns a generator that generates strings that are + * suitable to be used as a root component in POSIX paths. + * + * As per + * \l {https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_02}, + * this is any sequence of slash characters that is not of + * length 2. + */ + inline Catch::Generators::GeneratorWrapper<QString> posix_root() { + return uniformly_valued_oneof( + QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::move_into_vector( + string(character('/', '/'), 1, 1), + string(character('/', '/'), 3, maximum_component_length) + ), + std::vector{1, maximum_component_length - 3} + ); + } + + /*! + * Returns a generator that generates strings that are + * suitable to be used as directory components in POSIX paths + * and that use an alphabet that should generally be supported + * by other systems. + * + * Components of this kind use the \l + * {https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_282}{Portable Filename Character Set}. + */ + inline Catch::Generators::GeneratorWrapper<QString> portable_posix_directory_name() { + return string( + QDOC_CATCH_GENERATORS_QCHAR_ALPHABETS_NAMESPACE::portable_posix_filename(), + minimum_component_length, maximum_component_length + ); + } + + /*! + * Returns a generator that generates strings that are + * suitable to be used as filenames in POSIX paths and that + * use an alphabet that should generally be supported by + * other systems. + * + * Filenames of this kind use the \l + * {https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_282}{Portable Filename Character Set}. + */ + inline Catch::Generators::GeneratorWrapper<QString> portable_posix_filename() { + // REMARK: "." and ".." always represent directories so we + // avoid generating them. Other than this, there is no + // difference between a file name and a directory name. + return filter([](auto& filename) { return filename != "." && filename != ".."; }, portable_posix_directory_name()); + } + + /*! + * Returns a generator that generates strings that can be used + * as POSIX compliant separators. + * + * As per \l + * {https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_271}, + * a separator is a sequence of one or more slashes. + */ + inline Catch::Generators::GeneratorWrapper<QString> posix_separator() { + return string(character('/', '/'), minimum_component_length, maximum_component_length); + } + + /*! + * Returns a generator that generates strings that can be + * suitably used as logical drive names in Windows' paths. + * + * As per \l + * {https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats#traditional-dos-paths} + * and \l + * {https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getlogicaldrives}, + * they are composed of a single letter. + * Each generated string always follows the lettet with a + * colon, as it is specifically intended for path usages, + * where this is required. + * + * We use only uppercase letters for the drives names albeit, + * depending on case sensitivity, lowercase letter could be + * used. + */ + inline Catch::Generators::GeneratorWrapper<QString> windows_logical_drives() { + // REMARK: If a Windows path is generated on Windows + // itself, we expect that it may be used to interact with + // the filesystem, similar to how we expect a POSIX path + // to be used on Linux. + // For this reason, we only generate a specific drive, the one + // that contains the current working directory, so that we + // know it is an actually available drive and to contain the + // possible modifications to the filesystem to an easily + // foundable place. + +#if defined(Q_OS_WINDOWS) + + auto root_device{QStorageInfo{QDir()}.rootPath().first(1) + ":"}; + + return cycle(Catch::Generators::value(std::move(root_device))); + +#else + + return Catch::Generators::map( + [](QString letter){ return letter + ':';}, + string(QDOC_CATCH_GENERATORS_QCHAR_ALPHABETS_NAMESPACE::ascii_uppercase(), 1, 1) + ); + +#endif + } + + /*! + * Returns a generator that generate strings that can be used + * as separators in Windows based paths. + * + * As per \l + * {https://docs.microsoft.com/en-us/dotnet/api/system.io.path.directoryseparatorchar?view=net-6.0} + * and \l + * {https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats#canonicalize-separators}, + * this is a sequence of one or more backward or forward slashes. + */ + inline Catch::Generators::GeneratorWrapper<QString> windows_separator() { + return uniform_oneof( + QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::move_into_vector( + string(character('\\', '\\'), minimum_component_length, maximum_component_length), + string(character('/', '/'), minimum_component_length, maximum_component_length) + ) + ); + } + + } // end QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE + + /*! + * Returns a generator that generates strings representing + * POSIX compatible paths. + * + * The generated paths follows the format specified in \l + * {https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_271}. + * + * The optional length-requirements, such as PATH_MAX and + * NAME_MAX, are relaxed away as they are generally not + * respected by modern systems. + * + * It is possible to set the probability of obtaining a + * relative or absolute path through \a + * absolute_path_probability and the one of obtaining a path + * potentially pointing ot a directory or on a file through \a + * directory_path_probability. + */ + inline Catch::Generators::GeneratorWrapper<QString> relaxed_portable_posix_path(double absolute_path_probability = 0.5, double directory_path_probability = 0.5) { + return path( + // POSIX path are never multi-device, so that we have + // provide an empty device component generator and set + // the probability for Multi-Device paths to zero. + string(character(), 0, 0), + QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::posix_root(), + QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::portable_posix_directory_name(), + QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::portable_posix_filename(), + QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::posix_separator(), + PathGeneratorConfiguration{} + .set_multi_device_path_probability(0.0) + .set_absolute_path_probability(absolute_path_probability) + .set_directory_path_probability(directory_path_probability) + ); + } + + /*! + * Returns a generator that produces strings that represents + * traditional DOS paths as defined in \l + * {https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats#traditional-dos-paths}. + * + * The directory and filename components of a path generated + * in this way are, currently, restricted to use a portable + * character set as defined by POSIX. + * + * Do note that most paths themselves, will not be portable, on + * the whole, albeit they may be valid paths on other systems, as + * Windows uses a path system that is generally incompatible with + * other systems. + * + * Some possibly valid special path, such as a "C:" or "\" + * will never be generated. + */ + inline Catch::Generators::GeneratorWrapper<QString> traditional_dos_path( + double absolute_path_probability = 0.5, + double directory_path_probability = 0.5, + double multi_device_path_probability = 0.5 + ) { + return path( + QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::windows_logical_drives(), + QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::windows_separator(), + // REMAKR: Windows treats trailing dots as if they were a + // component of their own, that is, as the special + // relative paths. + // This seems to not be correctly handled by Qt's + // filesystem methods, resulting in inconsistencies when + // one such path is encountered. + // To avoid the issue, considering that an equivalent path + // can be formed by actually having the dots on their own + // as a component, we filter out all those paths that have + // trailing dots but are not only composed of dots. + Catch::Generators::filter( + [](auto& path){ return !(path.endsWith(".") && path.contains(QRegularExpression("[^.]"))) ; }, + QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::portable_posix_directory_name() + ), + QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::portable_posix_filename(), + QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::windows_separator(), + PathGeneratorConfiguration{} + .set_multi_device_path_probability(multi_device_path_probability) + .set_absolute_path_probability(absolute_path_probability) + .set_directory_path_probability(directory_path_probability) + ); + } + + // TODO: Find a good way to test the following functions. + // native_path can probably be tied to the tests for the + // OS-specific functions, with TEMPLATE_TEST_CASE. + // The other ones may follow a similar pattern but require a bit + // more work so that they tie to a specific case instead of the + // general one. + // Nonetheless, this approach is both error prone and difficult to + // parse, because of the required if preprocessor directives, + // and should be avoided if possible. + + /*! + * Returns a generator that generates QStrings that represents + * paths native to the underlying OS. + * + * On Windows, paths that refer to a drive always refer to the + * root drive. + * + * native* functions should always be chosen when using paths for + * testing interfacing with the filesystem itself. + * + * System outside Linux, macOS or Windows are not supported. + */ + inline Catch::Generators::GeneratorWrapper<QString> native_path(double absolute_path_probability = 0.5, double directory_path_probability = 0.5) { +#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) + + return relaxed_portable_posix_path(absolute_path_probability, directory_path_probability); + +#elif defined(Q_OS_WINDOWS) + + // REMARK: When generating native paths for testing we + // generally want to avoid relative paths that are + // drive-specific, as we want them to be tied to a specific + // working directory that may not be the current directory on + // the drive. + // Hence, we avoid generating paths that may have a drive component. + // For tests where those kind of paths are interesting, a + // specific Windows-only test should be made, using + // traditional_dos_path to generate drive-relative paths only. + return traditional_dos_path(absolute_path_probability, directory_path_probability, 0.0); + +#endif + } + + /*! + * Returns a generator that generates QStrings that represents + * paths native to the underlying OS and that are always \e + * {Relative}. + * + * Avoids generating paths that refer to a directory that is not + * included in the path itself. + * + * System outside Linux, macOS or Windows are not supported. + */ + inline Catch::Generators::GeneratorWrapper<QString> native_relative_path(double directory_path_probability = 0.5) { + // REMARK: When testing, we generally use some specific + // directory as a root for relative paths. + // We want the generated path to be relative to that + // directory because we need a clean state for the test to + // be reliable. + // When generating paths, it is possible, correctly, to + // have a path that refers to that directory or some + // parent of it, removing us from the clean state that we + // need. + // To avoid that, we filter out paths that end up referring to a directory that is not under our "root" directory. + // + // We can think of each generated component moving us + // further down or up, in case of "..", a directory + // hierarchy, or keeping us at the same place in case of + // ".". + // Any path that ends up under our original "root" + // directory will safely keep our clean state for testing. + // + // Each "." keeps us at the same level in the hierarchy. + // Each ".." moves us up one level in the hierarchy. + // Each component that is not "." or ".." moves us down + // one level into the hierarchy. + // + // Then, to avoid referring to the "root" directory or one + // of its parents, we need to balance out each "." and + // ".." with the components that precedes or follow their + // appearance. + // + // Since "." keeps us at the same level, it can appear how + // many times it wants as long as the path referes to the + // "root" directory or a directory or file under it and at + // least one other component referes to a directory or + // file that is under the "root" directory. + // + // Since ".." moves us one level up in the hierarchy, a + // sequence of n ".." components is safe when at least n + + // 1 non "." or ".." components appear before it. + // + // To avoid the above problem, we filter away paths that + // do not respect those rules. + return Catch::Generators::filter( + [](auto& path){ + QStringList components{path.split(QRegularExpression{R"((\\|\/)+)"}, Qt::SkipEmptyParts)}; + int depth{0}; + + for (auto& component : components) { + if (component == "..") + --depth; + else if (component != ".") + ++depth; + + if (depth < 0) return false; + } + + return (depth > 0); + }, + native_path(0.0, directory_path_probability) + ); + } + + /*! + * Returns a generator that generates QStrings that represents + * paths native to the underlying OS and that are always \e + * {Relative} and \e {To a File}. + * + * System outside Linux, macOS or Windows are not supported. + */ + inline Catch::Generators::GeneratorWrapper<QString> native_relative_file_path() { + return native_relative_path(0.0); + } + + /*! + * Returns a generator that generates QStrings that represents + * paths native to the underlying OS and that are always \e + * {Relative} and \e {To a Directory}. + * + * System outside Linux, macOS or Windows are not supported. + */ + inline Catch::Generators::GeneratorWrapper<QString> native_relative_directory_path() { + return native_relative_path(1.0); + } + +} // end QDOC_CATCH_GENERATORS_ROOT_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/qchar_generator.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/qchar_generator.h new file mode 100644 index 0000000000000000000000000000000000000000..6dd4097bd1e772a1db5d3bf4d23d2766b3b04329 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/qchar_generator.h @@ -0,0 +1,110 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../namespaces.h" +#include "../utilities/semantics/move_into_vector.h" +#include "combinators/oneof_generator.h" + +#include <catch/catch.hpp> + +#include <random> + +#include <QChar> + +namespace QDOC_CATCH_GENERATORS_ROOT_NAMESPACE { + namespace QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE { + + class QCharGenerator : public Catch::Generators::IGenerator<QChar> { + public: + QCharGenerator( + char16_t lower_bound = std::numeric_limits<char16_t>::min(), + char16_t upper_bound = std::numeric_limits<char16_t>::max() + ) : random_engine{std::random_device{}()}, + distribution{static_cast<unsigned int>(lower_bound), static_cast<unsigned int>(upper_bound)} + { + assert(lower_bound <= upper_bound); + static_cast<void>(next()); + } + + QChar const& get() const override { return current_character; } + + bool next() override { + current_character = QChar(static_cast<char16_t>(distribution(random_engine))); + + return true; + } + + private: + QChar current_character; + + std::mt19937 random_engine; + std::uniform_int_distribution<unsigned int> distribution; + }; + + } // end QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE + + + /*! + * Returns a generator of that generates elements of QChar whose + * ucs value is in the range [\a lower_bound, \a upper_bound]. + * + * When \a lower_bound = \a upper_bound, the generator infinitely + * generates the same character. + */ + inline Catch::Generators::GeneratorWrapper<QChar> character(char16_t lower_bound = std::numeric_limits<char16_t>::min(), char16_t upper_bound = std::numeric_limits<char16_t>::max()) { + return Catch::Generators::GeneratorWrapper<QChar>(std::unique_ptr<Catch::Generators::IGenerator<QChar>>(new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::QCharGenerator(lower_bound, upper_bound))); + } + + + namespace QDOC_CATCH_GENERATORS_QCHAR_ALPHABETS_NAMESPACE { + + namespace QDOC_CATCH_GENERATORS_TRAITS_NAMESPACE { + + enum class Alphabets : std::size_t {digit, ascii_lowercase, ascii_uppercase, ascii_alpha, ascii_alphanumeric, portable_posix_filename}; + + template<Alphabets alphabet> + struct sizeof_alphabet; + + template<Alphabets alphabet> + inline constexpr std::size_t sizeof_alphabet_v = sizeof_alphabet<alphabet>::value; + + template <> struct sizeof_alphabet<Alphabets::digit> { static constexpr std::size_t value{'9' - '0'}; }; + template <> struct sizeof_alphabet<Alphabets::ascii_lowercase> { static constexpr std::size_t value{'z' - 'a'}; }; + template<> struct sizeof_alphabet<Alphabets::ascii_uppercase> { static constexpr std::size_t value{'Z' - 'A'}; }; + template<> struct sizeof_alphabet<Alphabets::ascii_alpha> { static constexpr std::size_t value{sizeof_alphabet_v<Alphabets::ascii_lowercase> + sizeof_alphabet_v<Alphabets::ascii_uppercase>}; }; + template<> struct sizeof_alphabet<Alphabets::ascii_alphanumeric>{ static constexpr std::size_t value{sizeof_alphabet_v<Alphabets::ascii_alpha> + sizeof_alphabet_v<Alphabets::digit>}; }; + + } // end QDOC_CATCH_GENERATORS_TRAITS_NAMESPACE + + + inline Catch::Generators::GeneratorWrapper<QChar> digit() { + return Catch::Generators::GeneratorWrapper<QChar>(std::unique_ptr<Catch::Generators::IGenerator<QChar>>(new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::QCharGenerator('0', '9'))); + } + + inline Catch::Generators::GeneratorWrapper<QChar> ascii_lowercase() { + return Catch::Generators::GeneratorWrapper<QChar>(std::unique_ptr<Catch::Generators::IGenerator<QChar>>(new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::QCharGenerator('a', 'z'))); + } + + inline Catch::Generators::GeneratorWrapper<QChar> ascii_uppercase() { + return Catch::Generators::GeneratorWrapper<QChar>(std::unique_ptr<Catch::Generators::IGenerator<QChar>>(new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::QCharGenerator('A', 'Z'))); + } + + inline Catch::Generators::GeneratorWrapper<QChar> ascii_alpha() { + return uniform_oneof(QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::move_into_vector(ascii_lowercase(), ascii_uppercase())); + } + + inline Catch::Generators::GeneratorWrapper<QChar> ascii_alphanumeric() { + return uniformly_valued_oneof(QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::move_into_vector(ascii_alpha(), digit()), std::vector{traits::sizeof_alphabet_v<traits::Alphabets::ascii_alpha> , traits::sizeof_alphabet_v<traits::Alphabets::digit>}); + } + + inline Catch::Generators::GeneratorWrapper<QChar> portable_posix_filename() { + return uniformly_valued_oneof(QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::move_into_vector(ascii_alphanumeric(), character('.', '.'), character('-', '-'), character('_', '_')), + std::vector{traits::sizeof_alphabet_v<traits::Alphabets::ascii_alphanumeric>, std::size_t{1}, std::size_t{1}, std::size_t{1}}); + } + + } // end QDOC_CATCH_GENERATORS_QCHAR_ALPHABETS_NAMESPACE + + +} // end QDOC_CATCH_GENERATORS_ROOT_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/qstring_generator.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/qstring_generator.h new file mode 100644 index 0000000000000000000000000000000000000000..3685d0de3c4d636118540f9822e7352aa392721d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/generators/qstring_generator.h @@ -0,0 +1,92 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../namespaces.h" +#include "qchar_generator.h" +#include "../utilities/semantics/generator_handler.h" + +#include <catch/catch.hpp> + +#include <random> + +#include <QString> + +namespace QDOC_CATCH_GENERATORS_ROOT_NAMESPACE { + namespace QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE { + + class QStringGenerator : public Catch::Generators::IGenerator<QString> { + public: + QStringGenerator(Catch::Generators::GeneratorWrapper<QChar>&& character_generator, qsizetype minimum_length, qsizetype maximum_length) + : character_generator{QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE::handler(std::move(character_generator))}, + random_engine{std::random_device{}()}, + length_distribution{minimum_length, maximum_length}, + current_string{} + { + assert(minimum_length >= 0); + assert(maximum_length >= 0); + assert(minimum_length <= maximum_length); + + if (!next()) + Catch::throw_exception("Not enough values to initialize the first string"); + } + + QString const& get() const override { return current_string; } + + bool next() override { + qsizetype length{length_distribution(random_engine)}; + + current_string = QString(); + for (qsizetype length_index{0}; length_index < length; ++length_index) { + if (!character_generator.next()) return false; + + current_string += character_generator.get(); + } + + return true; + } + + private: + Catch::Generators::GeneratorWrapper<QChar> character_generator; + + std::mt19937 random_engine; + std::uniform_int_distribution<qsizetype> length_distribution; + + QString current_string; + }; + + } // end QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE + + /*! + * Returns a generator that generates elements of QString from + * some amount of elements taken from \a character_generator. + * + * The generated strings will have a length in the range + * [\a minimum_length, \a maximum_length]. + * + * For compatibility with the Qt API, it is possible to provide + * negative bounds for the length. This is, nonetheless, + * considered an error such that the bounds should always be + * greater or equal to zero. + * + * It is similarly considered an error to have minimum_length <= + * maximum_length. + * + * The provided generator will generate elements until \a + * character_generator is exhausted. + */ + inline Catch::Generators::GeneratorWrapper<QString> string(Catch::Generators::GeneratorWrapper<QChar>&& character_generator, qsizetype minimum_length, qsizetype maximum_length) { + return Catch::Generators::GeneratorWrapper<QString>(std::unique_ptr<Catch::Generators::IGenerator<QString>>(new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::QStringGenerator(std::move(character_generator), minimum_length, maximum_length))); + } + + /*! + * Returns an infinite generator whose elements are the empty + * QString. + */ + inline Catch::Generators::GeneratorWrapper<QString> empty_string() { + return Catch::Generators::GeneratorWrapper<QString>(std::unique_ptr<Catch::Generators::IGenerator<QString>>(new QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::QStringGenerator(character(), 0, 0))); + } + + +} // end QDOC_CATCH_GENERATORS_ROOT_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/namespaces.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/namespaces.h new file mode 100644 index 0000000000000000000000000000000000000000..e276868a788230cec72096965292b6b8243c7043 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/namespaces.h @@ -0,0 +1,14 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#define QDOC_CATCH_GENERATORS_ROOT_NAMESPACE qdoc::catch_generators + +#define QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE details + +#define QDOC_CATCH_GENERATORS_TRAITS_NAMESPACE traits + +#define QDOC_CATCH_GENERATORS_QCHAR_ALPHABETS_NAMESPACE alphabets + +#define QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE QDOC_CATCH_GENERATORS_ROOT_NAMESPACE::QDOC_CATCH_GENERATORS_PRIVATE_NAMESPACE::utils diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/semantics/copy_value.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/semantics/copy_value.h new file mode 100644 index 0000000000000000000000000000000000000000..d747175c8da84ef99a3bb41b75d6fba312d4c95a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/semantics/copy_value.h @@ -0,0 +1,26 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../../namespaces.h" + +#include <type_traits> + +namespace QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE { + + /*! + * Forces \value to be copied in an expression context. + * + * This is used in contexts where inferences of a type that + * requires generality might identify a reference when ownership + * is required. + * + * Note that the compiler might optmize the copy away. This is a + * non-issue as we are only interested in breaking lifetime + * dependencies. + */ + template<typename T> + std::remove_reference_t<T> copy_value(T value) { return value; } + +} // end QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/semantics/generator_handler.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/semantics/generator_handler.h new file mode 100644 index 0000000000000000000000000000000000000000..2a9de5c8020970765f57ebecb5a350a20f759f75 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/semantics/generator_handler.h @@ -0,0 +1,97 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../../namespaces.h" + +#include <catch/catch.hpp> + +#include <optional> +#include <cassert> + +namespace QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE { + + template<typename T> + class GeneratorHandler : public Catch::Generators::IGenerator<T> { + public: + + GeneratorHandler(Catch::Generators::GeneratorWrapper<T>&& generator) + : generator{std::move(generator)}, + first_call{true} + {} + + T const& get() const override { + assert(!first_call); + return generator.get(); + } + + bool next() override { + if (first_call) { + first_call = false; + return true; + } + + return generator.next(); + } + + private: + Catch::Generators::GeneratorWrapper<T> generator; + bool first_call; + }; + + + /*! + * Returns a generator wrapping \a generator that ensures that + * changes its semantics so that the first call to get should be + * preceded by a call to next. + * + * Catch generators require that is valid to call get and obtain a + * valid value on a generator that was just created. + * That is, generators should be non-empty and their first value + * should be initialized on construction. + * + * Normally, this is not a problem, and the next implementation of + * the generator can be simply called in the constructor. + * But when a generator depends on other generators, doing so will + * generally skip the first value that the generator + * produces, as the wrapping generator will need to advance the + * underlying generator, losing the value in the process. + * This is in particular, a problem, on generators that are finite + * or infinite and ordered. + * + * To solve the issue, the original value can be saved before + * advancing the generator or some code can be duplicated or + * abstracted so that what a new element can be generated without + * advancing the underlying generator. + * + * While this is acceptable, it can be error prone on more complex + * generators, generators that randomly access a collection of + * generators and so on. + * + * To simplify this process, this generator changes the semantics + * of the wrapped generator such that the first value of the + * generator is produced after the first call to next and the + * generator is considered in an invalid state before the first + * advancement. + * + * In this way, by wrapping all generators that a generator + * depends on, the implementation required for the first value is + * the same as the one required for all following values, with + * regards to the sequencing of next and get operations, + * simplifying the implementation of dependent generators. + * + * Do note that, while the generator returned by this function + * implments the generator interface that Catch2 requires, it + * cannot be normally used as a generator as it fails to comply + * with the first value semantics that a generator requires. + * Indeed, it should only be used as an intermediate wrapper for + * the implementation of generators that depends on other + * generators. + */ + template<typename T> + inline Catch::Generators::GeneratorWrapper<T> handler(Catch::Generators::GeneratorWrapper<T>&& generator) { + return Catch::Generators::GeneratorWrapper<T>(std::unique_ptr<Catch::Generators::IGenerator<T>>(new GeneratorHandler(std::move(generator)))); + } + +} // end QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/semantics/move_into_vector.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/semantics/move_into_vector.h new file mode 100644 index 0000000000000000000000000000000000000000..dbc85f92087d964add0a1a8cfa760b3b747ebe8a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/semantics/move_into_vector.h @@ -0,0 +1,62 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../../namespaces.h" + +#include <vector> +#include <tuple> + +namespace QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE { + + namespace QDOC_CATCH_GENERATORS_TRAITS_NAMESPACE { + + /*! + * Returns the type of the first element of Args. + * + * Args is expected to have at least one + */ + template<typename... Args> + using first_from_pack_t = std::tuple_element_t<0, std::tuple<Args...>>; + + } // end QDOC_CATCH_GENERATORS_TRAITS_NAMESPACE + + + /*! + * Builds an std::vector by moving \a movables into it. + * + * \a movables must be made of homogenous types. + * + * This function is intended to allow the construction of an + * std::vector<T>, where T is a move only type, as an expression, + * to lighten the idiom. + * + * For example, Catch's GeneratorWrapper<T> adapts a + * std::unique_ptr, which is move only, making it impossible to + * build a std::vector from them in place. + * + * Then, everywhere this is needed, a more complex approach of + * generating the collection of objects, generating a vector of a + * suitable size and iterating the objects to move-emplace them in + * the vector is required. + * + * This not only complicates the code but is incompatible with a + * GENERATE expression, making it extremely hard, noisy and error + * prone to use them together. + * + * In those cases, then, a call to move_into_vector can be used as + * an expression to circumvent the problem. + */ + template<typename... MoveOnlyTypes> + inline auto move_into_vector(MoveOnlyTypes... movables) { + std::vector<QDOC_CATCH_GENERATORS_TRAITS_NAMESPACE::first_from_pack_t<MoveOnlyTypes...>> + moved_into_vector; + moved_into_vector.reserve(sizeof...(movables)); + + (moved_into_vector.emplace_back(std::move(movables)), ...); + + return moved_into_vector; + } + +} // end QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/statistics/distribution.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/statistics/distribution.h new file mode 100644 index 0000000000000000000000000000000000000000..d56d9589ff20f1122c69fcb78af7d9b1313f7450 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/statistics/distribution.h @@ -0,0 +1,158 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../../namespaces.h" + +#include <functional> +#include <optional> +#include <ostream> +#include <unordered_map> + +namespace QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE { + + template<typename T> + using Histogram = std::unordered_map<T, std::size_t>; + + template<typename InputIt, typename GroupBy> + auto make_histogram(InputIt begin, InputIt end, GroupBy&& group_by) { + Histogram<std::invoke_result_t<GroupBy, decltype(*begin)>> histogram{}; + + while (begin != end) { + auto key{std::invoke(std::forward<GroupBy>(group_by), *begin)}; + + histogram.try_emplace(key, 0); + histogram[key] += 1; + ++begin; + } + + return histogram; + } + + template<typename T> + struct DistributionError { + T value; + double probability; + double expected_probability; + }; + + template<typename T> + inline std::ostream& operator<<(std::ostream& os, const DistributionError<T>& error) { + return os << "DistributionError{" << + "The value { " << error.value << + " } appear with a probability of { " << error.probability << + " } while a probability of { " << error.expected_probability << " } was expected." << + "}"; + } + + // REMARK: The following should really return an Either of unit/error + // but std::variant in C++ is both extremely unusable and comes with a + // strong overhead unless certain conditions are met. + // For this reason, we keep to the less intutitive optional error. + + /*! + * Returns true when the given \a sequence approximately respects a + * given distribution. + * + * The \a sequence respects a given distribution when the count of + * each collection of values is a percentage of the total values that + * is near the percentage probability described by distribution. + * + * The values in \a sequence are collected according to \a group_by. + * \a group_by, given an element of \a sequence, should return a value + * of some type that represent the category of the inspected value. + * Values that have the same category share their count. + * + * The distribution that should be respected is given by \a + * probability_of. \a probability_of is a function that takes a + * category that was produced from a call to \a group_by and returns + * the expect probability, in percentage, of apperance for that + * category. + * + * The given probability is then compared to the one found by counting + * the element of \a sequence under \a group_by, to ensure that it + * matches. + * + * The margin of error for the comparison is given, in percentage + * points, by \a margin. + * The approximation uses an absolute comparison and scales the + * margin inversely based on the size of \a sequence, to account for the + * precision of the data set itself. + * + * When the distribution is not respected, a DistributionError is + * returned enclosed in an optional value. + * The error allows reports which the first category for which the + * comparison failed, along with its expected probability and the one + * that was actually inferred from \a sequence. + */ + template<typename T, typename GroupBy, typename ProbabilityOf> + std::optional<DistributionError<T>> respects_distribution(std::vector<T>&& sequence, GroupBy&& group_by, ProbabilityOf&& probability_of, double margin = 33) { + std::size_t data_point_amount{sequence.size()}; + + // REMARK: We scale the margin based on the data set to allow for + // an easier change in downstream tests. + // The precision required for the approximation will vary + // depending on how many values we generate. + // The amount of values we generate depends on how much time we + // want the tests to take. + // This amount may change in the future. For example, as code is + // added and tests are added, we might need some expensive + // computations here and there. + // Sometimes, this will increase the test suite runtime without an + // obvious way of improving the performance of the underlying code + // to reduce it. + // In those cases, the total run time can be decreased by running + // less generations for battle-tested tests. + // If some code has not been changed for a long time, it will have + // had thousands of generations by that point, giving us a good + // degree of certainty of it not being bugged (for whatever bugs + // the tests account for). + // Then, running a certain amount of generation is not required + // anymore such that some of them can be optimized out. + // For tests like the one using this function, where our ability + // to test is always dependent on the amount of generations, + // changing the generated amount will mean that we will need to + // change our conditions too, potentially changing the meaning of + // the test. + // To take this into account, we perform a scaling on the + // condition itself, so that if the amount of data points that are + // generated changes, we do not generally have to change anything + // in the condition. + // + // For this case, we scale logarithmically_10 for the simple + // reason that we tend to generate values in power of tens, + // starting with the 100 values default that Quickcheck used. + // + // The default value for the margin on which the scaling is based, + // was chosen heuristically. + // As we expect generation under 10^3 to be generally meaningless + // for this kind of testing, the value was chosen so that it would + // start to normalize around that amount. + // Deviation of about 5-10% were identified trough various + // generations for an amount of data points near 1000, while a + // deviation of about 1-3% was identified with about 10000 values. + // With the chosen default value, the scaling approaches those + // percentage points with some margin of error. + // + // We expect up to a 10%, or a bit more, deviation to be suitable + // for our purposes, as it would still allow for a varied + // distribution in downstream consumers. + double scaled_margin{margin * (1.0/std::log10(data_point_amount))}; + + auto histogram{make_histogram(sequence.begin(), sequence.end(), std::forward<GroupBy>(group_by))}; + + for (auto& bin : histogram) { + auto [key, count] = bin; + + double actual_percentage{percent_of(static_cast<double>(count), static_cast<double>(data_point_amount))}; + double expected_percentage{std::invoke(std::forward<ProbabilityOf>(probability_of), key)}; + + if (!(actual_percentage == Approx(expected_percentage).margin(scaled_margin))) + return std::make_optional(DistributionError<T>{key, actual_percentage, expected_percentage}); + } + + return std::nullopt; + } + +} // end QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/statistics/percentages.h b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/statistics/percentages.h new file mode 100644 index 0000000000000000000000000000000000000000..54a321d6fc5a65196a9e828abc4ca0d2066976c1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQDocCatchGenerators/catch_generators/utilities/statistics/percentages.h @@ -0,0 +1,49 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include "../../namespaces.h" + +#include <cassert> + +namespace QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE { + + /*! + * Returns the percentage of \amount over \a total. + * + * \a amount needs to be greater or equal to zero and \a total + * needs to be greater than zero. + */ + inline double percent_of(double amount, double total) { + assert(amount >= 0.0); + assert(total > 0.0); + + return (amount / total) * 100.0; + } + + /*! + * Given the cardinality of a set, returns the percentage + * probability that applied to every element of the set generates + * a uniform distribution. + */ + inline double uniform_probability(std::size_t cardinality) { + assert(cardinality > 0); + + return (100.0 / static_cast<double>(cardinality)); + } + + /*! + * Returns a percentage probability that is equal to \a + * probability. + * + * \a probability must be in the range [0.0, 1.0] + */ + inline double probability_to_percentage(double probability) { + assert(probability >= 0.0); + assert(probability <= 1.0); + + return probability * 100.0; + } + +} // end QDOC_CATCH_GENERATORS_UTILITIES_ABSOLUTE_NAMESPACE diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/inlinecomponentutils_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/inlinecomponentutils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..76e3c17f842dce3cb15d6d39ed7b005b35618fad --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/inlinecomponentutils_p.h @@ -0,0 +1,161 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef INLINECOMPONENTUTILS_P_H +#define INLINECOMPONENTUTILS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlmetatype_p.h> +#include <private/qv4compileddata_p.h> +#include <private/qv4resolvedtypereference_p.h> + +QT_BEGIN_NAMESPACE + +namespace icutils { +struct Node { +private: + using IndexType = std::vector<QV4::CompiledData::InlineComponent>::size_type; + using IndexField = quint32_le_bitfield_member<0, 30, IndexType>; + using TemporaryMarkField = quint32_le_bitfield_member<30, 1>; + using PermanentMarkField = quint32_le_bitfield_member<31, 1>; + quint32_le_bitfield_union<IndexField, TemporaryMarkField, PermanentMarkField> m_data; + +public: + Node() = default; + Node(const Node &) = default; + Node(Node &&) = default; + Node& operator=(Node const &) = default; + Node& operator=(Node &&) = default; + bool operator==(Node const &other) const {return m_data.data() == other.m_data.data(); } + + Node(IndexType s) : m_data(QSpecialIntegerBitfieldZero) { m_data.set<IndexField>(s); } + + bool hasPermanentMark() const { return m_data.get<PermanentMarkField>(); } + bool hasTemporaryMark() const { return m_data.get<TemporaryMarkField>(); } + + void setPermanentMark() + { + m_data.set<TemporaryMarkField>(0); + m_data.set<PermanentMarkField>(1); + } + + void setTemporaryMark() + { + m_data.set<TemporaryMarkField>(1); + } + + IndexType index() const { return m_data.get<IndexField>(); } +}; + +using NodeList = std::vector<Node>; +using AdjacencyList = std::vector<std::vector<Node*>>; + +inline bool containedInSameType(const QQmlType &a, const QQmlType &b) +{ + return QQmlMetaType::equalBaseUrls(a.sourceUrl(), b.sourceUrl()); +} + +template<typename ObjectContainer, typename InlineComponent> +void fillAdjacencyListForInlineComponents(ObjectContainer *objectContainer, + AdjacencyList &adjacencyList, NodeList &nodes, + const std::vector<InlineComponent> &allICs) +{ + using CompiledObject = typename ObjectContainer::CompiledObject; + // add an edge from A to B if A and B are inline components with the same containing type + // and A inherits from B (ignore indirect chains through external types for now) + // or if A instantiates B + for (typename std::vector<InlineComponent>::size_type i = 0; i < allICs.size(); ++i) { + const auto& ic = allICs[i]; + const CompiledObject *obj = objectContainer->objectAt(ic.objectIndex); + QV4::ResolvedTypeReference *currentICTypeRef = objectContainer->resolvedType(ic.nameIndex); + auto createEdgeFromTypeRef = [&](QV4::ResolvedTypeReference *targetTypeRef) { + if (targetTypeRef) { + const auto targetType = targetTypeRef->type(); + if (targetType.isInlineComponentType() + && containedInSameType(targetType, currentICTypeRef->type())) { + auto icIt = std::find_if(allICs.cbegin(), allICs.cend(), [&](const QV4::CompiledData::InlineComponent &icSearched){ + return objectContainer->stringAt(icSearched.nameIndex) + == targetType.elementName(); + }); + Q_ASSERT(icIt != allICs.cend()); + Node& target = nodes[i]; + adjacencyList[std::distance(allICs.cbegin(), icIt)].push_back(&target); + } + } + }; + if (obj->inheritedTypeNameIndex != 0) { + QV4::ResolvedTypeReference *parentTypeRef = objectContainer->resolvedType(obj->inheritedTypeNameIndex); + createEdgeFromTypeRef(parentTypeRef); + + } + auto referencedInICObjectIndex = ic.objectIndex + 1; + while (int(referencedInICObjectIndex) < objectContainer->objectCount()) { + auto potentiallyReferencedInICObject = objectContainer->objectAt(referencedInICObjectIndex); + bool stillInIC + = !potentiallyReferencedInICObject->hasFlag( + QV4::CompiledData::Object::IsInlineComponentRoot) + && potentiallyReferencedInICObject->hasFlag( + QV4::CompiledData::Object::IsPartOfInlineComponent); + if (!stillInIC) + break; + createEdgeFromTypeRef(objectContainer->resolvedType(potentiallyReferencedInICObject->inheritedTypeNameIndex)); + ++referencedInICObjectIndex; + } + } +}; + +inline void topoVisit(Node *node, AdjacencyList &adjacencyList, bool &hasCycle, + NodeList &nodesSorted) +{ + if (node->hasPermanentMark()) + return; + if (node->hasTemporaryMark()) { + hasCycle = true; + return; + } + node->setTemporaryMark(); + + auto const &edges = adjacencyList[node->index()]; + for (auto edgeTarget =edges.begin(); edgeTarget != edges.end(); ++edgeTarget) { + topoVisit(*edgeTarget, adjacencyList, hasCycle, nodesSorted); + } + + node->setPermanentMark(); + nodesSorted.push_back(*node); +}; + +// Use DFS based topological sorting (https://en.wikipedia.org/wiki/Topological_sorting) +inline NodeList topoSort(NodeList &nodes, AdjacencyList &adjacencyList, bool &hasCycle) +{ + NodeList nodesSorted; + nodesSorted.reserve(nodes.size()); + + hasCycle = false; + auto currentNodeIt = std::find_if(nodes.begin(), nodes.end(), [](const Node& node) { + return !node.hasPermanentMark(); + }); + // Do a topological sort of all inline components + // afterwards, nodesSorted contains the nodes for the inline components in reverse topological order + while (currentNodeIt != nodes.end() && !hasCycle) { + Node& currentNode = *currentNodeIt; + topoVisit(¤tNode, adjacencyList, hasCycle, nodesSorted); + currentNodeIt = std::find_if(nodes.begin(), nodes.end(), [](const Node& node) { + return !node.hasPermanentMark(); + }); + } + return nodesSorted; +} +} + +QT_END_NAMESPACE + +#endif // INLINECOMPONENTUTILS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qabstractanimationjob_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qabstractanimationjob_p.h new file mode 100644 index 0000000000000000000000000000000000000000..641b15688dce3c6100c323a9648191c3f227b2ab --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qabstractanimationjob_p.h @@ -0,0 +1,230 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QABSTRACTANIMATIONJOB_P_H +#define QABSTRACTANIMATIONJOB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> +#include <private/qanimationjobutil_p.h> +#include <private/qdoubleendedlist_p.h> +#include <QtCore/QObject> +#include <QtCore/private/qabstractanimation_p.h> +#include <vector> + +QT_REQUIRE_CONFIG(qml_animation); + +QT_BEGIN_NAMESPACE + +class QAnimationGroupJob; +class QAnimationJobChangeListener; +class QQmlAnimationTimer; + +class Q_QML_EXPORT QAbstractAnimationJob : public QInheritedListNode +{ + Q_DISABLE_COPY(QAbstractAnimationJob) +public: + enum Direction { + Forward, + Backward + }; + + enum State { + Stopped, + Paused, + Running + }; + + QAbstractAnimationJob(); + virtual ~QAbstractAnimationJob(); + + //definition + inline QAnimationGroupJob *group() const {return m_group;} + + inline int loopCount() const {return m_loopCount;} + void setLoopCount(int loopCount); + + int totalDuration() const; + virtual int duration() const {return 0;} + + inline QAbstractAnimationJob::Direction direction() const {return m_direction;} + void setDirection(QAbstractAnimationJob::Direction direction); + + //state + inline int currentTime() const {return m_totalCurrentTime;} + inline int currentLoopTime() const {return m_currentTime;} + inline int currentLoop() const {return m_currentLoop;} + inline QAbstractAnimationJob::State state() const {return m_state;} + inline bool isRunning() { return m_state == Running; } + inline bool isStopped() { return m_state == Stopped; } + inline bool isPaused() { return m_state == Paused; } + void setDisableUserControl(); + void setEnableUserControl(); + bool userControlDisabled() const; + + void setCurrentTime(int msecs); + + void start(); + void pause(); + void resume(); + void stop(); + void complete(); + + enum ChangeType { + Completion = 0x01, + StateChange = 0x02, + CurrentLoop = 0x04, + CurrentTime = 0x08 + }; + Q_DECLARE_FLAGS(ChangeTypes, ChangeType) + + void addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes); + void removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes); + + bool isGroup() const { return m_isGroup; } + bool isRenderThreadJob() const { return m_isRenderThreadJob; } + bool isRenderThreadProxy() const { return m_isRenderThreadProxy; } + + SelfDeletable m_selfDeletable; +protected: + virtual void updateCurrentTime(int) {} + virtual void updateLoopCount(int) {} + virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); + virtual void updateDirection(QAbstractAnimationJob::Direction direction); + virtual void topLevelAnimationLoopChanged() {} + + virtual void debugAnimation(QDebug d) const; + + void fireTopLevelAnimationLoopChanged(); + + void setState(QAbstractAnimationJob::State state); + + void finished(); + void stateChanged(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); + void currentLoopChanged(); + void directionChanged(QAbstractAnimationJob::Direction); + void currentTimeChanged(int currentTime); + + //definition + int m_loopCount; + QAnimationGroupJob *m_group; + QAbstractAnimationJob::Direction m_direction; + + //state + QAbstractAnimationJob::State m_state; + int m_totalCurrentTime; + int m_currentTime; + int m_currentLoop; + //records the finish time for an uncontrolled animation (used by animation groups) + int m_uncontrolledFinishTime; + int m_currentLoopStartTime; // used together with m_uncontrolledFinishTime + + struct ChangeListener { + ChangeListener(QAnimationJobChangeListener *l, QAbstractAnimationJob::ChangeTypes t) : listener(l), types(t) {} + QAnimationJobChangeListener *listener; + QAbstractAnimationJob::ChangeTypes types; + bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; } + }; + std::vector<ChangeListener> changeListeners; + + QQmlAnimationTimer *m_timer = nullptr; + + bool m_hasRegisteredTimer:1; + bool m_isPause:1; + bool m_isGroup:1; + bool m_disableUserControl:1; + bool m_hasCurrentTimeChangeListeners:1; + bool m_isRenderThreadJob:1; + bool m_isRenderThreadProxy:1; + + friend class QQmlAnimationTimer; + friend class QAnimationGroupJob; + friend Q_QML_EXPORT QDebug operator<<(QDebug, const QAbstractAnimationJob *job); +}; + +class Q_QML_EXPORT QAnimationJobChangeListener +{ +public: + virtual ~QAnimationJobChangeListener(); + virtual void animationFinished(QAbstractAnimationJob *) {} + virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State) {} + virtual void animationCurrentLoopChanged(QAbstractAnimationJob *) {} + virtual void animationCurrentTimeChanged(QAbstractAnimationJob *, int) {} +}; + +class Q_QML_EXPORT QQmlAnimationTimer : public QAbstractAnimationTimer +{ + Q_OBJECT +private: + QQmlAnimationTimer(); + +public: + ~QQmlAnimationTimer(); // must be destructible by QThreadStorage + + static QQmlAnimationTimer *instance(); + static QQmlAnimationTimer *instance(bool create); + + void registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel); + void unregisterAnimation(QAbstractAnimationJob *animation); + + /* + this is used for updating the currentTime of all animations in case the pause + timer is active or, otherwise, only of the animation passed as parameter. + */ + void ensureTimerUpdate(); + + /* + this will evaluate the need of restarting the pause timer in case there is still + some pause animations running. + */ + void updateAnimationTimer(); + + void restartAnimationTimer() override; + void updateAnimationsTime(qint64 timeStep) override; + + //useful for profiling/debugging + int runningAnimationCount() override { return animations.size(); } + + bool hasStartAnimationPending() const { return startAnimationPending; } + +public Q_SLOTS: + void startAnimations(); + void stopTimer(); + +private: + qint64 lastTick; + int currentAnimationIdx; + bool insideTick; + bool startAnimationPending; + bool stopTimerPending; + + QList<QAbstractAnimationJob*> animations, animationsToStart; + + // this is the count of running animations that are not a group neither a pause animation + int runningLeafAnimations; + QList<QAbstractAnimationJob*> runningPauseAnimations; + + void registerRunningAnimation(QAbstractAnimationJob *animation); + void unregisterRunningAnimation(QAbstractAnimationJob *animation); + void unsetJobTimer(QAbstractAnimationJob *animation); + + int closestPauseAnimationTimeToFinish(); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractAnimationJob::ChangeTypes) + +Q_QML_EXPORT QDebug operator<<(QDebug, const QAbstractAnimationJob *job); + +QT_END_NAMESPACE + +#endif // QABSTRACTANIMATIONJOB_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qanimationgroupjob_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qanimationgroupjob_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8e5d7314ce5a2a75bcfea409bbe4679cb768eb9d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qanimationgroupjob_p.h @@ -0,0 +1,71 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QANIMATIONGROUPJOB_P_H +#define QANIMATIONGROUPJOB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qabstractanimationjob_p.h> +#include <QtQml/private/qdoubleendedlist_p.h> +#include <QtCore/qdebug.h> + +QT_REQUIRE_CONFIG(qml_animation); + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QAnimationGroupJob : public QAbstractAnimationJob +{ + Q_DISABLE_COPY(QAnimationGroupJob) +public: + using Children = QDoubleEndedList<QAbstractAnimationJob>; + + QAnimationGroupJob(); + ~QAnimationGroupJob() override; + + void appendAnimation(QAbstractAnimationJob *animation); + void prependAnimation(QAbstractAnimationJob *animation); + void removeAnimation(QAbstractAnimationJob *animation); + + Children *children() { return &m_children; } + const Children *children() const { return &m_children; } + + virtual void clear(); + + //called by QAbstractAnimationJob + virtual void uncontrolledAnimationFinished(QAbstractAnimationJob *animation); +protected: + void topLevelAnimationLoopChanged() override; + + virtual void animationInserted(QAbstractAnimationJob*) { } + virtual void animationRemoved(QAbstractAnimationJob*, QAbstractAnimationJob*, QAbstractAnimationJob*); + + //TODO: confirm location of these (should any be moved into QAbstractAnimationJob?) + void resetUncontrolledAnimationsFinishTime(); + void resetUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim); + int uncontrolledAnimationFinishTime(const QAbstractAnimationJob *anim) const + { + return anim->m_uncontrolledFinishTime; + } + void setUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim, int time); + + void debugChildren(QDebug d) const; + + void ungroupChild(QAbstractAnimationJob *animation); + void handleAnimationRemoved(QAbstractAnimationJob *animation); + + Children m_children; +}; + +QT_END_NAMESPACE + +#endif //QANIMATIONGROUPJOB_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qanimationjobutil_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qanimationjobutil_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b67e758747bf6e010aa0531955fee0884fd6ffa8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qanimationjobutil_p.h @@ -0,0 +1,66 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QANIMATIONJOBUTIL_P_H +#define QANIMATIONJOBUTIL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qcompilerdetection.h> +#include <QtCore/qtconfigmacros.h> + +#include <type_traits> + +QT_REQUIRE_CONFIG(qml_animation); + +#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU_ONLY >= 1300 +# define ACTION_IF_DISABLE_DANGLING_POINTER_WARNING QT_WARNING_DISABLE_GCC("-Wdangling-pointer") +#else +# define ACTION_IF_DISABLE_DANGLING_POINTER_WARNING +#endif + +// SelfDeletable is used for self-destruction detection along with +// ACTION_IF_DELETED and RETURN_IF_DELETED macros. While using, the objects +// under test should have a member m_selfDeletable of type SelfDeletable +struct SelfDeletable { + ~SelfDeletable() { + if (m_wasDeleted) + *m_wasDeleted = true; + } + bool *m_wasDeleted = nullptr; +}; + +// \param p pointer to object under test, which should have a member m_selfDeletable of type SelfDeletable +// \param func statements or functions that to be executed under test. +// \param action post process if p was deleted under test. +#define ACTION_IF_DELETED(p, func, action) \ +do { \ + QT_WARNING_PUSH \ + ACTION_IF_DISABLE_DANGLING_POINTER_WARNING \ + static_assert(std::is_same<decltype((p)->m_selfDeletable), SelfDeletable>::value, "m_selfDeletable must be SelfDeletable");\ + bool *prevWasDeleted = (p)->m_selfDeletable.m_wasDeleted; \ + bool wasDeleted = false; \ + (p)->m_selfDeletable.m_wasDeleted = &wasDeleted; \ + {func;} \ + if (wasDeleted) { \ + if (prevWasDeleted) \ + *prevWasDeleted = true; \ + {action;} \ + } \ + (p)->m_selfDeletable.m_wasDeleted = prevWasDeleted; \ + QT_WARNING_POP \ +} while (false) + +#define RETURN_IF_DELETED(func) \ +ACTION_IF_DELETED(this, func, return) + +#endif // QANIMATIONJOBUTIL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qbipointer_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qbipointer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..416fdf89f3c391dde2633958b828bd1315b24b58 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qbipointer_p.h @@ -0,0 +1,203 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QBIPOINTER_P_H +#define QBIPOINTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +#include <QtCore/qhashfunctions.h> + +QT_BEGIN_NAMESPACE + +namespace QtPrivate { +template <typename T> struct QFlagPointerAlignment +{ + enum : size_t { Value = Q_ALIGNOF(T) }; +}; +template <> struct QFlagPointerAlignment<void> +{ + enum : size_t { Value = ~size_t(0) }; +}; +} + +/*! + \internal + \class template<typename T1, typename T2> QBiPointer<T1, T2> + + \short QBiPointer can be thought of as a space-optimized std::variant<T1*, T2*> + with a nicer API to check the active pointer. Its other main feature is that + it only requires sizeof(void *) space. + + \note It can also store one additional flag for a user defined purpose. + */ +template<typename T, typename T2> +class QBiPointer { +public: + Q_NODISCARD_CTOR constexpr QBiPointer() noexcept = default; + ~QBiPointer() noexcept = default; + Q_NODISCARD_CTOR QBiPointer(const QBiPointer &o) noexcept = default; + Q_NODISCARD_CTOR QBiPointer(QBiPointer &&o) noexcept = default; + QBiPointer<T, T2> &operator=(const QBiPointer<T, T2> &o) noexcept = default; + QBiPointer<T, T2> &operator=(QBiPointer<T, T2> &&o) noexcept = default; + + void swap(QBiPointer &other) noexcept { std::swap(ptr_value, other.ptr_value); } + + Q_NODISCARD_CTOR inline QBiPointer(T *); + Q_NODISCARD_CTOR inline QBiPointer(T2 *); + + inline bool isNull() const; + inline bool isT1() const; + inline bool isT2() const; + + inline bool flag() const; + inline void setFlag(); + inline void clearFlag(); + inline void setFlagValue(bool); + + inline QBiPointer<T, T2> &operator=(T *); + inline QBiPointer<T, T2> &operator=(T2 *); + + friend inline bool operator==(QBiPointer<T, T2> ptr1, QBiPointer<T, T2> ptr2) + { + if (ptr1.isNull() && ptr2.isNull()) + return true; + if (ptr1.isT1() && ptr2.isT1()) + return ptr1.asT1() == ptr2.asT1(); + if (ptr1.isT2() && ptr2.isT2()) + return ptr1.asT2() == ptr2.asT2(); + return false; + } + friend inline bool operator!=(QBiPointer<T, T2> ptr1, QBiPointer<T, T2> ptr2) + { + return !(ptr1 == ptr2); + } + + friend void swap(QBiPointer &lhs, QBiPointer &rhs) noexcept { lhs.swap(rhs); } + + inline T *asT1() const; + inline T2 *asT2() const; + + friend size_t qHash(const QBiPointer<T, T2> &ptr, size_t seed = 0) + { + return qHash(ptr.isNull() ? quintptr(0) : ptr.ptr_value, seed); + } + +private: + quintptr ptr_value = 0; + + static const quintptr FlagBit = 0x1; + static const quintptr Flag2Bit = 0x2; + static const quintptr FlagsMask = FlagBit | Flag2Bit; +}; + +template <typename...Ts> // can't use commas in macros +Q_DECLARE_TYPEINFO_BODY(QBiPointer<Ts...>, Q_PRIMITIVE_TYPE); + +template<typename T, typename T2> +QBiPointer<T, T2>::QBiPointer(T *v) +: ptr_value(quintptr(v)) +{ + Q_STATIC_ASSERT_X(QtPrivate::QFlagPointerAlignment<T>::Value >= 4, + "Type T does not have sufficient alignment"); + Q_ASSERT((quintptr(v) & FlagsMask) == 0); +} + +template<typename T, typename T2> +QBiPointer<T, T2>::QBiPointer(T2 *v) +: ptr_value(quintptr(v) | Flag2Bit) +{ + Q_STATIC_ASSERT_X(QtPrivate::QFlagPointerAlignment<T2>::Value >= 4, + "Type T2 does not have sufficient alignment"); + Q_ASSERT((quintptr(v) & FlagsMask) == 0); +} + +template<typename T, typename T2> +bool QBiPointer<T, T2>::isNull() const +{ + return 0 == (ptr_value & (~FlagsMask)); +} + +template<typename T, typename T2> +bool QBiPointer<T, T2>::isT1() const +{ + return !(ptr_value & Flag2Bit); +} + +template<typename T, typename T2> +bool QBiPointer<T, T2>::isT2() const +{ + return ptr_value & Flag2Bit; +} + +template<typename T, typename T2> +bool QBiPointer<T, T2>::flag() const +{ + return ptr_value & FlagBit; +} + +template<typename T, typename T2> +void QBiPointer<T, T2>::setFlag() +{ + ptr_value |= FlagBit; +} + +template<typename T, typename T2> +void QBiPointer<T, T2>::clearFlag() +{ + ptr_value &= ~FlagBit; +} + +template<typename T, typename T2> +void QBiPointer<T, T2>::setFlagValue(bool v) +{ + if (v) setFlag(); + else clearFlag(); +} + +template<typename T, typename T2> +QBiPointer<T, T2> &QBiPointer<T, T2>::operator=(T *o) +{ + Q_ASSERT((quintptr(o) & FlagsMask) == 0); + + ptr_value = quintptr(o) | (ptr_value & FlagBit); + return *this; +} + +template<typename T, typename T2> +QBiPointer<T, T2> &QBiPointer<T, T2>::operator=(T2 *o) +{ + Q_ASSERT((quintptr(o) & FlagsMask) == 0); + + ptr_value = quintptr(o) | (ptr_value & FlagBit) | Flag2Bit; + return *this; +} + +template<typename T, typename T2> +T *QBiPointer<T, T2>::asT1() const +{ + Q_ASSERT(isT1()); + return (T *)(ptr_value & ~FlagsMask); +} + +template<typename T, typename T2> +T2 *QBiPointer<T, T2>::asT2() const +{ + Q_ASSERT(isT2()); + return (T2 *)(ptr_value & ~FlagsMask); +} + +QT_END_NAMESPACE + +#endif // QBIPOINTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qcontinuinganimationgroupjob_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qcontinuinganimationgroupjob_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1ac20b03fe5fce93933ab1ba52eed600f86850ae --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qcontinuinganimationgroupjob_p.h @@ -0,0 +1,43 @@ +// Copyright (C) 2016 Jolla Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCONTINUINGANIMATIONGROUPJOB_P_H +#define QCONTINUINGANIMATIONGROUPJOB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qanimationgroupjob_p.h" + +QT_REQUIRE_CONFIG(qml_animation); + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QContinuingAnimationGroupJob : public QAnimationGroupJob +{ + Q_DISABLE_COPY(QContinuingAnimationGroupJob) +public: + QContinuingAnimationGroupJob(); + ~QContinuingAnimationGroupJob(); + + int duration() const override { return -1; } + +protected: + void updateCurrentTime(int currentTime) override; + void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override; + void updateDirection(QAbstractAnimationJob::Direction direction) override; + void uncontrolledAnimationFinished(QAbstractAnimationJob *animation) override; + void debugAnimation(QDebug d) const override; +}; + +QT_END_NAMESPACE + +#endif // QCONTINUINGANIMATIONGROUPJOB_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qdoubleendedlist_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qdoubleendedlist_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bf492578612744a919bc9d3a0a53ea575f9b6c4b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qdoubleendedlist_p.h @@ -0,0 +1,256 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDOUBLEENDEDLIST_P_H +#define QDOUBLEENDEDLIST_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QInheritedListNode +{ +public: + ~QInheritedListNode() { remove(); } + bool isInList() const + { + Q_ASSERT((m_prev && m_next) || (!m_prev && !m_next)); + return m_prev != nullptr; + } + +private: + template<class N> + friend class QDoubleEndedList; + + void remove() + { + Q_ASSERT((m_prev && m_next) || (!m_prev && !m_next)); + if (!m_prev) + return; + + m_prev->m_next = m_next; + m_next->m_prev = m_prev; + m_prev = nullptr; + m_next = nullptr; + } + + QInheritedListNode *m_next = nullptr; + QInheritedListNode *m_prev = nullptr; +}; + +template<class N> +class QDoubleEndedList +{ +public: + QDoubleEndedList() + { + m_head.m_next = &m_head; + m_head.m_prev = &m_head; + assertHeadConsistent(); + } + + ~QDoubleEndedList() + { + assertHeadConsistent(); + while (!isEmpty()) + m_head.m_next->remove(); + assertHeadConsistent(); + } + + bool isEmpty() const + { + assertHeadConsistent(); + return m_head.m_next == &m_head; + } + + void prepend(N *n) + { + assertHeadConsistent(); + QInheritedListNode *nnode = n; + nnode->remove(); + + nnode->m_next = m_head.m_next ? m_head.m_next : &m_head; + nnode->m_next->m_prev = nnode; + + m_head.m_next = nnode; + nnode->m_prev = &m_head; + assertHeadConsistent(); + } + + void append(N *n) + { + assertHeadConsistent(); + QInheritedListNode *nnode = n; + nnode->remove(); + + nnode->m_prev = m_head.m_prev ? m_head.m_prev : &m_head; + nnode->m_prev->m_next = nnode; + + m_head.m_prev = nnode; + nnode->m_next = &m_head; + assertHeadConsistent(); + } + + void remove(N *n) { + Q_ASSERT(contains(n)); + QInheritedListNode *nnode = n; + nnode->remove(); + assertHeadConsistent(); + } + + bool contains(const N *n) const + { + assertHeadConsistent(); + for (const QInheritedListNode *nnode = m_head.m_next; + nnode != &m_head; nnode = nnode->m_next) { + if (nnode == n) + return true; + } + + return false; + } + + template<typename T, typename Node> + class base_iterator { + public: + T *operator*() const { return QDoubleEndedList<N>::nodeToN(m_node); } + T *operator->() const { return QDoubleEndedList<N>::nodeToN(m_node); } + + bool operator==(const base_iterator &other) const { return other.m_node == m_node; } + bool operator!=(const base_iterator &other) const { return other.m_node != m_node; } + + base_iterator &operator++() + { + m_node = m_node->m_next; + return *this; + } + + base_iterator operator++(int) + { + const base_iterator self(m_node); + m_node = m_node->m_next; + return self; + } + + private: + friend class QDoubleEndedList<N>; + + base_iterator(Node *node) : m_node(node) + { + Q_ASSERT(m_node != nullptr); + } + + Node *m_node = nullptr; + }; + + using iterator = base_iterator<N, QInheritedListNode>; + using const_iterator = base_iterator<const N, const QInheritedListNode>; + + const N *first() const { return checkedNodeToN(m_head.m_next); } + N *first() { return checkedNodeToN(m_head.m_next); } + + const N *last() const { return checkedNodeToN(m_head.m_prev); } + N *last() { return checkedNodeToN(m_head.m_prev); } + + const N *next(const N *current) const + { + Q_ASSERT(contains(current)); + const QInheritedListNode *nnode = current; + return checkedNodeToN(nnode->m_next); + } + + N *next(N *current) + { + Q_ASSERT(contains(current)); + const QInheritedListNode *nnode = current; + return checkedNodeToN(nnode->m_next); + } + + const N *prev(const N *current) const + { + Q_ASSERT(contains(current)); + const QInheritedListNode *nnode = current; + return checkedNodeToN(nnode->m_prev); + } + + N *prev(N *current) + { + Q_ASSERT(contains(current)); + const QInheritedListNode *nnode = current; + return checkedNodeToN(nnode->m_prev); + } + + iterator begin() + { + assertHeadConsistent(); + return iterator(m_head.m_next); + } + + iterator end() + { + assertHeadConsistent(); + return iterator(&m_head); + } + + const_iterator begin() const + { + assertHeadConsistent(); + return const_iterator(m_head.m_next); + } + + const_iterator end() const + { + assertHeadConsistent(); + return const_iterator(&m_head); + } + + qsizetype count() const + { + assertHeadConsistent(); + qsizetype result = 0; + for (const auto *node = m_head.m_next; node != &m_head; node = node->m_next) + ++result; + return result; + } + +private: + static N *nodeToN(QInheritedListNode *node) + { + return static_cast<N *>(node); + } + + static const N *nodeToN(const QInheritedListNode *node) + { + return static_cast<const N *>(node); + } + + N *checkedNodeToN(QInheritedListNode *node) const + { + assertHeadConsistent(); + return (!node || node == &m_head) ? nullptr : nodeToN(node); + } + + void assertHeadConsistent() const + { + Q_ASSERT(m_head.m_next != nullptr); + Q_ASSERT(m_head.m_prev != nullptr); + Q_ASSERT(m_head.m_next != &m_head || m_head.m_prev == &m_head); + } + + QInheritedListNode m_head; +}; + +QT_END_NAMESPACE + +#endif // QDOUBLEENDEDLIST_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qfieldlist_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qfieldlist_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5128440f229a33663c8d1634416173d51347526b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qfieldlist_p.h @@ -0,0 +1,359 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFIELDLIST_P_H +#define QFIELDLIST_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qtaggedpointer.h> + + +// QForwardFieldList is a super simple linked list that can only prepend +template<class N, N *N::*nextMember, typename Tag = QtPrivate::TagInfo<N>> +class QForwardFieldList +{ +public: + inline QForwardFieldList(); + inline N *first() const; + inline N *takeFirst(); + + inline void prepend(N *); + template <typename OtherTag> + inline void copyAndClearPrepend(QForwardFieldList<N, nextMember, OtherTag> &); + + inline bool isEmpty() const; + inline bool isOne() const; + inline bool isMany() const; + + static inline N *next(N *v); + + inline Tag tag() const; + inline void setTag(Tag t); +private: + QTaggedPointer<N, Tag> _first; +}; + +// QFieldList is a simple linked list, that can append and prepend and also +// maintains a count +template<class N, N *N::*nextMember> +class QFieldList +{ +public: + inline QFieldList(); + inline N *first() const; + inline N *takeFirst(); + + inline void append(N *); + inline void prepend(N *); + + inline bool isEmpty() const; + inline bool isOne() const; + inline bool isMany() const; + inline int count() const; + + inline void append(QFieldList<N, nextMember> &); + inline void prepend(QFieldList<N, nextMember> &); + inline void insertAfter(N *, QFieldList<N, nextMember> &); + + inline void copyAndClear(QFieldList<N, nextMember> &); + template <typename Tag> + inline void copyAndClearAppend(QForwardFieldList<N, nextMember, Tag> &); + template <typename Tag> + inline void copyAndClearPrepend(QForwardFieldList<N, nextMember, Tag> &); + + static inline N *next(N *v); + + inline bool flag() const; + inline void setFlag(); + inline void clearFlag(); + inline void setFlagValue(bool); +private: + N *_first; + N *_last; + quint32 _flag:1; + quint32 _count:31; +}; + +template<class N, N *N::*nextMember, typename Tag> +QForwardFieldList<N, nextMember, Tag>::QForwardFieldList() +{ +} + +template<class N, N *N::*nextMember, typename Tag> +N *QForwardFieldList<N, nextMember, Tag>::first() const +{ + return _first.data(); +} + +template<class N, N *N::*nextMember, typename Tag> +N *QForwardFieldList<N, nextMember, Tag>::takeFirst() +{ + N *value = _first.data(); + if (value) { + _first = next(value); + value->*nextMember = nullptr; + } + return value; +} + +template<class N, N *N::*nextMember, typename Tag> +void QForwardFieldList<N, nextMember, Tag>::prepend(N *v) +{ + Q_ASSERT(v->*nextMember == nullptr); + v->*nextMember = _first.data(); + _first = v; +} + +template<class N, N *N::*nextMember, typename Tag> +template <typename OtherTag> +void QForwardFieldList<N, nextMember, Tag>::copyAndClearPrepend(QForwardFieldList<N, nextMember, OtherTag> &o) +{ + _first = nullptr; + while (N *n = o.takeFirst()) prepend(n); +} + +template<class N, N *N::*nextMember, typename Tag> +bool QForwardFieldList<N, nextMember, Tag>::isEmpty() const +{ + return _first.isNull(); +} + +template<class N, N *N::*nextMember, typename Tag> +bool QForwardFieldList<N, nextMember, Tag>::isOne() const +{ + return _first.data() && _first->*nextMember == 0; +} + +template<class N, N *N::*nextMember, typename Tag> +bool QForwardFieldList<N, nextMember, Tag>::isMany() const +{ + return _first.data() && _first->*nextMember != 0; +} + +template<class N, N *N::*nextMember, typename Tag> +N *QForwardFieldList<N, nextMember, Tag>::next(N *v) +{ + Q_ASSERT(v); + return v->*nextMember; +} + +template<class N, N *N::*nextMember, typename Tag> +Tag QForwardFieldList<N, nextMember, Tag>::tag() const +{ + return _first.tag(); +} + +template<class N, N *N::*nextMember, typename Tag> +void QForwardFieldList<N, nextMember, Tag>::setTag(Tag t) +{ + _first.setTag(t); +} + +template<class N, N *N::*nextMember> +QFieldList<N, nextMember>::QFieldList() +: _first(nullptr), _last(nullptr), _flag(0), _count(0) +{ +} + +template<class N, N *N::*nextMember> +N *QFieldList<N, nextMember>::first() const +{ + return _first; +} + +template<class N, N *N::*nextMember> +N *QFieldList<N, nextMember>::takeFirst() +{ + N *value = _first; + if (value) { + _first = next(value); + if (_last == value) { + Q_ASSERT(_first == nullptr); + _last = nullptr; + } + value->*nextMember = nullptr; + --_count; + } + return value; +} + +template<class N, N *N::*nextMember> +void QFieldList<N, nextMember>::append(N *v) +{ + Q_ASSERT(v->*nextMember == nullptr); + if (isEmpty()) { + _first = v; + _last = v; + } else { + _last->*nextMember = v; + _last = v; + } + ++_count; +} + +template<class N, N *N::*nextMember> +void QFieldList<N, nextMember>::prepend(N *v) +{ + Q_ASSERT(v->*nextMember == nullptr); + if (isEmpty()) { + _first = v; + _last = v; + } else { + v->*nextMember = _first; + _first = v; + } + ++_count; +} + +template<class N, N *N::*nextMember> +bool QFieldList<N, nextMember>::isEmpty() const +{ + return _count == 0; +} + +template<class N, N *N::*nextMember> +bool QFieldList<N, nextMember>::isOne() const +{ + return _count == 1; +} + +template<class N, N *N::*nextMember> +bool QFieldList<N, nextMember>::isMany() const +{ + return _count > 1; +} + +template<class N, N *N::*nextMember> +int QFieldList<N, nextMember>::count() const +{ + return _count; +} + +template<class N, N *N::*nextMember> +N *QFieldList<N, nextMember>::next(N *v) +{ + Q_ASSERT(v); + return v->*nextMember; +} + +template<class N, N *N::*nextMember> +void QFieldList<N, nextMember>::append(QFieldList<N, nextMember> &o) +{ + if (!o.isEmpty()) { + if (isEmpty()) { + _first = o._first; + _last = o._last; + _count = o._count; + } else { + _last->*nextMember = o._first; + _last = o._last; + _count += o._count; + } + o._first = o._last = 0; o._count = 0; + } +} + +template<class N, N *N::*nextMember> +void QFieldList<N, nextMember>::prepend(QFieldList<N, nextMember> &o) +{ + if (!o.isEmpty()) { + if (isEmpty()) { + _first = o._first; + _last = o._last; + _count = o._count; + } else { + o._last->*nextMember = _first; + _first = o._first; + _count += o._count; + } + o._first = o._last = 0; o._count = 0; + } +} + +template<class N, N *N::*nextMember> +void QFieldList<N, nextMember>::insertAfter(N *after, QFieldList<N, nextMember> &o) +{ + if (after == 0) { + prepend(o); + } else if (after == _last) { + append(o); + } else if (!o.isEmpty()) { + if (isEmpty()) { + _first = o._first; + _last = o._last; + _count = o._count; + } else { + o._last->*nextMember = after->*nextMember; + after->*nextMember = o._first; + _count += o._count; + } + o._first = o._last = 0; o._count = 0; + } +} + +template<class N, N *N::*nextMember> +void QFieldList<N, nextMember>::copyAndClear(QFieldList<N, nextMember> &o) +{ + _first = o._first; + _last = o._last; + _count = o._count; + o._first = o._last = nullptr; + o._count = 0; +} + +template<class N, N *N::*nextMember> +template <typename Tag> +void QFieldList<N, nextMember>::copyAndClearAppend(QForwardFieldList<N, nextMember, Tag> &o) +{ + _first = 0; + _last = 0; + _count = 0; + while (N *n = o.takeFirst()) append(n); +} + +template<class N, N *N::*nextMember> +template <typename Tag> +void QFieldList<N, nextMember>::copyAndClearPrepend(QForwardFieldList<N, nextMember, Tag> &o) +{ + _first = nullptr; + _last = nullptr; + _count = 0; + while (N *n = o.takeFirst()) prepend(n); +} + +template<class N, N *N::*nextMember> +bool QFieldList<N, nextMember>::flag() const +{ + return _flag; +} + +template<class N, N *N::*nextMember> +void QFieldList<N, nextMember>::setFlag() +{ + _flag = true; +} + +template<class N, N *N::*nextMember> +void QFieldList<N, nextMember>::clearFlag() +{ + _flag = false; +} + +template<class N, N *N::*nextMember> +void QFieldList<N, nextMember>::setFlagValue(bool v) +{ + _flag = v; +} + +#endif // QFIELDLIST_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qfinitestack_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qfinitestack_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e2bcacdc8c987f9e5cfdce0f07ebe1d1c57d6431 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qfinitestack_p.h @@ -0,0 +1,152 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QFINITESTACK_P_H +#define QFINITESTACK_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +template<typename T> +struct QFiniteStack { + inline QFiniteStack(); + inline ~QFiniteStack(); + + inline void deallocate(); + inline void allocate(int size); + + inline int capacity() const { return _alloc; } + + inline bool isEmpty() const; + inline const T &top() const; + inline T &top(); + inline void push(const T &o); + inline T pop(); + inline int count() const; + inline const T &at(int index) const; + inline T &operator[](int index); +private: + T *_array; + int _alloc; + int _size; +}; + +template<typename T> +QFiniteStack<T>::QFiniteStack() +: _array(nullptr), _alloc(0), _size(0) +{ +} + +template<typename T> +QFiniteStack<T>::~QFiniteStack() +{ + deallocate(); +} + +template<typename T> +bool QFiniteStack<T>::isEmpty() const +{ + return _size == 0; +} + +template<typename T> +const T &QFiniteStack<T>::top() const +{ + return _array[_size - 1]; +} + +template<typename T> +T &QFiniteStack<T>::top() +{ + return _array[_size - 1]; +} + +template<typename T> +void QFiniteStack<T>::push(const T &o) +{ + Q_ASSERT(_size < _alloc); + if (QTypeInfo<T>::isComplex) { + new (_array + _size++) T(o); + } else { + _array[_size++] = o; + } +} + +template<typename T> +T QFiniteStack<T>::pop() +{ + Q_ASSERT(_size > 0); + --_size; + + if (QTypeInfo<T>::isComplex) { + T rv = _array[_size]; + (_array + _size)->~T(); + return rv; + } else { + return _array[_size]; + } +} + +template<typename T> +int QFiniteStack<T>::count() const +{ + return _size; +} + +template<typename T> +const T &QFiniteStack<T>::at(int index) const +{ + return _array[index]; +} + +template<typename T> +T &QFiniteStack<T>::operator[](int index) +{ + return _array[index]; +} + +template<typename T> +void QFiniteStack<T>::allocate(int size) +{ + Q_ASSERT(_array == nullptr); + Q_ASSERT(_alloc == 0); + Q_ASSERT(_size == 0); + + if (!size) return; + + _array = (T *)malloc(size * sizeof(T)); + _alloc = size; +} + +template<typename T> +void QFiniteStack<T>::deallocate() +{ + if (QTypeInfo<T>::isComplex) { + T *i = _array + _size; + while (i != _array) + (--i)->~T(); + } + + free(_array); + + _array = nullptr; + _alloc = 0; + _size = 0; +} + +QT_END_NAMESPACE + +#endif // QFINITESTACK_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qhashedstring_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qhashedstring_p.h new file mode 100644 index 0000000000000000000000000000000000000000..89ca6386c08948365b12ca804907675437428dad --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qhashedstring_p.h @@ -0,0 +1,442 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QHASHEDSTRING_P_H +#define QHASHEDSTRING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtCore/qstring.h> +#include <private/qv4string_p.h> + +#if defined(Q_OS_QNX) +#include <stdlib.h> +#endif + +QT_BEGIN_NAMESPACE + +class QHashedStringRef; +class Q_QML_EXPORT QHashedString : public QString +{ +public: + inline QHashedString(); + inline QHashedString(const QString &string); + inline QHashedString(const QString &string, quint32); + inline QHashedString(const QHashedString &string); + + inline QHashedString &operator=(const QHashedString &string); + inline bool operator==(const QHashedString &string) const; + inline bool operator==(const QHashedStringRef &string) const; + + inline quint32 hash() const; + inline quint32 existingHash() const; + + static inline bool compare(const QChar *lhs, const char *rhs, int length); + static inline bool compare(const char *lhs, const char *rhs, int length); + + static inline quint32 stringHash(const QChar* data, int length); + static inline quint32 stringHash(const char *data, int length); + +private: + friend class QHashedStringRef; + friend class QStringHashNode; + + inline void computeHash() const; + mutable quint32 m_hash = 0; +}; + +class QHashedCStringRef; +class Q_QML_EXPORT QHashedStringRef +{ +public: + inline QHashedStringRef(); + inline QHashedStringRef(const QString &); + inline QHashedStringRef(QStringView); + inline QHashedStringRef(const QChar *, int); + inline QHashedStringRef(const QChar *, int, quint32); + inline QHashedStringRef(const QHashedString &); + inline QHashedStringRef(const QHashedStringRef &); + inline QHashedStringRef &operator=(const QHashedStringRef &); + + inline bool operator==(const QString &string) const; + inline bool operator==(const QHashedString &string) const; + inline bool operator==(const QHashedStringRef &string) const; + inline bool operator==(const QHashedCStringRef &string) const; + inline bool operator!=(const QString &string) const; + inline bool operator!=(const QHashedString &string) const; + inline bool operator!=(const QHashedStringRef &string) const; + inline bool operator!=(const QHashedCStringRef &string) const; + + inline quint32 hash() const; + + inline QChar *data(); + inline const QChar &at(int) const; + inline const QChar *constData() const; + bool startsWith(const QString &) const; + bool endsWith(const QString &) const; + int indexOf(const QChar &, int from=0) const; + QHashedStringRef mid(int, int) const; + QVector<QHashedStringRef> split(const QChar sep) const; + + inline bool isEmpty() const; + inline int length() const; + inline bool startsWithUpper() const; + + QString toString() const; + + inline bool isLatin1() const; + +private: + friend class QHashedString; + + inline void computeHash() const; + + const QChar *m_data = nullptr; + int m_length = 0; + mutable quint32 m_hash = 0; +}; + +class QHashedCStringRef +{ +public: + inline QHashedCStringRef(); + inline QHashedCStringRef(const char *, int); + inline QHashedCStringRef(const char *, int, quint32); + inline QHashedCStringRef(const QHashedCStringRef &); + + inline quint32 hash() const; + + inline const char *constData() const; + inline int length() const; + + Q_AUTOTEST_EXPORT QString toUtf16() const; + inline int utf16length() const; + inline void writeUtf16(QChar *) const; + inline void writeUtf16(quint16 *) const; +private: + friend class QHashedStringRef; + + inline void computeHash() const; + + const char *m_data = nullptr; + int m_length = 0; + mutable quint32 m_hash = 0; +}; + +inline size_t qHash(const QHashedString &string) +{ + return uint(string.hash()); +} + +inline size_t qHash(const QHashedStringRef &string) +{ + return uint(string.hash()); +} + +QHashedString::QHashedString() +: QString() +{ +} + +QHashedString::QHashedString(const QString &string) +: QString(string), m_hash(0) +{ +} + +QHashedString::QHashedString(const QString &string, quint32 hash) +: QString(string), m_hash(hash) +{ +} + +QHashedString::QHashedString(const QHashedString &string) +: QString(string), m_hash(string.m_hash) +{ +} + +QHashedString &QHashedString::operator=(const QHashedString &string) +{ + static_cast<QString &>(*this) = string; + m_hash = string.m_hash; + return *this; +} + +bool QHashedString::operator==(const QHashedString &string) const +{ + return (string.m_hash == m_hash || !string.m_hash || !m_hash) && + static_cast<const QString &>(*this) == static_cast<const QString &>(string); +} + +bool QHashedString::operator==(const QHashedStringRef &string) const +{ + if (m_hash && string.m_hash && m_hash != string.m_hash) + return false; + QStringView otherView {string.m_data, string.m_length}; + return static_cast<const QString &>(*this) == otherView; +} + +quint32 QHashedString::hash() const +{ + if (!m_hash) computeHash(); + return m_hash; +} + +quint32 QHashedString::existingHash() const +{ + return m_hash; +} + +QHashedStringRef::QHashedStringRef() +{ +} + +// QHashedStringRef is meant for identifiers, property names, etc. +// Those should alsways be smaller than std::numeric_limits<int>::max()) +QHashedStringRef::QHashedStringRef(const QString &str) +: m_data(str.constData()), m_length(int(str.size())), m_hash(0) +{ + Q_ASSERT(str.size() <= std::numeric_limits<int>::max()); +} + +QHashedStringRef::QHashedStringRef(QStringView str) +: m_data(str.constData()), m_length(int(str.size())), m_hash(0) +{ + Q_ASSERT(str.size() <= std::numeric_limits<int>::max()); +} + +QHashedStringRef::QHashedStringRef(const QChar *data, int length) +: m_data(data), m_length(length), m_hash(0) +{ +} + +QHashedStringRef::QHashedStringRef(const QChar *data, int length, quint32 hash) +: m_data(data), m_length(length), m_hash(hash) +{ +} + +QHashedStringRef::QHashedStringRef(const QHashedString &string) +: m_data(string.constData()), m_length(int(string.size())), m_hash(string.m_hash) +{ + Q_ASSERT(string.size() <= std::numeric_limits<int>::max()); +} + +QHashedStringRef::QHashedStringRef(const QHashedStringRef &string) +: m_data(string.m_data), m_length(string.m_length), m_hash(string.m_hash) +{ +} + +QHashedStringRef &QHashedStringRef::operator=(const QHashedStringRef &o) +{ + m_data = o.m_data; + m_length = o.m_length; + m_hash = o.m_hash; + return *this; +} + +bool QHashedStringRef::operator==(const QString &string) const +{ + QStringView view {m_data, m_length}; + return view == string; +} + +bool QHashedStringRef::operator==(const QHashedString &string) const +{ + if (m_hash && string.m_hash && m_hash != string.m_hash) + return false; + QStringView view {m_data, m_length}; + QStringView otherView {string.constData(), string.size()}; + return view == otherView; +} + +bool QHashedStringRef::operator==(const QHashedStringRef &string) const +{ + if (m_hash && string.m_hash && m_hash != string.m_hash) + return false; + QStringView view {m_data, m_length}; + QStringView otherView {string.m_data, string.m_length}; + return view == otherView; +} + +bool QHashedStringRef::operator==(const QHashedCStringRef &string) const +{ + return m_length == string.m_length && + (m_hash == string.m_hash || !m_hash || !string.m_hash) && + QHashedString::compare(m_data, string.m_data, m_length); +} + +bool QHashedStringRef::operator!=(const QString &string) const +{ + return !(*this == string); +} + +bool QHashedStringRef::operator!=(const QHashedString &string) const +{ + return !(*this == string); +} + +bool QHashedStringRef::operator!=(const QHashedStringRef &string) const +{ + return !(*this == string); +} + +bool QHashedStringRef::operator!=(const QHashedCStringRef &string) const +{ + return !(*this == string); +} + +QChar *QHashedStringRef::data() +{ + return const_cast<QChar *>(m_data); +} + +const QChar &QHashedStringRef::at(int index) const +{ + Q_ASSERT(index < m_length); + return m_data[index]; +} + +const QChar *QHashedStringRef::constData() const +{ + return m_data; +} + +bool QHashedStringRef::isEmpty() const +{ + return m_length == 0; +} + +int QHashedStringRef::length() const +{ + return m_length; +} + +bool QHashedStringRef::isLatin1() const +{ + for (int ii = 0; ii < m_length; ++ii) + if (m_data[ii].unicode() > 127) return false; + return true; +} + +void QHashedStringRef::computeHash() const +{ + m_hash = QHashedString::stringHash(m_data, m_length); +} + +bool QHashedStringRef::startsWithUpper() const +{ + if (m_length < 1) return false; + return m_data[0].isUpper(); +} + +quint32 QHashedStringRef::hash() const +{ + if (!m_hash) computeHash(); + return m_hash; +} + +QHashedCStringRef::QHashedCStringRef() +{ +} + +QHashedCStringRef::QHashedCStringRef(const char *data, int length) +: m_data(data), m_length(length), m_hash(0) +{ +} + +QHashedCStringRef::QHashedCStringRef(const char *data, int length, quint32 hash) +: m_data(data), m_length(length), m_hash(hash) +{ +} + +QHashedCStringRef::QHashedCStringRef(const QHashedCStringRef &o) +: m_data(o.m_data), m_length(o.m_length), m_hash(o.m_hash) +{ +} + +quint32 QHashedCStringRef::hash() const +{ + if (!m_hash) computeHash(); + return m_hash; +} + +const char *QHashedCStringRef::constData() const +{ + return m_data; +} + +int QHashedCStringRef::length() const +{ + return m_length; +} + +int QHashedCStringRef::utf16length() const +{ + return m_length; +} + +void QHashedCStringRef::writeUtf16(QChar *output) const +{ + writeUtf16((quint16 *)output); +} + +void QHashedCStringRef::writeUtf16(quint16 *output) const +{ + int l = m_length; + const char *d = m_data; + while (l--) + *output++ = *d++; +} + +void QHashedCStringRef::computeHash() const +{ + m_hash = QHashedString::stringHash(m_data, m_length); +} + +bool QHashedString::compare(const QChar *lhs, const char *rhs, int length) +{ + Q_ASSERT(lhs && rhs); + const quint16 *l = (const quint16*)lhs; + while (length--) + if (*l++ != *rhs++) return false; + return true; +} + +bool QHashedString::compare(const char *lhs, const char *rhs, int length) +{ + Q_ASSERT(lhs && rhs); + return 0 == ::memcmp(lhs, rhs, length); +} + + +quint32 QHashedString::stringHash(const QChar *data, int length) +{ + return QV4::String::createHashValue(data, length, nullptr); +} + +quint32 QHashedString::stringHash(const char *data, int length) +{ + return QV4::String::createHashValue(data, length, nullptr); +} + +void QHashedString::computeHash() const +{ + m_hash = stringHash(constData(), int(size())); +} + +namespace QtPrivate { +inline QString asString(const QHashedCStringRef &ref) { return ref.toUtf16(); } +inline QString asString(const QHashedStringRef &ref) { return ref.toString(); } +} + +QT_END_NAMESPACE + +#endif // QHASHEDSTRING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qintrusivelist_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qintrusivelist_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cbd1ae54ea6e3fee34873760621ea955879c260a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qintrusivelist_p.h @@ -0,0 +1,159 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QINTRUSIVELIST_P_H +#define QINTRUSIVELIST_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QIntrusiveListNode +{ +public: + ~QIntrusiveListNode() { remove(); } + + void remove() + { + if (_prev) *_prev = _next; + if (_next) _next->_prev = _prev; + _prev = nullptr; + _next = nullptr; + } + + bool isInList() const { return _prev != nullptr; } + +private: + template<class N, QIntrusiveListNode N::*member> + friend class QIntrusiveList; + + QIntrusiveListNode *_next = nullptr; + QIntrusiveListNode**_prev = nullptr; +}; + +template<class N, QIntrusiveListNode N::*member> +class QIntrusiveList +{ +private: + template<typename O> + class iterator_impl { + public: + iterator_impl() = default; + iterator_impl(O value) : _value(value) {} + + O operator*() const { return _value; } + O operator->() const { return _value; } + bool operator==(const iterator_impl &other) const { return other._value == _value; } + bool operator!=(const iterator_impl &other) const { return other._value != _value; } + iterator_impl &operator++() + { + _value = QIntrusiveList<N, member>::next(_value); + return *this; + } + + protected: + O _value = nullptr; + }; + +public: + class iterator : public iterator_impl<N *> + { + public: + iterator() = default; + iterator(N *value) : iterator_impl<N *>(value) {} + + iterator &erase() + { + N *old = this->_value; + this->_value = QIntrusiveList<N, member>::next(this->_value); + (old->*member).remove(); + return *this; + } + }; + + using const_iterator = iterator_impl<const N *>; + + using Iterator = iterator; + using ConstIterator = const_iterator; + + ~QIntrusiveList() { while (__first) __first->remove(); } + + bool isEmpty() const { return __first == nullptr; } + + void insert(N *n) + { + QIntrusiveListNode *nnode = &(n->*member); + nnode->remove(); + + nnode->_next = __first; + if (nnode->_next) nnode->_next->_prev = &nnode->_next; + __first = nnode; + nnode->_prev = &__first; + } + + void remove(N *n) + { + QIntrusiveListNode *nnode = &(n->*member); + nnode->remove(); + } + + bool contains(const N *n) const + { + QIntrusiveListNode *nnode = __first; + while (nnode) { + if (nodeToN(nnode) == n) + return true; + nnode = nnode->_next; + } + return false; + } + + const N *first() const { return __first ? nodeToN(__first) : nullptr; } + N *first() { return __first ? nodeToN(__first) : nullptr; } + + template<typename O> + static O next(O current) + { + QIntrusiveListNode *nextnode = (current->*member)._next; + return nextnode ? nodeToN(nextnode) : nullptr; + } + + iterator begin() { return __first ? iterator(nodeToN(__first)) : iterator(); } + iterator end() { return iterator(); } + + const_iterator begin() const + { + return __first ? const_iterator(nodeToN(__first)) : const_iterator(); + } + + const_iterator end() const { return const_iterator(); } + +private: + + static N *nodeToN(QIntrusiveListNode *node) + { + QT_WARNING_PUSH +#if defined(Q_CC_CLANG) && Q_CC_CLANG >= 1300 + QT_WARNING_DISABLE_CLANG("-Wnull-pointer-subtraction") +#endif + return (N *)((char *)node - ((char *)&(((N *)nullptr)->*member) - (char *)nullptr)); + QT_WARNING_POP + } + + QIntrusiveListNode *__first = nullptr; +}; + +QT_END_NAMESPACE + +#endif // QINTRUSIVELIST_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qjsengine_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qjsengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..338b5440f077377914bcda84f4e2827d9c8a08cd --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qjsengine_p.h @@ -0,0 +1,54 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QJSENGINE_P_H +#define QJSENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qobject_p.h> +#include <QtCore/qmutex.h> +#include <QtCore/qproperty.h> +#include "qjsengine.h" +#include "private/qtqmlglobal_p.h" +#include <private/qqmlmetatype_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlPropertyCache; + +namespace QV4 { +struct ExecutionEngine; +} + +class Q_QML_EXPORT QJSEnginePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QJSEngine) + +public: + static QJSEnginePrivate* get(QJSEngine*e) { return e->d_func(); } + static const QJSEnginePrivate* get(const QJSEngine*e) { return e->d_func(); } + static QJSEnginePrivate* get(QV4::ExecutionEngine *e); + + QJSEnginePrivate() = default; + ~QJSEnginePrivate() override; + + static void addToDebugServer(QJSEngine *q); + static void removeFromDebugServer(QJSEngine *q); + + void uiLanguageChanged() { Q_Q(QJSEngine); if (q) q->uiLanguageChanged(); } + Q_OBJECT_BINDABLE_PROPERTY(QJSEnginePrivate, QString, uiLanguage, &QJSEnginePrivate::uiLanguageChanged); +}; + +QT_END_NAMESPACE + +#endif // QJSENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qjsvalue_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qjsvalue_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1347db24d20e58e9cf33e734a2a32662495d6d3c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qjsvalue_p.h @@ -0,0 +1,373 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QJSVALUE_P_H +#define QJSVALUE_P_H + +#include <qjsvalue.h> +#include <private/qtqmlglobal_p.h> +#include <private/qv4value_p.h> +#include <private/qv4string_p.h> +#include <private/qv4engine_p.h> +#include <private/qv4mm_p.h> +#include <private/qv4persistent_p.h> + +#include <QtCore/qthread.h> + +QT_BEGIN_NAMESPACE + +class QJSValuePrivate +{ + static constexpr quint64 s_tagBits = 3; // 3 bits mask + static constexpr quint64 s_tagMask = (1 << s_tagBits) - 1; + + static constexpr quint64 s_pointerBit = 0x1; + +public: + enum class Kind { + Undefined = 0x0, + Null = 0x2, + IntValue = 0x4, + BoolValue = 0x6, + DoublePtr = 0x0 | s_pointerBit, + QV4ValuePtr = 0x2 | s_pointerBit, + QStringPtr = 0x4 | s_pointerBit, + }; + + static_assert(quint64(Kind::Undefined) <= s_tagMask); + static_assert(quint64(Kind::Null) <= s_tagMask); + static_assert(quint64(Kind::IntValue) <= s_tagMask); + static_assert(quint64(Kind::BoolValue) <= s_tagMask); + static_assert(quint64(Kind::DoublePtr) <= s_tagMask); + static_assert(quint64(Kind::QV4ValuePtr) <= s_tagMask); + static_assert(quint64(Kind::QStringPtr) <= s_tagMask); + + static Kind tag(quint64 raw) { return Kind(raw & s_tagMask); } + +#if QT_POINTER_SIZE == 4 + static void *pointer(quint64 raw) + { + Q_ASSERT(quint64(tag(raw)) & s_pointerBit); + return reinterpret_cast<void *>(raw >> 32); + } + + static quint64 encodePointer(void *pointer, Kind tag) + { + Q_ASSERT(quint64(tag) & s_pointerBit); + return (quint64(quintptr(pointer)) << 32) | quint64(tag); + } +#else + static constexpr quint64 s_minAlignment = 1 << s_tagBits; + static_assert(alignof(double) >= s_minAlignment); + static_assert(alignof(QV4::Value) >= s_minAlignment); + static_assert(alignof(QString) >= s_minAlignment); + + static void *pointer(quint64 raw) + { + Q_ASSERT(quint64(tag(raw)) & s_pointerBit); + return reinterpret_cast<void *>(raw & ~s_tagMask); + } + + static quint64 encodePointer(void *pointer, Kind tag) + { + Q_ASSERT(quint64(tag) & s_pointerBit); + return quintptr(pointer) | quint64(tag); + } +#endif + + static quint64 encodeUndefined() + { + return quint64(Kind::Undefined); + } + + static quint64 encodeNull() + { + return quint64(Kind::Null); + } + + static int intValue(quint64 v) + { + Q_ASSERT(tag(v) == Kind::IntValue); + return v >> 32; + } + + static quint64 encode(int intValue) + { + return (quint64(intValue) << 32) | quint64(Kind::IntValue); + } + + static quint64 encode(uint uintValue) + { + return (uintValue < uint(std::numeric_limits<int>::max())) + ? encode(int(uintValue)) + : encode(double(uintValue)); + } + + static bool boolValue(quint64 v) + { + Q_ASSERT(tag(v) == Kind::BoolValue); + return v >> 32; + } + + static quint64 encode(bool boolValue) + { + return (quint64(boolValue) << 32) | quint64(Kind::BoolValue); + } + + static double *doublePtr(quint64 v) + { + Q_ASSERT(tag(v) == Kind::DoublePtr); + return static_cast<double *>(pointer(v)); + } + + static quint64 encode(double doubleValue) + { + return encodePointer(new double(doubleValue), Kind::DoublePtr); + } + + static QV4::Value *qv4ValuePtr(quint64 v) + { + Q_ASSERT(tag(v) == Kind::QV4ValuePtr); + return static_cast<QV4::Value *>(pointer(v)); + } + + static quint64 encode(const QV4::Value &qv4Value) + { + switch (qv4Value.type()) { + case QV4::StaticValue::Boolean_Type: + return encode(qv4Value.booleanValue()); + case QV4::StaticValue::Integer_Type: + return encode(qv4Value.integerValue()); + case QV4::StaticValue::Managed_Type: { + auto managed = qv4Value.as<QV4::Managed>(); + auto engine = managed->engine(); + auto mm = engine->memoryManager; + QV4::Value *m = mm->m_persistentValues->allocate(); + Q_ASSERT(m); + // we create a new strong reference to the heap managed object + // to avoid having to rescan the persistent values, we mark it here + QV4::WriteBarrier::markCustom(engine, [&](QV4::MarkStack *stack){ + if constexpr (QV4::WriteBarrier::isInsertionBarrier) + managed->heapObject()->mark(stack); + }); + *m = qv4Value; + return encodePointer(m, Kind::QV4ValuePtr); + } + case QV4::StaticValue::Double_Type: + return encode(qv4Value.doubleValue()); + case QV4::StaticValue::Null_Type: + return encodeNull(); + case QV4::StaticValue::Empty_Type: + Q_UNREACHABLE(); + break; + case QV4::StaticValue::Undefined_Type: + break; + } + + return encodeUndefined(); + } + + static QString *qStringPtr(quint64 v) + { + Q_ASSERT(tag(v) == Kind::QStringPtr); + return static_cast<QString *>(pointer(v)); + } + + static quint64 encode(QString stringValue) + { + return encodePointer(new QString(std::move(stringValue)), Kind::QStringPtr); + } + + static quint64 encode(QLatin1String stringValue) + { + return encodePointer(new QString(std::move(stringValue)), Kind::QStringPtr); + } + + static QJSValue fromReturnedValue(QV4::ReturnedValue d) + { + QJSValue result; + setValue(&result, d); + return result; + } + + template<typename T> + static const T *asManagedType(const QJSValue *jsval) + { + if (tag(jsval->d) == Kind::QV4ValuePtr) { + if (const QV4::Value *value = qv4ValuePtr(jsval->d)) + return value->as<T>(); + } + return nullptr; + } + + // This is a move operation and transfers ownership. + static QV4::Value *takeManagedValue(QJSValue *jsval) + { + if (tag(jsval->d) == Kind::QV4ValuePtr) { + if (QV4::Value *value = qv4ValuePtr(jsval->d)) { + jsval->d = encodeUndefined(); + return value; + } + } + return nullptr; + } + + static QV4::ReturnedValue asPrimitiveType(const QJSValue *jsval) + { + switch (tag(jsval->d)) { + case Kind::BoolValue: + return QV4::Encode(boolValue(jsval->d)); + case Kind::IntValue: + return QV4::Encode(intValue(jsval->d)); + case Kind::DoublePtr: + return QV4::Encode(*doublePtr(jsval->d)); + case Kind::Null: + return QV4::Encode::null(); + case Kind::Undefined: + case Kind::QV4ValuePtr: + case Kind::QStringPtr: + break; + } + + return QV4::Encode::undefined(); + } + + // Beware: This only returns a non-null string if the QJSValue actually holds one. + // QV4::Strings are kept as managed values. Retrieve those with getValue(). + static const QString *asQString(const QJSValue *jsval) + { + if (tag(jsval->d) == Kind::QStringPtr) { + if (const QString *string = qStringPtr(jsval->d)) + return string; + } + return nullptr; + } + + static QV4::ReturnedValue asReturnedValue(const QJSValue *jsval) + { + switch (tag(jsval->d)) { + case Kind::BoolValue: + return QV4::Encode(boolValue(jsval->d)); + case Kind::IntValue: + return QV4::Encode(intValue(jsval->d)); + case Kind::DoublePtr: + return QV4::Encode(*doublePtr(jsval->d)); + case Kind::Null: + return QV4::Encode::null(); + case Kind::QV4ValuePtr: + return qv4ValuePtr(jsval->d)->asReturnedValue(); + case Kind::Undefined: + case Kind::QStringPtr: + break; + } + + return QV4::Encode::undefined(); + } + + static void setString(QJSValue *jsval, QString s) + { + jsval->d = encode(std::move(s)); + } + + // Only use this with an existing persistent value. + // Ownership is transferred to the QJSValue. + static void adoptPersistentValue(QJSValue *jsval, QV4::Value *v) + { + jsval->d = encodePointer(v, Kind::QV4ValuePtr); + } + + static void setValue(QJSValue *jsval, const QV4::Value &v) + { + jsval->d = encode(v); + } + + // Moves any QString onto the V4 heap, changing the value to reflect that. + static void manageStringOnV4Heap(QV4::ExecutionEngine *e, QJSValue *jsval) + { + if (const QString *string = asQString(jsval)) { + jsval->d = encode(QV4::Value::fromHeapObject(e->newString(*string))); + delete string; + } + } + + // Converts any QString on the fly, involving an allocation. + // Does not change the value. + static QV4::ReturnedValue convertToReturnedValue(QV4::ExecutionEngine *e, + const QJSValue &jsval) + { + if (const QString *string = asQString(&jsval)) + return e->newString(*string)->asReturnedValue(); + if (const QV4::Value *val = asManagedType<QV4::Managed>(&jsval)) { + if (QV4::PersistentValueStorage::getEngine(val) == e) + return val->asReturnedValue(); + + qWarning("JSValue can't be reassigned to another engine."); + return QV4::Encode::undefined(); + } + return asPrimitiveType(&jsval); + } + + static QV4::ExecutionEngine *engine(const QJSValue *jsval) + { + if (tag(jsval->d) == Kind::QV4ValuePtr) { + if (const QV4::Value *value = qv4ValuePtr(jsval->d)) + return QV4::PersistentValueStorage::getEngine(value); + } + + return nullptr; + } + + static bool checkEngine(QV4::ExecutionEngine *e, const QJSValue &jsval) + { + QV4::ExecutionEngine *v4 = engine(&jsval); + return !v4 || v4 == e; + } + + static void free(QJSValue *jsval) + { + switch (tag(jsval->d)) { + case Kind::Undefined: + case Kind::Null: + case Kind::IntValue: + case Kind::BoolValue: + return; + case Kind::DoublePtr: + delete doublePtr(jsval->d); + return; + case Kind::QStringPtr: + delete qStringPtr(jsval->d); + return; + case Kind::QV4ValuePtr: + break; + } + + // We need a mutable value for free(). It needs to write to the actual memory. + QV4::Value *m = qv4ValuePtr(jsval->d); + Q_ASSERT(m); // Otherwise it would have been undefined above. + if (QV4::ExecutionEngine *e = QV4::PersistentValueStorage::getEngine(m)) { + if (QJSEngine *jsEngine = e->jsEngine()) { + if (jsEngine->thread() != QThread::currentThread()) { + QMetaObject::invokeMethod( + jsEngine, [m](){ QV4::PersistentValueStorage::free(m); }); + return; + } + } + } + QV4::PersistentValueStorage::free(m); + } +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qjsvalueiterator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qjsvalueiterator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e2460da9bee307532385f7207834a9f9050654c3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qjsvalueiterator_p.h @@ -0,0 +1,43 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QJSVALUEITERATOR_P_H +#define QJSVALUEITERATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qjsvalue.h" +#include "private/qv4objectiterator_p.h" + +QT_BEGIN_NAMESPACE + +class QJSValueIteratorPrivate +{ +public: + QJSValueIteratorPrivate(const QJSValue &v); + + void init(const QJSValue &v); + bool isValid() const; + + void next(); + + QV4::ExecutionEngine *engine = nullptr; + QV4::PersistentValue object; + QScopedPointer<QV4::OwnPropertyKeyIterator> iterator; + QV4::PersistentValue currentKey; + QV4::PersistentValue nextKey; +}; + + +QT_END_NAMESPACE + +#endif // QJSVALUEITERATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qlazilyallocated_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qlazilyallocated_p.h new file mode 100644 index 0000000000000000000000000000000000000000..521b76514ae86b2a361ef219ce0cc0a49be6292b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qlazilyallocated_p.h @@ -0,0 +1,93 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QLAZILYALLOCATED_P_H +#define QLAZILYALLOCATED_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qtaggedpointer.h> + +QT_BEGIN_NAMESPACE + +template<typename T, typename Tag = typename QtPrivate::TagInfo<T>::TagType> +class QLazilyAllocated { +public: + inline QLazilyAllocated(); + inline ~QLazilyAllocated(); + + inline bool isAllocated() const; + + inline T *operator->() const; + + inline T &value(); + inline const T &value() const; + + inline Tag tag() const; + inline void setTag(Tag t); +private: + mutable QTaggedPointer<T, Tag> d; +}; + +template<typename T, typename Tag> +QLazilyAllocated<T, Tag>::QLazilyAllocated() +{ +} + +template<typename T, typename Tag> +QLazilyAllocated<T, Tag>::~QLazilyAllocated() +{ + delete d.data(); +} + +template<typename T, typename Tag> +bool QLazilyAllocated<T, Tag>::isAllocated() const +{ + return !d.isNull(); +} + +template<typename T, typename Tag> +T &QLazilyAllocated<T, Tag>::value() +{ + if (d.isNull()) d = new T; + return *d; +} + +template<typename T, typename Tag> +const T &QLazilyAllocated<T, Tag>::value() const +{ + if (d.isNull()) d = new T; + return *d; +} + +template<typename T, typename Tag> +T *QLazilyAllocated<T, Tag>::operator->() const +{ + return d.data(); +} + +template<typename T, typename Tag> +Tag QLazilyAllocated<T, Tag>::tag() const +{ + return d.tag(); +} + +template<typename T, typename Tag> +void QLazilyAllocated<T, Tag>::setTag(Tag t) +{ + d.setTag(t); +} + +QT_END_NAMESPACE + +#endif // QLAZILYALLOCATED_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qlinkedstringhash_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qlinkedstringhash_p.h new file mode 100644 index 0000000000000000000000000000000000000000..91ccb1a35dca4542ce7c359c5746140814c1a197 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qlinkedstringhash_p.h @@ -0,0 +1,202 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QLINKEDSTRINGHASH_P_H +#define QLINKEDSTRINGHASH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qstringhash_p.h> + +QT_BEGIN_NAMESPACE + +template<class T> +class QLinkedStringHash : private QStringHash<T> +{ +public: + using typename QStringHash<T>::Node; + using typename QStringHash<T>::NewedNode; + using typename QStringHash<T>::ReservedNodePool; + using typename QStringHash<T>::mapped_type; + + using ConstIteratorData = QStringHashData::IteratorData<const QLinkedStringHash>; + using ConstIterator = typename QStringHash<T>::template Iterator<ConstIteratorData, const T>; + + void linkAndReserve(const QLinkedStringHash<T> &other, int additionalReserve) + { + clear(); + + if (other.count()) { + data.size = other.data.size; + data.rehashToSize(other.count() + additionalReserve); + + if (data.numBuckets == other.data.numBuckets) { + nodePool = new ReservedNodePool; + nodePool->count = additionalReserve; + nodePool->used = 0; + nodePool->nodes = new Node[additionalReserve]; + + for (int ii = 0; ii < data.numBuckets; ++ii) + data.buckets[ii] = (Node *)other.data.buckets[ii]; + + link = &other; + return; + } + + data.size = 0; + } + + data.numBits = other.data.numBits; + reserve(other.count() + additionalReserve); + copy(other); + } + + inline bool isLinked() const + { + return link != 0; + } + + void clear() + { + QStringHash<T>::clear(); + link = nullptr; + } + + template<typename K> + void insert(const K &key, const T &value) + { + // If this is a linked hash, we can't rely on owning the node, so we always + // create a new one. + Node *n = link ? nullptr : QStringHash<T>::findNode(key); + if (n) + n->value = value; + else + QStringHash<T>::createNode(key, value); + } + + template<typename K> + inline ConstIterator find(const K &key) const + { + return iterator(QStringHash<T>::findNode(key)); + } + + ConstIterator begin() const + { + return ConstIterator( + QStringHash<T>::template iterateFirst<const QLinkedStringHash<T>, + ConstIteratorData>(this)); + } + + ConstIterator end() const { return ConstIterator(); } + + inline T *value(const ConstIterator &iter) { return value(iter.node()->key()); } + + using QStringHash<T>::value; + using QStringHash<T>::reserve; + using QStringHash<T>::copy; + +protected: + friend QStringHash<T>; + using QStringHash<T>::data; + using QStringHash<T>::nodePool; + + using QStringHash<T>::createNode; + + inline ConstIteratorData iterateFirst() const + { + const ConstIteratorData rv + = QStringHash<T>::template iterateFirst<const QLinkedStringHash<T>, + ConstIteratorData>(this); + return (rv.n == nullptr && link) ? link->iterateFirst() : rv; + } + + static inline ConstIteratorData iterateNext(const ConstIteratorData &d) + { + const QLinkedStringHash<T> *self = d.p; + const ConstIteratorData rv = QStringHash<T>::iterateNext(d); + return (rv.n == nullptr && self->link) ? self->link->iterateFirst() : rv; + } + + inline ConstIterator iterator(Node *n) const + { + if (!n) + return ConstIterator(); + + const QLinkedStringHash<T> *container = this; + + if (link) { + // This node could be in the linked hash + if ((n >= nodePool->nodes) && (n < (nodePool->nodes + nodePool->used))) { + // The node is in this hash + } else if ((n >= link->nodePool->nodes) + && (n < (link->nodePool->nodes + link->nodePool->used))) { + // The node is in the linked hash + container = link; + } else { + const NewedNode *ln = link->newedNodes; + while (ln) { + if (ln == n) { + // This node is in the linked hash's newed list + container = link; + break; + } + ln = ln->nextNewed; + } + } + } + + + ConstIteratorData rv; + rv.n = n; + rv.p = container; + return ConstIterator(rv); + } + + const QLinkedStringHash<T> *link = nullptr; +}; + +template<class T> +class QLinkedStringMultiHash : public QLinkedStringHash<T> +{ +public: + using ConstIterator = typename QLinkedStringHash<T>::ConstIterator; + + template<typename K> + inline void insert(const K &key, const T &value) + { + // Always create a new node + QLinkedStringHash<T>::createNode(key, value); + } + + inline void insert(const ConstIterator &iter) + { + // Always create a new node + QLinkedStringHash<T>::createNode(iter.key(), iter.value()); + } + + inline ConstIterator findNext(const ConstIterator &iter) const + { + if (auto *node = iter.node()) { + QHashedString key(node->key()); + while ((node = static_cast<typename QLinkedStringHash<T>::Node *>(node->next.data()))) { + if (node->equals(key)) + return QLinkedStringHash<T>::iterator(node); + } + } + + return ConstIterator(); + } +}; + +QT_END_NAMESPACE + +#endif // QLINKEDSTRINGHASH_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qml_compile_hash_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qml_compile_hash_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f887c9a8a4887f8b9a91de90604a79bb21a17f19 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qml_compile_hash_p.h @@ -0,0 +1,15 @@ +// Generated file, DO NOT EDIT + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#define QML_COMPILE_HASH "c6d701873e841e708b57faf8d319b3b2e89e4aa9" +#define QML_COMPILE_HASH_LENGTH 40 diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qparallelanimationgroupjob_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qparallelanimationgroupjob_p.h new file mode 100644 index 0000000000000000000000000000000000000000..845b9eca75da4821637840f68c4c882339354476 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qparallelanimationgroupjob_p.h @@ -0,0 +1,51 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPARALLELANIMATIONGROUPJOB_P_H +#define QPARALLELANIMATIONGROUPJOB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qanimationgroupjob_p.h" + +QT_REQUIRE_CONFIG(qml_animation); + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QParallelAnimationGroupJob : public QAnimationGroupJob +{ + Q_DISABLE_COPY(QParallelAnimationGroupJob) +public: + QParallelAnimationGroupJob(); + ~QParallelAnimationGroupJob(); + + int duration() const override; + +protected: + void updateCurrentTime(int currentTime) override; + void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override; + void updateDirection(QAbstractAnimationJob::Direction direction) override; + void uncontrolledAnimationFinished(QAbstractAnimationJob *animation) override; + void debugAnimation(QDebug d) const override; + +private: + bool shouldAnimationStart(QAbstractAnimationJob *animation, bool startIfAtEnd) const; + void applyGroupState(QAbstractAnimationJob *animation); + + //state + int m_previousLoop = 0; + int m_previousCurrentTime = 0; +}; + +QT_END_NAMESPACE + +#endif // QPARALLELANIMATIONGROUPJOB_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qpauseanimationjob_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qpauseanimationjob_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b13a95a29c18ac5affcc4ebc6444f3d235ab2f2f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qpauseanimationjob_p.h @@ -0,0 +1,45 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPAUSEANIMATIONJOB_P_H +#define QPAUSEANIMATIONJOB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qanimationgroupjob_p.h> + +QT_REQUIRE_CONFIG(qml_animation); + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QPauseAnimationJob : public QAbstractAnimationJob +{ + Q_DISABLE_COPY(QPauseAnimationJob) +public: + explicit QPauseAnimationJob(int duration = 250); + ~QPauseAnimationJob() override; + + int duration() const override; + void setDuration(int msecs); + +protected: + void updateCurrentTime(int) override; + void debugAnimation(QDebug d) const override; + +private: + //definition + int m_duration; +}; + +QT_END_NAMESPACE + +#endif // QPAUSEANIMATIONJOB_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qpodvector_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qpodvector_p.h new file mode 100644 index 0000000000000000000000000000000000000000..aa5341c2f6bcb6b673d93a51e040701daa15a171 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qpodvector_p.h @@ -0,0 +1,135 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPODVECTOR_P_H +#define QPODVECTOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> +#include <QDebug> + +QT_BEGIN_NAMESPACE + +template<class T, int Increment> +class QPODVector +{ +public: + QPODVector() + : m_count(0), m_capacity(0), m_data(nullptr) {} + ~QPODVector() { if (m_data) ::free(m_data); } + + const T &at(int idx) const { + return m_data[idx]; + } + + T &operator[](int idx) { + return m_data[idx]; + } + + void clear() { + m_count = 0; + } + + void prepend(const T &v) { + insert(0, v); + } + + void append(const T &v) { + insert(m_count, v); + } + + void insert(int idx, const T &v) { + if (m_count == m_capacity) { + m_capacity += Increment; + m_data = (T *)realloc(static_cast<void *>(m_data), m_capacity * sizeof(T)); + } + int moveCount = m_count - idx; + if (moveCount) + ::memmove(static_cast<void *>(m_data + idx + 1), static_cast<const void *>(m_data + idx), moveCount * sizeof(T)); + m_count++; + m_data[idx] = v; + } + + void reserve(int count) { + if (count >= m_capacity) { + m_capacity = (count + (Increment-1)) & (0xFFFFFFFF - Increment + 1); + m_data = (T *)realloc(static_cast<void *>(m_data), m_capacity * sizeof(T)); + } + } + + void insertBlank(int idx, int count) { + int newSize = m_count + count; + reserve(newSize); + int moveCount = m_count - idx; + if (moveCount) + ::memmove(static_cast<void *>(m_data + idx + count), static_cast<const void *>(m_data + idx), + moveCount * sizeof(T)); + m_count = newSize; + } + + void remove(int idx, int count = 1) { + int moveCount = m_count - (idx + count); + if (moveCount) + ::memmove(static_cast<void *>(m_data + idx), static_cast<const void *>(m_data + idx + count), + moveCount * sizeof(T)); + m_count -= count; + } + + void removeOne(const T &v) { + int idx = 0; + while (idx < m_count) { + if (m_data[idx] == v) { + remove(idx); + return; + } + ++idx; + } + } + + int find(const T &v) { + for (int idx = 0; idx < m_count; ++idx) + if (m_data[idx] == v) + return idx; + return -1; + } + + bool contains(const T &v) { + return find(v) != -1; + } + + int count() const { + return m_count; + } + + void copyAndClear(QPODVector<T,Increment> &other) { + if (other.m_data) ::free(other.m_data); + other.m_count = m_count; + other.m_capacity = m_capacity; + other.m_data = m_data; + m_count = 0; + m_capacity = 0; + m_data = nullptr; + } + + QPODVector<T,Increment> &operator<<(const T &v) { append(v); return *this; } +private: + QPODVector(const QPODVector &); + QPODVector &operator=(const QPODVector &); + int m_count; + int m_capacity; + T *m_data; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qprimefornumbits_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qprimefornumbits_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e28a667fe950318ca1dad2d75e0c9449f800eded --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qprimefornumbits_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QPRIMEFORNUMBITS_P_H +#define QPRIMEFORNUMBITS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> + +QT_BEGIN_NAMESPACE + +/* + The prime_deltas array is a table of selected prime values, even + though it doesn't look like one. The primes we are using are 1, + 2, 5, 11, 17, 37, 67, 131, 257, ..., i.e. primes in the immediate + surrounding of a power of two. + + The qPrimeForNumBits() function returns the prime associated to a + power of two. For example, qPrimeForNumBits(8) returns 257. +*/ + +inline int qPrimeForNumBits(int numBits) +{ + static constexpr const uchar prime_deltas[] = { + 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3, + 1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0 + }; + + return (1 << numBits) + prime_deltas[numBits]; +} + +QT_END_NAMESPACE + +#endif // QPRIMEFORNUMBITS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlabstractbinding_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlabstractbinding_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f584aadea90d6e9f0cdd3ba7fc3a92591ebbad2c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlabstractbinding_p.h @@ -0,0 +1,175 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLABSTRACTBINDING_P_H +#define QQMLABSTRACTBINDING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qsharedpointer.h> +#include <QtCore/qshareddata.h> +#include <private/qtqmlglobal_p.h> +#include <private/qqmlproperty_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlObjectCreator; +class QQmlAnyBinding; + +class Q_QML_EXPORT QQmlAbstractBinding +{ + friend class QQmlAnyBinding; +protected: + QQmlAbstractBinding(); +public: + enum Kind { + ValueTypeProxy, + QmlBinding, + PropertyToPropertyBinding, + }; + + virtual ~QQmlAbstractBinding(); + + typedef QExplicitlySharedDataPointer<QQmlAbstractBinding> Ptr; + + virtual QString expression() const; + + virtual Kind kind() const = 0; + + // Should return the encoded property index for the binding. Should return this value + // even if the binding is not enabled or added to an object. + // Encoding is: coreIndex | (valueTypeIndex << 16) + QQmlPropertyIndex targetPropertyIndex() const { return m_targetIndex; } + + // Should return the object for the binding. Should return this object even if the + // binding is not enabled or added to the object. + QObject *targetObject() const { return m_target.data(); } + + void setTarget(const QQmlProperty &); + bool setTarget(QObject *, const QQmlPropertyData &, const QQmlPropertyData *valueType); + bool setTarget(QObject *, int coreIndex, bool coreIsAlias, int valueTypeIndex); + + virtual void setEnabled(bool e, QQmlPropertyData::WriteFlags f = QQmlPropertyData::DontRemoveBinding) = 0; + + void addToObject(); + void removeFromObject(); + + virtual void printBindingLoopError(const QQmlProperty &prop); + + inline QQmlAbstractBinding *nextBinding() const; + + inline bool canUseAccessor() const + { return m_nextBinding.tag().testFlag(CanUseAccessor); } + void setCanUseAccessor(bool canUseAccessor) + { m_nextBinding.setTag(m_nextBinding.tag().setFlag(CanUseAccessor, canUseAccessor)); } + + struct RefCount { + RefCount() {} + int refCount = 0; + void ref() { ++refCount; } + int deref() { return --refCount; } + operator int() const { return refCount; } + }; + RefCount ref; + + enum TargetTag { + NoTargetTag = 0x0, + UpdatingBinding = 0x1, + BindingEnabled = 0x2 + }; + Q_DECLARE_FLAGS(TargetTags, TargetTag) + + enum NextBindingTag { + NoBindingTag = 0x0, + AddedToObject = 0x1, + CanUseAccessor = 0x2 + }; + Q_DECLARE_FLAGS(NextBindingTags, NextBindingTag) + +protected: + friend class QQmlData; + friend class QQmlValueTypeProxyBinding; + friend class QQmlObjectCreator; + + inline void setAddedToObject(bool v); + inline bool isAddedToObject() const; + + inline void setNextBinding(QQmlAbstractBinding *); + + void getPropertyData( + const QQmlPropertyData **propertyData, QQmlPropertyData *valueTypeData) const; + + inline bool updatingFlag() const; + inline void setUpdatingFlag(bool); + inline bool enabledFlag() const; + inline void setEnabledFlag(bool); + void updateCanUseAccessor(); + + QQmlPropertyIndex m_targetIndex; + + // Pointer is the target object to which the binding binds + QTaggedPointer<QObject, TargetTags> m_target; + + // Pointer to the next binding in the linked list of bindings. + QTaggedPointer<QQmlAbstractBinding, NextBindingTags> m_nextBinding; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlAbstractBinding::TargetTags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlAbstractBinding::NextBindingTags) + +void QQmlAbstractBinding::setAddedToObject(bool v) +{ + m_nextBinding.setTag(m_nextBinding.tag().setFlag(AddedToObject, v)); +} + +bool QQmlAbstractBinding::isAddedToObject() const +{ + return m_nextBinding.tag().testFlag(AddedToObject); +} + +QQmlAbstractBinding *QQmlAbstractBinding::nextBinding() const +{ + return m_nextBinding.data(); +} + +void QQmlAbstractBinding::setNextBinding(QQmlAbstractBinding *b) +{ + if (b) + b->ref.ref(); + if (m_nextBinding.data() && !m_nextBinding->ref.deref()) + delete m_nextBinding.data(); + m_nextBinding = b; +} + +bool QQmlAbstractBinding::updatingFlag() const +{ + return m_target.tag().testFlag(UpdatingBinding); +} + +void QQmlAbstractBinding::setUpdatingFlag(bool v) +{ + m_target.setTag(m_target.tag().setFlag(UpdatingBinding, v)); +} + +bool QQmlAbstractBinding::enabledFlag() const +{ + return m_target.tag().testFlag(BindingEnabled); +} + +void QQmlAbstractBinding::setEnabledFlag(bool v) +{ + m_target.setTag(m_target.tag().setFlag(BindingEnabled, v)); +} + +QT_END_NAMESPACE + +#endif // QQMLABSTRACTBINDING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlabstractprofileradapter_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlabstractprofileradapter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b5bb68e1bb8b7e10804aa804ce80516641e75281 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlabstractprofileradapter_p.h @@ -0,0 +1,85 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLABSTRACTPROFILERADAPTER_P_H +#define QQMLABSTRACTPROFILERADAPTER_P_H + +#include <private/qtqmlglobal_p.h> +#include <private/qqmlprofilerdefinitions_p.h> + +#include <QtCore/QObject> +#include <QtCore/QElapsedTimer> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +QT_REQUIRE_CONFIG(qml_debug); + +class QQmlProfilerService; +class Q_QML_EXPORT QQmlAbstractProfilerAdapter : public QObject, public QQmlProfilerDefinitions { + Q_OBJECT + +public: + static const int s_numMessagesPerBatch = 1000; + + QQmlAbstractProfilerAdapter(QObject *parent = nullptr) : + QObject(parent), service(nullptr), waiting(true), featuresEnabled(0) {} + ~QQmlAbstractProfilerAdapter() override {} + void setService(QQmlProfilerService *new_service) { service = new_service; } + + virtual qint64 sendMessages(qint64 until, QList<QByteArray> &messages) = 0; + + void startProfiling(quint64 features); + + void stopProfiling(); + + void reportData() { Q_EMIT dataRequested(); } + + void stopWaiting() { waiting = false; } + void startWaiting() { waiting = true; } + + bool isRunning() const { return featuresEnabled != 0; } + quint64 features() const { return featuresEnabled; } + + void synchronize(const QElapsedTimer &t) { Q_EMIT referenceTimeKnown(t); } + +Q_SIGNALS: + void profilingEnabled(quint64 features); + void profilingEnabledWhileWaiting(quint64 features); + + void profilingDisabled(); + void profilingDisabledWhileWaiting(); + + void dataRequested(); + void referenceTimeKnown(const QElapsedTimer &timer); + +protected: + QQmlProfilerService *service; + +private: + bool waiting; + quint64 featuresEnabled; +}; + +class Q_QML_EXPORT QQmlAbstractProfilerAdapterFactory : public QObject +{ + Q_OBJECT +public: + virtual QQmlAbstractProfilerAdapter *create(const QString &key) = 0; +}; + +#define QQmlAbstractProfilerAdapterFactory_iid "org.qt-project.Qt.QQmlAbstractProfilerAdapterFactory" + +QT_END_NAMESPACE + +#endif // QQMLABSTRACTPROFILERADAPTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlanybinding_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlanybinding_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2fa46b265001a71e9b5d93adde13496d76f927af --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlanybinding_p.h @@ -0,0 +1,473 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLANYBINDINGPTR_P_H +#define QQMLANYBINDINGPTR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qqmlproperty.h> +#include <private/qqmlpropertybinding_p.h> +#include <private/qqmlbinding_p.h> + +QT_BEGIN_NAMESPACE + +// Fully inline so that subsequent prop.isBindable check might get ellided. + +/*! + \internal + \brief QQmlAnyBinding is an abstraction over the various bindings in QML + + QQmlAnyBinding can store both classical bindings (derived from QQmlAbstractBinding) + as well as new-style bindings (derived from QPropertyBindingPrivate). For both, it keeps + a strong reference to them, and knows how to delete them in case the reference count + becomes zero. In that sense it can be thought of as a union of QUntypedPropertyBinding + and QQmlAbstractBinding::Ptr. + + It also offers methods to create bindings (from QV4::Function, from translation bindings + and from code strings). Moreover, it allows the retrieval, the removal and the + installation of bindings on a QQmlProperty. + + Note that the class intentionally does not allow construction from QUntypedProperty and + QQmlAbstractBinding::Ptr. This is meant to catch code which doesn't handle bindable properties + yet when porting existing code. + */ +class QQmlAnyBinding { +public: + + constexpr QQmlAnyBinding() noexcept = default; + QQmlAnyBinding(std::nullptr_t) : d(static_cast<QQmlAbstractBinding *>(nullptr)) {} + + /*! + \internal + Returns the binding of the property \a prop as a QQmlAnyBinding. + The binding continues to be active and set on the property. + If there was no binding set, the returned QQmlAnyBinding is null. + */ + static QQmlAnyBinding ofProperty(const QQmlProperty &prop) { + QQmlAnyBinding binding; + if (prop.isBindable()) { + QUntypedBindable bindable = prop.property().bindable(prop.object()); + binding = bindable.binding(); + } else { + binding = QQmlPropertyPrivate::binding(prop); + } + return binding; + } + + /*! + \overload + + \a object must be non-null + */ + static QQmlAnyBinding ofProperty(QObject *object, QQmlPropertyIndex index) + { + QQmlAnyBinding binding; + Q_ASSERT(object); + auto coreIndex = index.coreIndex(); + // we don't support bindable properties on value types so far + if (!index.hasValueTypeIndex() + && QQmlData::ensurePropertyCache(object)->property(coreIndex)->isBindable()) { + auto metaProp = object->metaObject()->property(coreIndex); + QUntypedBindable bindable = metaProp.bindable(object); + binding = bindable.binding(); + } else { + binding = QQmlPropertyPrivate::binding(object, index); + } + return binding; + } + + /*! + Removes the binding from the property \a prop, and returns it as a + QQmlAnyBinding if there was any. Otherwise returns a null + QQmlAnyBinding. + */ + static QQmlAnyBinding takeFrom(const QQmlProperty &prop) + { + QQmlAnyBinding binding; + if (prop.isBindable()) { + QUntypedBindable bindable = prop.property().bindable(prop.object()); + binding = bindable.takeBinding(); + } else { + auto qmlBinding = QQmlPropertyPrivate::binding(prop); + if (qmlBinding) { + binding = qmlBinding; // this needs to run before removeFromObject, else the refcount might reach zero + qmlBinding->setEnabled(false, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); + qmlBinding->removeFromObject(); + } + } + return binding; + } + + /*! + \internal + Creates a binding for property \a prop from \a function. + \a obj is the scope object which shall be used for the function and \a scope its QML scope. + The binding is not installed on the property (but if a QQmlBinding is created, it has its + target set to \a prop). + */ + static QQmlAnyBinding createFromFunction(const QQmlProperty &prop, QV4::Function *function, + QObject *obj, const QQmlRefPointer<QQmlContextData> &ctxt, + QV4::ExecutionContext *scope) + { + QQmlAnyBinding binding; + auto propPriv = QQmlPropertyPrivate::get(prop); + if (prop.isBindable()) { + auto index = QQmlPropertyIndex(propPriv->core.coreIndex(), -1); + binding = QQmlPropertyBinding::create(&propPriv->core, + function, obj, ctxt, + scope, prop.object(), index); + } else { + auto qmlBinding = QQmlBinding::create(&propPriv->core, function, obj, ctxt, scope); + qmlBinding->setTarget(prop); + binding = qmlBinding; + } + return binding; + } + + /*! + \internal + Creates a binding for property \a prop from \a script. + \a obj is the scope object which shall be used for the function and \a ctxt its QML scope. + The binding is not installed on the property (but if a QQmlBinding is created, it has its + target set to \a prop). + */ + static QQmlAnyBinding createFromScriptString(const QQmlProperty &prop, const QQmlScriptString &script, + QObject *obj, QQmlContext *ctxt) + { + QQmlAnyBinding binding; + auto propPriv = QQmlPropertyPrivate::get(prop); + if (prop.isBindable()) { + auto index = QQmlPropertyIndex(propPriv->core.coreIndex(), -1); + binding = QQmlPropertyBinding::createFromScriptString(&propPriv->core, script, obj, ctxt, prop.object(), index); + } else { + auto qmlBinding = QQmlBinding::create(&propPriv->core, script, obj, ctxt); + qmlBinding->setTarget(prop); + binding = qmlBinding; + } + return binding; + } + + + /*! + \internal + Removes the binding from \a prop if there is any. + */ + static void removeBindingFrom(QQmlProperty &prop) + { + if (prop.isBindable()) + prop.property().bindable(prop.object()).takeBinding(); + else + QQmlPropertyPrivate::removeBinding(prop); + } + + /*! + \internal + Creates a binding for property \a prop from \a function. + \a obj is the scope object which shall be used for the function and \a scope its QML scope. + The binding is not installed on the property (but if a QQmlBinding is created, it has its + target set to \a prop). + */ + static QQmlAnyBinding createFromCodeString(const QQmlProperty &prop, const QString& code, QObject *obj, const QQmlRefPointer<QQmlContextData> &ctxt, const QString &url, quint16 lineNumber) { + QQmlAnyBinding binding; + auto propPriv = QQmlPropertyPrivate::get(prop); + if (prop.isBindable()) { + auto index = QQmlPropertyIndex(propPriv->core.coreIndex(), -1); + binding = QQmlPropertyBinding::createFromCodeString(&propPriv->core, + code, obj, ctxt, + url, lineNumber, + prop.object(), index); + } else { + auto qmlBinding = QQmlBinding::create(&propPriv->core, code, obj, ctxt, url, lineNumber); + qmlBinding->setTarget(prop); + binding = qmlBinding; + } + return binding; + } + + /*! + \internal + Creates a translattion binding for \a prop from \a compilationUnit and \a transationBinding. + \a obj is the context object, \a context the qml context. + */ + static QQmlAnyBinding createTranslationBinding(const QQmlProperty &prop, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *translationBinding, QObject *scopeObject=nullptr, QQmlRefPointer<QQmlContextData> context={}) + { + QQmlAnyBinding binding; + auto propPriv = QQmlPropertyPrivate::get(prop); + if (prop.isBindable()) { + binding = QQmlTranslationPropertyBinding::create(&propPriv->core, compilationUnit, translationBinding); + } else { + auto qmlBinding = QQmlBinding::createTranslationBinding(compilationUnit, translationBinding, scopeObject, context); + binding = qmlBinding; + qmlBinding->setTarget(prop); + } + return binding; + } + + /*! + \internal + Installs the binding referenced by this QQmlAnyBinding on the target. + If \a mode is set to RespectInterceptors, interceptors are honored, otherwise + writes and binding installation bypass them (the default). + Preconditions: + - The binding is non-null. + - If the binding is QQmlAbstractBinding derived, the target is non-bindable. + - If the binding is a QUntypedPropertyBinding, then the target is bindable. + */ + enum InterceptorMode : bool { + IgnoreInterceptors, + RespectInterceptors + }; + + void installOn(const QQmlProperty &target, InterceptorMode mode = IgnoreInterceptors) + { + Q_ASSERT(!d.isNull()); + if (isAbstractPropertyBinding()) { + auto abstractBinding = asAbstractBinding(); + Q_ASSERT(abstractBinding->targetObject() == target.object() || QQmlPropertyPrivate::get(target)->core.isAlias()); + Q_ASSERT(!target.isBindable()); + if (mode == IgnoreInterceptors) + QQmlPropertyPrivate::setBinding(abstractBinding, QQmlPropertyPrivate::None, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); + else + QQmlPropertyPrivate::setBinding(abstractBinding); + } else { + Q_ASSERT(target.isBindable()); + QUntypedBindable bindable; + void *argv[] = {&bindable}; + if (mode == IgnoreInterceptors) { + target.object()->qt_metacall(QMetaObject::BindableProperty, target.index(), argv); + } else { + QMetaObject::metacall(target.object(), QMetaObject::BindableProperty, target.index(), argv); + } + bindable.setBinding(asUntypedPropertyBinding()); + } + } + + /*! + \internal + Returns true if the binding is in an error state (e.g. binding loop), false otherwise. + + \note For ValueTypeProxyBindings, this methods will always return false + */ + bool hasError() { + if (isAbstractPropertyBinding()) { + auto abstractBinding = asAbstractBinding(); + if (abstractBinding->kind() != QQmlAbstractBinding::QmlBinding) + return false; + return static_cast<QQmlBinding *>(abstractBinding)->hasError(); + } else { + return asUntypedPropertyBinding().error().hasError(); + } + } + + /*! + Stores a null binding. For purpose of classification, the null bindings is + treated as a QQmlAbstractPropertyBindings. + */ + QQmlAnyBinding &operator=(std::nullptr_t) + { + clear(); + return *this; + } + + operator bool() const{ + return !d.isNull(); + } + + /*! + \internal + Returns true if a binding derived from QQmlAbstractPropertyBinding is stored. + The binding migh still be null. + */ + bool isAbstractPropertyBinding() const + { return d.isT1(); } + + /*! + \internal + Returns true if a binding derived from QPropertyBindingPrivate is stored. + The binding might still be null. + */ + bool isUntypedPropertyBinding() const + { return d.isT2(); } + + /*! + \internal + Returns the stored QPropertyBindingPrivate as a QUntypedPropertyBinding. + If no such binding is currently stored, a null QUntypedPropertyBinding is returned. + */ + QUntypedPropertyBinding asUntypedPropertyBinding() const + { + if (d.isT1() || d.isNull()) + return {}; + auto priv = d.asT2(); + return QUntypedPropertyBinding {priv}; + } + + /*! + \internal + Returns the stored QQmlAbstractBinding. + If no such binding is currently stored, a null pointer is returned. + */ + QQmlAbstractBinding *asAbstractBinding() const + { + if (d.isT2() || d.isNull()) + return nullptr; + return d.asT1(); + } + + /*! + \internal + Reevaluates the binding. If the binding was disabled, + it gets enabled. + */ + void refresh() + { + if (d.isNull()) + return; + if (d.isT1()) { + auto binding = static_cast<QQmlBinding *>(d.asT1()); + binding->setEnabledFlag(true); + binding->refresh(); + } else { + auto bindingPriv = d.asT2(); + PendingBindingObserverList bindingObservers; + bindingPriv->evaluateRecursive(bindingObservers); + bindingPriv->notifyNonRecursive(bindingObservers); + } + + } + + /*! + \internal + Stores \a binding and keeps a reference to it. + */ + QQmlAnyBinding &operator=(QQmlAbstractBinding *binding) + { + clear(); + if (binding) { + d = binding; + binding->ref.ref(); + } + return *this; + } + + /*! + \internal + Stores the binding stored in \a binding and keeps a reference to it. + */ + QQmlAnyBinding &operator=(const QQmlAbstractBinding::Ptr &binding) + { + clear(); + if (binding) { + d = binding.data(); + binding->ref.ref(); + } + return *this; + } + + /*! + \internal + Stores \a binding's binding, taking ownership from \a binding. + */ + QQmlAnyBinding &operator=(QQmlAbstractBinding::Ptr &&binding) + { + clear(); + if (binding) { + d = binding.take(); + } + return *this; + } + + /*! + \internal + Stores the binding stored in \a untypedBinding and keeps a reference to it. + */ + QQmlAnyBinding &operator=(const QUntypedPropertyBinding &untypedBinding) + { + clear(); + auto binding = QPropertyBindingPrivate::get(untypedBinding); + if (binding) { + d = binding; + binding->addRef(); + } + return *this; + } + + /*! + \internal + \overload + Stores the binding stored in \a untypedBinding, taking ownership from it. + */ + QQmlAnyBinding &operator=(QUntypedPropertyBinding &&untypedBinding) + { + clear(); + auto binding = QPropertyBindingPrivate::get(untypedBinding); + QPropertyBindingPrivatePtr ptr(binding); + if (binding) { + d = static_cast<QPropertyBindingPrivate *>(ptr.take()); + } + return *this; + } + + QQmlAnyBinding(QQmlAnyBinding &&other) noexcept + : d(std::exchange(other.d, QBiPointer<QQmlAbstractBinding, QPropertyBindingPrivate>())) + {} + + QQmlAnyBinding(const QQmlAnyBinding &other) noexcept { *this = other; } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QQmlAnyBinding) + + void swap(QQmlAnyBinding &other) noexcept { d.swap(other.d); } + friend void swap(QQmlAnyBinding &lhs, QQmlAnyBinding &rhs) noexcept { lhs.swap(rhs); } + + QQmlAnyBinding &operator=(const QQmlAnyBinding &other) noexcept + { + clear(); + if (auto abstractBinding = other.asAbstractBinding()) + *this = abstractBinding; + else if (auto untypedBinding = other.asUntypedPropertyBinding(); !untypedBinding.isNull()) + *this = untypedBinding; + return *this; + } + + friend inline bool operator==(const QQmlAnyBinding &p1, const QQmlAnyBinding &p2) + { + return p1.d == p2.d; + } + + friend inline bool operator!=(const QQmlAnyBinding &p1, const QQmlAnyBinding &p2) + { + return p1.d != p2.d; + } + + ~QQmlAnyBinding() noexcept { clear(); } +private: + void clear() noexcept { + if (d.isNull()) + return; + if (d.isT1()) { + QQmlAbstractBinding *qqmlptr = d.asT1(); + if (!qqmlptr->ref.deref()) + delete qqmlptr; + } else if (d.isT2()) { + QPropertyBindingPrivate *priv = d.asT2(); + if (!priv->deref()) + QPropertyBindingPrivate::destroyAndFreeMemory(priv); + } + d = static_cast<QQmlAbstractBinding *>(nullptr); + } + QBiPointer<QQmlAbstractBinding, QPropertyBindingPrivate> d; +}; + +QT_END_NAMESPACE + + +#endif // QQMLANYBINDINGPTR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlapplicationengine_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlapplicationengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..30caebbda804a759a7835b868470194812250784 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlapplicationengine_p.h @@ -0,0 +1,54 @@ +// Copyright (C) 2016 Research In Motion. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLAPPLICATIONENGINE_P_H +#define QQMLAPPLICATIONENGINE_P_H + +#include "qqmlapplicationengine.h" +#include "qqmlengine_p.h" +#include <QCoreApplication> +#include <QFileInfo> +#include <QLibraryInfo> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QFileSelector; +class Q_QML_EXPORT QQmlApplicationEnginePrivate : public QQmlEnginePrivate +{ + Q_DECLARE_PUBLIC(QQmlApplicationEngine) +public: + QQmlApplicationEnginePrivate(QQmlEngine *e); + ~QQmlApplicationEnginePrivate(); + void ensureInitialized(); + void init(); + void cleanUp(); + + void startLoad(const QUrl &url, const QByteArray &data = QByteArray(), bool dataFlag = false); + void startLoad(QAnyStringView uri, QAnyStringView type); + void _q_loadTranslations(); + void finishLoad(QQmlComponent *component); + void ensureLoadingFinishes(QQmlComponent *component); + QList<QObject *> objects; + QVariantMap initialProperties; + QStringList extraFileSelectors; + QString translationsDirectory; +#if QT_CONFIG(translation) + std::unique_ptr<QTranslator> activeTranslator; +#endif + bool isInitialized = false; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlbinding_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlbinding_p.h new file mode 100644 index 0000000000000000000000000000000000000000..28c74fe3ba5f46ca9c7cc8243144cb535b87cd37 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlbinding_p.h @@ -0,0 +1,139 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLBINDING_P_H +#define QQMLBINDING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlproperty.h" +#include "qqmlscriptstring.h" + +#include <QtCore/QObject> +#include <QtCore/QMetaProperty> + +#include <private/qqmlabstractbinding_p.h> +#include <private/qqmljavascriptexpression_p.h> +#include <private/qv4functionobject_p.h> +#include <private/qqmltranslation_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlContext; +class Q_QML_EXPORT QQmlBinding : public QQmlJavaScriptExpression, + public QQmlAbstractBinding +{ + friend class QQmlAbstractBinding; +public: + typedef QExplicitlySharedDataPointer<QQmlBinding> Ptr; + + static QQmlBinding *create(const QQmlPropertyData *, const QQmlScriptString &, QObject *, QQmlContext *); + + static QQmlBinding *create( + const QQmlPropertyData *, const QString &, QObject *, + const QQmlRefPointer<QQmlContextData> &, const QString &url = QString(), + quint16 lineNumber = 0); + + static QQmlBinding *create( + const QQmlPropertyData *property, QV4::Function *function, QObject *obj, + const QQmlRefPointer<QQmlContextData> &ctxt, QV4::ExecutionContext *scope); + + static QQmlBinding *create(QMetaType propertyType, QV4::Function *function, QObject *obj, + const QQmlRefPointer<QQmlContextData> &ctxt, + QV4::ExecutionContext *scope); + + static QQmlBinding *createTranslationBinding( + const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit, + const QV4::CompiledData::Binding *binding, QObject *obj, + const QQmlRefPointer<QQmlContextData> &ctxt); + + static QQmlBinding * + createTranslationBinding(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit, + const QQmlRefPointer<QQmlContextData> &ctxt, + const QString &propertyName, const QQmlTranslation &translationData, + const QQmlSourceLocation &location, QObject *obj); + + Kind kind() const final { return QQmlAbstractBinding::QmlBinding; } + + ~QQmlBinding() override; + + bool mustCaptureBindableProperty() const final {return true;} + void refresh() override; + + void setEnabled(bool, QQmlPropertyData::WriteFlags flags = QQmlPropertyData::DontRemoveBinding) override; + QString expression() const override; + void update(QQmlPropertyData::WriteFlags flags = QQmlPropertyData::DontRemoveBinding); + + void printBindingLoopError(const QQmlProperty &prop) override; + + typedef int Identifier; + enum { + Invalid = -1 + }; + + QVariant evaluate(); + bool evaluate(void *result, QMetaType type) + { + return QQmlJavaScriptExpression::evaluate(&result, &type, 0); + } + + void expressionChanged() override; + + QQmlSourceLocation sourceLocation() const override; + void setSourceLocation(const QQmlSourceLocation &location); + void setBoundFunction(QV4::BoundFunction *boundFunction) { + m_boundFunction.set(boundFunction->engine(), *boundFunction); + } + bool hasBoundFunction() const { return m_boundFunction.valueRef(); } + + /** + * This method returns a snapshot of the currently tracked dependencies of + * this binding. The dependencies can change upon reevaluation. This method is + * used in GammaRay to visualize binding hierarchies. + * + * Call this method from the UI thread. + */ + QVector<QQmlProperty> dependencies() const; + // This method is used internally to check whether a binding is constant and can be removed + virtual bool hasDependencies() const; + +protected: + virtual void doUpdate(const DeleteWatcher &watcher, + QQmlPropertyData::WriteFlags flags, QV4::Scope &scope); + + virtual bool write(const QV4::Value &result, bool isUndefined, QQmlPropertyData::WriteFlags flags) = 0; + virtual bool write(void *result, QMetaType type, bool isUndefined, QQmlPropertyData::WriteFlags flags) = 0; + + int getPropertyType() const; + + bool slowWrite(const QQmlPropertyData &core, const QQmlPropertyData &valueTypeData, + const QV4::Value &result, bool isUndefined, QQmlPropertyData::WriteFlags flags); + bool slowWrite(const QQmlPropertyData &core, const QQmlPropertyData &valueTypeData, + const void *result, QMetaType resultType, bool isUndefined, + QQmlPropertyData::WriteFlags flags); + + QV4::ReturnedValue evaluate(bool *isUndefined); + +private: + static QQmlBinding *newBinding(const QQmlPropertyData *property); + static QQmlBinding *newBinding(QMetaType propertyType); + + QQmlSourceLocation *m_sourceLocation = nullptr; // used for Qt.binding() created functions + QV4::PersistentValue m_boundFunction; // used for Qt.binding() that are created from a bound function object + void handleWriteError(const void *result, QMetaType resultType, QMetaType metaType); +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QQmlBinding*) + +#endif // QQMLBINDING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlboundsignal_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlboundsignal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..252e84eb2a5d15bd39bccb1fe825c414434c38b5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlboundsignal_p.h @@ -0,0 +1,105 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLBOUNDSIGNAL_P_H +#define QQMLBOUNDSIGNAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qmetaobject.h> + +#include <private/qqmljavascriptexpression_p.h> +#include <private/qqmlnotifier_p.h> +#include <private/qqmlrefcount_p.h> +#include <private/qtqmlglobal_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlBoundSignalExpression final + : public QQmlJavaScriptExpression, + public QQmlRefCounted<QQmlBoundSignalExpression> +{ + friend class QQmlRefCounted<QQmlBoundSignalExpression>; +public: + QQmlBoundSignalExpression( + const QObject *target, int index, const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope, + const QString &expression, const QString &fileName, quint16 line, quint16 column, + const QString &handlerName = QString(), const QString ¶meterString = QString()); + + QQmlBoundSignalExpression( + const QObject *target, int index, const QQmlRefPointer<QQmlContextData> &ctxt, + QObject *scopeObject, QV4::Function *function, QV4::ExecutionContext *scope = nullptr); + + // inherited from QQmlJavaScriptExpression. + QString expressionIdentifier() const override; + void expressionChanged() override; + + // evaluation of a bound signal expression doesn't return any value + void evaluate(void **a); + + bool mustCaptureBindableProperty() const final {return true;} + + QString expression() const; + const QObject *target() const { return m_target; } + +private: + ~QQmlBoundSignalExpression() override; + + void init(const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope); + + bool expressionFunctionValid() const { return function() != nullptr; } + + int m_index; + const QObject *m_target; +}; + +class Q_QML_EXPORT QQmlBoundSignal : public QQmlNotifierEndpoint +{ +public: + QQmlBoundSignal(QObject *target, int signal, QObject *owner, QQmlEngine *engine); + ~QQmlBoundSignal(); + + void removeFromObject(); + + QQmlBoundSignalExpression *expression() const; + void takeExpression(QQmlBoundSignalExpression *); + + void setEnabled(bool enabled); + +private: + friend void QQmlBoundSignal_callback(QQmlNotifierEndpoint *, void **); + friend class QQmlPropertyPrivate; + friend class QQmlData; + friend class QQmlEngineDebugService; + + void addToObject(QObject *owner); + + QQmlBoundSignal **m_prevSignal; + QQmlBoundSignal *m_nextSignal; + + bool m_enabled; + + QQmlRefPointer<QQmlBoundSignalExpression> m_expression; +}; + +class QQmlPropertyObserver : public QPropertyObserver +{ +public: + QQmlPropertyObserver(QQmlBoundSignalExpression *expr); + +private: + QQmlRefPointer<QQmlBoundSignalExpression> expression; +}; + +QT_END_NAMESPACE + +#endif // QQMLBOUNDSIGNAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlbuiltinfunctions_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlbuiltinfunctions_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2a9a750b8d1ddbae8f04983e1731de956c74c1e9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlbuiltinfunctions_p.h @@ -0,0 +1,267 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLBUILTINFUNCTIONS_P_H +#define QQMLBUILTINFUNCTIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qjsengine_p.h> +#include <private/qqmlglobal_p.h> +#include <private/qqmlplatform_p.h> +#include <private/qv4functionobject_p.h> + +#include <QtCore/qnamespace.h> +#include <QtCore/qdatetime.h> +#include <QtCore/qsize.h> +#include <QtCore/qrect.h> +#include <QtCore/qpoint.h> + +#include <QtQml/qqmlcomponent.h> +#include <QtQml/qqmlengine.h> + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QtObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlApplication *application READ application CONSTANT) + Q_PROPERTY(QQmlPlatform *platform READ platform CONSTANT) + Q_PROPERTY(QObject *inputMethod READ inputMethod CONSTANT) + Q_PROPERTY(QObject *styleHints READ styleHints CONSTANT) + +#if QT_CONFIG(translation) + Q_PROPERTY(QString uiLanguage READ uiLanguage WRITE setUiLanguage BINDABLE uiLanguageBindable) +#endif + + QML_NAMED_ELEMENT(Qt) + QML_SINGLETON + QML_EXTENDED_NAMESPACE(Qt) + + Q_CLASSINFO("QML.StrictArguments", "true") + +public: + enum LoadingMode { Asynchronous = 0, Synchronous = 1 }; + Q_ENUM(LoadingMode); + + static QtObject *create(QQmlEngine *, QJSEngine *jsEngine); + + Q_INVOKABLE QJSValue include(const QString &url, const QJSValue &callback = QJSValue()) const; + Q_INVOKABLE bool isQtObject(const QJSValue &value) const; + + Q_INVOKABLE QVariant color(const QString &name) const; + Q_INVOKABLE QVariant rgba(double r, double g, double b, double a = 1) const; + Q_INVOKABLE QVariant hsla(double h, double s, double l, double a = 1) const; + Q_INVOKABLE QVariant hsva(double h, double s, double v, double a = 1) const; + Q_INVOKABLE bool colorEqual(const QVariant &lhs, const QVariant &rhs) const; + + Q_INVOKABLE QRectF rect(double x, double y, double width, double height) const; + Q_INVOKABLE QPointF point(double x, double y) const; + Q_INVOKABLE QSizeF size(double width, double height) const; + Q_INVOKABLE QVariant vector2d(double x, double y) const; + Q_INVOKABLE QVariant vector3d(double x, double y, double z) const; + Q_INVOKABLE QVariant vector4d(double x, double y, double z, double w) const; + Q_INVOKABLE QVariant quaternion(double scalar, double x, double y, double z) const; + + Q_INVOKABLE QVariant matrix4x4() const; + Q_INVOKABLE QVariant matrix4x4(double m11, double m12, double m13, double m14, + double m21, double m22, double m23, double m24, + double m31, double m32, double m33, double m34, + double m41, double m42, double m43, double m44) const; + Q_INVOKABLE QVariant matrix4x4(const QJSValue &value) const; + + Q_INVOKABLE QVariant lighter(const QJSValue &color, double factor = 1.5) const; + Q_INVOKABLE QVariant darker(const QJSValue &color, double factor = 2.0) const; + Q_INVOKABLE QVariant alpha(const QJSValue &baseColor, double value) const; + Q_INVOKABLE QVariant tint(const QJSValue &baseColor, const QJSValue &tintColor) const; + + Q_INVOKABLE QString formatDate(QDate date, const QString &format) const; + Q_INVOKABLE QString formatDate(const QDateTime &dateTime, const QString &format) const; + Q_INVOKABLE QString formatDate(const QString &string, const QString &format) const; + Q_INVOKABLE QString formatDate(QDate date, Qt::DateFormat format) const; + Q_INVOKABLE QString formatDate(const QDateTime &dateTime, Qt::DateFormat format) const; + Q_INVOKABLE QString formatDate(const QString &string, Qt::DateFormat format) const; + + Q_INVOKABLE QString formatTime(QTime time, const QString &format) const; + Q_INVOKABLE QString formatTime(const QDateTime &dateTime, const QString &format) const; + Q_INVOKABLE QString formatTime(const QString &time, const QString &format) const; + Q_INVOKABLE QString formatTime(QTime time, Qt::DateFormat format) const; + Q_INVOKABLE QString formatTime(const QDateTime &dateTime, Qt::DateFormat format) const; + Q_INVOKABLE QString formatTime(const QString &time, Qt::DateFormat format) const; + + Q_INVOKABLE QString formatDateTime(const QDateTime &date, const QString &format) const; + Q_INVOKABLE QString formatDateTime(const QString &string, const QString &format) const; + Q_INVOKABLE QString formatDateTime(const QDateTime &date, Qt::DateFormat format) const; + Q_INVOKABLE QString formatDateTime(const QString &string, Qt::DateFormat format) const; + +#if QT_CONFIG(qml_locale) + Q_INVOKABLE QString formatDate(QDate date, const QLocale &locale = QLocale(), + QLocale::FormatType formatType = QLocale::ShortFormat) const; + Q_INVOKABLE QString formatDate(const QDateTime &dateTime, const QLocale &locale = QLocale(), + QLocale::FormatType formatType = QLocale::ShortFormat) const; + Q_INVOKABLE QString formatDate(const QString &string, const QLocale &locale = QLocale(), + QLocale::FormatType formatType = QLocale::ShortFormat) const; + Q_INVOKABLE QString formatTime(QTime time, const QLocale &locale = QLocale(), + QLocale::FormatType formatType = QLocale::ShortFormat) const; + Q_INVOKABLE QString formatTime(const QDateTime &dateTime, const QLocale &locale = QLocale(), + QLocale::FormatType formatType = QLocale::ShortFormat) const; + Q_INVOKABLE QString formatTime(const QString &time, const QLocale &locale = QLocale(), + QLocale::FormatType formatType = QLocale::ShortFormat) const; + Q_INVOKABLE QString formatDateTime(const QDateTime &date, const QLocale &locale = QLocale(), + QLocale::FormatType formatType = QLocale::ShortFormat) const; + Q_INVOKABLE QString formatDateTime(const QString &string, const QLocale &locale = QLocale(), + QLocale::FormatType formatType = QLocale::ShortFormat) const; + Q_INVOKABLE QLocale locale() const; + Q_INVOKABLE QLocale locale(const QString &name) const; +#endif + + Q_INVOKABLE QUrl url(const QUrl &url) const; + Q_INVOKABLE QUrl resolvedUrl(const QUrl &url) const; + Q_INVOKABLE QUrl resolvedUrl(const QUrl &url, QObject *context) const; + Q_INVOKABLE bool openUrlExternally(const QUrl &url) const; + + Q_INVOKABLE QVariant font(const QJSValue &fontSpecifier) const; + Q_INVOKABLE QStringList fontFamilies() const; + + Q_INVOKABLE QString md5(const QString &data) const; + Q_INVOKABLE QString btoa(const QString &data) const; + Q_INVOKABLE QString atob(const QString &data) const; + + Q_INVOKABLE void quit() const; + Q_INVOKABLE void exit(int retCode) const; + + Q_INVOKABLE QObject *createQmlObject(const QString &qml, QObject *parent, + const QUrl &url = QUrl(QStringLiteral("inline"))) const; + Q_INVOKABLE QQmlComponent *createComponent(const QUrl &url, QObject *parent) const; + Q_INVOKABLE QQmlComponent *createComponent( + const QUrl &url, QQmlComponent::CompilationMode mode = QQmlComponent::PreferSynchronous, + QObject *parent = nullptr) const; + + Q_INVOKABLE QQmlComponent *createComponent(const QString &moduleUri, + const QString &typeName, QObject *parent) const; + Q_INVOKABLE QQmlComponent *createComponent(const QString &moduleUri, const QString &typeName, + QQmlComponent::CompilationMode mode = QQmlComponent::PreferSynchronous, + QObject *parent = nullptr) const; + + Q_INVOKABLE QJSValue binding(const QJSValue &function) const; + Q_INVOKABLE void callLater(QQmlV4FunctionPtr args); + +#if QT_CONFIG(translation) + QString uiLanguage() const; + void setUiLanguage(const QString &uiLanguage); + QBindable<QString> uiLanguageBindable(); +#endif + + // Not const because created on first use, and parented to this. + QQmlPlatform *platform(); + QQmlApplication *application(); + + QObject *inputMethod() const; + QObject *styleHints() const; + +private: + friend struct QV4::ExecutionEngine; + + QtObject(QV4::ExecutionEngine *engine); + + QQmlEngine *qmlEngine() const { return m_engine->qmlEngine(); } + QJSEngine *jsEngine() const { return m_engine->jsEngine(); } + QV4::ExecutionEngine *v4Engine() const { return m_engine; } + + struct Contexts { + QQmlRefPointer<QQmlContextData> context; + QQmlRefPointer<QQmlContextData> effectiveContext; + }; + Contexts getContexts() const; + + QQmlPlatform *m_platform = nullptr; + QQmlApplication *m_application = nullptr; + + QV4::ExecutionEngine *m_engine = nullptr; +}; + +namespace QV4 { + +namespace Heap { + +struct ConsoleObject : Object { + void init(); +}; + +#define QQmlBindingFunctionMembers(class, Member) \ + Member(class, Pointer, JavaScriptFunctionObject *, bindingFunction) +DECLARE_HEAP_OBJECT(QQmlBindingFunction, JavaScriptFunctionObject) { + DECLARE_MARKOBJECTS(QQmlBindingFunction) + void init(const QV4::JavaScriptFunctionObject *bindingFunction); +}; + +} + +struct ConsoleObject : Object +{ + V4_OBJECT2(ConsoleObject, Object) + + static ReturnedValue method_error(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_log(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_info(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_profile(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_profileEnd(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_time(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_timeEnd(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_count(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_trace(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_warn(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_assert(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_exception(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + +}; + +struct Q_QML_EXPORT GlobalExtensions { + static void init(Object *globalObject, QJSEngine::Extensions extensions); + +#if QT_CONFIG(translation) + static QString currentTranslationContext(ExecutionEngine *engine); + static ReturnedValue method_qsTranslate(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_qsTranslateNoOp(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_qsTr(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_qsTrNoOp(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_qsTrId(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_qsTrIdNoOp(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); +#endif + static ReturnedValue method_gc(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + + // on String:prototype + static ReturnedValue method_string_arg(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + +}; + +struct QQmlBindingFunction : public QV4::JavaScriptFunctionObject +{ + V4_OBJECT2(QQmlBindingFunction, JavaScriptFunctionObject) + + static ReturnedValue virtualCall( + const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + + Heap::JavaScriptFunctionObject *bindingFunction() const { return d()->bindingFunction; } + QQmlSourceLocation currentLocation() const; // from caller stack trace +}; + +inline bool FunctionObject::isBinding() const +{ + return d()->vtable() == QQmlBindingFunction::staticVTable(); +} + +} + +QT_END_NAMESPACE + +#endif // QQMLBUILTINFUNCTIONS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlbuiltins_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlbuiltins_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a2aead1b60e861f9b37eeff863297a915617324d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlbuiltins_p.h @@ -0,0 +1,557 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLBUILTINS_H +#define QQMLBUILTINS_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlcomponentattached_p.h> + +#include <QtQml/qjsvalue.h> +#include <QtQml/qqmlcomponent.h> +#include <QtQml/qqmlscriptstring.h> + +#include <QtQmlIntegration/qqmlintegration.h> + +#include <QtCore/qobject.h> +#include <QtCore/qglobal.h> +#include <QtCore/qtmetamacros.h> +#include <QtCore/qmetaobject.h> +#include <QtCore/qdatetime.h> +#include <QtCore/qstring.h> +#include <QtCore/qurl.h> +#include <QtCore/qvariantmap.h> +#include <QtCore/qtypes.h> +#include <QtCore/qchar.h> +#include <QtCore/qjsonobject.h> +#include <QtCore/qjsonvalue.h> +#include <QtCore/qjsonarray.h> + +#include <climits> + +#if QT_CONFIG(regularexpression) +#include <QtCore/qregularexpression.h> +#endif + +QT_BEGIN_NAMESPACE + +// moc doesn't do 64bit constants, so we have to determine the size of qsizetype indirectly. +// We assume that qsizetype is always the same size as a pointer. I haven't seen a platform +// where this is not the case. +// Furthermore moc is wrong about pretty much everything on 64bit windows. We need to hardcode +// the size there. +// Likewise, we also have to determine the size of long and ulong indirectly. + +#if defined(Q_OS_WIN64) + +static_assert(sizeof(long) == 4); +#define QML_LONG_IS_32BIT +static_assert(sizeof(qsizetype) == 8); +#define QML_SIZE_IS_64BIT + +#elif QT_POINTER_SIZE == 4 + +static_assert(sizeof(long) == 4); +#define QML_LONG_IS_32BIT +static_assert(sizeof(qsizetype) == 4); +#define QML_SIZE_IS_32BIT + +#else + +static_assert(sizeof(long) == 8); +#define QML_LONG_IS_64BIT +static_assert(sizeof(qsizetype) == 8); +#define QML_SIZE_IS_64BIT + +#endif + +#define QML_EXTENDED_JAVASCRIPT(EXTENDED_TYPE) \ + Q_CLASSINFO("QML.Extended", #EXTENDED_TYPE) \ + Q_CLASSINFO("QML.ExtensionIsJavaScript", "true") + +template<typename A> struct QQmlPrimitiveAliasFriend {}; + +#define QML_PRIMITIVE_ALIAS(PRIMITIVE_ALIAS) \ + Q_CLASSINFO("QML.PrimitiveAlias", #PRIMITIVE_ALIAS) \ + friend QQmlPrimitiveAliasFriend<PRIMITIVE_ALIAS>; + +struct QQmlVoidForeign +{ + Q_GADGET + QML_VALUE_TYPE(void) + QML_EXTENDED_JAVASCRIPT(undefined) +#if !QT_CONFIG(regularexpression) + QML_VALUE_TYPE(regexp) +#endif + QML_FOREIGN(void) +}; + +struct QQmlVarForeign +{ + Q_GADGET + QML_VALUE_TYPE(var) + QML_VALUE_TYPE(variant) + QML_FOREIGN(QVariant) + QML_EXTENDED(QQmlVarForeign) +}; + +struct QQmlQtObjectForeign +{ + Q_GADGET + QML_NAMED_ELEMENT(QtObject) + QML_EXTENDED_JAVASCRIPT(Object) + QML_FOREIGN(QObject) + Q_CLASSINFO("QML.Root", "true") +}; + +struct QQmlIntForeign +{ + Q_GADGET + QML_VALUE_TYPE(int) + QML_EXTENDED_JAVASCRIPT(Number) + QML_FOREIGN(int) +#ifdef QML_SIZE_IS_32BIT + // Keep qsizetype as primitive alias. We want it as separate type. + QML_PRIMITIVE_ALIAS(qsizetype) +#endif +}; + +struct QQmlQint32Foreign +{ + Q_GADGET + QML_FOREIGN(qint32) + QML_USING(int) +}; + +struct QQmlInt32TForeign +{ + Q_GADGET + QML_FOREIGN(int32_t) + QML_USING(int) +}; + +struct QQmlDoubleForeign +{ + Q_GADGET + QML_VALUE_TYPE(real) + QML_VALUE_TYPE(double) + QML_EXTENDED_JAVASCRIPT(Number) + QML_FOREIGN(double) +}; + +struct QQmlStringForeign +{ + Q_GADGET + QML_VALUE_TYPE(string) + QML_EXTENDED_JAVASCRIPT(String) + QML_FOREIGN(QString) +}; + +struct QQmlAnyStringViewForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED_JAVASCRIPT(String) + QML_FOREIGN(QAnyStringView) +}; + +struct QQmlBoolForeign +{ + Q_GADGET + QML_VALUE_TYPE(bool) + QML_EXTENDED_JAVASCRIPT(Boolean) + QML_FOREIGN(bool) +}; + +struct QQmlDateForeign +{ + Q_GADGET + QML_VALUE_TYPE(date) + QML_EXTENDED_JAVASCRIPT(Date) + QML_FOREIGN(QDateTime) +}; + +struct QQmlUrlForeign +{ + Q_GADGET + QML_VALUE_TYPE(url) + QML_EXTENDED_JAVASCRIPT(URL) + QML_FOREIGN(QUrl) +}; + +#if QT_CONFIG(regularexpression) +struct QQmlRegexpForeign +{ + Q_GADGET + QML_VALUE_TYPE(regexp) + QML_EXTENDED_JAVASCRIPT(RegExp) + QML_FOREIGN(QRegularExpression) +}; +#endif + +struct QQmlNullForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(std::nullptr_t) + QML_EXTENDED(QQmlNullForeign) +}; + +struct QQmlQVariantMapForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QVariantMap) + QML_EXTENDED_JAVASCRIPT(Object) +}; + +struct QQmlQint8Foreign +{ + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED_JAVASCRIPT(Number) + QML_FOREIGN(qint8) +}; + +struct QQmlInt8TForeign +{ + Q_GADGET + QML_FOREIGN(int8_t) + QML_USING(qint8) +}; + +struct QQmlQuint8Foreign +{ + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED_JAVASCRIPT(Number) + QML_FOREIGN(quint8) +}; + +struct QQmlUint8TForeign +{ + Q_GADGET + QML_FOREIGN(uint8_t) + QML_USING(quint8) +}; + +struct QQmlUcharForeign +{ + Q_GADGET + QML_FOREIGN(uchar) + QML_USING(quint8) +}; + +struct QQmlCharForeign +{ + Q_GADGET + QML_FOREIGN(char) +#if CHAR_MAX == UCHAR_MAX + QML_USING(quint8) +#elif CHAR_MAX == SCHAR_MAX + QML_USING(qint8) +#else +# error char is neither quint8 nor qint8 +#endif +}; + +struct QQmlShortForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED_JAVASCRIPT(Number) + QML_FOREIGN(short) +}; + +struct QQmlQint16Foreign +{ + Q_GADGET + QML_FOREIGN(qint16) + QML_USING(short) +}; + +struct QQmlInt16TForeign +{ + Q_GADGET + QML_FOREIGN(int16_t) + QML_USING(short) +}; + +struct QQmlUshortForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED_JAVASCRIPT(Number) + QML_FOREIGN(ushort) +}; + +struct QQmlQuint16Foreign +{ + Q_GADGET + QML_FOREIGN(quint16) + QML_USING(ushort) +}; + +struct QQmlUint16TForeign +{ + Q_GADGET + QML_FOREIGN(uint16_t) + QML_USING(ushort) +}; + +struct QQmlUintForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED_JAVASCRIPT(Number) + QML_FOREIGN(uint) +}; + +struct QQmlQuint32Foreign +{ + Q_GADGET + QML_FOREIGN(quint32) + QML_USING(uint) +}; + +struct QQmlUint32TForeign +{ + Q_GADGET + QML_FOREIGN(uint32_t) + QML_USING(uint) +}; + +struct QQmlQlonglongForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED_JAVASCRIPT(Number) + QML_FOREIGN(qlonglong) +#ifdef QML_SIZE_IS_64BIT + // Keep qsizetype as primitive alias. We want it as separate type. + QML_PRIMITIVE_ALIAS(qsizetype) +#endif +}; + +struct QQmlQint64Foreign +{ + Q_GADGET + QML_FOREIGN(qint64) + QML_USING(qlonglong) +}; + +struct QQmlInt64TForeign +{ + Q_GADGET + QML_FOREIGN(int64_t) + QML_USING(qlonglong) +}; + +struct QQmlLongForeign +{ + Q_GADGET + QML_FOREIGN(long) +#if defined QML_LONG_IS_32BIT + QML_USING(int) +#elif defined QML_LONG_IS_64BIT + QML_USING(qlonglong) +#else +# error long is neither 32bit nor 64bit +#endif +}; + +struct QQmlQulonglongForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED_JAVASCRIPT(Number) + QML_FOREIGN(qulonglong) +}; + +struct QQmlQuint64Foreign +{ + Q_GADGET + QML_FOREIGN(quint64) + QML_USING(qulonglong) +}; + +struct QQmlUint64TForeign +{ + Q_GADGET + QML_FOREIGN(uint64_t) + QML_USING(qulonglong) +}; + +struct QQmlUlongForeign +{ + Q_GADGET + QML_FOREIGN(ulong) +#if defined QML_LONG_IS_32BIT + QML_USING(uint) +#elif defined QML_LONG_IS_64BIT + QML_USING(qulonglong) +#else +# error ulong is neither 32bit nor 64bit +#endif +}; + +struct QQmlFloatForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED_JAVASCRIPT(Number) + QML_FOREIGN(float) +}; + +struct QQmlQRealForeign +{ + Q_GADGET + QML_FOREIGN(qreal) +#if !defined(QT_COORD_TYPE) || defined(QT_COORD_TYPE_IS_DOUBLE) + QML_USING(double) +#elif defined(QT_COORD_TYPE_IS_FLOAT) + QML_USING(float) +#else +# error qreal is neither float nor double +#endif +}; + +struct QQmlQCharForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QChar) + QML_EXTENDED_JAVASCRIPT(String) +}; + +struct QQmlQDateForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QDate) + QML_EXTENDED_JAVASCRIPT(Date) +}; + +struct QQmlQTimeForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QTime) + QML_EXTENDED_JAVASCRIPT(Date) +}; + +struct QQmlQByteArrayForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED_JAVASCRIPT(ArrayBuffer) + QML_FOREIGN(QByteArray) +}; + +struct QQmlQByteArrayListForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QByteArrayList) + QML_SEQUENTIAL_CONTAINER(QByteArray) +}; + +struct QQmlQStringListForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QStringList) + QML_SEQUENTIAL_CONTAINER(QString) +}; + +struct QQmlQVariantListForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QVariantList) + QML_SEQUENTIAL_CONTAINER(QVariant) +}; + +struct QQmlQObjectListForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QObjectList) + QML_SEQUENTIAL_CONTAINER(QObject*) +}; + +struct QQmlQListQObjectForeign +{ + Q_GADGET + QML_FOREIGN(QList<QObject*>) + QML_USING(QObjectList) +}; + +struct QQmlQJSValueForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QJSValue) + QML_EXTENDED(QQmlQJSValueForeign) +}; + +struct QQmlComponentForeign +{ + Q_GADGET + QML_NAMED_ELEMENT(Component) + QML_FOREIGN(QQmlComponent) + QML_ATTACHED(QQmlComponentAttached) +}; + +struct QQmlScriptStringForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QQmlScriptString) +}; + +struct QQmlV4FunctionPtrForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QQmlV4FunctionPtr) + QML_EXTENDED(QQmlV4FunctionPtrForeign) +}; + +struct QQmlQJsonObjectForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QJsonObject) + QML_EXTENDED_JAVASCRIPT(Object) +}; + +struct QQmlQJsonValueForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QJsonValue) + QML_EXTENDED(QQmlQJsonValueForeign) +}; + +struct QQmlQJsonArrayForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QJsonArray) + QML_SEQUENTIAL_CONTAINER(QJsonValue) +}; + +QT_END_NAMESPACE + +#endif // QQMLBUILTINS_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcomponent_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcomponent_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0814302f1322070878ffeb1f579ef88ac1f77790 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcomponent_p.h @@ -0,0 +1,328 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCOMPONENT_P_H +#define QQMLCOMPONENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlcomponent.h" + +#include "qqmlengine_p.h" +#include "qqmlerror.h" +#include <private/qqmlobjectcreator_p.h> +#include <private/qqmltypedata_p.h> +#include <private/qqmlguardedcontextdata_p.h> + +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QList> +#include <QtCore/qtclasshelpermacros.h> + +#include <private/qobject_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlComponent; +class QQmlEngine; + +class QQmlComponentAttached; +class Q_QML_EXPORT QQmlComponentPrivate : public QObjectPrivate, public QQmlTypeData::TypeDataCallback +{ + Q_DECLARE_PUBLIC(QQmlComponent) + +public: + QQmlComponentPrivate() + : progress(0.), start(-1), engine(nullptr) {} + + void loadUrl(const QUrl &newUrl, QQmlComponent::CompilationMode mode = QQmlComponent::PreferSynchronous); + + QObject *beginCreate(QQmlRefPointer<QQmlContextData>); + void completeCreate(); + void initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext, const QV4::Value &valuemap, QObject *toCreate, RequiredProperties *requiredProperties); + static void setInitialProperties( + QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, + const QV4::Value &v, RequiredProperties *requiredProperties, QObject *createdComponent, + QQmlObjectCreator *creator); + static QQmlError unsetRequiredPropertyToQQmlError(const RequiredPropertyInfo &unsetRequiredProperty); + + virtual void incubateObject( + QQmlIncubator *incubationTask, + QQmlComponent *component, + QQmlEngine *engine, + const QQmlRefPointer<QQmlContextData> &context, + const QQmlRefPointer<QQmlContextData> &forContext); + + QQmlRefPointer<QQmlTypeData> typeData; + void typeDataReady(QQmlTypeData *) override; + void typeDataProgress(QQmlTypeData *, qreal) override; + + void fromTypeData(const QQmlRefPointer<QQmlTypeData> &data); + + QUrl url; + qreal progress; + std::unique_ptr<QString> inlineComponentName; + + /* points to the sub-object in a QML file that should be instantiated + used create instances of QtQml's Component type and indirectly for inline components */ + int start; + + bool hadTopLevelRequiredProperties() const; + // TODO: merge compilation unit and type + QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit; + QQmlType loadedType; + + struct AnnotatedQmlError + { + AnnotatedQmlError() = default; + + AnnotatedQmlError(QQmlError error) + : error(std::move(error)) + { + } + + + AnnotatedQmlError(QQmlError error, bool transient) + : error(std::move(error)), isTransient(transient) + { + } + QQmlError error; + bool isTransient = false; // tells if the error is temporary (e.g. unset required property) + }; + + struct ConstructionState { + ConstructionState() = default; + inline ~ConstructionState(); + Q_DISABLE_COPY(ConstructionState) + inline ConstructionState(ConstructionState &&other) noexcept; + + void swap(ConstructionState &other) + { + m_creatorOrRequiredProperties.swap(other.m_creatorOrRequiredProperties); + } + + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QQmlComponentPrivate::ConstructionState); + + inline void ensureRequiredPropertyStorage(QObject *target); + inline RequiredProperties *requiredProperties(); + inline void addPendingRequiredProperty( + const QObject *object, const QQmlPropertyData *propData, + const RequiredPropertyInfo &info); + inline bool hasUnsetRequiredProperties() const; + inline void clearRequiredProperties(); + + inline void appendErrors(const QList<QQmlError> &qmlErrors); + inline void appendCreatorErrors(); + + inline QQmlObjectCreator *creator(); + inline const QQmlObjectCreator *creator() const; + inline void clear(); + inline bool hasCreator() const; + inline QQmlObjectCreator *initCreator( + const QQmlRefPointer<QQmlContextData> &parentContext, + const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, + const QQmlRefPointer<QQmlContextData> &creationContext); + + QList<AnnotatedQmlError> errors; + inline bool isCompletePending() const; + inline void setCompletePending(bool isPending); + + QObject *target() const + { + if (m_creatorOrRequiredProperties.isNull()) + return nullptr; + + if (m_creatorOrRequiredProperties.isT1()) { + const auto &objects = m_creatorOrRequiredProperties.asT1()->allCreatedObjects(); + return objects.isEmpty() ? nullptr : objects.at(0); + } + + Q_ASSERT(m_creatorOrRequiredProperties.isT2()); + return m_creatorOrRequiredProperties.asT2()->target; + } + + private: + QBiPointer<QQmlObjectCreator, RequiredPropertiesAndTarget> m_creatorOrRequiredProperties; + }; + ConstructionState state; + + using DeferredState = std::vector<ConstructionState>; + static void beginDeferred(QQmlEnginePrivate *enginePriv, QObject *object, DeferredState* deferredState); + static void completeDeferred(QQmlEnginePrivate *enginePriv, DeferredState *deferredState); + + static void complete(QQmlEnginePrivate *enginePriv, ConstructionState *state); + static QQmlProperty removePropertyFromRequired(QObject *createdComponent, const QString &name, RequiredProperties *requiredProperties, + QQmlEngine *engine, bool *wasInRequiredProperties = nullptr); + + QQmlEngine *engine; + QQmlGuardedContextData creationContext; + + void clear(); + + static QQmlComponentPrivate *get(QQmlComponent *c) { + return static_cast<QQmlComponentPrivate *>(QObjectPrivate::get(c)); + } + + QObject *doBeginCreate(QQmlComponent *q, QQmlContext *context); + bool setInitialProperty(QObject *component, const QString &name, const QVariant& value); + + enum CreateBehavior { + CreateDefault, + CreateWarnAboutRequiredProperties, + }; + QObject *createWithProperties(QObject *parent, const QVariantMap &properties, + QQmlContext *context, CreateBehavior behavior = CreateDefault, + bool createFromQml = false); + + bool isBound() const { return compilationUnit && (compilationUnit->componentsAreBound()); } + LoadHelper::ResolveTypeResult prepareLoadFromModule(QAnyStringView uri, + QAnyStringView typeName); + void completeLoadFromModule(QAnyStringView uri, QAnyStringView typeName, QQmlType type, + LoadHelper::ResolveTypeResult::Status moduleStatus, + QQmlComponent::CompilationMode mode = QQmlComponent::PreferSynchronous); +}; + +QQmlComponentPrivate::ConstructionState::~ConstructionState() +{ + if (m_creatorOrRequiredProperties.isT1()) + delete m_creatorOrRequiredProperties.asT1(); + else + delete m_creatorOrRequiredProperties.asT2(); +} + +QQmlComponentPrivate::ConstructionState::ConstructionState(ConstructionState &&other) noexcept +{ + errors = std::move(other.errors); + m_creatorOrRequiredProperties = std::exchange(other.m_creatorOrRequiredProperties, {}); +} + +/*! + \internal A list of pending required properties that need + to be set in order for object construction to be successful. + */ +inline RequiredProperties *QQmlComponentPrivate::ConstructionState::requiredProperties() { + if (m_creatorOrRequiredProperties.isNull()) + return nullptr; + else if (m_creatorOrRequiredProperties.isT1()) + return m_creatorOrRequiredProperties.asT1()->requiredProperties(); + else + return m_creatorOrRequiredProperties.asT2(); +} + +inline void QQmlComponentPrivate::ConstructionState::addPendingRequiredProperty( + const QObject *object, const QQmlPropertyData *propData, const RequiredPropertyInfo &info) +{ + Q_ASSERT(requiredProperties()); + requiredProperties()->insert({object, propData}, info); +} + +inline bool QQmlComponentPrivate::ConstructionState::hasUnsetRequiredProperties() const { + auto properties = const_cast<ConstructionState *>(this)->requiredProperties(); + return properties && !properties->isEmpty(); +} + +inline void QQmlComponentPrivate::ConstructionState::clearRequiredProperties() +{ + if (auto reqProps = requiredProperties()) + reqProps->clear(); +} + +inline void QQmlComponentPrivate::ConstructionState::appendErrors(const QList<QQmlError> &qmlErrors) +{ + for (const QQmlError &e : qmlErrors) + errors.emplaceBack(e); +} + +//! \internal Moves errors from creator into construction state itself +inline void QQmlComponentPrivate::ConstructionState::appendCreatorErrors() +{ + if (!hasCreator()) + return; + auto creatorErrorCount = creator()->errors.size(); + if (creatorErrorCount == 0) + return; + auto existingErrorCount = errors.size(); + errors.resize(existingErrorCount + creatorErrorCount); + for (qsizetype i = 0; i < creatorErrorCount; ++i) + errors[existingErrorCount + i] = AnnotatedQmlError { std::move(creator()->errors[i]) }; + creator()->errors.clear(); +} + +inline QQmlObjectCreator *QQmlComponentPrivate::ConstructionState::creator() +{ + if (m_creatorOrRequiredProperties.isT1()) + return m_creatorOrRequiredProperties.asT1(); + return nullptr; +} + +inline const QQmlObjectCreator *QQmlComponentPrivate::ConstructionState::creator() const +{ + if (m_creatorOrRequiredProperties.isT1()) + return m_creatorOrRequiredProperties.asT1(); + return nullptr; +} + +inline bool QQmlComponentPrivate::ConstructionState::hasCreator() const +{ + return creator() != nullptr; +} + +inline void QQmlComponentPrivate::ConstructionState::clear() +{ + if (m_creatorOrRequiredProperties.isT1()) { + delete m_creatorOrRequiredProperties.asT1(); + m_creatorOrRequiredProperties = static_cast<QQmlObjectCreator *>(nullptr); + } +} + +inline QQmlObjectCreator *QQmlComponentPrivate::ConstructionState::initCreator( + const QQmlRefPointer<QQmlContextData> &parentContext, + const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, + const QQmlRefPointer<QQmlContextData> &creationContext) +{ + if (m_creatorOrRequiredProperties.isT1()) + delete m_creatorOrRequiredProperties.asT1(); + else + delete m_creatorOrRequiredProperties.asT2(); + m_creatorOrRequiredProperties = new QQmlObjectCreator( + parentContext, compilationUnit, creationContext); + return m_creatorOrRequiredProperties.asT1(); +} + +inline bool QQmlComponentPrivate::ConstructionState::isCompletePending() const +{ + return m_creatorOrRequiredProperties.flag(); +} + +inline void QQmlComponentPrivate::ConstructionState::setCompletePending(bool isPending) +{ + m_creatorOrRequiredProperties.setFlagValue(isPending); +} + +/*! + \internal + This is meant to be used in the context of QQmlComponent::loadFromModule, + when dealing with a C++ type. In that case, we do not have a creator, + and need a separate storage for required properties and the target object. + */ +inline void QQmlComponentPrivate::ConstructionState::ensureRequiredPropertyStorage(QObject *target) +{ + Q_ASSERT(m_creatorOrRequiredProperties.isT2() || m_creatorOrRequiredProperties.isNull()); + if (m_creatorOrRequiredProperties.isNull()) + m_creatorOrRequiredProperties = new RequiredPropertiesAndTarget(target); + else + m_creatorOrRequiredProperties.asT2()->target = target; +} + +QT_END_NAMESPACE + +#endif // QQMLCOMPONENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcomponentandaliasresolver_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcomponentandaliasresolver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..965e8505f2777dbd32da854b3c1fd1606f414700 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcomponentandaliasresolver_p.h @@ -0,0 +1,484 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQMLCOMPONENTANDALIASRESOLVER_P_H +#define QQMLCOMPONENTANDALIASRESOLVER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqmlcomponent.h> +#include <QtQml/qqmlerror.h> + +#include <QtCore/qglobal.h> +#include <QtCore/qhash.h> + +#include <private/qqmltypeloader_p.h> +#include <private/qqmlpropertycachecreator_p.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcQmlTypeCompiler); + +// This class primarily resolves component boundaries in a document. +// With the information about boundaries, it then goes on to resolve aliases and generalized +// group properties. Both rely on IDs as first part of their expressions and the IDs have +// to be located in surrounding components. That's why we have to do this with the component +// boundaries in mind. + +class QQmlComponentAndAliasResolverBase +{ + Q_DECLARE_TR_FUNCTIONS(QQmlComponentAndAliasResolverBase) +}; + +template<typename ObjectContainer> +class QQmlComponentAndAliasResolver : public QQmlComponentAndAliasResolverBase +{ +public: + using CompiledObject = typename ObjectContainer::CompiledObject; + using CompiledBinding = typename ObjectContainer::CompiledBinding; + + QQmlComponentAndAliasResolver( + ObjectContainer *compiler, + QQmlEnginePrivate *enginePrivate, + QQmlPropertyCacheVector *propertyCaches); + + [[nodiscard]] QQmlError resolve(int root = 0); + +private: + enum AliasResolutionResult { + NoAliasResolved, + SomeAliasesResolved, + AllAliasesResolved + }; + + // To be specialized for each container + void allocateNamedObjects(CompiledObject *object) const; + void setObjectId(int index) const; + [[nodiscard]] bool markAsComponent(int index) const; + [[nodiscard]] AliasResolutionResult resolveAliasesInObject( + const CompiledObject &component, int objectIndex, QQmlError *error); + void resolveGeneralizedGroupProperty(const CompiledObject &component, CompiledBinding *binding); + [[nodiscard]] bool wrapImplicitComponent(CompiledBinding *binding); + + [[nodiscard]] QQmlError findAndRegisterImplicitComponents( + const CompiledObject *obj, const QQmlPropertyCache::ConstPtr &propertyCache); + [[nodiscard]] QQmlError collectIdsAndAliases(int objectIndex); + [[nodiscard]] QQmlError resolveAliases(int componentIndex); + void resolveGeneralizedGroupProperties(int componentIndex); + [[nodiscard]] QQmlError resolveComponentsInInlineComponentRoot(int root); + + QString stringAt(int idx) const { return m_compiler->stringAt(idx); } + QV4::ResolvedTypeReference *resolvedType(int id) const { return m_compiler->resolvedType(id); } + + [[nodiscard]] QQmlError error( + const QV4::CompiledData::Location &location, + const QString &description) + { + QQmlError error; + error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line())); + error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column())); + error.setDescription(description); + error.setUrl(m_compiler->url()); + return error; + } + + template<typename Token> + [[nodiscard]] QQmlError error(Token token, const QString &description) + { + return error(token->location, description); + } + + static bool isUsableComponent(const QMetaObject *metaObject) + { + // The metaObject is a component we're interested in if it either is a QQmlComponent itself + // or if any of its parents is a QQmlAbstractDelegateComponent. We don't want to include + // qqmldelegatecomponent_p.h because it belongs to QtQmlModels. + + if (metaObject == &QQmlComponent::staticMetaObject) + return true; + + for (; metaObject; metaObject = metaObject->superClass()) { + if (qstrcmp(metaObject->className(), "QQmlAbstractDelegateComponent") == 0) + return true; + } + + return false; + } + + ObjectContainer *m_compiler = nullptr; + QQmlEnginePrivate *m_enginePrivate = nullptr; + + // Implicit component insertion may have added objects and thus we also need + // to extend the symmetric propertyCaches. Therefore, non-const propertyCaches. + QQmlPropertyCacheVector *m_propertyCaches = nullptr; + + // indices of the objects that are actually Component {} + QVector<quint32> m_componentRoots; + QVector<int> m_objectsWithAliases; + QVector<CompiledBinding *> m_generalizedGroupProperties; + typename ObjectContainer::IdToObjectMap m_idToObjectIndex; +}; + +template<typename ObjectContainer> +QQmlComponentAndAliasResolver<ObjectContainer>::QQmlComponentAndAliasResolver( + ObjectContainer *compiler, + QQmlEnginePrivate *enginePrivate, + QQmlPropertyCacheVector *propertyCaches) + : m_compiler(compiler) + , m_enginePrivate(enginePrivate) + , m_propertyCaches(propertyCaches) +{ +} + +template<typename ObjectContainer> +QQmlError QQmlComponentAndAliasResolver<ObjectContainer>::findAndRegisterImplicitComponents( + const CompiledObject *obj, const QQmlPropertyCache::ConstPtr &propertyCache) +{ + QQmlPropertyResolver propertyResolver(propertyCache); + + const QQmlPropertyData *defaultProperty = obj->indexOfDefaultPropertyOrAlias != -1 + ? propertyCache->parent()->defaultProperty() + : propertyCache->defaultProperty(); + + for (auto binding = obj->bindingsBegin(), end = obj->bindingsEnd(); binding != end; ++binding) { + if (binding->type() != QV4::CompiledData::Binding::Type_Object) + continue; + if (binding->hasFlag(QV4::CompiledData::Binding::IsSignalHandlerObject)) + continue; + + auto targetObject = m_compiler->objectAt(binding->value.objectIndex); + auto typeReference = resolvedType(targetObject->inheritedTypeNameIndex); + Q_ASSERT(typeReference); + + const QMetaObject *firstMetaObject = nullptr; + const auto type = typeReference->type(); + if (type.isValid()) + firstMetaObject = type.metaObject(); + else if (const auto compilationUnit = typeReference->compilationUnit()) + firstMetaObject = compilationUnit->rootPropertyCache()->firstCppMetaObject(); + if (isUsableComponent(firstMetaObject)) + continue; + + // if here, not a QQmlComponent, so needs wrapping + const QQmlPropertyData *pd = nullptr; + if (binding->propertyNameIndex != quint32(0)) { + bool notInRevision = false; + pd = propertyResolver.property(stringAt(binding->propertyNameIndex), ¬InRevision); + } else { + pd = defaultProperty; + } + if (!pd || !pd->isQObject()) + continue; + + // If the version is given, use it and look up by QQmlType. + // Otherwise, make sure we look up by metaobject. + // TODO: Is this correct? + QQmlPropertyCache::ConstPtr pc = pd->typeVersion().hasMinorVersion() + ? QQmlMetaType::rawPropertyCacheForType(pd->propType(), pd->typeVersion()) + : QQmlMetaType::rawPropertyCacheForType(pd->propType()); + const QMetaObject *mo = pc ? pc->firstCppMetaObject() : nullptr; + while (mo) { + if (mo == &QQmlComponent::staticMetaObject) + break; + mo = mo->superClass(); + } + + if (!mo) + continue; + + if (!wrapImplicitComponent(binding)) + return error(binding, QQmlComponentAndAliasResolverBase::tr("Cannot wrap implicit component")); + } + + return QQmlError(); +} + +template<typename ObjectContainer> +QQmlError QQmlComponentAndAliasResolver<ObjectContainer>::resolveComponentsInInlineComponentRoot( + int root) +{ + // Find implicit components in the inline component itself. Also warn about inline + // components being explicit components. + + const auto rootObj = m_compiler->objectAt(root); + Q_ASSERT(rootObj->hasFlag(QV4::CompiledData::Object::IsInlineComponentRoot)); + + if (const int typeName = rootObj->inheritedTypeNameIndex) { + const auto *tref = resolvedType(typeName); + Q_ASSERT(tref); + if (tref->type().metaObject() == &QQmlComponent::staticMetaObject) { + qCWarning(lcQmlTypeCompiler).nospace().noquote() + << m_compiler->url().toString() << ":" << rootObj->location.line() << ":" + << rootObj->location.column() + << ": Using a Component as the root of an inline component is deprecated: " + "inline components are " + "automatically wrapped into Components when needed."; + return QQmlError(); + } + } + + const QQmlPropertyCache::ConstPtr rootCache = m_propertyCaches->at(root); + Q_ASSERT(rootCache); + + return findAndRegisterImplicitComponents(rootObj, rootCache); +} + +// Resolve ignores everything relating to inline components, except for implicit components. +template<typename ObjectContainer> +QQmlError QQmlComponentAndAliasResolver<ObjectContainer>::resolve(int root) +{ + // Detect real Component {} objects as well as implicitly defined components, such as + // someItemDelegate: Item {} + // In the implicit case Item is surrounded by a synthetic Component {} because the property + // on the left hand side is of QQmlComponent type. + const int objCountWithoutSynthesizedComponents = m_compiler->objectCount(); + + if (root != 0) { + const QQmlError error = resolveComponentsInInlineComponentRoot(root); + if (error.isValid()) + return error; + } + + // root+1, as ic root is handled at the end + const int startObjectIndex = root == 0 ? root : root+1; + + for (int i = startObjectIndex; i < objCountWithoutSynthesizedComponents; ++i) { + auto obj = m_compiler->objectAt(i); + const bool isInlineComponentRoot + = obj->hasFlag(QV4::CompiledData::Object::IsInlineComponentRoot); + const bool isPartOfInlineComponent + = obj->hasFlag(QV4::CompiledData::Object::IsPartOfInlineComponent); + QQmlPropertyCache::ConstPtr cache = m_propertyCaches->at(i); + + if (root == 0) { + // normal component root, skip over anything inline component related + if (isInlineComponentRoot || isPartOfInlineComponent) + continue; + } else if (!isPartOfInlineComponent || isInlineComponentRoot) { + // When handling an inline component, stop where the inline component ends + // Note: We do not support nested inline components. Therefore, isInlineComponentRoot + // tells us that the element after the current inline component is again an + // inline component + break; + } + + if (obj->inheritedTypeNameIndex == 0 && !cache) + continue; + + bool isExplicitComponent = false; + if (obj->inheritedTypeNameIndex) { + auto *tref = resolvedType(obj->inheritedTypeNameIndex); + Q_ASSERT(tref); + if (tref->type().metaObject() == &QQmlComponent::staticMetaObject) + isExplicitComponent = true; + } + + if (!isExplicitComponent) { + if (cache) { + const QQmlError error = findAndRegisterImplicitComponents(obj, cache); + if (error.isValid()) + return error; + } + continue; + } + + if (!markAsComponent(i)) + return error(obj, QQmlComponentAndAliasResolverBase::tr("Cannot mark object as component")); + + // check if this object is the root + if (i == 0) { + if (isExplicitComponent) + qCWarning(lcQmlTypeCompiler).nospace().noquote() + << m_compiler->url().toString() << ":" << obj->location.line() << ":" + << obj->location.column() + << ": Using a Component as the root of a QML document is deprecated: types " + "defined in qml documents are " + "automatically wrapped into Components when needed."; + } + + if (obj->functionCount() > 0) + return error(obj, QQmlComponentAndAliasResolverBase::tr("Component objects cannot declare new functions.")); + if (obj->propertyCount() > 0 || obj->aliasCount() > 0) + return error(obj, QQmlComponentAndAliasResolverBase::tr("Component objects cannot declare new properties.")); + if (obj->signalCount() > 0) + return error(obj, QQmlComponentAndAliasResolverBase::tr("Component objects cannot declare new signals.")); + + if (obj->bindingCount() == 0) + return error(obj, QQmlComponentAndAliasResolverBase::tr("Cannot create empty component specification")); + + const auto rootBinding = obj->bindingsBegin(); + const auto bindingsEnd = obj->bindingsEnd(); + + // Produce the more specific "no properties" error rather than the "invalid body" error + // where possible. + for (auto b = rootBinding; b != bindingsEnd; ++b) { + if (b->propertyNameIndex == 0) + continue; + + return error(b, QQmlComponentAndAliasResolverBase::tr("Component elements may not contain properties other than id")); + } + + if (auto b = rootBinding; + b->type() != QV4::CompiledData::Binding::Type_Object || ++b != bindingsEnd) { + return error(obj, QQmlComponentAndAliasResolverBase::tr("Invalid component body specification")); + } + + // For the root object, we are going to collect ids/aliases and resolve them for as a + // separate last pass. + if (i != 0) + m_componentRoots.append(i); + } + + for (int i = 0; i < m_componentRoots.size(); ++i) { + CompiledObject *component = m_compiler->objectAt(m_componentRoots.at(i)); + const auto rootBinding = component->bindingsBegin(); + + m_idToObjectIndex.clear(); + m_objectsWithAliases.clear(); + m_generalizedGroupProperties.clear(); + + if (const QQmlError error = collectIdsAndAliases(rootBinding->value.objectIndex); + error.isValid()) { + return error; + } + + allocateNamedObjects(component); + + if (const QQmlError error = resolveAliases(m_componentRoots.at(i)); error.isValid()) + return error; + + resolveGeneralizedGroupProperties(m_componentRoots.at(i)); + } + + // Collect ids and aliases for root + m_idToObjectIndex.clear(); + m_objectsWithAliases.clear(); + m_generalizedGroupProperties.clear(); + + if (const QQmlError error = collectIdsAndAliases(root); error.isValid()) + return error; + + allocateNamedObjects(m_compiler->objectAt(root)); + if (const QQmlError error = resolveAliases(root); error.isValid()) + return error; + + resolveGeneralizedGroupProperties(root); + return QQmlError(); +} + +template<typename ObjectContainer> +QQmlError QQmlComponentAndAliasResolver<ObjectContainer>::collectIdsAndAliases(int objectIndex) +{ + auto obj = m_compiler->objectAt(objectIndex); + + if (obj->idNameIndex != 0) { + if (m_idToObjectIndex.contains(obj->idNameIndex)) + return error(obj->locationOfIdProperty, QQmlComponentAndAliasResolverBase::tr("id is not unique")); + setObjectId(objectIndex); + m_idToObjectIndex.insert(obj->idNameIndex, objectIndex); + } + + if (obj->aliasCount() > 0) + m_objectsWithAliases.append(objectIndex); + + // Stop at Component boundary + if (obj->hasFlag(QV4::CompiledData::Object::IsComponent) && objectIndex != /*root object*/0) + return QQmlError(); + + for (auto binding = obj->bindingsBegin(), end = obj->bindingsEnd(); + binding != end; ++binding) { + switch (binding->type()) { + case QV4::CompiledData::Binding::Type_GroupProperty: { + const auto *inner = m_compiler->objectAt(binding->value.objectIndex); + if (m_compiler->stringAt(inner->inheritedTypeNameIndex).isEmpty()) { + const auto cache = m_propertyCaches->at(objectIndex); + if (!cache || !cache->property( + m_compiler->stringAt(binding->propertyNameIndex), nullptr, nullptr)) { + m_generalizedGroupProperties.append(binding); + } + } + } + Q_FALLTHROUGH(); + case QV4::CompiledData::Binding::Type_Object: + case QV4::CompiledData::Binding::Type_AttachedProperty: + if (const QQmlError error = collectIdsAndAliases(binding->value.objectIndex); + error.isValid()) { + return error; + } + break; + default: + break; + } + } + + return QQmlError(); +} + +template<typename ObjectContainer> +QQmlError QQmlComponentAndAliasResolver<ObjectContainer>::resolveAliases(int componentIndex) +{ + if (m_objectsWithAliases.isEmpty()) + return QQmlError(); + + QQmlPropertyCacheAliasCreator<ObjectContainer> aliasCacheCreator(m_propertyCaches, m_compiler); + + bool atLeastOneAliasResolved; + do { + atLeastOneAliasResolved = false; + QVector<int> pendingObjects; + + for (int objectIndex: std::as_const(m_objectsWithAliases)) { + + QQmlError error; + const auto &component = *m_compiler->objectAt(componentIndex); + const auto result = resolveAliasesInObject(component, objectIndex, &error); + if (error.isValid()) + return error; + + if (result == AllAliasesResolved) { + QQmlError error = aliasCacheCreator.appendAliasesToPropertyCache( + component, objectIndex, m_enginePrivate); + if (error.isValid()) + return error; + atLeastOneAliasResolved = true; + } else if (result == SomeAliasesResolved) { + atLeastOneAliasResolved = true; + pendingObjects.append(objectIndex); + } else { + pendingObjects.append(objectIndex); + } + } + qSwap(m_objectsWithAliases, pendingObjects); + } while (!m_objectsWithAliases.isEmpty() && atLeastOneAliasResolved); + + if (!atLeastOneAliasResolved && !m_objectsWithAliases.isEmpty()) { + const CompiledObject *obj = m_compiler->objectAt(m_objectsWithAliases.first()); + for (auto alias = obj->aliasesBegin(), end = obj->aliasesEnd(); alias != end; ++alias) { + if (!alias->hasFlag(QV4::CompiledData::Alias::Resolved)) + return error(alias->location, QQmlComponentAndAliasResolverBase::tr("Circular alias reference detected")); + } + } + + return QQmlError(); +} + +template<typename ObjectContainer> +void QQmlComponentAndAliasResolver<ObjectContainer>::resolveGeneralizedGroupProperties( + int componentIndex) +{ + const auto &component = *m_compiler->objectAt(componentIndex); + for (CompiledBinding *binding : m_generalizedGroupProperties) + resolveGeneralizedGroupProperty(component, binding); +} + +QT_END_NAMESPACE + +#endif // QQMLCOMPONENTANDALIASRESOLVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcomponentattached_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcomponentattached_p.h new file mode 100644 index 0000000000000000000000000000000000000000..578e5a7def4d47e0d6ebd454a2499baa1f3067b3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcomponentattached_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCOMPONENTATTACHED_P_H +#define QQMLCOMPONENTATTACHED_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqml.h> +#include <QtQml/qqmlcomponent.h> +#include <private/qtqmlglobal_p.h> +#include <QtCore/QObject> + +QT_BEGIN_NAMESPACE + + +// implemented in qqmlcomponent.cpp +class Q_QML_EXPORT QQmlComponentAttached : public QObject +{ + Q_OBJECT +public: + QQmlComponentAttached(QObject *parent = nullptr); + ~QQmlComponentAttached(); + + void insertIntoList(QQmlComponentAttached **listHead) + { + m_prev = listHead; + m_next = *listHead; + *listHead = this; + if (m_next) + m_next->m_prev = &m_next; + } + + void removeFromList() + { + *m_prev = m_next; + if (m_next) + m_next->m_prev = m_prev; + m_next = nullptr; + m_prev = nullptr; + } + + QQmlComponentAttached *next() const { return m_next; } + +Q_SIGNALS: + void completed(); + void destruction(); + +private: + QQmlComponentAttached **m_prev; + QQmlComponentAttached *m_next; +}; + +QT_END_NAMESPACE + +// TODO: We still need this because we cannot properly use QML_ATTACHED with QML_FOREIGN. +QML_DECLARE_TYPEINFO(QQmlComponent, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QQMLCOMPONENTATTACHED_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlconfigurabledebugservice_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlconfigurabledebugservice_p.h new file mode 100644 index 0000000000000000000000000000000000000000..24417c968339432dba65382264eac1d2ffa30f73 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlconfigurabledebugservice_p.h @@ -0,0 +1,77 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QQMLCONFIGURABLEDEBUGSEVICE_P_H +#define QQMLCONFIGURABLEDEBUGSEVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldebugservice_p.h" +#include "qqmldebugconnector_p.h" + +#include <QtCore/qmutex.h> + +QT_BEGIN_NAMESPACE + +template <class Base> +class QQmlConfigurableDebugService : public Base +{ +protected: + QQmlConfigurableDebugService(float version, QObject *parent = nullptr) : + Base(version, parent) + { + init(); + } + + void stopWaiting() + { + QMutexLocker lock(&m_configMutex); + m_waitingForConfiguration = false; + for (QJSEngine *engine : std::as_const(m_waitingEngines)) + Q_EMIT Base::attachedToEngine(engine); + m_waitingEngines.clear(); + } + + void init() + { + QMutexLocker lock(&m_configMutex); + // If we're not enabled or not blocking, don't wait for configuration + m_waitingForConfiguration = (Base::state() == QQmlDebugService::Enabled && + QQmlDebugConnector::instance()->blockingMode()); + } + + void stateChanged(QQmlDebugService::State newState) override + { + if (newState != QQmlDebugService::Enabled) + stopWaiting(); + else + init(); + } + + void engineAboutToBeAdded(QJSEngine *engine) override + { + QMutexLocker lock(&m_configMutex); + if (m_waitingForConfiguration) + m_waitingEngines.append(engine); + else + Q_EMIT Base::attachedToEngine(engine); + } + + QRecursiveMutex m_configMutex; + QList<QJSEngine *> m_waitingEngines; + bool m_waitingForConfiguration; +}; + +QT_END_NAMESPACE + +#endif // QQMLCONFIGURABLEDEBUGSEVICE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcontext_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcontext_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8661ac293a48b25aab46ede13b70fc860f9877e1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcontext_p.h @@ -0,0 +1,93 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCONTEXT_P_H +#define QQMLCONTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qlist.h> +#include <QtCore/qstring.h> +#include <QtCore/qvariant.h> +#include <QtCore/qpointer.h> +#include <QtQml/qqmlcontext.h> +#include <QtQml/qqmllist.h> + +#include <QtCore/private/qobject_p.h> +#include <QtCore/qtaggedpointer.h> +#include <QtQml/private/qqmlrefcount_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlContextData; + +class QQmlContextPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQmlContext) +public: + static QQmlContextPrivate *get(QQmlContext *context) { + return static_cast<QQmlContextPrivate *>(QObjectPrivate::get(context)); + } + + static QQmlContext *get(QQmlContextPrivate *context) { + return static_cast<QQmlContext *>(context->q_func()); + } + + static qsizetype context_count(QQmlListProperty<QObject> *); + static QObject *context_at(QQmlListProperty<QObject> *, qsizetype); + + void dropDestroyedQObject(const QString &name, QObject *destroyed); + + int notifyIndex() const { return m_notifyIndex; } + void setNotifyIndex(int notifyIndex) { m_notifyIndex = notifyIndex; } + + int numPropertyValues() const { + auto size = m_propertyValues.size(); + Q_ASSERT(size <= std::numeric_limits<int>::max()); + return int(size); + } + void appendPropertyValue(const QVariant &value) { m_propertyValues.append(value); } + void setPropertyValue(int index, const QVariant &value) { m_propertyValues[index] = value; } + QVariant propertyValue(int index) const { return m_propertyValues[index]; } + + QList<QPointer<QObject>> instances() const { return m_instances; } + void appendInstance(QObject *instance) { m_instances.append(instance); } + void cleanInstances() + { + for (auto it = m_instances.begin(); it != m_instances.end(); + it->isNull() ? (it = m_instances.erase(it)) : ++it) {} + } + + void emitDestruction(); + +private: + friend class QQmlContextData; + + QQmlContextPrivate(QQmlContextData *data) : m_data(data) {} + QQmlContextPrivate(QQmlContext *publicContext, const QQmlRefPointer<QQmlContextData> &parent, + QQmlEngine *engine = nullptr); + + // Intentionally a bare pointer. QQmlContextData knows whether it owns QQmlContext or vice + // versa. If QQmlContext is the owner, QQmlContextData keeps an extra ref for its publicContext. + // The publicContext ref is released when doing QQmlContextData::setPublicContext(nullptr). + QQmlContextData *m_data; + + QList<QVariant> m_propertyValues; + int m_notifyIndex = -1; + + // Only used for debugging + QList<QPointer<QObject>> m_instances; +}; + +QT_END_NAMESPACE + +#endif // QQMLCONTEXT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcontextdata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcontextdata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8f18509885aad389475a54c136363484d3e100f9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcontextdata_p.h @@ -0,0 +1,489 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCONTEXTDATA_P_H +#define QQMLCONTEXTDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qtqmlglobal_p.h> +#include <QtQml/private/qqmlcontext_p.h> +#include <QtQml/private/qqmlguard_p.h> +#include <QtQml/private/qqmltypenamecache_p.h> +#include <QtQml/private/qqmlnotifier_p.h> +#include <QtQml/private/qv4identifierhash_p.h> +#include <QtQml/private/qv4executablecompilationunit_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlComponentAttached; +class QQmlGuardedContextData; +class QQmlJavaScriptExpression; +class QQmlIncubatorPrivate; + +class Q_QML_EXPORT QQmlContextData +{ +public: + static QQmlRefPointer<QQmlContextData> createRefCounted( + const QQmlRefPointer<QQmlContextData> &parent) + { + return QQmlRefPointer<QQmlContextData>(new QQmlContextData(RefCounted, nullptr, parent), + QQmlRefPointer<QQmlContextData>::Adopt); + } + + // Owned by the parent. When the parent is reset to nullptr, it will be deref'd. + static QQmlRefPointer<QQmlContextData> createChild( + const QQmlRefPointer<QQmlContextData> &parent) + { + Q_ASSERT(!parent.isNull()); + return QQmlRefPointer<QQmlContextData>(new QQmlContextData(OwnedByParent, nullptr, parent)); + } + + void addref() const { ++m_refCount; } + void release() const { if (--m_refCount == 0) delete this; } + int count() const { return m_refCount; } + int refCount() const { return m_refCount; } + + QQmlRefPointer<QV4::ExecutableCompilationUnit> typeCompilationUnit() const + { + return m_typeCompilationUnit; + } + void initFromTypeCompilationUnit(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit, + int subComponentIndex); + + static QQmlRefPointer<QQmlContextData> get(QQmlContext *context) { + return QQmlContextPrivate::get(context)->m_data; + } + + void emitDestruction(); + void clearContext(); + void clearContextRecursively(); + void invalidate(); + + bool isValid() const + { + return m_engine && (!m_isInternal || !m_contextObject + || !QObjectPrivate::get(m_contextObject)->wasDeleted); + } + + bool isInternal() const { return m_isInternal; } + void setInternal(bool isInternal) { m_isInternal = isInternal; } + + bool isJSContext() const { return m_isJSContext; } + void setJSContext(bool isJSContext) { m_isJSContext = isJSContext; } + + bool isPragmaLibraryContext() const { return m_isPragmaLibraryContext; } + void setPragmaLibraryContext(bool library) { m_isPragmaLibraryContext = library; } + + QQmlRefPointer<QQmlContextData> parent() const { return m_parent; } + void clearParent() + { + if (!m_parent) + return; + + m_parent = nullptr; + if (m_ownedByParent) { + m_ownedByParent = false; + release(); + } + } + + void refreshExpressions(); + + void addOwnedObject(QQmlData *ownedObject); + QQmlData *ownedObjects() const { return m_ownedObjects; } + void setOwnedObjects(QQmlData *ownedObjects) { m_ownedObjects = ownedObjects; } + + enum QmlObjectKind { + OrdinaryObject, + DocumentRoot, + }; + void installContext(QQmlData *ddata, QmlObjectKind kind); + + QUrl resolvedUrl(const QUrl &) const; + + // My containing QQmlContext. If isInternal is true this owns publicContext. + // If internal is false publicContext owns this. + QQmlContext *asQQmlContext() + { + if (!m_publicContext) + m_publicContext = new QQmlContext(*new QQmlContextPrivate(this)); + return m_publicContext; + } + + QQmlContextPrivate *asQQmlContextPrivate() + { + return QQmlContextPrivate::get(asQQmlContext()); + } + + QObject *contextObject() const { return m_contextObject; } + void setContextObject(QObject *contextObject) { m_contextObject = contextObject; } + + template<typename HandleSelf, typename HandleLinked> + void deepClearContextObject( + QObject *contextObject, HandleSelf &&handleSelf, HandleLinked &&handleLinked) { + for (QQmlContextData *lc = m_linkedContext.data(); lc; lc = lc->m_linkedContext.data()) { + handleLinked(lc); + if (lc->m_contextObject == contextObject) + lc->m_contextObject = nullptr; + } + + handleSelf(this); + if (m_contextObject == contextObject) + m_contextObject = nullptr; + } + + void deepClearContextObject(QObject *contextObject) + { + deepClearContextObject( + contextObject, + [](QQmlContextData *self) { self->emitDestruction(); }, + [](QQmlContextData *){}); + } + + QQmlEngine *engine() const { return m_engine; } + void setEngine(QQmlEngine *engine) { m_engine = engine; } + + QQmlContext *publicContext() const { return m_publicContext; } + void clearPublicContext() + { + if (!m_publicContext) + return; + + m_publicContext = nullptr; + if (m_ownedByPublicContext) { + m_ownedByPublicContext = false; + release(); + } + } + + int propertyIndex(const QString &name) const + { + ensurePropertyNames(); + return m_propertyNameCache.value(name); + } + + int propertyIndex(QV4::String *name) const + { + ensurePropertyNames(); + return m_propertyNameCache.value(name); + } + + QString propertyName(int index) const + { + ensurePropertyNames(); + return m_propertyNameCache.findId(index); + } + + void addPropertyNameAndIndex(const QString &name, int index) + { + Q_ASSERT(!m_propertyNameCache.isEmpty()); + m_propertyNameCache.add(name, index); + } + + void setExpressions(QQmlJavaScriptExpression *expressions) { m_expressions = expressions; } + QQmlJavaScriptExpression *takeExpressions() + { + QQmlJavaScriptExpression *expressions = m_expressions; + m_expressions = nullptr; + return expressions; + } + + void setChildContexts(const QQmlRefPointer<QQmlContextData> &childContexts) + { + m_childContexts = childContexts.data(); + } + QQmlRefPointer<QQmlContextData> childContexts() const { return m_childContexts; } + QQmlRefPointer<QQmlContextData> takeChildContexts() + { + QQmlRefPointer<QQmlContextData> childContexts = m_childContexts; + m_childContexts = nullptr; + return childContexts; + } + QQmlRefPointer<QQmlContextData> nextChild() const { return m_nextChild; } + + int numIdValues() const { return m_idValueCount; } + void setIdValue(int index, QObject *idValue); + bool isIdValueSet(int index) const { return m_idValues[index].wasSet(); } + QQmlNotifier *idValueBindings(int index) const { return m_idValues[index].bindings(); } + QObject *idValue(int index) const { return m_idValues[index].data(); } + + // Return the outermost id for obj, if any. + QString findObjectId(const QObject *obj) const; + + // url() and urlString() prefer the CU's URL over explicitly set baseUrls. They + // don't search the context hierarchy. + // baseUrl() and baseUrlString() search the context hierarchy and prefer explicit + // base URLs over CU Urls. + + QUrl url() const; + QString urlString() const; + + void setBaseUrlString(const QString &baseUrlString) { m_baseUrlString = baseUrlString; } + QString baseUrlString() const + { + for (const QQmlContextData *data = this; data; data = data->m_parent) { + if (!data->m_baseUrlString.isEmpty()) + return data->m_baseUrlString; + if (data->m_typeCompilationUnit) + return data->m_typeCompilationUnit->finalUrlString(); + } + return QString(); + } + + void setBaseUrl(const QUrl &baseUrl) { m_baseUrl = baseUrl; } + QUrl baseUrl() const + { + for (const QQmlContextData *data = this; data; data = data->m_parent) { + if (!data->m_baseUrl.isEmpty()) + return data->m_baseUrl; + if (data->m_typeCompilationUnit) + return data->m_typeCompilationUnit->finalUrl(); + } + return QUrl(); + } + + QQmlRefPointer<QQmlTypeNameCache> imports() const { return m_imports; } + void setImports(const QQmlRefPointer<QQmlTypeNameCache> &imports) { m_imports = imports; } + + QQmlIncubatorPrivate *incubator() const { return m_hasExtraObject ? nullptr : m_incubator; } + void setIncubator(QQmlIncubatorPrivate *incubator) + { + Q_ASSERT(!m_hasExtraObject || m_extraObject == nullptr); + m_hasExtraObject = false; + m_incubator = incubator; + } + + QObject *extraObject() const { return m_hasExtraObject ? m_extraObject : nullptr; } + void setExtraObject(QObject *extraObject) + { + Q_ASSERT(m_hasExtraObject || m_incubator == nullptr); + m_hasExtraObject = true; + m_extraObject = extraObject; + } + + bool isRootObjectInCreation() const { return m_isRootObjectInCreation; } + void setRootObjectInCreation(bool rootInCreation) { m_isRootObjectInCreation = rootInCreation; } + + QV4::Value importedScripts() const { + if (m_hasWeakImportedScripts) + return m_weakImportedScripts.value(); + else + return m_importedScripts.value(); + } + void setImportedScripts(QV4::ExecutionEngine *engine, QV4::Value scripts) { + // setImportedScripts should not be called on an invalidated context + Q_ASSERT(!m_hasWeakImportedScripts); + m_importedScripts.set(engine, scripts); + } + + QQmlRefPointer<QQmlContextData> linkedContext() const { return m_linkedContext; } + void setLinkedContext(const QQmlRefPointer<QQmlContextData> &context) { m_linkedContext = context; } + + bool hasUnresolvedNames() const { return m_unresolvedNames; } + void setUnresolvedNames(bool hasUnresolvedNames) { m_unresolvedNames = hasUnresolvedNames; } + + QQmlComponentAttached *componentAttacheds() const { return m_componentAttacheds; } + void addComponentAttached(QQmlComponentAttached *attached); + + void addExpression(QQmlJavaScriptExpression *expression); + + bool valueTypesAreAddressable() const { + return m_typeCompilationUnit && m_typeCompilationUnit->valueTypesAreAddressable(); + } + + bool valueTypesAreAssertable() const { + return m_typeCompilationUnit && m_typeCompilationUnit->valueTypesAreAssertable(); + } + +private: + friend class QQmlGuardedContextData; + friend class QQmlContextPrivate; + + enum Ownership { + RefCounted, + OwnedByParent, + OwnedByPublicContext + }; + + // id guards + struct ContextGuard : public QQmlGuard<QObject> + { + enum Tag { + NoTag, + ObjectWasSet + }; + + inline ContextGuard() : QQmlGuard<QObject>(&ContextGuard::objectDestroyedImpl, nullptr), m_context(nullptr) {} + inline ContextGuard &operator=(QObject *obj); + + inline bool wasSet() const; + + QQmlNotifier *bindings() { return &m_bindings; } + void setContext(const QQmlRefPointer<QQmlContextData> &context) + { + m_context = context.data(); + } + + private: + inline static void objectDestroyedImpl(QQmlGuardImpl *); + // Not refcounted, as it always belongs to the QQmlContextData. + QTaggedPointer<QQmlContextData, Tag> m_context; + QQmlNotifier m_bindings; + }; + + // It's OK to pass a half-created publicContext here. We will not dereference it during + // construction. + QQmlContextData( + Ownership ownership, QQmlContext *publicContext, + const QQmlRefPointer<QQmlContextData> &parent, QQmlEngine *engine = nullptr) + : m_parent(parent.data()), + m_engine(engine ? engine : (parent.isNull() ? nullptr : parent->engine())), + m_isInternal(false), m_isJSContext(false), m_isPragmaLibraryContext(false), + m_unresolvedNames(false), m_hasEmittedDestruction(false), m_isRootObjectInCreation(false), + m_ownedByParent(ownership == OwnedByParent), + m_ownedByPublicContext(ownership == OwnedByPublicContext), m_hasExtraObject(false), + m_hasWeakImportedScripts(false), m_dummy(0), m_publicContext(publicContext), m_incubator(nullptr) + { + Q_ASSERT(!m_ownedByParent || !m_ownedByPublicContext); + if (!m_parent) + return; + + m_nextChild = m_parent->m_childContexts; + if (m_nextChild) + m_nextChild->m_prevChild = &m_nextChild; + m_prevChild = &m_parent->m_childContexts; + m_parent->m_childContexts = this; + } + + ~QQmlContextData(); + + bool hasExpressionsToRun(bool isGlobalRefresh) const + { + return m_expressions && (!isGlobalRefresh || m_unresolvedNames); + } + + void refreshExpressionsRecursive(bool isGlobal); + void refreshExpressionsRecursive(QQmlJavaScriptExpression *); + void initPropertyNames() const; + + void ensurePropertyNames() const + { + if (m_propertyNameCache.isEmpty()) + initPropertyNames(); + Q_ASSERT(!m_propertyNameCache.isEmpty()); + } + + // My parent context and engine + QQmlContextData *m_parent = nullptr; + QQmlEngine *m_engine = nullptr; + + mutable quint32 m_refCount = 1; + quint32 m_isInternal:1; + quint32 m_isJSContext:1; + quint32 m_isPragmaLibraryContext:1; + quint32 m_unresolvedNames:1; // True if expressions in this context failed to resolve a toplevel name + quint32 m_hasEmittedDestruction:1; + quint32 m_isRootObjectInCreation:1; + quint32 m_ownedByParent:1; + quint32 m_ownedByPublicContext:1; + quint32 m_hasExtraObject:1; // used in QQmlDelegateModelItem::dataForObject to find the corresponding QQmlDelegateModelItem of an object + quint32 m_hasWeakImportedScripts:1; + Q_DECL_UNUSED_MEMBER quint32 m_dummy:22; + QQmlContext *m_publicContext = nullptr; + + union { + // The incubator that is constructing this context if any + QQmlIncubatorPrivate *m_incubator; + // a pointer to extra data, currently only used in QQmlDelegateModel + QObject *m_extraObject; + }; + + // Compilation unit for contexts that belong to a compiled type. + QQmlRefPointer<QV4::ExecutableCompilationUnit> m_typeCompilationUnit; + + // object index in CompiledData::Unit to component that created this context + int m_componentObjectIndex = -1; + + // flag indicates whether the context owns the cache (after mutation) or not. + mutable QV4::IdentifierHash m_propertyNameCache; + + // Context object + QObject *m_contextObject = nullptr; + + // Any script blocks that exist on this context + union { + /* an invalidated context transitions from a strong reference to the scripts + to a weak one, so that the context doesn't needlessly holds on to the scripts, + but closures can still access them if needed + */ + QV4::PersistentValue m_importedScripts = {}; // This is a JS Array + QV4::WeakValue m_weakImportedScripts; + }; + + QUrl m_baseUrl; + QString m_baseUrlString; + + // List of imports that apply to this context + QQmlRefPointer<QQmlTypeNameCache> m_imports; + + // My children, not refcounted as that would create cyclic references + QQmlContextData *m_childContexts = nullptr; + + // My peers in parent's childContexts list; not refcounted + QQmlContextData *m_nextChild = nullptr; + QQmlContextData **m_prevChild = nullptr; + + // Expressions that use this context + QQmlJavaScriptExpression *m_expressions = nullptr; + + // Doubly-linked list of objects that are owned by this context + QQmlData *m_ownedObjects = nullptr; + + // Doubly-linked list of context guards (XXX merge with contextObjects) + QQmlGuardedContextData *m_contextGuards = nullptr; + + ContextGuard *m_idValues = nullptr; + int m_idValueCount = 0; + + // Linked contexts. this owns linkedContext. + QQmlRefPointer<QQmlContextData> m_linkedContext; + + // Linked list of uses of the Component attached property in this context + QQmlComponentAttached *m_componentAttacheds = nullptr; +}; + +QQmlContextData::ContextGuard &QQmlContextData::ContextGuard::operator=(QObject *obj) +{ + QQmlGuard<QObject>::operator=(obj); + m_context.setTag(ObjectWasSet); + m_bindings.notify(); // For alias connections + return *this; +} + + void QQmlContextData::ContextGuard::objectDestroyedImpl(QQmlGuardImpl *impl) +{ + auto This = static_cast<QQmlContextData::ContextGuard *>(impl); + if (QObject *contextObject = This->m_context->contextObject()) { + if (!QObjectPrivate::get(contextObject)->wasDeleted) + This->m_bindings.notify(); + } +} + +bool QQmlContextData::ContextGuard::wasSet() const +{ + return m_context.tag() == ObjectWasSet; +} + +QT_END_NAMESPACE + +#endif // QQMLCONTEXTDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcppbinding_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcppbinding_p.h new file mode 100644 index 0000000000000000000000000000000000000000..62992160cf02d5081b6abafb55f78c58f6907646 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcppbinding_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCPPBINDING_P_H +#define QQMLCPPBINDING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtCore/qproperty.h> +#include <QtCore/qurl.h> + +#include <QtQml/qqmlengine.h> +#include <QtQml/qqmlcontext.h> +#include <QtCore/qmetaobject.h> + +#include <private/qqmltypedata_p.h> +#include <private/qqmlpropertybinding_p.h> +#include <private/qqmlbinding_p.h> +#include <private/qv4qmlcontext_p.h> +#include <private/qqmlproperty_p.h> +#include <private/qqmlbinding_p.h> + +QT_BEGIN_NAMESPACE + +struct Q_QML_EXPORT QQmlCppBinding +{ + // TODO: this might instead be put into the QQmlEngine or QQmlAnyBinding? + static QUntypedPropertyBinding + createBindingForBindable(const QV4::ExecutableCompilationUnit *unit, QObject *thisObject, + qsizetype functionIndex, QObject *bindingTarget, int metaPropertyIndex, + int valueTypePropertyIndex, const QString &propertyName); + + static void createBindingForNonBindable(const QV4::ExecutableCompilationUnit *unit, + QObject *thisObject, qsizetype functionIndex, + QObject *bindingTarget, int metaPropertyIndex, + int valueTypePropertyIndex, + const QString &propertyName); + + static QUntypedPropertyBinding + createTranslationBindingForBindable(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit, + QObject *bindingTarget, int metaPropertyIndex, + const QQmlTranslation &translationData, + const QString &propertyName); + + static void createTranslationBindingForNonBindable( + const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit, + const QQmlSourceLocation &location, const QQmlTranslation &translationData, + QObject *thisObject, QObject *bindingTarget, int metaPropertyIndex, + const QString &propertyName, int valueTypePropertyIndex); +}; + +QT_END_NAMESPACE + +#endif // QQMLCPPBINDING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcpponassignment_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcpponassignment_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bc8abc24cb719b888d05212ec5e9283b4500f862 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcpponassignment_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCPPONASSIGNMENT_P_H +#define QQMLCPPONASSIGNMENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlpropertyvalueinterceptor_p.h> +#include <QtQml/qqmlpropertyvaluesource.h> + +QT_BEGIN_NAMESPACE + +/*! \internal + + Helper class that provides setTarget() functionality for both value + interceptors and value sources. + + Property value sources could be problematic because QQuickAbstractAnimation + changes access specifier of QQmlPropertyValueSource::setTarget() to private + (unintentionally?). This API allows to avoid manual casts to base types as + the C++ compiler would implicitly cast derived classes in this case. +*/ +struct Q_QML_EXPORT QQmlCppOnAssignmentHelper +{ + // TODO: in theory, this API might just accept QObject * and int that would + // give the QMetaProperty. using the meta property, one could create + // QQmlProperty with a call to QQmlProperty::restore() (if there's an + // overload that takes QMetaProperty instead of QQmlPropertyData - which is + // also possible to add by using QQmlPropertyData::load()) + static void set(QQmlPropertyValueInterceptor *interceptor, const QQmlProperty &property); + static void set(QQmlPropertyValueSource *valueSource, const QQmlProperty &property); +}; + +QT_END_NAMESPACE + +#endif // QQMLCPPONASSIGNMENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcpptypehelpers_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcpptypehelpers_p.h new file mode 100644 index 0000000000000000000000000000000000000000..560984183298af7f68ce289eb4aebe0cdb949fc7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcpptypehelpers_p.h @@ -0,0 +1,28 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCPPTYPEHELPERS_H +#define QQMLCPPTYPEHELPERS_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <type_traits> + +/*! \internal + Used by Qmltc to decide when value types should be passed by value or reference. + */ +template<typename T> +using passByConstRefOrValue = + std::conditional_t<((sizeof(T) > 3 * sizeof(void *)) || !std::is_trivial_v<T>), const T &, + T>; + +#endif // QQMLCPPTYPEHELPERS_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcustomparser_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcustomparser_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2431fda14aadba7a2f07dff327dfc873c8295c15 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlcustomparser_p.h @@ -0,0 +1,75 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCUSTOMPARSER_H +#define QQMLCUSTOMPARSER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqmlerror.h> +#include <QtQml/private/qqmlbinding_p.h> +#include <private/qv4compileddata_p.h> + +#include <QtCore/qbytearray.h> + +QT_BEGIN_NAMESPACE + +class QQmlPropertyValidator; +class QQmlEnginePrivate; + +class Q_QML_EXPORT QQmlCustomParser +{ +public: + enum Flag { + NoFlag = 0x00000000, + AcceptsAttachedProperties = 0x00000001, + AcceptsSignalHandlers = 0x00000002 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + QQmlCustomParser() : engine(nullptr), validator(nullptr), m_flags(NoFlag) {} + QQmlCustomParser(Flags f) : engine(nullptr), validator(nullptr), m_flags(f) {} + virtual ~QQmlCustomParser() {} + + void clearErrors(); + Flags flags() const { return m_flags; } + + virtual void verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) = 0; + virtual void applyBindings(QObject *, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) = 0; + + QVector<QQmlError> errors() const { return exceptions; } + +protected: + void error(const QV4::CompiledData::Binding *binding, const QString& description) + { error(binding->location, description); } + void error(const QV4::CompiledData::Object *object, const QString& description) + { error(object->location, description); } + void error(const QV4::CompiledData::Location &location, const QString& description); + + int evaluateEnum(const QString &, bool *ok) const; + + const QMetaObject *resolveType(const QString&) const; + +private: + QVector<QQmlError> exceptions; + QQmlEnginePrivate *engine; + const QQmlPropertyValidator *validator; + Flags m_flags; + QBiPointer<const QQmlImports, QQmlTypeNameCache> imports; + friend class QQmlPropertyValidator; + friend class QQmlObjectCreator; +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlCustomParser::Flags) + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ca5bed2e039a9dbbaa493914282f5bdccf9d87cb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldata_p.h @@ -0,0 +1,422 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDATA_P_H +#define QQMLDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> +#include <private/qobject_p.h> +#include <private/qqmlpropertyindex_p.h> +#include <private/qv4value_p.h> +#include <private/qv4persistent_p.h> +#include <private/qqmlrefcount_p.h> +#include <private/qqmlpropertycache_p.h> +#include <qqmlprivate.h> +#include <qjsengine.h> +#include <qvector.h> + +QT_BEGIN_NAMESPACE + +template <class Key, class T> class QHash; +class QQmlEngine; +class QQmlGuardImpl; +class QQmlAbstractBinding; +class QQmlBoundSignal; +class QQmlContext; +class QQmlPropertyCache; +class QQmlContextData; +class QQmlNotifier; +class QQmlDataExtended; +class QQmlNotifierEndpoint; +class QQmlPropertyObserver; + +namespace QV4 { +class ExecutableCompilationUnit; +namespace CompiledData { +struct Binding; +} +} + +// This class is structured in such a way, that simply zero'ing it is the +// default state for elemental object allocations. This is crucial in the +// workings of the QQmlInstruction::CreateSimpleObject instruction. +// Don't change anything here without first considering that case! +class Q_QML_EXPORT QQmlData : public QAbstractDeclarativeData +{ +public: + enum Ownership { DoesNotOwnMemory, OwnsMemory }; + + QQmlData(Ownership ownership); + ~QQmlData(); + + static inline void init() { + static bool initialized = false; + if (!initialized) { + initialized = true; + QAbstractDeclarativeData::destroyed = destroyed; + QAbstractDeclarativeData::signalEmitted = signalEmitted; + QAbstractDeclarativeData::receivers = receivers; + QAbstractDeclarativeData::isSignalConnected = isSignalConnected; + } + } + + static void destroyed(QAbstractDeclarativeData *, QObject *); + static void signalEmitted(QAbstractDeclarativeData *, QObject *, int, void **); + static int receivers(QAbstractDeclarativeData *, const QObject *, int); + static bool isSignalConnected(QAbstractDeclarativeData *, const QObject *, int); + + void destroyed(QObject *); + + void setImplicitDestructible() { + if (!explicitIndestructibleSet) indestructible = false; + } + + // If ownMemomry is true, the QQmlData was normally allocated. Otherwise it was allocated + // with placement new and QQmlData::destroyed is not allowed to free the memory + quint32 ownMemory:1; + // indestructible is set if and only if the object has CppOwnership + // This can be explicitly set with QJSEngine::setObjectOwnership + // Top level objects generally have CppOwnership (see QQmlcCmponentprivate::beginCreate), + // unless created by special methods like the QML component.createObject() function + quint32 indestructible:1; + // indestructible was explicitly set with setObjectOwnership + // or the object is a top-level object + quint32 explicitIndestructibleSet:1; + // set when one QObject has been wrapped into QObjectWrapper in multiple engines + // at the same time - a rather rare case + quint32 hasTaintedV4Object:1; + quint32 isQueuedForDeletion:1; + /* + * rootObjectInCreation should be true only when creating top level CPP and QML objects, + * v4 GC will check this flag, only deletes the objects when rootObjectInCreation is false. + */ + quint32 rootObjectInCreation:1; + // set when at least one of the object's properties is intercepted + quint32 hasInterceptorMetaObject:1; + quint32 hasVMEMetaObject:1; + // If we have another wrapper for a const QObject * in the multiply wrapped QObjects. + quint32 hasConstWrapper: 1; + quint32 dummy:7; + + // When bindingBitsSize < sizeof(ptr), we store the binding bit flags inside + // bindingBitsValue. When we need more than sizeof(ptr) bits, we allocated + // sufficient space and use bindingBits to point to it. + quint32 bindingBitsArraySize : 16; + typedef quintptr BindingBitsType; + enum { + BitsPerType = sizeof(BindingBitsType) * 8, + InlineBindingArraySize = 2 + }; + union { + BindingBitsType *bindingBits; + BindingBitsType bindingBitsValue[InlineBindingArraySize]; + }; + + struct NotifyList { + QAtomicInteger<quint64> connectionMask; + QQmlNotifierEndpoint *todo = nullptr; + QQmlNotifierEndpoint**notifies = nullptr; + quint16 maximumTodoIndex = 0; + quint16 notifiesSize = 0; + void layout(); + private: + void layout(QQmlNotifierEndpoint*); + }; + QAtomicPointer<NotifyList> notifyList; + + inline QQmlNotifierEndpoint *notify(int index) const; + void addNotify(int index, QQmlNotifierEndpoint *); + int endpointCount(int index); + bool signalHasEndpoint(int index) const; + + enum class DeleteNotifyList { Yes, No }; + void disconnectNotifiers(DeleteNotifyList doDelete); + + // The context that created the C++ object; not refcounted to prevent cycles + QQmlContextData *context = nullptr; + // The outermost context in which this object lives; not refcounted to prevent cycles + QQmlContextData *outerContext = nullptr; + QQmlRefPointer<QQmlContextData> ownContext; + + QQmlAbstractBinding *bindings = nullptr; + QQmlBoundSignal *signalHandlers = nullptr; + std::vector<QQmlPropertyObserver> propertyObservers; + + // Linked list for QQmlContext::contextObjects + QQmlData *nextContextObject = nullptr; + QQmlData**prevContextObject = nullptr; + + inline bool hasBindingBit(int) const; + inline void setBindingBit(QObject *obj, int); + inline void clearBindingBit(int); + + inline bool hasPendingBindingBit(int index) const; + inline void setPendingBindingBit(QObject *obj, int); + inline void clearPendingBindingBit(int); + + quint16 lineNumber = 0; + quint16 columnNumber = 0; + + quint32 jsEngineId = 0; // id of the engine that created the jsWrapper + + struct DeferredData { + DeferredData(); + ~DeferredData(); + unsigned int deferredIdx; + QMultiHash<int, const QV4::CompiledData::Binding *> bindings; + + // Not always the same as the other compilation unit + QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit; + + // Could be either context or outerContext + QQmlRefPointer<QQmlContextData> context; + Q_DISABLE_COPY(DeferredData); + }; + QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit; + QVector<DeferredData *> deferredData; + + void deferData(int objectIndex, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &, + const QQmlRefPointer<QQmlContextData> &); + void releaseDeferredData(); + + QV4::WeakValue jsWrapper; + + QQmlPropertyCache::ConstPtr propertyCache; + + QQmlGuardImpl *guards = nullptr; + + static QQmlData *get(QObjectPrivate *priv, bool create) { + // If QObjectData::isDeletingChildren is set then access to QObjectPrivate::declarativeData has + // to be avoided because QObjectPrivate::currentChildBeingDeleted is in use. + if (priv->isDeletingChildren || priv->wasDeleted) { + Q_ASSERT(!create); + return nullptr; + } else if (priv->declarativeData) { + return static_cast<QQmlData *>(priv->declarativeData); + } else if (create) { + return createQQmlData(priv); + } else { + return nullptr; + } + } + + static QQmlData *get(const QObjectPrivate *priv) { + // If QObjectData::isDeletingChildren is set then access to QObjectPrivate::declarativeData has + // to be avoided because QObjectPrivate::currentChildBeingDeleted is in use. + if (priv->isDeletingChildren || priv->wasDeleted) + return nullptr; + if (priv->declarativeData) + return static_cast<QQmlData *>(priv->declarativeData); + return nullptr; + } + + static QQmlData *get(QObject *object, bool create) { + return QQmlData::get(QObjectPrivate::get(object), create); + } + + static QQmlData *get(const QObject *object) { + return QQmlData::get(QObjectPrivate::get(object)); + + } + + static bool keepAliveDuringGarbageCollection(const QObject *object) { + QQmlData *ddata = get(object); + if (!ddata || ddata->indestructible || ddata->rootObjectInCreation) + return true; + return false; + } + + bool hasExtendedData() const { return extendedData != nullptr; } + QHash<QQmlAttachedPropertiesFunc, QObject *> *attachedProperties() const; + + static inline bool wasDeleted(const QObject *); + static inline bool wasDeleted(const QObjectPrivate *); + + static void markAsDeleted(QObject *); + static void setQueuedForDeletion(QObject *); + + static inline void flushPendingBinding(QObject *object, int coreIndex); + void flushPendingBinding(int coreIndex); + + static QQmlPropertyCache::ConstPtr ensurePropertyCache(QObject *object) + { + QQmlData *ddata = QQmlData::get(object, /*create*/true); + if (Q_LIKELY(ddata->propertyCache)) + return ddata->propertyCache; + return createPropertyCache(object); + } + + Q_ALWAYS_INLINE static uint offsetForBit(int bit) { return static_cast<uint>(bit) / BitsPerType; } + Q_ALWAYS_INLINE static BindingBitsType bitFlagForBit(int bit) { return BindingBitsType(1) << (static_cast<uint>(bit) & (BitsPerType - 1)); } + +private: + // For attachedProperties + mutable QQmlDataExtended *extendedData = nullptr; + + Q_NEVER_INLINE static QQmlData *createQQmlData(QObjectPrivate *priv); + Q_NEVER_INLINE static QQmlPropertyCache::ConstPtr createPropertyCache(QObject *object); + + Q_ALWAYS_INLINE bool hasBitSet(int bit) const + { + uint offset = offsetForBit(bit); + if (bindingBitsArraySize <= offset) + return false; + + const BindingBitsType *bits = (bindingBitsArraySize == InlineBindingArraySize) ? bindingBitsValue : bindingBits; + return bits[offset] & bitFlagForBit(bit); + } + + Q_ALWAYS_INLINE void clearBit(int bit) + { + uint offset = QQmlData::offsetForBit(bit); + if (bindingBitsArraySize > offset) { + BindingBitsType *bits = (bindingBitsArraySize == InlineBindingArraySize) ? bindingBitsValue : bindingBits; + bits[offset] &= ~QQmlData::bitFlagForBit(bit); + } + } + + Q_ALWAYS_INLINE void setBit(QObject *obj, int bit) + { + uint offset = QQmlData::offsetForBit(bit); + BindingBitsType *bits = (bindingBitsArraySize == InlineBindingArraySize) ? bindingBitsValue : bindingBits; + if (Q_UNLIKELY(bindingBitsArraySize <= offset)) + bits = growBits(obj, bit); + bits[offset] |= QQmlData::bitFlagForBit(bit); + } + + Q_NEVER_INLINE BindingBitsType *growBits(QObject *obj, int bit); + + Q_DISABLE_COPY_MOVE(QQmlData); +}; + +bool QQmlData::wasDeleted(const QObjectPrivate *priv) +{ + if (!priv || priv->wasDeleted || priv->isDeletingChildren) + return true; + + const QQmlData *ddata = QQmlData::get(priv); + return ddata && ddata->isQueuedForDeletion; +} + +bool QQmlData::wasDeleted(const QObject *object) +{ + if (!object) + return true; + + const QObjectPrivate *priv = QObjectPrivate::get(object); + return QQmlData::wasDeleted(priv); +} + +inline bool isIndexInConnectionMask(quint64 connectionMask, int index) +{ + return connectionMask & (1ULL << quint64(index % 64)); +} + +QQmlNotifierEndpoint *QQmlData::notify(int index) const +{ + // Can only happen on "home" thread. We apply relaxed semantics when loading the atomics. + + Q_ASSERT(index <= 0xFFFF); + + NotifyList *list = notifyList.loadRelaxed(); + if (!list || !isIndexInConnectionMask(list->connectionMask.loadRelaxed(), index)) + return nullptr; + + if (index < list->notifiesSize) + return list->notifies[index]; + + if (index <= list->maximumTodoIndex) { + list->layout(); + if (index < list->notifiesSize) + return list->notifies[index]; + } + + return nullptr; +} + +/* + The index MUST be in the range returned by QObjectPrivate::signalIndex() + This is different than the index returned by QMetaMethod::methodIndex() +*/ +inline bool QQmlData::signalHasEndpoint(int index) const +{ + // This can be called from any thread. + // We still use relaxed semantics. If we're on a thread different from the "home" thread + // of the QQmlData, two interesting things might happen: + // + // 1. The list might go away while we hold it. In that case we are dealing with an object whose + // QObject dtor is being executed concurrently. This is UB already without the notify lists. + // Therefore, we don't need to consider it. + // 2. The connectionMask may be amended or zeroed while we are looking at it. In that case + // we "misreport" the endpoint. Since ordering of events across threads is inherently + // nondeterministic, either result is correct in that case. We can accept it. + + NotifyList *list = notifyList.loadRelaxed(); + return list && isIndexInConnectionMask(list->connectionMask.loadRelaxed(), index); +} + +bool QQmlData::hasBindingBit(int coreIndex) const +{ + Q_ASSERT(coreIndex >= 0); + Q_ASSERT(coreIndex <= 0xffff); + + return hasBitSet(coreIndex * 2); +} + +void QQmlData::setBindingBit(QObject *obj, int coreIndex) +{ + Q_ASSERT(coreIndex >= 0); + Q_ASSERT(coreIndex <= 0xffff); + setBit(obj, coreIndex * 2); +} + +void QQmlData::clearBindingBit(int coreIndex) +{ + Q_ASSERT(coreIndex >= 0); + Q_ASSERT(coreIndex <= 0xffff); + clearBit(coreIndex * 2); +} + +bool QQmlData::hasPendingBindingBit(int coreIndex) const +{ + Q_ASSERT(coreIndex >= 0); + Q_ASSERT(coreIndex <= 0xffff); + + return hasBitSet(coreIndex * 2 + 1); +} + +void QQmlData::setPendingBindingBit(QObject *obj, int coreIndex) +{ + Q_ASSERT(coreIndex >= 0); + Q_ASSERT(coreIndex <= 0xffff); + setBit(obj, coreIndex * 2 + 1); +} + +void QQmlData::clearPendingBindingBit(int coreIndex) +{ + Q_ASSERT(coreIndex >= 0); + Q_ASSERT(coreIndex <= 0xffff); + clearBit(coreIndex * 2 + 1); +} + +void QQmlData::flushPendingBinding(QObject *object, int coreIndex) +{ + QQmlData *data = QQmlData::get(object, false); + if (data && data->hasPendingBindingBit(coreIndex)) + data->flushPendingBinding(coreIndex); +} + +QT_END_NAMESPACE + +#endif // QQMLDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldatablob_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldatablob_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6b0ecd7b3fce8667f677c5793a3664367b2e47d7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldatablob_p.h @@ -0,0 +1,231 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDATABLOB_P_H +#define QQMLDATABLOB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlrefcount_p.h> +#include <private/qqmljsdiagnosticmessage_p.h> + +#if QT_CONFIG(qml_network) +#include <QtNetwork/qnetworkreply.h> +#endif + +#include <QtQml/qqmlprivate.h> +#include <QtQml/qqmlerror.h> +#include <QtQml/qqmlabstracturlinterceptor.h> +#include <QtQml/qqmlprivate.h> + +#include <QtCore/qdatetime.h> +#include <QtCore/qfileinfo.h> +#include <QtCore/qurl.h> + +QT_BEGIN_NAMESPACE + +class QQmlTypeLoader; +class Q_QML_EXPORT QQmlDataBlob : public QQmlRefCounted<QQmlDataBlob> +{ +public: + using Ptr = QQmlRefPointer<QQmlDataBlob>; + + enum Status { + Null, // Prior to QQmlTypeLoader::load() + Loading, // Prior to data being received and dataReceived() being called + WaitingForDependencies, // While there are outstanding addDependency()s + ResolvingDependencies, // While resolving outstanding dependencies, to detect cycles + Complete, // Finished + Error // Error + }; + + enum Type { //Matched in QQmlAbstractUrlInterceptor + QmlFile = QQmlAbstractUrlInterceptor::QmlFile, + JavaScriptFile = QQmlAbstractUrlInterceptor::JavaScriptFile, + QmldirFile = QQmlAbstractUrlInterceptor::QmldirFile + }; + + QQmlDataBlob(const QUrl &, Type, QQmlTypeLoader* manager); + virtual ~QQmlDataBlob(); + + void startLoading(); + + QQmlTypeLoader *typeLoader() const { return m_typeLoader; } + + Type type() const; + + Status status() const; + bool isNull() const; + bool isLoading() const; + bool isWaiting() const; + bool isComplete() const; + bool isError() const; + bool isCompleteOrError() const; + + qreal progress() const; + + QUrl url() const; + QString urlString() const; + QUrl finalUrl() const; + QString finalUrlString() const; + + QList<QQmlError> errors() const; + + class SourceCodeData { + public: + QString readAll(QString *error) const; + QDateTime sourceTimeStamp() const; + bool exists() const; + bool isEmpty() const; + bool isValid() const + { + return hasInlineSourceCode || !fileInfo.filePath().isEmpty(); + } + + private: + friend class QQmlDataBlob; + friend class QQmlTypeLoader; + QString inlineSourceCode; + QFileInfo fileInfo; + bool hasInlineSourceCode = false; + }; + +protected: + // Can be called from within callbacks + void setError(const QQmlError &); + void setError(const QList<QQmlError> &errors); + void setError(const QQmlJS::DiagnosticMessage &error); + void setError(const QString &description); + void addDependency(QQmlDataBlob *); + + // Callbacks made in load thread + virtual void dataReceived(const SourceCodeData &) = 0; + virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *) = 0; + virtual void done(); +#if QT_CONFIG(qml_network) + virtual void networkError(QNetworkReply::NetworkError); +#endif + virtual void dependencyError(QQmlDataBlob *); + virtual void dependencyComplete(QQmlDataBlob *); + virtual void allDependenciesDone(); + + // Callbacks made in main thread + virtual void downloadProgressChanged(qreal); + virtual void completed(); + +protected: + // Manager that is currently fetching data for me + QQmlTypeLoader *m_typeLoader; + +private: + friend class QQmlTypeLoader; + friend class QQmlTypeLoaderThread; + + void tryDone(); + void cancelAllWaitingFor(); + void notifyAllWaitingOnMe(); + void notifyComplete(QQmlDataBlob *); + + struct ThreadData { + private: + enum { + StatusMask = 0x0000FFFF, + StatusShift = 0, + ProgressMask = 0x00FF0000, + ProgressShift = 16, + AsyncMask = 0x80000000, + NoMask = 0 + }; + + public: + inline ThreadData() + : _p(0) + { + } + + inline QQmlDataBlob::Status status() const + { + return QQmlDataBlob::Status((_p.loadRelaxed() & StatusMask) >> StatusShift); + } + + inline void setStatus(QQmlDataBlob::Status status) + { + while (true) { + int d = _p.loadRelaxed(); + int nd = (d & ~StatusMask) | ((status << StatusShift) & StatusMask); + if (d == nd || _p.testAndSetOrdered(d, nd)) return; + } + } + + inline bool isAsync() const + { + return _p.loadRelaxed() & AsyncMask; + } + + inline void setIsAsync(bool v) + { + while (true) { + int d = _p.loadRelaxed(); + int nd = (d & ~AsyncMask) | (v ? AsyncMask : NoMask); + if (d == nd || _p.testAndSetOrdered(d, nd)) return; + } + } + + inline qreal progress() const + { + return quint8((_p.loadRelaxed() & ProgressMask) >> ProgressShift) / float(0xFF); + } + + inline void setProgress(qreal progress) + { + quint8 v = 0xFF * progress; + while (true) { + int d = _p.loadRelaxed(); + int nd = (d & ~ProgressMask) | ((v << ProgressShift) & ProgressMask); + if (d == nd || _p.testAndSetOrdered(d, nd)) return; + } + } + + private: + QAtomicInt _p; + }; + ThreadData m_data; + + // m_errors should *always* be written before the status is set to Error. + // We use the status change as a memory fence around m_errors so that locking + // isn't required. Once the status is set to Error (or Complete), m_errors + // cannot be changed. + QList<QQmlError> m_errors; + + Type m_type; + + QUrl m_url; + QUrl m_finalUrl; + mutable QString m_urlString; + mutable QString m_finalUrlString; + + // List of QQmlDataBlob's that are waiting for me to complete. +protected: + QList<QQmlDataBlob *> m_waitingOnMe; +private: + + // List of QQmlDataBlob's that I am waiting for to complete. + QVector<QQmlRefPointer<QQmlDataBlob>> m_waitingFor; + + int m_redirectCount:30; + bool m_inCallback:1; + bool m_isDone:1; +}; + +QT_END_NAMESPACE + +#endif // QQMLDATABLOB_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugconnector_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugconnector_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cdc30686819b2f52910edfcdef36728aeacee9eb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugconnector_p.h @@ -0,0 +1,103 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGCONNECTOR_H +#define QQMLDEBUGCONNECTOR_H + +#include <QtQml/qtqmlglobal.h> +#include <QtQml/qjsengine.h> +#include <QtCore/QVariantList> + +#if QT_CONFIG(qml_debug) +#include <private/qqmldebugservice_p.h> +#endif + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +#if !QT_CONFIG(qml_debug) + +class Q_QML_EXPORT QQmlDebugConnector +{ + virtual ~QQmlDebugConnector() = default; // don't break 'override' on ~QQmlDebugServer +public: + static QQmlDebugConnector *instance() { return nullptr; } + + template<class Service> + static Service *service() { return nullptr; } + + bool hasEngine(QJSEngine *) const { return false; } + void addEngine(QJSEngine *) {} + void removeEngine(QJSEngine *) {} + + bool open(const QVariantHash &configuration = QVariantHash()) + { + Q_UNUSED(configuration); + return false; + } +}; + +#else + +class QQmlDebugService; +class Q_QML_EXPORT QQmlDebugConnector : public QObject +{ + Q_OBJECT +public: + static void setPluginKey(const QString &key); + static void setServices(const QStringList &services); + static QQmlDebugConnector *instance(); + static int dataStreamVersion() + { + return s_dataStreamVersion; + } + + virtual bool blockingMode() const = 0; + + virtual QQmlDebugService *service(const QString &name) const = 0; + + virtual void addEngine(QJSEngine *engine) = 0; + virtual void removeEngine(QJSEngine *engine) = 0; + virtual bool hasEngine(QJSEngine *engine) const = 0; + + virtual bool addService(const QString &name, QQmlDebugService *service) = 0; + virtual bool removeService(const QString &name) = 0; + + virtual bool open(const QVariantHash &configuration = QVariantHash()) = 0; + + template<class Service> + static Service *service() + { + QQmlDebugConnector *inst = instance(); + return inst ? static_cast<Service *>(inst->service(Service::s_key)) : nullptr; + } + +protected: + static QString commandLineArguments(); + static int s_dataStreamVersion; +}; + +class Q_QML_EXPORT QQmlDebugConnectorFactory : public QObject { + Q_OBJECT +public: + virtual QQmlDebugConnector *create(const QString &key) = 0; + ~QQmlDebugConnectorFactory() override; +}; + +#define QQmlDebugConnectorFactory_iid "org.qt-project.Qt.QQmlDebugConnectorFactory" + +#endif + +QT_END_NAMESPACE + +#endif // QQMLDEBUGCONNECTOR_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugpluginmanager_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugpluginmanager_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f0f173e002a549392d9284a8edd63bc8317466c0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugpluginmanager_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGPLUGINMANAGER_P_H +#define QQMLDEBUGPLUGINMANAGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QDebug> +#include <private/qtqmlglobal_p.h> +#include <private/qfactoryloader_p.h> + +QT_BEGIN_NAMESPACE + +#if !QT_CONFIG(qml_debug) + +#define Q_QML_DEBUG_PLUGIN_LOADER(interfaceName)\ + static interfaceName *load##interfaceName(const QString &key)\ + {\ + qWarning() << "Qml Debugger: QtQml is not configured for debugging. Ignoring request for"\ + << "debug plugin" << key;\ + return 0;\ + }\ + Q_DECL_UNUSED static QList<QPluginParsedMetaData> metaDataFor##interfaceName()\ + {\ + return {};\ + } + +#else // QT_CONFIG(qml_debug) + +#define Q_QML_DEBUG_PLUGIN_LOADER(interfaceName)\ + Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, interfaceName##Loader,\ + (interfaceName##Factory_iid, QLatin1String("/qmltooling")))\ + static interfaceName *load##interfaceName(const QString &key)\ + {\ + return qLoadPlugin<interfaceName, interfaceName##Factory>(interfaceName##Loader(), key);\ + }\ + Q_DECL_UNUSED static QList<QPluginParsedMetaData> metaDataFor##interfaceName()\ + {\ + return interfaceName##Loader()->metaData();\ + } + +#endif // QT_CONFIG(qml_debug) + +QT_END_NAMESPACE +#endif // QQMLDEBUGPLUGINMANAGER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugserver_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugserver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..55e7685138c4f594a558af1a3a5f429a63319973 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugserver_p.h @@ -0,0 +1,35 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGSERVER_P_H +#define QQMLDEBUGSERVER_P_H + +#include "qqmldebugconnector_p.h" + +#include <private/qtqmlglobal_p.h> +#include <QtCore/QIODevice> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlDebugServer : public QQmlDebugConnector +{ + Q_OBJECT +public: + ~QQmlDebugServer() override; + virtual void setDevice(QIODevice *socket) = 0; +}; + +QT_END_NAMESPACE + +#endif // QQMLDEBUGSERVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugserverconnection_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugserverconnection_p.h new file mode 100644 index 0000000000000000000000000000000000000000..060efda5dbb5c163c28644b516df8b58c8f49a27 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugserverconnection_p.h @@ -0,0 +1,53 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGSERVERCONNECTION_P_H +#define QQMLDEBUGSERVERCONNECTION_P_H + +#include <private/qtqmlglobal_p.h> +#include <QtCore/qobject.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlDebugServer; +class Q_QML_EXPORT QQmlDebugServerConnection : public QObject +{ + Q_OBJECT +public: + QQmlDebugServerConnection(QObject *parent = nullptr) : QObject(parent) {} + ~QQmlDebugServerConnection() override; + + virtual void setServer(QQmlDebugServer *server) = 0; + virtual bool setPortRange(int portFrom, int portTo, bool block, const QString &hostaddress) = 0; + virtual bool setFileName(const QString &fileName, bool block) = 0; + virtual bool isConnected() const = 0; + virtual void disconnect() = 0; + virtual void waitForConnection() = 0; + virtual void flush() = 0; +}; + +class Q_QML_EXPORT QQmlDebugServerConnectionFactory : public QObject +{ + Q_OBJECT +public: + ~QQmlDebugServerConnectionFactory() override; + virtual QQmlDebugServerConnection *create(const QString &key) = 0; +}; + +#define QQmlDebugServerConnectionFactory_iid "org.qt-project.Qt.QQmlDebugServerConnectionFactory" +Q_DECLARE_INTERFACE(QQmlDebugServerConnectionFactory, QQmlDebugServerConnectionFactory_iid) + +QT_END_NAMESPACE + +#endif // QQMLDEBUGSERVERCONNECTION_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugservice_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugservice_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7566216e0238ed88b795544d0c8c4bc08d723f50 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugservice_p.h @@ -0,0 +1,73 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGSERVICE_H +#define QQMLDEBUGSERVICE_H + +#include <QtCore/qobject.h> +#include <QtCore/qhash.h> + +#include <private/qtqmlglobal_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_REQUIRE_CONFIG(qml_debug); + +QT_BEGIN_NAMESPACE + +class QJSEngine; + +class QQmlDebugServicePrivate; +class Q_QML_EXPORT QQmlDebugService : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlDebugService) + +public: + ~QQmlDebugService() override; + + const QString &name() const; + float version() const; + + enum State { NotConnected, Unavailable, Enabled }; + State state() const; + void setState(State newState); + + virtual void stateAboutToBeChanged(State) {} + virtual void stateChanged(State) {} + virtual void messageReceived(const QByteArray &) {} + + virtual void engineAboutToBeAdded(QJSEngine *engine) { Q_EMIT attachedToEngine(engine); } + virtual void engineAboutToBeRemoved(QJSEngine *engine) { Q_EMIT detachedFromEngine(engine); } + + virtual void engineAdded(QJSEngine *) {} + virtual void engineRemoved(QJSEngine *) {} + + static const QHash<int, QObject *> &objectsForIds(); + static int idForObject(QObject *); + static QObject *objectForId(int id) { return objectsForIds().value(id); } + +protected: + explicit QQmlDebugService(const QString &, float version, QObject *parent = nullptr); + +Q_SIGNALS: + void attachedToEngine(QJSEngine *); + void detachedFromEngine(QJSEngine *); + + void messageToClient(const QString &name, const QByteArray &message); + void messagesToClient(const QString &name, const QList<QByteArray> &messages); +}; + +QT_END_NAMESPACE + +#endif // QQMLDEBUGSERVICE_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugservicefactory_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugservicefactory_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3389c606f3dd75d8f16db34e5b5bb3131141b5f9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugservicefactory_p.h @@ -0,0 +1,34 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGSERVICEFACTORY_P_H +#define QQMLDEBUGSERVICEFACTORY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldebugservice_p.h" + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlDebugServiceFactory : public QObject +{ + Q_OBJECT +public: + ~QQmlDebugServiceFactory() override; + virtual QQmlDebugService *create(const QString &key) = 0; +}; + +#define QQmlDebugServiceFactory_iid "org.qt-project.Qt.QQmlDebugServiceFactory" + +QT_END_NAMESPACE + +#endif // QQMLDEBUGSERVICEFACTORY_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugserviceinterfaces_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugserviceinterfaces_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8e38f3fab6625a497b00e0b1b031f71391ac9500 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugserviceinterfaces_p.h @@ -0,0 +1,253 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGSERVICEINTERFACES_P_H +#define QQMLDEBUGSERVICEINTERFACES_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> +#include <private/qtqmlglobal_p.h> +#if QT_CONFIG(qml_debug) +#include <private/qqmldebugservice_p.h> +#endif +#include <private/qqmldebugstatesdelegate_p.h> +#include <private/qqmlboundsignal_p.h> +#include <private/qqmltranslation_p.h> + +#include <limits> + +QT_BEGIN_NAMESPACE + +class QWindow; +class QQuickWindow; + + +#if !QT_CONFIG(qml_debug) + +class TranslationBindingInformation; + +class QV4DebugService +{ +public: + void signalEmitted(const QString &) {} +}; + +class QQmlProfilerService +{ +public: + void startProfiling(QJSEngine *engine, quint64 features = std::numeric_limits<quint64>::max()) + { + Q_UNUSED(engine); + Q_UNUSED(features); + } + + void stopProfiling(QJSEngine *) {} +}; + +class QQmlEngineDebugService +{ +public: + void objectCreated(QJSEngine *, QObject *) {} + static void setStatesDelegateFactory(QQmlDebugStatesDelegate *(*)()) {} +}; + +class QQmlInspectorService { +public: + void addWindow(QQuickWindow *) {} + void setParentWindow(QQuickWindow *, QWindow *) {} + void removeWindow(QQuickWindow *) {} +}; + +class QDebugMessageService {}; +class QQmlEngineControlService {}; +class QQmlNativeDebugService {}; +class QQmlDebugTranslationService { +public: + virtual void foundTranslationBinding(const TranslationBindingInformation &) {} +}; + +#else + +class Q_QML_EXPORT QV4DebugService : public QQmlDebugService +{ + Q_OBJECT +public: + ~QV4DebugService() override; + + static const QString s_key; + + virtual void signalEmitted(const QString &signal) = 0; + +protected: + friend class QQmlDebugConnector; + + explicit QV4DebugService(float version, QObject *parent = nullptr) : + QQmlDebugService(s_key, version, parent) {} +}; + +class QQmlAbstractProfilerAdapter; +class Q_QML_EXPORT QQmlProfilerService : public QQmlDebugService +{ + Q_OBJECT +public: + ~QQmlProfilerService() override; + + static const QString s_key; + + virtual void addGlobalProfiler(QQmlAbstractProfilerAdapter *profiler) = 0; + virtual void removeGlobalProfiler(QQmlAbstractProfilerAdapter *profiler) = 0; + + virtual void startProfiling(QJSEngine *engine, + quint64 features = std::numeric_limits<quint64>::max()) = 0; + virtual void stopProfiling(QJSEngine *engine) = 0; + + virtual void dataReady(QQmlAbstractProfilerAdapter *profiler) = 0; + +protected: + friend class QQmlDebugConnector; + + explicit QQmlProfilerService(float version, QObject *parent = nullptr) : + QQmlDebugService(s_key, version, parent) {} +}; + +class Q_QML_EXPORT QQmlEngineDebugService : public QQmlDebugService +{ + Q_OBJECT +public: + ~QQmlEngineDebugService() override; + + static const QString s_key; + + virtual void objectCreated(QJSEngine *engine, QObject *object) = 0; + static void setStatesDelegateFactory(QQmlDebugStatesDelegate *(*factory)()); + static QQmlDebugStatesDelegate *createStatesDelegate(); + +protected: + friend class QQmlDebugConnector; + + explicit QQmlEngineDebugService(float version, QObject *parent = nullptr) : + QQmlDebugService(s_key, version, parent) {} + + QQmlBoundSignal *nextSignal(QQmlBoundSignal *prev) { return prev->m_nextSignal; } +}; + +#if QT_CONFIG(translation) +struct TranslationBindingInformation +{ + static const TranslationBindingInformation + create(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, + const QV4::CompiledData::Binding *binding, QObject *scopeObject, + QQmlRefPointer<QQmlContextData> ctxt); + + QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit; + QObject *scopeObject; + QQmlRefPointer<QQmlContextData> ctxt; + + QString propertyName; + QQmlTranslation translation; + + quint32 line; + quint32 column; +}; + +class Q_QML_EXPORT QQmlDebugTranslationService : public QQmlDebugService +{ + Q_OBJECT +public: + ~QQmlDebugTranslationService() override; + + static const QString s_key; + + virtual void foundTranslationBinding(const TranslationBindingInformation &translationBindingInformation) = 0; +protected: + friend class QQmlDebugConnector; + + explicit QQmlDebugTranslationService(float version, QObject *parent = nullptr) : + QQmlDebugService(s_key, version, parent) {} + +}; +#endif //QT_CONFIG(translation) + +class Q_QML_EXPORT QQmlInspectorService : public QQmlDebugService +{ + Q_OBJECT +public: + ~QQmlInspectorService() override; + + static const QString s_key; + + virtual void addWindow(QQuickWindow *) = 0; + virtual void setParentWindow(QQuickWindow *, QWindow *) = 0; + virtual void removeWindow(QQuickWindow *) = 0; + +protected: + friend class QQmlDebugConnector; + + explicit QQmlInspectorService(float version, QObject *parent = nullptr) : + QQmlDebugService(s_key, version, parent) {} +}; + +class Q_QML_EXPORT QDebugMessageService : public QQmlDebugService +{ + Q_OBJECT +public: + ~QDebugMessageService() override; + + static const QString s_key; + + virtual void synchronizeTime(const QElapsedTimer &otherTimer) = 0; + +protected: + friend class QQmlDebugConnector; + + explicit QDebugMessageService(float version, QObject *parent = nullptr) : + QQmlDebugService(s_key, version, parent) {} +}; + +class Q_QML_EXPORT QQmlEngineControlService : public QQmlDebugService +{ + Q_OBJECT +public: + ~QQmlEngineControlService() override; + + static const QString s_key; + +protected: + friend class QQmlDebugConnector; + + QQmlEngineControlService(float version, QObject *parent = nullptr) : + QQmlDebugService(s_key, version, parent) {} + +}; + +class Q_QML_EXPORT QQmlNativeDebugService : public QQmlDebugService +{ + Q_OBJECT +public: + ~QQmlNativeDebugService() override; + + static const QString s_key; + +protected: + friend class QQmlDebugConnector; + + explicit QQmlNativeDebugService(float version, QObject *parent = nullptr) + : QQmlDebugService(s_key, version, parent) {} +}; + +#endif + +QT_END_NAMESPACE + +#endif // QQMLDEBUGSERVICEINTERFACES_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugstatesdelegate_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugstatesdelegate_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7b2fb3881941916007de1414b5831b03eebd62b3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugstatesdelegate_p.h @@ -0,0 +1,67 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGSTATESDELEGATE_P_H +#define QQMLDEBUGSTATESDELEGATE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qtqmlglobal.h> +#include <QtCore/QList> +#include <QtCore/QPointer> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +#if !QT_CONFIG(qml_debug) + +class QQmlDebugStatesDelegate {}; + +#else + +class QQmlContext; +class QQmlProperty; +class QObject; +class QString; +class QVariant; + +class QQmlDebugStatesDelegate +{ +protected: + QQmlDebugStatesDelegate() {} + +public: + virtual ~QQmlDebugStatesDelegate() {} + + virtual void buildStatesList(bool cleanList, + const QList<QPointer<QObject> > &instances) = 0; + virtual void updateBinding(QQmlContext *context, + const QQmlProperty &property, + const QVariant &expression, bool isLiteralValue, + const QString &fileName, int line, int column, + bool *inBaseState) = 0; + virtual bool setBindingForInvalidProperty(QObject *object, + const QString &propertyName, + const QVariant &expression, + bool isLiteralValue) = 0; + virtual void resetBindingForInvalidProperty(QObject *object, + const QString &propertyName) = 0; + +private: + Q_DISABLE_COPY(QQmlDebugStatesDelegate) +}; + +#endif + +QT_END_NAMESPACE + +#endif // QQMLDEBUGSTATESDELEGATE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugtranslationprotocol_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugtranslationprotocol_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1069606124db1d2b7dffdb8ec9caf650a49798c2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldebugtranslationprotocol_p.h @@ -0,0 +1,265 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQMLDEBUGTRANSLATIONPROTOCOL_P_H +#define QQMLDEBUGTRANSLATIONPROTOCOL_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +#include <QtCore/qdatastream.h> +#include <QtCore/qbuffer.h> +#include <QtCore/qurl.h> +#include <QtCore/qobjectdefs.h> +#include <QtCore/qmetaobject.h> +#include <QtCore/private/qglobal_p.h> +#include <tuple> + +QT_BEGIN_NAMESPACE + +namespace QQmlDebugTranslation { + +enum class Request { + ChangeLanguage = 1, + StateList, + ChangeState, + TranslationIssues, + TranslatableTextOccurrences, + WatchTextElides, + DisableWatchTextElides, + // following are obsolete, just provided for compilation compatibility + MissingTranslations +}; + +enum class Reply { + LanguageChanged = 101, + StateList, + StateChanged, + TranslationIssues, + TranslatableTextOccurrences, + // following are obsolete, just provided for compilation compatibility + MissingTranslations, + TextElided +}; + +inline QDataStream &operator<<(QDataStream &ds, Request r) +{ + return ds << int(r); +} + +inline QDataStream &operator>>(QDataStream &ds, Request &r) +{ + int i; + ds >> i; + r = Request(i); + return ds; +} + +inline QDataStream &operator<<(QDataStream &ds, Reply r) +{ + return ds << int(r); +} + +inline QDataStream &operator>>(QDataStream &ds, Reply &r) +{ + int i; + ds >> i; + r = Reply(i); + return ds; +} + +inline QByteArray createChangeLanguageRequest(QDataStream &packet, const QUrl &url, + const QString &locale) +{ + packet << Request::ChangeLanguage << url << locale; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createChangeStateRequest(QDataStream &packet, const QString &state) +{ + packet << Request::ChangeState << state; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createMissingTranslationsRequest(QDataStream &packet) +{ + packet << Request::MissingTranslations; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createTranslationIssuesRequest(QDataStream &packet) +{ + packet << Request::TranslationIssues; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createTranslatableTextOccurrencesRequest(QDataStream &packet) +{ + packet << Request::TranslatableTextOccurrences; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createStateListRequest(QDataStream &packet) +{ + packet << Request::StateList; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createWatchTextElidesRequest(QDataStream &packet) +{ + packet << Request::WatchTextElides; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createDisableWatchTextElidesRequest(QDataStream &packet) +{ + packet << Request::DisableWatchTextElides; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +class CodeMarker +{ +public: + friend QDataStream &operator>>(QDataStream &stream, CodeMarker &codeMarker) + { + return stream >> codeMarker.url + >> codeMarker.line + >> codeMarker.column; + } + + friend QDataStream &operator<<(QDataStream &stream, const CodeMarker &codeMarker) + { + return stream << codeMarker.url + << codeMarker.line + << codeMarker.column; + } + + friend bool operator<(const CodeMarker &first, const CodeMarker &second) + { + return std::tie(first.url, first.line, first.column) + < std::tie(second.url, second.line, second.column); + } + + friend bool operator==(const CodeMarker &first, const CodeMarker &second) + { + return first.line == second.line + && first.column == second.column + && first.url == second.url; + } + + QUrl url; + int line = -1; + int column = -1; +}; +class TranslationIssue +{ +public: + enum class Type{ + Missing, + Elided + }; + + friend QDataStream &operator>>(QDataStream &stream, TranslationIssue &issue) + { + int t; + stream >> issue.codeMarker + >> issue.language + >> t; + issue.type = Type(t); + return stream; + } + + friend QDataStream &operator<<(QDataStream &stream, const TranslationIssue &issue) + { + return stream << issue.codeMarker + << issue.language + << int(issue.type); + } + + friend bool operator==(const TranslationIssue &first, const TranslationIssue &second) + { + return first.type == second.type + && first.language == second.language + && first.codeMarker == second.codeMarker; + } + + QString toDebugString() const + { + QString debugString(QLatin1String( + "TranslationIssue(type=%1, line=%2, column=%3, url=%4, language=%5)")); + return debugString.arg(type == TranslationIssue::Type::Missing ? QLatin1String("Missing") + : QLatin1String("Elided"), + QString::number(codeMarker.line), QString::number(codeMarker.column), + codeMarker.url.toString(), language); + } + + QString language; + Type type = Type::Missing; + CodeMarker codeMarker; +}; +class QmlElement +{ +public: + QmlElement() = default; + + friend QDataStream &operator>>(QDataStream &stream, QmlElement &qmlElement) + { + return stream >> qmlElement.codeMarker >> qmlElement.elementId >> qmlElement.elementType + >> qmlElement.propertyName >> qmlElement.translationId >> qmlElement.translatedText + >> qmlElement.fontFamily >> qmlElement.fontPointSize >> qmlElement.fontPixelSize + >> qmlElement.fontStyleName >> qmlElement.horizontalAlignment + >> qmlElement.verticalAlignment >> qmlElement.stateName; + } + + friend QDataStream &operator<<(QDataStream &stream, const QmlElement &qmlElement) + { + return stream << qmlElement.codeMarker << qmlElement.elementId << qmlElement.elementType + << qmlElement.propertyName << qmlElement.translationId + << qmlElement.translatedText << qmlElement.fontFamily + << qmlElement.fontPointSize << qmlElement.fontPixelSize + << qmlElement.fontStyleName << qmlElement.horizontalAlignment + << qmlElement.verticalAlignment << qmlElement.stateName; + } + + CodeMarker codeMarker; + QString propertyName; + QString translationId; + QString translatedText; + QString fontFamily; + QString fontStyleName; + QString elementId; + QString elementType; + qreal fontPointSize = 0.0; + QString stateName; + int fontPixelSize = 0; + int horizontalAlignment = 0; + int verticalAlignment = 0; +}; + +class QmlState +{ +public: + QmlState() = default; + + friend QDataStream &operator>>(QDataStream &stream, QmlState &qmlState) + { + return stream >> qmlState.name; + } + + friend QDataStream &operator<<(QDataStream &stream, const QmlState &qmlState) + { + return stream << qmlState.name; + } + + QString name; +}; +} + +QT_END_NAMESPACE + +#endif // QQMLDEBUGTRANSLATIONPROTOCOL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldelayedcallqueue_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldelayedcallqueue_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e6c6e2f98ec884f13418674ddfc0bb1cdb05d8f3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldelayedcallqueue_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDELAYEDCALLQUEUE_P_H +#define QQMLDELAYEDCALLQUEUE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtCore/qobject.h> +#include <QtCore/qmetaobject.h> +#include <QtCore/qmetatype.h> +#include <private/qqmlguard_p.h> +#include <private/qv4context_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlDelayedCallQueue : public QObject +{ + Q_OBJECT +public: + QQmlDelayedCallQueue(); + ~QQmlDelayedCallQueue() override; + + void init(QV4::ExecutionEngine *); + + static QV4::ReturnedValue addUniquelyAndExecuteLater(QV4::ExecutionEngine *engine, + QQmlV4FunctionPtr args); + +public Q_SLOTS: + void ticked(); + +private: + struct DelayedFunctionCall + { + DelayedFunctionCall() {} + DelayedFunctionCall(QV4::PersistentValue function) + : m_function(function), m_guarded(false) { } + + void execute(QV4::ExecutionEngine *engine) const; + + QV4::PersistentValue m_function; + QV4::PersistentValue m_args; + QQmlGuard<QObject> m_objectGuard; + bool m_guarded; + }; + + void storeAnyArguments(DelayedFunctionCall& dfc, QQmlV4FunctionPtr args, int offset, QV4::ExecutionEngine *engine); + void executeAllExpired_Later(); + + QV4::ExecutionEngine *m_engine; + QVector<DelayedFunctionCall> m_delayedFunctionCalls; + QMetaMethod m_tickedMethod; + bool m_callbackOutstanding; +}; + +QT_END_NAMESPACE + +#endif // QQMLDELAYEDCALLQUEUE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldirdata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldirdata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5c03c0bea23c62b275cc3dd8485efff2c649487b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldirdata_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDIRDATA_P_H +#define QQMLDIRDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmltypeloader_p.h> + +QT_BEGIN_NAMESPACE + +class Q_AUTOTEST_EXPORT QQmlQmldirData : public QQmlTypeLoader::Blob +{ +private: + friend class QQmlTypeLoader; + + QQmlQmldirData(const QUrl &, QQmlTypeLoader *); + +public: + const QString &content() const; + QV4::CompiledData::Location importLocation(Blob *blob) const; + + template<typename Callback> + bool processImports(Blob *blob, const Callback &callback) const + { + bool result = true; + const auto range = m_imports.equal_range(blob); + for (auto it = range.first; it != range.second; ++it) { + // Do we need to resolve this import? + if ((it->import->priority == 0) || (it->import->priority > it->priority)) { + // This is the (current) best resolution for this import + if (!callback(it->import)) + result = false; + it->import->priority = it->priority; + } + } + return result; + } + + void setPriority(Blob *, PendingImportPtr, int); + +protected: + void dataReceived(const SourceCodeData &) override; + void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *) override; + +private: + struct PrioritizedImport { + PendingImportPtr import; + int priority = 0; + }; + + QString m_content; + QMultiHash<Blob *, PrioritizedImport> m_imports; +}; + +QT_END_NAMESPACE + +#endif // QQMLDIRDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldirparser_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldirparser_p.h new file mode 100644 index 0000000000000000000000000000000000000000..57ba336fd266b197b2cbd085b2112cceadb063f7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmldirparser_p.h @@ -0,0 +1,171 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDIRPARSER_P_H +#define QQMLDIRPARSER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/QUrl> +#include <QtCore/QHash> +#include <QtCore/QDebug> +#include <QtCore/QTypeRevision> +#include <private/qtqmlcompilerglobal_p.h> +#include <private/qqmljsdiagnosticmessage_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlEngine; +class Q_QML_COMPILER_EXPORT QQmlDirParser +{ +public: + void clear(); + bool parse(const QString &source); + void disambiguateFileSelectors(); + + bool hasError() const { return !_errors.isEmpty(); } + void setError(const QQmlJS::DiagnosticMessage &); + QList<QQmlJS::DiagnosticMessage> errors(const QString &uri) const; + + QString typeNamespace() const { return _typeNamespace; } + void setTypeNamespace(const QString &s) { _typeNamespace = s; } + + static void checkNonRelative(const char *item, const QString &typeName, const QString &fileName) + { + if (fileName.startsWith(QLatin1Char('/'))) { + qWarning() << item << typeName + << "is specified with non-relative URL" << fileName << "in a qmldir file." + << "URLs in qmldir files should be relative to the qmldir file's directory."; + } + } + + struct Plugin + { + Plugin() = default; + + Plugin(const QString &name, const QString &path, bool optional) + : name(name), path(path), optional(optional) + { + checkNonRelative("Plugin", name, path); + } + + QString name; + QString path; + bool optional = false; + }; + + struct Component + { + Component() = default; + + Component(const QString &typeName, const QString &fileName, QTypeRevision version) + : typeName(typeName), fileName(fileName), version(version), + internal(false), singleton(false) + { + checkNonRelative("Component", typeName, fileName); + } + + QString typeName; + QString fileName; + QTypeRevision version = QTypeRevision::zero(); + bool internal = false; + bool singleton = false; + }; + + struct Script + { + Script() = default; + + Script(const QString &nameSpace, const QString &fileName, QTypeRevision version) + : nameSpace(nameSpace), fileName(fileName), version(version) + { + checkNonRelative("Script", nameSpace, fileName); + } + + QString nameSpace; + QString fileName; + QTypeRevision version = QTypeRevision::zero(); + }; + + struct Import + { + enum Flag { + Default = 0x0, + Auto = 0x1, // forward the version of the importing module + Optional = 0x2, // is not automatically imported but only a tooling hint + OptionalDefault = + 0x4, // tooling hint only, denotes this entry should be imported by tooling + }; + Q_DECLARE_FLAGS(Flags, Flag) + + Import() = default; + Import(QString module, QTypeRevision version, Flags flags) + : module(module), version(version), flags(flags) + { + } + + QString module; + QTypeRevision version; // invalid version is latest version, unless Flag::Auto + Flags flags; + + friend bool operator==(const Import &a, const Import &b) + { + return a.module == b.module && a.version == b.version && a.flags == b.flags; + } + }; + + QMultiHash<QString,Component> components() const { return _components; } + QList<Import> dependencies() const { return _dependencies; } + QList<Import> imports() const { return _imports; } + QList<Script> scripts() const { return _scripts; } + QList<Plugin> plugins() const { return _plugins; } + bool designerSupported() const { return _designerSupported; } + bool isStaticModule() const { return _isStaticModule; } + bool isSystemModule() const { return _isSystemModule; } + + QStringList typeInfos() const { return _typeInfos; } + QStringList classNames() const { return _classNames; } + QString preferredPath() const { return _preferredPath; } + QString linkTarget() const { return _linkTarget; } + +private: + bool maybeAddComponent(const QString &typeName, const QString &fileName, const QString &version, QHash<QString,Component> &hash, int lineNumber = -1, bool multi = true); + void reportError(quint16 line, quint16 column, const QString &message); + +private: + QList<QQmlJS::DiagnosticMessage> _errors; + QString _typeNamespace; + QString _preferredPath; + QMultiHash<QString,Component> _components; + QList<Import> _dependencies; + QList<Import> _imports; + QList<Script> _scripts; + QList<Plugin> _plugins; + bool _designerSupported = false; + bool _isStaticModule = false; + bool _isSystemModule = false; + QStringList _typeInfos; + QStringList _classNames; + QString _linkTarget; +}; + +using QQmlDirComponents = QMultiHash<QString,QQmlDirParser::Component>; +using QQmlDirScripts = QList<QQmlDirParser::Script>; +using QQmlDirPlugins = QList<QQmlDirParser::Plugin>; +using QQmlDirImports = QList<QQmlDirParser::Import>; + +QDebug &operator<< (QDebug &, const QQmlDirParser::Component &); +QDebug &operator<< (QDebug &, const QQmlDirParser::Script &); + +QT_END_NAMESPACE + +#endif // QQMLDIRPARSER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlengine_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dd3283d691e7e73fe108534e02cade1f0b9539c2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlengine_p.h @@ -0,0 +1,418 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLENGINE_P_H +#define QQMLENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlengine.h" + +#include <private/qfieldlist_p.h> +#include <private/qintrusivelist_p.h> +#include <private/qjsengine_p.h> +#include <private/qjsvalue_p.h> +#include <private/qpodvector_p.h> +#include <private/qqmldirparser_p.h> +#include <private/qqmlimport_p.h> +#include <private/qqmlmetatype_p.h> +#include <private/qqmlnotifier_p.h> +#include <private/qqmlproperty_p.h> +#include <private/qqmltypeloader_p.h> +#include <private/qqmlvaluetype_p.h> +#include <private/qrecyclepool_p.h> +#include <private/qv4engine_p.h> + +#include <QtQml/qqml.h> +#include <QtQml/qqmlcontext.h> + +#include <QtCore/qlist.h> +#include <QtCore/qmetaobject.h> +#include <QtCore/qmutex.h> +#include <QtCore/qpair.h> +#include <QtCore/qpointer.h> +#include <QtCore/qproperty.h> +#include <QtCore/qstack.h> +#include <QtCore/qstring.h> +#include <QtCore/qthread.h> + +#include <atomic> + +QT_BEGIN_NAMESPACE + +class QNetworkAccessManager; +class QQmlDelayedError; +class QQmlIncubator; +class QQmlMetaObject; +class QQmlNetworkAccessManagerFactory; +class QQmlObjectCreator; +class QQmlProfiler; +class QQmlPropertyCapture; + +// This needs to be declared here so that the pool for it can live in QQmlEnginePrivate. +// The inline method definitions are in qqmljavascriptexpression_p.h +class QQmlJavaScriptExpressionGuard : public QQmlNotifierEndpoint +{ +public: + inline QQmlJavaScriptExpressionGuard(QQmlJavaScriptExpression *); + + static inline QQmlJavaScriptExpressionGuard *New(QQmlJavaScriptExpression *e, + QQmlEngine *engine); + inline void Delete(); + + QQmlJavaScriptExpression *expression; + QQmlJavaScriptExpressionGuard *next; +}; + +struct QPropertyChangeTrigger : QPropertyObserver { + Q_DISABLE_COPY_MOVE(QPropertyChangeTrigger) + + QPropertyChangeTrigger(QQmlJavaScriptExpression *expression) + : QPropertyObserver(&QPropertyChangeTrigger::trigger) + , m_expression(expression) + { + } + + QPointer<QObject> target; + QQmlJavaScriptExpression *m_expression; + int propertyIndex = 0; + static void trigger(QPropertyObserver *, QUntypedPropertyData *); + + QMetaProperty property() const; +}; + +struct TriggerList : QPropertyChangeTrigger { + TriggerList(QQmlJavaScriptExpression *expression) + : QPropertyChangeTrigger(expression) + {} + TriggerList *next = nullptr; +}; + +class Q_QML_EXPORT QQmlEnginePrivate : public QJSEnginePrivate +{ + Q_DECLARE_PUBLIC(QQmlEngine) +public: + explicit QQmlEnginePrivate(QQmlEngine *q) : importDatabase(q), typeLoader(q) {} + ~QQmlEnginePrivate() override; + + void init(); + // No mutex protecting baseModulesUninitialized, because use outside QQmlEngine + // is just qmlClearTypeRegistrations (which can't be called while an engine exists) + static bool baseModulesUninitialized; + + QQmlPropertyCapture *propertyCapture = nullptr; + + QRecyclePool<QQmlJavaScriptExpressionGuard> jsExpressionGuardPool; + QRecyclePool<TriggerList> qPropertyTriggerPool; + + QQmlContext *rootContext = nullptr; + Q_OBJECT_BINDABLE_PROPERTY(QQmlEnginePrivate, QString, translationLanguage); + +#if !QT_CONFIG(qml_debug) + static const quintptr profiler = 0; +#else + QQmlProfiler *profiler = nullptr; +#endif + + bool outputWarningsToMsgLog = true; + + // Bindings that have had errors during startup + QQmlDelayedError *erroredBindings = nullptr; + int inProgressCreations = 0; + + QV4::ExecutionEngine *v4engine() const { return q_func()->handle(); } + +#if QT_CONFIG(qml_worker_script) + QThread *workerScriptEngine = nullptr; +#endif + + QUrl baseUrl; + + QQmlObjectCreator *activeObjectCreator = nullptr; +#if QT_CONFIG(qml_network) + QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const; + QNetworkAccessManager *getNetworkAccessManager() const; + mutable QNetworkAccessManager *networkAccessManager = nullptr; + mutable QQmlNetworkAccessManagerFactory *networkAccessManagerFactory = nullptr; +#endif + mutable QRecursiveMutex imageProviderMutex; + QHash<QString,QSharedPointer<QQmlImageProviderBase> > imageProviders; + QSharedPointer<QQmlImageProviderBase> imageProvider(const QString &providerId) const; + + QList<QQmlAbstractUrlInterceptor *> urlInterceptors; + + int scarceResourcesRefCount = 0; + void referenceScarceResources(); + void dereferenceScarceResources(); + + QQmlImportDatabase importDatabase; + QQmlTypeLoader typeLoader; + + QString offlineStoragePath; + + // Unfortunate workaround to avoid a circular dependency between + // qqmlengine_p.h and qqmlincubator_p.h + struct Incubator { + QIntrusiveListNode next; + }; + QIntrusiveList<Incubator, &Incubator::next> incubatorList; + unsigned int incubatorCount = 0; + QQmlIncubationController *incubationController = nullptr; + void incubate(QQmlIncubator &, const QQmlRefPointer<QQmlContextData> &); + + // These methods may be called from any thread + QString offlineStorageDatabaseDirectory() const; + + bool isTypeLoaded(const QUrl &url) const; + bool isScriptLoaded(const QUrl &url) const; + + template <typename T> + T singletonInstance(const QQmlType &type); + + void sendQuit(); + void sendExit(int retCode = 0); + void warning(const QQmlError &); + void warning(const QList<QQmlError> &); + static void warning(QQmlEngine *, const QQmlError &); + static void warning(QQmlEngine *, const QList<QQmlError> &); + static void warning(QQmlEnginePrivate *, const QQmlError &); + static void warning(QQmlEnginePrivate *, const QList<QQmlError> &); + + inline static QV4::ExecutionEngine *getV4Engine(QQmlEngine *e); + inline static QQmlEnginePrivate *get(QQmlEngine *e); + inline static const QQmlEnginePrivate *get(const QQmlEngine *e); + inline static QQmlEnginePrivate *get(QQmlContext *c); + inline static QQmlEnginePrivate *get(const QQmlRefPointer<QQmlContextData> &c); + inline static QQmlEngine *get(QQmlEnginePrivate *p); + inline static QQmlEnginePrivate *get(QV4::ExecutionEngine *e); + + static QList<QQmlError> qmlErrorFromDiagnostics(const QString &fileName, const QList<QQmlJS::DiagnosticMessage> &diagnosticMessages); + + static bool designerMode(); + static void activateDesignerMode(); + + static std::atomic<bool> qml_debugging_enabled; + + mutable QMutex networkAccessManagerMutex; + + QQmlGadgetPtrWrapper *valueTypeInstance(QMetaType type) + { + int typeIndex = type.id(); + auto it = cachedValueTypeInstances.constFind(typeIndex); + if (it != cachedValueTypeInstances.cend()) + return *it; + + if (QQmlValueType *valueType = QQmlMetaType::valueType(type)) { + QQmlGadgetPtrWrapper *instance = new QQmlGadgetPtrWrapper(valueType); + cachedValueTypeInstances.insert(typeIndex, instance); + return instance; + } + + return nullptr; + } + + void executeRuntimeFunction(const QUrl &url, qsizetype functionIndex, QObject *thisObject, + int argc = 0, void **args = nullptr, QMetaType *types = nullptr); + void executeRuntimeFunction(const QV4::ExecutableCompilationUnit *unit, qsizetype functionIndex, + QObject *thisObject, int argc = 0, void **args = nullptr, + QMetaType *types = nullptr); + QV4::ExecutableCompilationUnit *compilationUnitFromUrl(const QUrl &url); + QQmlRefPointer<QQmlContextData> + createInternalContext(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit, + const QQmlRefPointer<QQmlContextData> &parentContext, + int subComponentIndex, bool isComponentRoot); + static void setInternalContext(QObject *This, const QQmlRefPointer<QQmlContextData> &context, + QQmlContextData::QmlObjectKind kind) + { + Q_ASSERT(This); + QQmlData *ddata = QQmlData::get(This, /*create*/ true); + // NB: copied from QQmlObjectCreator::createInstance() + // + // the if-statement logic to determine the kind is: + // if (static_cast<quint32>(index) == 0 || ddata->rootObjectInCreation || isInlineComponent) + // then QQmlContextData::DocumentRoot. here, we pass this through qmltc + context->installContext(ddata, kind); + Q_ASSERT(qmlEngine(This)); + } + +private: + class SingletonInstances : private QHash<QQmlType::SingletonInstanceInfo::ConstPtr, QJSValue> + { + public: + void convertAndInsert( + QV4::ExecutionEngine *engine, const QQmlType::SingletonInstanceInfo::ConstPtr &type, + QJSValue *value) + { + QJSValuePrivate::manageStringOnV4Heap(engine, value); + insert(type, *value); + } + + void clear() + { + const auto canDelete = [](QObject *instance, const auto &siinfo) -> bool { + if (!instance) + return false; + + if (!siinfo->url.isEmpty()) + return true; + + const auto *ddata = QQmlData::get(instance, false); + return !(ddata && ddata->indestructible && ddata->explicitIndestructibleSet); + }; + + for (auto it = constBegin(), end = constEnd(); it != end; ++it) { + auto *instance = it.value().toQObject(); + if (canDelete(instance, it.key())) + QQmlData::markAsDeleted(instance); + } + + for (auto it = constBegin(), end = constEnd(); it != end; ++it) { + QObject *instance = it.value().toQObject(); + + if (canDelete(instance, it.key())) + delete instance; + } + + QHash<QQmlType::SingletonInstanceInfo::ConstPtr, QJSValue>::clear(); + } + + using QHash<QQmlType::SingletonInstanceInfo::ConstPtr, QJSValue>::value; + using QHash<QQmlType::SingletonInstanceInfo::ConstPtr, QJSValue>::take; + }; + + SingletonInstances singletonInstances; + QHash<int, QQmlGadgetPtrWrapper *> cachedValueTypeInstances; + + static bool s_designerMode; + + void cleanupScarceResources(); +}; + +/* + This function should be called prior to evaluation of any js expression, + so that scarce resources are not freed prematurely (eg, if there is a + nested javascript expression). + */ +inline void QQmlEnginePrivate::referenceScarceResources() +{ + scarceResourcesRefCount += 1; +} + +/* + This function should be called after evaluation of the js expression is + complete, and so the scarce resources may be freed safely. + */ +inline void QQmlEnginePrivate::dereferenceScarceResources() +{ + Q_ASSERT(scarceResourcesRefCount > 0); + scarceResourcesRefCount -= 1; + + // if the refcount is zero, then evaluation of the "top level" + // expression must have completed. We can safely release the + // scarce resources. + if (Q_LIKELY(scarceResourcesRefCount == 0)) { + QV4::ExecutionEngine *engine = v4engine(); + if (Q_UNLIKELY(!engine->scarceResources.isEmpty())) { + cleanupScarceResources(); + } + } +} + +QV4::ExecutionEngine *QQmlEnginePrivate::getV4Engine(QQmlEngine *e) +{ + Q_ASSERT(e); + + return e->handle(); +} + +QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlEngine *e) +{ + Q_ASSERT(e); + + return e->d_func(); +} + +const QQmlEnginePrivate *QQmlEnginePrivate::get(const QQmlEngine *e) +{ + Q_ASSERT(e); + + return e ? e->d_func() : nullptr; +} + +template<typename Context> +QQmlEnginePrivate *contextEngine(const Context &context) +{ + if (!context) + return nullptr; + if (QQmlEngine *engine = context->engine()) + return QQmlEnginePrivate::get(engine); + return nullptr; +} + +QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContext *c) +{ + return contextEngine(c); +} + +QQmlEnginePrivate *QQmlEnginePrivate::get(const QQmlRefPointer<QQmlContextData> &c) +{ + return contextEngine(c); +} + +QQmlEngine *QQmlEnginePrivate::get(QQmlEnginePrivate *p) +{ + Q_ASSERT(p); + + return p->q_func(); +} + +QQmlEnginePrivate *QQmlEnginePrivate::get(QV4::ExecutionEngine *e) +{ + QQmlEngine *qmlEngine = e->qmlEngine(); + if (!qmlEngine) + return nullptr; + return get(qmlEngine); +} + +template<> +Q_QML_EXPORT QJSValue QQmlEnginePrivate::singletonInstance<QJSValue>(const QQmlType &type); + +template<typename T> +T QQmlEnginePrivate::singletonInstance(const QQmlType &type) { + return qobject_cast<T>(singletonInstance<QJSValue>(type).toQObject()); +} + +struct LoadHelper final : QQmlTypeLoader::Blob +{ + LoadHelper(QQmlTypeLoader *loader, QAnyStringView uri); + + struct ResolveTypeResult + { + enum Status { NoSuchModule, ModuleFound } status; + QQmlType type; + }; + + ResolveTypeResult resolveType(QAnyStringView typeName); + +protected: + void dataReceived(const SourceCodeData &) final { Q_UNREACHABLE(); } + void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *) final { Q_UNREACHABLE(); } + +private: + bool couldFindModule() const; + QString m_uri; +}; + + +QT_END_NAMESPACE + +#endif // QQMLENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlenumdata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlenumdata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..87a4efddb9db3001c9965571afc27c739196e079 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlenumdata_p.h @@ -0,0 +1,30 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLENUMDATA_P_H +#define QQMLENUMDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlenumvalue_p.h> + +QT_BEGIN_NAMESPACE + +struct QQmlEnumData +{ + QString name; + QVector<QQmlEnumValue> values; +}; + +QT_END_NAMESPACE + +#endif // QQMLENUMDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlenumvalue_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlenumvalue_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f33633ecf18ec1f3c6eb855daf19a634bb736613 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlenumvalue_p.h @@ -0,0 +1,33 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLENUMVALUE_P_H +#define QQMLENUMVALUE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +struct QQmlEnumValue +{ + QQmlEnumValue() {} + QQmlEnumValue(const QString &n, int v) : namedValue(n), value(v) {} + QString namedValue; + int value = -1; +}; + +QT_END_NAMESPACE + +#endif // QQMLENUMVALUE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlexpression_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlexpression_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3c7ff05b910db7ea31eb751c187485757d4dae78 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlexpression_p.h @@ -0,0 +1,76 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLEXPRESSION_P_H +#define QQMLEXPRESSION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlexpression.h" + +#include <private/qqmlengine_p.h> +#include <private/qfieldlist_p.h> +#include <private/qqmljavascriptexpression_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlExpression; +class QString; +class QQmlExpressionPrivate : public QObjectPrivate, + public QQmlJavaScriptExpression +{ + Q_DECLARE_PUBLIC(QQmlExpression) +public: + QQmlExpressionPrivate(); + ~QQmlExpressionPrivate() override; + + void init(const QQmlRefPointer<QQmlContextData> &, const QString &, QObject *); + void init(const QQmlRefPointer<QQmlContextData> &, QV4::Function *runtimeFunction, QObject *); + + QVariant value(bool *isUndefined = nullptr); + + QV4::ReturnedValue v4value(bool *isUndefined = nullptr); + bool mustCaptureBindableProperty() const final {return true;} + + static inline QQmlExpressionPrivate *get(QQmlExpression *expr); + static inline QQmlExpression *get(QQmlExpressionPrivate *expr); + + void _q_notify(); + + bool expressionFunctionValid:1; + + // Inherited from QQmlJavaScriptExpression + QString expressionIdentifier() const override; + void expressionChanged() override; + + QString expression; + + QString url; // This is a QString for a reason. QUrls are slooooooow... + quint16 line; + quint16 column; + QString name; //function name, hint for the debugger +}; + +QQmlExpressionPrivate *QQmlExpressionPrivate::get(QQmlExpression *expr) +{ + return static_cast<QQmlExpressionPrivate *>(QObjectPrivate::get(expr)); +} + +QQmlExpression *QQmlExpressionPrivate::get(QQmlExpressionPrivate *expr) +{ + return expr->q_func(); +} + + +QT_END_NAMESPACE + +#endif // QQMLEXPRESSION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlextensionplugin_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlextensionplugin_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8f65d9596c7091f1fd0f4ae50fc6fae1f47ae270 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlextensionplugin_p.h @@ -0,0 +1,38 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLEXTENSIONPLUGIN_P_H +#define QQMLEXTENSIONPLUGIN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qobject_p.h> +#include "qqmlextensionplugin.h" + +QT_BEGIN_NAMESPACE + +#if QT_DEPRECATED_SINCE(6, 3) +class QQmlExtensionPluginPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQmlExtensionPlugin) + +public: + static QQmlExtensionPluginPrivate* get(QQmlExtensionPlugin *e) { return e->d_func(); } + + QUrl baseUrl; + +}; +#endif + +QT_END_NAMESPACE + +#endif // QQMLEXTENSIONPLUGIN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlfileselector_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlfileselector_p.h new file mode 100644 index 0000000000000000000000000000000000000000..11551f60d85d9efecf148ec645c61a1eb0f54c90 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlfileselector_p.h @@ -0,0 +1,54 @@ +// Copyright (C) 2016 BlackBerry Limited. All rights reserved. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLFILESELECTOR_P_H +#define QQMLFILESELECTOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlfileselector.h" +#include <QSet> +#include <QQmlAbstractUrlInterceptor> +#include <private/qobject_p.h> +#include <private/qtqmlglobal_p.h> + +#include <QtCore/qpointer.h> + +QT_BEGIN_NAMESPACE + +class QFileSelector; +class QQmlFileSelectorInterceptor; +class Q_QML_EXPORT QQmlFileSelectorPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQmlFileSelector) +public: + QQmlFileSelectorPrivate(); + ~QQmlFileSelectorPrivate(); + + QFileSelector* selector; + QPointer<QQmlEngine> engine; + bool ownSelector; + QScopedPointer<QQmlFileSelectorInterceptor> myInstance; +}; + +class Q_QML_EXPORT QQmlFileSelectorInterceptor : public QQmlAbstractUrlInterceptor +{ +public: + QQmlFileSelectorInterceptor(QQmlFileSelectorPrivate* pd); + QQmlFileSelectorPrivate* d; +protected: + QUrl intercept(const QUrl &path, DataType type) override; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlfinalizer_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlfinalizer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dd69b218a4f077d1d28d23d78e7766b0880c3e5f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlfinalizer_p.h @@ -0,0 +1,34 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLFINALIZER_P_H +#define QQMLFINALIZER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qtqmlglobal_p.h> +#include <qobject.h> + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlFinalizerHook +{ +public: + virtual ~QQmlFinalizerHook(); + virtual void componentFinalized() = 0; +}; +#define QQmlFinalizerHook_iid "org.qt-project.Qt.QQmlFinalizerHook" +Q_DECLARE_INTERFACE(QQmlFinalizerHook, QQmlFinalizerHook_iid) + +QT_END_NAMESPACE + +#endif // QQMLFINALIZER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4c2abe496f1f0f9e94e7fc005fc1bf96256f5296 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlglobal_p.h @@ -0,0 +1,331 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLGLOBAL_H +#define QQMLGLOBAL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qmetaobject_p.h> +#include <private/qqmlmetaobject_p.h> +#include <private/qqmltype_p.h> +#include <private/qtqmlglobal_p.h> + +#include <QtQml/qqml.h> +#include <QtCore/qobject.h> + +QT_BEGIN_NAMESPACE + +inline bool qmlConvertBoolConfigOption(const char *v) +{ + return v != nullptr && qstrcmp(v, "0") != 0 && qstrcmp(v, "false") != 0; +} + +template<typename T, T(*Convert)(const char *)> +T qmlGetConfigOption(const char *var) +{ + if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty(var))) + return Convert(qgetenv(var)); + return Convert(nullptr); +} + +#define DEFINE_BOOL_CONFIG_OPTION(name, var) \ + static bool name() \ + { \ + static const bool result = qmlGetConfigOption<bool, qmlConvertBoolConfigOption>(#var); \ + return result; \ + } + +/*! + Connect \a Signal of \a Sender to \a Method of \a Receiver. \a Signal must be + of type \a SenderType and \a Receiver of type \a ReceiverType. + + Unlike QObject::connect(), this macro caches the lookup of the signal and method + indexes. It also does not require lazy QMetaObjects to be built so should be + preferred in all QML code that might interact with QML built objects. + + \code + QQuickTextControl *control; + QQuickTextEdit *textEdit; + qmlobject_connect(control, QQuickTextControl, SIGNAL(updateRequest(QRectF)), + textEdit, QQuickTextEdit, SLOT(updateDocument())); + \endcode +*/ +#define qmlobject_connect(Sender, SenderType, Signal, Receiver, ReceiverType, Method) \ +do { \ + SenderType *sender = (Sender); \ + ReceiverType *receiver = (Receiver); \ + const char *signal = (Signal); \ + const char *method = (Method); \ + static int signalIdx = -1; \ + static int methodIdx = -1; \ + if (signalIdx < 0) { \ + Q_ASSERT((int(*signal) - '0') == QSIGNAL_CODE); \ + signalIdx = SenderType::staticMetaObject.indexOfSignal(signal+1); \ + } \ + if (methodIdx < 0) { \ + int code = (int(*method) - '0'); \ + Q_ASSERT(code == QSLOT_CODE || code == QSIGNAL_CODE); \ + if (code == QSLOT_CODE) \ + methodIdx = ReceiverType::staticMetaObject.indexOfSlot(method+1); \ + else \ + methodIdx = ReceiverType::staticMetaObject.indexOfSignal(method+1); \ + } \ + Q_ASSERT(signalIdx != -1 && methodIdx != -1); \ + QMetaObject::connect(sender, signalIdx, receiver, methodIdx, Qt::DirectConnection); \ +} while (0) + +/*! + Disconnect \a Signal of \a Sender from \a Method of \a Receiver. \a Signal must be + of type \a SenderType and \a Receiver of type \a ReceiverType. + + Unlike QObject::disconnect(), this macro caches the lookup of the signal and method + indexes. It also does not require lazy QMetaObjects to be built so should be + preferred in all QML code that might interact with QML built objects. + + \code + QQuickTextControl *control; + QQuickTextEdit *textEdit; + qmlobject_disconnect(control, QQuickTextControl, SIGNAL(updateRequest(QRectF)), + textEdit, QQuickTextEdit, SLOT(updateDocument())); + \endcode +*/ +#define qmlobject_disconnect(Sender, SenderType, Signal, Receiver, ReceiverType, Method) \ +do { \ + SenderType *sender = (Sender); \ + ReceiverType *receiver = (Receiver); \ + const char *signal = (Signal); \ + const char *method = (Method); \ + static int signalIdx = -1; \ + static int methodIdx = -1; \ + if (signalIdx < 0) { \ + Q_ASSERT((int(*signal) - '0') == QSIGNAL_CODE); \ + signalIdx = SenderType::staticMetaObject.indexOfSignal(signal+1); \ + } \ + if (methodIdx < 0) { \ + int code = (int(*method) - '0'); \ + Q_ASSERT(code == QSLOT_CODE || code == QSIGNAL_CODE); \ + if (code == QSLOT_CODE) \ + methodIdx = ReceiverType::staticMetaObject.indexOfSlot(method+1); \ + else \ + methodIdx = ReceiverType::staticMetaObject.indexOfSignal(method+1); \ + } \ + Q_ASSERT(signalIdx != -1 && methodIdx != -1); \ + QMetaObject::disconnect(sender, signalIdx, receiver, methodIdx); \ +} while (0) + +Q_QML_EXPORT bool qmlobject_can_cpp_cast(QObject *object, const QMetaObject *mo); +Q_QML_EXPORT bool qmlobject_can_qml_cast(QObject *object, const QQmlType &type); + +/*! + This method is identical to qobject_cast<T>() except that it does not require lazy + QMetaObjects to be built, so should be preferred in all QML code that might interact + with QML built objects. + + \code + QObject *object; + if (QQuickTextEdit *textEdit = qmlobject_cast<QQuickTextEdit *>(object)) { + // ...Do something... + } + \endcode +*/ +template<class T> +T qmlobject_cast(QObject *object) +{ + if (!object) + return nullptr; + if (qmlobject_can_cpp_cast(object, &(std::remove_pointer_t<T>::staticMetaObject))) + return static_cast<T>(object); + else + return nullptr; +} + +class QQuickItem; +template<> +inline QQuickItem *qmlobject_cast<QQuickItem *>(QObject *object) +{ + if (!object || !object->isQuickItemType()) + return nullptr; + // QQuickItem is incomplete here -> can't use static_cast + // but we don't need any pointer adjustment, so reinterpret is safe + return reinterpret_cast<QQuickItem *>(object); +} + +#define IS_SIGNAL_CONNECTED(Sender, SenderType, Name, Arguments) \ +do { \ + QObject *sender = (Sender); \ + void (SenderType::*signal)Arguments = &SenderType::Name; \ + static QMetaMethod method = QMetaMethod::fromSignal(signal); \ + static int signalIdx = QMetaObjectPrivate::signalIndex(method); \ + return QObjectPrivate::get(sender)->isSignalConnected(signalIdx); \ +} while (0) + +/*! + Returns true if the case of \a fileName is equivalent to the file case of + \a fileName on disk, and false otherwise. + + This is used to ensure that the behavior of QML on a case-insensitive file + system is the same as on a case-sensitive file system. This function + performs a "best effort" attempt to determine the real case of the file. + It may have false positives (say the case is correct when it isn't), but it + should never have a false negative (say the case is incorrect when it is + correct). + + Length specifies specifies the number of characters to be checked from + behind. That is, if a file name results from a relative path specification + like "foo/bar.qml" and is made absolute, the original length (11) should + be passed indicating that only the last part of the relative path should + be checked. + +*/ +bool QQml_isFileCaseCorrect(const QString &fileName, int length = -1); + +/*! + Makes the \a object a child of \a parent. Note that when using this method, + neither \a parent nor the object's previous parent (if it had one) will + receive ChildRemoved or ChildAdded events. +*/ +inline void QQml_setParent_noEvent(QObject *object, QObject *parent) +{ + QObjectPrivate *d_ptr = QObjectPrivate::get(object); + bool sce = d_ptr->sendChildEvents; + d_ptr->sendChildEvents = false; + object->setParent(parent); + d_ptr->sendChildEvents = sce; +} + +class QQmlValueTypeProvider +{ +public: + static bool populateValueType( + QMetaType targetMetaType, void *target, const QV4::Value &source, + QV4::ExecutionEngine *engine); + static bool populateValueType( + QMetaType targetMetaType, void *target, QMetaType sourceMetaType, void *source, + QV4::ExecutionEngine *engine); + + static Q_QML_EXPORT void *heapCreateValueType( + const QQmlType &targetType, const QV4::Value &source, QV4::ExecutionEngine *engine); + static QVariant constructValueType( + QMetaType targetMetaType, const QMetaObject *targetMetaObject, + int ctorIndex, void *ctorArg); + + static QVariant createValueType(const QJSValue &, QMetaType); + static QVariant createValueType(const QString &, QMetaType); + static QVariant createValueType(const QV4::Value &, QMetaType, QV4::ExecutionEngine *); + static QVariant createValueType(const QVariant &, QMetaType, QV4::ExecutionEngine *); +}; + +class Q_QML_EXPORT QQmlColorProvider +{ +public: + virtual ~QQmlColorProvider(); + virtual QVariant colorFromString(const QString &, bool *); + virtual unsigned rgbaFromString(const QString &, bool *); + + virtual QVariant fromRgbF(double, double, double, double); + virtual QVariant fromHslF(double, double, double, double); + virtual QVariant fromHsvF(double, double, double, double); + virtual QVariant lighter(const QVariant &, qreal); + virtual QVariant darker(const QVariant &, qreal); + virtual QVariant alpha(const QVariant &, qreal); + virtual QVariant tint(const QVariant &, const QVariant &); +}; + +Q_QML_EXPORT QQmlColorProvider *QQml_setColorProvider(QQmlColorProvider *); +Q_QML_EXPORT QQmlColorProvider *QQml_colorProvider(); + +class QQmlApplication; +class Q_QML_EXPORT QQmlGuiProvider +{ +public: + virtual ~QQmlGuiProvider(); + virtual QQmlApplication *application(QObject *parent); + virtual QObject *inputMethod(); + virtual QObject *styleHints(); + virtual QStringList fontFamilies(); + virtual bool openUrlExternally(const QUrl &); + virtual QString pluginName() const; +}; + +Q_QML_EXPORT QQmlGuiProvider *QQml_setGuiProvider(QQmlGuiProvider *); +Q_AUTOTEST_EXPORT QQmlGuiProvider *QQml_guiProvider(); + +class QQmlApplicationPrivate; + +class Q_QML_EXPORT QQmlApplication : public QObject +{ + //Application level logic, subclassed by Qt Quick if available via QQmlGuiProvider + Q_OBJECT + Q_PROPERTY(QStringList arguments READ args CONSTANT) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString version READ version WRITE setVersion NOTIFY versionChanged) + Q_PROPERTY(QString organization READ organization WRITE setOrganization NOTIFY organizationChanged) + Q_PROPERTY(QString domain READ domain WRITE setDomain NOTIFY domainChanged) + QML_ANONYMOUS +public: + QQmlApplication(QObject* parent=nullptr); + + QStringList args(); + + QString name() const; + QString version() const; + QString organization() const; + QString domain() const; + +public Q_SLOTS: + void setName(const QString &arg); + void setVersion(const QString &arg); + void setOrganization(const QString &arg); + void setDomain(const QString &arg); + +Q_SIGNALS: + void aboutToQuit(); + + void nameChanged(); + void versionChanged(); + void organizationChanged(); + void domainChanged(); + +protected: + QQmlApplication(QQmlApplicationPrivate &dd, QObject* parent=nullptr); + +private: + Q_DISABLE_COPY(QQmlApplication) + Q_DECLARE_PRIVATE(QQmlApplication) +}; + +class QQmlApplicationPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQmlApplication) +public: + QQmlApplicationPrivate() { + argsInit = false; + } + + bool argsInit; + QStringList args; +}; + +struct QQmlSourceLocation +{ + QQmlSourceLocation() {} + QQmlSourceLocation(const QString &sourceFile, quint16 line, quint16 column) + : sourceFile(sourceFile), line(line), column(column) {} + QString sourceFile; + quint16 line = 0; + quint16 column = 0; +}; + +QT_END_NAMESPACE + +#endif // QQMLGLOBAL_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlguard_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlguard_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9ddf8dcdfca503d3e1a00b0ac2ff514aaf3cc52c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlguard_p.h @@ -0,0 +1,233 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLGUARD_P_H +#define QQMLGUARD_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmldata_p.h> +#include <private/qqmlglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlGuardImpl +{ +public: + using ObjectDestroyedFn = void(*)(QQmlGuardImpl *); + + inline QQmlGuardImpl(); + inline QQmlGuardImpl(QObject *); + inline QQmlGuardImpl(const QQmlGuardImpl &); +protected: + inline ~QQmlGuardImpl(); + +public: // ### make so it can be private + QObject *o = nullptr; + QQmlGuardImpl *next = nullptr; + QQmlGuardImpl **prev = nullptr; + ObjectDestroyedFn objectDestroyed = nullptr; + + inline void addGuard(); + inline void remGuard(); + + inline void setObject(QObject *g); + bool isNull() const noexcept { return !o; } +}; + +class QObject; +template<class T> +class QQmlGuard : protected QQmlGuardImpl +{ + friend class QQmlData; +public: + Q_NODISCARD_CTOR inline QQmlGuard(); + Q_NODISCARD_CTOR inline QQmlGuard(ObjectDestroyedFn objectDestroyed, T *); + Q_NODISCARD_CTOR inline QQmlGuard(T *); + Q_NODISCARD_CTOR inline QQmlGuard(const QQmlGuard<T> &); + + inline QQmlGuard<T> &operator=(const QQmlGuard<T> &o); + inline QQmlGuard<T> &operator=(T *); + + T *object() const noexcept { return static_cast<T *>(o); } + void setObject(T *g) { QQmlGuardImpl::setObject(g); } + + using QQmlGuardImpl::isNull; + + T *operator->() const noexcept { return object(); } + T &operator*() const { return *object(); } + operator T *() const noexcept { return object(); } + T *data() const noexcept { return object(); } +}; + +/* used in QQmlStrongJSQObjectReference to indicate that the + * object has JS ownership + * We save it in objectDestroyFn to save space + * (implemented in qqmlengine.cpp) + */ +void Q_QML_EXPORT hasJsOwnershipIndicator(QQmlGuardImpl *); + +template <typename T> +class QQmlStrongJSQObjectReference final : protected QQmlGuardImpl +{ +public: + T *object() const noexcept { return static_cast<T *>(o); } + + using QQmlGuardImpl::isNull; + + T *operator->() const noexcept { return object(); } + T &operator*() const { return *object(); } + operator T *() const noexcept { return object(); } + T *data() const noexcept { return object(); } + + void setObject(T *obj, QObject *parent) { + T *old = object(); + if (obj == old) + return; + + if (hasJsOwnership() && old && old->parent() == parent) + QQml_setParent_noEvent(old, nullptr); + + QQmlGuardImpl::setObject(obj); + + if (obj && !obj->parent() && !QQmlData::keepAliveDuringGarbageCollection(obj)) { + setJsOwnership(true); + QQml_setParent_noEvent(obj, parent); + } else { + setJsOwnership(false); + } + } + +private: + bool hasJsOwnership() { + return objectDestroyed == hasJsOwnershipIndicator; + } + + void setJsOwnership(bool itHasOwnership) { + objectDestroyed = itHasOwnership ? hasJsOwnershipIndicator : nullptr; + } +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QQmlGuard<QObject>) + +QT_BEGIN_NAMESPACE + +QQmlGuardImpl::QQmlGuardImpl() +{ +} + +QQmlGuardImpl::QQmlGuardImpl(QObject *g) +: o(g) +{ + if (o) addGuard(); +} + +/* + \internal + Copying a QQmlGuardImpl leaves the old one in the intrinsic linked list of guards. + The fresh copy does not contain the list pointer of the existing guard; instead + only the object and objectDestroyed pointers are copied, and if there is an object + we add the new guard to the object's list of guards. + */ +QQmlGuardImpl::QQmlGuardImpl(const QQmlGuardImpl &g) +: o(g.o), objectDestroyed(g.objectDestroyed) +{ + if (o) addGuard(); +} + +QQmlGuardImpl::~QQmlGuardImpl() +{ + if (prev) remGuard(); + o = nullptr; +} + +void QQmlGuardImpl::addGuard() +{ + Q_ASSERT(!prev); + + if (QObjectPrivate::get(o)->wasDeleted) + return; + + QQmlData *data = QQmlData::get(o, true); + next = data->guards; + if (next) next->prev = &next; + data->guards = this; + prev = &data->guards; +} + +void QQmlGuardImpl::remGuard() +{ + Q_ASSERT(prev); + + if (next) next->prev = prev; + *prev = next; + next = nullptr; + prev = nullptr; +} + +template<class T> +QQmlGuard<T>::QQmlGuard() +{ +} + +template<class T> +QQmlGuard<T>::QQmlGuard(ObjectDestroyedFn objDestroyed, T *obj) + : QQmlGuardImpl(obj) +{ + objectDestroyed = objDestroyed; +} + +template<class T> +QQmlGuard<T>::QQmlGuard(T *g) +: QQmlGuardImpl(g) +{ +} + +template<class T> +QQmlGuard<T>::QQmlGuard(const QQmlGuard<T> &g) +: QQmlGuardImpl(g) +{ +} + +template<class T> +QQmlGuard<T> &QQmlGuard<T>::operator=(const QQmlGuard<T> &g) +{ + objectDestroyed = g.objectDestroyed; + setObject(g.object()); + return *this; +} + +template<class T> +QQmlGuard<T> &QQmlGuard<T>::operator=(T *g) +{ + /* this does not touch objectDestroyed, as operator= is only a convenience + * for setObject. All logic involving objectDestroyed is (sub-)class specific + * and remains unaffected. + */ + setObject(g); + return *this; +} + +void QQmlGuardImpl::setObject(QObject *g) +{ + if (g != o) { + if (prev) remGuard(); + o = g; + if (o) addGuard(); + } +} + +QT_END_NAMESPACE + +#endif // QQMLGUARD_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlguardedcontextdata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlguardedcontextdata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..661c055917741e0ffd96eba3eef130bd2738e9c2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlguardedcontextdata_p.h @@ -0,0 +1,95 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLGUARDEDCONTEXTDATA_P_H +#define QQMLGUARDEDCONTEXTDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qtqmlglobal_p.h> +#include <QtQml/private/qqmlcontextdata_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlGuardedContextData +{ + Q_DISABLE_COPY(QQmlGuardedContextData); +public: + QQmlGuardedContextData() = default; + ~QQmlGuardedContextData() { unlink(); } + + QQmlGuardedContextData(QQmlGuardedContextData &&) = default; + QQmlGuardedContextData &operator=(QQmlGuardedContextData &&) = default; + + QQmlGuardedContextData(QQmlRefPointer<QQmlContextData> data) + { + setContextData(std::move(data)); + } + + QQmlGuardedContextData &operator=(QQmlRefPointer<QQmlContextData> d) + { + setContextData(std::move(d)); + return *this; + } + + QQmlRefPointer<QQmlContextData> contextData() const { return m_contextData; } + void setContextData(QQmlRefPointer<QQmlContextData> contextData) + { + if (m_contextData.data() == contextData.data()) + return; + unlink(); + + if (contextData) { + m_contextData = std::move(contextData); + m_next = m_contextData->m_contextGuards; + if (m_next) + m_next->m_prev = &m_next; + + m_contextData->m_contextGuards = this; + m_prev = &m_contextData->m_contextGuards; + } + } + + bool isNull() const { return !m_contextData; } + + operator const QQmlRefPointer<QQmlContextData> &() const { return m_contextData; } + QQmlContextData &operator*() const { return m_contextData.operator*(); } + QQmlContextData *operator->() const { return m_contextData.operator->(); } + + QQmlGuardedContextData *next() const { return m_next; } + +private: + void reset() + { + m_contextData.reset(); + m_next = nullptr; + m_prev = nullptr; + } + + void unlink() + { + if (m_prev) { + *m_prev = m_next; + if (m_next) + m_next->m_prev = m_prev; + reset(); + } + } + + QQmlRefPointer<QQmlContextData> m_contextData; + QQmlGuardedContextData *m_next = nullptr; + QQmlGuardedContextData **m_prev = nullptr; +}; + +QT_END_NAMESPACE + +#endif // QQMLGUARDEDCONTEXTDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlimport_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlimport_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d0417c452787e506b4bf6fbbebe36ecc4600f997 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlimport_p.h @@ -0,0 +1,462 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLIMPORT_P_H +#define QQMLIMPORT_P_H + +#include <QtCore/qurl.h> +#include <QtCore/qcoreapplication.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qset.h> +#include <QtCore/qstringlist.h> +#include <QtQml/qqmlengine.h> +#include <QtQml/qqmlerror.h> +#include <QtQml/qqmlfile.h> +#include <private/qqmldirparser_p.h> +#include <private/qqmltype_p.h> +#include <private/qstringhash_p.h> +#include <private/qfieldlist_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlTypeNameCache; +class QQmlEngine; +class QDir; +class QQmlImportNamespace; +class QQmlImportDatabase; +class QQmlTypeLoader; +class QQmlTypeLoaderQmldirContent; +class QTypeRevision; + +const QLoggingCategory &lcQmlImport(); + +namespace QQmlImport { + enum RecursionRestriction { PreventRecursion, AllowRecursion }; +} + +struct QQmlImportInstance +{ + enum Precedence { + Lowest = std::numeric_limits<quint8>::max(), + Implicit = Lowest / 2, + Highest = 0, + }; + + QString uri; // e.g. QtQuick + QString url; // the base path of the import + QTypeRevision version; // the version imported + + bool isLibrary; // true means that this is not a file import + + // not covered by precedence. You can set a component as implicitly imported after the fact. + bool implicitlyImported = false; + bool isInlineComponent = false; + + quint8 precedence = 0; + + QQmlDirComponents qmlDirComponents; // a copy of the components listed in the qmldir + QQmlDirScripts qmlDirScripts; // a copy of the scripts in the qmldir + + bool setQmldirContent(const QString &resolvedUrl, const QQmlTypeLoaderQmldirContent &qmldir, + QQmlImportNamespace *nameSpace, QList<QQmlError> *errors); + + static QQmlDirScripts getVersionedScripts(const QQmlDirScripts &qmldirscripts, + QTypeRevision version); + + bool resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef &type, + QTypeRevision *version_return, QQmlType* type_return, + const QString *base = nullptr, bool *typeRecursionDetected = nullptr, + QQmlType::RegistrationType = QQmlType::AnyRegistrationType, + QQmlImport::RecursionRestriction recursionRestriction = QQmlImport::PreventRecursion, + QList<QQmlError> *errors = nullptr) const; +}; + +class QQmlImportNamespace +{ +public: + QQmlImportNamespace() : nextNamespace(nullptr) {} + ~QQmlImportNamespace() { qDeleteAll(imports); } + + QList<QQmlImportInstance *> imports; + + QQmlImportInstance *findImport(const QString &uri) const; + + bool resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef& type, + QTypeRevision *version_return, QQmlType* type_return, + const QString *base = nullptr, QList<QQmlError> *errors = nullptr, + QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType, + bool *typeRecursionDeteced = nullptr); + + // Prefix when used as a qualified import. Otherwise empty. + QHashedString prefix; + + // Used by QQmlImports::m_qualifiedSets + // set to this in unqualifiedSet to indicate that the lists of imports needs + // to be sorted when an inline component import was added + // We can't use flag pointer, as that does not work with QFieldList + QQmlImportNamespace *nextNamespace = nullptr; + bool needsSorting() const { return nextNamespace == this; } + void setNeedsSorting(bool needsSorting) + { + Q_ASSERT(nextNamespace == this || nextNamespace == nullptr); + nextNamespace = needsSorting ? this : nullptr; + } +}; + +class Q_QML_EXPORT QQmlImports final : public QQmlRefCounted<QQmlImports> +{ + Q_DISABLE_COPY_MOVE(QQmlImports) +public: + enum ImportVersion { FullyVersioned, PartiallyVersioned, Unversioned }; + + enum ImportFlag : quint8 { + ImportNoFlag = 0x0, + ImportIncomplete = 0x1, + }; + Q_DECLARE_FLAGS(ImportFlags, ImportFlag) + + QQmlImports() = default; + ~QQmlImports() + { + while (QQmlImportNamespace *ns = m_qualifiedSets.takeFirst()) + delete ns; + } + + void setBaseUrl(const QUrl &url, const QString &urlString = QString()); + QUrl baseUrl() const { return m_baseUrl; } + + bool resolveType( + QQmlTypeLoader *typeLoader, const QHashedStringRef &type, QQmlType *type_return, + QTypeRevision *version_return, QQmlImportNamespace **ns_return, + QList<QQmlError> *errors = nullptr, + QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType, + bool *typeRecursionDetected = nullptr) const; + + QTypeRevision addImplicitImport( + QQmlTypeLoader *typeLoader, QString *localQmldir, QList<QQmlError> *errors) + { + Q_ASSERT(errors); + qCDebug(lcQmlImport) << "addImplicitImport:" << qPrintable(baseUrl().toString()); + + const ImportFlags flags = + ImportFlags(!isLocal(baseUrl()) ? ImportIncomplete : ImportNoFlag); + return addFileImport( + typeLoader, QLatin1String("."), QString(), QTypeRevision(), flags, + QQmlImportInstance::Implicit, localQmldir, errors); + } + + bool addInlineComponentImport( + QQmlImportInstance *const importInstance, const QString &name, const QUrl importUrl); + + QTypeRevision addFileImport( + QQmlTypeLoader *typeLoader, const QString &uri, const QString &prefix, + QTypeRevision version, ImportFlags flags, quint16 precedence, QString *localQmldir, + QList<QQmlError> *errors); + + QTypeRevision addLibraryImport( + QQmlTypeLoader *typeLoader, const QString &uri, const QString &prefix, + QTypeRevision version, const QString &qmldirIdentifier, const QString &qmldirUrl, + ImportFlags flags, quint16 precedence, QList<QQmlError> *errors); + + QTypeRevision updateQmldirContent( + QQmlTypeLoader *typeLoader, const QString &uri, const QString &prefix, + const QString &qmldirIdentifier, const QString &qmldirUrl, QList<QQmlError> *errors); + + void populateCache(QQmlTypeNameCache *cache) const; + + struct ScriptReference + { + QString nameSpace; + QString qualifier; + QUrl location; + }; + + QList<ScriptReference> resolvedScripts() const; + + struct CompositeSingletonReference + { + QString typeName; + QString prefix; + QTypeRevision version; + }; + + QList<CompositeSingletonReference> resolvedCompositeSingletons() const; + + static QStringList completeQmldirPaths( + const QString &uri, const QStringList &basePaths, QTypeRevision version); + + static QString versionString(QTypeRevision version, ImportVersion importVersion); + + static bool isLocal(const QString &url) + { + return !QQmlFile::urlToLocalFileOrQrc(url).isEmpty(); + } + + static bool isLocal(const QUrl &url) + { + return !QQmlFile::urlToLocalFileOrQrc(url).isEmpty(); + } + + static QUrl urlFromLocalFileOrQrcOrUrl(const QString &); + + static void setDesignerSupportRequired(bool b); + + static QTypeRevision validVersion(QTypeRevision version = QTypeRevision()); + +private: + friend class QQmlImportDatabase; + + QQmlImportNamespace *importNamespace(const QString &prefix); + + bool resolveType( + QQmlTypeLoader *typeLoader, const QHashedStringRef &type, QTypeRevision *version_return, + QQmlType *type_return, QList<QQmlError> *errors, + QQmlType::RegistrationType registrationType, + bool *typeRecursionDetected = nullptr) const; + + QQmlImportNamespace *findQualifiedNamespace(const QHashedStringRef &) const; + + static QTypeRevision matchingQmldirVersion( + const QQmlTypeLoaderQmldirContent &qmldir, const QString &uri, + QTypeRevision version, QList<QQmlError> *errors); + + QTypeRevision importExtension( + QQmlTypeLoader *typeLoader, const QString &uri, QTypeRevision version, + const QQmlTypeLoaderQmldirContent *qmldir, QList<QQmlError> *errors); + + void registerBuiltinModuleTypes( + const QQmlTypeLoaderQmldirContent &qmldir, QTypeRevision version); + + QString redirectQmldirContent( + QQmlTypeLoader *typeLoader, QQmlTypeLoaderQmldirContent *qmldir, + QQmlImportInstance *inserted); + + bool getQmldirContent( + QQmlTypeLoader *typeLoader, const QString &qmldirIdentifier, const QString &uri, + QQmlTypeLoaderQmldirContent *qmldir, QList<QQmlError> *errors); + + QString resolvedUri(const QString &dir_arg, QQmlImportDatabase *database); + + QUrl m_baseUrl; + QString m_base; + + // storage of data related to imports without a namespace + // TODO: This needs to be mutable because QQmlImportNamespace likes to sort itself on + // resolveType(). Therefore, QQmlImportNamespace::resolveType() is not const. + // There should be a better way to do this. + mutable QQmlImportNamespace m_unqualifiedset; + + // storage of data related to imports with a namespace + QFieldList<QQmlImportNamespace, &QQmlImportNamespace::nextNamespace> m_qualifiedSets; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlImports::ImportFlags) + +class Q_QML_EXPORT QQmlImportDatabase +{ + Q_DECLARE_TR_FUNCTIONS(QQmlImportDatabase) +public: + enum PathType { Local, Remote, LocalOrRemote }; + + enum LocalQmldirSearchLocation { + QmldirFileAndCache, + QmldirCacheOnly, + }; + + enum LocalQmldirResult { + QmldirFound, + QmldirNotFound, + QmldirInterceptedToRemote, + QmldirRejected + }; + + QQmlImportDatabase(QQmlEngine *); + ~QQmlImportDatabase() { clearDirCache(); } + + bool removeDynamicPlugin(const QString &pluginId); + QStringList dynamicPlugins() const; + + QStringList importPathList(PathType type = LocalOrRemote) const; + void setImportPathList(const QStringList &paths); + void addImportPath(const QString& dir); + + QStringList pluginPathList() const { return filePluginPath; } + void setPluginPathList(const QStringList &paths); + + void addPluginPath(const QString& path); + + static void sanitizeUNCPath(QString *path) + { + // This handles the UNC path case as when the path is retrieved from the QUrl it + // will convert the host name from upper case to lower case. So the absoluteFilePath + // is changed at this point to make sure it will match later on in that case. + if (path->startsWith(QStringLiteral("//"))) { + // toLocalFile() since that faithfully restores all the things you can do to a + // path but not a URL, in particular weird characters like '%'. + *path = QUrl::fromLocalFile(*path).toLocalFile(); + } + } + + template<typename Callback> + LocalQmldirResult locateLocalQmldir( + const QString &uri, QTypeRevision version, LocalQmldirSearchLocation location, + const Callback &callback); + + static QTypeRevision lockModule(const QString &uri, const QString &typeNamespace, + QTypeRevision version, QList<QQmlError> *errors); + +private: + friend class QQmlImports; + friend class QQmlPluginImporter; + + QString absoluteFilePath(const QString &path) const; + void clearDirCache(); + + struct QmldirCache { + QTypeRevision version; + QString qmldirFilePath; + QString qmldirPathUrl; + QmldirCache *next; + }; + // Maps from an import to a linked list of qmldir info. + // Used in QQmlImports::locateQmldir() + QStringHash<QmldirCache *> qmldirCache; + + // XXX thread + QStringList filePluginPath; + QStringList fileImportPath; + + QSet<QString> modulesForWhichPluginsHaveBeenLoaded; + QSet<QString> initializedPlugins; + QQmlEngine *engine; +}; + +template<typename Callback> +QQmlImportDatabase::LocalQmldirResult QQmlImportDatabase::locateLocalQmldir( + const QString &uri, QTypeRevision version, + QQmlImportDatabase::LocalQmldirSearchLocation location, const Callback &callback) +{ + // Check cache first + + LocalQmldirResult result = QmldirNotFound; + QmldirCache *cacheTail = nullptr; + + QmldirCache **cachePtr = qmldirCache.value(uri); + QmldirCache *cacheHead = cachePtr ? *cachePtr : nullptr; + if (cacheHead) { + cacheTail = cacheHead; + do { + if (cacheTail->version == version) { + if (cacheTail->qmldirFilePath.isEmpty()) { + return cacheTail->qmldirPathUrl.isEmpty() + ? QmldirNotFound + : QmldirInterceptedToRemote; + } + if (callback(cacheTail->qmldirFilePath, cacheTail->qmldirPathUrl)) + return QmldirFound; + result = QmldirRejected; + } + } while (cacheTail->next && (cacheTail = cacheTail->next)); + } + + + // Do not try to construct the cache if it already had any entries for the URI. + // Otherwise we might duplicate cache entries. + if (location == QmldirCacheOnly || result != QmldirNotFound) + return result; + + const bool hasInterceptors = !engine->urlInterceptors().isEmpty(); + + // Interceptor might redirect remote files to local ones. + QStringList localImportPaths = importPathList(hasInterceptors ? LocalOrRemote : Local); + + // Search local import paths for a matching version + const QStringList qmlDirPaths = QQmlImports::completeQmldirPaths( + uri, localImportPaths, version); + + QString qmldirAbsoluteFilePath; + for (QString qmldirPath : qmlDirPaths) { + if (hasInterceptors) { + const QUrl intercepted = engine->interceptUrl( + QQmlImports::urlFromLocalFileOrQrcOrUrl(qmldirPath), + QQmlAbstractUrlInterceptor::QmldirFile); + qmldirPath = QQmlFile::urlToLocalFileOrQrc(intercepted); + if (result != QmldirInterceptedToRemote + && qmldirPath.isEmpty() + && !QQmlFile::isLocalFile(intercepted)) { + result = QmldirInterceptedToRemote; + } + } + + qmldirAbsoluteFilePath = absoluteFilePath(qmldirPath); + if (!qmldirAbsoluteFilePath.isEmpty()) { + QString url; + const QString absolutePath = qmldirAbsoluteFilePath.left( + qmldirAbsoluteFilePath.lastIndexOf(u'/') + 1); + if (absolutePath.at(0) == u':') { + url = QStringLiteral("qrc") + absolutePath; + } else { + url = QUrl::fromLocalFile(absolutePath).toString(); + sanitizeUNCPath(&qmldirAbsoluteFilePath); + } + + QmldirCache *cache = new QmldirCache; + cache->version = version; + cache->qmldirFilePath = qmldirAbsoluteFilePath; + cache->qmldirPathUrl = url; + cache->next = nullptr; + if (cacheTail) + cacheTail->next = cache; + else + qmldirCache.insert(uri, cache); + cacheTail = cache; + + if (result != QmldirFound) + result = callback(qmldirAbsoluteFilePath, url) ? QmldirFound : QmldirRejected; + + // Do not return here. Rather, construct the complete cache for this URI. + } + } + + // Nothing found? Add an empty cache entry to signal that for further requests. + if (result == QmldirNotFound || result == QmldirInterceptedToRemote) { + QmldirCache *cache = new QmldirCache; + cache->version = version; + cache->next = cacheHead; + if (result == QmldirInterceptedToRemote) { + // The actual value doesn't matter as long as it's not empty. + // We only use it to discern QmldirInterceptedToRemote from QmldirNotFound above. + cache->qmldirPathUrl = QStringLiteral("intercepted"); + } + qmldirCache.insert(uri, cache); + + if (result == QmldirNotFound) { + qCDebug(lcQmlImport) + << "locateLocalQmldir:" << qPrintable(uri) << "module's qmldir file not found"; + } + } else { + qCDebug(lcQmlImport) + << "locateLocalQmldir:" << qPrintable(uri) << "module's qmldir found at" + << qmldirAbsoluteFilePath; + } + + return result; +} + +void qmlClearEnginePlugins();// For internal use by qmlClearRegisteredProperties + +QT_END_NAMESPACE + +#endif // QQMLIMPORT_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlimportresolver_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlimportresolver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..80a76fee632170358c07a6c64184525f93721cbc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlimportresolver_p.h @@ -0,0 +1,31 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLIMPORTRESOLVER_P_H +#define QQMLIMPORTRESOLVER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlcompilerglobal_p.h> + +#include <QtCore/qglobal.h> +#include <QtCore/qstring.h> +#include <QtCore/qversionnumber.h> + +QT_BEGIN_NAMESPACE + +Q_QML_COMPILER_EXPORT QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths, + QTypeRevision version); + +QT_END_NAMESPACE + +#endif // QQMLIMPORTRESOLVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlincubator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlincubator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c21c3855414062a4c3cee35efbe39112850b1ebe --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlincubator_p.h @@ -0,0 +1,91 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLINCUBATOR_P_H +#define QQMLINCUBATOR_P_H + +#include "qqmlincubator.h" + +#include <private/qintrusivelist_p.h> +#include <private/qqmlvme_p.h> +#include <private/qrecursionwatcher_p.h> +#include <private/qqmlengine_p.h> +#include <private/qqmlguardedcontextdata_p.h> + +#include <QtCore/qpointer.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class RequiredProperties; + +class QQmlIncubator; +class Q_QML_EXPORT QQmlIncubatorPrivate : public QQmlEnginePrivate::Incubator, public QSharedData +{ +public: + QQmlIncubatorPrivate(QQmlIncubator *q, QQmlIncubator::IncubationMode m); + ~QQmlIncubatorPrivate(); + + inline static QQmlIncubatorPrivate *get(QQmlIncubator *incubator) { return incubator->d; } + + int subComponentToCreate; + QQmlIncubator *q; + + QQmlIncubator::Status calculateStatus() const; + void changeStatus(QQmlIncubator::Status); + QQmlIncubator::Status status; + + QQmlIncubator::IncubationMode mode; + bool isAsynchronous; + enum Progress : char { Execute, Completing, Completed }; + Progress progress; + + QList<QQmlError> errors; + + + QPointer<QObject> result; + enum HadTopLevelRequired : bool {No = 0, Yes = 1}; + /* TODO: unify with Creator pointer once QTBUG-108760 is implemented + though we don't acutally own the properties here; if we ever end up + with a use case for async incubation of C++ types, we however could + not rely on the component to still exist during incubation, and + would need to store a copy of the required properties instead + */ + QTaggedPointer<RequiredProperties, HadTopLevelRequired> requiredPropertiesFromComponent; + QQmlGuardedContextData rootContext; + QQmlEnginePrivate *enginePriv; + QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit; + QScopedPointer<QQmlObjectCreator> creator; + QQmlVMEGuard vmeGuard; + + QExplicitlySharedDataPointer<QQmlIncubatorPrivate> waitingOnMe; + typedef QQmlEnginePrivate::Incubator QIPBase; + QIntrusiveListNode nextWaitingFor; + QIntrusiveList<QQmlIncubatorPrivate, &QQmlIncubatorPrivate::nextWaitingFor> waitingFor; + + QRecursionNode recursion; + QVariantMap initialProperties; + + void clear(); + + void forceCompletion(QQmlInstantiationInterrupt &i); + void incubate(QQmlInstantiationInterrupt &i); + void incubateCppBasedComponent(QQmlComponent *component, QQmlContext *context); + RequiredProperties *requiredProperties(); + bool hadTopLevelRequiredProperties() const; +}; + +QT_END_NAMESPACE + +#endif // QQMLINCUBATOR_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlirbuilder_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlirbuilder_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e826efc6961e03e91b164b8fb6dcbd83fe1b6986 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlirbuilder_p.h @@ -0,0 +1,854 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQMLIRBUILDER_P_H +#define QQMLIRBUILDER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmljsast_p.h> +#include <private/qqmljsengine_p.h> +#include <private/qv4compiler_p.h> +#include <private/qv4compileddata_p.h> +#include <private/qqmljsmemorypool_p.h> +#include <private/qqmljsfixedpoolarray_p.h> +#include <private/qv4codegen_p.h> +#include <private/qv4compiler_p.h> +#include <QTextStream> +#include <QCoreApplication> + +QT_BEGIN_NAMESPACE + +class QQmlPropertyCache; +class QQmlContextData; +class QQmlTypeNameCache; +struct QQmlIRLoader; + +namespace QmlIR { + +struct Document; + +template <typename T> +struct PoolList +{ + PoolList() + : first(nullptr) + , last(nullptr) + {} + + T *first; + T *last; + int count = 0; + + int append(T *item) { + item->next = nullptr; + if (last) + last->next = item; + else + first = item; + last = item; + return count++; + } + + void prepend(T *item) { + item->next = first; + first = item; + if (!last) + last = first; + ++count; + } + + template <typename Sortable, typename Base, Sortable Base::*sortMember> + T *findSortedInsertionPoint(T *item) const + { + T *insertPos = nullptr; + + for (T *it = first; it; it = it->next) { + if (!(it->*sortMember <= item->*sortMember)) + break; + insertPos = it; + } + + return insertPos; + } + + void insertAfter(T *insertionPoint, T *item) { + if (!insertionPoint) { + prepend(item); + } else if (insertionPoint == last) { + append(item); + } else { + item->next = insertionPoint->next; + insertionPoint->next = item; + ++count; + } + } + + T *unlink(T *before, T *item) { + T * const newNext = item->next; + + if (before) + before->next = newNext; + else + first = newNext; + + if (item == last) { + if (newNext) + last = newNext; + else + last = first; + } + + --count; + return newNext; + } + + T *slowAt(int index) const + { + T *result = first; + while (index > 0 && result) { + result = result->next; + --index; + } + return result; + } + + struct Iterator { + // turn Iterator into a proper iterator + using iterator_category = std::forward_iterator_tag; + using value_type = T; + using difference_type = ptrdiff_t; + using pointer = T *; + using reference = T &; + + T *ptr; + + explicit Iterator(T *p) : ptr(p) {} + + T *operator->() { + return ptr; + } + + const T *operator->() const { + return ptr; + } + + T &operator*() { + return *ptr; + } + + const T &operator*() const { + return *ptr; + } + + Iterator& operator++() { + ptr = ptr->next; + return *this; + } + + Iterator operator++(int) { + Iterator that {ptr}; + ptr = ptr->next; + return that; + } + + bool operator==(const Iterator &rhs) const { + return ptr == rhs.ptr; + } + + bool operator!=(const Iterator &rhs) const { + return ptr != rhs.ptr; + } + + operator T *() { return ptr; } + operator const T *() const { return ptr; } + }; + + Iterator begin() { return Iterator(first); } + Iterator end() { return Iterator(nullptr); } + + using iterator = Iterator; +}; + +struct Object; + +struct EnumValue : public QV4::CompiledData::EnumValue +{ + EnumValue *next; +}; + +struct Enum +{ + int nameIndex; + QV4::CompiledData::Location location; + PoolList<EnumValue> *enumValues; + + int enumValueCount() const { return enumValues->count; } + PoolList<EnumValue>::Iterator enumValuesBegin() const { return enumValues->begin(); } + PoolList<EnumValue>::Iterator enumValuesEnd() const { return enumValues->end(); } + + Enum *next; +}; + + +struct Parameter : public QV4::CompiledData::Parameter +{ + Parameter *next; + + template<typename IdGenerator> + static bool initType( + QV4::CompiledData::ParameterType *type, const IdGenerator &idGenerator, + const QQmlJS::AST::Type *annotation) + { + using Flag = QV4::CompiledData::ParameterType::Flag; + + if (!annotation) + return initType(type, QString(), idGenerator(QString()), Flag::NoFlag); + + const QString typeId = annotation->typeId->toString(); + const QString typeArgument = + annotation->typeArgument ? annotation->typeArgument->toString() : QString(); + + if (typeArgument.isEmpty()) + return initType(type, typeId, idGenerator(typeId), Flag::NoFlag); + + if (typeId == QLatin1String("list")) + return initType(type, typeArgument, idGenerator(typeArgument), Flag::List); + + const QString annotationString = annotation->toString(); + return initType(type, annotationString, idGenerator(annotationString), Flag::NoFlag); + } + + static QV4::CompiledData::CommonType stringToBuiltinType(const QString &typeName); + +private: + static bool initType( + QV4::CompiledData::ParameterType *paramType, const QString &typeName, + int typeNameIndex, QV4::CompiledData::ParameterType::Flag listFlag); +}; + +struct Signal +{ + int nameIndex; + QV4::CompiledData::Location location; + PoolList<Parameter> *parameters; + + QStringList parameterStringList(const QV4::Compiler::StringTableGenerator *stringPool) const; + + int parameterCount() const { return parameters->count; } + PoolList<Parameter>::Iterator parametersBegin() const { return parameters->begin(); } + PoolList<Parameter>::Iterator parametersEnd() const { return parameters->end(); } + + Signal *next; +}; + +struct Property : public QV4::CompiledData::Property +{ + Property *next; +}; + +struct Binding : public QV4::CompiledData::Binding +{ + // The offset in the source file where the binding appeared. This is used for sorting to ensure + // that assignments to list properties are done in the correct order. We use the offset here instead + // of Binding::location as the latter has limited precision. + quint32 offset; + // Binding's compiledScriptIndex is index in object's functionsAndExpressions + Binding *next; +}; + +struct InlineComponent : public QV4::CompiledData::InlineComponent +{ + InlineComponent *next; +}; + +struct Alias : public QV4::CompiledData::Alias +{ + Alias *next; +}; + +struct RequiredPropertyExtraData : public QV4::CompiledData::RequiredPropertyExtraData +{ + RequiredPropertyExtraData *next; +}; + +struct Function +{ + QV4::CompiledData::Location location; + int nameIndex; + quint32 index; // index in parsedQML::functions + QQmlJS::FixedPoolArray<Parameter> formals; + QV4::CompiledData::ParameterType returnType; + + // --- QQmlPropertyCacheCreator interface + const Parameter *formalsBegin() const { return formals.begin(); } + const Parameter *formalsEnd() const { return formals.end(); } + // --- + + Function *next; +}; + +struct Q_QML_COMPILER_EXPORT CompiledFunctionOrExpression +{ + CompiledFunctionOrExpression() + {} + + QQmlJS::AST::Node *parentNode = nullptr; // FunctionDeclaration, Statement or Expression + QQmlJS::AST::Node *node = nullptr; // FunctionDeclaration, Statement or Expression + quint32 nameIndex = 0; + CompiledFunctionOrExpression *next = nullptr; +}; + +struct Q_QML_COMPILER_EXPORT Object +{ + Q_DECLARE_TR_FUNCTIONS(Object) +public: + quint32 inheritedTypeNameIndex; + quint32 idNameIndex; + int id; + int indexOfDefaultPropertyOrAlias; + bool defaultPropertyIsAlias; + quint32 flags; + + QV4::CompiledData::Location location; + QV4::CompiledData::Location locationOfIdProperty; + + const Property *firstProperty() const { return properties->first; } + int propertyCount() const { return properties->count; } + Alias *firstAlias() const { return aliases->first; } + int aliasCount() const { return aliases->count; } + const Enum *firstEnum() const { return qmlEnums->first; } + int enumCount() const { return qmlEnums->count; } + const Signal *firstSignal() const { return qmlSignals->first; } + int signalCount() const { return qmlSignals->count; } + Binding *firstBinding() const { return bindings->first; } + int bindingCount() const { return bindings->count; } + const Function *firstFunction() const { return functions->first; } + int functionCount() const { return functions->count; } + const InlineComponent *inlineComponent() const { return inlineComponents->first; } + int inlineComponentCount() const { return inlineComponents->count; } + const RequiredPropertyExtraData *requiredPropertyExtraData() const {return requiredPropertyExtraDatas->first; } + int requiredPropertyExtraDataCount() const { return requiredPropertyExtraDatas->count; } + void simplifyRequiredProperties(); + + PoolList<Binding>::Iterator bindingsBegin() const { return bindings->begin(); } + PoolList<Binding>::Iterator bindingsEnd() const { return bindings->end(); } + PoolList<Property>::Iterator propertiesBegin() const { return properties->begin(); } + PoolList<Property>::Iterator propertiesEnd() const { return properties->end(); } + PoolList<Alias>::Iterator aliasesBegin() const { return aliases->begin(); } + PoolList<Alias>::Iterator aliasesEnd() const { return aliases->end(); } + PoolList<Enum>::Iterator enumsBegin() const { return qmlEnums->begin(); } + PoolList<Enum>::Iterator enumsEnd() const { return qmlEnums->end(); } + PoolList<Signal>::Iterator signalsBegin() const { return qmlSignals->begin(); } + PoolList<Signal>::Iterator signalsEnd() const { return qmlSignals->end(); } + PoolList<Function>::Iterator functionsBegin() const { return functions->begin(); } + PoolList<Function>::Iterator functionsEnd() const { return functions->end(); } + PoolList<InlineComponent>::Iterator inlineComponentsBegin() const { return inlineComponents->begin(); } + PoolList<InlineComponent>::Iterator inlineComponentsEnd() const { return inlineComponents->end(); } + PoolList<RequiredPropertyExtraData>::Iterator requiredPropertyExtraDataBegin() const {return requiredPropertyExtraDatas->begin(); } + PoolList<RequiredPropertyExtraData>::Iterator requiredPropertyExtraDataEnd() const {return requiredPropertyExtraDatas->end(); } + + // If set, then declarations for this object (and init bindings for these) should go into the + // specified object. Used for declarations inside group properties. + Object *declarationsOverride; + + void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QV4::CompiledData::Location &location); + + QString appendEnum(Enum *enumeration); + QString appendSignal(Signal *signal); + QString appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation); + QString appendAlias(Alias *prop, const QString &aliasName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation); + void appendFunction(QmlIR::Function *f); + void appendInlineComponent(InlineComponent *ic); + void appendRequiredPropertyExtraData(RequiredPropertyExtraData *extraData); + + QString appendBinding(Binding *b, bool isListBinding); + Binding *findBinding(quint32 nameIndex) const; + Binding *unlinkBinding(Binding *before, Binding *binding) { return bindings->unlink(before, binding); } + void insertSorted(Binding *b); + QString bindingAsString(Document *doc, int scriptIndex) const; + + PoolList<CompiledFunctionOrExpression> *functionsAndExpressions; + QQmlJS::FixedPoolArray<int> runtimeFunctionIndices; + + QQmlJS::FixedPoolArray<quint32> namedObjectsInComponent; + int namedObjectsInComponentCount() const { return namedObjectsInComponent.size(); } + const quint32 *namedObjectsInComponentTable() const { return namedObjectsInComponent.begin(); } + + bool hasFlag(QV4::CompiledData::Object::Flag flag) const { return flags & flag; } + qint32 objectId() const { return id; } + bool hasAliasAsDefaultProperty() const { return defaultPropertyIsAlias; } + +private: + friend struct ::QQmlIRLoader; + + PoolList<Property> *properties; + PoolList<Alias> *aliases; + PoolList<Enum> *qmlEnums; + PoolList<Signal> *qmlSignals; + PoolList<Binding> *bindings; + PoolList<Function> *functions; + PoolList<InlineComponent> *inlineComponents; + PoolList<RequiredPropertyExtraData> *requiredPropertyExtraDatas; +}; + +struct Q_QML_COMPILER_EXPORT Pragma +{ + enum PragmaType + { + Singleton, + Strict, + ListPropertyAssignBehavior, + ComponentBehavior, + FunctionSignatureBehavior, + NativeMethodBehavior, + ValueTypeBehavior, + Translator, + }; + + enum ListPropertyAssignBehaviorValue + { + Append, + Replace, + ReplaceIfNotDefault, + }; + + enum ComponentBehaviorValue + { + Unbound, + Bound + }; + + enum FunctionSignatureBehaviorValue + { + Ignored, + Enforced + }; + + enum NativeMethodBehaviorValue + { + AcceptThisObject, + RejectThisObject + }; + + enum ValueTypeBehaviorValue + { + Copy = 0x1, + Addressable = 0x2, + Assertable = 0x4, + }; + Q_DECLARE_FLAGS(ValueTypeBehaviorValues, ValueTypeBehaviorValue); + + PragmaType type; + + union { + ListPropertyAssignBehaviorValue listPropertyAssignBehavior; + ComponentBehaviorValue componentBehavior; + FunctionSignatureBehaviorValue functionSignatureBehavior; + NativeMethodBehaviorValue nativeMethodBehavior; + ValueTypeBehaviorValues::Int valueTypeBehavior; + uint translationContextIndex; + }; + + QV4::CompiledData::Location location; +}; + +struct Q_QML_COMPILER_EXPORT Document +{ + Document(bool debugMode); + QString code; + QQmlJS::Engine jsParserEngine; + QV4::Compiler::Module jsModule; + QList<const QV4::CompiledData::Import *> imports; + QList<Pragma*> pragmas; + QQmlJS::AST::UiProgram *program; + QVector<Object*> objects; + QV4::Compiler::JSUnitGenerator jsGenerator; + + QQmlRefPointer<QV4::CompiledData::CompilationUnit> javaScriptCompilationUnit; + + bool isSingleton() const { + return std::any_of(pragmas.constBegin(), pragmas.constEnd(), [](const Pragma *pragma) { + return pragma->type == Pragma::Singleton; + }); + } + + int registerString(const QString &str) { return jsGenerator.registerString(str); } + QString stringAt(int index) const { return jsGenerator.stringForIndex(index); } + + int objectCount() const {return objects.size();} + Object* objectAt(int i) const {return objects.at(i);} +}; + +class Q_QML_COMPILER_EXPORT ScriptDirectivesCollector : public QQmlJS::Directives +{ + QmlIR::Document *document; + QQmlJS::Engine *engine; + QV4::Compiler::JSUnitGenerator *jsGenerator; + +public: + ScriptDirectivesCollector(QmlIR::Document *doc); + + void pragmaLibrary() override; + void importFile(const QString &jsfile, const QString &module, int lineNumber, int column) override; + void importModule(const QString &uri, const QString &version, const QString &module, int lineNumber, int column) override; +}; + +struct Q_QML_COMPILER_EXPORT IRBuilder : public QQmlJS::AST::Visitor +{ + Q_DECLARE_TR_FUNCTIONS(QQmlCodeGenerator) +public: + IRBuilder(const QSet<QString> &illegalNames); + bool generateFromQml(const QString &code, const QString &url, Document *output); + + using QQmlJS::AST::Visitor::visit; + using QQmlJS::AST::Visitor::endVisit; + + bool visit(QQmlJS::AST::UiArrayMemberList *ast) override; + bool visit(QQmlJS::AST::UiImport *ast) override; + bool visit(QQmlJS::AST::UiPragma *ast) override; + bool visit(QQmlJS::AST::UiHeaderItemList *ast) override; + bool visit(QQmlJS::AST::UiObjectInitializer *ast) override; + bool visit(QQmlJS::AST::UiObjectMemberList *ast) override; + bool visit(QQmlJS::AST::UiParameterList *ast) override; + bool visit(QQmlJS::AST::UiProgram *) override; + bool visit(QQmlJS::AST::UiQualifiedId *ast) override; + bool visit(QQmlJS::AST::UiArrayBinding *ast) override; + bool visit(QQmlJS::AST::UiObjectBinding *ast) override; + bool visit(QQmlJS::AST::UiObjectDefinition *ast) override; + bool visit(QQmlJS::AST::UiInlineComponent *ast) override; + bool visit(QQmlJS::AST::UiEnumDeclaration *ast) override; + bool visit(QQmlJS::AST::UiPublicMember *ast) override; + bool visit(QQmlJS::AST::UiScriptBinding *ast) override; + bool visit(QQmlJS::AST::UiSourceElement *ast) override; + bool visit(QQmlJS::AST::UiRequired *ast) override; + + void throwRecursionDepthError() override + { + recordError(QQmlJS::SourceLocation(), + QStringLiteral("Maximum statement or expression depth exceeded")); + } + + void accept(QQmlJS::AST::Node *node); + + // returns index in _objects + bool defineQMLObject( + int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, + const QV4::CompiledData::Location &location, + QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride = nullptr); + + bool defineQMLObject( + int *objectIndex, QQmlJS::AST::UiObjectDefinition *node, + Object *declarationsOverride = nullptr) + { + const QQmlJS::SourceLocation location = node->qualifiedTypeNameId->firstSourceLocation(); + return defineQMLObject( + objectIndex, node->qualifiedTypeNameId, + { location.startLine, location.startColumn }, node->initializer, + declarationsOverride); + } + + static QString asString(QQmlJS::AST::UiQualifiedId *node); + QStringView asStringRef(QQmlJS::AST::Node *node); + static QTypeRevision extractVersion(QStringView string); + QStringView textRefAt(const QQmlJS::SourceLocation &loc) const + { return QStringView(sourceCode).mid(loc.offset, loc.length); } + QStringView textRefAt(const QQmlJS::SourceLocation &first, + const QQmlJS::SourceLocation &last) const; + + void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, + QQmlJS::AST::Node *parentNode); + void tryGeneratingTranslationBinding(QStringView base, QQmlJS::AST::ArgumentList *args, QV4::CompiledData::Binding *binding); + + void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value, + QQmlJS::AST::Node *parentNode); + void appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment = false); + void appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation, + const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex, + QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode); + void appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation, + const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex, + int objectIndex, bool isListItem = false, bool isOnAssignment = false); + + bool appendAlias(QQmlJS::AST::UiPublicMember *node); + + Object *bindingsTarget() const; + + bool setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value); + + // resolves qualified name (font.pixelSize for example) and returns the last name along + // with the object any right-hand-side of a binding should apply to. + bool resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, Object **object, bool onAssignment = false); + + void recordError(const QQmlJS::SourceLocation &location, const QString &description); + + quint32 registerString(const QString &str) const { return jsGenerator->registerString(str); } + template <typename _Tp> _Tp *New() { return pool->New<_Tp>(); } + + QString stringAt(int index) const { return jsGenerator->stringForIndex(index); } + + static bool isStatementNodeScript(QQmlJS::AST::Statement *statement); + static bool isRedundantNullInitializerForPropertyDeclaration(Property *property, QQmlJS::AST::Statement *statement); + + QString sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::SourceLocation *errorLocation); + + QList<QQmlJS::DiagnosticMessage> errors; + + QSet<QString> illegalNames; + QSet<QString> inlineComponentsNames; + + QList<const QV4::CompiledData::Import *> _imports; + QList<Pragma*> _pragmas; + QVector<Object*> _objects; + + QV4::CompiledData::TypeReferenceMap _typeReferences; + + Object *_object; + Property *_propertyDeclaration; + + QQmlJS::MemoryPool *pool; + QString sourceCode; + QV4::Compiler::JSUnitGenerator *jsGenerator; + + bool insideInlineComponent = false; +}; + +struct Q_QML_COMPILER_EXPORT QmlUnitGenerator +{ + void generate(Document &output, const QV4::CompiledData::DependentTypesHasher &dependencyHasher = QV4::CompiledData::DependentTypesHasher()); + +private: + typedef bool (Binding::*BindingFilter)() const; + char *writeBindings(char *bindingPtr, const Object *o, BindingFilter filter) const; +}; + +struct Q_QML_COMPILER_EXPORT JSCodeGen : public QV4::Compiler::Codegen +{ + JSCodeGen(Document *document, const QSet<QString> &globalNames, + QV4::Compiler::CodegenWarningInterface *iface = + QV4::Compiler::defaultCodegenWarningInterface(), + bool storeSourceLocations = false); + + // Returns mapping from input functions to index in IR::Module::functions / compiledData->runtimeFunctions + QVector<int> + generateJSCodeForFunctionsAndBindings(const QList<CompiledFunctionOrExpression> &functions); + + bool generateRuntimeFunctions(QmlIR::Object *object); + +private: + Document *document; +}; + +// RegisterStringN ~= std::function<int(QStringView)> +// FinalizeTranlationData ~= std::function<void(QV4::CompiledData::Binding::ValueType, QV4::CompiledData::TranslationData)> +/* + \internal + \a base: name of the potential translation function + \a args: arguments to the function call + \a registerMainString: Takes the first argument passed to the translation function, and it's + result will be stored in a TranslationData's stringIndex for translation bindings and in numbeIndex + for string bindings. + \a registerCommentString: Takes the comment argument passed to some of the translation functions. + Result will be stored in a TranslationData's commentIndex + \a finalizeTranslationData: Takes the type of the binding and the previously set up TranslationData + */ +template< + typename RegisterMainString, + typename RegisterCommentString, + typename RegisterContextString, + typename FinalizeTranslationData> +void tryGeneratingTranslationBindingBase(QStringView base, QQmlJS::AST::ArgumentList *args, + RegisterMainString registerMainString, + RegisterCommentString registerCommentString, + RegisterContextString registerContextString, + FinalizeTranslationData finalizeTranslationData + ) +{ + if (base == QLatin1String("qsTr")) { + QV4::CompiledData::TranslationData translationData; + translationData.number = -1; + + // empty string + translationData.commentIndex = 0; + + // No context (not empty string) + translationData.contextIndex = QV4::CompiledData::TranslationData::NoContextIndex; + + if (!args || !args->expression) + return; // no arguments, stop + + QStringView translation; + if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) { + translation = arg1->value; + } else { + return; // first argument is not a string, stop + } + + translationData.stringIndex = registerMainString(translation); + + args = args->next; + + if (args) { + QQmlJS::AST::StringLiteral *arg2 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression); + if (!arg2) + return; // second argument is not a string, stop + translationData.commentIndex = registerCommentString(arg2->value); + + args = args->next; + if (args) { + if (QQmlJS::AST::NumericLiteral *arg3 = QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(args->expression)) { + translationData.number = int(arg3->value); + args = args->next; + } else { + return; // third argument is not a translation number, stop + } + } + } + + if (args) + return; // too many arguments, stop + + finalizeTranslationData(QV4::CompiledData::Binding::Type_Translation, translationData); + } else if (base == QLatin1String("qsTrId")) { + QV4::CompiledData::TranslationData translationData; + translationData.number = -1; + + // empty string, but unused + translationData.commentIndex = 0; + + // No context (not empty string) + translationData.contextIndex = QV4::CompiledData::TranslationData::NoContextIndex; + + if (!args || !args->expression) + return; // no arguments, stop + + QStringView id; + if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) { + id = arg1->value; + } else { + return; // first argument is not a string, stop + } + translationData.stringIndex = registerMainString(id); + + args = args->next; + + if (args) { + if (QQmlJS::AST::NumericLiteral *arg3 = QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(args->expression)) { + translationData.number = int(arg3->value); + args = args->next; + } else { + return; // third argument is not a translation number, stop + } + } + + if (args) + return; // too many arguments, stop + + finalizeTranslationData(QV4::CompiledData::Binding::Type_TranslationById, translationData); + } else if (base == QLatin1String("QT_TR_NOOP") || base == QLatin1String("QT_TRID_NOOP")) { + if (!args || !args->expression) + return; // no arguments, stop + + QStringView str; + if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) { + str = arg1->value; + } else { + return; // first argument is not a string, stop + } + + args = args->next; + if (args) + return; // too many arguments, stop + + QV4::CompiledData::TranslationData translationData; + translationData.number = registerMainString(str); + finalizeTranslationData(QV4::CompiledData::Binding::Type_String, translationData); + } else if (base == QLatin1String("QT_TRANSLATE_NOOP")) { + if (!args || !args->expression) + return; // no arguments, stop + + args = args->next; + if (!args || !args->expression) + return; // no second arguments, stop + + QStringView str; + if (QQmlJS::AST::StringLiteral *arg2 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) { + str = arg2->value; + } else { + return; // first argument is not a string, stop + } + + args = args->next; + if (args) + return; // too many arguments, stop + + QV4::CompiledData::TranslationData fakeTranslationData; + fakeTranslationData.number = registerMainString(str); + finalizeTranslationData(QV4::CompiledData::Binding::Type_String, fakeTranslationData); + } else if (base == QLatin1String("qsTranslate")) { + QV4::CompiledData::TranslationData translationData; + translationData.number = -1; + translationData.commentIndex = 0; // empty string + + if (!args || !args->next) + return; // less than 2 arguments, stop + + QStringView translation; + if (QQmlJS::AST::StringLiteral *arg1 + = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) { + translation = arg1->value; + } else { + return; // first argument is not a string, stop + } + + translationData.contextIndex = registerContextString(translation); + + args = args->next; + Q_ASSERT(args); + + QQmlJS::AST::StringLiteral *arg2 + = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression); + if (!arg2) + return; // second argument is not a string, stop + translationData.stringIndex = registerMainString(arg2->value); + + args = args->next; + if (args) { + QQmlJS::AST::StringLiteral *arg3 + = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression); + if (!arg3) + return; // third argument is not a string, stop + translationData.commentIndex = registerCommentString(arg3->value); + + args = args->next; + if (args) { + if (QQmlJS::AST::NumericLiteral *arg4 + = QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(args->expression)) { + translationData.number = int(arg4->value); + args = args->next; + } else { + return; // fourth argument is not a translation number, stop + } + } + } + + if (args) + return; // too many arguments, stop + + finalizeTranslationData(QV4::CompiledData::Binding::Type_Translation, translationData); + } +} + +} // namespace QmlIR + +QT_END_NAMESPACE + +#endif // QQMLIRBUILDER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlirloader_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlirloader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..30cf1d3dc12de21cd10764920a58e2f4237d20d7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlirloader_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLIRLOADER_P_H +#define QQMLIRLOADER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> +#include <private/qv4compileddata_p.h> +#include <private/qqmljsmemorypool_p.h> + +QT_BEGIN_NAMESPACE + +namespace QmlIR { +struct Document; +struct Object; +} + +struct Q_QML_EXPORT QQmlIRLoader { + QQmlIRLoader(const QV4::CompiledData::Unit *unit, QmlIR::Document *output); + + void load(); + +private: + QmlIR::Object *loadObject(const QV4::CompiledData::Object *serializedObject); + + template <typename _Tp> _Tp *New() { return pool->New<_Tp>(); } + + const QV4::CompiledData::Unit *unit; + QmlIR::Document *output; + QQmlJS::MemoryPool *pool; +}; + +QT_END_NAMESPACE + +#endif // QQMLIRLOADER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljavascriptexpression_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljavascriptexpression_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4d31aee330170de39a3cb88b58c20930708de5a8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljavascriptexpression_p.h @@ -0,0 +1,295 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJAVASCRIPTEXPRESSION_P_H +#define QQMLJAVASCRIPTEXPRESSION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtCore/qtaggedpointer.h> +#include <QtQml/qqmlerror.h> +#include <private/qqmlengine_p.h> +#include <QtQml/private/qbipointer_p.h> + +QT_BEGIN_NAMESPACE + +struct QQmlSourceLocation; + +class QQmlDelayedError +{ +public: + inline QQmlDelayedError() : nextError(nullptr), prevError(nullptr) {} + inline ~QQmlDelayedError() { (void)removeError(); } + + bool addError(QQmlEnginePrivate *); + + Q_REQUIRED_RESULT inline QQmlError removeError() { + if (prevError) { + if (nextError) nextError->prevError = prevError; + *prevError = nextError; + nextError = nullptr; + prevError = nullptr; + } + return m_error; + } + + inline bool isValid() const { return m_error.isValid(); } + inline const QQmlError &error() const { return m_error; } + inline void clearError() { m_error = QQmlError(); } + + void setErrorLocation(const QQmlSourceLocation &sourceLocation); + void setErrorDescription(const QString &description); + void setErrorObject(QObject *object); + + // Call only from catch(...) -- will re-throw if no JS exception + void catchJavaScriptException(QV4::ExecutionEngine *engine); + +private: + + mutable QQmlError m_error; + + QQmlDelayedError *nextError; + QQmlDelayedError **prevError; +}; + +class Q_QML_EXPORT QQmlJavaScriptExpression +{ + Q_DISABLE_COPY_MOVE(QQmlJavaScriptExpression) +public: + QQmlJavaScriptExpression(); + virtual ~QQmlJavaScriptExpression(); + + virtual QString expressionIdentifier() const; + virtual void expressionChanged() = 0; + + QV4::ReturnedValue evaluate(bool *isUndefined); + QV4::ReturnedValue evaluate(QV4::CallData *callData, bool *isUndefined); + bool evaluate(void **a, const QMetaType *types, int argc); + + inline bool notifyOnValueChanged() const; + + void setNotifyOnValueChanged(bool v); + void resetNotifyOnValueChanged(); + + inline QObject *scopeObject() const; + inline void setScopeObject(QObject *v); + + virtual QQmlSourceLocation sourceLocation() const; + + bool hasContext() const { return m_context != nullptr; } + bool hasValidContext() const { return m_context && m_context->isValid(); } + QQmlContext *publicContext() const { return m_context ? m_context->asQQmlContext() : nullptr; } + + QQmlRefPointer<QQmlContextData> context() const { return m_context; } + void setContext(const QQmlRefPointer<QQmlContextData> &context); + + void insertIntoList(QQmlJavaScriptExpression **listHead) + { + m_nextExpression = *listHead; + if (m_nextExpression) + m_nextExpression->m_prevExpression = &m_nextExpression; + m_prevExpression = listHead; + *listHead = this; + } + + QV4::Function *function() const { return m_v4Function; } + + virtual void refresh(); + + class DeleteWatcher { + public: + inline DeleteWatcher(QQmlJavaScriptExpression *); + inline ~DeleteWatcher(); + inline bool wasDeleted() const; + private: + friend class QQmlJavaScriptExpression; + QObject *_c; + QQmlJavaScriptExpression **_w; + QQmlJavaScriptExpression *_s; + }; + + inline bool hasError() const; + inline bool hasDelayedError() const; + QQmlError error(QQmlEngine *) const; + void clearError(); + void clearActiveGuards(); + QQmlDelayedError *delayedError(); + virtual bool mustCaptureBindableProperty() const {return true;} + + static QV4::ReturnedValue evalFunction( + const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope, const QString &code, + const QString &filename, quint16 line); + + QQmlEngine *engine() const { return m_context ? m_context->engine() : nullptr; } + bool hasUnresolvedNames() const { return m_context && m_context->hasUnresolvedNames(); } + + bool needsPropertyChangeTrigger(QObject *target, int propertyIndex); + QPropertyChangeTrigger *allocatePropertyChangeTrigger(QObject *target, int propertyIndex); + +protected: + void createQmlBinding(const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope, + const QString &code, const QString &filename, quint16 line); + + void setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f); + void setCompilationUnit(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit); + + // We store some flag bits in the following flag pointers. + // activeGuards:flag1 - notifyOnValueChanged + // activeGuards:flag2 - useSharedContext + QBiPointer<QObject, DeleteWatcher> m_scopeObject; + + enum GuardTag { + NoGuardTag, + NotifyOnValueChanged + }; + + QForwardFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next, GuardTag> activeGuards; + + enum Tag { + NoTag, + InEvaluationLoop + }; + + QTaggedPointer<QQmlDelayedError, Tag> m_error; + +private: + friend class QQmlContextData; + friend class QQmlPropertyCapture; + friend void QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint *, void **); + friend class QQmlTranslationBindingFromBinding; + friend class QQmlTranslationBindingFromTranslationInfo; + friend class QQmlJavaScriptExpressionCapture; + + // Not refcounted as the context will clear the expressions when destructed. + QQmlContextData *m_context; + + QQmlJavaScriptExpression **m_prevExpression; + QQmlJavaScriptExpression *m_nextExpression; + + QV4::PersistentValue m_qmlScope; + QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit; + + QV4::Function *m_v4Function; + +protected: + TriggerList *qpropertyChangeTriggers = nullptr; +}; + +class Q_QML_EXPORT QQmlPropertyCapture +{ +public: + QQmlPropertyCapture(QQmlEngine *engine, QQmlJavaScriptExpression *e, QQmlJavaScriptExpression::DeleteWatcher *w) + : engine(engine), expression(e), watcher(w), errorString(nullptr) { } + + ~QQmlPropertyCapture() { + Q_ASSERT(guards.isEmpty()); + Q_ASSERT(errorString == nullptr); + } + + void captureProperty(QQmlNotifier *); + void captureProperty(QObject *, int, int, bool doNotify = true); + void captureProperty(QObject *, const QQmlPropertyCache *, const QQmlPropertyData *, bool doNotify = true); + void captureTranslation(); + + QQmlEngine *engine; + QQmlJavaScriptExpression *expression; + QQmlJavaScriptExpression::DeleteWatcher *watcher; + QForwardFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next> guards; + QStringList *errorString; + +private: + void captureBindableProperty(QObject *o, const QMetaObject *metaObjectForBindable, int c); + void captureNonBindableProperty(QObject *o, int n, int c, bool doNotify); +}; + +QQmlJavaScriptExpression::DeleteWatcher::DeleteWatcher(QQmlJavaScriptExpression *e) +: _c(nullptr), _w(nullptr), _s(e) +{ + if (e->m_scopeObject.isT1()) { + _w = &_s; + _c = e->m_scopeObject.asT1(); + e->m_scopeObject = this; + } else { + // Another watcher is already registered + _w = &e->m_scopeObject.asT2()->_s; + } +} + +QQmlJavaScriptExpression::DeleteWatcher::~DeleteWatcher() +{ + Q_ASSERT(*_w == nullptr || (*_w == _s && _s->m_scopeObject.isT2())); + if (*_w && _s->m_scopeObject.asT2() == this) + _s->m_scopeObject = _c; +} + +bool QQmlJavaScriptExpression::DeleteWatcher::wasDeleted() const +{ + return *_w == nullptr; +} + +bool QQmlJavaScriptExpression::notifyOnValueChanged() const +{ + return activeGuards.tag() == NotifyOnValueChanged; +} + +QObject *QQmlJavaScriptExpression::scopeObject() const +{ + if (m_scopeObject.isT1()) return m_scopeObject.asT1(); + else return m_scopeObject.asT2()->_c; +} + +void QQmlJavaScriptExpression::setScopeObject(QObject *v) +{ + if (m_scopeObject.isT1()) m_scopeObject = v; + else m_scopeObject.asT2()->_c = v; +} + +bool QQmlJavaScriptExpression::hasError() const +{ + return !m_error.isNull() && m_error->isValid(); +} + +bool QQmlJavaScriptExpression::hasDelayedError() const +{ + return !m_error.isNull(); +} + +inline void QQmlJavaScriptExpression::clearError() +{ + delete m_error.data(); + m_error = nullptr; +} + +QQmlJavaScriptExpressionGuard::QQmlJavaScriptExpressionGuard(QQmlJavaScriptExpression *e) + : QQmlNotifierEndpoint(QQmlNotifierEndpoint::QQmlJavaScriptExpressionGuard), + expression(e), next(nullptr) +{ +} + +QQmlJavaScriptExpressionGuard * +QQmlJavaScriptExpressionGuard::New(QQmlJavaScriptExpression *e, + QQmlEngine *engine) +{ + Q_ASSERT(e); + return QQmlEnginePrivate::get(engine)->jsExpressionGuardPool.New(e); +} + +void QQmlJavaScriptExpressionGuard::Delete() +{ + QRecyclePool<QQmlJavaScriptExpressionGuard>::Delete(this); +} + + +QT_END_NAMESPACE + +#endif // QQMLJAVASCRIPTEXPRESSION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsast_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsast_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3c201086480ec78991df33e5465780039e8bd3a9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsast_p.h @@ -0,0 +1,3874 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJSAST_P_H +#define QQMLJSAST_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmljsastvisitor_p.h" +#include "qqmljsglobal_p.h" + +#include <private/qqmljsmemorypool_p.h> + +#include <QtCore/qtaggedpointer.h> +#include <QtCore/qversionnumber.h> + +#include <type_traits> + +QT_BEGIN_NAMESPACE + +class QString; + +namespace QQmlJS { + class Parser; +} + +#define QQMLJS_DECLARE_AST_NODE(name) \ + enum { K = Kind_##name }; + +namespace QSOperator // ### rename +{ + +enum Op { + Add, + And, + InplaceAnd, + Assign, + BitAnd, + BitOr, + BitXor, + InplaceSub, + Div, + InplaceDiv, + Equal, + Exp, + InplaceExp, + Ge, + Gt, + In, + InplaceAdd, + InstanceOf, + Le, + LShift, + InplaceLeftShift, + Lt, + Mod, + InplaceMod, + Mul, + InplaceMul, + NotEqual, + Or, + InplaceOr, + RShift, + InplaceRightShift, + StrictEqual, + StrictNotEqual, + Sub, + URShift, + InplaceURightShift, + InplaceXor, + As, + Coalesce, + Invalid +}; + +} // namespace QSOperator + +namespace QQmlJS { + +namespace AST { + +enum class VariableScope { + NoScope, + Var, + Let, + Const +}; + +template <typename T1, typename T2> +T1 cast(T2 *ast) +{ + if (ast && ast->kind == std::remove_pointer_t<T1>::K) + return static_cast<T1>(ast); + + return nullptr; +} + +FunctionExpression *asAnonymousFunctionDefinition(AST::Node *n); +ClassExpression *asAnonymousClassDefinition(AST::Node *n); + +class QML_PARSER_EXPORT Node: public Managed +{ +public: + enum Kind { + Kind_Undefined, + + Kind_ArgumentList, + Kind_ArrayPattern, + Kind_ArrayMemberExpression, + Kind_BinaryExpression, + Kind_Block, + Kind_BreakStatement, + Kind_CallExpression, + Kind_CaseBlock, + Kind_CaseClause, + Kind_CaseClauses, + Kind_Catch, + Kind_ConditionalExpression, + Kind_ContinueStatement, + Kind_DebuggerStatement, + Kind_DefaultClause, + Kind_DeleteExpression, + Kind_DoWhileStatement, + Kind_ElementList, + Kind_Elision, + Kind_EmptyStatement, + Kind_Expression, + Kind_ExpressionStatement, + Kind_FalseLiteral, + Kind_SuperLiteral, + Kind_FieldMemberExpression, + Kind_Finally, + Kind_ForEachStatement, + Kind_ForStatement, + Kind_FormalParameterList, + Kind_FunctionBody, + Kind_FunctionDeclaration, + Kind_FunctionExpression, + Kind_ClassExpression, + Kind_ClassDeclaration, + Kind_IdentifierExpression, + Kind_IdentifierPropertyName, + Kind_InitializerExpression, + Kind_ComputedPropertyName, + Kind_IfStatement, + Kind_LabelledStatement, + Kind_NameSpaceImport, + Kind_ImportSpecifier, + Kind_ImportsList, + Kind_NamedImports, + Kind_ImportClause, + Kind_FromClause, + Kind_ImportDeclaration, + Kind_Module, + Kind_ExportSpecifier, + Kind_ExportsList, + Kind_ExportClause, + Kind_ExportDeclaration, + Kind_NewExpression, + Kind_NewMemberExpression, + Kind_NotExpression, + Kind_NullExpression, + Kind_YieldExpression, + Kind_NumericLiteral, + Kind_NumericLiteralPropertyName, + Kind_ObjectPattern, + Kind_PostDecrementExpression, + Kind_PostIncrementExpression, + Kind_PreDecrementExpression, + Kind_PreIncrementExpression, + Kind_Program, + Kind_PropertyDefinitionList, + Kind_PropertyGetterSetter, + Kind_PropertyName, + Kind_PropertyNameAndValue, + Kind_RegExpLiteral, + Kind_ReturnStatement, + Kind_StatementList, + Kind_StringLiteral, + Kind_StringLiteralPropertyName, + Kind_SwitchStatement, + Kind_TemplateLiteral, + Kind_TaggedTemplate, + Kind_TypeExpression, + Kind_ThisExpression, + Kind_ThrowStatement, + Kind_TildeExpression, + Kind_TrueLiteral, + Kind_TryStatement, + Kind_TypeOfExpression, + Kind_UnaryMinusExpression, + Kind_UnaryPlusExpression, + Kind_VariableDeclaration, + Kind_VariableDeclarationList, + Kind_VariableStatement, + Kind_VoidExpression, + Kind_WhileStatement, + Kind_WithStatement, + Kind_NestedExpression, + Kind_ClassElementList, + Kind_PatternElement, + Kind_PatternElementList, + Kind_PatternProperty, + Kind_PatternPropertyList, + Kind_Type, + Kind_TypeArgument, + Kind_TypeAnnotation, + + Kind_UiArrayBinding, + Kind_UiImport, + Kind_UiObjectBinding, + Kind_UiObjectDefinition, + Kind_UiInlineComponent, + Kind_UiObjectInitializer, + Kind_UiObjectMemberList, + Kind_UiArrayMemberList, + Kind_UiPragmaValueList, + Kind_UiPragma, + Kind_UiProgram, + Kind_UiParameterList, + Kind_UiPropertyAttributes, + Kind_UiPublicMember, + Kind_UiQualifiedId, + Kind_UiScriptBinding, + Kind_UiSourceElement, + Kind_UiHeaderItemList, + Kind_UiEnumDeclaration, + Kind_UiEnumMemberList, + Kind_UiVersionSpecifier, + Kind_UiRequired, + Kind_UiAnnotation, + Kind_UiAnnotationList + }; + + inline Node() {} + + // NOTE: node destructors are never called, + // instead we block free the memory + // (see the NodePool class) + virtual ~Node() {} + + virtual ExpressionNode *expressionCast(); + virtual BinaryExpression *binaryExpressionCast(); + virtual Statement *statementCast(); + virtual UiObjectMember *uiObjectMemberCast(); + virtual LeftHandSideExpression *leftHandSideExpressionCast(); + virtual Pattern *patternCast(); + // implements the IsFunctionDefinition rules in the spec + virtual FunctionExpression *asFunctionDefinition(); + virtual ClassExpression *asClassDefinition(); + + bool ignoreRecursionDepth() const; + + inline void accept(BaseVisitor *visitor) + { + BaseVisitor::RecursionDepthCheck recursionCheck(visitor); + + // Stack overflow is uncommon, ignoreRecursionDepth() only returns true if + // QV4_CRASH_ON_STACKOVERFLOW is set, and ignoreRecursionDepth() needs to be out of line. + // Therefore, check for ignoreRecursionDepth() _after_ calling the inline recursionCheck(). + if (recursionCheck() || ignoreRecursionDepth()) { + if (visitor->preVisit(this)) + accept0(visitor); + visitor->postVisit(this); + } else { + visitor->throwRecursionDepthError(); + } + } + + inline static void accept(Node *node, BaseVisitor *visitor) + { + if (node) + node->accept(visitor); + } + + virtual void accept0(BaseVisitor *visitor) = 0; + virtual SourceLocation firstSourceLocation() const = 0; + virtual SourceLocation lastSourceLocation() const = 0; + +// attributes + int kind = Kind_Undefined; +}; + +template<typename T> +T lastListElement(T head) +{ + auto current = head; + while (current->next) + current = current->next; + return current; +} + +class QML_PARSER_EXPORT UiQualifiedId: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiQualifiedId) + + UiQualifiedId(QStringView name) + : next(this), name(name) + { kind = K; } + + UiQualifiedId(UiQualifiedId *previous, QStringView name) + : name(name) + { + kind = K; + next = previous->next; + previous->next = this; + } + + UiQualifiedId *finish() + { + UiQualifiedId *head = next; + next = nullptr; + return head; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return identifierToken; } + + SourceLocation lastSourceLocation() const override + { + return lastListElement(this)->lastOwnSourceLocation(); + } + + SourceLocation lastOwnSourceLocation() const { return identifierToken; } + + QString toString() const + { + QString result; + toString(&result); + return result; + } + + void toString(QString *out) const + { + for (const UiQualifiedId *it = this; it; it = it->next) { + out->append(it->name); + if (it->next) + out->append(QLatin1Char('.')); + } + } + +// attributes + UiQualifiedId *next; + QStringView name; + SourceLocation identifierToken; + SourceLocation dotToken; +}; + +class QML_PARSER_EXPORT Type: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(Type) + + Type(UiQualifiedId *typeId, Type *typeArgument = nullptr) + : typeId(typeId) + , typeArgument(typeArgument ? typeArgument->typeId : nullptr) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return typeId->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return typeArgument ? typeArgument->lastSourceLocation() : typeId->lastSourceLocation(); } + + QString toString() const; + void toString(QString *out) const; + +// attributes + UiQualifiedId *typeId; + UiQualifiedId *typeArgument; +}; + +class QML_PARSER_EXPORT TypeAnnotation: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(TypeAnnotation) + + TypeAnnotation(Type *type) + : type(type) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return colonToken; } + + SourceLocation lastSourceLocation() const override + { return type->lastSourceLocation(); } + +// attributes + Type *type; + SourceLocation colonToken; +}; +class QML_PARSER_EXPORT ExpressionNode: public Node +{ +public: + ExpressionNode() {} + + ExpressionNode *expressionCast() override; + bool containsOptionalChain() const; + + AST::FormalParameterList *reparseAsFormalParameterList(MemoryPool *pool); + +}; + +class QML_PARSER_EXPORT LeftHandSideExpression : public ExpressionNode +{ + LeftHandSideExpression *leftHandSideExpressionCast() override; +}; + +class QML_PARSER_EXPORT Statement: public Node +{ +public: + Statement() {} + + Statement *statementCast() override; +}; + +class QML_PARSER_EXPORT NestedExpression: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(NestedExpression) + + NestedExpression(ExpressionNode *expression) + : expression(expression) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lparenToken; } + + SourceLocation lastSourceLocation() const override + { return rparenToken; } + + FunctionExpression *asFunctionDefinition() override; + ClassExpression *asClassDefinition() override; + + +// attributes + ExpressionNode *expression; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + + +class QML_PARSER_EXPORT TypeExpression : public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(TypeExpression) + TypeExpression(Type *t) : m_type(t) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override { + return m_type->firstSourceLocation(); + } + + SourceLocation lastSourceLocation() const override { + return m_type->lastSourceLocation(); + } + + Type *m_type; +}; + +class QML_PARSER_EXPORT ThisExpression: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(ThisExpression) + + ThisExpression() { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return thisToken; } + + SourceLocation lastSourceLocation() const override + { return thisToken; } + +// attributes + SourceLocation thisToken; +}; + +class QML_PARSER_EXPORT IdentifierExpression: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(IdentifierExpression) + + IdentifierExpression(QStringView n): + name (n) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return identifierToken; } + + SourceLocation lastSourceLocation() const override + { return identifierToken; } + +// attributes + QStringView name; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT NullExpression: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(NullExpression) + + NullExpression() { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return nullToken; } + + SourceLocation lastSourceLocation() const override + { return nullToken; } + +// attributes + SourceLocation nullToken; +}; + +class QML_PARSER_EXPORT TrueLiteral: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(TrueLiteral) + + TrueLiteral() { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return trueToken; } + + SourceLocation lastSourceLocation() const override + { return trueToken; } + +// attributes + SourceLocation trueToken; +}; + +class QML_PARSER_EXPORT FalseLiteral: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(FalseLiteral) + + FalseLiteral() { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return falseToken; } + + SourceLocation lastSourceLocation() const override + { return falseToken; } + +// attributes + SourceLocation falseToken; +}; + +class QML_PARSER_EXPORT SuperLiteral : public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(SuperLiteral) + + SuperLiteral() { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return superToken; } + + SourceLocation lastSourceLocation() const override + { return superToken; } + +// attributes + SourceLocation superToken; +}; + + +class QML_PARSER_EXPORT NumericLiteral: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(NumericLiteral) + + NumericLiteral(double v): + value(v) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return literalToken; } + + SourceLocation lastSourceLocation() const override + { return literalToken; } + +// attributes: + double value; + SourceLocation literalToken; +}; + +class QML_PARSER_EXPORT UiVersionSpecifier : public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiVersionSpecifier) + + UiVersionSpecifier(int majorum) : version(QTypeRevision::fromMajorVersion(majorum)) + { + kind = K; + } + + UiVersionSpecifier(int majorum, int minorum) : version(QTypeRevision::fromVersion(majorum, minorum)) + { + kind = K; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override { return majorToken; } + + SourceLocation lastSourceLocation() const override + { + return minorToken.isValid() ? minorToken : majorToken; + } + + // attributes: + QTypeRevision version; + SourceLocation majorToken; + SourceLocation minorToken; +}; + +class QML_PARSER_EXPORT StringLiteral : public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(StringLiteral) + + StringLiteral(QStringView v): + value (v) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return literalToken; } + + SourceLocation lastSourceLocation() const override + { return literalToken; } + +// attributes: + QStringView value; + SourceLocation literalToken; +}; + +class QML_PARSER_EXPORT TemplateLiteral : public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(TemplateLiteral) + + TemplateLiteral(QStringView str, QStringView raw, ExpressionNode *e) + : value(str), rawValue(raw), expression(e), next(nullptr) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { return literalToken; } + + SourceLocation lastSourceLocation() const override + { + auto last = lastListElement(this); + return (last->expression ? last->expression->lastSourceLocation() : last->literalToken); + } + + void accept0(BaseVisitor *visitor) override; + + bool hasNoSubstitution = false; + QStringView value; + QStringView rawValue; + ExpressionNode *expression; + TemplateLiteral *next; + SourceLocation literalToken; +}; + +class QML_PARSER_EXPORT RegExpLiteral: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(RegExpLiteral) + + RegExpLiteral(QStringView p, int f): + pattern (p), flags (f) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return literalToken; } + + SourceLocation lastSourceLocation() const override + { return literalToken; } + +// attributes: + QStringView pattern; + int flags; + SourceLocation literalToken; +}; + +class QML_PARSER_EXPORT Pattern : public LeftHandSideExpression +{ +public: + enum ParseMode { + Literal, + Binding + }; + Pattern *patternCast() override; + virtual bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) = 0; + ParseMode parseMode = Literal; +}; + +class QML_PARSER_EXPORT ArrayPattern : public Pattern +{ +public: + QQMLJS_DECLARE_AST_NODE(ArrayPattern) + + ArrayPattern(PatternElementList *elts) + : elements(elts) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lbracketToken; } + + SourceLocation lastSourceLocation() const override + { return rbracketToken; } + + bool isValidArrayLiteral(SourceLocation *errorLocation = nullptr) const; + + bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) override; + +// attributes + PatternElementList *elements = nullptr; + SourceLocation lbracketToken; + SourceLocation commaToken; + SourceLocation rbracketToken; +}; + +class QML_PARSER_EXPORT ObjectPattern : public Pattern +{ +public: + QQMLJS_DECLARE_AST_NODE(ObjectPattern) + + ObjectPattern() + { kind = K; } + + ObjectPattern(PatternPropertyList *plist) + : properties(plist) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lbraceToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + + bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) override; + +// attributes + PatternPropertyList *properties = nullptr; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT Elision: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(Elision) + + Elision(): + next (this) { kind = K; } + + Elision(Elision *previous) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return commaToken; } + + SourceLocation lastSourceLocation() const override + { return lastListElement(this)->commaToken; } + + inline Elision *finish () + { + Elision *front = next; + next = nullptr; + return front; + } + +// attributes + Elision *next; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT PropertyName: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(PropertyName) + + PropertyName() { kind = K; } + + SourceLocation firstSourceLocation() const override + { return propertyNameToken; } + + SourceLocation lastSourceLocation() const override + { return propertyNameToken; } + + virtual QString asString() const = 0; + +// attributes + SourceLocation propertyNameToken; +}; + +struct QML_PARSER_EXPORT BoundName +{ + enum Type { + Declared, + Injected, + }; + + QString id; + QQmlJS::SourceLocation location; + QTaggedPointer<TypeAnnotation, Type> typeAnnotation; + BoundName(const QString &id, const QQmlJS::SourceLocation &location, + TypeAnnotation *typeAnnotation, Type type = Declared) + : id(id), location(location), typeAnnotation(typeAnnotation, type) + {} + BoundName() = default; + + bool isInjected() const { return typeAnnotation.tag() == Injected; } +}; + +struct BoundNames : public QVector<BoundName> +{ + int indexOf(const QString &name, int from = 0) const + { + auto found = std::find_if(constBegin() + from, constEnd(), + [name](const BoundName &it) { return it.id == name; }); + if (found == constEnd()) + return -1; + return found - constBegin(); + } + + bool contains(const QString &name) const + { + return indexOf(name) != -1; + } +}; + +/*! +\internal +This class is needed to pass the information about the equalToken in the parser, and is only needed +during AST construction. It behaves exactly like the expression it contains: that avoids changing +all the usages in qqmljs.g from ExpressionNode to InitializerExpression for every rule expecting a +InitializerOpt_In or InitializerOpt. +*/ +class QML_PARSER_EXPORT InitializerExpression : public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(InitializerExpression) + + InitializerExpression(ExpressionNode *e) : expression(e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return equalToken; } + + SourceLocation lastSourceLocation() const override { return expression->lastSourceLocation(); } + + FunctionExpression *asFunctionDefinition() override + { + return expression->asFunctionDefinition(); + } + + ClassExpression *asClassDefinition() override { return expression->asClassDefinition(); } + + // attributes + ExpressionNode *expression; + SourceLocation equalToken; +}; + +class QML_PARSER_EXPORT PatternElement : public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(PatternElement) + + enum Type { + // object literal types + Literal, + Method, + Getter, + Setter, + + // used by both bindings and literals + SpreadElement, + RestElement = SpreadElement, + + // binding types + Binding, + }; + +private: + /*! + \internal + Hide InitializerExpression from the AST. InitializerExpression is only needed during parsing for + the AST construction, and it is not possible for the parser to directly embed the location of + equal tokens inside the PatternElement without the InitializerExpression. + */ + void unwrapInitializer() + { + if (auto unwrapped = AST::cast<InitializerExpression *>(initializer)) { + equalToken = unwrapped->equalToken; + initializer = unwrapped->expression; + } + } +public: + + PatternElement(ExpressionNode *i = nullptr, Type t = Literal) + : initializer(i), type(t) + { + kind = K; + unwrapInitializer(); + } + + PatternElement(QStringView n, TypeAnnotation *typeAnnotation = nullptr, ExpressionNode *i = nullptr, Type t = Binding) + : bindingIdentifier(n), initializer(i), type(t) + , typeAnnotation(typeAnnotation) + { + Q_ASSERT(t >= RestElement); + kind = K; + unwrapInitializer(); + } + + PatternElement(Pattern *pattern, ExpressionNode *i = nullptr, Type t = Binding) + : bindingTarget(pattern), initializer(i), type(t) + { + Q_ASSERT(t >= RestElement); + kind = K; + unwrapInitializer(); + } + + void accept0(BaseVisitor *visitor) override; + virtual bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage); + + SourceLocation firstSourceLocation() const override + { return identifierToken.isValid() ? identifierToken : (bindingTarget ? bindingTarget->firstSourceLocation() : initializer->firstSourceLocation()); } + + SourceLocation lastSourceLocation() const override + { return initializer ? initializer->lastSourceLocation() : (bindingTarget ? bindingTarget->lastSourceLocation() : (typeAnnotation ? typeAnnotation->lastSourceLocation() : identifierToken)); } + + ExpressionNode *destructuringTarget() const { return bindingTarget; } + Pattern *destructuringPattern() const { return bindingTarget ? bindingTarget->patternCast() : nullptr; } + PatternElementList *elementList() const { ArrayPattern *a = cast<ArrayPattern *>(bindingTarget); return a ? a->elements : nullptr; } + PatternPropertyList *propertyList() const { ObjectPattern *o = cast<ObjectPattern *>(bindingTarget); return o ? o->properties : nullptr; } + + bool isVariableDeclaration() const { return scope != VariableScope::NoScope; } + bool isLexicallyScoped() const { return scope == VariableScope::Let || scope == VariableScope::Const; } + + virtual void boundNames(BoundNames *names); + +// attributes + SourceLocation identifierToken; + SourceLocation equalToken; + QStringView bindingIdentifier; + ExpressionNode *bindingTarget = nullptr; + ExpressionNode *initializer = nullptr; + Type type = Literal; + TypeAnnotation *typeAnnotation = nullptr; + // when used in a VariableDeclarationList + SourceLocation declarationKindToken; + VariableScope scope = VariableScope::NoScope; + bool isForDeclaration = false; + bool isInjectedSignalParameter = false; +}; + +class QML_PARSER_EXPORT PatternElementList : public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(PatternElementList) + + PatternElementList(Elision *elision, PatternElement *element) + : elision(elision), element(element), next(this) + { kind = K; } + + PatternElementList *append(PatternElementList *n) { + n->next = next; + next = n; + return n; + } + + inline PatternElementList *finish () + { + PatternElementList *front = next; + next = 0; + return front; + } + + void accept0(BaseVisitor *visitor) override; + + void boundNames(BoundNames *names); + + SourceLocation firstSourceLocation() const override + { return elision ? elision->firstSourceLocation() : element->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + auto last = lastListElement(this); + return last->element ? last->element->lastSourceLocation() : last->elision->lastSourceLocation(); + } + + Elision *elision = nullptr; + PatternElement *element = nullptr; + PatternElementList *next; +}; + +class QML_PARSER_EXPORT PatternProperty : public PatternElement +{ +public: + QQMLJS_DECLARE_AST_NODE(PatternProperty) + + PatternProperty(PropertyName *name, ExpressionNode *i = nullptr, Type t = Literal) + : PatternElement(i, t), name(name) + { kind = K; } + + PatternProperty(PropertyName *name, QStringView n, ExpressionNode *i = nullptr) + : PatternElement(n, /*type annotation*/nullptr, i), name(name) + { kind = K; } + + PatternProperty(PropertyName *name, Pattern *pattern, ExpressionNode *i = nullptr) + : PatternElement(pattern, i), name(name) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return name->firstSourceLocation(); } + SourceLocation lastSourceLocation() const override + { + SourceLocation loc = PatternElement::lastSourceLocation(); + return loc.isValid() ? loc : name->lastSourceLocation(); + } + + void boundNames(BoundNames *names) override; + bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) override; + +// attributes + PropertyName *name; + SourceLocation colonToken; +}; + + +class QML_PARSER_EXPORT PatternPropertyList : public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(PatternPropertyList) + + PatternPropertyList(PatternProperty *property) + : property(property), next(this) + { kind = K; } + + PatternPropertyList(PatternPropertyList *previous, PatternProperty *property) + : property(property), next(this) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(BaseVisitor *visitor) override; + + void boundNames(BoundNames *names); + + inline PatternPropertyList *finish () + { + PatternPropertyList *front = next; + next = 0; + return front; + } + + SourceLocation firstSourceLocation() const override + { return property->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return lastListElement(this)->property->lastSourceLocation(); } + + PatternProperty *property; + PatternPropertyList *next; +}; + +class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName +{ +public: + QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName) + + IdentifierPropertyName(QStringView n): + id (n) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + QString asString() const override { return id.toString(); } + +// attributes + QStringView id; +}; + +class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName +{ +public: + QQMLJS_DECLARE_AST_NODE(StringLiteralPropertyName) + + StringLiteralPropertyName(QStringView n): + id (n) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + QString asString() const override { return id.toString(); } + +// attributes + QStringView id; +}; + +class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName +{ +public: + QQMLJS_DECLARE_AST_NODE(NumericLiteralPropertyName) + + NumericLiteralPropertyName(double n): + id (n) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + QString asString() const override; + +// attributes + double id; +}; + +class QML_PARSER_EXPORT ComputedPropertyName : public PropertyName +{ +public: + QQMLJS_DECLARE_AST_NODE(ComputedPropertyName) + + ComputedPropertyName(ExpressionNode *expression) + : expression(expression) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + QString asString() const override { return QString(); } + + SourceLocation firstSourceLocation() const override + { return expression->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; +}; + + +class QML_PARSER_EXPORT ArrayMemberExpression: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(ArrayMemberExpression) + + ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e): + base (b), expression (e) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return rbracketToken; } + +// attributes + ExpressionNode *base; + ExpressionNode *expression; + SourceLocation lbracketToken; + SourceLocation rbracketToken; + bool isOptional = false; +}; + +class QML_PARSER_EXPORT FieldMemberExpression: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(FieldMemberExpression) + + FieldMemberExpression(ExpressionNode *b, QStringView n): + base (b), name (n) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return identifierToken; } + + // attributes + ExpressionNode *base; + QStringView name; + SourceLocation dotToken; + SourceLocation identifierToken; + bool isOptional = false; +}; + +class QML_PARSER_EXPORT TaggedTemplate : public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(TaggedTemplate) + + TaggedTemplate(ExpressionNode *b, TemplateLiteral *t) + : base (b), templateLiteral(t) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return templateLiteral->lastSourceLocation(); } + + // attributes + ExpressionNode *base; + TemplateLiteral *templateLiteral; +}; + +class QML_PARSER_EXPORT NewMemberExpression: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(NewMemberExpression) + + NewMemberExpression(ExpressionNode *b, ArgumentList *a): + base (b), arguments (a) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return newToken; } + + SourceLocation lastSourceLocation() const override + { return rparenToken; } + + // attributes + ExpressionNode *base; + ArgumentList *arguments; + SourceLocation newToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT NewExpression: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(NewExpression) + + NewExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return newToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation newToken; +}; + +class QML_PARSER_EXPORT CallExpression: public LeftHandSideExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(CallExpression) + + CallExpression(ExpressionNode *b, ArgumentList *a): + base (b), arguments (a) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return rparenToken; } + +// attributes + ExpressionNode *base; + ArgumentList *arguments; + SourceLocation lparenToken; + SourceLocation rparenToken; + bool isOptional = false; +}; + +class QML_PARSER_EXPORT ArgumentList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ArgumentList) + + ArgumentList(ExpressionNode *e): + expression (e), next (this) + { kind = K; } + + ArgumentList(ArgumentList *previous, ExpressionNode *e): + expression (e) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return expression->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + if (next) + return next->lastSourceLocation(); + return expression->lastSourceLocation(); + } + + inline ArgumentList *finish () + { + ArgumentList *front = next; + next = nullptr; + return front; + } + +// attributes + ExpressionNode *expression; + ArgumentList *next; + SourceLocation commaToken; + bool isSpreadElement = false; +}; + +class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(PostIncrementExpression) + + PostIncrementExpression(ExpressionNode *b): + base (b) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return incrementToken; } + +// attributes + ExpressionNode *base; + SourceLocation incrementToken; +}; + +class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(PostDecrementExpression) + + PostDecrementExpression(ExpressionNode *b): + base (b) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return decrementToken; } + +// attributes + ExpressionNode *base; + SourceLocation decrementToken; +}; + +class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(DeleteExpression) + + DeleteExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return deleteToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation deleteToken; +}; + +class QML_PARSER_EXPORT VoidExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(VoidExpression) + + VoidExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return voidToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation voidToken; +}; + +class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(TypeOfExpression) + + TypeOfExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return typeofToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation typeofToken; +}; + +class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(PreIncrementExpression) + + PreIncrementExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return incrementToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation incrementToken; +}; + +class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(PreDecrementExpression) + + PreDecrementExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return decrementToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation decrementToken; +}; + +class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(UnaryPlusExpression) + + UnaryPlusExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return plusToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation plusToken; +}; + +class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(UnaryMinusExpression) + + UnaryMinusExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return minusToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation minusToken; +}; + +class QML_PARSER_EXPORT TildeExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(TildeExpression) + + TildeExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return tildeToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation tildeToken; +}; + +class QML_PARSER_EXPORT NotExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(NotExpression) + + NotExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return notToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation notToken; +}; + +class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(BinaryExpression) + + BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r): + left (l), op (o), right (r) + { kind = K; } + + BinaryExpression *binaryExpressionCast() override; + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return left->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return right->lastSourceLocation(); } + +// attributes + ExpressionNode *left; + int op; + ExpressionNode *right; + SourceLocation operatorToken; +}; + +class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(ConditionalExpression) + + ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f): + expression (e), ok (t), ko (f) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return expression->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return ko->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + ExpressionNode *ok; + ExpressionNode *ko; + SourceLocation questionToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename +{ +public: + QQMLJS_DECLARE_AST_NODE(Expression) + + Expression(ExpressionNode *l, ExpressionNode *r): + left (l), right (r) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return left->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return right->lastSourceLocation(); } + +// attributes + ExpressionNode *left; + ExpressionNode *right; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT Block: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(Block) + + Block(StatementList *slist): + statements (slist) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lbraceToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + + // attributes + StatementList *statements; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT StatementList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(StatementList) + + // ### This should be a Statement, but FunctionDeclaration currently doesn't inherit it. + StatementList(Node *stmt) + : statement(stmt), next (this) + { kind = K; } + + StatementList *append(StatementList *n) { + n->next = next; + next = n; + return n; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return statement->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + return lastListElement(this)->statement->lastSourceLocation(); + } + + inline StatementList *finish () + { + StatementList *front = next; + next = nullptr; + return front; + } + +// attributes + Node *statement = nullptr; + StatementList *next; +}; + +class QML_PARSER_EXPORT VariableDeclarationList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(VariableDeclarationList) + + VariableDeclarationList(PatternElement *decl) + : declaration(decl), next(this) + { kind = K; } + + VariableDeclarationList(VariableDeclarationList *previous, PatternElement *decl) + : declaration(decl) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return declaration->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + if (next) + return next->lastSourceLocation(); + return declaration->lastSourceLocation(); + } + + inline VariableDeclarationList *finish(VariableScope s) + { + VariableDeclarationList *front = next; + next = nullptr; + VariableDeclarationList *vdl; + for (vdl = front; vdl != nullptr; vdl = vdl->next) { + vdl->declaration->scope = s; + } + return front; + } + +// attributes + PatternElement *declaration; + VariableDeclarationList *next; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT VariableStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(VariableStatement) + + VariableStatement(VariableDeclarationList *vlist): + declarations (vlist) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return declarationKindToken; } + + SourceLocation lastSourceLocation() const override + { return declarations->lastSourceLocation(); } + +// attributes + VariableDeclarationList *declarations; + SourceLocation declarationKindToken; +}; + +class QML_PARSER_EXPORT EmptyStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(EmptyStatement) + + EmptyStatement() { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return semicolonToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT ExpressionStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ExpressionStatement) + + ExpressionStatement(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return expression->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + ExpressionNode *expression; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT IfStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(IfStatement) + + IfStatement(ExpressionNode *e, Statement *t, Statement *f = nullptr): + expression (e), ok (t), ko (f) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return ifToken; } + + SourceLocation lastSourceLocation() const override + { + if (ko) + return ko->lastSourceLocation(); + + return ok->lastSourceLocation(); + } + +// attributes + ExpressionNode *expression; + Statement *ok; + Statement *ko; + SourceLocation ifToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation elseToken; +}; + +class QML_PARSER_EXPORT DoWhileStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(DoWhileStatement) + + DoWhileStatement(Statement *stmt, ExpressionNode *e): + statement (stmt), expression (e) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return doToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + Statement *statement; + ExpressionNode *expression; + SourceLocation doToken; + SourceLocation whileToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT WhileStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(WhileStatement) + + WhileStatement(ExpressionNode *e, Statement *stmt): + expression (e), statement (stmt) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return whileToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + Statement *statement; + SourceLocation whileToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ForStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ForStatement) + + ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt): + initialiser (i), condition (c), expression (e), statement (stmt) + { kind = K; } + + ForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt): + declarations (vlist), condition (c), expression (e), statement (stmt) + { kind = K; } + + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return forToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *initialiser = nullptr; + VariableDeclarationList *declarations = nullptr; + ExpressionNode *condition; + ExpressionNode *expression; + Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation firstSemicolonToken; + SourceLocation secondSemicolonToken; + SourceLocation rparenToken; +}; + +enum class ForEachType { + In, + Of +}; + +class QML_PARSER_EXPORT ForEachStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ForEachStatement) + + ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt) + : lhs(i), expression(e), statement(stmt) + { kind = K; } + ForEachStatement(PatternElement *v, ExpressionNode *e, Statement *stmt) + : lhs(v), expression(e), statement(stmt) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return forToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + + PatternElement *declaration() const { + return AST::cast<PatternElement *>(lhs); + } + +// attributes + Node *lhs; + ExpressionNode *expression; + Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation inOfToken; + SourceLocation rparenToken; + ForEachType type; +}; + +class QML_PARSER_EXPORT ContinueStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ContinueStatement) + + ContinueStatement(QStringView l = QStringView()): + label (l) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return continueToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + QStringView label; + SourceLocation continueToken; + SourceLocation identifierToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT BreakStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(BreakStatement) + + BreakStatement(QStringView l): + label (l) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return breakToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + + // attributes + QStringView label; + SourceLocation breakToken; + SourceLocation identifierToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT ReturnStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ReturnStatement) + + ReturnStatement(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return returnToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + ExpressionNode *expression; + SourceLocation returnToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT YieldExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(YieldExpression) + + YieldExpression(ExpressionNode *e = nullptr): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return yieldToken; } + + SourceLocation lastSourceLocation() const override + { return expression ? expression->lastSourceLocation() : yieldToken; } + +// attributes + ExpressionNode *expression; + bool isYieldStar = false; + SourceLocation yieldToken; +}; + +class QML_PARSER_EXPORT WithStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(WithStatement) + + WithStatement(ExpressionNode *e, Statement *stmt): + expression (e), statement (stmt) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return withToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + Statement *statement; + SourceLocation withToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT CaseBlock: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(CaseBlock) + + CaseBlock(CaseClauses *c, DefaultClause *d = nullptr, CaseClauses *r = nullptr): + clauses (c), defaultClause (d), moreClauses (r) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lbraceToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + +// attributes + CaseClauses *clauses; + DefaultClause *defaultClause; + CaseClauses *moreClauses; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT SwitchStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(SwitchStatement) + + SwitchStatement(ExpressionNode *e, CaseBlock *b): + expression (e), block (b) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return switchToken; } + + SourceLocation lastSourceLocation() const override + { return block->rbraceToken; } + +// attributes + ExpressionNode *expression; + CaseBlock *block; + SourceLocation switchToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT CaseClause: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(CaseClause) + + CaseClause(ExpressionNode *e, StatementList *slist): + expression (e), statements (slist) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return caseToken; } + + SourceLocation lastSourceLocation() const override + { return statements ? statements->lastSourceLocation() : colonToken; } + +// attributes + ExpressionNode *expression; + StatementList *statements; + SourceLocation caseToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT CaseClauses: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(CaseClauses) + + CaseClauses(CaseClause *c): + clause (c), next (this) + { kind = K; } + + CaseClauses(CaseClauses *previous, CaseClause *c): + clause (c) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return clause->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + return lastListElement(this)->clause->lastSourceLocation(); + } + + inline CaseClauses *finish () + { + CaseClauses *front = next; + next = nullptr; + return front; + } + +//attributes + CaseClause *clause; + CaseClauses *next; +}; + +class QML_PARSER_EXPORT DefaultClause: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(DefaultClause) + + DefaultClause(StatementList *slist): + statements (slist) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return defaultToken; } + + SourceLocation lastSourceLocation() const override + { return statements ? statements->lastSourceLocation() : colonToken; } + +// attributes + StatementList *statements; + SourceLocation defaultToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT LabelledStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(LabelledStatement) + + LabelledStatement(QStringView l, Statement *stmt): + label (l), statement (stmt) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return identifierToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + QStringView label; + Statement *statement; + SourceLocation identifierToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT ThrowStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ThrowStatement) + + ThrowStatement(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return throwToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + + // attributes + ExpressionNode *expression; + SourceLocation throwToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT Catch: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(Catch) + + Catch(PatternElement *p, Block *stmt) + : patternElement(p), statement(stmt) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return catchToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + PatternElement *patternElement; + Block *statement; + SourceLocation catchToken; + SourceLocation lparenToken; + SourceLocation identifierToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT Finally: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(Finally) + + Finally(Block *stmt): + statement (stmt) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return finallyToken; } + + SourceLocation lastSourceLocation() const override + { return statement ? statement->lastSourceLocation() : finallyToken; } + +// attributes + Block *statement; + SourceLocation finallyToken; +}; + +class QML_PARSER_EXPORT TryStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(TryStatement) + + TryStatement(Statement *stmt, Catch *c, Finally *f): + statement (stmt), catchExpression (c), finallyExpression (f) + { kind = K; } + + TryStatement(Statement *stmt, Finally *f): + statement (stmt), catchExpression (nullptr), finallyExpression (f) + { kind = K; } + + TryStatement(Statement *stmt, Catch *c): + statement (stmt), catchExpression (c), finallyExpression (nullptr) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return tryToken; } + + SourceLocation lastSourceLocation() const override + { + if (finallyExpression) + return finallyExpression->statement->rbraceToken; + else if (catchExpression) + return catchExpression->statement->rbraceToken; + + return statement->lastSourceLocation(); + } + +// attributes + Statement *statement; + Catch *catchExpression; + Finally *finallyExpression; + SourceLocation tryToken; +}; + +class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(FunctionExpression) + + FunctionExpression(QStringView n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr): + name (n), formals (f), body (b), + typeAnnotation(typeAnnotation) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return functionToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + + FunctionExpression *asFunctionDefinition() override; + +// attributes + QStringView name; + bool isArrowFunction = false; + bool isGenerator = false; + FormalParameterList *formals; + StatementList *body; + TypeAnnotation *typeAnnotation; + SourceLocation functionToken; + // for generators: + SourceLocation starToken; + SourceLocation identifierToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(FunctionDeclaration) + + FunctionDeclaration(QStringView n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr): + FunctionExpression(n, f, b, typeAnnotation) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; +}; + +class QML_PARSER_EXPORT FormalParameterList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(FormalParameterList) + + FormalParameterList(FormalParameterList *previous, PatternElement *e) + : element(e) + { + kind = K; + if (previous) { + next = previous->next; + previous->next = this; + } else { + next = this; + } + } + + FormalParameterList *append(FormalParameterList *n) { + n->next = next; + next = n; + return n; + } + + bool isSimpleParameterList() + { + AST::FormalParameterList *formals = this; + while (formals) { + PatternElement *e = formals->element; + if (e && e->type == PatternElement::RestElement) + return false; + if (e && (e->initializer || e->bindingTarget)) + return false; + formals = formals->next; + } + return true; + } + + int length() + { + // the length property of Function objects + int l = 0; + AST::FormalParameterList *formals = this; + while (formals) { + PatternElement *e = formals->element; + if (!e || e->initializer) + break; + if (e->type == PatternElement::RestElement) + break; + ++l; + formals = formals->next; + } + return l; + } + + bool containsName(const QString &name) const { + for (const FormalParameterList *it = this; it; it = it->next) { + PatternElement *b = it->element; + // ### handle binding patterns + if (b && b->bindingIdentifier == name) + return true; + } + return false; + } + + BoundNames formals() const; + + BoundNames boundNames() const; + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return element->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + return lastListElement(this)->element->lastSourceLocation(); + } + + FormalParameterList *finish(MemoryPool *pool); + +// attributes + PatternElement *element = nullptr; + FormalParameterList *next; +}; + +class QML_PARSER_EXPORT ClassExpression : public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(ClassExpression) + + ClassExpression(QStringView n, ExpressionNode *heritage, ClassElementList *elements) + : name(n), heritage(heritage), elements(elements) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return classToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + + ClassExpression *asClassDefinition() override; + +// attributes + QStringView name; + ExpressionNode *heritage; + ClassElementList *elements; + SourceLocation classToken; + SourceLocation identifierToken; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT ClassDeclaration: public ClassExpression +{ +public: + QQMLJS_DECLARE_AST_NODE(ClassDeclaration) + + ClassDeclaration(QStringView n, ExpressionNode *heritage, ClassElementList *elements) + : ClassExpression(n, heritage, elements) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; +}; + + +class QML_PARSER_EXPORT ClassElementList : public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ClassElementList) + + ClassElementList(PatternProperty *property, bool isStatic) + : isStatic(isStatic), property(property) + { + kind = K; + next = this; + } + + ClassElementList *append(ClassElementList *n) { + n->next = next; + next = n; + return n; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return property->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + if (next) + return next->lastSourceLocation(); + return property->lastSourceLocation(); + } + + ClassElementList *finish(); + + bool isStatic; + ClassElementList *next; + PatternProperty *property; +}; + +class QML_PARSER_EXPORT Program: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(Program) + + Program(StatementList *statements) + : statements(statements) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return statements ? statements->firstSourceLocation() : SourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return statements ? statements->lastSourceLocation() : SourceLocation(); } + +// attributes + StatementList *statements; +}; + +class QML_PARSER_EXPORT ImportSpecifier: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ImportSpecifier) + + ImportSpecifier(QStringView importedBinding) + : importedBinding(importedBinding) + { + kind = K; + } + + ImportSpecifier(QStringView identifier, QStringView importedBinding) + : identifier(identifier), importedBinding(importedBinding) + { + kind = K; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return identifier.isNull() ? importedBindingToken : identifierToken; } + SourceLocation lastSourceLocation() const override + { return importedBindingToken; } + +// attributes + SourceLocation identifierToken; + SourceLocation importedBindingToken; + QStringView identifier; + QStringView importedBinding; +}; + +class QML_PARSER_EXPORT ImportsList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ImportsList) + + ImportsList(ImportSpecifier *importSpecifier) + : importSpecifier(importSpecifier) + { + kind = K; + next = this; + } + + ImportsList(ImportsList *previous, ImportSpecifier *importSpecifier) + : importSpecifier(importSpecifier) + { + kind = K; + if (previous) { + next = previous->next; + previous->next = this; + } else { + next = this; + } + } + + ImportsList *finish() + { + ImportsList *head = next; + next = nullptr; + return head; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return importSpecifierToken; } + + SourceLocation lastSourceLocation() const override + { + return lastListElement(this)->importSpecifierToken; + } + +// attributes + SourceLocation importSpecifierToken; + ImportSpecifier *importSpecifier; + ImportsList *next = this; +}; + +class QML_PARSER_EXPORT NamedImports: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(NamedImports) + + NamedImports() + { + kind = K; + } + + NamedImports(ImportsList *importsList) + : importsList(importsList) + { + kind = K; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return leftBraceToken; } + SourceLocation lastSourceLocation() const override + { return rightBraceToken; } + +// attributes + SourceLocation leftBraceToken; + SourceLocation rightBraceToken; + ImportsList *importsList = nullptr; +}; + +class QML_PARSER_EXPORT NameSpaceImport: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(NameSpaceImport) + + NameSpaceImport(QStringView importedBinding) + : importedBinding(importedBinding) + { + kind = K; + } + + void accept0(BaseVisitor *visitor) override; + + virtual SourceLocation firstSourceLocation() const override + { return starToken; } + virtual SourceLocation lastSourceLocation() const override + { return importedBindingToken; } + +// attributes + SourceLocation starToken; + SourceLocation importedBindingToken; + QStringView importedBinding; +}; + +class QML_PARSER_EXPORT ImportClause: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ImportClause) + + ImportClause(QStringView importedDefaultBinding) + : importedDefaultBinding(importedDefaultBinding) + { + kind = K; + } + + ImportClause(NameSpaceImport *nameSpaceImport) + : nameSpaceImport(nameSpaceImport) + { + kind = K; + } + + ImportClause(NamedImports *namedImports) + : namedImports(namedImports) + { + kind = K; + } + + ImportClause(QStringView importedDefaultBinding, NameSpaceImport *nameSpaceImport) + : importedDefaultBinding(importedDefaultBinding) + , nameSpaceImport(nameSpaceImport) + { + kind = K; + } + + ImportClause(QStringView importedDefaultBinding, NamedImports *namedImports) + : importedDefaultBinding(importedDefaultBinding) + , namedImports(namedImports) + { + kind = K; + } + + void accept0(BaseVisitor *visitor) override; + + virtual SourceLocation firstSourceLocation() const override + { return importedDefaultBinding.isNull() ? (nameSpaceImport ? nameSpaceImport->firstSourceLocation() : namedImports->firstSourceLocation()) : importedDefaultBindingToken; } + virtual SourceLocation lastSourceLocation() const override + { return importedDefaultBinding.isNull() ? (nameSpaceImport ? nameSpaceImport->lastSourceLocation() : namedImports->lastSourceLocation()) : importedDefaultBindingToken; } + +// attributes + SourceLocation importedDefaultBindingToken; + QStringView importedDefaultBinding; + NameSpaceImport *nameSpaceImport = nullptr; + NamedImports *namedImports = nullptr; +}; + +class QML_PARSER_EXPORT FromClause: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(FromClause) + + FromClause(QStringView moduleSpecifier) + : moduleSpecifier(moduleSpecifier) + { + kind = K; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return fromToken; } + + SourceLocation lastSourceLocation() const override + { return moduleSpecifierToken; } + +// attributes + SourceLocation fromToken; + SourceLocation moduleSpecifierToken; + QStringView moduleSpecifier; +}; + +class QML_PARSER_EXPORT ImportDeclaration: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ImportDeclaration) + + ImportDeclaration(ImportClause *importClause, FromClause *fromClause) + : importClause(importClause), fromClause(fromClause) + { + kind = K; + } + + ImportDeclaration(QStringView moduleSpecifier) + : moduleSpecifier(moduleSpecifier) + { + kind = K; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return importToken; } + + SourceLocation lastSourceLocation() const override + { return moduleSpecifier.isNull() ? fromClause->lastSourceLocation() : moduleSpecifierToken; } + +// attributes + SourceLocation importToken; + SourceLocation moduleSpecifierToken; + QStringView moduleSpecifier; + ImportClause *importClause = nullptr; + FromClause *fromClause = nullptr; +}; + +class QML_PARSER_EXPORT ExportSpecifier: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ExportSpecifier) + + ExportSpecifier(QStringView identifier) + : identifier(identifier), exportedIdentifier(identifier) + { + kind = K; + } + + ExportSpecifier(QStringView identifier, QStringView exportedIdentifier) + : identifier(identifier), exportedIdentifier(exportedIdentifier) + { + kind = K; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return identifierToken; } + SourceLocation lastSourceLocation() const override + { return exportedIdentifierToken.isValid() ? exportedIdentifierToken : identifierToken; } + +// attributes + SourceLocation identifierToken; + SourceLocation exportedIdentifierToken; + QStringView identifier; + QStringView exportedIdentifier; +}; + +class QML_PARSER_EXPORT ExportsList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ExportsList) + + ExportsList(ExportSpecifier *exportSpecifier) + : exportSpecifier(exportSpecifier) + { + kind = K; + next = this; + } + + ExportsList(ExportsList *previous, ExportSpecifier *exportSpecifier) + : exportSpecifier(exportSpecifier) + { + kind = K; + if (previous) { + next = previous->next; + previous->next = this; + } else { + next = this; + } + } + + ExportsList *finish() + { + ExportsList *head = next; + next = nullptr; + return head; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return exportSpecifier->firstSourceLocation(); } + SourceLocation lastSourceLocation() const override + { return lastListElement(this)->exportSpecifier->lastSourceLocation(); } + +// attributes + ExportSpecifier *exportSpecifier; + ExportsList *next; +}; + +class QML_PARSER_EXPORT ExportClause: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ExportClause) + + ExportClause() + { + kind = K; + } + + ExportClause(ExportsList *exportsList) + : exportsList(exportsList) + { + kind = K; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return leftBraceToken; } + SourceLocation lastSourceLocation() const override + { return rightBraceToken; } + +// attributes + SourceLocation leftBraceToken; + SourceLocation rightBraceToken; + ExportsList *exportsList = nullptr; +}; + +class QML_PARSER_EXPORT ExportDeclaration: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(ExportDeclaration) + + ExportDeclaration(FromClause *fromClause) + : fromClause(fromClause) + { + kind = K; + } + + ExportDeclaration(ExportClause *exportClause, FromClause *fromClause) + : exportClause(exportClause), fromClause(fromClause) + { + kind = K; + } + + ExportDeclaration(ExportClause *exportClause) + : exportClause(exportClause) + { + kind = K; + } + + ExportDeclaration(bool exportDefault, Node *variableStatementOrDeclaration) + : variableStatementOrDeclaration(variableStatementOrDeclaration) + , exportDefault(exportDefault) + { + kind = K; + } + + bool exportsAll() const + { + return fromClause && !exportClause; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return exportToken; } + SourceLocation lastSourceLocation() const override + { return fromClause ? fromClause->lastSourceLocation() : (exportClause ? exportClause->lastSourceLocation() : variableStatementOrDeclaration->lastSourceLocation()); } + +// attributes + SourceLocation exportToken; + ExportClause *exportClause = nullptr; + FromClause *fromClause = nullptr; + Node *variableStatementOrDeclaration = nullptr; + bool exportDefault = false; +}; + +class QML_PARSER_EXPORT ESModule: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(Module) + + ESModule(StatementList *body) + : body(body) + { + kind = K; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return body ? body->firstSourceLocation() : SourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return body ? body->lastSourceLocation() : SourceLocation(); } + +// attributes + StatementList *body; +}; + +class QML_PARSER_EXPORT DebuggerStatement: public Statement +{ +public: + QQMLJS_DECLARE_AST_NODE(DebuggerStatement) + + DebuggerStatement() + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return debuggerToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + SourceLocation debuggerToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT UiImport: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiImport) + + UiImport(QStringView fileName) + : fileName(fileName), importUri(nullptr) + { kind = K; } + + UiImport(UiQualifiedId *uri) + : importUri(uri) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return importToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + QStringView fileName; + UiQualifiedId *importUri; + QStringView importId; + SourceLocation importToken; + SourceLocation fileNameToken; + SourceLocation asToken; + SourceLocation importIdToken; + SourceLocation semicolonToken; + UiVersionSpecifier *version = nullptr; +}; + +class QML_PARSER_EXPORT UiObjectMember: public Node +{ +public: + SourceLocation firstSourceLocation() const override = 0; + SourceLocation lastSourceLocation() const override = 0; + + UiObjectMember *uiObjectMemberCast() override; + +// attributes + UiAnnotationList *annotations = nullptr; +}; + +class QML_PARSER_EXPORT UiObjectMemberList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiObjectMemberList) + + UiObjectMemberList(UiObjectMember *member) + : next(this), member(member) + { kind = K; } + + UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member) + : member(member) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return member->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return lastListElement(this)->member->lastSourceLocation(); } + + UiObjectMemberList *finish() + { + UiObjectMemberList *head = next; + next = nullptr; + return head; + } + +// attributes + UiObjectMemberList *next; + UiObjectMember *member; +}; + +class QML_PARSER_EXPORT UiPragmaValueList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiPragmaValueList) + + UiPragmaValueList(QStringView value) + : value(value) + , next(this) + { + kind = K; + } + + UiPragmaValueList(UiPragmaValueList *previous, QStringView value) + : value(value) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return location; } + + SourceLocation lastSourceLocation() const override + { return lastListElement(this)->location; } + + UiPragmaValueList *finish() + { + UiPragmaValueList *head = next; + next = nullptr; + return head; + } + + QStringView value; + UiPragmaValueList *next; + SourceLocation location; +}; + +class QML_PARSER_EXPORT UiPragma: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiPragma) + + UiPragma(QStringView name, UiPragmaValueList *values = nullptr) + : name(name), values(values) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return pragmaToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + QStringView name; + UiPragmaValueList *values; + SourceLocation pragmaToken; + SourceLocation pragmaIdToken; + SourceLocation colonToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT UiRequired: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiRequired) + + UiRequired(QStringView name) + :name(name) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return requiredToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + + QStringView name; + SourceLocation requiredToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT UiHeaderItemList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiHeaderItemList) + + UiHeaderItemList(UiImport *import) + : headerItem(import), next(this) + { kind = K; } + + UiHeaderItemList(UiPragma *pragma) + : headerItem(pragma), next(this) + { kind = K; } + + UiHeaderItemList(UiHeaderItemList *previous, UiImport *import) + : headerItem(import) + { + kind = K; + next = previous->next; + previous->next = this; + } + + UiHeaderItemList(UiHeaderItemList *previous, UiPragma *pragma) + : headerItem(pragma) + { + kind = K; + next = previous->next; + previous->next = this; + } + + UiHeaderItemList *finish() + { + UiHeaderItemList *head = next; + next = nullptr; + return head; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return headerItem->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return lastListElement(this)->headerItem->lastSourceLocation(); } + +// attributes + Node *headerItem; + UiHeaderItemList *next; +}; + +class QML_PARSER_EXPORT UiProgram: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiProgram) + + UiProgram(UiHeaderItemList *headers, UiObjectMemberList *members) + : headers(headers), members(members) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { + if (headers) + return headers->firstSourceLocation(); + else if (members) + return members->firstSourceLocation(); + return SourceLocation(); + } + + SourceLocation lastSourceLocation() const override + { + if (members) + return members->lastSourceLocation(); + else if (headers) + return headers->lastSourceLocation(); + return SourceLocation(); + } + +// attributes + UiHeaderItemList *headers; + UiObjectMemberList *members; +}; + +class QML_PARSER_EXPORT UiArrayMemberList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiArrayMemberList) + + UiArrayMemberList(UiObjectMember *member) + : next(this), member(member) + { kind = K; } + + UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member) + : member(member) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return member->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return lastListElement(this)->member->lastSourceLocation(); } + + UiArrayMemberList *finish() + { + UiArrayMemberList *head = next; + next = nullptr; + return head; + } + +// attributes + UiArrayMemberList *next; + UiObjectMember *member; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT UiObjectInitializer: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiObjectInitializer) + + UiObjectInitializer(UiObjectMemberList *members) + : members(members) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lbraceToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + +// attributes + SourceLocation lbraceToken; + UiObjectMemberList *members; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT UiParameterList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiParameterList) + + UiParameterList(Type *t, QStringView n): + type (t), name (n), next (this) + { kind = K; } + + UiParameterList(UiParameterList *previous, Type *t, QStringView n): + type (t), name (n) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(BaseVisitor *) override; + + SourceLocation firstSourceLocation() const override + { return colonToken.isValid() ? identifierToken : propertyTypeToken; } + + SourceLocation lastSourceLocation() const override + { + auto last = lastListElement(this); + return last->lastOwnSourceLocation(); + } + + SourceLocation lastOwnSourceLocation() const + { + return (colonToken.isValid() ? propertyTypeToken : identifierToken); + } + + inline UiParameterList *finish () + { + UiParameterList *front = next; + next = nullptr; + return front; + } + +// attributes + Type *type; + QStringView name; + UiParameterList *next; + SourceLocation commaToken; + SourceLocation propertyTypeToken; + SourceLocation identifierToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT UiPropertyAttributes : public Node +{ + QQMLJS_DECLARE_AST_NODE(UiPropertyAttributes) +public: + UiPropertyAttributes() { kind = K; } + + SourceLocation defaultToken() const { return m_defaultToken; } + bool isDefaultMember() const { return defaultToken().isValid(); } + SourceLocation requiredToken() const { return m_requiredToken; } + bool isRequired() const { return requiredToken().isValid(); } + SourceLocation readonlyToken() const { return m_readonlyToken; } + bool isReadonly() const { return readonlyToken().isValid(); } + + SourceLocation propertyToken() const { return m_propertyToken; } + + template <bool InvalidIsLargest = true> + static bool compareLocationsByBegin(const SourceLocation *& lhs, const SourceLocation *& rhs) + { + if (lhs->isValid() && rhs->isValid()) + return lhs->begin() < rhs->begin(); + else if (lhs->isValid()) + return InvalidIsLargest; + else + return !InvalidIsLargest; + } + + void accept0(BaseVisitor *) override {} // intentionally do nothing + + SourceLocation firstSourceLocation() const override; + + SourceLocation lastSourceLocation() const override; + +private: + friend class QQmlJS::Parser; + SourceLocation m_defaultToken; + SourceLocation m_readonlyToken; + SourceLocation m_requiredToken; + SourceLocation m_propertyToken; +}; + +class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiPublicMember) + + UiPublicMember(UiQualifiedId *memberType, + QStringView name) + : type(Property), memberType(memberType), name(name), statement(nullptr), binding(nullptr), parameters(nullptr) + { kind = K; } + + UiPublicMember(UiQualifiedId *memberType, + QStringView name, + Statement *statement) + : type(Property), memberType(memberType), name(name), statement(statement), binding(nullptr), parameters(nullptr) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { + if (hasAttributes) + return m_attributes->firstSourceLocation(); + else + return m_propertyToken; + } + + SourceLocation lastSourceLocation() const override + { + if (binding) + return binding->lastSourceLocation(); + if (statement) + return statement->lastSourceLocation(); + + return semicolonToken; + } + + SourceLocation defaultToken() const + { + return hasAttributes ? m_attributes->defaultToken() : SourceLocation {}; + } + bool isDefaultMember() const { return defaultToken().isValid(); } + + SourceLocation requiredToken() const + { + return hasAttributes ? m_attributes->requiredToken() : SourceLocation {}; + } + bool isRequired() const { return requiredToken().isValid(); } + + SourceLocation readonlyToken() const + { + return hasAttributes ? m_attributes->readonlyToken() : SourceLocation {}; + } + bool isReadonly() const { return readonlyToken().isValid(); } + + void setAttributes(UiPropertyAttributes *attributes) + { + m_attributes = attributes; + hasAttributes = true; + } + + SourceLocation propertyToken() const + { + return hasAttributes ? m_attributes->propertyToken() : m_propertyToken; + } + + void setPropertyToken(SourceLocation token) + { + m_propertyToken = token; + hasAttributes = false; + } + +// attributes + enum : bool { Signal, Property } type; + bool hasAttributes = false; + QStringView typeModifier; + UiQualifiedId *memberType; + QStringView name; + Statement *statement; // initialized with a JS expression + UiObjectMember *binding; // initialized with a QML object or array. + UiParameterList *parameters; + // TODO: merge source locations + SourceLocation typeModifierToken; + SourceLocation typeToken; + SourceLocation identifierToken; + SourceLocation colonToken; + SourceLocation semicolonToken; +private: + union { + SourceLocation m_propertyToken = SourceLocation {}; + UiPropertyAttributes *m_attributes; + }; +}; + +class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiObjectDefinition) + + UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId, + UiObjectInitializer *initializer) + : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return qualifiedTypeNameId->identifierToken; } + + SourceLocation lastSourceLocation() const override + { return initializer->rbraceToken; } + +// attributes + UiQualifiedId *qualifiedTypeNameId; + UiObjectInitializer *initializer; +}; + +class QML_PARSER_EXPORT UiInlineComponent: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiInlineComponent) + + UiInlineComponent(QStringView inlineComponentName, UiObjectDefinition* inlineComponent) + : name(inlineComponentName), component(inlineComponent) + { kind = K; } + + SourceLocation lastSourceLocation() const override + {return component->lastSourceLocation();} + + SourceLocation firstSourceLocation() const override + {return componentToken;} + + void accept0(BaseVisitor *visitor) override; + + // attributes + QStringView name; + UiObjectDefinition* component; + SourceLocation componentToken; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiSourceElement) + + UiSourceElement(Node *sourceElement) + : sourceElement(sourceElement) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { + if (FunctionExpression *funDecl = sourceElement->asFunctionDefinition()) + return funDecl->firstSourceLocation(); + else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement)) + return varStmt->firstSourceLocation(); + + return SourceLocation(); + } + + SourceLocation lastSourceLocation() const override + { + if (FunctionExpression *funDecl = sourceElement->asFunctionDefinition()) + return funDecl->lastSourceLocation(); + else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement)) + return varStmt->lastSourceLocation(); + + return SourceLocation(); + } + + void accept0(BaseVisitor *visitor) override; + + +// attributes + Node *sourceElement; +}; + +class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiObjectBinding) + + UiObjectBinding(UiQualifiedId *qualifiedId, + UiQualifiedId *qualifiedTypeNameId, + UiObjectInitializer *initializer) + : qualifiedId(qualifiedId), + qualifiedTypeNameId(qualifiedTypeNameId), + initializer(initializer), + hasOnToken(false) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { + if (hasOnToken && qualifiedTypeNameId) + return qualifiedTypeNameId->identifierToken; + + return qualifiedId->identifierToken; + } + + SourceLocation lastSourceLocation() const override + { return initializer->rbraceToken; } + + void accept0(BaseVisitor *visitor) override; + + +// attributes + UiQualifiedId *qualifiedId; + UiQualifiedId *qualifiedTypeNameId; + UiObjectInitializer *initializer; + SourceLocation colonToken; + bool hasOnToken; +}; + +class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiScriptBinding) + + UiScriptBinding(UiQualifiedId *qualifiedId, + Statement *statement) + : qualifiedId(qualifiedId), + statement(statement) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { return qualifiedId->identifierToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + + void accept0(BaseVisitor *visitor) override; + +// attributes + UiQualifiedId *qualifiedId; + Statement *statement; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiArrayBinding) + + UiArrayBinding(UiQualifiedId *qualifiedId, + UiArrayMemberList *members) + : qualifiedId(qualifiedId), + members(members) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { Q_ASSERT(qualifiedId); return qualifiedId->identifierToken; } + + SourceLocation lastSourceLocation() const override + { return rbracketToken; } + + void accept0(BaseVisitor *visitor) override; + +// attributes + UiQualifiedId *qualifiedId; + UiArrayMemberList *members; + SourceLocation colonToken; + SourceLocation lbracketToken; + SourceLocation rbracketToken; +}; + +class QML_PARSER_EXPORT UiEnumMemberList: public Node +{ + QQMLJS_DECLARE_AST_NODE(UiEnumMemberList) +public: + UiEnumMemberList(QStringView member, double v = 0.0) + : next(this), member(member), value(v) + { kind = K; } + + UiEnumMemberList(UiEnumMemberList *previous, QStringView member) + : member(member) + { + kind = K; + next = previous->next; + previous->next = this; + value = previous->value + 1; + } + + UiEnumMemberList(UiEnumMemberList *previous, QStringView member, double v) + : member(member), value(v) + { + kind = K; + next = previous->next; + previous->next = this; + } + + SourceLocation firstSourceLocation() const override + { return memberToken; } + + SourceLocation lastSourceLocation() const override + { + auto last = lastListElement(this); + return last->valueToken.isValid() ? last->valueToken : last->memberToken; + } + + void accept0(BaseVisitor *visitor) override; + + UiEnumMemberList *finish() + { + UiEnumMemberList *head = next; + next = nullptr; + return head; + } + +// attributes + UiEnumMemberList *next; + QStringView member; + double value; + SourceLocation memberToken; + SourceLocation valueToken; +}; + +class QML_PARSER_EXPORT UiEnumDeclaration: public UiObjectMember +{ +public: + QQMLJS_DECLARE_AST_NODE(UiEnumDeclaration) + + UiEnumDeclaration(QStringView name, + UiEnumMemberList *members) + : name(name) + , members(members) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { return enumToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + + void accept0(BaseVisitor *visitor) override; + +// attributes + SourceLocation enumToken; + SourceLocation identifierToken; + SourceLocation lbraceToken; + SourceLocation rbraceToken; + QStringView name; + UiEnumMemberList *members; +}; + +class QML_PARSER_EXPORT UiAnnotation: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiAnnotation) + + UiAnnotation(UiQualifiedId *qualifiedTypeNameId, + UiObjectInitializer *initializer) + : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer) + { kind = K; } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return qualifiedTypeNameId->identifierToken; } + + SourceLocation lastSourceLocation() const override + { return initializer->rbraceToken; } + +// attributes + UiQualifiedId *qualifiedTypeNameId; + UiObjectInitializer *initializer; +}; + +class QML_PARSER_EXPORT UiAnnotationList: public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(UiAnnotationList) + + UiAnnotationList(UiAnnotation *annotation) + : next(this), annotation(annotation) + { kind = K; } + + UiAnnotationList(UiAnnotationList *previous, UiAnnotation *annotation) + : annotation(annotation) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(BaseVisitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return annotation->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return lastListElement(this)->annotation->lastSourceLocation(); } + + UiAnnotationList *finish() + { + UiAnnotationList *head = next; + next = nullptr; + return head; + } + +// attributes + UiAnnotationList *next; + UiAnnotation *annotation; +}; + +} } // namespace AST + + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsastfwd_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsastfwd_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8b842aaf9683edd2f583a38bd882ffa36330ff54 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsastfwd_p.h @@ -0,0 +1,159 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJSAST_FWD_P_H +#define QQMLJSAST_FWD_P_H + +#include <private/qqmljssourcelocation_p.h> + +#include <QtCore/qglobal.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { namespace AST { + +class BaseVisitor; +class Visitor; +class Node; +class ExpressionNode; +class Statement; +class TypeExpression; +class ThisExpression; +class IdentifierExpression; +class NullExpression; +class TrueLiteral; +class FalseLiteral; +class SuperLiteral; +class NumericLiteral; +class StringLiteral; +class TemplateLiteral; +class RegExpLiteral; +class Pattern; +class ArrayPattern; +class ObjectPattern; +class PatternElement; +class PatternElementList; +class PatternProperty; +class PatternPropertyList; +class Elision; +class PropertyName; +class IdentifierPropertyName; +class StringLiteralPropertyName; +class NumericLiteralPropertyName; +class ComputedPropertyName; +class ArrayMemberExpression; +class FieldMemberExpression; +class TaggedTemplate; +class NewMemberExpression; +class NewExpression; +class CallExpression; +class ArgumentList; +class PostIncrementExpression; +class PostDecrementExpression; +class DeleteExpression; +class VoidExpression; +class TypeOfExpression; +class PreIncrementExpression; +class PreDecrementExpression; +class UnaryPlusExpression; +class UnaryMinusExpression; +class TildeExpression; +class NotExpression; +class BinaryExpression; +class ConditionalExpression; +class Expression; // ### rename +class YieldExpression; +class Block; +class LeftHandSideExpression; +class StatementList; +class VariableStatement; +class VariableDeclarationList; +class EmptyStatement; +class ExpressionStatement; +class IfStatement; +class DoWhileStatement; +class WhileStatement; +class ForStatement; +class ForEachStatement; +class ContinueStatement; +class BreakStatement; +class ReturnStatement; +class WithStatement; +class SwitchStatement; +class CaseBlock; +class CaseClauses; +class CaseClause; +class DefaultClause; +class LabelledStatement; +class ThrowStatement; +class TryStatement; +class Catch; +class Finally; +class FunctionDeclaration; +class FunctionExpression; +class FormalParameterList; +class ExportSpecifier; +class ExportsList; +class ExportClause; +class ExportDeclaration; +class Program; +class ImportSpecifier; +class ImportsList; +class NamedImports; +class NameSpaceImport; +class NamedImport; +class ImportClause; +class FromClause; +class ImportDeclaration; +class ESModule; +class DebuggerStatement; +class NestedExpression; +class ClassExpression; +class ClassDeclaration; +class ClassElementList; +class Type; +class TypeAnnotation; + +// ui elements +class UiProgram; +class UiPragmaValueList; +class UiPragma; +class UiImport; +class UiPublicMember; +class UiParameterList; +class UiObjectDefinition; +class UiInlineComponent; +class UiObjectInitializer; +class UiObjectBinding; +class UiScriptBinding; +class UiSourceElement; +class UiArrayBinding; +class UiObjectMember; +class UiObjectMemberList; +class UiArrayMemberList; +class UiQualifiedId; +class UiHeaderItemList; +class UiEnumDeclaration; +class UiEnumMemberList; +class UiVersionSpecifier; +class UiRequired; +class UiAnnotation; +class UiAnnotationList; + +} // namespace AST +} // namespace QQmlJS + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsastvisitor_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsastvisitor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8b6d5d1d3ecc734b0edc1fb3d6404964b3952267 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsastvisitor_p.h @@ -0,0 +1,241 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJSASTVISITOR_P_H +#define QQMLJSASTVISITOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmljsastfwd_p.h" +#include "qqmljsglobal_p.h" + +QT_BEGIN_NAMESPACE + +// as done in https://en.wikipedia.org/wiki/X_Macro + +#define QQmlJSASTUiClassListToVisit \ + X(UiProgram) \ + X(UiHeaderItemList) \ + X(UiPragmaValueList) \ + X(UiPragma) \ + X(UiImport) \ + X(UiPublicMember) \ + X(UiSourceElement) \ + X(UiObjectDefinition) \ + X(UiObjectInitializer) \ + X(UiObjectBinding) \ + X(UiScriptBinding) \ + X(UiArrayBinding) \ + X(UiParameterList) \ + X(UiObjectMemberList) \ + X(UiArrayMemberList) \ + X(UiQualifiedId) \ + X(UiEnumDeclaration) \ + X(UiEnumMemberList) \ + X(UiVersionSpecifier) \ + X(UiInlineComponent) \ + X(UiAnnotation) \ + X(UiAnnotationList) \ + X(UiRequired) + +#define QQmlJSASTQQmlJSClassListToVisit \ + X(TypeExpression) \ + X(ThisExpression) \ + X(IdentifierExpression) \ + X(NullExpression) \ + X(TrueLiteral) \ + X(FalseLiteral) \ + X(SuperLiteral) \ + X(StringLiteral) \ + X(TemplateLiteral) \ + X(NumericLiteral) \ + X(RegExpLiteral) \ + X(ArrayPattern) \ + X(ObjectPattern) \ + X(PatternElementList) \ + X(PatternPropertyList) \ + X(PatternElement) \ + X(PatternProperty) \ + X(Elision) \ + X(NestedExpression) \ + X(IdentifierPropertyName) \ + X(StringLiteralPropertyName) \ + X(NumericLiteralPropertyName) \ + X(ComputedPropertyName) \ + X(ArrayMemberExpression) \ + X(FieldMemberExpression) \ + X(TaggedTemplate) \ + X(NewMemberExpression) \ + X(NewExpression) \ + X(CallExpression) \ + X(ArgumentList) \ + X(PostIncrementExpression) \ + X(PostDecrementExpression) \ + X(DeleteExpression) \ + X(VoidExpression) \ + X(TypeOfExpression) \ + X(PreIncrementExpression) \ + X(PreDecrementExpression) \ + X(UnaryPlusExpression) \ + X(UnaryMinusExpression) \ + X(TildeExpression) \ + X(NotExpression) \ + X(BinaryExpression) \ + X(ConditionalExpression) \ + X(Expression) \ + X(Block) \ + X(StatementList) \ + X(VariableStatement) \ + X(VariableDeclarationList) \ + X(EmptyStatement) \ + X(ExpressionStatement) \ + X(IfStatement) \ + X(DoWhileStatement) \ + X(WhileStatement) \ + X(ForStatement) \ + X(ForEachStatement) \ + X(ContinueStatement) \ + X(BreakStatement) \ + X(ReturnStatement) \ + X(YieldExpression) \ + X(WithStatement) \ + X(SwitchStatement) \ + X(CaseBlock) \ + X(CaseClauses) \ + X(CaseClause) \ + X(DefaultClause) \ + X(LabelledStatement) \ + X(ThrowStatement) \ + X(TryStatement) \ + X(Catch) \ + X(Finally) \ + X(FunctionDeclaration) \ + X(FunctionExpression) \ + X(FormalParameterList) \ + X(ClassExpression) \ + X(ClassDeclaration) \ + X(ClassElementList) \ + X(Program) \ + X(NameSpaceImport) \ + X(ImportSpecifier) \ + X(ImportsList) \ + X(NamedImports) \ + X(FromClause) \ + X(ImportClause) \ + X(ImportDeclaration) \ + X(ExportSpecifier) \ + X(ExportsList) \ + X(ExportClause) \ + X(ExportDeclaration) \ + X(ESModule) \ + X(DebuggerStatement) \ + X(Type) \ + X(TypeAnnotation) + +#define QQmlJSASTClassListToVisit QQmlJSASTUiClassListToVisit QQmlJSASTQQmlJSClassListToVisit + +namespace QQmlJS { namespace AST { + +class QML_PARSER_EXPORT BaseVisitor +{ +public: + class RecursionDepthCheck + { + Q_DISABLE_COPY(RecursionDepthCheck) + public: + RecursionDepthCheck(RecursionDepthCheck &&) = delete; + RecursionDepthCheck &operator=(RecursionDepthCheck &&) = delete; + + RecursionDepthCheck(BaseVisitor *visitor) : m_visitor(visitor) + { + ++(m_visitor->m_recursionDepth); + } + + ~RecursionDepthCheck() + { + --(m_visitor->m_recursionDepth); + } + + bool operator()() const { + return m_visitor->m_recursionDepth < s_recursionLimit; + } + + private: + static const quint16 s_recursionLimit = 4096; + BaseVisitor *m_visitor; + }; + + BaseVisitor(quint16 parentRecursionDepth = 0); + virtual ~BaseVisitor(); + + virtual bool preVisit(Node *) = 0; + virtual void postVisit(Node *) = 0; + +#define X(name) \ + virtual bool visit(name *) = 0; \ + virtual void endVisit(name *) = 0; + QQmlJSASTClassListToVisit +#undef X + + virtual void throwRecursionDepthError() = 0; + + quint16 recursionDepth() const { return m_recursionDepth; } + +protected: + quint16 m_recursionDepth = 0; + friend class RecursionDepthCheck; +}; + +class QML_PARSER_EXPORT Visitor: public BaseVisitor +{ +public: + Visitor(quint16 parentRecursionDepth = 0); + + bool preVisit(Node *) override { return true; } + void postVisit(Node *) override {} + +#define X(name) \ + bool visit(name *) override { return true; } \ + void endVisit(name *) override { } + QQmlJSASTClassListToVisit +#undef X +}; + +class QML_PARSER_EXPORT JSVisitor : public BaseVisitor +{ +public: + JSVisitor() = default; + + bool preVisit(Node *) override { return true; } + void postVisit(Node *) override { } + +#define X(name) \ + bool visit(name *) override { return true; } \ + void endVisit(name *) override { } + QQmlJSASTQQmlJSClassListToVisit +#undef X + +#define X(name) \ + bool visit(name *) override \ + { \ + Q_ASSERT(false); \ + return false; \ + } \ + void endVisit(name *) override { } + QQmlJSASTUiClassListToVisit +#undef X +}; // namespace AST +} } // namespace AST + +QT_END_NAMESPACE + +#endif // QQMLJSASTVISITOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsdiagnosticmessage_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsdiagnosticmessage_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9457dc66f7c47b2ad8db158680ae2adaee4b4c88 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsdiagnosticmessage_p.h @@ -0,0 +1,56 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJSDIAGNOSTICMESSAGE_P_H +#define QQMLJSDIAGNOSTICMESSAGE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qlogging.h> +#include <QtCore/qstring.h> + +// Include the API version here, to avoid complications when querying it for the +// QQmlSourceLocation -> line/column change. + +#include "qqmljssourcelocation_p.h" + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +struct DiagnosticMessage +{ + QString message; + QtMsgType type = QtCriticalMsg; + SourceLocation loc; + + bool isError() const + { + return type == QtCriticalMsg; + } + + bool isWarning() const + { + return type == QtWarningMsg; + } + + bool isValid() const + { + return !message.isEmpty(); + } +}; +} // namespace QQmlJS + +Q_DECLARE_TYPEINFO(QQmlJS::DiagnosticMessage, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + +#endif // QQMLJSDIAGNOSTICMESSAGE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsengine_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsengine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c624b6af93527b5fc065da6afe332a664e0641ef --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsengine_p.h @@ -0,0 +1,110 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJSENGINE_P_H +#define QQMLJSENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmljsglobal_p.h" +#include <private/qqmljssourcelocation_p.h> + +#include <private/qqmljsmemorypool_p.h> + +#include <QtCore/qstring.h> +#include <QtCore/qset.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { + +class Lexer; +class MemoryPool; + +class QML_PARSER_EXPORT Directives { +public: + virtual ~Directives() {} + + virtual void pragmaLibrary() + { + } + + virtual void importFile(const QString &jsfile, const QString &module, int line, int column) + { + Q_UNUSED(jsfile); + Q_UNUSED(module); + Q_UNUSED(line); + Q_UNUSED(column); + } + + virtual void importModule(const QString &uri, const QString &version, const QString &module, int line, int column) + { + Q_UNUSED(uri); + Q_UNUSED(version); + Q_UNUSED(module); + Q_UNUSED(line); + Q_UNUSED(column); + } +}; + +class Engine +{ + Lexer *_lexer = nullptr; + Directives *_directives = nullptr; + MemoryPool _pool; + QList<SourceLocation> _comments; + QStringList _extraCode; + QString _code; + +public: + void setCode(const QString &code) { _code = code; } + const QString &code() const { return _code; } + + void addComment(int pos, int len, int line, int col) + { + Q_ASSERT(len >= 0); + _comments.append(QQmlJS::SourceLocation(pos, len, line, col)); + } + + QList<SourceLocation> comments() const { return _comments; } + + Lexer *lexer() const { return _lexer; } + void setLexer(Lexer *lexer) { _lexer = lexer; } + + Directives *directives() const { return _directives; } + void setDirectives(Directives *directives) { _directives = directives; } + + MemoryPool *pool() { return &_pool; } + const MemoryPool *pool() const { return &_pool; } + + QStringView midRef(int position, int size) + { + return QStringView{_code}.mid(position, size); + } + + QStringView newStringRef(const QString &text) + { + _extraCode.append(text); + return QStringView{_extraCode.last()}; + } + + QStringView newStringRef(const QChar *chars, int size) + { + return newStringRef(QString(chars, size)); + } +}; + +} // end of namespace QQmlJS + +QT_END_NAMESPACE + +#endif // QQMLJSENGINE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsfixedpoolarray_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsfixedpoolarray_p.h new file mode 100644 index 0000000000000000000000000000000000000000..30d6f091b6088cd45802a6ba6577a2ddef98b922 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsfixedpoolarray_p.h @@ -0,0 +1,104 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJSFIXEDPOOLARRAY_P_H +#define QQMLJSFIXEDPOOLARRAY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <private/qqmljsmemorypool_p.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { + +template <typename T> +class FixedPoolArray +{ + T *data; + int count = 0; + +public: + FixedPoolArray() + : data(nullptr) + {} + + FixedPoolArray(MemoryPool *pool, int size) + { allocate(pool, size); } + + void allocate(MemoryPool *pool, int size) + { + count = size; + data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T))); + } + + void allocate(MemoryPool *pool, const QVector<T> &vector) + { + count = vector.size(); + data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T))); + + if (QTypeInfo<T>::isComplex) { + for (int i = 0; i < count; ++i) + new (data + i) T(vector.at(i)); + } else if (count) { + memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T)); + } + } + + template <typename Container> + void allocate(MemoryPool *pool, const Container &container) + { + count = container.size(); + data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T))); + typename Container::ConstIterator it = container.constBegin(); + for (int i = 0; i < count; ++i) + new (data + i) T(*it++); + } + + int size() const + { return count; } + + const T &at(int index) const { + Q_ASSERT(index >= 0 && index < count); + return data[index]; + } + + T &at(int index) { + Q_ASSERT(index >= 0 && index < count); + return data[index]; + } + + T &operator[](int index) { + return at(index); + } + + + int indexOf(const T &value) const { + for (int i = 0; i < count; ++i) + if (data[i] == value) + return i; + return -1; + } + + const T *begin() const { return data; } + const T *end() const { return data + count; } + + T *begin() { return data; } + T *end() { return data + count; } +}; + +} // namespace QQmlJS + +QT_END_NAMESPACE + +#endif // QQMLJSFIXEDPOOLARRAY_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2235a9d4f4b75efd7609f3ec3f45a219b1dc67dd --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsglobal_p.h @@ -0,0 +1,29 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQMLJSGLOBAL_P_H +#define QQMLJSGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +#ifndef QT_STATIC +# if defined(QT_BUILD_QML_LIB) +# define QML_PARSER_EXPORT Q_DECL_EXPORT +# else +# define QML_PARSER_EXPORT Q_DECL_IMPORT +# endif +#else +# define QML_PARSER_EXPORT +#endif + +#endif // QQMLJSGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsgrammar_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsgrammar_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4e47cc9dd8d8eb9afd0d42370985866c316a4e8f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsgrammar_p.h @@ -0,0 +1,212 @@ +// Copyright (C) The Qt Company Ltd. and other contributors. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// This file was generated by qlalr - DO NOT EDIT! +#ifndef QQMLJSGRAMMAR_P_H +#define QQMLJSGRAMMAR_P_H + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +class QQmlJSGrammar +{ +public: + enum VariousConstants { + EOF_SYMBOL = 0, + REDUCE_HERE = 138, + T_AND = 1, + T_AND_AND = 2, + T_AND_EQ = 3, + T_ARROW = 95, + T_AS = 116, + T_AT = 89, + T_AUTOMATIC_SEMICOLON = 63, + T_BREAK = 4, + T_CASE = 5, + T_CATCH = 6, + T_CLASS = 102, + T_COLON = 7, + T_COMMA = 8, + T_COMMENT = 93, + T_COMPATIBILITY_SEMICOLON = 94, + T_COMPONENT = 108, + T_CONST = 87, + T_CONTINUE = 9, + T_DEBUGGER = 90, + T_DEFAULT = 10, + T_DELETE = 11, + T_DIVIDE_ = 12, + T_DIVIDE_EQ = 13, + T_DO = 14, + T_DOT = 15, + T_ELLIPSIS = 99, + T_ELSE = 16, + T_ENUM = 98, + T_EOL = 122, + T_EQ = 17, + T_EQ_EQ = 18, + T_EQ_EQ_EQ = 19, + T_ERROR = 121, + T_EXPORT = 105, + T_EXTENDS = 103, + T_FALSE = 86, + T_FEED_JS_EXPRESSION = 131, + T_FEED_JS_MODULE = 133, + T_FEED_JS_SCRIPT = 132, + T_FEED_JS_STATEMENT = 130, + T_FEED_UI_OBJECT_MEMBER = 129, + T_FEED_UI_PROGRAM = 128, + T_FINALLY = 20, + T_FOR = 21, + T_FORCE_BLOCK = 135, + T_FORCE_DECLARATION = 134, + T_FOR_LOOKAHEAD_OK = 136, + T_FROM = 106, + T_FUNCTION = 22, + T_GE = 23, + T_GET = 118, + T_GT = 24, + T_GT_GT = 25, + T_GT_GT_EQ = 26, + T_GT_GT_GT = 27, + T_GT_GT_GT_EQ = 28, + T_IDENTIFIER = 29, + T_IF = 30, + T_IMPORT = 114, + T_IN = 31, + T_INSTANCEOF = 32, + T_LBRACE = 33, + T_LBRACKET = 34, + T_LE = 35, + T_LET = 88, + T_LPAREN = 36, + T_LT = 37, + T_LT_LT = 38, + T_LT_LT_EQ = 39, + T_MINUS = 40, + T_MINUS_EQ = 41, + T_MINUS_MINUS = 42, + T_MULTILINE_STRING_LITERAL = 92, + T_NEW = 43, + T_NONE = 120, + T_NOT = 44, + T_NOT_EQ = 45, + T_NOT_EQ_EQ = 46, + T_NO_SUBSTITUTION_TEMPLATE = 109, + T_NULL = 84, + T_NUMERIC_LITERAL = 47, + T_OF = 117, + T_ON = 137, + T_OR = 48, + T_OR_EQ = 50, + T_OR_OR = 51, + T_PARTIAL_COMMENT = 123, + T_PARTIAL_DOUBLE_QUOTE_STRING_LITERAL = 125, + T_PARTIAL_SINGLE_QUOTE_STRING_LITERAL = 124, + T_PARTIAL_TEMPLATE_HEAD = 126, + T_PARTIAL_TEMPLATE_MIDDLE = 127, + T_PLUS = 52, + T_PLUS_EQ = 53, + T_PLUS_PLUS = 54, + T_PRAGMA = 115, + T_PROPERTY = 69, + T_PUBLIC = 113, + T_QUESTION = 55, + T_QUESTION_DOT = 97, + T_QUESTION_QUESTION = 96, + T_RBRACE = 56, + T_RBRACKET = 57, + T_READONLY = 71, + T_REMAINDER = 58, + T_REMAINDER_EQ = 59, + T_REQUIRED = 107, + T_RESERVED_WORD = 91, + T_RETURN = 60, + T_RPAREN = 61, + T_SEMICOLON = 62, + T_SET = 119, + T_SIGNAL = 70, + T_STAR = 64, + T_STAR_EQ = 67, + T_STAR_STAR = 65, + T_STAR_STAR_EQ = 66, + T_STATIC = 104, + T_STRING_LITERAL = 68, + T_SUPER = 101, + T_SWITCH = 72, + T_TEMPLATE_HEAD = 110, + T_TEMPLATE_MIDDLE = 111, + T_TEMPLATE_TAIL = 112, + T_THEN = 139, + T_THIS = 73, + T_THROW = 74, + T_TILDE = 75, + T_TRUE = 85, + T_TRY = 76, + T_TYPEOF = 77, + T_VAR = 78, + T_VERSION_NUMBER = 49, + T_VOID = 79, + T_WHILE = 80, + T_WITH = 81, + T_WITHOUTAS = 140, + T_XOR = 82, + T_XOR_EQ = 83, + T_YIELD = 100, + + ACCEPT_STATE = 1111, + RULE_COUNT = 625, + STATE_COUNT = 1112, + TERMINAL_COUNT = 141, + NON_TERMINAL_COUNT = 241, + + GOTO_INDEX_OFFSET = 1112, + GOTO_INFO_OFFSET = 7873, + GOTO_CHECK_OFFSET = 7873 + }; + + static const char *const spell[]; + static const short lhs[]; + static const short rhs[]; + static const short goto_default[]; + static const short action_default[]; + static const short action_index[]; + static const short action_info[]; + static const short action_check[]; + + static inline int nt_action (int state, int nt) + { + const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt; + if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt) + return goto_default [nt]; + + return action_info [GOTO_INFO_OFFSET + yyn]; + } + + static inline int t_action (int state, int token) + { + const int yyn = action_index [state] + token; + + if (yyn < 0 || action_check [yyn] != token) + return - action_default [state]; + + return action_info [yyn]; + } +}; + + +QT_END_NAMESPACE +#endif // QQMLJSGRAMMAR_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljskeywords_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljskeywords_p.h new file mode 100644 index 0000000000000000000000000000000000000000..aecb5805f28bfbd66e50b1760fbc47d10de41d68 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljskeywords_p.h @@ -0,0 +1,918 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJSKEYWORDS_P_H +#define QQMLJSKEYWORDS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmljslexer_p.h" + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { + +static inline int classify2(const QChar *s, int parseModeFlags) { + if (s[0].unicode() == 'a') { + if (s[1].unicode() == 's') { + return Lexer::T_AS; + } + } + else if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'o') { + return Lexer::T_DO; + } + } + else if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'f') { + return Lexer::T_IF; + } + else if (s[1].unicode() == 'n') { + return Lexer::T_IN; + } + } + else if (s[0].unicode() == 'o') { + if (s[1].unicode() == 'n') { + return (parseModeFlags & Lexer::QmlMode) ? Lexer::T_ON : Lexer::T_IDENTIFIER; + } + else if (s[1].unicode() == 'f') { + return Lexer::T_OF; + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify3(const QChar *s, int parseModeFlags) { + if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'r') { + return Lexer::T_FOR; + } + } + } + else if (s[0].unicode() == 'g') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 't') { + return Lexer::T_GET; + } + } + } + else if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'n') { + if (s[2].unicode() == 't') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_INT) : int(Lexer::T_IDENTIFIER); + } + } + } + else if (s[0].unicode() == 'l') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 't') { + return int(Lexer::T_LET); + } + } + } + else if (s[0].unicode() == 'n') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'w') { + return Lexer::T_NEW; + } + } + } + else if (s[0].unicode() == 's') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 't') { + return Lexer::T_SET; + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'y') { + return Lexer::T_TRY; + } + } + } + else if (s[0].unicode() == 'v') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 'r') { + return Lexer::T_VAR; + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify4(const QChar *s, int parseModeFlags) { + if (s[0].unicode() == 'b') { + if (s[1].unicode() == 'y') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'e') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_BYTE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[0].unicode() == 'c') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 'e') { + return Lexer::T_CASE; + } + } + } + else if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 'r') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_CHAR) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[0].unicode() == 'e') { + if (s[1].unicode() == 'l') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 'e') { + return Lexer::T_ELSE; + } + } + } + else if (s[1].unicode() == 'n') { + if (s[2].unicode() == 'u') { + if (s[3].unicode() == 'm') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_ENUM) : int(Lexer::T_RESERVED_WORD); + } + } + } + } + else if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'm') { + return int(Lexer::T_FROM); + } + } + } + } + else if (s[0].unicode() == 'g') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'o') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_GOTO) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[0].unicode() == 'l') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'g') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_LONG) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[0].unicode() == 'n') { + if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 'l') { + return Lexer::T_NULL; + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 's') { + return Lexer::T_THIS; + } + } + } + else if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'u') { + if (s[3].unicode() == 'e') { + return Lexer::T_TRUE; + } + } + } + } + else if (s[0].unicode() == 'v') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 'd') { + return Lexer::T_VOID; + } + } + } + } + else if (s[0].unicode() == 'w') { + if (s[1].unicode() == 'i') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'h') { + return Lexer::T_WITH; + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify5(const QChar *s, int parseModeFlags) { + if (s[0].unicode() == 'b') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'e') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'k') { + return Lexer::T_BREAK; + } + } + } + } + } + else if (s[0].unicode() == 'c') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'c') { + if (s[4].unicode() == 'h') { + return Lexer::T_CATCH; + } + } + } + } + else if (s[1].unicode() == 'l') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 's') { + if (s[4].unicode() == 's') { + return Lexer::T_CLASS; + } + } + } + } + else if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 's') { + if (s[4].unicode() == 't') { + return int(Lexer::T_CONST); + } + } + } + } + } + else if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 's') { + if (s[4].unicode() == 'e') { + return Lexer::T_FALSE; + } + } + } + } + else if (s[1].unicode() == 'i') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'l') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_FINAL) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[1].unicode() == 'l') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 't') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_FLOAT) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + else if (s[0].unicode() == 's') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'r') { + if (s[4].unicode() == 't') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_SHORT) : int(Lexer::T_IDENTIFIER); + } + } + } + } + else if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'r') { + return int(Lexer::T_SUPER); + } + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'r') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'w') { + return Lexer::T_THROW; + } + } + } + } + } + else if (s[0].unicode() == 'w') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'e') { + return Lexer::T_WHILE; + } + } + } + } + } + else if (s[0].unicode() == 'y') { + if (s[1].unicode() == 'i') { + if (s[2].unicode() == 'e') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'd') { + return (parseModeFlags & Lexer::YieldIsKeyword) ? Lexer::T_YIELD : Lexer::T_IDENTIFIER; + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify6(const QChar *s, int parseModeFlags) { + if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 't') { + if (s[5].unicode() == 'e') { + return Lexer::T_DELETE; + } + } + } + } + } + else if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'u') { + if (s[3].unicode() == 'b') { + if (s[4].unicode() == 'l') { + if (s[5].unicode() == 'e') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_DOUBLE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + else if (s[0].unicode() == 'e') { + if (s[1].unicode() == 'x') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 't') { + return Lexer::T_EXPORT; + } + } + } + } + } + } + else if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'm') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 't') { + return Lexer::T_IMPORT; + } + } + } + } + } + } + else if (s[0].unicode() == 'n') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'i') { + if (s[4].unicode() == 'v') { + if (s[5].unicode() == 'e') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_NATIVE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + else if (s[0].unicode() == 'p') { + if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'b') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'i') { + if (s[5].unicode() == 'c') { + return (parseModeFlags & Lexer::QmlMode) ? Lexer::T_PUBLIC : Lexer::T_IDENTIFIER; + } + } + } + } + } + else if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 'g') { + if (s[4].unicode() == 'm') { + if (s[5].unicode() == 'a') { + return (parseModeFlags & Lexer::QmlMode) ? Lexer::T_PRAGMA : Lexer::T_IDENTIFIER; + } + } + } + } + } + } + else if (s[0].unicode() == 'r') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'u') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 'n') { + return Lexer::T_RETURN; + } + } + } + } + } + } + else if (s[0].unicode() == 's') { + if ((parseModeFlags & Lexer::QmlMode) && s[1].unicode() == 'i') { + if (s[2].unicode() == 'g') { + if (s[3].unicode() == 'n') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 'l') { + return Lexer::T_SIGNAL; + } + } + } + } + } + else if (s[1].unicode() == 't') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'i') { + if (s[5].unicode() == 'c') { + return (parseModeFlags & Lexer::StaticIsKeyword) ? int(Lexer::T_STATIC) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + else if (s[1].unicode() == 'w') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'c') { + if (s[5].unicode() == 'h') { + return Lexer::T_SWITCH; + } + } + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'r') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'w') { + if (s[5].unicode() == 's') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_THROWS) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + else if (s[1].unicode() == 'y') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'o') { + if (s[5].unicode() == 'f') { + return Lexer::T_TYPEOF; + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify7(const QChar *s, int parseModeFlags) { + if (s[0].unicode() == 'b') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'a') { + if (s[6].unicode() == 'n') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_BOOLEAN) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + else if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'f') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'u') { + if (s[5].unicode() == 'l') { + if (s[6].unicode() == 't') { + return Lexer::T_DEFAULT; + } + } + } + } + } + } + } + else if (s[0].unicode() == 'e') { + if (s[1].unicode() == 'x') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'n') { + if (s[5].unicode() == 'd') { + if (s[6].unicode() == 's') { + return Lexer::T_EXTENDS; + } + } + } + } + } + } + } + else if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'i') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'l') { + if (s[5].unicode() == 'l') { + if (s[6].unicode() == 'y') { + return Lexer::T_FINALLY; + } + } + } + } + } + } + } + else if (s[0].unicode() == 'p') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 'c') { + if (s[3].unicode() == 'k') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 'g') { + if (s[6].unicode() == 'e') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_PACKAGE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + else if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 'v') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 't') { + if (s[6].unicode() == 'e') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_PRIVATE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify8(const QChar *s, int parseModeFlags) { + if (s[0].unicode() == 'a') { + if (s[1].unicode() == 'b') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 'a') { + if (s[6].unicode() == 'c') { + if (s[7].unicode() == 't') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_ABSTRACT) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'c') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'i') { + if (s[5].unicode() == 'n') { + if (s[6].unicode() == 'u') { + if (s[7].unicode() == 'e') { + return Lexer::T_CONTINUE; + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'b') { + if (s[3].unicode() == 'u') { + if (s[4].unicode() == 'g') { + if (s[5].unicode() == 'g') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'r') { + return Lexer::T_DEBUGGER; + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'c') { + if (s[4].unicode() == 't') { + if (s[5].unicode() == 'i') { + if (s[6].unicode() == 'o') { + if (s[7].unicode() == 'n') { + return Lexer::T_FUNCTION; + } + } + } + } + } + } + } + } + else if ((parseModeFlags & Lexer::QmlMode) && s[0].unicode() == 'p') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'p') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'r') { + if (s[6].unicode() == 't') { + if (s[7].unicode() == 'y') { + return Lexer::T_PROPERTY; + } + } + } + } + } + } + } + } + else if ((parseModeFlags & Lexer::QmlMode) && s[0].unicode() == 'r') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 'd') { + if (s[4].unicode() == 'o') { + if (s[5].unicode() == 'n') { + if (s[6].unicode() == 'l') { + if (s[7].unicode() == 'y') { + return Lexer::T_READONLY; + } + } + } + } + } + } else if (s[2].unicode() == 'q') { + if (s[3].unicode() == 'u') { + if (s[4].unicode() == 'i') { + if (s[5].unicode() == 'r') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'd') { + return Lexer::T_REQUIRED; + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'v') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 't') { + if (s[5].unicode() == 'i') { + if (s[6].unicode() == 'l') { + if (s[7].unicode() == 'e') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_VOLATILE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify9(const QChar *s, int parseModeFlags) { + if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'n') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 'f') { + if (s[6].unicode() == 'a') { + if (s[7].unicode() == 'c') { + if (s[8].unicode() == 'e') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_INTERFACE) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'p') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'c') { + if (s[6].unicode() == 't') { + if (s[7].unicode() == 'e') { + if (s[8].unicode() == 'd') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_PROTECTED) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 'n') { + if (s[4].unicode() == 's') { + if (s[5].unicode() == 'i') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'n') { + if (s[8].unicode() == 't') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_TRANSIENT) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'c') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'm') { + if (s[3].unicode() == 'p') { + if (s[4].unicode() == 'o') { + if (s[5].unicode() == 'n') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'n') { + if (s[8].unicode() == 't') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_COMPONENT) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify10(const QChar *s, int parseModeFlags) { + if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'm') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'm') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'n') { + if (s[8].unicode() == 't') { + if (s[9].unicode() == 's') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_IMPLEMENTS) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + else if (s[1].unicode() == 'n') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 'n') { + if (s[6].unicode() == 'c') { + if (s[7].unicode() == 'e') { + if (s[8].unicode() == 'o') { + if (s[9].unicode() == 'f') { + return Lexer::T_INSTANCEOF; + } + } + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify12(const QChar *s, int parseModeFlags) { + if (s[0].unicode() == 's') { + if (s[1].unicode() == 'y') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'c') { + if (s[4].unicode() == 'h') { + if (s[5].unicode() == 'r') { + if (s[6].unicode() == 'o') { + if (s[7].unicode() == 'n') { + if (s[8].unicode() == 'i') { + if (s[9].unicode() == 'z') { + if (s[10].unicode() == 'e') { + if (s[11].unicode() == 'd') { + return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_SYNCHRONIZED) : int(Lexer::T_IDENTIFIER); + } + } + } + } + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +int Lexer::classify(const QChar *s, int n, int parseModeFlags) { + switch (n) { + case 2: return classify2(s, parseModeFlags); + case 3: return classify3(s, parseModeFlags); + case 4: return classify4(s, parseModeFlags); + case 5: return classify5(s, parseModeFlags); + case 6: return classify6(s, parseModeFlags); + case 7: return classify7(s, parseModeFlags); + case 8: return classify8(s, parseModeFlags); + case 9: return classify9(s, parseModeFlags); + case 10: return classify10(s, parseModeFlags); + case 12: return classify12(s, parseModeFlags); + default: return Lexer::T_IDENTIFIER; + } // switch +} + +} // namespace QQmlJS + +QT_END_NAMESPACE + +#endif // QQMLJSKEYWORDS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljslexer_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljslexer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8c89c45492f6cf19c28fa10ba854b96d3b1d3b61 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljslexer_p.h @@ -0,0 +1,298 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJSLEXER_P_H +#define QQMLJSLEXER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmljsglobal_p.h> +#include <private/qqmljsgrammar_p.h> + +#include <QtCore/qstring.h> +#include <QtCore/qstack.h> + +QT_BEGIN_NAMESPACE + +class QDebug; + +namespace QQmlJS { + +class Engine; +struct DiagnosticMessage; +class Directives; + +class QML_PARSER_EXPORT Lexer: public QQmlJSGrammar +{ +public: + enum { + T_ABSTRACT = T_RESERVED_WORD, + T_BOOLEAN = T_RESERVED_WORD, + T_BYTE = T_RESERVED_WORD, + T_CHAR = T_RESERVED_WORD, + T_DOUBLE = T_RESERVED_WORD, + T_FINAL = T_RESERVED_WORD, + T_FLOAT = T_RESERVED_WORD, + T_GOTO = T_RESERVED_WORD, + T_IMPLEMENTS = T_RESERVED_WORD, + T_INT = T_RESERVED_WORD, + T_INTERFACE = T_RESERVED_WORD, + T_LONG = T_RESERVED_WORD, + T_NATIVE = T_RESERVED_WORD, + T_PACKAGE = T_RESERVED_WORD, + T_PRIVATE = T_RESERVED_WORD, + T_PROTECTED = T_RESERVED_WORD, + T_SHORT = T_RESERVED_WORD, + T_SYNCHRONIZED = T_RESERVED_WORD, + T_THROWS = T_RESERVED_WORD, + T_TRANSIENT = T_RESERVED_WORD, + T_VOLATILE = T_RESERVED_WORD + }; + + enum Error { + NoError, + IllegalCharacter, + IllegalNumber, + UnclosedStringLiteral, + IllegalEscapeSequence, + IllegalUnicodeEscapeSequence, + UnclosedComment, + IllegalExponentIndicator, + IllegalIdentifier, + IllegalHexadecimalEscapeSequence + }; + + enum RegExpBodyPrefix { + NoPrefix, + EqualPrefix + }; + + enum RegExpFlag { + RegExp_Global = 0x01, + RegExp_IgnoreCase = 0x02, + RegExp_Multiline = 0x04, + RegExp_Unicode = 0x08, + RegExp_Sticky = 0x10 + }; + + enum ParseModeFlags { + QmlMode = 0x1, + YieldIsKeyword = 0x2, + StaticIsKeyword = 0x4 + }; + + enum class ImportState { + SawImport, + NoQmlImport + }; + + enum class LexMode { WholeCode, LineByLine }; + + enum class CodeContinuation { Reset, Continue }; + +public: + Lexer(Engine *engine, LexMode lexMode = LexMode::WholeCode); + + bool qmlMode() const; + bool yieldIsKeyWord() const { return _state.generatorLevel != 0; } + void setStaticIsKeyword(bool b) { _staticIsKeyword = b; } + + QString code() const; + void setCode(const QString &code, int lineno, bool qmlMode = true, + CodeContinuation codeContinuation = CodeContinuation::Reset); + + int lex(); + + bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix); + bool scanDirectives(Directives *directives, DiagnosticMessage *error); + + int regExpFlags() const { return _state.patternFlags; } + QString regExpPattern() const { return _tokenText; } + + int tokenKind() const { return _state.tokenKind; } + int tokenOffset() const { return _currentOffset + _tokenStartPtr - _code.unicode(); } + int tokenLength() const { return _tokenLength; } + + int tokenStartLine() const { return _tokenLine; } + int tokenStartColumn() const { return _tokenColumn; } + + inline QStringView tokenSpell() const { return _tokenSpell; } + inline QStringView rawString() const { return _rawString; } + double tokenValue() const { return _state.tokenValue; } + QString tokenText() const; + + Error errorCode() const; + QString errorMessage() const; + + bool canInsertAutomaticSemicolon(int token) const; + + enum ParenthesesState { + IgnoreParentheses, + CountParentheses, + BalancedParentheses + }; + + enum class CommentState { NoComment, HadComment, InMultilineComment }; + + void enterGeneratorBody() { ++_state.generatorLevel; } + void leaveGeneratorBody() { --_state.generatorLevel; } + + struct State + { + Error errorCode = NoError; + + QChar currentChar = u'\n'; + double tokenValue = 0; + + // parentheses state + ParenthesesState parenthesesState = IgnoreParentheses; + int parenthesesCount = 0; + + // template string stack + QStack<int> outerTemplateBraceCount; + int bracesCount = -1; + + int stackToken = -1; + + int patternFlags = 0; + int tokenKind = 0; + ImportState importState = ImportState::NoQmlImport; + + bool validTokenText = false; + bool prohibitAutomaticSemicolon = false; + bool restrictedKeyword = false; + bool terminator = false; + bool followsClosingBrace = false; + bool delimited = true; + bool handlingDirectives = false; + CommentState comments = CommentState::NoComment; + int generatorLevel = 0; + + friend bool operator==(State const &s1, State const &s2) + { + if (s1.errorCode != s2.errorCode) + return false; + if (s1.currentChar != s2.currentChar) + return false; + if (s1.tokenValue != s2.tokenValue) + return false; + if (s1.parenthesesState != s2.parenthesesState) + return false; + if (s1.parenthesesCount != s2.parenthesesCount) + return false; + if (s1.outerTemplateBraceCount != s2.outerTemplateBraceCount) + return false; + if (s1.bracesCount != s2.bracesCount) + return false; + if (s1.stackToken != s2.stackToken) + return false; + if (s1.patternFlags != s2.patternFlags) + return false; + if (s1.tokenKind != s2.tokenKind) + return false; + if (s1.importState != s2.importState) + return false; + if (s1.validTokenText != s2.validTokenText) + return false; + if (s1.prohibitAutomaticSemicolon != s2.prohibitAutomaticSemicolon) + return false; + if (s1.restrictedKeyword != s2.restrictedKeyword) + return false; + if (s1.terminator != s2.terminator) + return false; + if (s1.followsClosingBrace != s2.followsClosingBrace) + return false; + if (s1.delimited != s2.delimited) + return false; + if (s1.handlingDirectives != s2.handlingDirectives) + return false; + if (s1.generatorLevel != s2.generatorLevel) + return false; + return true; + } + + friend bool operator!=(State const &s1, State const &s2) { return !(s1 == s2); } + + friend QML_PARSER_EXPORT QDebug operator<<(QDebug dbg, State const &s); + }; + + const State &state() const; + void setState(const State &state); + +protected: + static int classify(const QChar *s, int n, int parseModeFlags); + +private: + int parseModeFlags() const; + bool prevTerminator() const; + bool followsClosingBrace() const; + inline void scanChar(); + inline QChar peekChar(); + int scanToken(); + int scanNumber(QChar ch); + int scanVersionNumber(QChar ch); + enum ScanStringMode { + SingleQuote = '\'', + DoubleQuote = '"', + TemplateHead = '`', + TemplateContinuation = 0 + }; + int scanString(ScanStringMode mode); + + bool isLineTerminator() const; + unsigned isLineTerminatorSequence() const; + static bool isIdentLetter(QChar c); + static bool isDecimalDigit(ushort c); + static bool isHexDigit(QChar c); + static bool isOctalDigit(ushort c); + + void syncProhibitAutomaticSemicolon(); + uint decodeUnicodeEscapeCharacter(bool *ok); + QChar decodeHexEscapeCharacter(bool *ok); + + friend QML_PARSER_EXPORT QDebug operator<<(QDebug dbg, const Lexer &l); + +private: + Engine *_engine; + + LexMode _lexMode = LexMode::WholeCode; + QString _code; + const QChar *_endPtr; + bool _qmlMode; + bool _staticIsKeyword = false; + + bool _skipLinefeed = false; + + int _currentLineNumber = 0; + int _currentColumnNumber = 0; + int _currentOffset = 0; + + int _tokenLength = 0; + int _tokenLine = 0; + int _tokenColumn = 0; + + QString _tokenText; + QString _errorMessage; + QStringView _tokenSpell; + QStringView _rawString; + + const QChar *_codePtr = nullptr; + const QChar *_tokenStartPtr = nullptr; + + State _state; +}; + +} // end of namespace QQmlJS + +QT_END_NAMESPACE + +#endif // LEXER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsmemorypool_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsmemorypool_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cac4749078d21486cd83960c5e69571f2f75a206 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsmemorypool_p.h @@ -0,0 +1,139 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJSMEMORYPOOL_P_H +#define QQMLJSMEMORYPOOL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qstring.h> +#include <QtCore/qvector.h> + +#include <cstdlib> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { + +class Managed; + +class MemoryPool +{ + Q_DISABLE_COPY_MOVE(MemoryPool); + +public: + MemoryPool() = default; + ~MemoryPool() + { + if (_blocks) { + for (int i = 0; i < _allocatedBlocks; ++i) { + if (char *b = _blocks[i]) + free(b); + } + + free(_blocks); + } + } + + inline void *allocate(size_t size) + { + size = (size + 7) & ~size_t(7); + if (Q_LIKELY(_ptr && size < size_t(_end - _ptr))) { + void *addr = _ptr; + _ptr += size; + return addr; + } + return allocate_helper(size); + } + + void reset() + { + _blockCount = -1; + _ptr = _end = nullptr; + } + + template <typename Tp> Tp *New() { return new (this->allocate(sizeof(Tp))) Tp(); } + template <typename Tp, typename... Ta> Tp *New(Ta... args) + { return new (this->allocate(sizeof(Tp))) Tp(args...); } + + QStringView newString(QString string) { + return strings.emplace_back(std::move(string)); + } + +private: + Q_NEVER_INLINE void *allocate_helper(size_t size) + { + size_t currentBlockSize = DEFAULT_BLOCK_SIZE; + while (Q_UNLIKELY(size >= currentBlockSize)) + currentBlockSize *= 2; + + if (++_blockCount == _allocatedBlocks) { + if (! _allocatedBlocks) + _allocatedBlocks = DEFAULT_BLOCK_COUNT; + else + _allocatedBlocks *= 2; + + _blocks = reinterpret_cast<char **>(realloc(_blocks, sizeof(char *) * size_t(_allocatedBlocks))); + Q_CHECK_PTR(_blocks); + + for (int index = _blockCount; index < _allocatedBlocks; ++index) + _blocks[index] = nullptr; + } + + char *&block = _blocks[_blockCount]; + + if (! block) { + block = reinterpret_cast<char *>(malloc(currentBlockSize)); + Q_CHECK_PTR(block); + } + + _ptr = block; + _end = _ptr + currentBlockSize; + + void *addr = _ptr; + _ptr += size; + return addr; + } + +private: + char **_blocks = nullptr; + int _allocatedBlocks = 0; + int _blockCount = -1; + char *_ptr = nullptr; + char *_end = nullptr; + QStringList strings; + + enum + { + DEFAULT_BLOCK_SIZE = 8 * 1024, + DEFAULT_BLOCK_COUNT = 8 + }; +}; + +class Managed +{ + Q_DISABLE_COPY(Managed) +public: + Managed() = default; + ~Managed() = default; + + void *operator new(size_t size, MemoryPool *pool) { return pool->allocate(size); } + void operator delete(void *) {} + void operator delete(void *, MemoryPool *) {} +}; + +} // namespace QQmlJS + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsparser_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsparser_p.h new file mode 100644 index 0000000000000000000000000000000000000000..19f50384d0aa85350287563347be6799cf29d565 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljsparser_p.h @@ -0,0 +1,318 @@ + +#line 125 "../../../qtdeclarative/src/qml/parser/qqmljs.g" +// Copyright (C) 2016 The Qt Company Ltd. +// Contact: https://www.qt.io/licensing/ +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// +// W A R N I N G +// ------------- +// +// This file is automatically generated from qqmljs.g. +// Changes should be made to that file, not here. Any change to this file will +// be lost! +// +// To regenerate this file, run: +// qlalr --no-debug --no-lines --qt qqmljs.g +// + +#ifndef QQMLJSPARSER_P_H +#define QQMLJSPARSER_P_H + +#include <private/qqmljsglobal_p.h> +#include <private/qqmljsgrammar_p.h> +#include <private/qqmljsast_p.h> +#include <private/qqmljsengine_p.h> +#include <private/qqmljsdiagnosticmessage_p.h> + +#include <QtCore/qlist.h> +#include <QtCore/qstring.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { + +class Engine; + +class QML_PARSER_EXPORT Parser: protected QQmlJSGrammar +{ +public: + union Value { + int ival; + double dval; + AST::VariableScope scope; + AST::ForEachType forEachType; + AST::ArgumentList *ArgumentList; + AST::CaseBlock *CaseBlock; + AST::CaseClause *CaseClause; + AST::CaseClauses *CaseClauses; + AST::Catch *Catch; + AST::DefaultClause *DefaultClause; + AST::Elision *Elision; + AST::ExpressionNode *Expression; + AST::TemplateLiteral *Template; + AST::Finally *Finally; + AST::FormalParameterList *FormalParameterList; + AST::FunctionDeclaration *FunctionDeclaration; + AST::Node *Node; + AST::PropertyName *PropertyName; + AST::Statement *Statement; + AST::StatementList *StatementList; + AST::Block *Block; + AST::VariableDeclarationList *VariableDeclarationList; + AST::Pattern *Pattern; + AST::PatternElement *PatternElement; + AST::PatternElementList *PatternElementList; + AST::PatternProperty *PatternProperty; + AST::PatternPropertyList *PatternPropertyList; + AST::ClassElementList *ClassElementList; + AST::ImportClause *ImportClause; + AST::FromClause *FromClause; + AST::NameSpaceImport *NameSpaceImport; + AST::ImportsList *ImportsList; + AST::NamedImports *NamedImports; + AST::ImportSpecifier *ImportSpecifier; + AST::ExportSpecifier *ExportSpecifier; + AST::ExportsList *ExportsList; + AST::ExportClause *ExportClause; + AST::ExportDeclaration *ExportDeclaration; + AST::TypeAnnotation *TypeAnnotation; + AST::Type *Type; + + AST::UiProgram *UiProgram; + AST::UiHeaderItemList *UiHeaderItemList; + AST::UiPragmaValueList *UiPragmaValueList; + AST::UiPragma *UiPragma; + AST::UiImport *UiImport; + AST::UiParameterList *UiParameterList; + AST::UiPropertyAttributes *UiPropertyAttributes; + AST::UiPublicMember *UiPublicMember; + AST::UiObjectDefinition *UiObjectDefinition; + AST::UiObjectInitializer *UiObjectInitializer; + AST::UiObjectBinding *UiObjectBinding; + AST::UiScriptBinding *UiScriptBinding; + AST::UiArrayBinding *UiArrayBinding; + AST::UiObjectMember *UiObjectMember; + AST::UiObjectMemberList *UiObjectMemberList; + AST::UiArrayMemberList *UiArrayMemberList; + AST::UiQualifiedId *UiQualifiedId; + AST::UiEnumMemberList *UiEnumMemberList; + AST::UiVersionSpecifier *UiVersionSpecifier; + AST::UiAnnotation *UiAnnotation; + AST::UiAnnotationList *UiAnnotationList; + }; + +public: + Parser(Engine *engine); + ~Parser(); + + // parse a UI program + bool parse() { ++functionNestingLevel; bool r = parse(T_FEED_UI_PROGRAM); --functionNestingLevel; return r; } + bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } + bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } + bool parseUiObjectMember() { ++functionNestingLevel; bool r = parse(T_FEED_UI_OBJECT_MEMBER); --functionNestingLevel; return r; } + bool parseProgram() { return parse(T_FEED_JS_SCRIPT); } + bool parseScript() { return parse(T_FEED_JS_SCRIPT); } + bool parseModule() { return parse(T_FEED_JS_MODULE); } + + AST::UiProgram *ast() const + { return AST::cast<AST::UiProgram *>(program); } + + AST::Statement *statement() const + { + if (! program) + return 0; + + return program->statementCast(); + } + + AST::ExpressionNode *expression() const + { + if (! program) + return 0; + + return program->expressionCast(); + } + + AST::UiObjectMember *uiObjectMember() const + { + if (! program) + return 0; + + return program->uiObjectMemberCast(); + } + + AST::Node *rootNode() const + { return program; } + + QList<DiagnosticMessage> diagnosticMessages() const + { return diagnostic_messages; } + + inline DiagnosticMessage diagnosticMessage() const + { + for (const DiagnosticMessage &d : diagnostic_messages) { + if (d.type != QtWarningMsg) + return d; + } + + return DiagnosticMessage(); + } + + inline QString errorMessage() const + { return diagnosticMessage().message; } + + inline int errorLineNumber() const + { return diagnosticMessage().loc.startLine; } + + inline int errorColumnNumber() const + { return diagnosticMessage().loc.startColumn; } + + inline bool identifierInsertionEnabled() const + { return m_identifierInsertionEnabled; } + + inline void setIdentifierInsertionEnabled(bool enable) + { m_identifierInsertionEnabled = enable; } + + inline bool incompleteBindingsEnabled() const + { return m_incompleteBindingsEnabled; } + + inline void setIncompleteBindingsEnabled(bool enable) + { m_incompleteBindingsEnabled = enable; } + +protected: + bool parse(int startToken); + + void reallocateStack(); + + inline Value &sym(int index) + { return sym_stack [tos + index - 1]; } + + inline QStringView &stringRef(int index) + { return string_stack [tos + index - 1]; } + + inline QStringView &rawStringRef(int index) + { return rawString_stack [tos + index - 1]; } + + inline SourceLocation &loc(int index) + { return location_stack [tos + index - 1]; } + + AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); + + void pushToken(int token); + void pushTokenWithEmptyLocation(int token); + int lookaheadToken(Lexer *lexer); + + static DiagnosticMessage compileError(const SourceLocation &location, + const QString &message, QtMsgType kind = QtCriticalMsg) + { + DiagnosticMessage error; + error.loc = location; + error.message = message; + error.type = kind; + return error; + } + + void syntaxError(const SourceLocation &location, const char *message) { + diagnostic_messages.append(compileError(location, QLatin1String(message))); + } + void syntaxError(const SourceLocation &location, const QString &message) { + diagnostic_messages.append(compileError(location, message)); + } + + bool ensureNoFunctionTypeAnnotations(AST::TypeAnnotation *returnTypeAnnotation, AST::FormalParameterList *formals); + +protected: + Engine *driver; + MemoryPool *pool; + int tos = 0; + int stack_size = 0; + Value *sym_stack = nullptr; + int *state_stack = nullptr; + SourceLocation *location_stack = nullptr; + std::vector<QStringView> string_stack; + std::vector<QStringView> rawString_stack; + + AST::Node *program = nullptr; + + // error recovery and lookahead handling + enum { TOKEN_BUFFER_SIZE = 5 }; + + struct SavedToken { + int token; + double dval; + SourceLocation loc; + QStringView spell; + QStringView raw; + }; + + int yytoken = -1; + double yylval = 0.; + QStringView yytokenspell; + QStringView yytokenraw; + SourceLocation yylloc; + SourceLocation yyprevlloc; + int yyprevtoken = -1; + + SavedToken token_buffer[TOKEN_BUFFER_SIZE]; + SavedToken *first_token = nullptr; + SavedToken *last_token = nullptr; + + int functionNestingLevel = 0; + int classNestingLevel = 0; + + enum CoverExpressionType { + CE_Invalid, + CE_ParenthesizedExpression, + CE_FormalParameterList + }; + SourceLocation coverExpressionErrorLocation; + CoverExpressionType coverExpressionType = CE_Invalid; + + QList<DiagnosticMessage> diagnostic_messages; + bool m_identifierInsertionEnabled = false; + bool m_incompleteBindingsEnabled = false; +}; + +} // end of namespace QQmlJS + + + +#line 1841 "../../../qtdeclarative/src/qml/parser/qqmljs.g" + +#define J_SCRIPT_REGEXPLITERAL_RULE1 168 + +#line 1853 "../../../qtdeclarative/src/qml/parser/qqmljs.g" + +#define J_SCRIPT_REGEXPLITERAL_RULE2 169 + +#line 3477 "../../../qtdeclarative/src/qml/parser/qqmljs.g" + +#define J_SCRIPT_EXPRESSIONSTATEMENTLOOKAHEAD_RULE 470 + +#line 4136 "../../../qtdeclarative/src/qml/parser/qqmljs.g" + +#define J_SCRIPT_CONCISEBODYLOOKAHEAD_RULE 540 + +#line 4688 "../../../qtdeclarative/src/qml/parser/qqmljs.g" + +#define J_SCRIPT_EXPORTDECLARATIONLOOKAHEAD_RULE 608 + +#line 4963 "../../../qtdeclarative/src/qml/parser/qqmljs.g" + +QT_END_NAMESPACE + + + +#endif // QQMLJSPARSER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljssourcelocation_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljssourcelocation_p.h new file mode 100644 index 0000000000000000000000000000000000000000..990f4fe249aa33f58e3b0dde611d06ceb8a28214 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmljssourcelocation_p.h @@ -0,0 +1,107 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLJSSOURCELOCATION_P_H +#define QQMLJSSOURCELOCATION_P_H + +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qhashfunctions.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { + +class SourceLocation +{ +public: + explicit SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) + : offset(offset), length(length), + startLine(line), startColumn(column) + { } + + bool isValid() const { return *this != SourceLocation(); } + + quint32 begin() const { return offset; } + quint32 end() const { return offset + length; } + + // Returns a zero length location at the start of the current one. + SourceLocation startZeroLengthLocation() const + { + return SourceLocation(offset, 0, startLine, startColumn); + } + // Returns a zero length location at the end of the current one. + SourceLocation endZeroLengthLocation(QStringView text) const + { + quint32 i = offset; + quint32 endLine = startLine; + quint32 endColumn = startColumn; + while (i < end()) { + QChar c = text.at(i); + switch (c.unicode()) { + case '\n': + if (i + 1 < end() && text.at(i + 1) == QLatin1Char('\r')) + ++i; + Q_FALLTHROUGH(); + case '\r': + ++endLine; + endColumn = 1; + break; + default: + ++endColumn; + } + ++i; + } + return SourceLocation(offset + length, 0, endLine, endColumn); + } + +// attributes + // ### encode + quint32 offset; + quint32 length; + quint32 startLine; + quint32 startColumn; + + friend size_t qHash(const SourceLocation &location, size_t seed = 0) + { + return qHashMulti(seed, location.offset, location.length, + location.startLine, location.startColumn); + } + + friend bool operator==(const SourceLocation &a, const SourceLocation &b) + { + return a.offset == b.offset && a.length == b.length + && a.startLine == b.startLine && a.startColumn == b.startColumn; + } + + friend bool operator!=(const SourceLocation &a, const SourceLocation &b) { return !(a == b); } + + // Returns a source location starting at the beginning of l1, l2 and ending at the end of them. + // Ignores invalid source locations. + friend SourceLocation combine(const SourceLocation &l1, const SourceLocation &l2) { + quint32 e = qMax(l1.end(), l2.end()); + SourceLocation res; + if (l1.offset <= l2.offset) + res = (l1.isValid() ? l1 : l2); + else + res = (l2.isValid() ? l2 : l1); + res.length = e - res.offset; + return res; + } +}; + +} // namespace QQmlJS + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmllist_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmllist_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f04fd22b57e8b4aa516c4aaf2a1a4f057b041446 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmllist_p.h @@ -0,0 +1,231 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLIST_P_H +#define QQMLLIST_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmllist.h" +#include "qqmlmetaobject_p.h" +#include "qqmlmetatype_p.h" +#include <QtQml/private/qbipointer_p.h> + +#include <QtCore/qpointer.h> + +QT_BEGIN_NAMESPACE + +class QQmlListReferencePrivate +{ +public: + QQmlListReferencePrivate(); + + static QQmlListReference init(const QQmlListProperty<QObject> &, QMetaType); + + QPointer<QObject> object; + QQmlListProperty<QObject> property; + QMetaType propertyType; + + void addref(); + void release(); + int refCount; + + static inline QQmlListReferencePrivate *get(QQmlListReference *ref) { + return ref->d; + } + + const QMetaObject *elementType() + { + if (!m_elementType) { + m_elementType = QQmlMetaType::rawMetaObjectForType( + QQmlMetaType::listValueType(propertyType)).metaObject(); + } + + return m_elementType; + } + +private: + const QMetaObject *m_elementType = nullptr; +}; + +template<typename T> +class QQmlListIterator { +public: + using difference_type = qsizetype; + using iterator_category = std::random_access_iterator_tag; + using value_type = T*; + + class reference + { + public: + explicit reference(const QQmlListIterator *iter) : m_iter(iter) {} + reference(const reference &) = default; + reference(reference &&) = default; + ~reference() = default; + + operator T *() const + { + if (m_iter == nullptr) + return nullptr; + return m_iter->m_list->at(m_iter->m_list, m_iter->m_i); + } + + reference &operator=(T *value) { + m_iter->m_list->replace(m_iter->m_list, m_iter->m_i, value); + return *this; + } + + reference &operator=(const reference &value) { return operator=((T *)(value)); } + reference &operator=(reference &&value) { return operator=((T *)(value)); } + + friend void swap(reference a, reference b) + { + T *tmp = a; + a = b; + b = std::move(tmp); + } + private: + const QQmlListIterator *m_iter; + }; + + class pointer + { + public: + explicit pointer(const QQmlListIterator *iter) : m_iter(iter) {} + reference operator*() const { return reference(m_iter); } + QQmlListIterator operator->() const { return *m_iter; } + + private: + const QQmlListIterator *m_iter; + }; + + QQmlListIterator() = default; + QQmlListIterator(QQmlListProperty<T> *list, qsizetype i) : m_list(list), m_i(i) {} + + QQmlListIterator &operator++() + { + ++m_i; + return *this; + } + + QQmlListIterator operator++(int) + { + QQmlListIterator result = *this; + ++m_i; + return result; + } + + QQmlListIterator &operator--() + { + --m_i; + return *this; + } + + QQmlListIterator operator--(int) + { + QQmlListIterator result = *this; + --m_i; + return result; + } + + QQmlListIterator &operator+=(qsizetype j) + { + m_i += j; + return *this; + } + + QQmlListIterator &operator-=(qsizetype j) + { + m_i -= j; + return *this; + } + + QQmlListIterator operator+(qsizetype j) + { + return QQmlListIterator(m_list, m_i + j); + } + + QQmlListIterator operator-(qsizetype j) + { + return QQmlListIterator(m_list, m_i - j); + } + + reference operator*() const + { + return reference(this); + } + + pointer operator->() const + { + return pointer(this); + } + +private: + friend inline bool operator==(const QQmlListIterator &a, const QQmlListIterator &b) + { + return a.m_list == b.m_list && a.m_i == b.m_i; + } + + friend inline bool operator!=(const QQmlListIterator &a, const QQmlListIterator &b) + { + return a.m_list != b.m_list || a.m_i != b.m_i; + } + + friend inline bool operator<(const QQmlListIterator &i, const QQmlListIterator &j) + { + return i - j < 0; + } + + friend inline bool operator>=(const QQmlListIterator &i, const QQmlListIterator &j) + { + return !(i < j); + } + + friend inline bool operator>(const QQmlListIterator &i, const QQmlListIterator &j) + { + return i - j > 0; + } + + friend inline bool operator<=(const QQmlListIterator &i, const QQmlListIterator &j) + { + return !(i > j); + } + + friend inline QQmlListIterator operator+(qsizetype i, const QQmlListIterator &j) + { + return j + i; + } + + friend inline qsizetype operator-(const QQmlListIterator &i, const QQmlListIterator &j) + { + return i.m_i - j.m_i; + } + + QQmlListProperty<T> *m_list = nullptr; + qsizetype m_i = 0; +}; + +template<typename T> +QQmlListIterator<T> begin(QQmlListProperty<T> &list) +{ + return QQmlListIterator<T>(&list, 0); +} + +template<typename T> +QQmlListIterator<T> end(QQmlListProperty<T> &list) +{ + return QQmlListIterator<T>(&list, list.count(&list)); +} + +QT_END_NAMESPACE + +#endif // QQMLLIST_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmllistwrapper_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmllistwrapper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e7d889010f7b4fe05a398d7eb132b687ac073e02 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmllistwrapper_p.h @@ -0,0 +1,109 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLISTWRAPPER_P_H +#define QQMLLISTWRAPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtCore/qpointer.h> + +#include <QtQml/qqmllist.h> + +#include <private/qv4value_p.h> +#include <private/qv4object_p.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcIncompatibleElement) + +namespace QV4 { + +namespace Heap { + +struct QmlListWrapper : Object +{ + void init(QMetaType propertyType); + void init(QObject *object, int propertyId, QMetaType propertyType); + void init(QObject *object, const QQmlListProperty<QObject> &list, QMetaType propertyType); + void destroy(); + + QObject *object() const { return m_object.data(); } + QMetaType propertyType() const { return QMetaType(m_propertyType); } + QMetaType elementType() const { return QQmlMetaType::listValueType(propertyType()); } + + const QQmlListProperty<QObject> *property() const + { + return reinterpret_cast<const QQmlListProperty<QObject>*>(m_propertyData); + } + + QQmlListProperty<QObject> *property() + { + return reinterpret_cast<QQmlListProperty<QObject>*>(m_propertyData); + } + +private: + void *m_propertyData[sizeof(QQmlListProperty<QObject>)/sizeof(void*)]; + + QV4QPointer<QObject> m_object; + + // interface instead of QMetaType to keep class a POD + const QtPrivate::QMetaTypeInterface *m_propertyType; +}; + +} + +struct Q_QML_EXPORT QmlListWrapper : Object +{ + V4_OBJECT2(QmlListWrapper, Object) + V4_NEEDS_DESTROY + V4_PROTOTYPE(propertyListPrototype) + Q_MANAGED_TYPE(QmlListProperty) + + static ReturnedValue create(ExecutionEngine *engine, QObject *object, int propId, QMetaType propType); + static ReturnedValue create(ExecutionEngine *engine, const QQmlListProperty<QObject> &prop, QMetaType propType); + static ReturnedValue create(ExecutionEngine *engine, QMetaType propType); + + QVariant toVariant() const; + QQmlListReference toListReference() const; + + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static qint64 virtualGetLength(const Managed *m); + static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); +}; + +struct PropertyListPrototype : Object +{ + V4_PROTOTYPE(arrayPrototype) + + void init(); + + static ReturnedValue method_pop(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_push(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_shift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_splice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_unshift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_set_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +} + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmllocale_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmllocale_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bf790c848e8fd5c489eef9ab236da738a48daafd --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmllocale_p.h @@ -0,0 +1,249 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLOCALE_H +#define QQMLLOCALE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qqml.h> + +#include <QtCore/qlocale.h> +#include <QtCore/qobject.h> +#include <private/qtqmlglobal_p.h> +#include <private/qv4object_p.h> + +QT_REQUIRE_CONFIG(qml_locale); + +QT_BEGIN_NAMESPACE + + +class QQmlDateExtension +{ +public: + static void registerExtension(QV4::ExecutionEngine *engine); + +private: + static QV4::ReturnedValue method_toLocaleString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_toLocaleTimeString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_toLocaleDateString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_fromLocaleString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_fromLocaleTimeString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_fromLocaleDateString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_timeZoneUpdated(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); +}; + + +class QQmlNumberExtension +{ +public: + static void registerExtension(QV4::ExecutionEngine *engine); + +private: + static QV4::ReturnedValue method_toLocaleString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_fromLocaleString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue method_toLocaleCurrencyString(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); +}; + +// This needs to be a struct so that we can derive from QLocale and inherit its enums. Then we can +// use it as extension in QQmlLocaleEnums and expose all the enums in one go, without duplicating +// any in different qmltypes files. +struct Q_QML_EXPORT QQmlLocale : public QLocale +{ + Q_GADGET + QML_ANONYMOUS +public: + + // Qt defines Sunday as 7, but JS Date assigns Sunday 0 + enum DayOfWeek { + Sunday = 0, + Monday = Qt::Monday, + Tuesday = Qt::Tuesday, + Wednesday = Qt::Wednesday, + Thursday = Qt::Thursday, + Friday = Qt::Friday, + Saturday = Qt::Saturday + }; + Q_ENUM(DayOfWeek) + + static QV4::ReturnedValue locale(QV4::ExecutionEngine *engine, const QString &localeName); + static void registerStringLocaleCompare(QV4::ExecutionEngine *engine); + static QV4::ReturnedValue method_localeCompare( + const QV4::FunctionObject *, const QV4::Value *thisObject, + const QV4::Value *argv, int argc); +}; + +struct DayOfWeekList +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QList<QQmlLocale::DayOfWeek>) + QML_SEQUENTIAL_CONTAINER(QQmlLocale::DayOfWeek) +}; + +class QQmlLocaleValueType +{ + QLocale locale; + + Q_PROPERTY(QQmlLocale::DayOfWeek firstDayOfWeek READ firstDayOfWeek CONSTANT) + Q_PROPERTY(QLocale::MeasurementSystem measurementSystem READ measurementSystem CONSTANT) + Q_PROPERTY(Qt::LayoutDirection textDirection READ textDirection CONSTANT) + Q_PROPERTY(QList<QQmlLocale::DayOfWeek> weekDays READ weekDays CONSTANT) + Q_PROPERTY(QStringList uiLanguages READ uiLanguages CONSTANT) + + Q_PROPERTY(QString name READ name CONSTANT) + Q_PROPERTY(QString nativeLanguageName READ nativeLanguageName CONSTANT) +#if QT_DEPRECATED_SINCE(6, 6) + Q_PROPERTY(QString nativeCountryName READ nativeCountryName CONSTANT) +#endif + Q_PROPERTY(QString nativeTerritoryName READ nativeTerritoryName CONSTANT) + Q_PROPERTY(QString decimalPoint READ decimalPoint CONSTANT) + Q_PROPERTY(QString groupSeparator READ groupSeparator CONSTANT) + Q_PROPERTY(QString percent READ percent CONSTANT) + Q_PROPERTY(QString zeroDigit READ zeroDigit CONSTANT) + Q_PROPERTY(QString negativeSign READ negativeSign CONSTANT) + Q_PROPERTY(QString positiveSign READ positiveSign CONSTANT) + Q_PROPERTY(QString exponential READ exponential CONSTANT) + Q_PROPERTY(QString amText READ amText CONSTANT) + Q_PROPERTY(QString pmText READ pmText CONSTANT) + + Q_PROPERTY(QLocale::NumberOptions numberOptions READ numberOptions WRITE setNumberOptions) + + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QLocale) + QML_EXTENDED(QQmlLocaleValueType) + QML_CONSTRUCTIBLE_VALUE + +public: + Q_INVOKABLE QQmlLocaleValueType(const QString &name) : locale(name) {} + + Q_INVOKABLE QString currencySymbol( + QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol) const + { + return locale.currencySymbol(format); + } + + Q_INVOKABLE QString dateTimeFormat(QLocale::FormatType format = QLocale::LongFormat) const + { + return locale.dateTimeFormat(format); + } + + Q_INVOKABLE QString timeFormat(QLocale::FormatType format = QLocale::LongFormat) const + { + return locale.timeFormat(format); + } + + Q_INVOKABLE QString dateFormat(QLocale::FormatType format = QLocale::LongFormat) const + { + return locale.dateFormat(format); + } + + Q_INVOKABLE QString monthName(int index, QLocale::FormatType format = QLocale::LongFormat) const + { + // +1 added to idx because JS is 0-based, whereas QLocale months begin at 1. + return locale.monthName(index + 1, format); + } + + Q_INVOKABLE QString standaloneMonthName( + int index, QLocale::FormatType format = QLocale::LongFormat) const + { + // +1 added to idx because JS is 0-based, whereas QLocale months begin at 1. + return locale.standaloneMonthName(index + 1, format); + } + + Q_INVOKABLE QString dayName(int index, QLocale::FormatType format = QLocale::LongFormat) const + { + // 0 -> 7 as Qt::Sunday is 7, but Sunday is 0 in JS Date + return locale.dayName(index == 0 ? 7 : index, format); + } + + Q_INVOKABLE QString standaloneDayName( + int index, QLocale::FormatType format = QLocale::LongFormat) const + { + // 0 -> 7 as Qt::Sunday is 7, but Sunday is 0 in JS Date + return locale.standaloneDayName(index == 0 ? 7 : index, format); + } + + Q_INVOKABLE void formattedDataSize(QQmlV4FunctionPtr args) const; + Q_INVOKABLE QString formattedDataSize( + double bytes, int precision = 2, + QLocale::DataSizeFormats format = QLocale::DataSizeIecFormat) const + { + return locale.formattedDataSize( + qint64(QV4::Value::toInteger(bytes)), precision, format); + } + + Q_INVOKABLE void toString(QQmlV4FunctionPtr args) const; + + // As a special (undocumented) case, when called with no arguments, + // just forward to QDebug. This makes it consistent with other types + // in JS that can be converted to a string via toString(). + Q_INVOKABLE QString toString() const { return QDebug::toString(locale); } + + Q_INVOKABLE QString toString(int i) const { return locale.toString(i); } + Q_INVOKABLE QString toString(double f) const + { + return QJSNumberCoercion::isInteger(f) ? toString(int(f)) : locale.toString(f); + } + Q_INVOKABLE QString toString(double f, const QString &format, int precision = 6) const + { + // Lacking a char type, we have to use QString here + return format.length() < 1 + ? QString() + : locale.toString(f, format.at(0).toLatin1(), precision); + } + Q_INVOKABLE QString toString(const QDateTime &dateTime, const QString &format) const + { + return locale.toString(dateTime, format); + } + Q_INVOKABLE QString toString( + const QDateTime &dateTime, QLocale::FormatType format = QLocale::LongFormat) const + { + return locale.toString(dateTime, format); + } + + QQmlLocale::DayOfWeek firstDayOfWeek() const; + QLocale::MeasurementSystem measurementSystem() const { return locale.measurementSystem(); } + Qt::LayoutDirection textDirection() const { return locale.textDirection(); } + QList<QQmlLocale::DayOfWeek> weekDays() const; + QStringList uiLanguages() const { return locale.uiLanguages(); } + + QString name() const { return locale.name(); } + QString nativeLanguageName() const { return locale.nativeLanguageName(); } +#if QT_DEPRECATED_SINCE(6, 6) + QString nativeCountryName() const + { + QT_IGNORE_DEPRECATIONS(return locale.nativeCountryName();) + } +#endif + QString nativeTerritoryName() const { return locale.nativeTerritoryName(); } + QString decimalPoint() const { return locale.decimalPoint(); } + QString groupSeparator() const { return locale.groupSeparator(); } + QString percent() const { return locale.percent(); } + QString zeroDigit() const { return locale.zeroDigit(); } + QString negativeSign() const { return locale.negativeSign(); } + QString positiveSign() const { return locale.positiveSign(); } + QString exponential() const { return locale.exponential(); } + QString amText() const { return locale.amText(); } + QString pmText() const { return locale.pmText(); } + + QLocale::NumberOptions numberOptions() const { return locale.numberOptions(); } + void setNumberOptions(const QLocale::NumberOptions &numberOptions) + { + locale.setNumberOptions(numberOptions); + } +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlloggingcategorybase_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlloggingcategorybase_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fa9ed459583282afd68f220a98e43e8be266638e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlloggingcategorybase_p.h @@ -0,0 +1,47 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLOGGINGCATEGORYBASE_P_H +#define QQMLLOGGINGCATEGORYBASE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqml.h> + +#include <QtCore/qobject.h> +#include <QtCore/qloggingcategory.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlLoggingCategoryBase : public QObject +{ + Q_OBJECT + QML_ANONYMOUS + +public: + QQmlLoggingCategoryBase(QObject *parent = nullptr) : QObject(parent) {} + + const QLoggingCategory *category() const { return m_category.get(); } + void setCategory(const char *name, QtMsgType type) + { + m_category = std::make_unique<QLoggingCategory>(name, type); + } + +private: + std::unique_ptr<QLoggingCategory> m_category; +}; + +QT_END_NAMESPACE + +#endif // QQMLLOGGINGCATEGORYBASE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlmetaobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlmetaobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..da4e04df2f8cdc7df2005015bb4b7f7946ed00d6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlmetaobject_p.h @@ -0,0 +1,228 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLMETAOBJECT_P_H +#define QQMLMETAOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlpropertycache_p.h> + +#include <QtQml/qtqmlglobal.h> +#include <QtCore/qvarlengtharray.h> +#include <QtCore/qmetaobject.h> + +QT_BEGIN_NAMESPACE + +// QQmlMetaObject serves as a wrapper around either QMetaObject or QQmlPropertyCache. +// This is necessary as we delay creation of QMetaObject for synthesized QObjects, but +// we don't want to needlessly generate QQmlPropertyCaches every time we encounter a +// QObject type used in assignment or when we don't have a QQmlEngine etc. +// +// This class does NOT reference the propertycache. +class QQmlEnginePrivate; +class QQmlPropertyData; +class Q_QML_EXPORT QQmlMetaObject +{ +public: + template<qsizetype Prealloc> + using ArgTypeStorage = QVarLengthArray<QMetaType, Prealloc>; + + inline QQmlMetaObject() = default; + inline QQmlMetaObject(const QObject *); + inline QQmlMetaObject(const QMetaObject *); + inline QQmlMetaObject(const QQmlPropertyCache::ConstPtr &); + inline QQmlMetaObject(const QQmlMetaObject &); + + inline QQmlMetaObject &operator=(const QQmlMetaObject &); + + inline bool isNull() const; + + inline const char *className() const; + inline int propertyCount() const; + + inline const QMetaObject *metaObject() const; + + QMetaType methodReturnType(const QQmlPropertyData &data, QByteArray *unknownTypeError) const; + + /*! + \internal + Returns false if one of the types is unknown. Otherwise, fills \a argstorage with the + metatypes of the function. + */ + template<typename ArgTypeStorage> + bool methodParameterTypes( + int index, ArgTypeStorage *argStorage, QByteArray *unknownTypeError) const + { + Q_ASSERT(_m && index >= 0); + + QMetaMethod m = _m->method(index); + return methodParameterTypes(m, argStorage, unknownTypeError); + } + + /*! + \internal + Returns false if one of the types is unknown. Otherwise, fills \a argstorage with the + metatypes of the function. + */ + template<typename ArgTypeStorage> + bool constructorParameterTypes( + int index, ArgTypeStorage *dummy, QByteArray *unknownTypeError) const + { + QMetaMethod m = _m->constructor(index); + return methodParameterTypes(m, dummy, unknownTypeError); + } + + + static bool canConvert(const QQmlMetaObject &from, const QQmlMetaObject &to) + { + Q_ASSERT(!from.isNull() && !to.isNull()); + return from.metaObject()->inherits(to.metaObject()); + } + + // static_metacall (on Gadgets) doesn't call the base implementation and therefore + // we need a helper to find the correct meta object and property/method index. + static void resolveGadgetMethodOrPropertyIndex( + QMetaObject::Call type, const QMetaObject **metaObject, int *index); + + template<typename ArgTypeStorage> + static bool methodParameterTypes( + const QMetaMethod &method, ArgTypeStorage *argStorage, QByteArray *unknownTypeError) + { + Q_ASSERT(argStorage); + + const int argc = method.parameterCount(); + argStorage->resize(argc); + for (int ii = 0; ii < argc; ++ii) { + if (!parameterType(method, ii, unknownTypeError, [argStorage](int ii, QMetaType &&type) { + argStorage->operator[](ii) = std::forward<QMetaType>(type); + })) { + return false; + } + } + return true; + } + + template<typename ArgTypeStorage> + static bool methodReturnAndParameterTypes( + const QMetaMethod &method, ArgTypeStorage *argStorage, QByteArray *unknownTypeError) + { + Q_ASSERT(argStorage); + + const int argc = method.parameterCount(); + argStorage->resize(argc + 1); + + QMetaType type = method.returnMetaType(); + if (type.flags().testFlag(QMetaType::IsEnumeration)) + type = type.underlyingType(); + + if (!type.isValid()) { + if (unknownTypeError) + *unknownTypeError = "return type"; + return false; + } + + argStorage->operator[](0) = type; + + for (int ii = 0; ii < argc; ++ii) { + if (!parameterType( + method, ii, unknownTypeError, [argStorage](int ii, QMetaType &&type) { + argStorage->operator[](ii + 1) = std::forward<QMetaType>(type); + })) { + return false; + } + } + + return true; + } + +protected: + template<typename Store> + static bool parameterType( + const QMetaMethod &method, int ii, QByteArray *unknownTypeError, const Store &store) + { + QMetaType type = method.parameterMetaType(ii); + + // we treat enumerations as their underlying type + if (type.flags().testFlag(QMetaType::IsEnumeration)) + type = type.underlyingType(); + + if (!type.isValid()) { + if (unknownTypeError) + *unknownTypeError = method.parameterTypeName(ii); + return false; + } + + store(ii, std::move(type)); + return true; + } + + + const QMetaObject *_m = nullptr; + +}; + +QQmlMetaObject::QQmlMetaObject(const QObject *o) +{ + if (o) + _m = o->metaObject(); +} + +QQmlMetaObject::QQmlMetaObject(const QMetaObject *m) + : _m(m) +{ +} + +QQmlMetaObject::QQmlMetaObject(const QQmlPropertyCache::ConstPtr &m) +{ + if (m) + _m = m->createMetaObject(); +} + +QQmlMetaObject::QQmlMetaObject(const QQmlMetaObject &o) + : _m(o._m) +{ +} + +QQmlMetaObject &QQmlMetaObject::operator=(const QQmlMetaObject &o) +{ + _m = o._m; + return *this; +} + +bool QQmlMetaObject::isNull() const +{ + return !_m; +} + +const char *QQmlMetaObject::className() const +{ + if (!_m) + return nullptr; + return metaObject()->className(); +} + +int QQmlMetaObject::propertyCount() const +{ + if (!_m) + return 0; + return metaObject()->propertyCount(); +} + +const QMetaObject *QQmlMetaObject::metaObject() const +{ + return _m; +} + +QT_END_NAMESPACE + +#endif // QQMLMETAOBJECT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlmetatype_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlmetatype_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f4a7fbedcbf2411804f2df8b15b4b66f61426d45 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlmetatype_p.h @@ -0,0 +1,360 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLMETATYPE_P_H +#define QQMLMETATYPE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmldirparser_p.h> +#include <private/qqmlmetaobject_p.h> +#include <private/qqmlproxymetaobject_p.h> +#include <private/qqmltype_p.h> +#include <private/qtqmlglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlTypeModule; +class QRecursiveMutex; +class QQmlError; +class QQmlValueType; + +namespace QV4 { +namespace CompiledData { +struct CompilationUnit; +} +} + +class Q_QML_EXPORT QQmlMetaType +{ + friend class QQmlDesignerMetaObject; + +public: + + enum class RegistrationResult { + Success, + Failure, + NoRegistrationFunction + }; + + static QUrl inlineComponentUrl(const QUrl &baseUrl, const QString &name) + { + QUrl icUrl = baseUrl; + icUrl.setFragment(name); + return icUrl; + } + + static bool equalBaseUrls(const QUrl &aUrl, const QUrl &bUrl) + { + // Everything but fragment has to match + return aUrl.port() == bUrl.port() + && aUrl.scheme() == bUrl.scheme() + && aUrl.userName() == bUrl.userName() + && aUrl.password() == bUrl.password() + && aUrl.host() == bUrl.host() + && aUrl.path() == bUrl.path() + && aUrl.query() == bUrl.query(); + } + + enum CompositeTypeLookupMode { + NonSingleton, + Singleton, + }; + + static QQmlType findCompositeType( + const QUrl &url, + const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, + CompositeTypeLookupMode mode = NonSingleton); + static QQmlType findInlineComponentType( + const QUrl &url, + const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit); + static QQmlType findInlineComponentType( + const QUrl &baseUrl, const QString &name, + const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit) + { + return findInlineComponentType(inlineComponentUrl(baseUrl, name), compilationUnit); + } + + static void unregisterInternalCompositeType(QMetaType metaType, QMetaType listMetaType); + static QQmlType registerType(const QQmlPrivate::RegisterType &type); + static QQmlType registerInterface(const QQmlPrivate::RegisterInterface &type); + static QQmlType registerSingletonType( + const QQmlPrivate::RegisterSingletonType &type, + const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo); + static QQmlType registerCompositeSingletonType( + const QQmlPrivate::RegisterCompositeSingletonType &type, + const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo); + static QQmlType registerCompositeType(const QQmlPrivate::RegisterCompositeType &type); + static RegistrationResult registerPluginTypes(QObject *instance, const QString &basePath, + const QString &uri, const QString &typeNamespace, + QTypeRevision version, QList<QQmlError> *errors); + + static QQmlType typeForUrl(const QString &urlString, const QHashedStringRef& typeName, + CompositeTypeLookupMode mode, QList<QQmlError> *errors, + QTypeRevision version = QTypeRevision()); + + static QQmlType fetchOrCreateInlineComponentTypeForUrl(const QUrl &url); + static QQmlType inlineComponentType(const QQmlType &outerType, const QString &name) + { + return outerType.isComposite() + ? fetchOrCreateInlineComponentTypeForUrl( + inlineComponentUrl(outerType.sourceUrl(), name)) + : QQmlType(); + } + + static void unregisterType(int type); + + static void registerMetaObjectForType(const QMetaObject *metaobject, QQmlTypePrivate *type); + + static void registerModule(const char *uri, QTypeRevision version); + static bool protectModule(const QString &uri, QTypeRevision version, + bool weakProtectAllVersions = false); + + static void registerModuleImport(const QString &uri, QTypeRevision version, + const QQmlDirParser::Import &import); + static void unregisterModuleImport(const QString &uri, QTypeRevision version, + const QQmlDirParser::Import &import); + static QList<QQmlDirParser::Import> moduleImports(const QString &uri, QTypeRevision version); + + static int typeId(const char *uri, QTypeRevision version, const char *qmlName); + + static void registerUndeletableType(const QQmlType &dtype); + + static QList<QString> qmlTypeNames(); + static QList<QQmlType> qmlTypes(); + static QList<QQmlType> qmlSingletonTypes(); + static QList<QQmlType> qmlAllTypes(); + + static QQmlType qmlType(const QString &qualifiedName, QTypeRevision version); + static QQmlType qmlType(const QHashedStringRef &name, const QHashedStringRef &module, QTypeRevision version); + static QQmlType qmlType(const QMetaObject *); + static QQmlType qmlType(const QMetaObject *metaObject, const QHashedStringRef &module, QTypeRevision version); + static QQmlType qmlTypeById(int qmlTypeId); + + static QQmlType qmlType(QMetaType metaType); + static QQmlType qmlListType(QMetaType metaType); + + static QQmlType qmlType(const QUrl &unNormalizedUrl, bool includeNonFileImports = false); + + static QQmlPropertyCache::ConstPtr propertyCache( + QObject *object, QTypeRevision version = QTypeRevision()); + static QQmlPropertyCache::ConstPtr propertyCache( + const QMetaObject *metaObject, QTypeRevision version = QTypeRevision()); + static QQmlPropertyCache::ConstPtr propertyCache( + const QQmlType &type, QTypeRevision version); + + // These methods may be called from the loader thread + static QQmlMetaObject rawMetaObjectForType(QMetaType metaType); + static QQmlMetaObject metaObjectForType(QMetaType metaType); + static QQmlPropertyCache::ConstPtr propertyCacheForType(QMetaType metaType); + static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(QMetaType metaType); + static QQmlPropertyCache::ConstPtr rawPropertyCacheForType( + QMetaType metaType, QTypeRevision version); + + static void freeUnusedTypesAndCaches(); + + static QMetaProperty defaultProperty(const QMetaObject *); + static QMetaProperty defaultProperty(QObject *); + static QMetaMethod defaultMethod(const QMetaObject *); + static QMetaMethod defaultMethod(QObject *); + + static QObject *toQObject(const QVariant &, bool *ok = nullptr); + + static QMetaType listValueType(QMetaType type); + static QQmlAttachedPropertiesFunc attachedPropertiesFunc(QQmlEnginePrivate *, + const QMetaObject *); + static bool isInterface(QMetaType type); + static const char *interfaceIId(QMetaType type); + static bool isList(QMetaType type); + + static QTypeRevision latestModuleVersion(const QString &uri); + static bool isStronglyLockedModule(const QString &uri, QTypeRevision version); + static QTypeRevision matchingModuleVersion(const QString &module, QTypeRevision version); + static QQmlTypeModule *typeModule(const QString &uri, QTypeRevision version); + + static QList<QQmlPrivate::AutoParentFunction> parentFunctions(); + + enum class CachedUnitLookupError { + NoError, + NoUnitFound, + VersionMismatch, + NotFullyTyped + }; + + enum CacheMode { RejectAll, AcceptUntyped, RequireFullyTyped }; + static const QQmlPrivate::CachedQmlUnit *findCachedCompilationUnit( + const QUrl &uri, CacheMode mode, CachedUnitLookupError *status); + + // used by tst_qqmlcachegen.cpp + static void prependCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler); + static void removeCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler); + + static QString prettyTypeName(const QObject *object); + + template <typename QQmlTypeContainer> + static void removeQQmlTypePrivate(QQmlTypeContainer &container, + const QQmlTypePrivate *reference) + { + for (typename QQmlTypeContainer::iterator it = container.begin(); it != container.end();) { + if (*it == reference) + it = container.erase(it); + else + ++it; + } + } + + template <typename InlineComponentContainer> + static void removeFromInlineComponents( + InlineComponentContainer &container, const QQmlTypePrivate *reference) + { + const QUrl referenceUrl = QQmlType(reference).sourceUrl(); + for (auto it = container.begin(), end = container.end(); it != end;) { + if (equalBaseUrls(it.key(), referenceUrl)) + it = container.erase(it); + else + ++it; + } + } + + static void registerTypeAlias(int typeId, const QString &name); + + static int registerAutoParentFunction(const QQmlPrivate::RegisterAutoParent &autoparent); + static void unregisterAutoParentFunction(const QQmlPrivate::AutoParentFunction &function); + + static QQmlType registerSequentialContainer( + const QQmlPrivate::RegisterSequentialContainer &sequenceRegistration); + static void unregisterSequentialContainer(int id); + + static int registerUnitCacheHook(const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration); + static void clearTypeRegistrations(); + + static QList<QQmlProxyMetaObject::ProxyData> proxyData(const QMetaObject *mo, + const QMetaObject *baseMetaObject, + QMetaObject *lastMetaObject); + + enum ClonePolicy { + CloneAll, // default + CloneEnumsOnly, // skip properties and methods + }; + static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo, + const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd, + ClonePolicy policy); + + static void qmlInsertModuleRegistration(const QString &uri, void (*registerFunction)()); + static void qmlRemoveModuleRegistration(const QString &uri); + + static bool qmlRegisterModuleTypes(const QString &uri); + + static bool isValueType(QMetaType type); + static QQmlValueType *valueType(QMetaType metaType); + static const QMetaObject *metaObjectForValueType(QMetaType type); + + static QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t); + static void registerInternalCompositeType( + const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit); + static void unregisterInternalCompositeType( + const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit); + static int countInternalCompositeTypeSelfReferences( + const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit); + static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit( + QMetaType type); + static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit( + const QUrl &url); +}; + +Q_DECLARE_TYPEINFO(QQmlMetaType, Q_RELOCATABLE_TYPE); + +// used in QQmlListMetaType to tag the metatpye +inline const QMetaObject *dynamicQmlListMarker(const QtPrivate::QMetaTypeInterface *) { + return nullptr; +}; + +inline const QMetaObject *dynamicQmlMetaObject(const QtPrivate::QMetaTypeInterface *iface) { + return QQmlMetaType::metaObjectForType(QMetaType(iface)).metaObject(); +}; + +// metatype interface for composite QML types +struct QQmlMetaTypeInterface : QtPrivate::QMetaTypeInterface +{ + const QByteArray name; + QQmlMetaTypeInterface(const QByteArray &name) + : QMetaTypeInterface { + /*.revision=*/ QMetaTypeInterface::CurrentRevision, + /*.alignment=*/ alignof(QObject *), + /*.size=*/ sizeof(QObject *), + /*.flags=*/ QtPrivate::QMetaTypeTypeFlags<QObject *>::Flags, + /*.typeId=*/ 0, + /*.metaObjectFn=*/ &dynamicQmlMetaObject, + /*.name=*/ name.constData(), + /*.defaultCtr=*/ [](const QMetaTypeInterface *, void *addr) { + *static_cast<QObject **>(addr) = nullptr; + }, + /*.copyCtr=*/ [](const QMetaTypeInterface *, void *addr, const void *other) { + *static_cast<QObject **>(addr) = *static_cast<QObject *const *>(other); + }, + /*.moveCtr=*/ [](const QMetaTypeInterface *, void *addr, void *other) { + *static_cast<QObject **>(addr) = *static_cast<QObject **>(other); + }, + /*.dtor=*/ [](const QMetaTypeInterface *, void *) {}, + /*.equals*/ nullptr, + /*.lessThan*/ nullptr, + /*.debugStream=*/ nullptr, + /*.dataStreamOut=*/ nullptr, + /*.dataStreamIn=*/ nullptr, + /*.legacyRegisterOp=*/ nullptr + } + , name(name) { } +}; + +// metatype for qml list types +struct QQmlListMetaTypeInterface : QtPrivate::QMetaTypeInterface +{ + const QByteArray name; + // if this interface is for list<type>; valueType stores the interface for type + const QtPrivate::QMetaTypeInterface *valueType; + QQmlListMetaTypeInterface(const QByteArray &name, const QtPrivate::QMetaTypeInterface *valueType) + : QMetaTypeInterface { + /*.revision=*/ QMetaTypeInterface::CurrentRevision, + /*.alignment=*/ alignof(QQmlListProperty<QObject>), + /*.size=*/ sizeof(QQmlListProperty<QObject>), + /*.flags=*/ QtPrivate::QMetaTypeTypeFlags<QQmlListProperty<QObject>>::Flags, + /*.typeId=*/ 0, + /*.metaObjectFn=*/ &dynamicQmlListMarker, + /*.name=*/ name.constData(), + /*.defaultCtr=*/ [](const QMetaTypeInterface *, void *addr) { + new (addr) QQmlListProperty<QObject> (); + }, + /*.copyCtr=*/ [](const QMetaTypeInterface *, void *addr, const void *other) { + new (addr) QQmlListProperty<QObject>( + *static_cast<const QQmlListProperty<QObject> *>(other)); + }, + /*.moveCtr=*/ [](const QMetaTypeInterface *, void *addr, void *other) { + new (addr) QQmlListProperty<QObject>( + std::move(*static_cast<QQmlListProperty<QObject> *>(other))); + }, + /*.dtor=*/ [](const QMetaTypeInterface *, void *addr) { + static_cast<QQmlListProperty<QObject> *>(addr)->~QQmlListProperty<QObject>(); + }, + /*.equals*/ nullptr, + /*.lessThan*/ nullptr, + /*.debugStream=*/ nullptr, + /*.dataStreamOut=*/ nullptr, + /*.dataStreamIn=*/ nullptr, + /*.legacyRegisterOp=*/ nullptr + } + , name(name), valueType(valueType) { } +}; + +QT_END_NAMESPACE + +#endif // QQMLMETATYPE_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlmetatypedata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlmetatypedata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f3b2874451457bb2000c93d67abb155aaa099ba6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlmetatypedata_p.h @@ -0,0 +1,131 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLMETATYPEDATA_P_H +#define QQMLMETATYPEDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmltype_p.h> +#include <private/qqmlmetatype_p.h> +#include <private/qhashedstring_p.h> +#include <private/qqmlvaluetype_p.h> + +#include <QtCore/qset.h> +#include <QtCore/qvector.h> + +QT_BEGIN_NAMESPACE + +class QQmlTypePrivate; +struct QQmlMetaTypeData +{ + QQmlMetaTypeData(); + ~QQmlMetaTypeData(); + void registerType(QQmlTypePrivate *priv); + QList<QQmlType> types; + QSet<QQmlType> undeletableTypes; + typedef QHash<int, QQmlTypePrivate *> Ids; + Ids idToType; + + using Names = QMultiHash<QHashedString, const QQmlTypePrivate *>; + Names nameToType; + + typedef QHash<QUrl, const QQmlTypePrivate *> Files; //For file imported composite types only + Files urlToType; + Files urlToNonFileImportType; // For non-file imported composite and composite + // singleton types. This way we can locate any + // of them by url, even if it was registered as + // a module via QQmlPrivate::RegisterCompositeType + typedef QMultiHash<const QMetaObject *, QQmlTypePrivate *> MetaObjects; + MetaObjects metaObjectToType; + QVector<QHash<QTypeRevision, QQmlPropertyCache::ConstPtr>> typePropertyCaches; + QHash<int, QQmlValueType *> metaTypeToValueType; + + using CompositeTypes = QHash<const QtPrivate::QMetaTypeInterface *, + QQmlRefPointer<QV4::CompiledData::CompilationUnit>>; + CompositeTypes compositeTypes; + QHash<QUrl, QQmlType> inlineComponentTypes; + + struct VersionedUri { + VersionedUri() = default; + VersionedUri(const QString &uri, QTypeRevision version) + : uri(uri), majorVersion(version.majorVersion()) {} + VersionedUri(const std::unique_ptr<QQmlTypeModule> &module); + + friend bool operator==(const VersionedUri &a, const VersionedUri &b) + { + return a.majorVersion == b.majorVersion && a.uri == b.uri; + } + + friend size_t qHash(const VersionedUri &v, size_t seed = 0) + { + return qHashMulti(seed, v.uri, v.majorVersion); + } + + friend bool operator<(const QQmlMetaTypeData::VersionedUri &a, + const QQmlMetaTypeData::VersionedUri &b) + { + const int diff = a.uri.compare(b.uri); + return diff < 0 || (diff == 0 && a.majorVersion < b.majorVersion); + } + + QString uri; + quint8 majorVersion = 0; + }; + + typedef std::vector<std::unique_ptr<QQmlTypeModule>> TypeModules; + TypeModules uriToModule; + QQmlTypeModule *findTypeModule(const QString &module, QTypeRevision version); + QQmlTypeModule *addTypeModule(std::unique_ptr<QQmlTypeModule> module); + + using ModuleImports = QMultiMap<VersionedUri, QQmlDirParser::Import>; + ModuleImports moduleImports; + + QHash<QString, void (*)()> moduleTypeRegistrationFunctions; + bool registerModuleTypes(const QString &uri); + + QSet<int> interfaces; + + QList<QQmlPrivate::AutoParentFunction> parentFunctions; + QVector<QQmlPrivate::QmlUnitCacheLookupFunction> lookupCachedQmlUnit; + + QHash<const QMetaObject *, QQmlPropertyCache::ConstPtr> propertyCaches; + + QQmlPropertyCache::ConstPtr propertyCacheForVersion(int index, QTypeRevision version) const; + void setPropertyCacheForVersion( + int index, QTypeRevision version, const QQmlPropertyCache::ConstPtr &cache); + void clearPropertyCachesForVersion(int index); + + QQmlPropertyCache::ConstPtr propertyCache(const QMetaObject *metaObject, QTypeRevision version); + QQmlPropertyCache::ConstPtr propertyCache(const QQmlType &type, QTypeRevision version); + QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t) const; + + void setTypeRegistrationFailures(QStringList *failures) + { + m_typeRegistrationFailures = failures; + } + + void recordTypeRegFailure(const QString &message) + { + if (m_typeRegistrationFailures) + m_typeRegistrationFailures->append(message); + else + qWarning("%s", message.toUtf8().constData()); + } + +private: + QStringList *m_typeRegistrationFailures = nullptr; +}; + +QT_END_NAMESPACE + +#endif // QQMLMETATYPEDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlnotifier_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlnotifier_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ee2a536adf23901790ae44a6b6c8408c98dd8f66 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlnotifier_p.h @@ -0,0 +1,263 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLNOTIFIER_P_H +#define QQMLNOTIFIER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qmetaobject.h> +#include <private/qmetaobject_p.h> +#include <private/qtqmlglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlNotifierEndpoint; +class QQmlData; +class Q_QML_EXPORT QQmlNotifier +{ +public: + inline QQmlNotifier(); + inline ~QQmlNotifier(); + inline void notify(); + + static void notify(QQmlData *ddata, int notifierIndex); + +private: + friend class QQmlData; + friend class QQmlNotifierEndpoint; + friend class QQmlThreadNotifierProxyObject; + + static void emitNotify(QQmlNotifierEndpoint *, void **a); + QQmlNotifierEndpoint *endpoints = nullptr; +}; + +class QQmlEngine; +class QQmlNotifierEndpoint +{ + QQmlNotifierEndpoint *next; + QQmlNotifierEndpoint **prev; +public: + // QQmlNotifierEndpoint can only invoke one of a set of pre-defined callbacks. + // To add another callback, extend this enum and add the callback to the top + // of qqmlnotifier.cpp. Four bits are reserved for the callback, so there can + // be up to 15 of them (0 is reserved). + enum Callback { + None = 0, + QQmlBoundSignal = 1, + QQmlJavaScriptExpressionGuard = 2, + QQmlVMEMetaObjectEndpoint = 3, + QQmlPropertyGuard = 4, + }; + + inline QQmlNotifierEndpoint(Callback callback); + inline ~QQmlNotifierEndpoint(); + + inline bool isConnected() const; + inline bool isConnected(QObject *source, int sourceSignal) const; + inline bool isConnected(QQmlNotifier *) const; + + void connect(QObject *source, int sourceSignal, QQmlEngine *engine, bool doNotify = true); + inline void connect(QQmlNotifier *); + inline void disconnect(); + + inline bool isNotifying() const; + inline void startNotifying(qintptr *originalSenderPtr); + inline void stopNotifying(qintptr *originalSenderPtr); + + inline void cancelNotify(); + + inline int signalIndex() const { return sourceSignal; } + + inline qintptr sender() const; + inline void setSender(qintptr sender); + + inline QObject *senderAsObject() const; + inline QQmlNotifier *senderAsNotifier() const; + +private: + friend class QQmlData; + friend class QQmlNotifier; + + // Contains either the QObject*, or the QQmlNotifier* that this + // endpoint is connected to. While the endpoint is notifying, the + // senderPtr points to another qintptr that contains this value. + qintptr senderPtr; + + Callback callback:4; + int needsConnectNotify:1; + // The index is in the range returned by QObjectPrivate::signalIndex(). + // This is different from QMetaMethod::methodIndex(). + signed int sourceSignal:27; +}; + +QQmlNotifier::QQmlNotifier() +{ +} + +QQmlNotifier::~QQmlNotifier() +{ + QQmlNotifierEndpoint *endpoint = endpoints; + while (endpoint) { + QQmlNotifierEndpoint *n = endpoint; + endpoint = n->next; + n->setSender(0x0); + n->next = nullptr; + n->prev = nullptr; + n->sourceSignal = -1; + } + endpoints = nullptr; +} + +void QQmlNotifier::notify() +{ + void *args[] = { nullptr }; + if (endpoints) emitNotify(endpoints, args); +} + +QQmlNotifierEndpoint::QQmlNotifierEndpoint(Callback callback) +: next(nullptr), prev(nullptr), senderPtr(0), callback(callback), needsConnectNotify(false), sourceSignal(-1) +{ +} + +QQmlNotifierEndpoint::~QQmlNotifierEndpoint() +{ + disconnect(); +} + +bool QQmlNotifierEndpoint::isConnected() const +{ + return prev != nullptr; +} + +/*! \internal + \a sourceSignal MUST be in the signal index range (see QObjectPrivate::signalIndex()). + This is different from QMetaMethod::methodIndex(). +*/ +bool QQmlNotifierEndpoint::isConnected(QObject *source, int sourceSignal) const +{ + return this->sourceSignal != -1 && senderAsObject() == source && + this->sourceSignal == sourceSignal; +} + +bool QQmlNotifierEndpoint::isConnected(QQmlNotifier *notifier) const +{ + return sourceSignal == -1 && senderAsNotifier() == notifier; +} + +void QQmlNotifierEndpoint::connect(QQmlNotifier *notifier) +{ + disconnect(); + + next = notifier->endpoints; + if (next) { next->prev = &next; } + notifier->endpoints = this; + prev = ¬ifier->endpoints; + setSender(qintptr(notifier)); +} + +void QQmlNotifierEndpoint::disconnect() +{ + // Remove from notifier chain before calling disconnectNotify(), so that that + // QObject::receivers() returns the correct value in there + if (next) next->prev = prev; + if (prev) *prev = next; + + if (sourceSignal != -1 && needsConnectNotify) { + QObject * const obj = senderAsObject(); + Q_ASSERT(obj); + QObjectPrivate * const priv = QObjectPrivate::get(obj); + + // In some degenerate cases an object being destructed might be unable + // to produce a metaObject(). Therefore we check here. + if (const QMetaObject *mo = obj->metaObject()) + priv->disconnectNotify(QMetaObjectPrivate::signal(mo, sourceSignal)); + } + + setSender(0x0); + next = nullptr; + prev = nullptr; + sourceSignal = -1; +} + +/*! +Returns true if a notify is in progress. This means that the signal or QQmlNotifier +that this endpoing is connected to has been triggered, but this endpoint's callback has not +yet been called. + +An in progress notify can be cancelled by calling cancelNotify. +*/ +bool QQmlNotifierEndpoint::isNotifying() const +{ + return senderPtr & 0x1; +} + +void QQmlNotifierEndpoint::startNotifying(qintptr *originalSenderPtr) +{ + Q_ASSERT(*originalSenderPtr == 0); + // Set the endpoint to notifying: + // - Save the original senderPtr, + *originalSenderPtr = senderPtr; + // - Take a pointer of it, + // - And assign that to the senderPtr, including a flag to signify "notifying". + senderPtr = qintptr(originalSenderPtr) | 0x1; +} + +void QQmlNotifierEndpoint::stopNotifying(qintptr *originalSenderPtr) +{ + // End of notifying, restore values + Q_ASSERT((senderPtr & ~0x1) == qintptr(originalSenderPtr)); + senderPtr = *originalSenderPtr; + *originalSenderPtr = 0; +} + +/*! +Cancel any notifies that are in progress. +*/ +void QQmlNotifierEndpoint::cancelNotify() +{ + if (isNotifying()) { + auto *ptr = (qintptr *)(senderPtr & ~0x1); + Q_ASSERT(ptr); + senderPtr = *ptr; + *ptr = 0; + } +} + +qintptr QQmlNotifierEndpoint::sender() const +{ + return isNotifying() ? *(qintptr *)(senderPtr & ~0x1) : senderPtr; +} + +void QQmlNotifierEndpoint::setSender(qintptr sender) +{ + // If we're just notifying, we write through to the originalSenderPtr + if (isNotifying()) + *(qintptr *)(senderPtr & ~0x1) = sender; + else + senderPtr = sender; +} + +QObject *QQmlNotifierEndpoint::senderAsObject() const +{ + return (QObject *)(sender()); +} + +QQmlNotifier *QQmlNotifierEndpoint::senderAsNotifier() const +{ + return (QQmlNotifier *)(sender()); +} + +QT_END_NAMESPACE + +#endif // QQMLNOTIFIER_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlnullablevalue_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlnullablevalue_p.h new file mode 100644 index 0000000000000000000000000000000000000000..82a9c5766d863a4f99e8dae55cb254c091dde49a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlnullablevalue_p.h @@ -0,0 +1,92 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLNULLABLEVALUE_P_H +#define QQMLNULLABLEVALUE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +template<typename T> +struct QQmlNullableValue +{ + QQmlNullableValue() = default; + + QQmlNullableValue(const QQmlNullableValue<T> &o) + : m_value(o.m_value) + , m_isNull(o.m_isNull) + {} + + QQmlNullableValue(QQmlNullableValue<T> &&o) noexcept + : m_value(std::move(o.m_value)) + , m_isNull(std::exchange(o.m_isNull, true)) + {} + + QQmlNullableValue(const T &t) + : m_value(t) + , m_isNull(false) + {} + + QQmlNullableValue(T &&t) noexcept + : m_value(std::move(t)) + , m_isNull(false) + {} + + QQmlNullableValue<T> &operator=(const QQmlNullableValue<T> &o) + { + if (&o != this) { + m_value = o.m_value; + m_isNull = o.m_isNull; + } + return *this; + } + + QQmlNullableValue<T> &operator=(QQmlNullableValue<T> &&o) noexcept + { + if (&o != this) { + m_value = std::move(o.m_value); + m_isNull = std::exchange(o.m_isNull, true); + } + return *this; + } + + QQmlNullableValue<T> &operator=(const T &t) + { + m_value = t; + m_isNull = false; + return *this; + } + + QQmlNullableValue<T> &operator=(T &&t) noexcept + { + m_value = std::move(t); + m_isNull = false; + return *this; + } + + const T &value() const { return m_value; } + operator T() const { return m_value; } + + void invalidate() { m_isNull = true; } + bool isValid() const { return !m_isNull; } + +private: + T m_value = T(); + bool m_isNull = true; +}; + +QT_END_NAMESPACE + +#endif // QQMLNULLABLEVALUE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlobjectcreator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlobjectcreator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..89fb9e58d6e50752f99fac701af155c0adc5e967 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlobjectcreator_p.h @@ -0,0 +1,342 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQMLOBJECTCREATOR_P_H +#define QQMLOBJECTCREATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlimport_p.h> +#include <private/qqmltypenamecache_p.h> +#include <private/qv4compileddata_p.h> +#include <private/qfinitestack_p.h> +#include <private/qrecursionwatcher_p.h> +#include <private/qqmlprofiler_p.h> +#include <private/qv4qmlcontext_p.h> +#include <private/qqmlguardedcontextdata_p.h> +#include <private/qqmlfinalizer_p.h> +#include <private/qqmlvmemetaobject_p.h> + +#include <qpointer.h> + +QT_BEGIN_NAMESPACE + +class QQmlAbstractBinding; +class QQmlInstantiationInterrupt; +class QQmlIncubatorPrivate; + +struct AliasToRequiredInfo { + QString propertyName; + QUrl fileUrl; +}; + +/*! +\internal +This struct contains information solely used for displaying error messages +\variable aliasesToRequired allows us to give the user a way to know which (aliasing) properties +can be set to set the required property +\sa QQmlComponentPrivate::unsetRequiredPropertyToQQmlError +*/ +struct RequiredPropertyInfo +{ + QString propertyName; + QUrl fileUrl; + QV4::CompiledData::Location location; + QVector<AliasToRequiredInfo> aliasesToRequired; +}; + +struct RequiredPropertyKey +{ + RequiredPropertyKey() = default; + RequiredPropertyKey(const QObject *object, const QQmlPropertyData *data) + : object(object) + , data(data) + {} + + const QObject *object = nullptr; + const QQmlPropertyData *data = nullptr; + +private: + friend size_t qHash(const RequiredPropertyKey &key, size_t seed = 0) + { + return qHashMulti(seed, key.object, key.data); + } + + friend bool operator==(const RequiredPropertyKey &a, const RequiredPropertyKey &b) + { + return a.object == b.object && a.data == b.data; + } +}; + +class RequiredProperties : public QHash<RequiredPropertyKey, RequiredPropertyInfo> {}; + +class RequiredPropertiesAndTarget : public RequiredProperties +{ +public: + RequiredPropertiesAndTarget(QObject *target) : target(target) {} + RequiredPropertiesAndTarget(const RequiredPropertiesAndTarget &) = default; + RequiredPropertiesAndTarget(RequiredPropertiesAndTarget &&) = default; + RequiredPropertiesAndTarget &operator=(const RequiredPropertiesAndTarget &) = default; + RequiredPropertiesAndTarget &operator=(RequiredPropertiesAndTarget &&) = default; + QObject *target = nullptr; +}; + +struct DeferredQPropertyBinding { + QObject *target = nullptr; + int properyIndex = -1; + QUntypedPropertyBinding binding; +}; + +class ObjectInCreationGCAnchorList { +public: + // this is a non owning view, rule of zero applies + ObjectInCreationGCAnchorList() = default; + ObjectInCreationGCAnchorList(const QV4::Scope &scope, int totalObjectCount) + { + allJavaScriptObjects = scope.alloc(totalObjectCount); + } + void trackObject(QV4::ExecutionEngine *engine, QObject *instance); + bool canTrack() const { return allJavaScriptObjects; } +private: + QV4::Value *allJavaScriptObjects = nullptr; // pointer to vector on JS stack to reference JS wrappers during creation phase. +}; + +struct QQmlObjectCreatorSharedState final : QQmlRefCounted<QQmlObjectCreatorSharedState> +{ + QQmlRefPointer<QQmlContextData> rootContext; + QQmlRefPointer<QQmlContextData> creationContext; + QFiniteStack<QQmlAbstractBinding::Ptr> allCreatedBindings; + QFiniteStack<QQmlParserStatus*> allParserStatusCallbacks; + QFiniteStack<QQmlGuard<QObject> > allCreatedObjects; + ObjectInCreationGCAnchorList allJavaScriptObjects; // pointer to vector on JS stack to reference JS wrappers during creation phase. + QQmlComponentAttached *componentAttached; + QList<QQmlFinalizerHook *> finalizeHooks; + QQmlVmeProfiler profiler; + QRecursionNode recursionNode; + RequiredProperties requiredProperties; + QList<DeferredQPropertyBinding> allQPropertyBindings; + bool hadTopLevelRequiredProperties; +}; + +class Q_QML_EXPORT QQmlObjectCreator +{ + Q_DECLARE_TR_FUNCTIONS(QQmlObjectCreator) +public: + QQmlObjectCreator( + const QQmlRefPointer<QQmlContextData> &parentContext, + const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, + const QQmlRefPointer<QQmlContextData> &creationContext, + QQmlIncubatorPrivate *incubator = nullptr); + ~QQmlObjectCreator(); + + enum CreationFlags { NormalObject = 1, InlineComponent = 2 }; + QObject *create(int subComponentIndex = -1, QObject *parent = nullptr, + QQmlInstantiationInterrupt *interrupt = nullptr, int flags = NormalObject); + + bool populateDeferredProperties(QObject *instance, const QQmlData::DeferredData *deferredData); + + void beginPopulateDeferred(const QQmlRefPointer<QQmlContextData> &context); + void populateDeferredBinding(const QQmlProperty &qmlProperty, int deferredIndex, + const QV4::CompiledData::Binding *binding); + void populateDeferredInstance(QObject *outerObject, int deferredIndex, + int index, QObject *instance, QObject *bindingTarget, + const QQmlPropertyData *valueTypeProperty, + const QV4::CompiledData::Binding *binding = nullptr); + void finalizePopulateDeferred(); + + bool finalize(QQmlInstantiationInterrupt &interrupt); + void clear(); + + QQmlRefPointer<QQmlContextData> rootContext() const { return sharedState->rootContext; } + QQmlComponentAttached **componentAttachment() { return &sharedState->componentAttached; } + + QList<QQmlError> errors; + + QQmlRefPointer<QQmlContextData> parentContextData() const + { + return parentContext.contextData(); + } + QFiniteStack<QQmlGuard<QObject> > &allCreatedObjects() { return sharedState->allCreatedObjects; } + + RequiredProperties *requiredProperties() {return &sharedState->requiredProperties;} + bool componentHadTopLevelRequiredProperties() const {return sharedState->hadTopLevelRequiredProperties;} + + static QQmlComponent *createComponent(QQmlEngine *engine, + QV4::ExecutableCompilationUnit *compilationUnit, + int index, QObject *parent, + const QQmlRefPointer<QQmlContextData> &context); + + void removePendingBinding(QObject *target, int propertyIndex) + { + QList<DeferredQPropertyBinding> &pendingBindings = sharedState.data()->allQPropertyBindings; + pendingBindings.removeIf([&](const DeferredQPropertyBinding &deferred) { + return deferred.properyIndex == propertyIndex && deferred.target == target; + }); + } + +private: + QQmlObjectCreator( + const QQmlRefPointer<QQmlContextData> &contextData, + const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, + QQmlObjectCreatorSharedState *inheritedSharedState, bool isContextObject); + + void init(const QQmlRefPointer<QQmlContextData> &parentContext); + + QObject *createInstance(int index, QObject *parent = nullptr, bool isContextObject = false); + + bool populateInstance(int index, QObject *instance, QObject *bindingTarget, + const QQmlPropertyData *valueTypeProperty, + const QV4::CompiledData::Binding *binding = nullptr); + + // If qmlProperty and binding are null, populate all properties, otherwise only the given one. + void populateDeferred(QObject *instance, int deferredIndex); + void populateDeferred(QObject *instance, int deferredIndex, + const QQmlPropertyPrivate *qmlProperty, + const QV4::CompiledData::Binding *binding); + + enum BindingMode { + ApplyNone = 0x0, + ApplyImmediate = 0x1, + ApplyDeferred = 0x2, + ApplyAll = ApplyImmediate | ApplyDeferred, + }; + Q_DECLARE_FLAGS(BindingSetupFlags, BindingMode); + + void setupBindings(BindingSetupFlags mode = BindingMode::ApplyImmediate); + bool setPropertyBinding(const QQmlPropertyData *property, const QV4::CompiledData::Binding *binding); + void setPropertyValue(const QQmlPropertyData *property, const QV4::CompiledData::Binding *binding); + void setupFunctions(); + + QString stringAt(int idx) const { return compilationUnit->stringAt(idx); } + void recordError(const QV4::CompiledData::Location &location, const QString &description); + + void registerObjectWithContextById(const QV4::CompiledData::Object *object, QObject *instance) const; + + inline QV4::QmlContext *currentQmlContext(); + QV4::ResolvedTypeReference *resolvedType(int id) const + { + return compilationUnit->resolvedType(id); + } + + enum Phase { + Startup, + CreatingObjects, + CreatingObjectsPhase2, + ObjectsCreated, + Finalizing, + Done + } phase; + + QQmlEngine *engine; + QV4::ExecutionEngine *v4; + QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit; + const QV4::CompiledData::Unit *qmlUnit; + QQmlGuardedContextData parentContext; + QQmlRefPointer<QQmlContextData> context; + const QQmlPropertyCacheVector *propertyCaches; + QQmlRefPointer<QQmlObjectCreatorSharedState> sharedState; + bool topLevelCreator; + bool isContextObject; + QQmlIncubatorPrivate *incubator; + + QObject *_qobject; + QObject *_scopeObject; + QObject *_bindingTarget; + + const QQmlPropertyData *_valueTypeProperty; // belongs to _qobjectForBindings's property cache + int _compiledObjectIndex; + const QV4::CompiledData::Object *_compiledObject; + QQmlData *_ddata; + QQmlPropertyCache::ConstPtr _propertyCache; + QQmlVMEMetaObject *_vmeMetaObject; + QQmlListProperty<void> _currentList; + QV4::QmlContext *_qmlContext; + + friend struct QQmlObjectCreatorRecursionWatcher; + + typedef std::function<bool(QQmlObjectCreatorSharedState *sharedState)> PendingAliasBinding; + std::vector<PendingAliasBinding> pendingAliasBindings; + + template<typename Functor> + void doPopulateDeferred(QObject *instance, int deferredIndex, Functor f) + { + QQmlData *declarativeData = QQmlData::get(instance); + + // We're in the process of creating the object. We sure hope it's still alive. + Q_ASSERT(declarativeData && declarativeData->propertyCache); + + QObject *bindingTarget = instance; + + QQmlPropertyCache::ConstPtr cache = declarativeData->propertyCache; + QQmlVMEMetaObject *vmeMetaObject = QQmlVMEMetaObject::get(instance); + + QObject *scopeObject = instance; + qt_ptr_swap(_scopeObject, scopeObject); + + QV4::Scope valueScope(v4); + QScopedValueRollback<ObjectInCreationGCAnchorList> jsObjectGuard( + sharedState->allJavaScriptObjects, + ObjectInCreationGCAnchorList(valueScope, compilationUnit->totalObjectCount())); + + Q_ASSERT(topLevelCreator); + QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc()); + + qt_ptr_swap(_qmlContext, qmlContext); + + _propertyCache.swap(cache); + qt_ptr_swap(_qobject, instance); + + int objectIndex = deferredIndex; + std::swap(_compiledObjectIndex, objectIndex); + + const QV4::CompiledData::Object *obj = compilationUnit->objectAt(_compiledObjectIndex); + qt_ptr_swap(_compiledObject, obj); + qt_ptr_swap(_ddata, declarativeData); + qt_ptr_swap(_bindingTarget, bindingTarget); + qt_ptr_swap(_vmeMetaObject, vmeMetaObject); + + f(); + + qt_ptr_swap(_vmeMetaObject, vmeMetaObject); + qt_ptr_swap(_bindingTarget, bindingTarget); + qt_ptr_swap(_ddata, declarativeData); + qt_ptr_swap(_compiledObject, obj); + std::swap(_compiledObjectIndex, objectIndex); + qt_ptr_swap(_qobject, instance); + _propertyCache.swap(cache); + + qt_ptr_swap(_qmlContext, qmlContext); + qt_ptr_swap(_scopeObject, scopeObject); + } +}; + +struct QQmlObjectCreatorRecursionWatcher +{ + QQmlObjectCreatorRecursionWatcher(QQmlObjectCreator *creator); + + bool hasRecursed() const { return watcher.hasRecursed(); } + +private: + QQmlRefPointer<QQmlObjectCreatorSharedState> sharedState; + QRecursionWatcher<QQmlObjectCreatorSharedState, &QQmlObjectCreatorSharedState::recursionNode> watcher; +}; + +QV4::QmlContext *QQmlObjectCreator::currentQmlContext() +{ + if (!_qmlContext->isManaged()) + _qmlContext->setM(QV4::QmlContext::create(v4->rootContext(), context, _scopeObject)); + + return _qmlContext; +} + +QT_END_NAMESPACE + +#endif // QQMLOBJECTCREATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlobjectorgadget_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlobjectorgadget_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f7a1e82a2d8d566486fb1c9a0055ad0ded66709c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlobjectorgadget_p.h @@ -0,0 +1,49 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLOBJECTORGADGET_P_H +#define QQMLOBJECTORGADGET_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlmetaobject_p.h> +#include <private/qbipointer_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlObjectOrGadget: public QQmlMetaObject +{ +public: + QQmlObjectOrGadget(QObject *obj) + : QQmlMetaObject(obj), + ptr(obj) + {} + QQmlObjectOrGadget(const QMetaObject *metaObject, void *gadget) + : QQmlMetaObject(metaObject) + , ptr(gadget) + {} + QQmlObjectOrGadget(const QMetaObject* metaObject) + : QQmlMetaObject(metaObject) + {} + + void metacall(QMetaObject::Call type, int index, void **argv) const; + + bool isNull() const { return ptr.isNull(); } + QObject *qObject() const { return ptr.isT1() ? ptr.asT1() : nullptr; } + +private: + QBiPointer<QObject, void> ptr; +}; + +QT_END_NAMESPACE + +#endif // QQMLOBJECTORGADGET_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlopenmetaobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlopenmetaobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d768875b816d365375d9e8b4bb34af1c4293fd3e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlopenmetaobject_p.h @@ -0,0 +1,114 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLOPENMETAOBJECT_H +#define QQMLOPENMETAOBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/QMetaObject> +#include <QtCore/QObject> + +#include <private/qobject_p.h> +#include <private/qqmlrefcount_p.h> +#include <private/qtqmlglobal_p.h> +#include <private/qqmlpropertycache_p.h> + +QT_BEGIN_NAMESPACE + + +class QQmlEngine; +class QMetaPropertyBuilder; +class QQmlOpenMetaObjectTypePrivate; +class Q_QML_EXPORT QQmlOpenMetaObjectType final + : public QQmlRefCounted<QQmlOpenMetaObjectType> +{ +public: + QQmlOpenMetaObjectType(const QMetaObject *base); + ~QQmlOpenMetaObjectType(); + + void createProperties(const QVector<QByteArray> &names); + int createProperty(const QByteArray &name); + + int propertyOffset() const; + int signalOffset() const; + + int propertyCount() const; + QByteArray propertyName(int) const; + + QQmlPropertyCache::Ptr cache() const; + +protected: + virtual void propertyCreated(int, QMetaPropertyBuilder &); + +private: + QQmlOpenMetaObjectTypePrivate *d; + friend class QQmlOpenMetaObject; + friend class QQmlOpenMetaObjectPrivate; +}; + +class QQmlOpenMetaObjectPrivate; +class Q_QML_EXPORT QQmlOpenMetaObject : public QAbstractDynamicMetaObject +{ +public: + QQmlOpenMetaObject(QObject *, const QMetaObject * = nullptr); + QQmlOpenMetaObject(QObject *, const QQmlRefPointer<QQmlOpenMetaObjectType> &); + ~QQmlOpenMetaObject() override; + + QVariant value(const QByteArray &) const; + bool setValue(const QByteArray &, const QVariant &, bool force = false); + void setValues(const QHash<QByteArray, QVariant> &, bool force = false); + QVariant value(int) const; + void setValue(int, const QVariant &); + QVariant &valueRef(const QByteArray &); + bool hasValue(int) const; + + int count() const; + QByteArray name(int) const; + + QObject *object() const; + virtual QVariant initialValue(int); + + // Be careful - once setCached(true) is called createProperty() is no + // longer automatically called for new properties. + void setCached(bool); + + bool autoCreatesProperties() const; + void setAutoCreatesProperties(bool autoCreate); + + QQmlOpenMetaObjectType *type() const; + QDynamicMetaObjectData *parent() const; + + void emitPropertyNotification(const QByteArray &propertyName); + void unparent(); + +protected: + int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override; + int createProperty(const char *, const char *) override; + + virtual void propertyRead(int); + virtual void propertyWrite(int); + virtual QVariant propertyWriteValue(int, const QVariant &); + virtual void propertyWritten(int); + virtual void propertyCreated(int, QMetaPropertyBuilder &); + + + bool checkedSetValue(int index, const QVariant &value, bool force); + +private: + QQmlOpenMetaObjectPrivate *d; + friend class QQmlOpenMetaObjectType; +}; + +QT_END_NAMESPACE + +#endif // QQMLOPENMETAOBJECT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlplatform_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlplatform_p.h new file mode 100644 index 0000000000000000000000000000000000000000..58138683c7a4ca2bb57d2a16f657f13e4fccb671 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlplatform_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPLATFORM_P_H +#define QQMLPLATFORM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/QObject> +#include <qqml.h> +#include <private/qtqmlglobal_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlPlatform : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString os READ os CONSTANT) + Q_PROPERTY(QString pluginName READ pluginName CONSTANT) + QML_ANONYMOUS + +public: + explicit QQmlPlatform(QObject *parent = nullptr); + virtual ~QQmlPlatform(); + + static QString os(); + QString pluginName() const; + +private: + Q_DISABLE_COPY(QQmlPlatform) +}; + +QT_END_NAMESPACE + +#endif // QQMLPLATFORM_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpluginimporter_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpluginimporter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fe8b06c9d38e8bd79213273618f68b688d6ba9a5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpluginimporter_p.h @@ -0,0 +1,81 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPLUGINIMPORTER_P_H +#define QQMLPLUGINIMPORTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> +#include <private/qqmlimport_p.h> +#include <private/qqmltypeloaderqmldircontent_p.h> + +#include <QtCore/qjsonarray.h> +#include <QtCore/qplugin.h> +#include <QtCore/qversionnumber.h> + +QT_BEGIN_NAMESPACE + +class QQmlPluginImporter +{ + Q_DISABLE_COPY_MOVE(QQmlPluginImporter) + +public: + QQmlPluginImporter(const QString &uri, QTypeRevision version, QQmlImportDatabase *database, + const QQmlTypeLoaderQmldirContent *qmldir, QQmlTypeLoader *typeLoader, + QList<QQmlError> *errors) + : uri(uri) + , qmldirPath(truncateToDirectory(qmldir->qmldirLocation())) + , qmldir(qmldir) + , database(database) + , typeLoader(typeLoader) + , errors(errors) + , version(version) + {} + + ~QQmlPluginImporter() = default; + + QTypeRevision importDynamicPlugin( + const QString &filePath, const QString &pluginId, bool optional); + QTypeRevision importStaticPlugin(QObject *instance, const QString &pluginId); + QTypeRevision importPlugins(); + + static bool removePlugin(const QString &pluginId); + static QStringList plugins(); + +private: + struct StaticPluginData { + QStaticPlugin plugin; + QJsonArray uriList; + }; + + static QString truncateToDirectory(const QString &qmldirFilePath); + bool populatePluginDataVector(QVector<StaticPluginData> &result, + const QStringList &versionUris); + + QString resolvePlugin(const QString &qmldirPluginPath, const QString &baseName); + void finalizePlugin(QObject *instance, const QString &path); + + const QString uri; + const QString qmldirPath; + + const QQmlTypeLoaderQmldirContent *qmldir = nullptr; + QQmlImportDatabase *database = nullptr; + QQmlTypeLoader *typeLoader = nullptr; + QList<QQmlError> *errors = nullptr; + + const QTypeRevision version; +}; + +QT_END_NAMESPACE + +#endif // QQMLPLUGINIMPORTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlprofiler_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlprofiler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0ae18b7cea7eff846ce84f26b2f1878221ed013f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlprofiler_p.h @@ -0,0 +1,501 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROFILER_P_H +#define QQMLPROFILER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qfinitestack_p.h> +#include <private/qqmlbinding_p.h> +#include <private/qqmlboundsignal_p.h> +#include <private/qqmlglobal_p.h> +#include <private/qv4function_p.h> + +#if QT_CONFIG(qml_debug) +#include "qqmlprofilerdefinitions_p.h" +#endif + +#include <QtCore/qurl.h> +#include <QtCore/qstring.h> + +QT_BEGIN_NAMESPACE + +#if !QT_CONFIG(qml_debug) + +#define Q_QML_PROFILE_IF_ENABLED(feature, profiler, Code) +#define Q_QML_PROFILE(feature, profiler, Method) +#define Q_QML_OC_PROFILE(member, Code) + +class QQmlProfiler {}; + +struct QQmlBindingProfiler +{ + QQmlBindingProfiler(quintptr, QV4::Function *) {} +}; + +struct QQmlHandlingSignalProfiler +{ + QQmlHandlingSignalProfiler(quintptr, QQmlBoundSignalExpression *) {} +}; + +struct QQmlCompilingProfiler +{ + QQmlCompilingProfiler(quintptr, QQmlDataBlob *) {} +}; + +struct QQmlVmeProfiler { + QQmlVmeProfiler() {} + + void init(quintptr, int) {} + + const QV4::CompiledData::Object *pop() { return nullptr; } + void push(const QV4::CompiledData::Object *) {} + + static const quintptr profiler = 0; +}; + +struct QQmlObjectCreationProfiler +{ + QQmlObjectCreationProfiler(quintptr, const QV4::CompiledData::Object *) {} + void update(QV4::CompiledData::CompilationUnit *, const QV4::CompiledData::Object *, + const QString &, const QUrl &) {} +}; + +struct QQmlObjectCompletionProfiler +{ + QQmlObjectCompletionProfiler(QQmlVmeProfiler *) {} +}; + +#else + +#define Q_QML_PROFILE_IF_ENABLED(feature, profiler, Code)\ + if (profiler && (profiler->featuresEnabled & (1 << feature))) {\ + Code;\ + } else\ + (void)0 + +#define Q_QML_PROFILE(feature, profiler, Method)\ + Q_QML_PROFILE_IF_ENABLED(feature, profiler, profiler->Method) + +#define Q_QML_OC_PROFILE(member, Code)\ + Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, member.profiler, Code) + +// This struct is somewhat dangerous to use: +// The messageType is a bit field. You can pack multiple messages into +// one object, e.g. RangeStart and RangeLocation. Each one will be read +// independently when converting to QByteArrays. Thus you can only pack +// messages if their data doesn't overlap. It's up to you to figure that +// out. +struct Q_AUTOTEST_EXPORT QQmlProfilerData : public QQmlProfilerDefinitions +{ + QQmlProfilerData(qint64 time = -1, int messageType = -1, + RangeType detailType = MaximumRangeType, quintptr locationId = 0) : + time(time), locationId(locationId), messageType(messageType), detailType(detailType) + {} + + qint64 time; + quintptr locationId; + + int messageType; //bit field of QQmlProfilerService::Message + RangeType detailType; +}; + +Q_DECLARE_TYPEINFO(QQmlProfilerData, Q_RELOCATABLE_TYPE); + +class Q_QML_EXPORT QQmlProfiler : public QObject, public QQmlProfilerDefinitions { + Q_OBJECT +public: + + struct Location { + Location(const QQmlSourceLocation &location = QQmlSourceLocation(), + const QUrl &url = QUrl()) : + location(location), url(url) {} + QQmlSourceLocation location; + QUrl url; + }; + + // Unfortunately we have to resolve the locations right away because the QML context might not + // be available anymore when we send the data. + struct RefLocation : public Location { + RefLocation() + : Location(), locationType(MaximumRangeType), something(nullptr), sent(false) + { + } + + RefLocation(QV4::Function *ref) + : Location(ref->sourceLocation()), locationType(Binding), sent(false) + { + function = ref; + function->executableCompilationUnit()->addref(); + } + + RefLocation(QV4::ExecutableCompilationUnit *ref, const QUrl &url, + const QV4::CompiledData::Object *obj, const QString &type) + : Location(QQmlSourceLocation(type, obj->location.line(), obj->location.column()), url), + locationType(Creating), sent(false) + { + unit = ref; + unit->addref(); + } + + RefLocation(QQmlBoundSignalExpression *ref) + : Location(ref->sourceLocation()), locationType(HandlingSignal), sent(false) + { + boundSignal = ref; + boundSignal->addref(); + } + + RefLocation(QQmlDataBlob *ref) + : Location(QQmlSourceLocation(), ref->url()), locationType(Compiling), sent(false) + { + blob = ref; + blob->addref(); + } + + RefLocation(const RefLocation &other) + : Location(other), + locationType(other.locationType), + function(other.function), + sent(other.sent) + { + addref(); + } + + RefLocation &operator=(const RefLocation &other) + { + if (this != &other) { + release(); + Location::operator=(other); + locationType = other.locationType; + function = other.function; + sent = other.sent; + addref(); + } + return *this; + } + + ~RefLocation() + { + release(); + } + + void addref() + { + if (isNull()) + return; + + switch (locationType) { + case Binding: + function->executableCompilationUnit()->addref(); + break; + case Creating: + unit->addref(); + break; + case HandlingSignal: + boundSignal->addref(); + break; + case Compiling: + blob->addref(); + break; + default: + Q_ASSERT(locationType == MaximumRangeType); + break; + } + } + + void release() + { + if (isNull()) + return; + + switch (locationType) { + case Binding: + function->executableCompilationUnit()->release(); + break; + case Creating: + unit->release(); + break; + case HandlingSignal: + boundSignal->release(); + break; + case Compiling: + blob->release(); + break; + default: + Q_ASSERT(locationType == MaximumRangeType); + break; + } + } + + bool isValid() const + { + return locationType != MaximumRangeType; + } + + bool isNull() const + { + return !something; + } + + RangeType locationType; + union { + QV4::Function *function; + QV4::ExecutableCompilationUnit *unit; + QQmlBoundSignalExpression *boundSignal; + QQmlDataBlob *blob; + void *something; + }; + bool sent; + }; + + typedef QHash<quintptr, Location> LocationHash; + + void startBinding(QV4::Function *function) + { + // Use the QV4::Function as ID, as that is common among different instances of the same + // component. QQmlBinding is per instance. + // Add 1 to the ID, to make it different from the IDs the V4 and signal handling profilers + // produce. The +1 makes the pointer point into the middle of the QV4::Function. Thus it + // still points to valid memory but we cannot accidentally create a duplicate key from + // another object. + // If there is no function, use a static but valid address: The profiler itself. + quintptr locationId = function ? id(function) + 1 : id(this); + m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), + (1 << RangeStart | 1 << RangeLocation), Binding, + locationId)); + + RefLocation &location = m_locations[locationId]; + if (!location.isValid()) { + if (function) + location = RefLocation(function); + else // Make it valid without actually providing a location + location.locationType = Binding; + } + } + + // Have toByteArrays() construct another RangeData event from the same QString later. + // This is somewhat pointless but important for backwards compatibility. + void startCompiling(QQmlDataBlob *blob) + { + quintptr locationId(id(blob)); + m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), + (1 << RangeStart | 1 << RangeLocation | 1 << RangeData), + Compiling, locationId)); + + RefLocation &location = m_locations[locationId]; + if (!location.isValid()) + location = RefLocation(blob); + } + + void startHandlingSignal(QQmlBoundSignalExpression *expression) + { + // Use the QV4::Function as ID, as that is common among different instances of the same + // component. QQmlBoundSignalExpression is per instance. + // Add 2 to the ID, to make it different from the IDs the V4 and binding profilers produce. + // The +2 makes the pointer point into the middle of the QV4::Function. Thus it still points + // to valid memory but we cannot accidentally create a duplicate key from another object. + quintptr locationId(id(expression->function()) + 2); + m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), + (1 << RangeStart | 1 << RangeLocation), HandlingSignal, + locationId)); + + RefLocation &location = m_locations[locationId]; + if (!location.isValid()) + location = RefLocation(expression); + } + + void startCreating(const QV4::CompiledData::Object *obj) + { + m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), + (1 << RangeStart | 1 << RangeLocation | 1 << RangeData), + Creating, id(obj))); + } + + void updateCreating(const QV4::CompiledData::Object *obj, + QV4::ExecutableCompilationUnit *ref, + const QUrl &url, const QString &type) + { + quintptr locationId(id(obj)); + RefLocation &location = m_locations[locationId]; + if (!location.isValid()) + location = RefLocation(ref, url, obj, type); + } + + template<RangeType Range> + void endRange() + { + m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), 1 << RangeEnd, Range)); + } + + QQmlProfiler(); + + quint64 featuresEnabled; + + template<typename Object> + static quintptr id(const Object *pointer) + { + return reinterpret_cast<quintptr>(pointer); + } + + void startProfiling(quint64 features); + void stopProfiling(); + void reportData(); + void setTimer(const QElapsedTimer &timer) { m_timer = timer; } + +Q_SIGNALS: + void dataReady(const QVector<QQmlProfilerData> &, const QQmlProfiler::LocationHash &); + +protected: + QElapsedTimer m_timer; + QHash<quintptr, RefLocation> m_locations; + QVector<QQmlProfilerData> m_data; +}; + +// +// RAII helper structs +// + +struct QQmlProfilerHelper : public QQmlProfilerDefinitions { + QQmlProfiler *profiler; + QQmlProfilerHelper(QQmlProfiler *profiler) : profiler(profiler) {} +}; + +struct QQmlBindingProfiler : public QQmlProfilerHelper { + QQmlBindingProfiler(QQmlProfiler *profiler, QV4::Function *function) : + QQmlProfilerHelper(profiler) + { + Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileBinding, profiler, + startBinding(function)); + } + + ~QQmlBindingProfiler() + { + Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileBinding, profiler, + endRange<Binding>()); + } +}; + +struct QQmlHandlingSignalProfiler : public QQmlProfilerHelper { + QQmlHandlingSignalProfiler(QQmlProfiler *profiler, QQmlBoundSignalExpression *expression) : + QQmlProfilerHelper(profiler) + { + Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileHandlingSignal, profiler, + startHandlingSignal(expression)); + } + + ~QQmlHandlingSignalProfiler() + { + Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileHandlingSignal, profiler, + endRange<QQmlProfiler::HandlingSignal>()); + } +}; + +struct QQmlCompilingProfiler : public QQmlProfilerHelper { + QQmlCompilingProfiler(QQmlProfiler *profiler, QQmlDataBlob *blob) : + QQmlProfilerHelper(profiler) + { + Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCompiling, profiler, startCompiling(blob)); + } + + ~QQmlCompilingProfiler() + { + Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCompiling, profiler, endRange<Compiling>()); + } +}; + +struct QQmlVmeProfiler : public QQmlProfilerDefinitions { +public: + + QQmlVmeProfiler() : profiler(nullptr) {} + + void init(QQmlProfiler *p, int maxDepth) + { + profiler = p; + ranges.allocate(maxDepth); + } + + const QV4::CompiledData::Object *pop() + { + if (ranges.count() > 0) + return ranges.pop(); + else + return nullptr; + } + + void push(const QV4::CompiledData::Object *object) + { + if (ranges.capacity() > ranges.count()) + ranges.push(object); + } + + QQmlProfiler *profiler; + +private: + QFiniteStack<const QV4::CompiledData::Object *> ranges; +}; + +class QQmlObjectCreationProfiler { +public: + + QQmlObjectCreationProfiler(QQmlProfiler *profiler, const QV4::CompiledData::Object *obj) + : profiler(profiler) + { + Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCreating, profiler, startCreating(obj)); + } + + ~QQmlObjectCreationProfiler() + { + Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCreating, profiler, endRange<QQmlProfilerDefinitions::Creating>()); + } + + void update(QV4::ExecutableCompilationUnit *ref, const QV4::CompiledData::Object *obj, + const QString &typeName, const QUrl &url) + { + profiler->updateCreating(obj, ref, url, typeName); + } + +private: + QQmlProfiler *profiler; +}; + +class QQmlObjectCompletionProfiler { +public: + QQmlObjectCompletionProfiler(QQmlVmeProfiler *parent) : + profiler(parent->profiler) + { + Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, profiler, { + profiler->startCreating(parent->pop()); + }); + } + + ~QQmlObjectCompletionProfiler() + { + Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCreating, profiler, + endRange<QQmlProfilerDefinitions::Creating>()); + } +private: + QQmlProfiler *profiler; +}; + +#endif // QT_CONFIG(qml_debug) + +QT_END_NAMESPACE + +#if QT_CONFIG(qml_debug) + +Q_DECLARE_METATYPE(QVector<QQmlProfilerData>) +Q_DECLARE_METATYPE(QQmlProfiler::LocationHash) + +#endif // QT_CONFIG(qml_debug) + +#endif // QQMLPROFILER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlprofilerdefinitions_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlprofilerdefinitions_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e846c89ed688fe6ae670209d2abcd07c4dba89bf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlprofilerdefinitions_p.h @@ -0,0 +1,144 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROFILERDEFINITIONS_P_H +#define QQMLPROFILERDEFINITIONS_P_H + +#include <private/qtqmlglobal_p.h> +#include <private/qv4profiling_p.h> + +QT_REQUIRE_CONFIG(qml_debug); + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +struct QQmlProfilerDefinitions { + enum Message { + Event, + RangeStart, + RangeData, + RangeLocation, + RangeEnd, + Complete, // end of transmission + PixmapCacheEvent, + SceneGraphFrame, + MemoryAllocation, + DebugMessage, + Quick3DFrame, + + MaximumMessage + }; + + enum EventType { + FramePaint, + Mouse, + Key, + AnimationFrame, + EndTrace, + StartTrace, + + MaximumEventType + }; + + enum RangeType { + Painting, + Compiling, + Creating, + Binding, //running a binding + HandlingSignal, //running a signal handler + Javascript, + + MaximumRangeType + }; + + enum PixmapEventType { + PixmapSizeKnown, + PixmapReferenceCountChanged, + PixmapCacheCountChanged, + PixmapLoadingStarted, + PixmapLoadingFinished, + PixmapLoadingError, + + MaximumPixmapEventType + }; + + enum SceneGraphFrameType { + SceneGraphRendererFrame, // Render Thread + SceneGraphAdaptationLayerFrame, // Render Thread + SceneGraphContextFrame, // Render Thread + SceneGraphRenderLoopFrame, // Render Thread + SceneGraphTexturePrepare, // Render Thread + SceneGraphTextureDeletion, // Render Thread + SceneGraphPolishAndSync, // GUI Thread + SceneGraphWindowsRenderShow, // Unused + SceneGraphWindowsAnimations, // GUI Thread + SceneGraphPolishFrame, // GUI Thread + + MaximumSceneGraphFrameType, + NumRenderThreadFrameTypes = SceneGraphPolishAndSync, + NumGUIThreadFrameTypes = MaximumSceneGraphFrameType - NumRenderThreadFrameTypes + }; + + enum Quick3DFrameType { + Quick3DRenderFrame, // Render Thread + Quick3DSynchronizeFrame, + Quick3DPrepareFrame, + Quick3DMeshLoad, + Quick3DCustomMeshLoad, + Quick3DTextureLoad, + Quick3DGenerateShader, + Quick3DLoadShader, + Quick3DParticleUpdate, // GUI Thread + Quick3DRenderCall, // Render Thread + Quick3DRenderPass, // Render Thread + Quick3DEventData, // N/A + MaximumQuick3DFrameType, + }; + + enum ProfileFeature { + ProfileJavaScript, + ProfileMemory, + ProfilePixmapCache, + ProfileSceneGraph, + ProfileAnimations, + ProfilePainting, + ProfileCompiling, + ProfileCreating, + ProfileBinding, + ProfileHandlingSignal, + ProfileInputEvents, + ProfileDebugMessages, + ProfileQuick3D, + + MaximumProfileFeature + }; + + enum InputEventType { + InputKeyPress, + InputKeyRelease, + InputKeyUnknown, + + InputMousePress, + InputMouseRelease, + InputMouseMove, + InputMouseDoubleClick, + InputMouseWheel, + InputMouseUnknown, + + MaximumInputEventType + }; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlproperty_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlproperty_p.h new file mode 100644 index 0000000000000000000000000000000000000000..18cbd8a74bb5faa71dbe493e27507133fa312a2e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlproperty_p.h @@ -0,0 +1,163 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROPERTY_P_H +#define QQMLPROPERTY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlproperty.h" + +#include <private/qobject_p.h> +#include <private/qqmlcontextdata_p.h> +#include <private/qqmlpropertydata_p.h> +#include <private/qqmlpropertyindex_p.h> +#include <private/qqmlrefcount_p.h> +#include <private/qtqmlglobal_p.h> + +#include <QtQml/qqmlengine.h> + +#include <QtCore/qpointer.h> + +QT_BEGIN_NAMESPACE + +class QQmlContext; +class QQmlEnginePrivate; +class QQmlJavaScriptExpression; +class QQmlMetaObject; +class QQmlAbstractBinding; +class QQmlBoundSignalExpression; + +class Q_QML_EXPORT QQmlPropertyPrivate final : public QQmlRefCounted<QQmlPropertyPrivate> +{ +public: + enum class InitFlag { + None = 0x0, + AllowId = 0x1, + AllowSignal = 0x2 + }; + Q_DECLARE_FLAGS(InitFlags, InitFlag); + + QQmlRefPointer<QQmlContextData> context; + QPointer<QQmlEngine> engine; + QPointer<QObject> object; + + QQmlPropertyData core; + QQmlPropertyData valueTypeData; + + QString nameCache; + + // ### Qt7: Get rid of this. + static bool resolveUrlsOnAssignment(); + + QQmlPropertyPrivate() {} + + QQmlPropertyIndex encodedIndex() const + { return encodedIndex(core, valueTypeData); } + static QQmlPropertyIndex encodedIndex(const QQmlPropertyData &core, const QQmlPropertyData &valueTypeData) + { return QQmlPropertyIndex(core.coreIndex(), valueTypeData.coreIndex()); } + + QQmlRefPointer<QQmlContextData> effectiveContext() const; + + void initProperty(QObject *obj, const QString &name, InitFlags flags = InitFlag::None); + void initDefault(QObject *obj); + + bool isValueType() const; + QMetaType propertyType() const; + QQmlProperty::Type type() const; + QQmlProperty::PropertyTypeCategory propertyTypeCategory() const; + + QVariant readValueProperty(); + bool writeValueProperty(const QVariant &, QQmlPropertyData::WriteFlags); + + static QQmlMetaObject rawMetaObjectForType(QMetaType metaType); + static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, + const QVariant &value, int flags); + static bool writeValueProperty(QObject *, + const QQmlPropertyData &, const QQmlPropertyData &valueTypeData, + const QVariant &, const QQmlRefPointer<QQmlContextData> &, + QQmlPropertyData::WriteFlags flags = {}); + static bool resetValueProperty(QObject *, + const QQmlPropertyData &, const QQmlPropertyData &valueTypeData, + const QQmlRefPointer<QQmlContextData> &, + QQmlPropertyData::WriteFlags flags = {}); + static bool write(QObject *, const QQmlPropertyData &, const QVariant &, + const QQmlRefPointer<QQmlContextData> &, + QQmlPropertyData::WriteFlags flags = {}); + static bool reset(QObject *, const QQmlPropertyData &, + QQmlPropertyData::WriteFlags flags = {}); + static void findAliasTarget(QObject *, QQmlPropertyIndex, QObject **, QQmlPropertyIndex *); + + struct ResolvedAlias + { + QObject *targetObject; + QQmlPropertyIndex targetIndex; + }; + /*! + \internal + Given an alias property specified by \a baseObject and \a baseIndex, this function + computes the alias target. + */ + static ResolvedAlias findAliasTarget(QObject *baseObject, QQmlPropertyIndex baseIndex); + + enum BindingFlag { + None = 0, + DontEnable = 0x1 + }; + Q_DECLARE_FLAGS(BindingFlags, BindingFlag) + + static void setBinding(QQmlAbstractBinding *binding, BindingFlags flags = None, + QQmlPropertyData::WriteFlags writeFlags = QQmlPropertyData::DontRemoveBinding); + + static void removeBinding(const QQmlProperty &that); + static void removeBinding(QObject *o, QQmlPropertyIndex index); + static void removeBinding(QQmlAbstractBinding *b); + static QQmlAbstractBinding *binding(QObject *, QQmlPropertyIndex index); + + static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *, + const QQmlRefPointer<QQmlContextData> &); + + int signalIndex() const; + + static inline QQmlPropertyPrivate *get(const QQmlProperty &p) { return p.d; } + + // "Public" (to QML) methods + static QQmlAbstractBinding *binding(const QQmlProperty &that); + static void setBinding(const QQmlProperty &that, QQmlAbstractBinding *); + static QQmlBoundSignalExpression *signalExpression(const QQmlProperty &that); + static void setSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *); + static void takeSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *); + static bool write(const QQmlProperty &that, const QVariant &, QQmlPropertyData::WriteFlags); + static QQmlPropertyIndex propertyIndex(const QQmlProperty &that); + static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &); + static QMetaProperty findPropertyByName(const QMetaObject *mo, const QByteArray &); + static bool connect(const QObject *sender, int signal_index, + const QObject *receiver, int method_index, + int type = 0, int *types = nullptr); + static void flushSignal(const QObject *sender, int signal_index); + + static QList<QUrl> urlSequence(const QVariant &value); + static QList<QUrl> urlSequence( + const QVariant &value, const QQmlRefPointer<QQmlContextData> &ctxt); + static QQmlProperty create( + QObject *target, const QString &propertyName, + const QQmlRefPointer<QQmlContextData> &context, + QQmlPropertyPrivate::InitFlags flags); + +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyPrivate::BindingFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyPrivate::InitFlags); + +QT_END_NAMESPACE + +#endif // QQMLPROPERTY_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertybinding_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertybinding_p.h new file mode 100644 index 0000000000000000000000000000000000000000..55e787d1617bdae1d3c13a09f6a45e1d3fe43142 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertybinding_p.h @@ -0,0 +1,421 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROPERTYBINDING_P_H +#define QQMLPROPERTYBINDING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmljavascriptexpression_p.h> +#include <private/qqmlpropertydata_p.h> +#include <private/qv4alloca_p.h> +#include <private/qqmltranslation_p.h> + +#include <QtCore/qproperty.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + struct BoundFunction; +} + +class QQmlPropertyBinding; +class QQmlScriptString; + +class Q_QML_EXPORT QQmlPropertyBindingJS : public QQmlJavaScriptExpression +{ + bool mustCaptureBindableProperty() const final {return false;} + + friend class QQmlPropertyBinding; + void expressionChanged() override; + QQmlPropertyBinding *asBinding() + { + return const_cast<QQmlPropertyBinding *>(static_cast<const QQmlPropertyBindingJS *>(this)->asBinding()); + } + + inline QQmlPropertyBinding const *asBinding() const; +}; + +class Q_QML_EXPORT QQmlPropertyBindingJSForBoundFunction : public QQmlPropertyBindingJS +{ +public: + QV4::ReturnedValue evaluate(bool *isUndefined); + QV4::PersistentValue m_boundFunction; +}; + +class Q_QML_EXPORT QQmlPropertyBinding : public QPropertyBindingPrivate + +{ + friend class QQmlPropertyBindingJS; + + static constexpr std::size_t jsExpressionOffsetLength() { + struct composite { QQmlPropertyBinding b; QQmlPropertyBindingJS js; }; + QT_WARNING_PUSH QT_WARNING_DISABLE_INVALID_OFFSETOF + return sizeof (QQmlPropertyBinding) - offsetof(composite, js); + QT_WARNING_POP + } + +public: + + QQmlPropertyBindingJS *jsExpression() + { + return const_cast<QQmlPropertyBindingJS *>(static_cast<const QQmlPropertyBinding *>(this)->jsExpression()); + } + + QQmlPropertyBindingJS const *jsExpression() const + { + return std::launder(reinterpret_cast<QQmlPropertyBindingJS const *>( + reinterpret_cast<std::byte const*>(this) + + QPropertyBindingPrivate::getSizeEnsuringAlignment() + + jsExpressionOffsetLength())); + } + + static QUntypedPropertyBinding create(const QQmlPropertyData *pd, QV4::Function *function, + QObject *obj, const QQmlRefPointer<QQmlContextData> &ctxt, + QV4::ExecutionContext *scope, QObject *target, + QQmlPropertyIndex targetIndex); + static QUntypedPropertyBinding create(QMetaType propertyType, QV4::Function *function, + QObject *obj, const QQmlRefPointer<QQmlContextData> &ctxt, + QV4::ExecutionContext *scope, QObject *target, + QQmlPropertyIndex targetIndex); + static QUntypedPropertyBinding createFromCodeString(const QQmlPropertyData *property, + const QString &str, QObject *obj, + const QQmlRefPointer<QQmlContextData> &ctxt, + const QString &url, quint16 lineNumber, + QObject *target, QQmlPropertyIndex targetIndex); + static QUntypedPropertyBinding createFromScriptString(const QQmlPropertyData *property, + const QQmlScriptString& script, QObject *obj, + QQmlContext *ctxt, QObject *target, + QQmlPropertyIndex targetIndex); + + static QUntypedPropertyBinding createFromBoundFunction(const QQmlPropertyData *pd, QV4::BoundFunction *function, + QObject *obj, const QQmlRefPointer<QQmlContextData> &ctxt, + QV4::ExecutionContext *scope, QObject *target, + QQmlPropertyIndex targetIndex); + + static bool isUndefined(const QUntypedPropertyBinding &binding) + { + return isUndefined(QPropertyBindingPrivate::get(binding)); + } + + static bool isUndefined(const QPropertyBindingPrivate *binding) + { + if (!(binding && binding->hasCustomVTable())) + return false; + return static_cast<const QQmlPropertyBinding *>(binding)->isUndefined(); + } + + template<QMetaType::Type type> + static bool doEvaluate(QMetaType metaType, QUntypedPropertyData *dataPtr, void *f) { + auto address = static_cast<std::byte*>(f); + address -= QPropertyBindingPrivate::getSizeEnsuringAlignment(); // f now points to QPropertyBindingPrivate suboject + // and that has the same address as QQmlPropertyBinding + return reinterpret_cast<QQmlPropertyBinding *>(address)->evaluate<type>(metaType, dataPtr); + } + + bool hasDependencies() + { + return (dependencyObserverCount > 0) || !jsExpression()->activeGuards.isEmpty(); + } + +private: + template <QMetaType::Type type> + bool evaluate(QMetaType metaType, void *dataPtr); + + Q_NEVER_INLINE void handleUndefinedAssignment(QQmlEnginePrivate *ep, void *dataPtr); + + QString createBindingLoopErrorDescription(); + + struct TargetData { + enum BoundFunction : bool { + WithoutBoundFunction = false, + HasBoundFunction = true, + }; + TargetData(QObject *target, QQmlPropertyIndex index, BoundFunction state) + : target(target), targetIndex(index), hasBoundFunction(state) + {} + QObject *target; + QQmlPropertyIndex targetIndex; + bool hasBoundFunction; + bool isUndefined = false; + }; + QQmlPropertyBinding(QMetaType metaType, QObject *target, QQmlPropertyIndex targetIndex, TargetData::BoundFunction hasBoundFunction); + + QObject *target() + { + return std::launder(reinterpret_cast<TargetData *>(&declarativeExtraData))->target; + } + + QQmlPropertyIndex targetIndex() + { + return std::launder(reinterpret_cast<TargetData *>(&declarativeExtraData))->targetIndex; + } + + bool hasBoundFunction() + { + return std::launder(reinterpret_cast<TargetData *>(&declarativeExtraData))->hasBoundFunction; + } + + bool isUndefined() const + { + return std::launder(reinterpret_cast<TargetData const *>(&declarativeExtraData))->isUndefined; + } + + void setIsUndefined(bool isUndefined) + { + std::launder(reinterpret_cast<TargetData *>(&declarativeExtraData))->isUndefined = isUndefined; + } + + static void bindingErrorCallback(QPropertyBindingPrivate *); +}; + +template <auto I> +struct Print {}; + +namespace QtPrivate { +template<QMetaType::Type type> +inline constexpr BindingFunctionVTable bindingFunctionVTableForQQmlPropertyBinding = { + &QQmlPropertyBinding::doEvaluate<type>, + [](void *qpropertyBinding){ + QQmlPropertyBinding *binding = reinterpret_cast<QQmlPropertyBinding *>(qpropertyBinding); + binding->jsExpression()->~QQmlPropertyBindingJS(); + binding->~QQmlPropertyBinding(); + auto address = static_cast<std::byte*>(qpropertyBinding); + delete[] address; + }, + [](void *, void *){}, + 0 +}; +} + +inline const QtPrivate::BindingFunctionVTable *bindingFunctionVTableForQQmlPropertyBinding(QMetaType type) +{ +#define FOR_TYPE(TYPE) \ + case TYPE: return &QtPrivate::bindingFunctionVTableForQQmlPropertyBinding<TYPE> + switch (type.id()) { + FOR_TYPE(QMetaType::Int); + FOR_TYPE(QMetaType::QString); + FOR_TYPE(QMetaType::Double); + FOR_TYPE(QMetaType::Float); + FOR_TYPE(QMetaType::Bool); + default: + if (type.flags() & QMetaType::PointerToQObject) + return &QtPrivate::bindingFunctionVTableForQQmlPropertyBinding<QMetaType::QObjectStar>; + return &QtPrivate::bindingFunctionVTableForQQmlPropertyBinding<QMetaType::UnknownType>; + } +#undef FOR_TYPE +} + +class QQmlTranslationPropertyBinding +{ +public: + static QUntypedPropertyBinding Q_QML_EXPORT create(const QQmlPropertyData *pd, + const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, + const QV4::CompiledData::Binding *binding); + static QUntypedPropertyBinding Q_QML_EXPORT + create(const QMetaType &pd, + const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, + const QQmlTranslation &translationData); +}; + +inline const QQmlPropertyBinding *QQmlPropertyBindingJS::asBinding() const +{ + return std::launder(reinterpret_cast<QQmlPropertyBinding const *>( + reinterpret_cast<std::byte const*>(this) + - QPropertyBindingPrivate::getSizeEnsuringAlignment() + - QQmlPropertyBinding::jsExpressionOffsetLength())); +} + +static_assert(sizeof(QQmlPropertyBinding) == sizeof(QPropertyBindingPrivate)); // else the whole offset computatation will break +template<typename T> +bool compareAndAssign(void *dataPtr, const void *result) +{ + if (*static_cast<const T *>(result) == *static_cast<const T *>(dataPtr)) + return false; + *static_cast<T *>(dataPtr) = *static_cast<const T *>(result); + return true; +} + +template <QMetaType::Type type> +bool QQmlPropertyBinding::evaluate(QMetaType metaType, void *dataPtr) +{ + const auto ctxt = jsExpression()->context(); + QQmlEngine *engine = ctxt ? ctxt->engine() : nullptr; + if (!engine) { + QPropertyBindingError error(QPropertyBindingError::EvaluationError); + if (auto currentBinding = QPropertyBindingPrivate::currentlyEvaluatingBinding()) + currentBinding->setError(std::move(error)); + return false; + } + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); + ep->referenceScarceResources(); + + const auto handleErrorAndUndefined = [&](bool evaluatedToUndefined) { + ep->dereferenceScarceResources(); + if (jsExpression()->hasError()) { + QPropertyBindingError error(QPropertyBindingError::UnknownError, + jsExpression()->delayedError()->error().description()); + QPropertyBindingPrivate::currentlyEvaluatingBinding()->setError(std::move(error)); + bindingErrorCallback(this); + return false; + } + + if (evaluatedToUndefined) { + handleUndefinedAssignment(ep, dataPtr); + // if property has been changed due to reset, reset is responsible for + // notifying observers + return false; + } else if (isUndefined()) { + setIsUndefined(false); + } + + return true; + }; + + if (!hasBoundFunction()) { + Q_ASSERT(metaType.sizeOf() > 0); + + using Tuple = std::tuple<qsizetype, bool, bool>; + const auto [size, needsConstruction, needsDestruction] = [&]() -> Tuple { + switch (type) { + case QMetaType::QObjectStar: return Tuple(sizeof(QObject *), false, false); + case QMetaType::Bool: return Tuple(sizeof(bool), false, false); + case QMetaType::Int: return Tuple(sizeof(int), false, false); + case QMetaType::Double: return Tuple(sizeof(double), false, false); + case QMetaType::Float: return Tuple(sizeof(float), false, false); + case QMetaType::QString: return Tuple(sizeof(QString), true, true); + default: { + const auto flags = metaType.flags(); + return Tuple( + metaType.sizeOf(), + flags & QMetaType::NeedsConstruction, + flags & QMetaType::NeedsDestruction); + } + } + }(); + Q_ALLOCA_VAR(void, result, size); + if (needsConstruction) + metaType.construct(result); + + const bool evaluatedToUndefined = !jsExpression()->evaluate(&result, &metaType, 0); + if (!handleErrorAndUndefined(evaluatedToUndefined)) + return false; + + switch (type) { + case QMetaType::QObjectStar: + return compareAndAssign<QObject *>(dataPtr, result); + case QMetaType::Bool: + return compareAndAssign<bool>(dataPtr, result); + case QMetaType::Int: + return compareAndAssign<int>(dataPtr, result); + case QMetaType::Double: + return compareAndAssign<double>(dataPtr, result); + case QMetaType::Float: + return compareAndAssign<float>(dataPtr, result); + case QMetaType::QString: { + const bool hasChanged = compareAndAssign<QString>(dataPtr, result); + static_cast<QString *>(result)->~QString(); + return hasChanged; + } + default: + break; + } + + const bool hasChanged = !metaType.equals(result, dataPtr); + if (hasChanged) { + if (needsDestruction) + metaType.destruct(dataPtr); + metaType.construct(dataPtr, result); + } + if (needsDestruction) + metaType.destruct(result); + return hasChanged; + } + + bool evaluatedToUndefined = false; + QV4::Scope scope(engine->handle()); + QV4::ScopedValue result(scope, static_cast<QQmlPropertyBindingJSForBoundFunction *>( + jsExpression())->evaluate(&evaluatedToUndefined)); + + if (!handleErrorAndUndefined(evaluatedToUndefined)) + return false; + + switch (type) { + case QMetaType::Bool: { + bool b; + if (result->isBoolean()) + b = result->booleanValue(); + else + b = result->toBoolean(); + if (b == *static_cast<bool *>(dataPtr)) + return false; + *static_cast<bool *>(dataPtr) = b; + return true; + } + case QMetaType::Int: { + int i; + if (result->isInteger()) + i = result->integerValue(); + else if (result->isNumber()) { + i = QV4::StaticValue::toInteger(result->doubleValue()); + } else { + break; + } + if (i == *static_cast<int *>(dataPtr)) + return false; + *static_cast<int *>(dataPtr) = i; + return true; + } + case QMetaType::Double: + if (result->isNumber()) { + double d = result->asDouble(); + if (d == *static_cast<double *>(dataPtr)) + return false; + *static_cast<double *>(dataPtr) = d; + return true; + } + break; + case QMetaType::Float: + if (result->isNumber()) { + float d = float(result->asDouble()); + if (d == *static_cast<float *>(dataPtr)) + return false; + *static_cast<float *>(dataPtr) = d; + return true; + } + break; + case QMetaType::QString: + if (result->isString()) { + QString s = result->toQStringNoThrow(); + if (s == *static_cast<QString *>(dataPtr)) + return false; + *static_cast<QString *>(dataPtr) = s; + return true; + } + break; + default: + break; + } + + QVariant resultVariant(QV4::ExecutionEngine::toVariant(result, metaType)); + resultVariant.convert(metaType); + const bool hasChanged = !metaType.equals(resultVariant.constData(), dataPtr); + metaType.destruct(dataPtr); + metaType.construct(dataPtr, resultVariant.constData()); + return hasChanged; +} + +QT_END_NAMESPACE + +#endif // QQMLPROPERTYBINDING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycache_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9f69de3f80f2016f48e980a3aba8eac48212f4ce --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycache_p.h @@ -0,0 +1,486 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROPERTYCACHE_P_H +#define QQMLPROPERTYCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qlinkedstringhash_p.h> +#include <private/qqmlenumdata_p.h> +#include <private/qqmlenumvalue_p.h> +#include <private/qqmlpropertydata_p.h> +#include <private/qqmlrefcount_p.h> + +#include <QtCore/qvarlengtharray.h> +#include <QtCore/qvector.h> +#include <QtCore/qversionnumber.h> + +#include <limits> + +QT_BEGIN_NAMESPACE + +class QCryptographicHash; +class QJSEngine; +class QMetaObjectBuilder; +class QQmlContextData; +class QQmlPropertyCache; +class QQmlPropertyCacheMethodArguments; +class QQmlVMEMetaObject; + +class QQmlMetaObjectPointer +{ +public: + Q_NODISCARD_CTOR QQmlMetaObjectPointer() = default; + + Q_NODISCARD_CTOR QQmlMetaObjectPointer(const QMetaObject *staticMetaObject) + : d(quintptr(staticMetaObject)) + { + Q_ASSERT((d.loadRelaxed() & Shared) == 0); + } + + ~QQmlMetaObjectPointer() + { + const auto dd = d.loadAcquire(); + if (dd & Shared) + reinterpret_cast<SharedHolder *>(dd ^ Shared)->release(); + } + +private: + friend class QQmlPropertyCache; + Q_NODISCARD_CTOR QQmlMetaObjectPointer(const QQmlMetaObjectPointer &other) + : d(other.d.loadRelaxed()) + { + // other has to survive until this ctor is done. So d cannot disappear before. + const auto od = other.d.loadRelaxed(); + if (od & Shared) + reinterpret_cast<SharedHolder *>(od ^ Shared)->addref(); + } + + QQmlMetaObjectPointer(QQmlMetaObjectPointer &&other) = delete; + QQmlMetaObjectPointer &operator=(QQmlMetaObjectPointer &&other) = delete; + QQmlMetaObjectPointer &operator=(const QQmlMetaObjectPointer &other) = delete; + +public: + void setSharedOnce(QMetaObject *shared) const + { + SharedHolder *holder = new SharedHolder(shared); + if (!d.testAndSetRelease(0, quintptr(holder) | Shared)) + holder->release(); + } + + const QMetaObject *metaObject() const + { + const auto dd = d.loadAcquire(); + if (dd & Shared) + return reinterpret_cast<SharedHolder *>(dd ^ Shared)->metaObject; + return reinterpret_cast<const QMetaObject *>(dd); + } + + bool isShared() const + { + // This works because static metaobjects need to be set in the ctor and once a shared + // metaobject has been set, it cannot be removed anymore. + const auto dd = d.loadRelaxed(); + return !dd || (dd & Shared); + } + + bool isNull() const + { + return d.loadRelaxed() == 0; + } + +private: + enum Tag { + Static = 0, + Shared = 1 + }; + + struct SharedHolder final : public QQmlRefCounted<SharedHolder> + { + Q_DISABLE_COPY_MOVE(SharedHolder) + SharedHolder(QMetaObject *shared) : metaObject(shared) {} + ~SharedHolder() { free(metaObject); } + QMetaObject *metaObject; + }; + + mutable QBasicAtomicInteger<quintptr> d = 0; +}; + +class Q_QML_EXPORT QQmlPropertyCache final + : public QQmlRefCounted<QQmlPropertyCache> +{ +public: + using Ptr = QQmlRefPointer<QQmlPropertyCache>; + + struct ConstPtr : public QQmlRefPointer<const QQmlPropertyCache> + { + using QQmlRefPointer<const QQmlPropertyCache>::QQmlRefPointer; + + ConstPtr(const Ptr &ptr) : ConstPtr(ptr.data(), AddRef) {} + ConstPtr(Ptr &&ptr) : ConstPtr(ptr.take(), Adopt) {} + ConstPtr &operator=(const Ptr &ptr) { return operator=(ConstPtr(ptr)); } + ConstPtr &operator=(Ptr &&ptr) { return operator=(ConstPtr(std::move(ptr))); } + }; + + static Ptr createStandalone( + const QMetaObject *, QTypeRevision metaObjectRevision = QTypeRevision::zero()); + + QQmlPropertyCache() = default; + ~QQmlPropertyCache(); + + void update(const QMetaObject *); + void invalidate(const QMetaObject *); + + QQmlPropertyCache::Ptr copy() const; + + QQmlPropertyCache::Ptr copyAndAppend( + const QMetaObject *, QTypeRevision typeVersion, + QQmlPropertyData::Flags propertyFlags = QQmlPropertyData::Flags(), + QQmlPropertyData::Flags methodFlags = QQmlPropertyData::Flags(), + QQmlPropertyData::Flags signalFlags = QQmlPropertyData::Flags()) const; + + QQmlPropertyCache::Ptr copyAndReserve( + int propertyCount, int methodCount, int signalCount, int enumCount) const; + void appendProperty(const QString &, QQmlPropertyData::Flags flags, int coreIndex, + QMetaType propType, QTypeRevision revision, int notifyIndex); + void appendSignal(const QString &, QQmlPropertyData::Flags, int coreIndex, + const QMetaType *types = nullptr, + const QList<QByteArray> &names = QList<QByteArray>()); + void appendMethod(const QString &, QQmlPropertyData::Flags flags, int coreIndex, + QMetaType returnType, const QList<QByteArray> &names, + const QVector<QMetaType> ¶meterTypes); + void appendEnum(const QString &, const QVector<QQmlEnumValue> &); + + const QMetaObject *metaObject() const; + const QMetaObject *createMetaObject() const; + const QMetaObject *firstCppMetaObject() const; + + template<typename K> + const QQmlPropertyData *property(const K &key, QObject *object, + const QQmlRefPointer<QQmlContextData> &context) const + { + return findProperty(stringCache.find(key), object, context); + } + + const QQmlPropertyData *property(int) const; + const QQmlPropertyData *maybeUnresolvedProperty(int) const; + const QQmlPropertyData *method(int) const; + const QQmlPropertyData *signal(int index) const; + QQmlEnumData *qmlEnum(int) const; + int methodIndexToSignalIndex(int) const; + + QString defaultPropertyName() const; + const QQmlPropertyData *defaultProperty() const; + + // Return a reference here so that we don't have to addref/release all the time + inline const QQmlPropertyCache::ConstPtr &parent() const; + + // is used by the Qml Designer + void setParent(QQmlPropertyCache::ConstPtr newParent); + + inline const QQmlPropertyData *overrideData(const QQmlPropertyData *) const; + inline bool isAllowedInRevision(const QQmlPropertyData *) const; + + static const QQmlPropertyData *property( + QObject *, QStringView, const QQmlRefPointer<QQmlContextData> &, + QQmlPropertyData *); + static const QQmlPropertyData *property(QObject *, const QLatin1String &, const QQmlRefPointer<QQmlContextData> &, + QQmlPropertyData *); + static const QQmlPropertyData *property(QObject *, const QV4::String *, const QQmlRefPointer<QQmlContextData> &, + QQmlPropertyData *); + + //see QMetaObjectPrivate::originalClone + int originalClone(int index) const; + static int originalClone(const QObject *, int index); + + QList<QByteArray> signalParameterNames(int index) const; + static QString signalParameterStringForJS(QV4::ExecutionEngine *engine, const QList<QByteArray> ¶meterNameList, QString *errorString = nullptr); + + const char *className() const; + + inline int propertyCount() const; + inline int propertyOffset() const; + inline int methodCount() const; + inline int methodOffset() const; + inline int signalCount() const; + inline int signalOffset() const; + inline int qmlEnumCount() const; + + void toMetaObjectBuilder(QMetaObjectBuilder &) const; + + inline bool callJSFactoryMethod(QObject *object, void **args) const; + + static bool determineMetaObjectSizes(const QMetaObject &mo, int *fieldCount, int *stringCount); + static bool addToHash(QCryptographicHash &hash, const QMetaObject &mo); + + QByteArray checksum(QHash<quintptr, QByteArray> *checksums, bool *ok) const; + + QTypeRevision allowedRevision(int index) const { return allowedRevisionCache[index]; } + void setAllowedRevision(int index, QTypeRevision allowed) { allowedRevisionCache[index] = allowed; } + +private: + friend class QQmlEnginePrivate; + friend class QQmlCompiler; + template <typename T> friend class QQmlPropertyCacheCreator; + template <typename T> friend class QQmlPropertyCacheAliasCreator; + template <typename T> friend class QQmlComponentAndAliasResolver; + friend class QQmlMetaObject; + + QQmlPropertyCache(const QQmlMetaObjectPointer &metaObject) : _metaObject(metaObject) {} + + inline QQmlPropertyCache::Ptr copy(const QQmlMetaObjectPointer &mo, int reserve) const; + + void append(const QMetaObject *, QTypeRevision typeVersion, + QQmlPropertyData::Flags propertyFlags = QQmlPropertyData::Flags(), + QQmlPropertyData::Flags methodFlags = QQmlPropertyData::Flags(), + QQmlPropertyData::Flags signalFlags = QQmlPropertyData::Flags()); + + QQmlPropertyCacheMethodArguments *createArgumentsObject(int count, const QList<QByteArray> &names); + + typedef QVector<QQmlPropertyData> IndexCache; + typedef QLinkedStringMultiHash<QPair<int, QQmlPropertyData *> > StringCache; + typedef QVector<QTypeRevision> AllowedRevisionCache; + + const QQmlPropertyData *findProperty(StringCache::ConstIterator it, QObject *, + const QQmlRefPointer<QQmlContextData> &) const; + const QQmlPropertyData *findProperty(StringCache::ConstIterator it, const QQmlVMEMetaObject *, + const QQmlRefPointer<QQmlContextData> &) const; + + template<typename K> + QQmlPropertyData *findNamedProperty(const K &key) const + { + StringCache::mapped_type *it = stringCache.value(key); + return it ? it->second : 0; + } + + template<typename K> + void setNamedProperty(const K &key, int index, QQmlPropertyData *data) + { + stringCache.insert(key, qMakePair(index, data)); + } + +private: + enum OverrideResult { NoOverride, InvalidOverride, ValidOverride }; + + template<typename String> + OverrideResult handleOverride(const String &name, QQmlPropertyData *data, QQmlPropertyData *old) + { + if (!old) + return NoOverride; + + if (data->markAsOverrideOf(old)) + return ValidOverride; + + qWarning("Final member %s is overridden in class %s. The override won't be used.", + qPrintable(name), className()); + return InvalidOverride; + } + + template<typename String> + OverrideResult handleOverride(const String &name, QQmlPropertyData *data) + { + return handleOverride(name, data, findNamedProperty(name)); + } + + int propertyIndexCacheStart = 0; // placed here to avoid gap between QQmlRefCount and _parent + QQmlPropertyCache::ConstPtr _parent; + + IndexCache propertyIndexCache; + IndexCache methodIndexCache; + IndexCache signalHandlerIndexCache; + StringCache stringCache; + AllowedRevisionCache allowedRevisionCache; + QVector<QQmlEnumData> enumCache; + + QQmlMetaObjectPointer _metaObject; + QByteArray _dynamicClassName; + QByteArray _dynamicStringData; + QByteArray _listPropertyAssignBehavior; + QString _defaultPropertyName; + QQmlPropertyCacheMethodArguments *argumentsCache = nullptr; + int methodIndexCacheStart = 0; + int signalHandlerIndexCacheStart = 0; + int _jsFactoryMethodIndex = -1; +}; + +// Returns this property cache's metaObject. May be null if it hasn't been created yet. +inline const QMetaObject *QQmlPropertyCache::metaObject() const +{ + return _metaObject.metaObject(); +} + +// Returns the first C++ type's QMetaObject - that is, the first QMetaObject not created by +// QML +inline const QMetaObject *QQmlPropertyCache::firstCppMetaObject() const +{ + const QQmlPropertyCache *p = this; + while (p->_metaObject.isShared()) + p = p->parent().data(); + return p->_metaObject.metaObject(); +} + +inline const QQmlPropertyData *QQmlPropertyCache::property(int index) const +{ + if (index < 0 || index >= propertyCount()) + return nullptr; + + if (index < propertyIndexCacheStart) + return _parent->property(index); + + return &propertyIndexCache.at(index - propertyIndexCacheStart); +} + +inline const QQmlPropertyData *QQmlPropertyCache::method(int index) const +{ + if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.size())) + return nullptr; + + if (index < methodIndexCacheStart) + return _parent->method(index); + + return const_cast<const QQmlPropertyData *>(&methodIndexCache.at(index - methodIndexCacheStart)); +} + +/*! \internal + \a index MUST be in the signal index range (see QObjectPrivate::signalIndex()). + This is different from QMetaMethod::methodIndex(). +*/ +inline const QQmlPropertyData *QQmlPropertyCache::signal(int index) const +{ + if (index < 0 || index >= (signalHandlerIndexCacheStart + signalHandlerIndexCache.size())) + return nullptr; + + if (index < signalHandlerIndexCacheStart) + return _parent->signal(index); + + const QQmlPropertyData *rv = const_cast<const QQmlPropertyData *>(&methodIndexCache.at(index - signalHandlerIndexCacheStart)); + Q_ASSERT(rv->isSignal() || rv->coreIndex() == -1); + return rv; +} + +inline QQmlEnumData *QQmlPropertyCache::qmlEnum(int index) const +{ + if (index < 0 || index >= enumCache.size()) + return nullptr; + + return const_cast<QQmlEnumData *>(&enumCache.at(index)); +} + +inline int QQmlPropertyCache::methodIndexToSignalIndex(int index) const +{ + if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.size())) + return index; + + if (index < methodIndexCacheStart) + return _parent->methodIndexToSignalIndex(index); + + return index - methodIndexCacheStart + signalHandlerIndexCacheStart; +} + +// Returns the name of the default property for this cache +inline QString QQmlPropertyCache::defaultPropertyName() const +{ + return _defaultPropertyName; +} + +inline const QQmlPropertyCache::ConstPtr &QQmlPropertyCache::parent() const +{ + return _parent; +} + +const QQmlPropertyData * +QQmlPropertyCache::overrideData(const QQmlPropertyData *data) const +{ + if (!data->hasOverride()) + return nullptr; + + if (data->overrideIndexIsProperty()) + return property(data->overrideIndex()); + else + return method(data->overrideIndex()); +} + +bool QQmlPropertyCache::isAllowedInRevision(const QQmlPropertyData *data) const +{ + const QTypeRevision requested = data->revision(); + const int offset = data->metaObjectOffset(); + if (offset == -1 && requested == QTypeRevision::zero()) + return true; + + Q_ASSERT(offset >= 0); + Q_ASSERT(offset < allowedRevisionCache.size()); + const QTypeRevision allowed = allowedRevisionCache[offset]; + + if (requested.hasMajorVersion()) { + if (requested.majorVersion() > allowed.majorVersion()) + return false; + if (requested.majorVersion() < allowed.majorVersion()) + return true; + } + + return !requested.hasMinorVersion() || requested.minorVersion() <= allowed.minorVersion(); +} + +int QQmlPropertyCache::propertyCount() const +{ + return propertyIndexCacheStart + int(propertyIndexCache.size()); +} + +int QQmlPropertyCache::propertyOffset() const +{ + return propertyIndexCacheStart; +} + +int QQmlPropertyCache::methodCount() const +{ + return methodIndexCacheStart + int(methodIndexCache.size()); +} + +int QQmlPropertyCache::methodOffset() const +{ + return methodIndexCacheStart; +} + +int QQmlPropertyCache::signalCount() const +{ + return signalHandlerIndexCacheStart + int(signalHandlerIndexCache.size()); +} + +int QQmlPropertyCache::signalOffset() const +{ + return signalHandlerIndexCacheStart; +} + +int QQmlPropertyCache::qmlEnumCount() const +{ + return int(enumCache.size()); +} + +bool QQmlPropertyCache::callJSFactoryMethod(QObject *object, void **args) const +{ + if (_jsFactoryMethodIndex != -1) { + if (const QMetaObject *mo = _metaObject.metaObject()) { + mo->d.static_metacall(object, QMetaObject::InvokeMetaMethod, + _jsFactoryMethodIndex, args); + return true; + } + return false; + } + if (_parent) + return _parent->callJSFactoryMethod(object, args); + return false; +} + +QT_END_NAMESPACE + +#endif // QQMLPROPERTYCACHE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycachecreator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycachecreator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b3056ff5c2d49e17efbed45a86b282883baf57b7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycachecreator_p.h @@ -0,0 +1,1041 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQMLPROPERTYCACHECREATOR_P_H +#define QQMLPROPERTYCACHECREATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlvaluetype_p.h> +#include <private/qqmlengine_p.h> +#include <private/qqmlmetaobject_p.h> +#include <private/qqmlpropertyresolver_p.h> +#include <private/qqmltypedata_p.h> +#include <private/inlinecomponentutils_p.h> +#include <private/qqmlsourcecoordinate_p.h> +#include <private/qqmlsignalnames_p.h> + +#include <QScopedValueRollback> + +#if QT_CONFIG(regularexpression) +#include <QtCore/qregularexpression.h> +#endif + +#include <vector> + +QT_BEGIN_NAMESPACE + +inline QQmlError qQmlCompileError(const QV4::CompiledData::Location &location, + const QString &description) +{ + QQmlError error; + error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line())); + error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column())); + error.setDescription(description); + return error; +} + +struct QQmlBindingInstantiationContext { + QQmlBindingInstantiationContext() {} + QQmlBindingInstantiationContext( + int referencingObjectIndex, const QV4::CompiledData::Binding *instantiatingBinding, + const QString &instantiatingPropertyName, + const QQmlPropertyCache::ConstPtr &referencingObjectPropertyCache); + + bool resolveInstantiatingProperty(); + QQmlPropertyCache::ConstPtr instantiatingPropertyCache() const; + + int referencingObjectIndex = -1; + const QV4::CompiledData::Binding *instantiatingBinding = nullptr; + QString instantiatingPropertyName; + QQmlPropertyCache::ConstPtr referencingObjectPropertyCache; + const QQmlPropertyData *instantiatingProperty = nullptr; +}; + +struct QQmlPendingGroupPropertyBindings : public QVector<QQmlBindingInstantiationContext> +{ + void resolveMissingPropertyCaches( + QQmlPropertyCacheVector *propertyCaches) const; +}; + +struct QQmlPropertyCacheCreatorBase +{ + Q_DECLARE_TR_FUNCTIONS(QQmlPropertyCacheCreatorBase) +public: + static QAtomicInt Q_AUTOTEST_EXPORT classIndexCounter; + + static QMetaType metaTypeForPropertyType(QV4::CompiledData::CommonType type) + { + switch (type) { + case QV4::CompiledData::CommonType::Void: return QMetaType(); + case QV4::CompiledData::CommonType::Var: return QMetaType::fromType<QVariant>(); + case QV4::CompiledData::CommonType::Int: return QMetaType::fromType<int>(); + case QV4::CompiledData::CommonType::Bool: return QMetaType::fromType<bool>(); + case QV4::CompiledData::CommonType::Real: return QMetaType::fromType<qreal>(); + case QV4::CompiledData::CommonType::String: return QMetaType::fromType<QString>(); + case QV4::CompiledData::CommonType::Url: return QMetaType::fromType<QUrl>(); + case QV4::CompiledData::CommonType::Time: return QMetaType::fromType<QTime>(); + case QV4::CompiledData::CommonType::Date: return QMetaType::fromType<QDate>(); + case QV4::CompiledData::CommonType::DateTime: return QMetaType::fromType<QDateTime>(); +#if QT_CONFIG(regularexpression) + case QV4::CompiledData::CommonType::RegExp: return QMetaType::fromType<QRegularExpression>(); +#else + case QV4::CompiledData::CommonType::RegExp: return QMetaType(); +#endif + case QV4::CompiledData::CommonType::Rect: return QMetaType::fromType<QRectF>(); + case QV4::CompiledData::CommonType::Point: return QMetaType::fromType<QPointF>(); + case QV4::CompiledData::CommonType::Size: return QMetaType::fromType<QSizeF>(); + case QV4::CompiledData::CommonType::Invalid: break; + }; + return QMetaType {}; + } + + static QMetaType listTypeForPropertyType(QV4::CompiledData::CommonType type) + { + switch (type) { + case QV4::CompiledData::CommonType::Void: return QMetaType(); + case QV4::CompiledData::CommonType::Var: return QMetaType::fromType<QList<QVariant>>(); + case QV4::CompiledData::CommonType::Int: return QMetaType::fromType<QList<int>>(); + case QV4::CompiledData::CommonType::Bool: return QMetaType::fromType<QList<bool>>(); + case QV4::CompiledData::CommonType::Real: return QMetaType::fromType<QList<qreal>>(); + case QV4::CompiledData::CommonType::String: return QMetaType::fromType<QList<QString>>(); + case QV4::CompiledData::CommonType::Url: return QMetaType::fromType<QList<QUrl>>(); + case QV4::CompiledData::CommonType::Time: return QMetaType::fromType<QList<QTime>>(); + case QV4::CompiledData::CommonType::Date: return QMetaType::fromType<QList<QDate>>(); + case QV4::CompiledData::CommonType::DateTime: return QMetaType::fromType<QList<QDateTime>>(); +#if QT_CONFIG(regularexpression) + case QV4::CompiledData::CommonType::RegExp: return QMetaType::fromType<QList<QRegularExpression>>(); +#else + case QV4::CompiledData::CommonType::RegExp: return QMetaType(); +#endif + case QV4::CompiledData::CommonType::Rect: return QMetaType::fromType<QList<QRectF>>(); + case QV4::CompiledData::CommonType::Point: return QMetaType::fromType<QList<QPointF>>(); + case QV4::CompiledData::CommonType::Size: return QMetaType::fromType<QList<QSizeF>>(); + case QV4::CompiledData::CommonType::Invalid: break; + }; + return QMetaType {}; + } + + static bool canCreateClassNameTypeByUrl(const QUrl &url); + static QByteArray createClassNameTypeByUrl(const QUrl &url); + + static QByteArray createClassNameForInlineComponent(const QUrl &baseUrl, const QString &name); + + struct IncrementalResult { + // valid if and only if an error occurred + QQmlError error; + // true if there was no error and there are still components left to process + bool canResume = false; + // the object index of the last processed (inline) component root. + int processedRoot = 0; + }; +}; + +template <typename ObjectContainer> +class QQmlPropertyCacheCreator : public QQmlPropertyCacheCreatorBase +{ +public: + using CompiledObject = typename ObjectContainer::CompiledObject; + using InlineComponent = typename std::remove_reference<decltype (*(std::declval<CompiledObject>().inlineComponentsBegin()))>::type; + + QQmlPropertyCacheCreator(QQmlPropertyCacheVector *propertyCaches, + QQmlPendingGroupPropertyBindings *pendingGroupPropertyBindings, + QQmlEnginePrivate *enginePrivate, + const ObjectContainer *objectContainer, const QQmlImports *imports, + const QByteArray &typeClassName); + ~QQmlPropertyCacheCreator() { propertyCaches->seal(); } + + + /*! + \internal + Creates the property cache for the CompiledObjects of objectContainer, + one (inline) root component at a time. + + \note Later compiler passes might modify those property caches. Therefore, + the actual metaobjects are not created yet. + */ + IncrementalResult buildMetaObjectsIncrementally(); + + /*! + \internal + Returns a valid error if the inline components of the objectContainer + form a cycle. Otherwise an invalid error is returned + */ + QQmlError verifyNoICCycle(); + + enum class VMEMetaObjectIsRequired { + Maybe, + Always + }; +protected: + QQmlError buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired); + QQmlPropertyCache::ConstPtr propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlError *error) const; + QQmlError createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlPropertyCache::ConstPtr &baseTypeCache); + + QMetaType metaTypeForParameter(const QV4::CompiledData::ParameterType ¶m, QString *customTypeName = nullptr); + + QString stringAt(int index) const { return objectContainer->stringAt(index); } + + QQmlEnginePrivate * const enginePrivate; + const ObjectContainer * const objectContainer; + const QQmlImports * const imports; + QQmlPropertyCacheVector *propertyCaches; + QQmlPendingGroupPropertyBindings *pendingGroupPropertyBindings; + QByteArray typeClassName; // not const as we temporarily chang it for inline components + unsigned int currentRoot; // set to objectID of inline component root when handling inline components + + QQmlBindingInstantiationContext m_context; + std::vector<InlineComponent> allICs; + std::vector<icutils::Node> nodesSorted; + std::vector<icutils::Node>::reverse_iterator nodeIt = nodesSorted.rbegin(); + bool hasCycle = false; +}; + +template <typename ObjectContainer> +inline QQmlPropertyCacheCreator<ObjectContainer>::QQmlPropertyCacheCreator(QQmlPropertyCacheVector *propertyCaches, + QQmlPendingGroupPropertyBindings *pendingGroupPropertyBindings, + QQmlEnginePrivate *enginePrivate, + const ObjectContainer *objectContainer, const QQmlImports *imports, + const QByteArray &typeClassName) + : enginePrivate(enginePrivate) + , objectContainer(objectContainer) + , imports(imports) + , propertyCaches(propertyCaches) + , pendingGroupPropertyBindings(pendingGroupPropertyBindings) + , typeClassName(typeClassName) + , currentRoot(-1) +{ + propertyCaches->resetAndResize(objectContainer->objectCount()); + + using namespace icutils; + + // get a list of all inline components + + for (int i=0; i != objectContainer->objectCount(); ++i) { + const CompiledObject *obj = objectContainer->objectAt(i); + for (auto it = obj->inlineComponentsBegin(); it != obj->inlineComponentsEnd(); ++it) { + allICs.push_back(*it); + } + } + + // create a graph on inline components referencing inline components + std::vector<icutils::Node> nodes; + nodes.resize(allICs.size()); + std::iota(nodes.begin(), nodes.end(), 0); + AdjacencyList adjacencyList; + adjacencyList.resize(nodes.size()); + fillAdjacencyListForInlineComponents(objectContainer, adjacencyList, nodes, allICs); + + nodesSorted = topoSort(nodes, adjacencyList, hasCycle); + nodeIt = nodesSorted.rbegin(); +} + +template <typename ObjectContainer> +inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::verifyNoICCycle() +{ + if (hasCycle) { + QQmlError diag; + diag.setDescription(QLatin1String("Inline components form a cycle!")); + return diag; + } + return {}; +} + +template <typename ObjectContainer> +inline QQmlPropertyCacheCreatorBase::IncrementalResult +QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjectsIncrementally() +{ + // needs to be checked with verifyNoICCycle before this function is called + Q_ASSERT(!hasCycle); + + // create meta objects for inline components before compiling actual root component + if (nodeIt != nodesSorted.rend()) { + const auto &ic = allICs[nodeIt->index()]; + QV4::ResolvedTypeReference *typeRef = objectContainer->resolvedType(ic.nameIndex); + Q_ASSERT(propertyCaches->at(ic.objectIndex).isNull()); + Q_ASSERT(typeRef->typePropertyCache().isNull()); // not set yet + + QByteArray icTypeName { objectContainer->stringAt(ic.nameIndex).toUtf8() }; + QScopedValueRollback<QByteArray> nameChange {typeClassName, icTypeName}; + QScopedValueRollback<unsigned int> rootChange {currentRoot, ic.objectIndex}; + ++nodeIt; + QQmlError diag = buildMetaObjectRecursively(ic.objectIndex, m_context, VMEMetaObjectIsRequired::Always); + if (diag.isValid()) { + return {diag, false, 0}; + } + typeRef->setTypePropertyCache(propertyCaches->at(ic.objectIndex)); + Q_ASSERT(!typeRef->typePropertyCache().isNull()); + return { QQmlError(), true, int(ic.objectIndex) }; + } + + auto diag = buildMetaObjectRecursively(/*root object*/0, m_context, VMEMetaObjectIsRequired::Maybe); + return {diag, false, 0}; +} + +template <typename ObjectContainer> +inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired) +{ + auto isAddressable = [](const QUrl &url) { + const QString fileName = url.fileName(); + return !fileName.isEmpty() && fileName.front().isUpper(); + }; + + const CompiledObject *obj = objectContainer->objectAt(objectIndex); + bool needVMEMetaObject = isVMERequired == VMEMetaObjectIsRequired::Always || obj->propertyCount() != 0 || obj->aliasCount() != 0 + || obj->signalCount() != 0 || obj->functionCount() != 0 || obj->enumCount() != 0 + || ((obj->hasFlag(QV4::CompiledData::Object::IsComponent) + || (objectIndex == 0 && isAddressable(objectContainer->url()))) + && !objectContainer->resolvedType(obj->inheritedTypeNameIndex)->isFullyDynamicType()); + + if (!needVMEMetaObject) { + auto binding = obj->bindingsBegin(); + auto end = obj->bindingsEnd(); + for ( ; binding != end; ++binding) { + if (binding->type() == QV4::CompiledData::Binding::Type_Object + && (binding->flags() & QV4::CompiledData::Binding::IsOnAssignment)) { + // If the on assignment is inside a group property, we need to distinguish between QObject based + // group properties and value type group properties. For the former the base type is derived from + // the property that references us, for the latter we only need a meta-object on the referencing object + // because interceptors can't go to the shared value type instances. + if (context.instantiatingProperty && QQmlMetaType::isValueType(context.instantiatingProperty->propType())) { + if (!propertyCaches->needsVMEMetaObject(context.referencingObjectIndex)) { + const CompiledObject *obj = objectContainer->objectAt(context.referencingObjectIndex); + auto *typeRef = objectContainer->resolvedType(obj->inheritedTypeNameIndex); + Q_ASSERT(typeRef); + QQmlPropertyCache::ConstPtr baseTypeCache = typeRef->createPropertyCache(); + QQmlError error = baseTypeCache + ? createMetaObject(context.referencingObjectIndex, obj, baseTypeCache) + : qQmlCompileError(binding->location, QQmlPropertyCacheCreatorBase::tr( + "Type cannot be used for 'on' assignment")); + if (error.isValid()) + return error; + } + } else { + // On assignments are implemented using value interceptors, which require a VME meta object. + needVMEMetaObject = true; + } + break; + } + } + } + + QQmlPropertyCache::ConstPtr baseTypeCache; + { + QQmlError error; + baseTypeCache = propertyCacheForObject(obj, context, &error); + if (error.isValid()) + return error; + } + + if (baseTypeCache) { + if (needVMEMetaObject) { + QQmlError error = createMetaObject(objectIndex, obj, baseTypeCache); + if (error.isValid()) + return error; + } else { + propertyCaches->set(objectIndex, baseTypeCache); + } + } + + QQmlPropertyCache::ConstPtr thisCache = propertyCaches->at(objectIndex); + auto binding = obj->bindingsBegin(); + auto end = obj->bindingsEnd(); + for (; binding != end; ++binding) { + switch (binding->type()) { + case QV4::CompiledData::Binding::Type_Object: + case QV4::CompiledData::Binding::Type_GroupProperty: + case QV4::CompiledData::Binding::Type_AttachedProperty: + // We can always resolve object, group, and attached properties. + break; + default: + // Everything else is of no interest here. + continue; + } + + QQmlBindingInstantiationContext context( + objectIndex, &(*binding), stringAt(binding->propertyNameIndex), thisCache); + + // Binding to group property where we failed to look up the type of the + // property? Possibly a group property that is an alias that's not resolved yet. + // Let's attempt to resolve it after we're done with the aliases and fill in the + // propertyCaches entry then. + if (!thisCache || !context.resolveInstantiatingProperty()) + pendingGroupPropertyBindings->append(context); + + QQmlError error = buildMetaObjectRecursively( + binding->value.objectIndex, context, VMEMetaObjectIsRequired::Maybe); + if (error.isValid()) + return error; + } + + QQmlError noError; + return noError; +} + +template <typename ObjectContainer> +inline QQmlPropertyCache::ConstPtr QQmlPropertyCacheCreator<ObjectContainer>::propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlError *error) const +{ + if (context.instantiatingProperty) { + return context.instantiatingPropertyCache(); + } else if (obj->inheritedTypeNameIndex != 0) { + auto *typeRef = objectContainer->resolvedType(obj->inheritedTypeNameIndex); + Q_ASSERT(typeRef); + + if (typeRef->isFullyDynamicType()) { + if (obj->propertyCount() > 0 || obj->aliasCount() > 0) { + *error = qQmlCompileError(obj->location, QQmlPropertyCacheCreatorBase::tr("Fully dynamic types cannot declare new properties.")); + return nullptr; + } + if (obj->signalCount() > 0) { + *error = qQmlCompileError(obj->location, QQmlPropertyCacheCreatorBase::tr("Fully dynamic types cannot declare new signals.")); + return nullptr; + } + if (obj->functionCount() > 0) { + *error = qQmlCompileError(obj->location, QQmlPropertyCacheCreatorBase::tr("Fully Dynamic types cannot declare new functions.")); + return nullptr; + } + } + + if (QQmlPropertyCache::ConstPtr propertyCache = typeRef->createPropertyCache()) + return propertyCache; + *error = qQmlCompileError( + obj->location, + QQmlPropertyCacheCreatorBase::tr("Type '%1' cannot declare new members.") + .arg(stringAt(obj->inheritedTypeNameIndex))); + return nullptr; + } else if (const QV4::CompiledData::Binding *binding = context.instantiatingBinding) { + if (binding->isAttachedProperty()) { + auto *typeRef = objectContainer->resolvedType( + binding->propertyNameIndex); + Q_ASSERT(typeRef); + QQmlType qmltype = typeRef->type(); + if (!qmltype.isValid()) { + imports->resolveType( + QQmlTypeLoader::get(enginePrivate), stringAt(binding->propertyNameIndex), + &qmltype, nullptr, nullptr); + } + + const QMetaObject *attachedMo = qmltype.attachedPropertiesType(enginePrivate); + if (!attachedMo) { + *error = qQmlCompileError(binding->location, QQmlPropertyCacheCreatorBase::tr("Non-existent attached object")); + return nullptr; + } + return QQmlMetaType::propertyCache(attachedMo); + } + } + return nullptr; +} + +template <typename ObjectContainer> +inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject( + int objectIndex, const CompiledObject *obj, + const QQmlPropertyCache::ConstPtr &baseTypeCache) +{ + QQmlPropertyCache::Ptr cache = baseTypeCache->copyAndReserve( + obj->propertyCount() + obj->aliasCount(), + obj->functionCount() + obj->propertyCount() + obj->aliasCount() + obj->signalCount(), + obj->signalCount() + obj->propertyCount() + obj->aliasCount(), + obj->enumCount()); + + propertyCaches->setOwn(objectIndex, cache); + propertyCaches->setNeedsVMEMetaObject(objectIndex); + + QByteArray newClassName; + + if (objectIndex == /*root object*/0 || int(currentRoot) == objectIndex) { + newClassName = typeClassName; + } + if (newClassName.isEmpty()) { + newClassName = QQmlMetaObject(baseTypeCache).className(); + newClassName.append("_QML_"); + newClassName.append(QByteArray::number(classIndexCounter.fetchAndAddRelaxed(1))); + } + + cache->_dynamicClassName = newClassName; + + using ListPropertyAssignBehavior = typename ObjectContainer::ListPropertyAssignBehavior; + switch (objectContainer->listPropertyAssignBehavior()) { + case ListPropertyAssignBehavior::ReplaceIfNotDefault: + cache->_listPropertyAssignBehavior = "ReplaceIfNotDefault"; + break; + case ListPropertyAssignBehavior::Replace: + cache->_listPropertyAssignBehavior = "Replace"; + break; + case ListPropertyAssignBehavior::Append: + break; + } + + QQmlPropertyResolver resolver(baseTypeCache); + + auto p = obj->propertiesBegin(); + auto pend = obj->propertiesEnd(); + for ( ; p != pend; ++p) { + bool notInRevision = false; + const QQmlPropertyData *d = resolver.property(stringAt(p->nameIndex), ¬InRevision); + if (d && d->isFinal()) + return qQmlCompileError(p->location, QQmlPropertyCacheCreatorBase::tr("Cannot override FINAL property")); + } + + auto a = obj->aliasesBegin(); + auto aend = obj->aliasesEnd(); + for ( ; a != aend; ++a) { + bool notInRevision = false; + const QQmlPropertyData *d = resolver.property(stringAt(a->nameIndex()), ¬InRevision); + if (d && d->isFinal()) + return qQmlCompileError(a->location, QQmlPropertyCacheCreatorBase::tr("Cannot override FINAL property")); + } + + int effectivePropertyIndex = cache->propertyIndexCacheStart; + int effectiveMethodIndex = cache->methodIndexCacheStart; + + // For property change signal override detection. + // We prepopulate a set of signal names which already exist in the object, + // and throw an error if there is a signal/method defined as an override. + // TODO: Remove AllowOverride once we can. No override should be allowed. + enum class AllowOverride { No, Yes }; + QHash<QString, AllowOverride> seenSignals { + { QStringLiteral("destroyed"), AllowOverride::No }, + { QStringLiteral("parentChanged"), AllowOverride::No }, + { QStringLiteral("objectNameChanged"), AllowOverride::No } + }; + const QQmlPropertyCache *parentCache = cache.data(); + while ((parentCache = parentCache->parent().data())) { + if (int pSigCount = parentCache->signalCount()) { + int pSigOffset = parentCache->signalOffset(); + for (int i = pSigOffset; i < pSigCount; ++i) { + const QQmlPropertyData *currPSig = parentCache->signal(i); + // XXX TODO: find a better way to get signal name from the property data :-/ + for (QQmlPropertyCache::StringCache::ConstIterator iter = parentCache->stringCache.begin(); + iter != parentCache->stringCache.end(); ++iter) { + if (currPSig == (*iter).second) { + if (currPSig->isOverridableSignal()) { + const qsizetype oldSize = seenSignals.size(); + AllowOverride &entry = seenSignals[iter.key()]; + if (seenSignals.size() != oldSize) + entry = AllowOverride::Yes; + } else { + seenSignals[iter.key()] = AllowOverride::No; + } + + break; + } + } + } + } + } + + // Set up notify signals for properties - first normal, then alias + p = obj->propertiesBegin(); + pend = obj->propertiesEnd(); + for ( ; p != pend; ++p) { + auto flags = QQmlPropertyData::defaultSignalFlags(); + + const QString changedSigName = + QQmlSignalNames::propertyNameToChangedSignalName(stringAt(p->nameIndex)); + seenSignals[changedSigName] = AllowOverride::No; + + cache->appendSignal(changedSigName, flags, effectiveMethodIndex++); + } + + a = obj->aliasesBegin(); + aend = obj->aliasesEnd(); + for ( ; a != aend; ++a) { + auto flags = QQmlPropertyData::defaultSignalFlags(); + + const QString changedSigName = + QQmlSignalNames::propertyNameToChangedSignalName(stringAt(a->nameIndex())); + seenSignals[changedSigName] = AllowOverride::No; + + cache->appendSignal(changedSigName, flags, effectiveMethodIndex++); + } + + auto e = obj->enumsBegin(); + auto eend = obj->enumsEnd(); + for ( ; e != eend; ++e) { + const int enumValueCount = e->enumValueCount(); + QVector<QQmlEnumValue> values; + values.reserve(enumValueCount); + + auto enumValue = e->enumValuesBegin(); + auto end = e->enumValuesEnd(); + for ( ; enumValue != end; ++enumValue) + values.append(QQmlEnumValue(stringAt(enumValue->nameIndex), enumValue->value)); + + cache->appendEnum(stringAt(e->nameIndex), values); + } + + // Dynamic signals + auto s = obj->signalsBegin(); + auto send = obj->signalsEnd(); + for ( ; s != send; ++s) { + const int paramCount = s->parameterCount(); + + QList<QByteArray> names; + names.reserve(paramCount); + QVarLengthArray<QMetaType, 10> paramTypes(paramCount); + + if (paramCount) { + + int i = 0; + auto param = s->parametersBegin(); + auto end = s->parametersEnd(); + for ( ; param != end; ++param, ++i) { + names.append(stringAt(param->nameIndex).toUtf8()); + + QString customTypeName; + QMetaType type = metaTypeForParameter(param->type, &customTypeName); + if (!type.isValid()) + return qQmlCompileError(s->location, QQmlPropertyCacheCreatorBase::tr("Invalid signal parameter type: %1").arg(customTypeName)); + + paramTypes[i] = type; + } + } + + auto flags = QQmlPropertyData::defaultSignalFlags(); + if (paramCount) + flags.setHasArguments(true); + + QString signalName = stringAt(s->nameIndex); + const auto it = seenSignals.find(signalName); + if (it == seenSignals.end()) { + seenSignals[signalName] = AllowOverride::No; + } else { + // TODO: Remove the AllowOverride::Yes branch once we can. + QQmlError message = qQmlCompileError( + s->location, + QQmlPropertyCacheCreatorBase::tr( + "Duplicate signal name: " + "invalid override of property change signal or superclass signal")); + switch (*it) { + case AllowOverride::No: + return message; + case AllowOverride::Yes: + message.setUrl(objectContainer->url()); + enginePrivate->warning(message); + *it = AllowOverride::No; // No further overriding allowed. + break; + } + } + cache->appendSignal(signalName, flags, effectiveMethodIndex++, + paramCount?paramTypes.constData():nullptr, names); + } + + + // Dynamic slots + auto function = objectContainer->objectFunctionsBegin(obj); + auto fend = objectContainer->objectFunctionsEnd(obj); + for ( ; function != fend; ++function) { + auto flags = QQmlPropertyData::defaultSlotFlags(); + + const QString slotName = stringAt(function->nameIndex); + const auto it = seenSignals.constFind(slotName); + if (it != seenSignals.constEnd()) { + // TODO: Remove the AllowOverride::Yes branch once we can. + QQmlError message = qQmlCompileError( + function->location, + QQmlPropertyCacheCreatorBase::tr( + "Duplicate method name: " + "invalid override of property change signal or superclass signal")); + switch (*it) { + case AllowOverride::No: + return message; + case AllowOverride::Yes: + message.setUrl(objectContainer->url()); + enginePrivate->warning(message); + break; + } + } + // Note: we don't append slotName to the seenSignals list, since we don't + // protect against overriding change signals or methods with properties. + + QList<QByteArray> parameterNames; + QVector<QMetaType> parameterTypes; + auto formal = function->formalsBegin(); + auto end = function->formalsEnd(); + for ( ; formal != end; ++formal) { + flags.setHasArguments(true); + parameterNames << stringAt(formal->nameIndex).toUtf8(); + QMetaType type = metaTypeForParameter(formal->type); + if (!type.isValid()) + type = QMetaType::fromType<QVariant>(); + parameterTypes << type; + } + + QMetaType returnType = metaTypeForParameter(function->returnType); + if (!returnType.isValid()) + returnType = QMetaType::fromType<QVariant>(); + + cache->appendMethod(slotName, flags, effectiveMethodIndex++, returnType, parameterNames, parameterTypes); + } + + + // Dynamic properties + int effectiveSignalIndex = cache->signalHandlerIndexCacheStart; + int propertyIdx = 0; + p = obj->propertiesBegin(); + pend = obj->propertiesEnd(); + for ( ; p != pend; ++p, ++propertyIdx) { + QMetaType propertyType; + QTypeRevision propertyTypeVersion = QTypeRevision::zero(); + QQmlPropertyData::Flags propertyFlags; + + const QV4::CompiledData::CommonType type = p->commonType(); + + if (p->isList()) + propertyFlags.setType(QQmlPropertyData::Flags::QListType); + else if (type == QV4::CompiledData::CommonType::Var) + propertyFlags.setType(QQmlPropertyData::Flags::VarPropertyType); + + if (type != QV4::CompiledData::CommonType::Invalid) { + propertyType = p->isList() + ? listTypeForPropertyType(type) + : metaTypeForPropertyType(type); + } else { + Q_ASSERT(!p->isCommonType()); + + QQmlType qmltype; + bool selfReference = false; + if (!imports->resolveType( + QQmlTypeLoader::get(enginePrivate), + stringAt(p->commonTypeOrTypeNameIndex()), &qmltype, nullptr, nullptr, + nullptr, QQmlType::AnyRegistrationType, &selfReference)) { + return qQmlCompileError(p->location, QQmlPropertyCacheCreatorBase::tr("Invalid property type")); + } + + // inline components are not necessarily valid yet + Q_ASSERT(qmltype.isValid()); + if (qmltype.isComposite() || qmltype.isInlineComponentType()) { + QQmlType compositeType; + if (qmltype.isInlineComponentType()) { + compositeType = qmltype; + Q_ASSERT(compositeType.isValid()); + } else if (selfReference) { + compositeType = objectContainer->qmlTypeForComponent(); + } else { + // compositeType may not be the same type as qmlType because multiple engines + // may load different types for the same document. Therefore we have to ask + // our engine's type loader here. + QQmlRefPointer<QQmlTypeData> tdata + = enginePrivate->typeLoader.getType(qmltype.sourceUrl()); + Q_ASSERT(tdata); + Q_ASSERT(tdata->isComplete()); + compositeType = tdata->compilationUnit()->qmlTypeForComponent(); + } + + if (p->isList()) { + propertyType = compositeType.qListTypeId(); + } else { + propertyType = compositeType.typeId(); + } + } else { + if (p->isList()) + propertyType = qmltype.qListTypeId(); + else + propertyType = qmltype.typeId(); + propertyTypeVersion = qmltype.version(); + } + + if (p->isList()) + propertyFlags.setType(QQmlPropertyData::Flags::QListType); + else if (propertyType.flags().testFlag(QMetaType::PointerToQObject)) + propertyFlags.setType(QQmlPropertyData::Flags::QObjectDerivedType); + } + + if (!p->isReadOnly() && !propertyType.flags().testFlag(QMetaType::IsQmlList)) + propertyFlags.setIsWritable(true); + + + QString propertyName = stringAt(p->nameIndex); + if (!obj->hasAliasAsDefaultProperty() && propertyIdx == obj->indexOfDefaultPropertyOrAlias) + cache->_defaultPropertyName = propertyName; + cache->appendProperty(propertyName, propertyFlags, effectivePropertyIndex++, + propertyType, propertyTypeVersion, effectiveSignalIndex); + + effectiveSignalIndex++; + } + + QQmlError noError; + return noError; +} + +template <typename ObjectContainer> +inline QMetaType QQmlPropertyCacheCreator<ObjectContainer>::metaTypeForParameter( + const QV4::CompiledData::ParameterType ¶m, QString *customTypeName) +{ + const quint32 typeId = param.typeNameIndexOrCommonType(); + if (param.indexIsCommonType()) { + // built-in type + if (param.isList()) + return listTypeForPropertyType(QV4::CompiledData::CommonType(typeId)); + return metaTypeForPropertyType(QV4::CompiledData::CommonType(typeId)); + } + + // lazily resolved type + const QString typeName = stringAt(param.typeNameIndexOrCommonType()); + if (customTypeName) + *customTypeName = typeName; + QQmlType qmltype; + bool selfReference = false; + if (!imports->resolveType( + &enginePrivate->typeLoader, typeName, &qmltype, nullptr, nullptr, nullptr, + QQmlType::AnyRegistrationType, &selfReference)) + return QMetaType(); + + if (!qmltype.isComposite()) { + const QMetaType typeId = param.isList() ? qmltype.qListTypeId() : qmltype.typeId(); + if (!typeId.isValid() && qmltype.isInlineComponentType()) { + const QQmlType qmlType = objectContainer->qmlTypeForComponent(qmltype.elementName()); + return param.isList() ? qmlType.qListTypeId() : qmlType.typeId(); + } else { + return typeId; + } + } + + if (selfReference) { + const QQmlType qmlType = objectContainer->qmlTypeForComponent(); + return param.isList() ? qmlType.qListTypeId() : qmlType.typeId(); + } + + return param.isList() ? qmltype.qListTypeId() : qmltype.typeId(); +} + +template <typename ObjectContainer, typename CompiledObject> +int objectForId(const ObjectContainer *objectContainer, const CompiledObject &component, int id) +{ + for (quint32 i = 0, count = component.namedObjectsInComponentCount(); i < count; ++i) { + const int candidateIndex = component.namedObjectsInComponentTable()[i]; + const CompiledObject &candidate = *objectContainer->objectAt(candidateIndex); + if (candidate.objectId() == id) + return candidateIndex; + } + return -1; +} + +template <typename ObjectContainer> +class QQmlPropertyCacheAliasCreator +{ +public: + typedef typename ObjectContainer::CompiledObject CompiledObject; + + QQmlPropertyCacheAliasCreator( + QQmlPropertyCacheVector *propertyCaches, const ObjectContainer *objectContainer); + QQmlError appendAliasesToPropertyCache( + const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv); + +private: + QQmlError propertyDataForAlias( + const CompiledObject &component, const QV4::CompiledData::Alias &alias, QMetaType *type, + QTypeRevision *version, QQmlPropertyData::Flags *propertyFlags, + QQmlEnginePrivate *enginePriv); + + QQmlPropertyCacheVector *propertyCaches; + const ObjectContainer *objectContainer; +}; + +template <typename ObjectContainer> +inline QQmlPropertyCacheAliasCreator<ObjectContainer>::QQmlPropertyCacheAliasCreator( + QQmlPropertyCacheVector *propertyCaches, const ObjectContainer *objectContainer) + : propertyCaches(propertyCaches) + , objectContainer(objectContainer) +{ +} + +template <typename ObjectContainer> +inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias( + const CompiledObject &component, const QV4::CompiledData::Alias &alias, QMetaType *type, + QTypeRevision *version, QQmlPropertyData::Flags *propertyFlags, + QQmlEnginePrivate *enginePriv) +{ + *type = QMetaType(); + bool writable = false; + bool resettable = false; + bool bindable = false; + + propertyFlags->setIsAlias(true); + + if (alias.isAliasToLocalAlias()) { + const QV4::CompiledData::Alias *lastAlias = &alias; + QVarLengthArray<const QV4::CompiledData::Alias *, 4> seenAliases({lastAlias}); + + do { + const int targetObjectIndex = objectForId( + objectContainer, component, lastAlias->targetObjectId()); + Q_ASSERT(targetObjectIndex >= 0); + const CompiledObject *targetObject = objectContainer->objectAt(targetObjectIndex); + Q_ASSERT(targetObject); + + auto nextAlias = targetObject->aliasesBegin(); + for (uint i = 0; i < lastAlias->localAliasIndex; ++i) + ++nextAlias; + + const QV4::CompiledData::Alias *targetAlias = &(*nextAlias); + if (seenAliases.contains(targetAlias)) { + return qQmlCompileError(targetAlias->location, + QQmlPropertyCacheCreatorBase::tr("Cyclic alias")); + } + + seenAliases.append(targetAlias); + lastAlias = targetAlias; + } while (lastAlias->isAliasToLocalAlias()); + + return propertyDataForAlias( + component, *lastAlias, type, version, propertyFlags, enginePriv); + } + + const int targetObjectIndex = objectForId(objectContainer, component, alias.targetObjectId()); + Q_ASSERT(targetObjectIndex >= 0); + const CompiledObject &targetObject = *objectContainer->objectAt(targetObjectIndex); + + if (alias.encodedMetaPropertyIndex == -1) { + Q_ASSERT(alias.hasFlag(QV4::CompiledData::Alias::AliasPointsToPointerObject)); + auto *typeRef = objectContainer->resolvedType(targetObject.inheritedTypeNameIndex); + if (!typeRef) { + // Can be caused by the alias target not being a valid id or property. E.g.: + // property alias dataValue: dataVal + // invalidAliasComponent { id: dataVal } + return qQmlCompileError(targetObject.location, + QQmlPropertyCacheCreatorBase::tr("Invalid alias target")); + } + + const auto referencedType = typeRef->type(); + if (referencedType.isValid()) { + *type = referencedType.typeId(); + if (!type->isValid() && referencedType.isInlineComponentType()) { + *type = objectContainer->qmlTypeForComponent(referencedType.elementName()).typeId(); + Q_ASSERT(type->isValid()); + } + } else { + *type = typeRef->compilationUnit()->metaType(); + } + + *version = typeRef->version(); + + propertyFlags->setType(QQmlPropertyData::Flags::QObjectDerivedType); + } else { + int coreIndex = QQmlPropertyIndex::fromEncoded(alias.encodedMetaPropertyIndex).coreIndex(); + int valueTypeIndex = QQmlPropertyIndex::fromEncoded( + alias.encodedMetaPropertyIndex).valueTypeIndex(); + + QQmlPropertyCache::ConstPtr targetCache = propertyCaches->at(targetObjectIndex); + Q_ASSERT(targetCache); + + const QQmlPropertyData *targetProperty = targetCache->property(coreIndex); + Q_ASSERT(targetProperty); + + const QMetaType targetPropType = targetProperty->propType(); + + const auto populateWithPropertyData = [&](const QQmlPropertyData *property) { + *type = property->propType(); + writable = property->isWritable(); + resettable = property->isResettable(); + bindable = property->isBindable(); + + if (property->isVarProperty()) + propertyFlags->setType(QQmlPropertyData::Flags::QVariantType); + else + propertyFlags->copyPropertyTypeFlags(property->flags()); + }; + + // for deep aliases, valueTypeIndex is always set + if (!QQmlMetaType::isValueType(targetPropType) && valueTypeIndex != -1) { + // deep alias property + + QQmlPropertyCache::ConstPtr typeCache + = QQmlMetaType::propertyCacheForType(targetPropType); + + if (!typeCache) { + // See if it's a half-resolved composite type + if (const QV4::ResolvedTypeReference *typeRef + = objectContainer->resolvedType(targetPropType)) { + typeCache = typeRef->typePropertyCache(); + } + } + + const QQmlPropertyData *typeProperty = typeCache + ? typeCache->property(valueTypeIndex) + : nullptr; + if (typeProperty == nullptr) { + return qQmlCompileError( + alias.referenceLocation, + QQmlPropertyCacheCreatorBase::tr("Invalid alias target")); + } + populateWithPropertyData(typeProperty); + } else { + // value type or primitive type or enum + populateWithPropertyData(targetProperty); + + if (valueTypeIndex != -1) { + const QMetaObject *valueTypeMetaObject + = QQmlMetaType::metaObjectForValueType(*type); + const QMetaProperty valueTypeMetaProperty + = valueTypeMetaObject->property(valueTypeIndex); + *type = valueTypeMetaProperty.metaType(); + + // We can only write or reset the value type property if we can write + // the value type itself. + resettable = writable && valueTypeMetaProperty.isResettable(); + writable = writable && valueTypeMetaProperty.isWritable(); + + bindable = valueTypeMetaProperty.isBindable(); + } + } + } + + propertyFlags->setIsWritable( + writable && !alias.hasFlag(QV4::CompiledData::Alias::IsReadOnly)); + propertyFlags->setIsResettable(resettable); + propertyFlags->setIsBindable(bindable); + return QQmlError(); +} + +template <typename ObjectContainer> +inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasesToPropertyCache( + const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv) +{ + const CompiledObject &object = *objectContainer->objectAt(objectIndex); + if (!object.aliasCount()) + return QQmlError(); + + QQmlPropertyCache::Ptr propertyCache = propertyCaches->ownAt(objectIndex); + Q_ASSERT(propertyCache); + + int effectiveSignalIndex = propertyCache->signalHandlerIndexCacheStart + propertyCache->propertyIndexCache.size(); + int effectivePropertyIndex = propertyCache->propertyIndexCacheStart + propertyCache->propertyIndexCache.size(); + + int aliasIndex = 0; + auto alias = object.aliasesBegin(); + auto end = object.aliasesEnd(); + for ( ; alias != end; ++alias, ++aliasIndex) { + Q_ASSERT(alias->hasFlag(QV4::CompiledData::Alias::Resolved)); + + QMetaType type; + QTypeRevision version = QTypeRevision::zero(); + QQmlPropertyData::Flags propertyFlags; + QQmlError error = propertyDataForAlias(component, *alias, &type, &version, + &propertyFlags, enginePriv); + if (error.isValid()) + return error; + + const QString propertyName = objectContainer->stringAt(alias->nameIndex()); + + if (object.hasAliasAsDefaultProperty() && aliasIndex == object.indexOfDefaultPropertyOrAlias) + propertyCache->_defaultPropertyName = propertyName; + + propertyCache->appendProperty(propertyName, propertyFlags, effectivePropertyIndex++, + type, version, effectiveSignalIndex++); + } + + return QQmlError(); +} + +QT_END_NAMESPACE + +#endif // QQMLPROPERTYCACHECREATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycachemethodarguments_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycachemethodarguments_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5c0c010a9b1b209597bd4f9ef33e7bd24fc8f121 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycachemethodarguments_p.h @@ -0,0 +1,37 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROPERTYCACHEMETODARGUMENTS_P_H +#define QQMLPROPERTYCACHEMETODARGUMENTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qlist.h> +#include <QtCore/qbytearray.h> +#include <QtCore/qtaggedpointer.h> +#include <QtCore/qmetatype.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QString; +class QQmlPropertyCacheMethodArguments +{ +public: + QQmlPropertyCacheMethodArguments *next; + QList<QByteArray> *names; + QMetaType types[1]; // First one is return type +}; + +QT_END_NAMESPACE + +#endif // QQMLPROPERTYCACHEMETODARGUMENTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycachevector_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycachevector_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b57a1ff7738b56607bf980a1f2688e749e8fefb8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertycachevector_p.h @@ -0,0 +1,145 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROPERTYCACHEVECTOR_P_H +#define QQMLPROPERTYCACHEVECTOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlpropertycache_p.h> +#include <private/qbipointer_p.h> + +#include <QtCore/qtaggedpointer.h> + +QT_BEGIN_NAMESPACE + +class QQmlPropertyCacheVector +{ +public: + QQmlPropertyCacheVector() = default; + QQmlPropertyCacheVector(QQmlPropertyCacheVector &&) = default; + QQmlPropertyCacheVector &operator=(QQmlPropertyCacheVector &&) = default; + + ~QQmlPropertyCacheVector() { clear(); } + void resize(int size) + { + Q_ASSERT(size >= data.size()); + return data.resize(size); + } + + int count() const { + // the property cache vector will never contain more thant INT_MAX many elements + return int(data.size()); + } + void clear() + { + for (int i = 0; i < data.size(); ++i) + releaseElement(i); + data.clear(); + } + + void resetAndResize(int size) + { + for (int i = 0; i < data.size(); ++i) { + releaseElement(i); + data[i] = BiPointer(); + } + data.resize(size); + } + + void append(const QQmlPropertyCache::ConstPtr &cache) { + cache->addref(); + data.append(BiPointer(cache.data())); + Q_ASSERT(data.last().isT1()); + Q_ASSERT(data.size() <= std::numeric_limits<int>::max()); + } + + void appendOwn(const QQmlPropertyCache::Ptr &cache) { + cache->addref(); + data.append(BiPointer(cache.data())); + Q_ASSERT(data.last().isT2()); + Q_ASSERT(data.size() <= std::numeric_limits<int>::max()); + } + + QQmlPropertyCache::ConstPtr at(int index) const + { + const auto entry = data.at(index); + if (entry.isT2()) + return entry.asT2(); + return entry.asT1(); + } + + QQmlPropertyCache::Ptr ownAt(int index) const + { + const auto entry = data.at(index); + if (entry.isT2()) + return entry.asT2(); + return QQmlPropertyCache::Ptr(); + } + + void set(int index, const QQmlPropertyCache::ConstPtr &replacement) { + if (QQmlPropertyCache::ConstPtr oldCache = at(index)) { + // If it is our own, we keep it our own + if (replacement.data() == oldCache.data()) + return; + oldCache->release(); + } + data[index] = replacement.data(); + replacement->addref(); + Q_ASSERT(data[index].isT1()); + } + + void setOwn(int index, const QQmlPropertyCache::Ptr &replacement) { + if (QQmlPropertyCache::ConstPtr oldCache = at(index)) { + if (replacement.data() != oldCache.data()) { + oldCache->release(); + replacement->addref(); + } + } else { + replacement->addref(); + } + data[index] = replacement.data(); + Q_ASSERT(data[index].isT2()); + } + + void setNeedsVMEMetaObject(int index) { data[index].setFlag(); } + bool needsVMEMetaObject(int index) const { return data.at(index).flag(); } + + void seal() + { + for (auto &entry: data) { + if (entry.isT2()) + entry = static_cast<const QQmlPropertyCache *>(entry.asT2()); + Q_ASSERT(entry.isT1()); + } + } + +private: + void releaseElement(int i) + { + const auto &cache = data.at(i); + if (cache.isT2()) { + if (QQmlPropertyCache *data = cache.asT2()) + data->release(); + } else if (const QQmlPropertyCache *data = cache.asT1()) { + data->release(); + } + } + + Q_DISABLE_COPY(QQmlPropertyCacheVector) + using BiPointer = QBiPointer<const QQmlPropertyCache, QQmlPropertyCache>; + QVector<BiPointer> data; +}; + +QT_END_NAMESPACE + +#endif // QQMLPROPERTYCACHEVECTOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertydata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertydata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9a984dd233425fa39e93cfee7324fdd3c3239479 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertydata_p.h @@ -0,0 +1,510 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROPERTYDATA_P_H +#define QQMLPROPERTYDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qobject_p.h> +#include <QtCore/qglobal.h> +#include <QtCore/qversionnumber.h> + +QT_BEGIN_NAMESPACE + +class QQmlPropertyCacheMethodArguments; +class QQmlPropertyData +{ +public: + enum WriteFlag { + BypassInterceptor = 0x01, + DontRemoveBinding = 0x02, + RemoveBindingOnAliasWrite = 0x04, + HasInternalIndex = 0x8, + }; + Q_DECLARE_FLAGS(WriteFlags, WriteFlag) + + typedef QObjectPrivate::StaticMetaCallFunction StaticMetaCallFunction; + + struct Flags { + friend class QQmlPropertyData; + enum Type { + OtherType = 0, + FunctionType = 1, // Is an invokable + QObjectDerivedType = 2, // Property type is a QObject* derived type + EnumType = 3, // Property type is an enum + QListType = 4, // Property type is a QML list + VarPropertyType = 5, // Property type is a "var" property of VMEMO + QVariantType = 6, // Property is a QVariant + // One spot left for an extra type in the 3 bits used to store this. + }; + + private: + // The _otherBits (which "pad" the Flags struct to align it nicely) are used + // to store the relative property index. It will only get used when said index fits. See + // trySetStaticMetaCallFunction for details. + // (Note: this padding is done here, because certain compilers have surprising behavior + // when an enum is declared in-between two bit fields.) + enum { BitsLeftInFlags = 16 }; + unsigned otherBits : BitsLeftInFlags; // align to 32 bits + + // Members of the form aORb can only be a when type is not FunctionType, and only be + // b when type equals FunctionType. For that reason, the semantic meaning of the bit is + // overloaded, and the accessor functions are used to get the correct value + // + // Moreover, isSignalHandler, isOverridableSignal and isCloned make only sense + // for functions, too (and could at a later point be reused for flags that only make sense + // for non-functions) + // + // Lastly, isDirect and isOverridden apply to both functions and non-functions + unsigned isConst : 1; // Property: has CONST flag/Method: is const + unsigned isVMEFunction : 1; // Function was added by QML + unsigned isWritableORhasArguments : 1; // Has WRITE function OR Function takes arguments + unsigned isResettableORisSignal : 1; // Has RESET function OR Function is a signal + unsigned isAliasORisVMESignal : 1; // Is a QML alias to another property OR Signal was added by QML + unsigned isFinalORisV4Function : 1; // Has FINAL flag OR Function takes QQmlV4FunctionPtr args + unsigned isSignalHandler : 1; // Function is a signal handler + + // TODO: Remove this once we can. Signals should not be overridable. + unsigned isOverridableSignal : 1; // Function is an overridable signal + + unsigned isRequiredORisCloned : 1; // Has REQUIRED flag OR The function was marked as cloned + unsigned isConstructorORisBindable : 1; // The function was marked is a constructor OR property is backed by QProperty<T> + unsigned isOverridden : 1; // Is overridden by a extension property + unsigned hasMetaObject : 1; + unsigned type : 3; // stores an entry of Types + + // Internal QQmlPropertyCache flags + unsigned overrideIndexIsProperty : 1; + + public: + inline Flags(); + inline bool operator==(const Flags &other) const; + inline void copyPropertyTypeFlags(Flags from); + + void setIsConstant(bool b) { + isConst = b; + } + + void setIsWritable(bool b) { + Q_ASSERT(type != FunctionType); + isWritableORhasArguments = b; + } + + void setIsResettable(bool b) { + Q_ASSERT(type != FunctionType); + isResettableORisSignal = b; + } + + void setIsAlias(bool b) { + Q_ASSERT(type != FunctionType); + isAliasORisVMESignal = b; + } + + void setIsFinal(bool b) { + Q_ASSERT(type != FunctionType); + isFinalORisV4Function = b; + } + + void setIsOverridden(bool b) { + isOverridden = b; + } + + void setIsBindable(bool b) { + Q_ASSERT(type != FunctionType); + isConstructorORisBindable = b; + } + + void setIsRequired(bool b) { + Q_ASSERT(type != FunctionType); + isRequiredORisCloned = b; + } + + void setIsVMEFunction(bool b) { + Q_ASSERT(type == FunctionType); + isVMEFunction = b; + } + void setHasArguments(bool b) { + Q_ASSERT(type == FunctionType); + isWritableORhasArguments = b; + } + void setIsSignal(bool b) { + Q_ASSERT(type == FunctionType); + isResettableORisSignal = b; + } + void setIsVMESignal(bool b) { + Q_ASSERT(type == FunctionType); + isAliasORisVMESignal = b; + } + + void setIsV4Function(bool b) { + Q_ASSERT(type == FunctionType); + isFinalORisV4Function = b; + } + + void setIsSignalHandler(bool b) { + Q_ASSERT(type == FunctionType); + isSignalHandler = b; + } + + // TODO: Remove this once we can. Signals should not be overridable. + void setIsOverridableSignal(bool b) { + Q_ASSERT(type == FunctionType); + Q_ASSERT(isResettableORisSignal); + isOverridableSignal = b; + } + + void setIsCloned(bool b) { + Q_ASSERT(type == FunctionType); + isRequiredORisCloned = b; + } + + void setIsConstructor(bool b) { + Q_ASSERT(type == FunctionType); + isConstructorORisBindable = b; + } + + void setHasMetaObject(bool b) { + hasMetaObject = b; + } + + void setType(Type newType) { + type = newType; + } + }; + + + inline bool operator==(const QQmlPropertyData &) const; + + Flags flags() const { return m_flags; } + void setFlags(Flags f) + { + unsigned otherBits = m_flags.otherBits; + m_flags = f; + m_flags.otherBits = otherBits; + } + + bool isValid() const { return coreIndex() != -1; } + + bool isConstant() const { return m_flags.isConst; } + bool isWritable() const { return !isFunction() && m_flags.isWritableORhasArguments; } + void setWritable(bool onoff) { Q_ASSERT(!isFunction()); m_flags.isWritableORhasArguments = onoff; } + bool isResettable() const { return !isFunction() && m_flags.isResettableORisSignal; } + bool isAlias() const { return !isFunction() && m_flags.isAliasORisVMESignal; } + bool isFinal() const { return !isFunction() && m_flags.isFinalORisV4Function; } + bool isOverridden() const { return m_flags.isOverridden; } + bool isRequired() const { return !isFunction() && m_flags.isRequiredORisCloned; } + bool hasStaticMetaCallFunction() const { return staticMetaCallFunction() != nullptr; } + bool isFunction() const { return m_flags.type == Flags::FunctionType; } + bool isQObject() const { return m_flags.type == Flags::QObjectDerivedType; } + bool isEnum() const { return m_flags.type == Flags::EnumType; } + bool isQList() const { return m_flags.type == Flags::QListType; } + bool isVarProperty() const { return m_flags.type == Flags::VarPropertyType; } + bool isQVariant() const { return m_flags.type == Flags::QVariantType; } + bool isVMEFunction() const { return isFunction() && m_flags.isVMEFunction; } + bool hasArguments() const { return isFunction() && m_flags.isWritableORhasArguments; } + bool isSignal() const { return isFunction() && m_flags.isResettableORisSignal; } + bool isVMESignal() const { return isFunction() && m_flags.isAliasORisVMESignal; } + bool isV4Function() const { return isFunction() && m_flags.isFinalORisV4Function; } + bool isSignalHandler() const { return m_flags.isSignalHandler; } + bool hasMetaObject() const { return m_flags.hasMetaObject; } + + // TODO: Remove this once we can. Signals should not be overridable. + bool isOverridableSignal() const { return m_flags.isOverridableSignal; } + + bool isCloned() const { return isFunction() && m_flags.isRequiredORisCloned; } + bool isConstructor() const { return isFunction() && m_flags.isConstructorORisBindable; } + bool isBindable() const { return !isFunction() && m_flags.isConstructorORisBindable; } + + bool hasOverride() const { return overrideIndex() >= 0; } + bool hasRevision() const { return revision() != QTypeRevision::zero(); } + + QMetaType propType() const { return m_propType; } + void setPropType(QMetaType pt) + { + m_propType = pt; + } + + int notifyIndex() const { return m_notifyIndex; } + void setNotifyIndex(int idx) + { + Q_ASSERT(idx >= std::numeric_limits<qint16>::min()); + Q_ASSERT(idx <= std::numeric_limits<qint16>::max()); + m_notifyIndex = qint16(idx); + } + + bool overrideIndexIsProperty() const { return m_flags.overrideIndexIsProperty; } + void setOverrideIndexIsProperty(bool onoff) { m_flags.overrideIndexIsProperty = onoff; } + + int overrideIndex() const { return m_overrideIndex; } + void setOverrideIndex(int idx) + { + Q_ASSERT(idx >= std::numeric_limits<qint16>::min()); + Q_ASSERT(idx <= std::numeric_limits<qint16>::max()); + m_overrideIndex = qint16(idx); + } + + int coreIndex() const { return m_coreIndex; } + void setCoreIndex(int idx) + { + Q_ASSERT(idx >= std::numeric_limits<qint16>::min()); + Q_ASSERT(idx <= std::numeric_limits<qint16>::max()); + m_coreIndex = qint16(idx); + } + + QTypeRevision revision() const { return m_revision; } + void setRevision(QTypeRevision revision) { m_revision = revision; } + + /* If a property is a C++ type, then we store the minor + * version of this type. + * This is required to resolve property or signal revisions + * if this property is used as a grouped property. + * + * Test.qml + * property TextEdit someTextEdit: TextEdit {} + * + * Test { + * someTextEdit.preeditText: "test" //revision 7 + * someTextEdit.onEditingFinished: console.log("test") //revision 6 + * } + * + * To determine if these properties with revisions are available we need + * the minor version of TextEdit as imported in Test.qml. + * + */ + + QTypeRevision typeVersion() const { return m_typeVersion; } + void setTypeVersion(QTypeRevision typeVersion) { m_typeVersion = typeVersion; } + + QQmlPropertyCacheMethodArguments *arguments() const + { + Q_ASSERT(!hasMetaObject()); + return m_arguments; + } + void setArguments(QQmlPropertyCacheMethodArguments *args) + { + Q_ASSERT(!hasMetaObject()); + m_arguments = args; + } + + const QMetaObject *metaObject() const + { + Q_ASSERT(hasMetaObject()); + return m_metaObject; + } + + void setMetaObject(const QMetaObject *metaObject) + { + Q_ASSERT(!hasArguments() || !m_arguments); + m_flags.setHasMetaObject(true); + m_metaObject = metaObject; + } + + QMetaMethod metaMethod() const + { + Q_ASSERT(hasMetaObject()); + Q_ASSERT(isFunction()); + return m_metaObject->method(m_coreIndex); + } + + int metaObjectOffset() const { return m_metaObjectOffset; } + void setMetaObjectOffset(int off) + { + Q_ASSERT(off >= std::numeric_limits<qint16>::min()); + Q_ASSERT(off <= std::numeric_limits<qint16>::max()); + m_metaObjectOffset = qint16(off); + } + + StaticMetaCallFunction staticMetaCallFunction() const { Q_ASSERT(!isFunction()); return m_staticMetaCallFunction; } + void trySetStaticMetaCallFunction(StaticMetaCallFunction f, unsigned relativePropertyIndex) + { + Q_ASSERT(!isFunction()); + if (relativePropertyIndex < (1 << Flags::BitsLeftInFlags) - 1) { + m_flags.otherBits = relativePropertyIndex; + m_staticMetaCallFunction = f; + } + } + quint16 relativePropertyIndex() const { Q_ASSERT(hasStaticMetaCallFunction()); return m_flags.otherBits; } + + static Flags flagsForProperty(const QMetaProperty &); + void load(const QMetaProperty &); + void load(const QMetaMethod &); + + QString name(QObject *object) const { return object ? name(object->metaObject()) : QString(); } + QString name(const QMetaObject *metaObject) const + { + if (!metaObject || m_coreIndex == -1) + return QString(); + + return QString::fromUtf8(isFunction() + ? metaObject->method(m_coreIndex).name().constData() + : metaObject->property(m_coreIndex).name()); + } + + bool markAsOverrideOf(QQmlPropertyData *predecessor); + + inline void readProperty(QObject *target, void *property) const + { + void *args[] = { property, nullptr }; + readPropertyWithArgs(target, args); + } + + // This is the same as QMetaObject::metacall(), but inlined here to avoid a function call. + // And we ignore the return value. + template<QMetaObject::Call call> + void doMetacall(QObject *object, int idx, void **argv) const + { + if (QDynamicMetaObjectData *dynamicMetaObject = QObjectPrivate::get(object)->metaObject) + dynamicMetaObject->metaCall(object, call, idx, argv); + else + object->qt_metacall(call, idx, argv); + } + + void readPropertyWithArgs(QObject *target, void *args[]) const + { + if (hasStaticMetaCallFunction()) + staticMetaCallFunction()(target, QMetaObject::ReadProperty, relativePropertyIndex(), args); + else + doMetacall<QMetaObject::ReadProperty>(target, coreIndex(), args); + } + + bool writeProperty(QObject *target, void *value, WriteFlags flags) const + { + int status = -1; + void *argv[] = { value, nullptr, &status, &flags }; + if (flags.testFlag(BypassInterceptor) && hasStaticMetaCallFunction()) + staticMetaCallFunction()(target, QMetaObject::WriteProperty, relativePropertyIndex(), argv); + else + doMetacall<QMetaObject::WriteProperty>(target, coreIndex(), argv); + return true; + } + + bool resetProperty(QObject *target, WriteFlags flags) const + { + if (flags.testFlag(BypassInterceptor) && hasStaticMetaCallFunction()) + staticMetaCallFunction()(target, QMetaObject::ResetProperty, relativePropertyIndex(), nullptr); + else + doMetacall<QMetaObject::ResetProperty>(target, coreIndex(), nullptr); + return true; + } + + static Flags defaultSignalFlags() + { + Flags f; + f.setType(Flags::FunctionType); + f.setIsSignal(true); + f.setIsVMESignal(true); + return f; + } + + static Flags defaultSlotFlags() + { + Flags f; + f.setType(Flags::FunctionType); + f.setIsVMEFunction(true); + return f; + } + +private: + friend class QQmlPropertyCache; + + Flags m_flags; + qint16 m_coreIndex = -1; + + // The notify index is in the range returned by QObjectPrivate::signalIndex(). + // This is different from QMetaMethod::methodIndex(). + qint16 m_notifyIndex = -1; + qint16 m_overrideIndex = -1; + + qint16 m_metaObjectOffset = -1; + + QTypeRevision m_revision = QTypeRevision::zero(); + QTypeRevision m_typeVersion = QTypeRevision::zero(); + + QMetaType m_propType = {}; + + union { + QQmlPropertyCacheMethodArguments *m_arguments = nullptr; + StaticMetaCallFunction m_staticMetaCallFunction; + const QMetaObject *m_metaObject; + }; +}; + +#if QT_POINTER_SIZE == 4 + Q_STATIC_ASSERT(sizeof(QQmlPropertyData) == 24); +#else // QT_POINTER_SIZE == 8 + Q_STATIC_ASSERT(sizeof(QQmlPropertyData) == 32); +#endif + +static_assert(std::is_trivially_copyable<QQmlPropertyData>::value); + +bool QQmlPropertyData::operator==(const QQmlPropertyData &other) const +{ + return flags() == other.flags() && + propType() == other.propType() && + coreIndex() == other.coreIndex() && + notifyIndex() == other.notifyIndex() && + revision() == other.revision(); +} + +QQmlPropertyData::Flags::Flags() + : otherBits(0) + , isConst(false) + , isVMEFunction(false) + , isWritableORhasArguments(false) + , isResettableORisSignal(false) + , isAliasORisVMESignal(false) + , isFinalORisV4Function(false) + , isSignalHandler(false) + , isOverridableSignal(false) + , isRequiredORisCloned(false) + , isConstructorORisBindable(false) + , isOverridden(false) + , hasMetaObject(false) + , type(OtherType) + , overrideIndexIsProperty(false) +{ +} + +bool QQmlPropertyData::Flags::operator==(const QQmlPropertyData::Flags &other) const +{ + return isConst == other.isConst && + isVMEFunction == other.isVMEFunction && + isWritableORhasArguments == other.isWritableORhasArguments && + isResettableORisSignal == other.isResettableORisSignal && + isAliasORisVMESignal == other.isAliasORisVMESignal && + isFinalORisV4Function == other.isFinalORisV4Function && + isOverridden == other.isOverridden && + isSignalHandler == other.isSignalHandler && + isRequiredORisCloned == other.isRequiredORisCloned && + hasMetaObject == other.hasMetaObject && + type == other.type && + isConstructorORisBindable == other.isConstructorORisBindable && + overrideIndexIsProperty == other.overrideIndexIsProperty; +} + +void QQmlPropertyData::Flags::copyPropertyTypeFlags(QQmlPropertyData::Flags from) +{ + switch (from.type) { + case QObjectDerivedType: + case EnumType: + case QListType: + case QVariantType: + type = from.type; + } +} + +Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyData::WriteFlags) + +QT_END_NAMESPACE + +#endif // QQMLPROPERTYDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyindex_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyindex_p.h new file mode 100644 index 0000000000000000000000000000000000000000..141ae8980653e0b57ab9efb0094d84601f4ad257 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyindex_p.h @@ -0,0 +1,97 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROPERTYINDEX_P_H +#define QQMLPROPERTYINDEX_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlPropertyIndex +{ + qint32 index; + +public: + QQmlPropertyIndex() + { index = -1; } + + static QQmlPropertyIndex fromEncoded(qint32 encodedIndex) + { + QQmlPropertyIndex idx; + idx.index = encodedIndex; + return idx; + } + + explicit QQmlPropertyIndex(int coreIndex) + { index = encode(coreIndex, -1); } + + explicit QQmlPropertyIndex(int coreIndex, int valueTypeIndex) + : index(encode(coreIndex, valueTypeIndex)) + {} + + bool isValid() const + { return index != -1; } + + int coreIndex() const + { + if (index == -1) + return -1; + return index & 0xffff; + } + + int valueTypeIndex() const + { + if (index == -1) + return -1; + return (index >> 16) - 1; + } + + bool hasValueTypeIndex() const + { + if (index == -1) + return false; + return index >> 16; + } + + qint32 toEncoded() const + { return index; } + + int intValue() const + { return index; } + + bool operator==(const QQmlPropertyIndex &other) const + { return index == other.index; } + + bool operator!=(const QQmlPropertyIndex &other) const + { return !operator==(other); } + +private: + static qint32 encode(int coreIndex, int valueTypeIndex) + { + Q_ASSERT(coreIndex >= -1); + Q_ASSERT(coreIndex <= 0xffff); + Q_ASSERT(valueTypeIndex >= -1); + Q_ASSERT(valueTypeIndex < 0xffff); + + if (coreIndex == -1) + return -1; + else + return coreIndex | ((valueTypeIndex + 1) << 16); + } +}; + +QT_END_NAMESPACE + +#endif // QQMLPROPERTYINDEX_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyresolver_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyresolver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8fddca2600de02bb847f738ef74ce9e8b2a35034 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyresolver_p.h @@ -0,0 +1,51 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROPERTYRESOLVER_P_H +#define QQMLPROPERTYRESOLVER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> +#include <private/qqmlpropertycache_p.h> +#include <private/qqmlrefcount_p.h> + +QT_BEGIN_NAMESPACE + +struct Q_QML_EXPORT QQmlPropertyResolver +{ + QQmlPropertyResolver(const QQmlPropertyCache::ConstPtr &cache) + : cache(cache) + {} + + const QQmlPropertyData *property(int index) const + { + return cache->property(index); + } + + enum RevisionCheck { + CheckRevision, + IgnoreRevision + }; + + const QQmlPropertyData *property(const QString &name, bool *notInRevision = nullptr, + RevisionCheck check = CheckRevision) const; + + // This code must match the semantics of QQmlPropertyPrivate::findSignalByName + const QQmlPropertyData *signal(const QString &name, bool *notInRevision) const; + + QQmlPropertyCache::ConstPtr cache; +}; + +QT_END_NAMESPACE + +#endif // QQMLPROPERTYRESOLVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertytopropertybinding_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertytopropertybinding_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ff449204179e5703aa4c14fbd0f5433276853ad0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertytopropertybinding_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROPERTYTOPROPERTYBINDINDING_P_H +#define QQMLPROPERTYTOPROPERTYBINDINDING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlabstractbinding_p.h> +#include <private/qqmlnotifier_p.h> +#include <QtCore/qproperty.h> + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlPropertyToPropertyBinding + : public QQmlAbstractBinding, public QQmlNotifierEndpoint +{ +public: + QQmlPropertyToPropertyBinding( + QQmlEngine *engine, QObject *sourceObject, int sourcePropertyIndex, + QObject *targetObject, int targetPropertyIndex); + + Kind kind() const final; + void setEnabled(bool e, QQmlPropertyData::WriteFlags flags) final; + + void update(QQmlPropertyData::WriteFlags flags = QQmlPropertyData::DontRemoveBinding); + +private: + static void trigger(QPropertyObserver *, QUntypedPropertyData *); + + void captureProperty( + const QMetaObject *sourceMetaObject, int notifyIndex, + bool isSourceBindable, bool isTargetBindable); + + struct Observer : QPropertyObserver { + static void trigger(QPropertyObserver *observer, QUntypedPropertyData *); + Observer(QQmlPropertyToPropertyBinding *binding) + : QPropertyObserver(trigger) + , binding(binding) + { + } + QQmlPropertyToPropertyBinding *binding = nullptr; + }; + + std::unique_ptr<Observer> observer; + QQmlEngine *m_engine = nullptr; + QObject *m_sourceObject = nullptr; + int m_sourcePropertyIndex = -1; +}; + +void QQmlPropertyGuard_callback(QQmlNotifierEndpoint *e, void **); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyvalidator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyvalidator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..83f3104c39a1fe6edbccd077116ae89a2b7c4f11 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyvalidator_p.h @@ -0,0 +1,73 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQMLPROPERTYVALIDATOR_P_H +#define QQMLPROPERTYVALIDATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlengine_p.h> +#include <private/qqmlimport_p.h> +#include <private/qqmljsdiagnosticmessage_p.h> +#include <private/qqmlpropertycache_p.h> +#include <private/qv4compileddata_p.h> + +#include <QtCore/qcoreapplication.h> + +QT_BEGIN_NAMESPACE + +class QQmlPropertyValidator +{ + Q_DECLARE_TR_FUNCTIONS(QQmlPropertyValidator) +public: + QQmlPropertyValidator( + QQmlEnginePrivate *enginePrivate, const QQmlImports *imports, + const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit); + + QVector<QQmlError> validate(); + + QQmlPropertyCache::ConstPtr rootPropertyCache() const { return propertyCaches.at(0); } + QUrl documentSourceUrl() const { return compilationUnit->url(); } + +private: + QVector<QQmlError> validateObject( + int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding, + bool populatingValueTypeGroupProperty = false) const; + QQmlError validateLiteralBinding( + const QQmlPropertyCache::ConstPtr &propertyCache, const QQmlPropertyData *property, + const QV4::CompiledData::Binding *binding) const; + QQmlError validateObjectBinding( + const QQmlPropertyData *property, const QString &propertyName, + const QV4::CompiledData::Binding *binding) const; + + bool canCoerce(QMetaType to, QQmlPropertyCache::ConstPtr fromMo) const; + + Q_REQUIRED_RESULT QVector<QQmlError> recordError( + const QV4::CompiledData::Location &location, const QString &description) const; + Q_REQUIRED_RESULT QVector<QQmlError> recordError(const QQmlError &error) const; + QString stringAt(int index) const { return compilationUnit->stringAt(index); } + QV4::ResolvedTypeReference *resolvedType(int id) const + { + return compilationUnit->resolvedType(id); + } + + QQmlEnginePrivate *enginePrivate; + QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit; + const QQmlImports *imports; + const QV4::CompiledData::Unit *qmlUnit; + const QQmlPropertyCacheVector &propertyCaches; + + QVector<QV4::CompiledData::BindingPropertyData> * const bindingPropertyDataPerObject; +}; + +QT_END_NAMESPACE + +#endif // QQMLPROPERTYVALIDATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyvalueinterceptor_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyvalueinterceptor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e0c167b9ac9ba43a10fcce8f0f3a2607dd8a5183 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlpropertyvalueinterceptor_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROPERTYVALUEINTERCEPTOR_P_H +#define QQMLPROPERTYVALUEINTERCEPTOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> +#include <private/qqmlpropertyindex_p.h> +#include <QtCore/qobject.h> +#include <QtCore/qproperty.h> + +QT_BEGIN_NAMESPACE + +class QQmlProperty; +class Q_QML_EXPORT QQmlPropertyValueInterceptor +{ +public: + QQmlPropertyValueInterceptor(); + virtual ~QQmlPropertyValueInterceptor(); + virtual void setTarget(const QQmlProperty &property) = 0; + virtual void write(const QVariant &value) = 0; + virtual bool bindable(QUntypedBindable *bindable, QUntypedBindable target); + +private: + friend class QQmlInterceptorMetaObject; + + QQmlPropertyIndex m_propertyIndex; + QQmlPropertyValueInterceptor *m_next; +}; + +#define QQmlPropertyValueInterceptor_iid "org.qt-project.Qt.QQmlPropertyValueInterceptor" + +Q_DECLARE_INTERFACE(QQmlPropertyValueInterceptor, QQmlPropertyValueInterceptor_iid) + +QT_END_NAMESPACE + +#endif // QQMLPROPERTYVALUEINTERCEPTOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlproxymetaobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlproxymetaobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a7b95ffab4b1dbdf23b03ad9ec785049933d0482 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlproxymetaobject_p.h @@ -0,0 +1,77 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROXYMETAOBJECT_P_H +#define QQMLPROXYMETAOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> +#include <private/qmetaobjectbuilder_p.h> + +#include <QtCore/QMetaObject> +#include <QtCore/QObject> + +#include <private/qobject_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlProxyMetaObject : public QDynamicMetaObjectData +{ +public: + struct ProxyData { + typedef QObject *(*CreateFunc)(QObject *); + QMetaObject *metaObject; + CreateFunc createFunc; + int propertyOffset; + int methodOffset; + }; + + QQmlProxyMetaObject(QObject *, const QList<ProxyData> *); + ~QQmlProxyMetaObject(); + + static constexpr int extensionObjectId(int id) noexcept + { + Q_ASSERT(id >= 0); + Q_ASSERT(id <= MaxExtensionCount); // MaxExtensionCount is a valid index + return ExtensionObjectId | id; + } + +protected: + int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override; + QMetaObject *toDynamicMetaObject(QObject *) override; + void objectDestroyed(QObject *object) override; + +private: + QObject *getProxy(int index); + + const QList<ProxyData> *metaObjects; + QObject **proxies; + + QDynamicMetaObjectData *parent; + QMetaObject *metaObject; + QObject *object; + + // ExtensionObjectId acts as a flag for whether we should interpret a + // QMetaObject::CustomCall as a call to fetch the extension object (see + // QQmlProxyMetaObject::metaCall()). MaxExtensionCount is a limit on how + // many extensions we can query via such mechanism + enum : int { + MaxExtensionCount = 127, // magic number so that low bits are all '1' + ExtensionObjectId = ~MaxExtensionCount, + }; +}; + +QT_END_NAMESPACE + +#endif // QQMLPROXYMETAOBJECT_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlrefcount_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlrefcount_p.h new file mode 100644 index 0000000000000000000000000000000000000000..af34afa075c51226bb4bfb80ecc9009bf9e0893b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlrefcount_p.h @@ -0,0 +1,237 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLREFCOUNT_P_H +#define QQMLREFCOUNT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtCore/qatomic.h> +#include <private/qv4global_p.h> + +QT_BEGIN_NAMESPACE + +template <typename T> +class QQmlRefCounted; + +class QQmlRefCount +{ + Q_DISABLE_COPY_MOVE(QQmlRefCount) +public: + inline QQmlRefCount(); + inline void addref() const; + inline int count() const; + +private: + inline ~QQmlRefCount(); + template <typename T> friend class QQmlRefCounted; + +private: + mutable QAtomicInt refCount; +}; + +template <typename T> +class QQmlRefCounted : public QQmlRefCount +{ +public: + inline void release() const; +protected: + inline ~QQmlRefCounted(); +}; + +template<class T> +class QQmlRefPointer +{ +public: + enum Mode { + AddRef, + Adopt + }; + Q_NODISCARD_CTOR inline QQmlRefPointer() noexcept; + Q_NODISCARD_CTOR inline QQmlRefPointer(T *, Mode m = AddRef); + Q_NODISCARD_CTOR inline QQmlRefPointer(const QQmlRefPointer &); + Q_NODISCARD_CTOR inline QQmlRefPointer(QQmlRefPointer &&) noexcept; + inline ~QQmlRefPointer(); + + void swap(QQmlRefPointer &other) noexcept { qt_ptr_swap(o, other.o); } + + inline QQmlRefPointer<T> &operator=(const QQmlRefPointer<T> &o); + inline QQmlRefPointer<T> &operator=(QQmlRefPointer<T> &&o) noexcept; + + inline bool isNull() const { return !o; } + + inline T* operator->() const { return o; } + inline T& operator*() const { return *o; } + explicit inline operator bool() const { return o != nullptr; } + inline T* data() const { return o; } + + inline QQmlRefPointer<T> &adopt(T *); + + inline T* take() { T *res = o; o = nullptr; return res; } + + friend bool operator==(const QQmlRefPointer &a, const QQmlRefPointer &b) noexcept + { + return a.o == b.o; + } + + friend bool operator!=(const QQmlRefPointer &a, const QQmlRefPointer &b) noexcept + { + return !(a == b); + } + + friend size_t qHash(const QQmlRefPointer &v, size_t seed = 0) noexcept + { + return qHash(v.o, seed); + } + + void reset(T *t = nullptr) + { + if (t == o) + return; + if (o) + o->release(); + if (t) + t->addref(); + o = t; + } + +private: + T *o; +}; + +namespace QQml { +/*! + \internal + Creates a QQmlRefPointer which takes ownership of a newly constructed T. + T must derive from QQmlRefCounted<T> (as we rely on an initial refcount of _1_). + T will be constructed by forwarding \a args to its constructor. + */ +template <typename T, typename ...Args> +QQmlRefPointer<T> makeRefPointer(Args&&... args) +{ + static_assert(std::is_base_of_v<QQmlRefCount, T>); + return QQmlRefPointer<T>(new T(std::forward<Args>(args)...), QQmlRefPointer<T>::Adopt); +} +} + +template <typename T> +Q_DECLARE_TYPEINFO_BODY(QQmlRefPointer<T>, Q_RELOCATABLE_TYPE); + +QQmlRefCount::QQmlRefCount() +: refCount(1) +{ +} + +QQmlRefCount::~QQmlRefCount() +{ + Q_ASSERT(refCount.loadRelaxed() == 0); +} + +void QQmlRefCount::addref() const +{ + Q_ASSERT(refCount.loadRelaxed() > 0); + refCount.ref(); +} + +template <typename T> +void QQmlRefCounted<T>::release() const +{ + static_assert(std::is_base_of_v<QQmlRefCounted, T>, + "QQmlRefCounted<T> must be a base of T (CRTP)"); + Q_ASSERT(refCount.loadRelaxed() > 0); + if (!refCount.deref()) + delete static_cast<const T *>(this); +} + +template <typename T> +QQmlRefCounted<T>::~QQmlRefCounted() +{ + static_assert(std::is_final_v<T> || std::has_virtual_destructor_v<T>, + "T must either be marked final or have a virtual dtor, " + "lest release() runs into UB."); +} + +int QQmlRefCount::count() const +{ + return refCount.loadRelaxed(); +} + +template<class T> +QQmlRefPointer<T>::QQmlRefPointer() noexcept +: o(nullptr) +{ +} + +template<class T> +QQmlRefPointer<T>::QQmlRefPointer(T *o, Mode m) +: o(o) +{ + if (m == AddRef && o) + o->addref(); +} + +template<class T> +QQmlRefPointer<T>::QQmlRefPointer(const QQmlRefPointer<T> &other) +: o(other.o) +{ + if (o) o->addref(); +} + +template <class T> +QQmlRefPointer<T>::QQmlRefPointer(QQmlRefPointer<T> &&other) noexcept + : o(other.take()) +{ +} + +template<class T> +QQmlRefPointer<T>::~QQmlRefPointer() +{ + if (o) o->release(); +} + +template<class T> +QQmlRefPointer<T> &QQmlRefPointer<T>::operator=(const QQmlRefPointer<T> &other) +{ + if (o == other.o) + return *this; + if (other.o) + other.o->addref(); + if (o) + o->release(); + o = other.o; + return *this; +} + +template <class T> +QQmlRefPointer<T> &QQmlRefPointer<T>::operator=(QQmlRefPointer<T> &&other) noexcept +{ + QQmlRefPointer<T> m(std::move(other)); + swap(m); + return *this; +} + +/*! +Takes ownership of \a other. take() does *not* add a reference, as it assumes ownership +of the callers reference of other. +*/ +template<class T> +QQmlRefPointer<T> &QQmlRefPointer<T>::adopt(T *other) +{ + if (o) o->release(); + o = other; + return *this; +} + +QT_END_NAMESPACE + +#endif // QQMLREFCOUNT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlscriptblob_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlscriptblob_p.h new file mode 100644 index 0000000000000000000000000000000000000000..935d35fea2c6bb28b571380e5d09182ab623d2f4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlscriptblob_p.h @@ -0,0 +1,63 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSCRIPTBLOB_P_H +#define QQMLSCRIPTBLOB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmltypeloader_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlScriptData; +class Q_AUTOTEST_EXPORT QQmlScriptBlob : public QQmlTypeLoader::Blob +{ +private: + friend class QQmlTypeLoader; + + QQmlScriptBlob(const QUrl &, QQmlTypeLoader *); + +public: + ~QQmlScriptBlob() override; + + struct ScriptReference + { + QV4::CompiledData::Location location; + QString qualifier; + QString nameSpace; + QQmlRefPointer<QQmlScriptBlob> script; + }; + + QQmlRefPointer<QQmlScriptData> scriptData() const; + bool hasScriptValue() const; + +protected: + void dataReceived(const SourceCodeData &) override; + void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) override; + void done() override; + + QString stringAt(int index) const override; + +private: + void scriptImported(const QQmlRefPointer<QQmlScriptBlob> &blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override; + void initializeFromCompilationUnit(QQmlRefPointer<QV4::CompiledData::CompilationUnit> &&cu); + void initializeFromNative(); + + QList<ScriptReference> m_scripts; + QQmlRefPointer<QQmlScriptData> m_scriptData; + const bool m_isModule; +}; + +QT_END_NAMESPACE + +#endif // QQMLSCRIPTBLOB_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlscriptdata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlscriptdata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c05eae8eda382d26a6746698442e385a33975e64 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlscriptdata_p.h @@ -0,0 +1,82 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSCRIPTDATA_P_H +#define QQMLSCRIPTDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlrefcount_p.h> +#include <private/qqmlscriptblob_p.h> +#include <private/qv4value_p.h> +#include <private/qv4persistent_p.h> +#include <private/qv4compileddata_p.h> +#include <private/qv4scopedvalue_p.h> + +#include <QtCore/qurl.h> + +QT_BEGIN_NAMESPACE + +class QQmlTypeNameCache; +class QQmlContextData; + +class Q_AUTOTEST_EXPORT QQmlScriptData final : public QQmlRefCounted<QQmlScriptData> +{ +private: + friend class QQmlTypeLoader; + + QQmlScriptData() = default; + +public: + QUrl url; + QString urlString; + QQmlRefPointer<QQmlTypeNameCache> typeNameCache; + QVector<QQmlRefPointer<QQmlScriptBlob>> scripts; + + QV4::ReturnedValue ownScriptValue(QV4::ExecutionEngine *v4) const; + QV4::ReturnedValue scriptValueForContext(const QQmlRefPointer<QQmlContextData> &parentCtxt); + + QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit() const + { + return m_precompiledScript; + } + +private: + friend class QQmlScriptBlob; + + QQmlRefPointer<QQmlContextData> qmlContextDataForContext( + const QQmlRefPointer<QQmlContextData> &parentQmlContextData); + + template<typename WithExecutableCU> + QV4::ReturnedValue handleOwnScriptValueOrExecutableCU( + QV4::ExecutionEngine *v4, + WithExecutableCU &&withExecutableCU) const + { + QV4::Scope scope(v4); + + QV4::ScopedValue value(scope, v4->nativeModule(url)); + if (!value->isEmpty()) + return value->asReturnedValue(); + + if (!m_precompiledScript) + return QV4::Value::emptyValue().asReturnedValue(); + + return withExecutableCU(v4->executableCompilationUnit( + QQmlRefPointer<QV4::CompiledData::CompilationUnit>(m_precompiledScript))); + } + + QQmlRefPointer<QV4::CompiledData::CompilationUnit> m_precompiledScript; +}; + +QT_END_NAMESPACE + +#endif // QQMLSCRIPTDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlscriptstring_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlscriptstring_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d8187da4d72a2ce77253103aef3aed676055360a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlscriptstring_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSCRIPTSTRING_P_H +#define QQMLSCRIPTSTRING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlscriptstring.h" +#include <QtQml/qqmlcontext.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class Q_AUTOTEST_EXPORT QQmlScriptStringPrivate : public QSharedData +{ +public: + QQmlScriptStringPrivate() : context(nullptr), scope(nullptr), bindingId(-1), lineNumber(0), columnNumber(0), + numberValue(0), isStringLiteral(false), isNumberLiteral(false) {} + + //for testing + static const QQmlScriptStringPrivate* get(const QQmlScriptString &script); + + QQmlContext *context; + QObject *scope; + QString script; + int bindingId; + quint16 lineNumber; + quint16 columnNumber; + double numberValue; + bool isStringLiteral; + bool isNumberLiteral; +}; + +QT_END_NAMESPACE + +#endif // QQMLSCRIPTSTRING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlsignalnames_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlsignalnames_p.h new file mode 100644 index 0000000000000000000000000000000000000000..737a08ea18de290b949a61aac9dbdce46b375c61 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlsignalnames_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSIGNALANDPROPERTYNAMES_P_H +#define QQMLSIGNALANDPROPERTYNAMES_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <cstddef> +#include <optional> + +#include <QtQml/private/qtqmlglobal_p.h> +#include <QtCore/qstringview.h> +#include <QtCore/qstring.h> +#include <type_traits> + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlSignalNames +{ +public: + static QString propertyNameToChangedSignalName(QStringView property); + static QByteArray propertyNameToChangedSignalName(QUtf8StringView property); + + static QString propertyNameToChangedHandlerName(QStringView property); + + static QString signalNameToHandlerName(QAnyStringView signal); + + static std::optional<QString> changedSignalNameToPropertyName(QStringView changeSignal); + static std::optional<QByteArray> changedSignalNameToPropertyName(QUtf8StringView changeSignal); + + static std::optional<QString> changedHandlerNameToPropertyName(QStringView handler); + static std::optional<QByteArray> changedHandlerNameToPropertyName(QUtf8StringView handler); + + static std::optional<QString> handlerNameToSignalName(QStringView handler); + static std::optional<QString> changedHandlerNameToSignalName(QStringView changedHandler); + + static bool isChangedHandlerName(QStringView signalName); + static bool isChangedSignalName(QStringView signalName); + static bool isHandlerName(QStringView signalName); + + static QString addPrefixToPropertyName(QStringView prefix, QStringView propertyName); + + // ### Qt7: remove this + static std::optional<QString> badHandlerNameToSignalName(QStringView handler); +}; + +QT_END_NAMESPACE + +#endif // QQMLSIGNALANDPROPERTYNAMES_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlsourcecoordinate_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlsourcecoordinate_p.h new file mode 100644 index 0000000000000000000000000000000000000000..09cad95ecec48158294f0e79a9af51f1a24ee48e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlsourcecoordinate_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSOURCECOORDINATE_P_H +#define QQMLSOURCECOORDINATE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +#include <limits> + +QT_BEGIN_NAMESPACE + +// These methods are needed because in some public methods we historically interpret -1 as the +// invalid line or column, even though all the lines and columns are 1-based. Also, the different +// integer ranges may turn certain large values into invalid ones on conversion. + +template<typename From, typename To> +To qmlConvertSourceCoordinate(From n); + +template<> +inline quint16 qmlConvertSourceCoordinate<int, quint16>(int n) +{ + return (n > 0 && n <= int(std::numeric_limits<quint16>::max())) ? quint16(n) : 0; +} + +template<> +inline quint32 qmlConvertSourceCoordinate<int, quint32>(int n) +{ + return n > 0 ? quint32(n) : 0u; +} + +// TODO: In Qt6, change behavior and make the invalid coordinate 0 for the following two methods. + +template<> +inline int qmlConvertSourceCoordinate<quint16, int>(quint16 n) +{ + return (n == 0u) ? -1 : int(n); +} + +template<> +inline int qmlConvertSourceCoordinate<quint32, int>(quint32 n) +{ + return (n == 0u || n > quint32(std::numeric_limits<int>::max())) ? -1 : int(n); +} + +QT_END_NAMESPACE + +#endif // QQMLSOURCECOORDINATE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlstringconverters_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlstringconverters_p.h new file mode 100644 index 0000000000000000000000000000000000000000..95cd1bf8aa9ffdc47b5ad61b3a67b9cc88a06db3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlstringconverters_p.h @@ -0,0 +1,123 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSTRINGCONVERTERS_P_H +#define QQMLSTRINGCONVERTERS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtCore/qvariant.h> + +#include <private/qtqmlglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QPointF; +class QSizeF; +class QRectF; +class QString; +class QByteArray; + +namespace QQmlStringConverters +{ + Q_QML_EXPORT QVariant variantFromString(const QString &, QMetaType preferredType, bool *ok = nullptr); + + Q_QML_EXPORT QVariant colorFromString(const QString &, bool *ok = nullptr); + Q_QML_EXPORT unsigned rgbaFromString(const QString &, bool *ok = nullptr); + +#if QT_CONFIG(datestring) + Q_QML_EXPORT QDate dateFromString(const QString &, bool *ok = nullptr); + Q_QML_EXPORT QTime timeFromString(const QString &, bool *ok = nullptr); + Q_QML_EXPORT QDateTime dateTimeFromString(const QString &, bool *ok = nullptr); +#endif + Q_QML_EXPORT QPointF pointFFromString(const QString &, bool *ok = nullptr); + Q_QML_EXPORT QSizeF sizeFFromString(const QString &, bool *ok = nullptr); + Q_QML_EXPORT QRectF rectFFromString(const QString &, bool *ok = nullptr); + + // checks if the string contains a list of doubles separated by separators, like "double1 + // separators1 double2 separators2 ..." for example. + template<int NumParams, char16_t... separators> + bool isValidNumberString(const QString &s, std::array<double, NumParams> *numbers = nullptr) + { + Q_STATIC_ASSERT_X( + NumParams == 2 || NumParams == 3 || NumParams == 4 || NumParams == 16, + "Unsupported number of params; add an additional case below if necessary."); + constexpr std::array<char16_t, NumParams - 1> separatorArray{ separators... }; + // complain about missing separators when first or last entry is initialized with 0 + Q_STATIC_ASSERT_X(separatorArray[0] != 0, + "Did not specify any separators for isValidNumberString."); + Q_STATIC_ASSERT_X(separatorArray[NumParams - 2] != 0, + "Did not specify enough separators for isValidNumberString."); + + bool floatOk = true; + QStringView view(s); + for (qsizetype i = 0; i < NumParams - 1; ++i) { + const qsizetype commaIndex = view.indexOf(separatorArray[i]); + if (commaIndex == -1) + return false; + const auto current = view.first(commaIndex).toDouble(&floatOk); + if (!floatOk) + return false; + if (numbers) + (*numbers)[i] = current; + + view = view.sliced(commaIndex + 1); + } + const auto current = view.toDouble(&floatOk); + if (!floatOk) + return false; + if (numbers) + (*numbers)[NumParams - 1] = current; + + return true; + } + + // Constructs a value type T from the given string that contains NumParams double values + // separated by separators, like "double1 separators1 double2 separators2 ..." for example. + template<typename T, int NumParams, char16_t... separators> + T valueTypeFromNumberString(const QString &s, bool *ok = nullptr) + { + Q_STATIC_ASSERT_X( + NumParams == 2 || NumParams == 3 || NumParams == 4 || NumParams == 16, + "Unsupported number of params; add an additional case below if necessary."); + + std::array<double, NumParams> parameters; + if (!isValidNumberString<NumParams, separators...>(s, ¶meters)) { + if (ok) + *ok = false; + return T{}; + } + + if (ok) + *ok = true; + + if constexpr (NumParams == 2) { + return T(parameters[0], parameters[1]); + } else if constexpr (NumParams == 3) { + return T(parameters[0], parameters[1], parameters[2]); + } else if constexpr (NumParams == 4) { + return T(parameters[0], parameters[1], parameters[2], parameters[3]); + } else if constexpr (NumParams == 16) { + return T(parameters[0], parameters[1], parameters[2], parameters[3], parameters[4], + parameters[5], parameters[6], parameters[7], parameters[8], parameters[9], + parameters[10], parameters[11], parameters[12], parameters[13], parameters[14], + parameters[15]); + } + + Q_UNREACHABLE_RETURN(T{}); + } +} + +QT_END_NAMESPACE + +#endif // QQMLSTRINGCONVERTERS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltcobjectcreationhelper_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltcobjectcreationhelper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..32645667ad5a190228a9de80d92e5b8d1800d19f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltcobjectcreationhelper_p.h @@ -0,0 +1,125 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTCOBJECTCREATIONHELPER_P_H +#define QQMLTCOBJECTCREATIONHELPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqml.h> +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qversionnumber.h> +#include <private/qtqmlglobal_p.h> +#include <private/qqmltype_p.h> + +#include <array> + +QT_BEGIN_NAMESPACE + +/*! + \internal + + (Kind of) type-erased object creation utility that can be used throughout + the generated C++ code. By nature it shows relative data to the current QML + document and allows to get and set object pointers. + */ +class QQmltcObjectCreationHelper +{ + QObject **m_data = nullptr; // QObject* array + const qsizetype m_size = 0; // size of m_data array, exists for bounds checking + const qsizetype m_offset = 0; // global offset into m_data array + + qsizetype offset() const { return m_offset; } + +public: + /*! + Constructs initial "view" from basic data. Supposed to only be called + once from QQmltcObjectCreationBase. + */ + QQmltcObjectCreationHelper(QObject **data, qsizetype size) : m_data(data), m_size(size) + { + Q_UNUSED(m_size); + } + + /*! + Constructs new "view" from \a base view, adding \a localOffset to the + offset of that base. + */ + QQmltcObjectCreationHelper(const QQmltcObjectCreationHelper *base, qsizetype localOffset) + : m_data(base->m_data), m_size(base->m_size), m_offset(base->m_offset + localOffset) + { + } + + template<typename T> + T *get(qsizetype i) const + { + Q_ASSERT(m_data); + Q_ASSERT(i >= 0 && i + offset() < m_size); + Q_ASSERT(qobject_cast<T *>(m_data[i + offset()]) != nullptr); + // Note: perform cheap cast as we know *exactly* the real type of the + // object + return static_cast<T *>(m_data[i + offset()]); + } + + void set(qsizetype i, QObject *object) + { + Q_ASSERT(m_data); + Q_ASSERT(i >= 0 && i + offset() < m_size); + Q_ASSERT(m_data[i + offset()] == nullptr); // prevent accidental resets + m_data[i + offset()] = object; + } + + template<typename T> + static constexpr uint typeCount() noexcept + { + return T::q_qmltc_typeCount(); + } +}; + +/*! + \internal + + Base helper for qmltc-generated types that linearly stores pointers to all + the to-be-created objects for fast access during object creation. + */ +template<typename QmltcGeneratedType> +class QQmltcObjectCreationBase +{ + // Note: +1 for the document root itself + std::array<QObject *, QmltcGeneratedType::q_qmltc_typeCount() + 1> m_objects = {}; + +public: + QQmltcObjectCreationHelper view() + { + return QQmltcObjectCreationHelper(m_objects.data(), m_objects.size()); + } +}; + +struct QmltcTypeData +{ + QQmlType::RegistrationType regType = QQmlType::CppType; + int allocationSize = 0; + const QMetaObject *metaObject = nullptr; + + template<typename QmltcGeneratedType> + QmltcTypeData(QmltcGeneratedType *) + : allocationSize(sizeof(QmltcGeneratedType)), + metaObject(&QmltcGeneratedType::staticMetaObject) + { + } +}; + +Q_QML_EXPORT void qmltcCreateDynamicMetaObject(QObject *object, const QmltcTypeData &data); + +QT_END_NAMESPACE + +#endif // QQMLTCOBJECTCREATIONHELPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlthread_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlthread_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2daa9a9bfa0c88e9a0b62cb59125c7a61f08668c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlthread_p.h @@ -0,0 +1,143 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTHREAD_P_H +#define QQMLTHREAD_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#include <QtCore/qglobal.h> + +#include <private/qintrusivelist_p.h> + +QT_BEGIN_NAMESPACE + +class QThread; +class QMutex; + +class QQmlThreadPrivate; +class QQmlThread +{ +public: + QQmlThread(); + virtual ~QQmlThread(); + + void startup(); + void shutdown(); + bool isShutdown() const; + + QMutex &mutex(); + void lock(); + void unlock(); + void wakeOne(); + void wait(); + + QThread *thread() const; + bool isThisThread() const; + + // Synchronously invoke a method in the thread + template<typename Method, typename ...Args> + void callMethodInThread(Method &&method, Args &&...args); + + // Synchronously invoke a method in the main thread. If the main thread is + // blocked in a callMethodInThread() call, the call is made from within that + // call. + template<typename Method, typename ...Args> + void callMethodInMain(Method &&method, Args &&...args); + + // Asynchronously invoke a method in the thread. + template<typename Method, typename ...Args> + void postMethodToThread(Method &&method, Args &&...args); + + // Asynchronously invoke a method in the main thread. + template<typename Method, typename ...Args> + void postMethodToMain(Method &&method, Args &&...args); + + void waitForNextMessage(); + void discardMessages(); + +private: + friend class QQmlThreadPrivate; + + struct Message { + Message() : next(nullptr) {} + virtual ~Message() {} + Message *next; + virtual void call(QQmlThread *) = 0; + }; + template<typename Method, typename ...Args> + Message *createMessageFromMethod(Method &&method, Args &&...args); + void internalCallMethodInThread(Message *); + void internalCallMethodInMain(Message *); + void internalPostMethodToThread(Message *); + void internalPostMethodToMain(Message *); + QQmlThreadPrivate *d; +}; + +namespace QtPrivate { +template <typename> struct member_function_traits; + +template <typename Return, typename Object, typename... Args> +struct member_function_traits<Return (Object::*)(Args...)> +{ + using class_type = Object; +}; +} + +template<typename Method, typename ...Args> +QQmlThread::Message *QQmlThread::createMessageFromMethod(Method &&method, Args &&...args) +{ + struct I : public Message { + Method m; + std::tuple<std::decay_t<Args>...> arguments; + I(Method &&method, Args&& ...args) : m(std::forward<Method>(method)), arguments(std::forward<Args>(args)...) {} + void call(QQmlThread *thread) override { + using class_type = typename QtPrivate::member_function_traits<Method>::class_type; + class_type *me = static_cast<class_type *>(thread); + std::apply(m, std::tuple_cat(std::make_tuple(me), arguments)); + } + }; + return new I(std::forward<Method>(method), std::forward<Args>(args)...); +} + +template<typename Method, typename ...Args> +void QQmlThread::callMethodInMain(Method &&method, Args&& ...args) +{ + Message *m = createMessageFromMethod(std::forward<Method>(method), std::forward<Args>(args)...); + internalCallMethodInMain(m); +} + +template<typename Method, typename ...Args> +void QQmlThread::callMethodInThread(Method &&method, Args&& ...args) +{ + Message *m = createMessageFromMethod(std::forward<Method>(method), std::forward<Args>(args)...); + internalCallMethodInThread(m); +} + +template<typename Method, typename ...Args> +void QQmlThread::postMethodToThread(Method &&method, Args&& ...args) +{ + Message *m = createMessageFromMethod(std::forward<Method>(method), std::forward<Args>(args)...); + internalPostMethodToThread(m); +} + +template<typename Method, typename ...Args> +void QQmlThread::postMethodToMain(Method &&method, Args&& ...args) +{ + Message *m = createMessageFromMethod(std::forward<Method>(method), std::forward<Args>(args)...); + internalPostMethodToMain(m); +} + +QT_END_NAMESPACE + +#endif // QQMLTHREAD_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltranslation_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltranslation_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f4aea34997f017d4e5e39bccb9bada6786826a21 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltranslation_p.h @@ -0,0 +1,74 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTRANSLATION_P_H +#define QQMLTRANSLATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> + +#include <private/qv4qmlcontext_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlTranslation +{ +public: + class Q_QML_EXPORT QsTrData + { + QByteArray context; + QByteArray text; + QByteArray comment; + int number; + + public: + QsTrData(const QString &fileNameForContext, const QString &text, const QString &comment, + int number); + QString translate() const; + QString serializeForQmltc() const; + QString idForQmlDebug() const; + }; + + class Q_QML_EXPORT QsTrIdData + { + QByteArray id; + int number; + + public: + QsTrIdData(const QString &id, int number); + QString translate() const; + QString serializeForQmltc() const; + QString idForQmlDebug() const; + }; + + // The static analyzer hates std::monostate in std::variant because + // that results in various uninitialized memory "problems". Just use + // std::nullptr_t to indicate "empty". + using Data = std::variant<std::nullptr_t, QsTrData, QsTrIdData>; + +private: + Data data; + +public: + QQmlTranslation(const Data &d); + QQmlTranslation(); + QString translate() const; + QString serializeForQmltc() const; + QString idForQmlDebug() const; + + static QString contextFromQmlFilename(const QString &qmlFilename); +}; + +QT_END_NAMESPACE + +#endif // QQMLTRANSLATION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltype_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltype_p.h new file mode 100644 index 0000000000000000000000000000000000000000..80b2e87429352848e5790f55767177e7bd57b6e2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltype_p.h @@ -0,0 +1,194 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTYPE_P_H +#define QQMLTYPE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <functional> + +#include <private/qtqmlglobal_p.h> +#include <private/qqmlrefcount_p.h> + +#include <QtQml/qqmlprivate.h> +#include <QtQml/qjsvalue.h> + +#include <QtCore/qobject.h> +#include <QtCore/qversionnumber.h> + +QT_BEGIN_NAMESPACE + +class QHashedCStringRef; +class QQmlTypePrivate; +class QHashedString; +class QHashedStringRef; +class QQmlCustomParser; +class QQmlEnginePrivate; +class QQmlPropertyCache; + +namespace QV4 { +struct String; +} + +class Q_QML_EXPORT QQmlType +{ +public: + QQmlType(); + QQmlType(const QQmlType &other); + QQmlType(QQmlType &&other); + QQmlType &operator =(const QQmlType &other); + QQmlType &operator =(QQmlType &&other); + explicit QQmlType(const QQmlTypePrivate *priv); + ~QQmlType(); + + bool isValid() const { return !d.isNull(); } + + QByteArray typeName() const; + QString qmlTypeName() const; + QString elementName() const; + + QHashedString module() const; + QTypeRevision version() const; + + bool availableInVersion(QTypeRevision version) const; + bool availableInVersion(const QHashedStringRef &module, QTypeRevision version) const; + + typedef QVariant (*CreateValueTypeFunc)(const QJSValue &); + CreateValueTypeFunc createValueTypeFunction() const; + + bool canConstructValueType() const; + bool canPopulateValueType() const; + + QObject *create() const; + QObject *create(void **, size_t) const; + QObject *createWithQQmlData() const; + + typedef void (*CreateFunc)(void *, void *); + CreateFunc createFunction() const; + + QQmlCustomParser *customParser() const; + + bool isCreatable() const; + typedef QObject *(*ExtensionFunc)(QObject *); + ExtensionFunc extensionFunction() const; + const QMetaObject *extensionMetaObject() const; + bool isExtendedType() const; + QString noCreationReason() const; + + bool isSingleton() const; + bool isInterface() const; + bool isComposite() const; + bool isCompositeSingleton() const; + bool isQObjectSingleton() const; + bool isQJSValueSingleton() const; + bool isSequentialContainer() const; + bool isValueType() const; + + QMetaType typeId() const; + QMetaType qListTypeId() const; + QMetaSequence listMetaSequence() const; + + const QMetaObject *metaObject() const; + + // Precondition: The type is actually a value type! + const QMetaObject *metaObjectForValueType() const; + + const QMetaObject *baseMetaObject() const; + QTypeRevision metaObjectRevision() const; + bool containsRevisionedAttributes() const; + + QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const; + const QMetaObject *attachedPropertiesType(QQmlEnginePrivate *engine) const; + + int parserStatusCast() const; + const char *interfaceIId() const; + int propertyValueSourceCast() const; + int propertyValueInterceptorCast() const; + int finalizerCast() const; + + int index() const; + + bool isInlineComponentType() const; + + struct Q_QML_EXPORT SingletonInstanceInfo final + : public QQmlRefCounted<SingletonInstanceInfo> + { + using Ptr = QQmlRefPointer<SingletonInstanceInfo>; + using ConstPtr = QQmlRefPointer<const SingletonInstanceInfo>; + + static Ptr create() { return Ptr(new SingletonInstanceInfo, Ptr::Adopt); } + + std::function<QJSValue(QQmlEngine *, QJSEngine *)> scriptCallback = {}; + std::function<QObject *(QQmlEngine *, QJSEngine *)> qobjectCallback = {}; + QByteArray typeName; + QUrl url; // used by composite singletons + + private: + Q_DISABLE_COPY_MOVE(SingletonInstanceInfo) + SingletonInstanceInfo() = default; + }; + SingletonInstanceInfo::ConstPtr singletonInstanceInfo() const; + + QUrl sourceUrl() const; + + int enumValue(QQmlEnginePrivate *engine, const QHashedStringRef &, bool *ok) const; + int enumValue(QQmlEnginePrivate *engine, const QHashedCStringRef &, bool *ok) const; + int enumValue(QQmlEnginePrivate *engine, const QV4::String *, bool *ok) const; + + int scopedEnumIndex(QQmlEnginePrivate *engine, const QV4::String *, bool *ok) const; + int scopedEnumIndex(QQmlEnginePrivate *engine, const QString &, bool *ok) const; + int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QV4::String *, bool *ok) const; + int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QString &, bool *ok) const; + int scopedEnumValue(QQmlEnginePrivate *engine, const QHashedStringRef &, const QHashedStringRef &, bool *ok) const; + + const QQmlTypePrivate *priv() const { return d.data(); } + static void refHandle(const QQmlTypePrivate *priv); + static void derefHandle(const QQmlTypePrivate *priv); + static int refCount(const QQmlTypePrivate *priv); + + enum RegistrationType { + CppType = 0, + SingletonType = 1, + InterfaceType = 2, + CompositeType = 3, + CompositeSingletonType = 4, + InlineComponentType = 5, + SequentialContainerType = 6, + AnyRegistrationType = 255 + }; + + void createProxy(QObject *instance) const; + +private: + friend class QQmlTypePrivate; + friend size_t qHash(const QQmlType &t, size_t seed); + friend bool operator==(const QQmlType &a, const QQmlType &b) noexcept + { + return a.d.data() == b.d.data(); + } + friend bool operator!=(const QQmlType &a, const QQmlType &b) noexcept + { + return !(a == b); + } + + QQmlRefPointer<const QQmlTypePrivate> d; +}; + +inline size_t qHash(const QQmlType &t, size_t seed = 0) +{ + return qHash(reinterpret_cast<quintptr>(t.d.data()), seed); +} + +QT_END_NAMESPACE + +#endif // QQMLTYPE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltype_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltype_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..127deabe1127d0b49981dcf00319749a6e34e85c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltype_p_p.h @@ -0,0 +1,329 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTYPE_P_P_H +#define QQMLTYPE_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlengine_p.h> +#include <private/qqmlmetatype_p.h> +#include <private/qqmlpropertycache_p.h> +#include <private/qqmlproxymetaobject_p.h> +#include <private/qqmlrefcount_p.h> +#include <private/qqmltype_p.h> +#include <private/qqmltypeloader_p.h> +#include <private/qstringhash_p.h> +#include <private/qv4engine_p.h> +#include <private/qv4executablecompilationunit_p.h> +#include <private/qv4resolvedtypereference_p.h> + +#include <QAtomicInteger> + +QT_BEGIN_NAMESPACE + +class QQmlTypePrivate final : public QQmlRefCounted<QQmlTypePrivate> +{ + Q_DISABLE_COPY_MOVE(QQmlTypePrivate) +public: + struct ProxyMetaObjects + { + ~ProxyMetaObjects() + { + for (const QQmlProxyMetaObject::ProxyData &metaObject : data) + free(metaObject.metaObject); + } + + QList<QQmlProxyMetaObject::ProxyData> data; + bool containsRevisionedAttributes = false; + }; + + struct Enums + { + ~Enums() { qDeleteAll(scopedEnums); } + + QStringHash<int> enums; + QStringHash<int> scopedEnumIndex; // maps from enum name to index in scopedEnums + QList<QStringHash<int> *> scopedEnums; + }; + + QQmlTypePrivate(QQmlType::RegistrationType type); + + const ProxyMetaObjects *init() const; + + QUrl sourceUrl() const + { + switch (regType) { + case QQmlType::CompositeType: + return extraData.compositeTypeData; + case QQmlType::CompositeSingletonType: + return extraData.singletonTypeData->singletonInstanceInfo->url; + case QQmlType::InlineComponentType: + return extraData.inlineComponentTypeData; + default: + return QUrl(); + } + } + + const QQmlTypePrivate *attachedPropertiesBase(QQmlEnginePrivate *engine) const + { + for (const QQmlTypePrivate *d = this; d; d = d->resolveCompositeBaseType(engine).d.data()) { + if (d->regType == QQmlType::CppType) + return d->extraData.cppTypeData->attachedPropertiesType ? d : nullptr; + + if (d->regType != QQmlType::CompositeType) + return nullptr; + } + return nullptr; + } + + bool isComposite() const + { + return regType == QQmlType::CompositeType || regType == QQmlType::CompositeSingletonType; + } + + bool isValueType() const + { + return regType == QQmlType::CppType && !(typeId.flags() & QMetaType::PointerToQObject); + } + + QQmlType resolveCompositeBaseType(QQmlEnginePrivate *engine) const; + QQmlPropertyCache::ConstPtr compositePropertyCache(QQmlEnginePrivate *engine) const; + + struct QQmlCppTypeData + { + int allocationSize; + void (*newFunc)(void *, void *); + void *userdata = nullptr; + QString noCreationReason; + QVariant (*createValueTypeFunc)(const QJSValue &); + int parserStatusCast; + QObject *(*extFunc)(QObject *); + const QMetaObject *extMetaObject; + QQmlCustomParser *customParser; + QQmlAttachedPropertiesFunc attachedPropertiesFunc; + const QMetaObject *attachedPropertiesType; + int propertyValueSourceCast; + int propertyValueInterceptorCast; + int finalizerCast; + bool registerEnumClassesUnscoped; + bool registerEnumsFromRelatedTypes; + bool constructValueType; + bool populateValueType; + }; + + struct QQmlSingletonTypeData + { + QQmlType::SingletonInstanceInfo::ConstPtr singletonInstanceInfo; + QObject *(*extFunc)(QObject *); + const QMetaObject *extMetaObject; + }; + + int index = -1; + + union extraData { + extraData() {} // QQmlTypePrivate() does the actual construction. + ~extraData() {} // ~QQmlTypePrivate() does the actual destruction. + + QQmlCppTypeData *cppTypeData; + QQmlSingletonTypeData *singletonTypeData; + QUrl compositeTypeData; + QUrl inlineComponentTypeData; + QMetaSequence sequentialContainerTypeData; + const char *interfaceTypeData; + } extraData; + static_assert(sizeof(extraData) == sizeof(void *)); + + QHashedString module; + QString name; + QString elementName; + QMetaType typeId; + QMetaType listId; + QQmlType::RegistrationType regType; + QTypeRevision version; + QTypeRevision revision = QTypeRevision::zero(); + const QMetaObject *baseMetaObject = nullptr; + + void setName(const QString &uri, const QString &element); + + template<typename String> + static int enumValue( + const QQmlRefPointer<const QQmlTypePrivate> &d, QQmlEnginePrivate *engine, + const String &name, bool *ok) + { + return doGetEnumValue(d, engine, [&](const QQmlTypePrivate::Enums *enums) { + return enums->enums.value(name); + }, ok); + } + + template<typename String> + static int scopedEnumIndex( + const QQmlRefPointer<const QQmlTypePrivate> &d, QQmlEnginePrivate *engine, + const String &name, bool *ok) + { + return doGetEnumValue(d, engine, [&](const QQmlTypePrivate::Enums *enums) { + return enums->scopedEnumIndex.value(name); + }, ok); + } + + template<typename String> + static int scopedEnumValue( + const QQmlRefPointer<const QQmlTypePrivate> &d, QQmlEnginePrivate *engine, int index, + const String &name, bool *ok) + { + return doGetEnumValue(d, engine, [&](const QQmlTypePrivate::Enums *enums) { + Q_ASSERT(index > -1 && index < enums->scopedEnums.size()); + return enums->scopedEnums.at(index)->value(name); + }, ok); + } + + template<typename String1, typename String2> + static int scopedEnumValue( + const QQmlRefPointer<const QQmlTypePrivate> &d, QQmlEnginePrivate *engine, + const String1 &scopedEnumName, const String2 &name, bool *ok) + { + return doGetEnumValue(d, engine, [&](const QQmlTypePrivate::Enums *enums) -> const int * { + const int *rv = enums->scopedEnumIndex.value(scopedEnumName); + if (!rv) + return nullptr; + + const int index = *rv; + Q_ASSERT(index > -1 && index < enums->scopedEnums.size()); + return enums->scopedEnums.at(index)->value(name); + }, ok); + } + + const QMetaObject *metaObject() const + { + if (isValueType()) + return metaObjectForValueType(); + + const QQmlTypePrivate::ProxyMetaObjects *proxies = init(); + return proxies->data.isEmpty() + ? baseMetaObject + : proxies->data.constFirst().metaObject; + } + + const QMetaObject *metaObjectForValueType() const + { + Q_ASSERT(isValueType()); + + // Prefer the extension meta object, if any. + // Extensions allow registration of non-gadget value types. + if (const QMetaObject *extensionMetaObject = extraData.cppTypeData->extMetaObject) { + // This may be a namespace even if the original metaType isn't. + // You can do such things with QML_FOREIGN declarations. + if (extensionMetaObject->metaType().flags() & QMetaType::IsGadget) + return extensionMetaObject; + } + + if (baseMetaObject) { + // This may be a namespace even if the original metaType isn't. + // You can do such things with QML_FOREIGN declarations. + if (baseMetaObject->metaType().flags() & QMetaType::IsGadget) + return baseMetaObject; + } + + return nullptr; + } + + static QQmlType visibleQmlTypeByName( + const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit, + const QString &elementName, QQmlTypeLoader *typeLoader) + { + const QQmlType qmltype = unit->typeNameCache->query<QQmlImport::AllowRecursion>( + elementName, typeLoader).type; + + if (qmltype.isValid() && qmltype.isInlineComponentType() + && !QQmlMetaType::obtainCompilationUnit(qmltype.typeId())) { + // If it seems to be an IC type, make sure there is an actual + // compilation unit for it. We create inline component types speculatively. + return QQmlType(); + } + + return qmltype; + } + + // Tries the base unit's resolvedTypes first. If successful, that is cheap + // because it's just a hash. Otherwise falls back to typeNameCache. + // typeNameCache is slower because it will do a generic type search on all imports. + // This can involve iterating all the types of an import or querying QQmlMetaType for + // further details. + // TODO: Not all referenced types are pre-resolved when loading. That should be fixed. + // In particular, types only used in function signatures are not resolved. + static QQmlType visibleQmlTypeByName( + const QV4::ExecutableCompilationUnit *unit, int elementNameId, + QQmlTypeLoader *typeLoader = nullptr) + { + const auto &base = unit->baseCompilationUnit(); + const auto it = base->resolvedTypes.constFind(elementNameId); + if (it == base->resolvedTypes.constEnd()) { + return visibleQmlTypeByName( + base, base->stringAt(elementNameId), + typeLoader ? typeLoader : unit->engine->typeLoader()); + } + + if (const QQmlType type = (*it)->type(); type.isValid()) + return type; + + if (const auto cu = (*it)->compilationUnit()) + return cu->qmlType; + + return QQmlType(); + } + +private: + mutable QAtomicPointer<const ProxyMetaObjects> proxyMetaObjects; + mutable QAtomicPointer<const Enums> enums; + + ~QQmlTypePrivate(); + friend class QQmlRefCounted<QQmlTypePrivate>; + + struct EnumInfo { + QStringList path; + QString metaObjectName; + QString enumName; + QString enumKey; + QString metaEnumScope; + bool scoped; + }; + + template<typename Op> + static int doGetEnumValue( + const QQmlRefPointer<const QQmlTypePrivate> &d, QQmlEnginePrivate *engine, + Op &&op, bool *ok) + { + Q_ASSERT(ok); + if (d) { + if (const QQmlTypePrivate::Enums *enums = d->initEnums(engine)) { + if (const int *rv = op(enums)) { + *ok = true; + return *rv; + } + } + } + + *ok = false; + return -1; + } + + const Enums *initEnums(QQmlEnginePrivate *engine) const; + void insertEnums(Enums *enums, const QMetaObject *metaObject) const; + void insertEnumsFromPropertyCache(Enums *enums, const QQmlPropertyCache::ConstPtr &cache) const; + + void createListOfPossibleConflictingItems(const QMetaObject *metaObject, QList<EnumInfo> &enumInfoList, QStringList path) const; + void createEnumConflictReport(const QMetaObject *metaObject, const QString &conflictingKey) const; +}; + +QT_END_NAMESPACE + +#endif // QQMLTYPE_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypecompiler_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypecompiler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dafbbd0164da2dbd086ca9f2012ecf71bcd8f5e6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypecompiler_p.h @@ -0,0 +1,274 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQMLTYPECOMPILER_P_H +#define QQMLTYPECOMPILER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qglobal.h> +#include <qqmlerror.h> +#include <qhash.h> +#include <private/qqmltypeloader_p.h> +#include <private/qqmlirbuilder_p.h> +#include <private/qqmlpropertycachecreator_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlEnginePrivate; +class QQmlError; +class QQmlTypeData; +class QQmlImports; + +namespace QmlIR { +struct Document; +} + +namespace QV4 { +namespace CompiledData { +struct QmlUnit; +struct Location; +} +} + +struct QQmlTypeCompiler +{ + Q_DECLARE_TR_FUNCTIONS(QQmlTypeCompiler) +public: + QQmlTypeCompiler(QQmlEnginePrivate *engine, + QQmlTypeData *typeData, + QmlIR::Document *document, + QV4::CompiledData::ResolvedTypeReferenceMap *resolvedTypeCache, + const QV4::CompiledData::DependentTypesHasher &dependencyHasher); + + // --- interface used by QQmlPropertyCacheCreator + typedef QmlIR::Object CompiledObject; + typedef QmlIR::Binding CompiledBinding; + using ListPropertyAssignBehavior = QmlIR::Pragma::ListPropertyAssignBehaviorValue; + + // Deliberate choice of map over hash here to ensure stable generated output. + using IdToObjectMap = QMap<int, int>; + + const QmlIR::Object *objectAt(int index) const { return document->objects.at(index); } + QmlIR::Object *objectAt(int index) { return document->objects.at(index); } + int objectCount() const { return document->objects.size(); } + QString stringAt(int idx) const; + QmlIR::PoolList<QmlIR::Function>::Iterator objectFunctionsBegin(const QmlIR::Object *object) const { return object->functionsBegin(); } + QmlIR::PoolList<QmlIR::Function>::Iterator objectFunctionsEnd(const QmlIR::Object *object) const { return object->functionsEnd(); } + QV4::CompiledData::ResolvedTypeReferenceMap *resolvedTypes = nullptr; + ListPropertyAssignBehavior listPropertyAssignBehavior() const + { + for (const QmlIR::Pragma *pragma: document->pragmas) { + if (pragma->type == QmlIR::Pragma::ListPropertyAssignBehavior) + return pragma->listPropertyAssignBehavior; + } + return ListPropertyAssignBehavior::Append; + } + // --- + + QQmlRefPointer<QV4::CompiledData::CompilationUnit> compile(); + + QList<QQmlError> compilationErrors() const { return errors; } + void recordError(const QV4::CompiledData::Location &location, const QString &description); + void recordError(const QQmlJS::DiagnosticMessage &message); + void recordError(const QQmlError &e); + + int registerString(const QString &str); + int registerConstant(QV4::ReturnedValue v); + + const QV4::CompiledData::Unit *qmlUnit() const; + + QUrl url() const { return typeData->finalUrl(); } + QQmlEnginePrivate *enginePrivate() const { return engine; } + const QQmlImports *imports() const; + QVector<QmlIR::Object *> *qmlObjects() const; + QQmlPropertyCacheVector *propertyCaches(); + const QQmlPropertyCacheVector *propertyCaches() const; + QQmlJS::MemoryPool *memoryPool(); + QStringView newStringRef(const QString &string); + const QV4::Compiler::StringTableGenerator *stringPool() const; + + const QHash<int, QQmlCustomParser*> &customParserCache() const { return customParsers; } + + QString bindingAsString(const QmlIR::Object *object, int scriptIndex) const; + + void addImport(const QString &module, const QString &qualifier, QTypeRevision version); + + QV4::ResolvedTypeReference *resolvedType(int id) const + { + return resolvedTypes->value(id); + } + + QV4::ResolvedTypeReference *resolvedType(QMetaType type) const + { + for (QV4::ResolvedTypeReference *ref : std::as_const(*resolvedTypes)) { + if (ref->type().typeId() == type) + return ref; + } + return nullptr; + } + + QQmlType qmlTypeForComponent(const QString &inlineComponentName = QString()) const; + +private: + QList<QQmlError> errors; + QQmlEnginePrivate *engine; + const QV4::CompiledData::DependentTypesHasher &dependencyHasher; + QmlIR::Document *document; + // index is string index of type name (use obj->inheritedTypeNameIndex) + QHash<int, QQmlCustomParser*> customParsers; + + // index in first hash is component index, vector inside contains object indices of objects with id property + QQmlPropertyCacheVector m_propertyCaches; + + QQmlTypeData *typeData; +}; + +struct QQmlCompilePass +{ + QQmlCompilePass(QQmlTypeCompiler *typeCompiler); + + QString stringAt(int idx) const { return compiler->stringAt(idx); } +protected: + void recordError(const QV4::CompiledData::Location &location, const QString &description) const + { compiler->recordError(location, description); } + + QV4::ResolvedTypeReference *resolvedType(int id) const + { return compiler->resolvedType(id); } + + QQmlTypeCompiler *compiler; +}; + +// Resolves signal handlers. Updates the QV4::CompiledData::Binding objects to +// set the property name to the final signal name (onTextChanged -> textChanged) +// and sets the IsSignalExpression flag. +struct SignalHandlerResolver : public QQmlCompilePass +{ + Q_DECLARE_TR_FUNCTIONS(SignalHandlerResolver) +public: + SignalHandlerResolver(QQmlTypeCompiler *typeCompiler); + + bool resolveSignalHandlerExpressions(); + +private: + bool resolveSignalHandlerExpressions(const QmlIR::Object *obj, const QString &typeName, + const QQmlPropertyCache::ConstPtr &propertyCache); + + QQmlEnginePrivate *enginePrivate; + const QVector<QmlIR::Object*> &qmlObjects; + const QQmlImports *imports; + const QHash<int, QQmlCustomParser*> &customParsers; + const QSet<QString> &illegalNames; + const QQmlPropertyCacheVector * const propertyCaches; +}; + +// ### This will go away when the codegen resolves all enums to constant expressions +// and we replace the constant expression with a literal binding instead of using +// a script. +class QQmlEnumTypeResolver : public QQmlCompilePass +{ + Q_DECLARE_TR_FUNCTIONS(QQmlEnumTypeResolver) +public: + QQmlEnumTypeResolver(QQmlTypeCompiler *typeCompiler); + + bool resolveEnumBindings(); + +private: + bool assignEnumToBinding(QmlIR::Binding *binding, QStringView enumName, int enumValue, bool isQtObject); + bool assignEnumToBinding(QmlIR::Binding *binding, const QString &enumName, int enumValue, bool isQtObject) + { + return assignEnumToBinding(binding, QStringView(enumName), enumValue, isQtObject); + } + bool tryQualifiedEnumAssignment( + const QmlIR::Object *obj, const QQmlPropertyCache::ConstPtr &propertyCache, + const QQmlPropertyData *prop, QmlIR::Binding *binding); + int evaluateEnum(const QString &scope, QStringView enumName, QStringView enumValue, bool *ok) const; + + + const QVector<QmlIR::Object*> &qmlObjects; + const QQmlPropertyCacheVector * const propertyCaches; + const QQmlImports *imports; +}; + +class QQmlCustomParserScriptIndexer: public QQmlCompilePass +{ +public: + QQmlCustomParserScriptIndexer(QQmlTypeCompiler *typeCompiler); + + void annotateBindingsWithScriptStrings(); + +private: + void scanObjectRecursively(int objectIndex, bool annotateScriptBindings = false); + + const QVector<QmlIR::Object*> &qmlObjects; + const QHash<int, QQmlCustomParser*> &customParsers; +}; + +// Annotate properties bound to aliases with a flag +class QQmlAliasAnnotator : public QQmlCompilePass +{ +public: + QQmlAliasAnnotator(QQmlTypeCompiler *typeCompiler); + + void annotateBindingsToAliases(); +private: + const QVector<QmlIR::Object*> &qmlObjects; + const QQmlPropertyCacheVector * const propertyCaches; +}; + +class QQmlScriptStringScanner : public QQmlCompilePass +{ +public: + QQmlScriptStringScanner(QQmlTypeCompiler *typeCompiler); + + void scan(); + +private: + const QVector<QmlIR::Object*> &qmlObjects; + const QQmlPropertyCacheVector * const propertyCaches; +}; + +class QQmlDeferredAndCustomParserBindingScanner : public QQmlCompilePass +{ + Q_DECLARE_TR_FUNCTIONS(QQmlDeferredAndCustomParserBindingScanner) +public: + QQmlDeferredAndCustomParserBindingScanner(QQmlTypeCompiler *typeCompiler); + + bool scanObject(); + +private: + enum class ScopeDeferred { False, True }; + bool scanObject(int objectIndex, ScopeDeferred scopeDeferred); + + QVector<QmlIR::Object*> *qmlObjects; + const QQmlPropertyCacheVector * const propertyCaches; + const QHash<int, QQmlCustomParser*> &customParsers; + + bool _seenObjectWithId; +}; + +class QQmlDefaultPropertyMerger : public QQmlCompilePass +{ +public: + QQmlDefaultPropertyMerger(QQmlTypeCompiler *typeCompiler); + + void mergeDefaultProperties(); + +private: + void mergeDefaultProperties(int objectIndex); + + const QVector<QmlIR::Object*> &qmlObjects; + const QQmlPropertyCacheVector * const propertyCaches; +}; + +QT_END_NAMESPACE + +#endif // QQMLTYPECOMPILER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypedata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypedata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2f5c452cfea4aec5b671154b2735379b4c64e326 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypedata_p.h @@ -0,0 +1,145 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTYPEDATA_P_H +#define QQMLTYPEDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmltypeloader_p.h> +#include <private/qv4executablecompilationunit_p.h> + +QT_BEGIN_NAMESPACE + +class Q_AUTOTEST_EXPORT QQmlTypeData : public QQmlTypeLoader::Blob +{ + Q_DECLARE_TR_FUNCTIONS(QQmlTypeData) +public: + struct TypeReference + { + TypeReference() : version(QTypeRevision::zero()), needsCreation(true) {} + + QV4::CompiledData::Location location; + QQmlType type; + QTypeRevision version; + QQmlRefPointer<QQmlTypeData> typeData; + bool selfReference = false; + QString prefix; // used by CompositeSingleton types + QString qualifiedName() const; + bool needsCreation; + }; + + struct ScriptReference + { + QV4::CompiledData::Location location; + QString qualifier; + QQmlRefPointer<QQmlScriptBlob> script; + }; + +private: + friend class QQmlTypeLoader; + + QQmlTypeData(const QUrl &, QQmlTypeLoader *); + template<typename Container> + void setCompileUnit(const Container &container); + +public: + ~QQmlTypeData() override; + + QV4::CompiledData::CompilationUnit *compilationUnit() const; + + // Used by QQmlComponent to get notifications + struct TypeDataCallback { + virtual ~TypeDataCallback(); + virtual void typeDataProgress(QQmlTypeData *, qreal) {} + virtual void typeDataReady(QQmlTypeData *) {} + }; + void registerCallback(TypeDataCallback *); + void unregisterCallback(TypeDataCallback *); + + QQmlType qmlType(const QString &inlineComponentName = QString()) const; + QByteArray typeClassName() const { return m_typeClassName; } + SourceCodeData backupSourceCode() const { return m_backupSourceCode; } + +protected: + void done() override; + void completed() override; + void dataReceived(const SourceCodeData &) override; + void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) override; + void allDependenciesDone() override; + void downloadProgressChanged(qreal) override; + + QString stringAt(int index) const override; + +private: + using InlineComponentData = QV4::CompiledData::InlineComponentData; + + bool tryLoadFromDiskCache(); + bool loadFromDiskCache(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit); + bool loadFromSource(); + void restoreIR(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit); + void continueLoadFromIR(); + void resolveTypes(); + QQmlError buildTypeResolutionCaches( + QQmlRefPointer<QQmlTypeNameCache> *typeNameCache, + QV4::CompiledData::ResolvedTypeReferenceMap *resolvedTypeCache + ) const; + void compile(const QQmlRefPointer<QQmlTypeNameCache> &typeNameCache, + QV4::CompiledData::ResolvedTypeReferenceMap *resolvedTypeCache, + const QV4::CompiledData::DependentTypesHasher &dependencyHasher); + QQmlError createTypeAndPropertyCaches( + const QQmlRefPointer<QQmlTypeNameCache> &typeNameCache, + const QV4::CompiledData::ResolvedTypeReferenceMap &resolvedTypeCache); + bool resolveType(const QString &typeName, QTypeRevision &version, + TypeReference &ref, int lineNumber = -1, int columnNumber = -1, + bool reportErrors = true, + QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType, + bool *typeRecursionDetected = nullptr); + + void scriptImported( + const QQmlRefPointer<QQmlScriptBlob> &blob, const QV4::CompiledData::Location &location, + const QString &nameSpace, const QString &qualifier) override; + + SourceCodeData m_backupSourceCode; // used when cache verification fails. + QScopedPointer<QmlIR::Document> m_document; + QV4::CompiledData::TypeReferenceMap m_typeReferences; + + QList<ScriptReference> m_scripts; + + QSet<QString> m_namespaces; + QList<TypeReference> m_compositeSingletons; + + // map from name index to resolved type + // While this could be a hash, a map is chosen here to provide a stable + // order, which is used to calculating a check-sum on dependent meta-objects. + QMap<int, TypeReference> m_resolvedTypes; + bool m_typesResolved:1; + + // Used for self-referencing types, otherwise invalid. + QQmlType m_qmlType; + QByteArray m_typeClassName; // used for meta-object later + + using CompilationUnitPtr = QQmlRefPointer<QV4::CompiledData::CompilationUnit>; + + QHash<QString, InlineComponentData> m_inlineComponentData; + + CompilationUnitPtr m_compiledData; + + QList<TypeDataCallback *> m_callbacks; + + bool m_implicitImportLoaded; + bool loadImplicitImport(); +}; + +QT_END_NAMESPACE + +#endif // QQMLTYPEDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloader_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e163a7031a3f0605c12b351477e3fac588884d5a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloader_p.h @@ -0,0 +1,253 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTYPELOADER_P_H +#define QQMLTYPELOADER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmldatablob_p.h> +#include <private/qqmlimport_p.h> +#include <private/qqmlmetatype_p.h> +#include <private/qv4compileddata_p.h> + +#include <QtQml/qtqmlglobal.h> +#include <QtQml/qqmlerror.h> + +#include <QtCore/qcache.h> +#include <QtCore/qmutex.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +class QQmlScriptBlob; +class QQmlQmldirData; +class QQmlTypeData; +class QQmlEngineExtensionInterface; +class QQmlExtensionInterface; +class QQmlProfiler; +class QQmlTypeLoaderThread; +class QQmlEngine; + +class Q_QML_EXPORT QQmlTypeLoader +{ + Q_DECLARE_TR_FUNCTIONS(QQmlTypeLoader) +public: + using ChecksumCache = QHash<quintptr, QByteArray>; + enum Mode { PreferSynchronous, Asynchronous, Synchronous }; + + class Q_QML_EXPORT Blob : public QQmlDataBlob + { + public: + Blob(const QUrl &url, QQmlDataBlob::Type type, QQmlTypeLoader *loader); + ~Blob() override; + + const QQmlImports *imports() const { return m_importCache.data(); } + + void setCachedUnitStatus(QQmlMetaType::CachedUnitLookupError status) { m_cachedUnitStatus = status; } + + struct PendingImport + { + QString uri; + QString qualifier; + + QV4::CompiledData::Import::ImportType type + = QV4::CompiledData::Import::ImportType::ImportLibrary; + QV4::CompiledData::Location location; + + QQmlImports::ImportFlags flags; + quint8 precedence = 0; + int priority = 0; + + QTypeRevision version; + + PendingImport() = default; + PendingImport(Blob *blob, const QV4::CompiledData::Import *import, + QQmlImports::ImportFlags flags); + }; + using PendingImportPtr = std::shared_ptr<PendingImport>; + + void importQmldirScripts(const PendingImportPtr &import, const QQmlTypeLoaderQmldirContent &qmldir, const QUrl &qmldirUrl); + + protected: + bool addImport(const QV4::CompiledData::Import *import, QQmlImports::ImportFlags, + QList<QQmlError> *errors); + bool addImport(PendingImportPtr import, QList<QQmlError> *errors); + + bool fetchQmldir(const QUrl &url, PendingImportPtr import, int priority, QList<QQmlError> *errors); + bool updateQmldir(const QQmlRefPointer<QQmlQmldirData> &data, const PendingImportPtr &import, QList<QQmlError> *errors); + + private: + bool addScriptImport(const PendingImportPtr &import); + bool addFileImport(const PendingImportPtr &import, QList<QQmlError> *errors); + bool addLibraryImport(const PendingImportPtr &import, QList<QQmlError> *errors); + + virtual bool qmldirDataAvailable(const QQmlRefPointer<QQmlQmldirData> &, QList<QQmlError> *); + + virtual void scriptImported(const QQmlRefPointer<QQmlScriptBlob> &, const QV4::CompiledData::Location &, const QString &, const QString &) {} + + void dependencyComplete(QQmlDataBlob *) override; + + bool loadImportDependencies( + const PendingImportPtr ¤tImport, const QString &qmldirUri, + QQmlImports::ImportFlags flags, QList<QQmlError> *errors); + + protected: + bool loadDependentImports( + const QList<QQmlDirParser::Import> &imports, const QString &qualifier, + QTypeRevision version, quint16 precedence, QQmlImports::ImportFlags flags, + QList<QQmlError> *errors); + virtual QString stringAt(int) const { return QString(); } + + bool isDebugging() const; + bool readCacheFile() const; + bool writeCacheFile() const; + QQmlMetaType::CacheMode aotCacheMode() const; + + QQmlRefPointer<QQmlImports> m_importCache; + QVector<PendingImportPtr> m_unresolvedImports; + QVector<QQmlRefPointer<QQmlQmldirData>> m_qmldirs; + QQmlMetaType::CachedUnitLookupError m_cachedUnitStatus = QQmlMetaType::CachedUnitLookupError::NoError; + }; + + QQmlTypeLoader(QQmlEngine *); + ~QQmlTypeLoader(); + + template< + typename Engine, + typename EnginePrivate = QQmlEnginePrivate, + typename = std::enable_if_t<std::is_same_v<Engine, QQmlEngine>>> + static QQmlTypeLoader *get(Engine *engine) + { + return get(EnginePrivate::get(engine)); + } + + template< + typename Engine, + typename = std::enable_if_t<std::is_same_v<Engine, QQmlEnginePrivate>>> + static QQmlTypeLoader *get(Engine *engine) + { + return &engine->typeLoader; + } + + QQmlImportDatabase *importDatabase() const; + ChecksumCache *checksumCache() { return &m_checksumCache; } + const ChecksumCache *checksumCache() const { return &m_checksumCache; } + + static QUrl normalize(const QUrl &unNormalizedUrl); + + QQmlRefPointer<QQmlTypeData> getType(const QUrl &unNormalizedUrl, Mode mode = PreferSynchronous); + QQmlRefPointer<QQmlTypeData> getType(const QByteArray &, const QUrl &url, Mode mode = PreferSynchronous); + + void injectScript(const QUrl &relativeUrl); + QQmlRefPointer<QQmlScriptBlob> injectedScript(const QUrl &relativeUrl); + + QQmlRefPointer<QQmlScriptBlob> getScript(const QUrl &unNormalizedUrl); + QQmlRefPointer<QQmlQmldirData> getQmldir(const QUrl &); + + QString absoluteFilePath(const QString &path); + bool fileExists(const QString &path, const QString &file); + bool directoryExists(const QString &path); + + const QQmlTypeLoaderQmldirContent qmldirContent(const QString &filePath); + void setQmldirContent(const QString &filePath, const QString &content); + + void clearCache(); + void trimCache(); + + bool isTypeLoaded(const QUrl &url) const; + bool isScriptLoaded(const QUrl &url) const; + + void lock() { m_mutex.lock(); } + void unlock() { m_mutex.unlock(); } + + void load(QQmlDataBlob *, Mode = PreferSynchronous); + void loadWithStaticData(QQmlDataBlob *, const QByteArray &, Mode = PreferSynchronous); + void loadWithCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit, Mode mode = PreferSynchronous); + void drop(const QQmlDataBlob::Ptr &blob); + + QQmlEngine *engine() const; + void initializeEngine(QQmlEngineExtensionInterface *, const char *); + void initializeEngine(QQmlExtensionInterface *, const char *); + void invalidate(); + +#if !QT_CONFIG(qml_debug) + quintptr profiler() const { return 0; } + void setProfiler(quintptr) {} +#else + QQmlProfiler *profiler() const { return m_profiler.data(); } + void setProfiler(QQmlProfiler *profiler); +#endif // QT_CONFIG(qml_debug) + + +private: + friend class QQmlDataBlob; + friend class QQmlTypeLoaderThread; +#if QT_CONFIG(qml_network) + friend class QQmlTypeLoaderNetworkReplyProxy; +#endif // qml_network + + void shutdownThread(); + + void loadThread(const QQmlDataBlob::Ptr &); + void loadWithStaticDataThread(const QQmlDataBlob::Ptr &, const QByteArray &); + void loadWithCachedUnitThread(const QQmlDataBlob::Ptr &blob, const QQmlPrivate::CachedQmlUnit *unit); +#if QT_CONFIG(qml_network) + void networkReplyFinished(QNetworkReply *); + void networkReplyProgress(QNetworkReply *, qint64, qint64); + + typedef QHash<QNetworkReply *, QQmlDataBlob::Ptr> NetworkReplies; +#endif + + void setData(const QQmlDataBlob::Ptr &, const QByteArray &); + void setData(const QQmlDataBlob::Ptr &, const QString &fileName); + void setData(const QQmlDataBlob::Ptr &, const QQmlDataBlob::SourceCodeData &); + void setCachedUnit(const QQmlDataBlob::Ptr &blob, const QQmlPrivate::CachedQmlUnit *unit); + + typedef QHash<QUrl, QQmlTypeData *> TypeCache; + typedef QHash<QUrl, QQmlScriptBlob *> ScriptCache; + typedef QHash<QUrl, QQmlQmldirData *> QmldirCache; + typedef QCache<QString, QCache<QString, bool> > ImportDirCache; + typedef QStringHash<QQmlTypeLoaderQmldirContent *> ImportQmlDirCache; + + QQmlEngine *m_engine; + QQmlTypeLoaderThread *m_thread; + QMutex &m_mutex; + +#if QT_CONFIG(qml_debug) + QScopedPointer<QQmlProfiler> m_profiler; +#endif + +#if QT_CONFIG(qml_network) + NetworkReplies m_networkReplies; +#endif + TypeCache m_typeCache; + int m_typeCacheTrimThreshold; + ScriptCache m_scriptCache; + QmldirCache m_qmldirCache; + ImportDirCache m_importDirCache; + ImportQmlDirCache m_importQmlDirCache; + ChecksumCache m_checksumCache; + + template<typename Loader> + void doLoad(const Loader &loader, QQmlDataBlob *blob, Mode mode); + void updateTypeCacheTrimThreshold(); + + friend struct PlainLoader; + friend struct CachedLoader; + friend struct StaticLoader; +}; + +QT_END_NAMESPACE + +#endif // QQMLTYPELOADER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloadernetworkreplyproxy_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloadernetworkreplyproxy_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c01607f04445d16ff71c4e6df8d01c08020a71a7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloadernetworkreplyproxy_p.h @@ -0,0 +1,51 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTYPELOADERNETWORKREPLYPROXY_P_H +#define QQMLTYPELOADERNETWORKREPLYPROXY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qtqmlglobal.h> +#include <QtCore/qobject.h> +#include <QtCore/private/qglobal_p.h> + +QT_REQUIRE_CONFIG(qml_network); + +QT_BEGIN_NAMESPACE + +class QNetworkReply; +class QQmlTypeLoader; + +// This is a lame object that we need to ensure that slots connected to +// QNetworkReply get called in the correct thread (the loader thread). +// As QQmlTypeLoader lives in the main thread, and we can't use +// Qt::DirectConnection connections from a QNetworkReply (because then +// sender() wont work), we need to insert this object in the middle. +class QQmlTypeLoaderNetworkReplyProxy : public QObject +{ + Q_OBJECT +public: + QQmlTypeLoaderNetworkReplyProxy(QQmlTypeLoader *l); + +public Q_SLOTS: + void finished(); + void downloadProgress(qint64, qint64); + void manualFinished(QNetworkReply*); + +private: + QQmlTypeLoader *l; +}; + +QT_END_NAMESPACE + +#endif // QQMLTYPELOADERNETWORKREPLYPROXY_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloaderqmldircontent_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloaderqmldircontent_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7d1445c25f6e97ce49f9ce2377b6681bbeb641e8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloaderqmldircontent_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTYPELOADERQMLDIRCONTENT_P_H +#define QQMLTYPELOADERQMLDIRCONTENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmldirparser_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlError; +class QQmlTypeLoaderQmldirContent +{ +private: + friend class QQmlTypeLoader; + + void setContent(const QString &location, const QString &content); + void setError(const QQmlError &); + +public: + QQmlTypeLoaderQmldirContent() = default; + QQmlTypeLoaderQmldirContent(const QQmlTypeLoaderQmldirContent &) = default; + QQmlTypeLoaderQmldirContent &operator=(const QQmlTypeLoaderQmldirContent &) = default; + + bool hasContent() const { return m_hasContent; } + bool hasError() const { return m_parser.hasError(); } + QList<QQmlError> errors(const QString &uri, const QUrl &url) const; + + QString typeNamespace() const { return m_parser.typeNamespace(); } + + QQmlDirComponents components() const { return m_parser.components(); } + QQmlDirScripts scripts() const { return m_parser.scripts(); } + QQmlDirPlugins plugins() const { return m_parser.plugins(); } + QQmlDirImports imports() const { return m_parser.imports(); } + + QString qmldirLocation() const { return m_location; } + QString preferredPath() const { return m_parser.preferredPath(); } + + bool hasRedirection() const + { + const QString preferred = preferredPath(); + return !preferred.isEmpty() + && preferred != QStringView(m_location).chopped(strlen("qmldir")); + } + + bool designerSupported() const { return m_parser.designerSupported(); } + bool hasTypeInfo() const { return !m_parser.typeInfos().isEmpty(); } + +private: + QQmlDirParser m_parser; + QString m_location; + bool m_hasContent = false; +}; + +QT_END_NAMESPACE + +#endif // QQMLTYPELOADERQMLDIRCONTENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloaderthread_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloaderthread_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d167bcce475b5621c515109e0dfb6bf161e71e5d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypeloaderthread_p.h @@ -0,0 +1,80 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTYPELOADERTHREAD_P_H +#define QQMLTYPELOADERTHREAD_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlthread_p.h> +#include <private/qv4compileddata_p.h> +#include <private/qqmldatablob_p.h> + +#include <QtQml/qtqmlglobal.h> + +#if QT_CONFIG(qml_network) +#include <private/qqmltypeloadernetworkreplyproxy_p.h> +#include <QtNetwork/qnetworkaccessmanager.h> +#endif + +QT_BEGIN_NAMESPACE + +class QQmlTypeLoader; +class QQmlEngineExtensionInterface; +class QQmlExtensionInterface; + +namespace QQmlPrivate { +struct CachedQmlUnit; +} + +class QQmlTypeLoaderThread : public QQmlThread +{ + typedef QQmlTypeLoaderThread This; + +public: + QQmlTypeLoaderThread(QQmlTypeLoader *loader); +#if QT_CONFIG(qml_network) + QNetworkAccessManager *networkAccessManager() const; + QQmlTypeLoaderNetworkReplyProxy *networkReplyProxy() const; +#endif // qml_network + void load(const QQmlDataBlob::Ptr &b); + void loadAsync(const QQmlDataBlob::Ptr &b); + void loadWithStaticData(const QQmlDataBlob::Ptr &b, const QByteArray &); + void loadWithStaticDataAsync(const QQmlDataBlob::Ptr &b, const QByteArray &); + void loadWithCachedUnit(const QQmlDataBlob::Ptr &b, const QQmlPrivate::CachedQmlUnit *unit); + void loadWithCachedUnitAsync(const QQmlDataBlob::Ptr &b, const QQmlPrivate::CachedQmlUnit *unit); + void callCompleted(const QQmlDataBlob::Ptr &b); + void callDownloadProgressChanged(const QQmlDataBlob::Ptr &b, qreal p); + void initializeEngine(QQmlExtensionInterface *, const char *); + void initializeEngine(QQmlEngineExtensionInterface *, const char *); + void drop(const QQmlDataBlob::Ptr &b); + +private: + void loadThread(const QQmlDataBlob::Ptr &b); + void loadWithStaticDataThread(const QQmlDataBlob::Ptr &b, const QByteArray &); + void loadWithCachedUnitThread(const QQmlDataBlob::Ptr &b, const QQmlPrivate::CachedQmlUnit *unit); + void callCompletedMain(const QQmlDataBlob::Ptr &b); + void callDownloadProgressChangedMain(const QQmlDataBlob::Ptr &b, qreal p); + void initializeExtensionMain(QQmlExtensionInterface *iface, const char *uri); + void initializeEngineExtensionMain(QQmlEngineExtensionInterface *iface, const char *uri); + void dropThread(const QQmlDataBlob::Ptr &b); + + QQmlTypeLoader *m_loader; +#if QT_CONFIG(qml_network) + mutable QNetworkAccessManager *m_networkAccessManager = nullptr; + mutable QQmlTypeLoaderNetworkReplyProxy *m_networkReplyProxy = nullptr; +#endif // qml_network +}; + +QT_END_NAMESPACE + +#endif // QQMLTYPELOADERTHREAD_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypemodule_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypemodule_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c65e547bb44d12a08f35cf78d0c2858fc36ef896 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypemodule_p.h @@ -0,0 +1,120 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTYPEMODULE_P_H +#define QQMLTYPEMODULE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qtqmlglobal.h> +#include <QtQml/private/qstringhash_p.h> +#include <QtQml/private/qqmltype_p.h> +#include <QtCore/qmutex.h> +#include <QtCore/qstring.h> +#include <QtCore/qversionnumber.h> + +#include <functional> + +QT_BEGIN_NAMESPACE + +class QQmlType; +class QQmlTypePrivate; +struct QQmlMetaTypeData; + +namespace QV4 { +struct String; +} + +class QQmlTypeModule +{ +public: + enum class LockLevel { + Open = 0, + Weak = 1, + Strong = 2 + }; + + QQmlTypeModule() = default; + QQmlTypeModule(const QString &uri, quint8 majorVersion) + : m_module(uri), m_majorVersion(majorVersion) + {} + + void add(QQmlTypePrivate *); + void remove(const QQmlTypePrivate *type); + + LockLevel lockLevel() const { return LockLevel(m_lockLevel.loadRelaxed()); } + bool setLockLevel(LockLevel mode) + { + while (true) { + const int currentLock = m_lockLevel.loadAcquire(); + if (currentLock > int(mode)) + return false; + if (currentLock == int(mode) || m_lockLevel.testAndSetRelease(currentLock, int(mode))) + return true; + } + } + + QString module() const + { + // No need to lock. m_module is const + return m_module; + } + + quint8 majorVersion() const + { + // No need to lock. d->majorVersion is const + return m_majorVersion; + } + + void addMinorVersion(quint8 minorVersion); + quint8 minimumMinorVersion() const { return m_minMinorVersion.loadRelaxed(); } + quint8 maximumMinorVersion() const { return m_maxMinorVersion.loadRelaxed(); } + + QQmlType type(const QHashedStringRef &name, QTypeRevision version) const + { + QMutexLocker lock(&m_mutex); + return findType(m_typeHash.value(name), version); + } + + QQmlType type(const QV4::String *name, QTypeRevision version) const + { + QMutexLocker lock(&m_mutex); + return findType(m_typeHash.value(name), version); + } + + void walkCompositeSingletons(const std::function<void(const QQmlType &)> &callback) const; + +private: + static Q_QML_EXPORT QQmlType findType( + const QList<QQmlTypePrivate *> *types, QTypeRevision version); + + const QString m_module; + const quint8 m_majorVersion = 0; + + // Can only ever decrease + QAtomicInt m_minMinorVersion = std::numeric_limits<quint8>::max(); + + // Can only ever increase + QAtomicInt m_maxMinorVersion = 0; + + // LockLevel. Can only be increased. + QAtomicInt m_lockLevel = int(LockLevel::Open); + + using TypeHash = QStringHash<QList<QQmlTypePrivate *>>; + TypeHash m_typeHash; + + mutable QMutex m_mutex; +}; + +QT_END_NAMESPACE + +#endif // QQMLTYPEMODULE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypemoduleversion_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypemoduleversion_p.h new file mode 100644 index 0000000000000000000000000000000000000000..086b316341c4751fb08bfe09dc6f53bda2be5694 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypemoduleversion_p.h @@ -0,0 +1,58 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTYPEMODULEVERSION_P_H +#define QQMLTYPEMODULEVERSION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qtqmlglobal.h> +#include <QtQml/private/qqmltype_p.h> +#include <QtQml/private/qqmltypemodule_p.h> +#include <QtCore/qversionnumber.h> + +QT_BEGIN_NAMESPACE + +class QQmlTypeModule; +class QQmlType; +class QHashedStringRef; + +namespace QV4 { +struct String; +} + +class QQmlTypeModuleVersion +{ +public: + QQmlTypeModuleVersion(); + QQmlTypeModuleVersion(QQmlTypeModule *, QTypeRevision); + QQmlTypeModuleVersion(const QQmlTypeModuleVersion &); + QQmlTypeModuleVersion &operator=(const QQmlTypeModuleVersion &); + + template<typename String> + QQmlType type(String name) const + { + if (!m_module) + return QQmlType(); + return m_module->type(name, QTypeRevision::isValidSegment(m_minor) + ? QTypeRevision::fromMinorVersion(m_minor) + : QTypeRevision()); + } + +private: + QQmlTypeModule *m_module; + quint8 m_minor; +}; + +QT_END_NAMESPACE + +#endif // QQMLTYPEMODULEVERSION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypenamecache_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypenamecache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1fd9a5d842cae41717e525e355f23d88ba1f28a6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypenamecache_p.h @@ -0,0 +1,278 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTYPENAMECACHE_P_H +#define QQMLTYPENAMECACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlrefcount_p.h> +#include "qqmlmetatype_p.h" + +#include <private/qstringhash_p.h> +#include <private/qqmlimport_p.h> +#include <private/qqmltypemoduleversion_p.h> + +#include <QtCore/qvector.h> + +QT_BEGIN_NAMESPACE + +struct QQmlImportRef { + inline QQmlImportRef() + : scriptIndex(-1) + {} + // Imported module + QVector<QQmlTypeModuleVersion> modules; + + // Or, imported script + int scriptIndex; + + // Or, imported compositeSingletons + QStringHash<QUrl> compositeSingletons; + + // The qualifier of this import + QString m_qualifier; +}; + +class QQmlType; +class QQmlEngine; +class Q_QML_EXPORT QQmlTypeNameCache final : public QQmlRefCounted<QQmlTypeNameCache> +{ +public: + QQmlTypeNameCache(const QQmlRefPointer<QQmlImports> &imports) : m_imports(imports) {} + ~QQmlTypeNameCache() {} + + inline bool isEmpty() const; + + void add(const QHashedString &name, int sciptIndex = -1, const QHashedString &nameSpace = QHashedString()); + void add(const QHashedString &name, const QUrl &url, const QHashedString &nameSpace = QHashedString()); + + struct Result { + inline Result(); + inline Result(const QQmlImportRef *importNamespace); + inline Result(const QQmlType &type); + inline Result(int scriptIndex); + + inline bool isValid() const; + + QQmlType type; + const QQmlImportRef *importNamespace; + int scriptIndex; + }; + + enum class QueryNamespaced { No, Yes }; + + // Restrict the types allowed for key. We don't want QV4::ScopedString, for example. + + template<QQmlImport::RecursionRestriction recursionRestriction = QQmlImport::PreventRecursion> + Result query(const QHashedStringRef &key, QQmlTypeLoader *typeLoader) const + { + return doQuery<const QHashedStringRef &, recursionRestriction>(key, typeLoader); + } + + template<QueryNamespaced queryNamespaced = QueryNamespaced::Yes> + Result query(const QHashedStringRef &key, const QQmlImportRef *importNamespace, + QQmlTypeLoader *typeLoader) const + { + return doQuery<const QHashedStringRef &, queryNamespaced>(key, importNamespace, typeLoader); + } + + template<QQmlImport::RecursionRestriction recursionRestriction = QQmlImport::PreventRecursion> + Result query(const QV4::String *key, QQmlTypeLoader *typeLoader) const + { + return doQuery<const QV4::String *, recursionRestriction>(key, typeLoader); + } + + template<QueryNamespaced queryNamespaced = QueryNamespaced::Yes> + Result query(const QV4::String *key, const QQmlImportRef *importNamespace, + QQmlTypeLoader *typeLoader) const + { + return doQuery<const QV4::String *, queryNamespaced>(key, importNamespace, typeLoader); + } + +private: + friend class QQmlImports; + + static QHashedStringRef toHashedStringRef(const QHashedStringRef &key) { return key; } + static QHashedStringRef toHashedStringRef(const QV4::String *key) + { + const QV4::Heap::String *heapString = key->d(); + + // toQString() would also do simplifyString(). Therefore, we can be sure that this + // is safe. Any other operation on the string data cannot keep references on the + // non-simplified pieces. + if (heapString->subtype >= QV4::Heap::String::StringType_Complex) + heapString->simplifyString(); + + // This is safe because the string data is backed by the QV4::String we got as + // parameter. The contract about passing V4 values as parameters is that you have to + // scope them first, so that they don't get gc'd while the callee is working on them. + const QStringPrivate &text = heapString->text(); + return QHashedStringRef(QStringView(text.ptr, text.size)); + } + + static QString toQString(const QHashedStringRef &key) { return key.toString(); } + static QString toQString(const QV4::String *key) { return key->toQStringNoThrow(); } + + template<typename Key, QQmlImport::RecursionRestriction recursionRestriction> + Result doQuery(Key name, QQmlTypeLoader *typeLoader) const + { + Result result = doQuery(m_namedImports, name); + + if (!result.isValid()) + result = typeSearch(m_anonymousImports, name); + + if (!result.isValid()) + result = doQuery(m_anonymousCompositeSingletons, name); + + if (!result.isValid()) { + // Look up anonymous types from the imports of this document + // ### it would be nice if QQmlImports allowed us to resolve a namespace + // first, and then types on it. + QQmlImportNamespace *typeNamespace = nullptr; + QList<QQmlError> errors; + QQmlType t; + bool typeRecursionDetected = false; + const bool typeFound = m_imports->resolveType( + typeLoader, toHashedStringRef(name), &t, nullptr, &typeNamespace, &errors, + QQmlType::AnyRegistrationType, + recursionRestriction == QQmlImport::AllowRecursion + ? &typeRecursionDetected + : nullptr); + if (typeFound) + return Result(t); + + } + + return result; + } + + template<typename Key, QueryNamespaced queryNamespaced> + Result doQuery(Key name, const QQmlImportRef *importNamespace, QQmlTypeLoader *typeLoader) const + { + Q_ASSERT(importNamespace && importNamespace->scriptIndex == -1); + + if constexpr (queryNamespaced == QueryNamespaced::Yes) { + QMap<const QQmlImportRef *, QStringHash<QQmlImportRef> >::const_iterator it + = m_namespacedImports.constFind(importNamespace); + if (it != m_namespacedImports.constEnd()) { + Result r = doQuery(*it, name); + if (r.isValid()) + return r; + } + } + + Result result = typeSearch(importNamespace->modules, name); + + if (!result.isValid()) + result = doQuery(importNamespace->compositeSingletons, name); + + if (!result.isValid()) { + // Look up types from the imports of this document + // ### it would be nice if QQmlImports allowed us to resolve a namespace + // first, and then types on it. + const QString qualifiedTypeName = importNamespace->m_qualifier + u'.' + toQString(name); + QQmlImportNamespace *typeNamespace = nullptr; + QList<QQmlError> errors; + QQmlType t; + bool typeFound = m_imports->resolveType( + typeLoader, qualifiedTypeName, &t, nullptr, &typeNamespace, &errors); + if (typeFound) + return Result(t); + } + + return result; + } + + template<typename Key> + Result doQuery(const QStringHash<QQmlImportRef> &imports, Key key) const + { + QQmlImportRef *i = imports.value(key); + if (i) { + Q_ASSERT(!i->m_qualifier.isEmpty()); + if (i->scriptIndex != -1) { + return Result(i->scriptIndex); + } else { + return Result(i); + } + } + + return Result(); + } + + template<typename Key> + Result doQuery(const QStringHash<QUrl> &urls, Key key) const + { + QUrl *url = urls.value(key); + if (url) { + QQmlType type = QQmlMetaType::qmlType(*url); + return Result(type); + } + + return Result(); + } + + template<typename Key> + Result typeSearch(const QVector<QQmlTypeModuleVersion> &modules, Key key) const + { + QVector<QQmlTypeModuleVersion>::const_iterator end = modules.constEnd(); + for (QVector<QQmlTypeModuleVersion>::const_iterator it = modules.constBegin(); it != end; ++it) { + QQmlType type = it->type(key); + if (type.isValid()) + return Result(type); + } + + return Result(); + } + + QStringHash<QQmlImportRef> m_namedImports; + QMap<const QQmlImportRef *, QStringHash<QQmlImportRef> > m_namespacedImports; + QVector<QQmlTypeModuleVersion> m_anonymousImports; + QStringHash<QUrl> m_anonymousCompositeSingletons; + QQmlRefPointer<QQmlImports> m_imports; +}; + +QQmlTypeNameCache::Result::Result() +: importNamespace(nullptr), scriptIndex(-1) +{ +} + +QQmlTypeNameCache::Result::Result(const QQmlImportRef *importNamespace) +: importNamespace(importNamespace), scriptIndex(-1) +{ +} + +QQmlTypeNameCache::Result::Result(const QQmlType &type) +: type(type), importNamespace(nullptr), scriptIndex(-1) +{ +} + +QQmlTypeNameCache::Result::Result(int scriptIndex) +: importNamespace(nullptr), scriptIndex(scriptIndex) +{ +} + +bool QQmlTypeNameCache::Result::isValid() const +{ + return type.isValid() || importNamespace || scriptIndex != -1; +} + +bool QQmlTypeNameCache::isEmpty() const +{ + return m_namedImports.isEmpty() && m_anonymousImports.isEmpty() + && m_anonymousCompositeSingletons.isEmpty(); +} + +QT_END_NAMESPACE + +#endif // QQMLTYPENAMECACHE_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypewrapper_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypewrapper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..381637aaf5baff5f2e88f513816a7a9db423a949 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmltypewrapper_p.h @@ -0,0 +1,175 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV8TYPEWRAPPER_P_H +#define QV8TYPEWRAPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtCore/qpointer.h> + +#include <private/qv4value_p.h> +#include <private/qv4functionobject_p.h> +#include <private/qv4qmetaobjectwrapper_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlTypeNameCache; +class QQmlType; +class QQmlTypePrivate; +struct QQmlImportRef; + +namespace QV4 { + +namespace Heap { + +struct QQmlTypeWrapper : FunctionObject { + + enum TypeNameMode : quint8 { + ExcludeEnums = 0x0, + IncludeEnums = 0x1, + TypeNameModeMask = 0x1, + }; + + enum Kind : quint8 { + Type = 0x0, + Namespace = 0x2, + KindMask = 0x2 + }; + + void init(TypeNameMode m, QObject *o, const QQmlTypePrivate *type); + void init(TypeNameMode m, QObject *o, QQmlTypeNameCache *type, const QQmlImportRef *import); + + void destroy(); + + const QMetaObject *metaObject() const { return type().metaObject(); } + QMetaType metaType() const { return type().typeId(); } + + QQmlType type() const; + TypeNameMode typeNameMode() const { return TypeNameMode(flags & TypeNameModeMask); } + Kind kind() const { return Kind(flags & KindMask); } + + const QQmlPropertyData *ensureConstructorsCache( + const QMetaObject *metaObject, QMetaType metaType) + { + Q_ASSERT(kind() == Type); + if (!t.constructors && metaObject) { + t.constructors = QMetaObjectWrapper::createConstructors(metaObject, metaType); + warnIfUncreatable(); + } + return t.constructors; + } + void warnIfUncreatable() const; + + QQmlTypeNameCache::Result queryNamespace( + const QV4::String *name, QQmlEnginePrivate *enginePrivate) const; + + QV4QPointer<QObject> object; + + union { + struct { + const QQmlTypePrivate *typePrivate; + const QQmlPropertyData *constructors; + } t; + struct { + QQmlTypeNameCache *typeNamespace; + const QQmlImportRef *importNamespace; + } n; + }; + + quint8 flags; +}; + +using QQmlTypeConstructor = QQmlTypeWrapper; + +struct QQmlScopedEnumWrapper : Object { + void init() { Object::init(); } + void destroy(); + int scopeEnumIndex; + const QQmlTypePrivate *typePrivate; + QQmlType type() const; +}; + +} + +struct Q_QML_EXPORT QQmlTypeWrapper : FunctionObject +{ + V4_OBJECT2(QQmlTypeWrapper, FunctionObject) + V4_PROTOTYPE(typeWrapperPrototype) + V4_NEEDS_DESTROY + + bool isSingleton() const; + const QMetaObject *metaObject() const; + QObject *object() const; + QObject *singletonObject() const; + + QVariant toVariant() const; + + static void initProto(ExecutionEngine *v4); + + static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlType &, + Heap::QQmlTypeWrapper::TypeNameMode = Heap::QQmlTypeWrapper::IncludeEnums); + static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlRefPointer<QQmlTypeNameCache> &, const QQmlImportRef *, + Heap::QQmlTypeWrapper::TypeNameMode = Heap::QQmlTypeWrapper::IncludeEnums); + + static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup); + static bool virtualResolveLookupSetter(Object *object, ExecutionEngine *engine, Lookup *lookup, const Value &value); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); + static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a); + + static ReturnedValue lookupSingletonProperty(Lookup *l, ExecutionEngine *engine, const Value &base); + static ReturnedValue lookupSingletonMethod(Lookup *l, ExecutionEngine *engine, const Value &base); + static ReturnedValue lookupEnumValue(Lookup *l, ExecutionEngine *engine, const Value &base); + static ReturnedValue lookupScopedEnum(Lookup *l, ExecutionEngine *engine, const Value &base); + +protected: + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p); + static bool virtualIsEqualTo(Managed *that, Managed *o); + static ReturnedValue virtualInstanceOf(const Object *typeObject, const Value &var); + +private: + static ReturnedValue method_hasInstance( + const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toString( + const FunctionObject *b, const Value *thisObject, const Value *, int); +}; + +struct QQmlTypeConstructor : QQmlTypeWrapper +{ + V4_OBJECT2(QQmlTypeConstructor, QQmlTypeWrapper) + + static ReturnedValue virtualCallAsConstructor( + const FunctionObject *f, const Value *argv, int argc, const Value *) + { + Q_ASSERT(f->as<QQmlTypeWrapper>()); + return QMetaObjectWrapper::construct( + static_cast<const QQmlTypeWrapper *>(f)->d(), argv, argc); + } +}; + +struct Q_QML_EXPORT QQmlScopedEnumWrapper : Object +{ + V4_OBJECT2(QQmlScopedEnumWrapper, Object) + V4_NEEDS_DESTROY + + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); +}; + +} + +QT_END_NAMESPACE + +#endif // QV8TYPEWRAPPER_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvaluetype_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvaluetype_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5006faf8bbbef3ea81b640554fdb07852698cc8a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvaluetype_p.h @@ -0,0 +1,412 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLVALUETYPE_P_H +#define QQMLVALUETYPE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qqmlproperty_p.h> + +#include <private/qqmlnullablevalue_p.h> +#include <private/qmetatype_p.h> +#include <private/qv4referenceobject_p.h> + +#include <QtCore/qobject.h> +#include <QtCore/qrect.h> +#if QT_CONFIG(easingcurve) +#include <QtCore/qeasingcurve.h> +#endif +#include <QtCore/qvariant.h> + +QT_BEGIN_NAMESPACE + +class Q_QML_EXPORT QQmlValueType : public QDynamicMetaObjectData +{ +public: + QQmlValueType() = default; + QQmlValueType(QMetaType type, const QMetaObject *staticMetaObject) + : m_metaType(type), m_staticMetaObject(staticMetaObject) + {} + ~QQmlValueType(); + + void *create() const { return m_metaType.create(); } + void destroy(void *gadgetPtr) const { m_metaType.destroy(gadgetPtr); } + + void construct(void *gadgetPtr, const void *copy) const { m_metaType.construct(gadgetPtr, copy); } + void destruct(void *gadgetPtr) const { m_metaType.destruct(gadgetPtr); } + + QMetaType metaType() const { return m_metaType; } + const QMetaObject *staticMetaObject() const { return m_staticMetaObject; } + + // ---- dynamic meta object data interface + QMetaObject *toDynamicMetaObject(QObject *) override; + void objectDestroyed(QObject *) override; + int metaCall(QObject *obj, QMetaObject::Call type, int _id, void **argv) override; + // ---- + +private: + QMetaType m_metaType; + const QMetaObject *m_staticMetaObject = nullptr; + QMetaObject *m_dynamicMetaObject = nullptr; +}; + +class Q_QML_EXPORT QQmlGadgetPtrWrapper : public QObject +{ + Q_OBJECT +public: + static QQmlGadgetPtrWrapper *instance(QQmlEngine *engine, QMetaType type); + + QQmlGadgetPtrWrapper(QQmlValueType *valueType, QObject *parent = nullptr); + ~QQmlGadgetPtrWrapper(); + + void read(QObject *obj, int idx); + void write(QObject *obj, int idx, QQmlPropertyData::WriteFlags flags, + int internalIndex = QV4::ReferenceObject::AllProperties) const; + QVariant value() const; + void setValue(const QVariant &value); + + QMetaType metaType() const { return valueType()->metaType(); } + int metaCall(QMetaObject::Call type, int id, void **argv); + + QMetaProperty property(int index) const + { + return valueType()->staticMetaObject()->property(index); + } + + QVariant readOnGadget(const QMetaProperty &property) const + { + return property.readOnGadget(m_gadgetPtr); + } + + void writeOnGadget(const QMetaProperty &property, const QVariant &value) + { + property.writeOnGadget(m_gadgetPtr, value); + } + + void writeOnGadget(const QMetaProperty &property, QVariant &&value) + { + property.writeOnGadget(m_gadgetPtr, std::move(value)); + } + +private: + const QQmlValueType *valueType() const; + void *m_gadgetPtr = nullptr; +}; + +struct Q_QML_EXPORT QQmlPointFValueType +{ + QPointF v; + Q_PROPERTY(qreal x READ x WRITE setX FINAL) + Q_PROPERTY(qreal y READ y WRITE setY FINAL) + Q_GADGET + QML_VALUE_TYPE(point) + QML_FOREIGN(QPointF) + QML_EXTENDED(QQmlPointFValueType) + QML_STRUCTURED_VALUE + +public: + Q_INVOKABLE QQmlPointFValueType() = default; + Q_INVOKABLE QQmlPointFValueType(const QPoint &point) : v(point) {} + Q_INVOKABLE QString toString() const; + qreal x() const; + qreal y() const; + void setX(qreal); + void setY(qreal); + + operator QPointF() const { return v; } +}; + +struct Q_QML_EXPORT QQmlPointValueType +{ + QPoint v; + Q_PROPERTY(int x READ x WRITE setX FINAL) + Q_PROPERTY(int y READ y WRITE setY FINAL) + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QPoint) + QML_EXTENDED(QQmlPointValueType) + QML_STRUCTURED_VALUE + +public: + QQmlPointValueType() = default; + Q_INVOKABLE QQmlPointValueType(const QPointF &point) : v(point.toPoint()) {} + Q_INVOKABLE QString toString() const; + int x() const; + int y() const; + void setX(int); + void setY(int); + + operator QPoint() const { return v; } +}; + +struct Q_QML_EXPORT QQmlSizeFValueType +{ + QSizeF v; + Q_PROPERTY(qreal width READ width WRITE setWidth FINAL) + Q_PROPERTY(qreal height READ height WRITE setHeight FINAL) + Q_GADGET + QML_VALUE_TYPE(size) + QML_FOREIGN(QSizeF) + QML_EXTENDED(QQmlSizeFValueType) + QML_STRUCTURED_VALUE + +public: + Q_INVOKABLE QQmlSizeFValueType() = default; + Q_INVOKABLE QQmlSizeFValueType(const QSize &size) : v(size) {} + Q_INVOKABLE QString toString() const; + qreal width() const; + qreal height() const; + void setWidth(qreal); + void setHeight(qreal); + + operator QSizeF() const { return v; } +}; + +struct Q_QML_EXPORT QQmlSizeValueType +{ + QSize v; + Q_PROPERTY(int width READ width WRITE setWidth FINAL) + Q_PROPERTY(int height READ height WRITE setHeight FINAL) + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QSize) + QML_EXTENDED(QQmlSizeValueType) + QML_STRUCTURED_VALUE + +public: + QQmlSizeValueType() = default; + Q_INVOKABLE QQmlSizeValueType(const QSizeF &size) : v(size.toSize()) {} + Q_INVOKABLE QString toString() const; + int width() const; + int height() const; + void setWidth(int); + void setHeight(int); + + operator QSize() const { return v; } +}; + +struct Q_QML_EXPORT QQmlRectFValueType +{ + QRectF v; + Q_PROPERTY(qreal x READ x WRITE setX FINAL) + Q_PROPERTY(qreal y READ y WRITE setY FINAL) + Q_PROPERTY(qreal width READ width WRITE setWidth FINAL) + Q_PROPERTY(qreal height READ height WRITE setHeight FINAL) + Q_PROPERTY(qreal left READ left DESIGNABLE false FINAL) + Q_PROPERTY(qreal right READ right DESIGNABLE false FINAL) + Q_PROPERTY(qreal top READ top DESIGNABLE false FINAL) + Q_PROPERTY(qreal bottom READ bottom DESIGNABLE false FINAL) + Q_GADGET + QML_VALUE_TYPE(rect) + QML_FOREIGN(QRectF) + QML_EXTENDED(QQmlRectFValueType) + QML_STRUCTURED_VALUE + +public: + Q_INVOKABLE QQmlRectFValueType() = default; + Q_INVOKABLE QQmlRectFValueType(const QRect &rect) : v(rect) {} + Q_INVOKABLE QString toString() const; + qreal x() const; + qreal y() const; + void setX(qreal); + void setY(qreal); + + qreal width() const; + qreal height() const; + void setWidth(qreal); + void setHeight(qreal); + + qreal left() const; + qreal right() const; + qreal top() const; + qreal bottom() const; + + operator QRectF() const { return v; } +}; + +struct Q_QML_EXPORT QQmlRectValueType +{ + QRect v; + Q_PROPERTY(int x READ x WRITE setX FINAL) + Q_PROPERTY(int y READ y WRITE setY FINAL) + Q_PROPERTY(int width READ width WRITE setWidth FINAL) + Q_PROPERTY(int height READ height WRITE setHeight FINAL) + Q_PROPERTY(int left READ left DESIGNABLE false FINAL) + Q_PROPERTY(int right READ right DESIGNABLE false FINAL) + Q_PROPERTY(int top READ top DESIGNABLE false FINAL) + Q_PROPERTY(int bottom READ bottom DESIGNABLE false FINAL) + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QRect) + QML_EXTENDED(QQmlRectValueType) + QML_STRUCTURED_VALUE + +public: + QQmlRectValueType() = default; + Q_INVOKABLE QQmlRectValueType(const QRectF &rect) : v(rect.toRect()) {} + Q_INVOKABLE QString toString() const; + int x() const; + int y() const; + void setX(int); + void setY(int); + + int width() const; + int height() const; + void setWidth(int); + void setHeight(int); + + int left() const; + int right() const; + int top() const; + int bottom() const; + + operator QRect() const { return v; } +}; + +struct Q_QML_EXPORT QQmlMarginsFValueType +{ + QMarginsF m; + Q_PROPERTY(qreal left READ left WRITE setLeft FINAL) + Q_PROPERTY(qreal right READ right WRITE setRight FINAL) + Q_PROPERTY(qreal top READ top WRITE setTop FINAL) + Q_PROPERTY(qreal bottom READ bottom WRITE setBottom FINAL) + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QMarginsF) + QML_EXTENDED(QQmlMarginsFValueType) + QML_STRUCTURED_VALUE + +public: + QQmlMarginsFValueType() = default; + Q_INVOKABLE QQmlMarginsFValueType(const QMargins &margins) : m(margins) {} + Q_INVOKABLE QString toString() const; + qreal left() const; + qreal right() const; + qreal top() const; + qreal bottom() const; + void setLeft(qreal); + void setRight(qreal); + void setTop(qreal); + void setBottom(qreal); + + operator QMarginsF() const { return m; } +}; + +struct Q_QML_EXPORT QQmlMarginsValueType +{ + QMargins m; + Q_PROPERTY(int left READ left WRITE setLeft FINAL) + Q_PROPERTY(int right READ right WRITE setRight FINAL) + Q_PROPERTY(int top READ top WRITE setTop FINAL) + Q_PROPERTY(int bottom READ bottom WRITE setBottom FINAL) + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QMargins) + QML_EXTENDED(QQmlMarginsValueType) + QML_STRUCTURED_VALUE + +public: + QQmlMarginsValueType() = default; + Q_INVOKABLE QQmlMarginsValueType(const QMarginsF &margins) : m(margins.toMargins()) {} + Q_INVOKABLE QString toString() const; + int left() const; + int right() const; + int top() const; + int bottom() const; + void setLeft(int); + void setRight(int); + void setTop(int); + void setBottom(int); + + operator QMargins() const { return m; } +}; + +#if QT_CONFIG(easingcurve) +namespace QQmlEasingEnums +{ +Q_NAMESPACE_EXPORT(Q_QML_EXPORT) +QML_NAMED_ELEMENT(Easing) + +enum Type { + Linear = QEasingCurve::Linear, + InQuad = QEasingCurve::InQuad, OutQuad = QEasingCurve::OutQuad, + InOutQuad = QEasingCurve::InOutQuad, OutInQuad = QEasingCurve::OutInQuad, + InCubic = QEasingCurve::InCubic, OutCubic = QEasingCurve::OutCubic, + InOutCubic = QEasingCurve::InOutCubic, OutInCubic = QEasingCurve::OutInCubic, + InQuart = QEasingCurve::InQuart, OutQuart = QEasingCurve::OutQuart, + InOutQuart = QEasingCurve::InOutQuart, OutInQuart = QEasingCurve::OutInQuart, + InQuint = QEasingCurve::InQuint, OutQuint = QEasingCurve::OutQuint, + InOutQuint = QEasingCurve::InOutQuint, OutInQuint = QEasingCurve::OutInQuint, + InSine = QEasingCurve::InSine, OutSine = QEasingCurve::OutSine, + InOutSine = QEasingCurve::InOutSine, OutInSine = QEasingCurve::OutInSine, + InExpo = QEasingCurve::InExpo, OutExpo = QEasingCurve::OutExpo, + InOutExpo = QEasingCurve::InOutExpo, OutInExpo = QEasingCurve::OutInExpo, + InCirc = QEasingCurve::InCirc, OutCirc = QEasingCurve::OutCirc, + InOutCirc = QEasingCurve::InOutCirc, OutInCirc = QEasingCurve::OutInCirc, + InElastic = QEasingCurve::InElastic, OutElastic = QEasingCurve::OutElastic, + InOutElastic = QEasingCurve::InOutElastic, OutInElastic = QEasingCurve::OutInElastic, + InBack = QEasingCurve::InBack, OutBack = QEasingCurve::OutBack, + InOutBack = QEasingCurve::InOutBack, OutInBack = QEasingCurve::OutInBack, + InBounce = QEasingCurve::InBounce, OutBounce = QEasingCurve::OutBounce, + InOutBounce = QEasingCurve::InOutBounce, OutInBounce = QEasingCurve::OutInBounce, + InCurve = QEasingCurve::InCurve, OutCurve = QEasingCurve::OutCurve, + SineCurve = QEasingCurve::SineCurve, CosineCurve = QEasingCurve::CosineCurve, + BezierSpline = QEasingCurve::BezierSpline, + + Bezier = BezierSpline // Evil! Don't use this! +}; +Q_ENUM_NS(Type) +}; + +struct Q_QML_EXPORT QQmlEasingValueType +{ + QEasingCurve v; + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QEasingCurve) + QML_EXTENDED(QQmlEasingValueType) + QML_STRUCTURED_VALUE + + Q_PROPERTY(QQmlEasingEnums::Type type READ type WRITE setType FINAL) + Q_PROPERTY(qreal amplitude READ amplitude WRITE setAmplitude FINAL) + Q_PROPERTY(qreal overshoot READ overshoot WRITE setOvershoot FINAL) + Q_PROPERTY(qreal period READ period WRITE setPeriod FINAL) + Q_PROPERTY(QVariantList bezierCurve READ bezierCurve WRITE setBezierCurve FINAL) + +public: + QQmlEasingEnums::Type type() const; + qreal amplitude() const; + qreal overshoot() const; + qreal period() const; + void setType(QQmlEasingEnums::Type); + void setAmplitude(qreal); + void setOvershoot(qreal); + void setPeriod(qreal); + void setBezierCurve(const QVariantList &); + QVariantList bezierCurve() const; + + operator QEasingCurve() const { return v; } +}; +#endif + +struct QQmlV4ExecutionEnginePtrForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_FOREIGN(QQmlV4ExecutionEnginePtr) + QML_EXTENDED(QQmlV4ExecutionEnginePtrForeign) +}; + +QT_END_NAMESPACE + +#endif // QQMLVALUETYPE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvaluetypeproxybinding_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvaluetypeproxybinding_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a33e02d31043e221e322f34f5c09c43bd9beaf8d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvaluetypeproxybinding_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLVALUETYPEPROXYBINDING_P_H +#define QQMLVALUETYPEPROXYBINDING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlabstractbinding_p.h> + +QT_BEGIN_NAMESPACE + +class Q_AUTOTEST_EXPORT QQmlValueTypeProxyBinding : public QQmlAbstractBinding +{ +public: + QQmlValueTypeProxyBinding(QObject *o, QQmlPropertyIndex coreIndex); + + QQmlAbstractBinding *subBindings() const; + QQmlAbstractBinding *binding(QQmlPropertyIndex targetPropertyIndex) const; + void removeBindings(quint32 mask); + + void setEnabled(bool, QQmlPropertyData::WriteFlags) override; + Kind kind() const final { return QQmlAbstractBinding::ValueTypeProxy; } + +protected: + ~QQmlValueTypeProxyBinding(); + +private: + friend class QQmlAbstractBinding; + Ptr m_bindings; +}; + +QT_END_NAMESPACE + +#endif // QQMLVALUETYPEPROXYBINDING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvaluetypewrapper_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvaluetypewrapper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..efe9cc4cbbffa6a990e2b5ad9b7aa2733dff5b39 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvaluetypewrapper_p.h @@ -0,0 +1,159 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLVALUETYPEWRAPPER_P_H +#define QQMLVALUETYPEWRAPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <private/qtqmlglobal_p.h> + +#include <private/qv4referenceobject_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlValueType; + +namespace QV4 { + +namespace Heap { + +#define QQmlValueTypeWrapperMembers(class, Member) + +DECLARE_HEAP_OBJECT(QQmlValueTypeWrapper, ReferenceObject) { + DECLARE_MARKOBJECTS(QQmlValueTypeWrapper); + + void init( + const void *data, QMetaType metaType, const QMetaObject *metaObject, + Object *object, int property, Flags flags) + { + ReferenceObject::init(object, property, flags); + setMetaType(metaType); + setMetaObject(metaObject); + if (data) + setData(data); + } + + QQmlValueTypeWrapper *detached() const; + + void destroy(); + + QMetaType metaType() const + { + Q_ASSERT(m_metaType != nullptr); + return QMetaType(m_metaType); + } + + void setGadgetPtr(void *gadgetPtr) { m_gadgetPtr = gadgetPtr; } + void *gadgetPtr() const { return m_gadgetPtr; } + + const QMetaObject *metaObject() const { return m_metaObject; } + + void setData(const void *data) + { + const QMetaType type = metaType(); + void *gadget = gadgetPtr(); + if (gadget) { + type.destruct(gadget); + } else { + gadget = ::operator new(type.sizeOf()); + setGadgetPtr(gadget); + } + type.construct(gadget, data); + } + + QVariant toVariant() const; + + void *storagePointer(); + bool setVariant(const QVariant &variant); + + bool readReference(); + bool writeBack(int propertyIndex = QV4::ReferenceObject::AllProperties); + +private: + void setMetaObject(const QMetaObject *metaObject) { m_metaObject = metaObject; } + void setMetaType(QMetaType metaType) + { + Q_ASSERT(metaType.isValid()); + m_metaType = metaType.iface(); + } + + void *m_gadgetPtr; + const QtPrivate::QMetaTypeInterface *m_metaType; + const QMetaObject *m_metaObject; +}; + +} + +struct Q_QML_EXPORT QQmlValueTypeWrapper : public ReferenceObject +{ + V4_OBJECT2(QQmlValueTypeWrapper, ReferenceObject) + V4_PROTOTYPE(valueTypeWrapperPrototype) + V4_NEEDS_DESTROY + +public: + + static ReturnedValue create( + ExecutionEngine *engine, const void *data, const QMetaObject *metaObject, + QMetaType type, Heap::Object *object, int property, Heap::ReferenceObject::Flags flags); + static ReturnedValue create( + ExecutionEngine *engine, Heap::QQmlValueTypeWrapper *cloneFrom, Heap::Object *object); + static ReturnedValue create( + ExecutionEngine *engine, const void *, const QMetaObject *metaObject, QMetaType type); + + QVariant toVariant() const; + + template<typename ValueType> + ValueType *cast() + { + if (QMetaType::fromType<ValueType>() != d()->metaType()) + return nullptr; + if (d()->isReference() && !readReferenceValue()) + return nullptr; + return static_cast<ValueType *>(d()->gadgetPtr()); + } + + bool toGadget(void *data) const; + bool isEqual(const QVariant& value) const; + int typeId() const; + QMetaType type() const; + bool write(QObject *target, int propertyIndex) const; + bool readReferenceValue() const { return d()->readReference(); } + const QMetaObject *metaObject() const { return d()->metaObject(); } + + QQmlPropertyData dataForPropertyKey(PropertyKey id) const; + + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static bool virtualIsEqualTo(Managed *m, Managed *other); + static bool virtualHasProperty(const Managed *m, PropertyKey id); + static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); + static ReturnedValue method_toString(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup); + static bool virtualResolveLookupSetter(Object *object, ExecutionEngine *engine, Lookup *lookup, const Value &value); + static ReturnedValue lookupGetter(Lookup *lookup, ExecutionEngine *engine, const Value &object); + static bool lookupSetter(QV4::Lookup *l, QV4::ExecutionEngine *engine, + QV4::Value &object, const QV4::Value &value); + + static void initProto(ExecutionEngine *v4); + static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a); +}; + +} + +QT_END_NAMESPACE + +#endif // QV8VALUETYPEWRAPPER_P_H + + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvme_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvme_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a40268b92c4e20098b8ca1070ac95e083c8bcdb5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvme_p.h @@ -0,0 +1,117 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLVME_P_H +#define QQMLVME_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qrecursionwatcher_p.h> + +#include <QtCore/QStack> +#include <QtCore/QString> +#include <QtCore/qelapsedtimer.h> +#include <QtCore/qdeadlinetimer.h> +#include <QtCore/qcoreapplication.h> +#include <QtCore/qtypeinfo.h> + +#include <private/qqmlengine_p.h> +#include <private/qfinitestack_p.h> + +#include <atomic> + +QT_BEGIN_NAMESPACE + +class QObject; + +class QQmlInstantiationInterrupt { +public: + inline QQmlInstantiationInterrupt(); + inline QQmlInstantiationInterrupt(std::atomic<bool> *runWhile, + QDeadlineTimer deadline = QDeadlineTimer::Forever); + inline QQmlInstantiationInterrupt(QDeadlineTimer deadline); + + inline bool shouldInterrupt() const; +private: + enum Mode { None, Time, Flag }; + Mode mode; + QDeadlineTimer deadline; + std::atomic<bool> *runWhile = nullptr; +}; + +class Q_QML_EXPORT QQmlVME +{ +public: + static void enableComponentComplete(); + static void disableComponentComplete(); + static bool componentCompleteEnabled(); + +private: + static bool s_enableComponentComplete; +}; + +// Used to check that a QQmlVME that is interrupted mid-execution +// is still valid. Checks all the objects and contexts have not been +// deleted. +// +// VME stands for Virtual Machine Execution. QML files used to +// be compiled to a byte code data structure that a virtual machine executed +// (for constructing the tree of QObjects and setting properties). +class QQmlVMEGuard +{ +public: + QQmlVMEGuard(); + ~QQmlVMEGuard(); + + void guard(QQmlObjectCreator *); + void clear(); + + bool isOK() const; + +private: + int m_objectCount; + QQmlGuard<QObject> *m_objects; + int m_contextCount; + QQmlGuardedContextData *m_contexts; +}; + +QQmlInstantiationInterrupt::QQmlInstantiationInterrupt() + : mode(None) +{ +} + +QQmlInstantiationInterrupt::QQmlInstantiationInterrupt(std::atomic<bool> *runWhile, QDeadlineTimer deadline) + : mode(Flag), deadline(deadline), runWhile(runWhile) +{ +} + +QQmlInstantiationInterrupt::QQmlInstantiationInterrupt(QDeadlineTimer deadline) + : mode(Time), deadline(deadline) +{ +} + +bool QQmlInstantiationInterrupt::shouldInterrupt() const +{ + switch (mode) { + case None: + return false; + case Time: + return deadline.hasExpired(); + case Flag: + return !runWhile->load(std::memory_order_acquire) || deadline.hasExpired(); + } + Q_UNREACHABLE_RETURN(false); +} + +QT_END_NAMESPACE + +#endif // QQMLVME_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvmemetaobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvmemetaobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3c6dc7fef65bb458f9cf83c9c311c3a013e2e367 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlvmemetaobject_p.h @@ -0,0 +1,328 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 BasysKom GmbH. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLVMEMETAOBJECT_P_H +#define QQMLVMEMETAOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qbipointer_p.h> +#include <private/qqmlguard_p.h> +#include <private/qqmlguardedcontextdata_p.h> +#include <private/qqmlpropertyvalueinterceptor_p.h> +#include <private/qv4object_p.h> +#include <private/qv4value_p.h> + +#include <QtCore/private/qobject_p.h> + +#if QT_CONFIG(regularexpression) +#include <QtCore/qregularexpression.h> +#endif + +#include <QtCore/qbitarray.h> +#include <QtCore/qdatetime.h> +#include <QtCore/qdebug.h> +#include <QtCore/qlist.h> +#include <QtCore/qmetaobject.h> +#include <QtCore/qpair.h> + +QT_BEGIN_NAMESPACE + +class QQmlVMEMetaObject; +class QQmlVMEResolvedList +{ + Q_DISABLE_COPY_MOVE(QQmlVMEResolvedList) + +public: + QQmlVMEResolvedList(QQmlListProperty<QObject> *prop); + ~QQmlVMEResolvedList(); + + QQmlVMEMetaObject *metaObject() const { return m_metaObject; } + QV4::Heap::Object *list() const { return m_list; } + quintptr id() const { return m_id; } + + void append(QObject *o) const; + void replace(qsizetype i, QObject *o) const; + QObject *at(qsizetype i) const; + + qsizetype size() const { return m_list->arrayData->length(); } + + void clear() const + { + QV4::Scope scope(m_list->internalClass->engine); + QV4::ScopedObject object(scope, m_list); + m_list->arrayData->vtable()->truncate(object, 0); + } + + void removeLast() const + { + const uint length = m_list->arrayData->length(); + if (length == 0) + return; + + QV4::Scope scope(m_list->internalClass->engine); + QV4::ScopedObject object(scope, m_list); + m_list->arrayData->vtable()->truncate(object, length - 1); + } + + void activateSignal() const; + +private: + QQmlVMEMetaObject *m_metaObject = nullptr; + QV4::Heap::Object *m_list = nullptr; + quintptr m_id = 0; +}; + +class QQmlVMEVariantQObjectPtr : public QQmlGuard<QObject> +{ +public: + inline QQmlVMEVariantQObjectPtr(); + + inline void setGuardedValue(QObject *obj, QQmlVMEMetaObject *target, int index); + + QQmlVMEMetaObject *m_target; + int m_index; + +private: + static void objectDestroyedImpl(QQmlGuardImpl *guard); +}; + + +class Q_QML_EXPORT QQmlInterceptorMetaObject : public QDynamicMetaObjectData +{ +public: + QQmlInterceptorMetaObject(QObject *obj, const QQmlPropertyCache::ConstPtr &cache); + ~QQmlInterceptorMetaObject() override; + + void registerInterceptor(QQmlPropertyIndex index, QQmlPropertyValueInterceptor *interceptor); + + static QQmlInterceptorMetaObject *get(QObject *obj); + + QMetaObject *toDynamicMetaObject(QObject *o) override; + + // Used by auto-tests for inspection + QQmlPropertyCache::ConstPtr propertyCache() const { return cache; } + + bool intercepts(QQmlPropertyIndex propertyIndex) const + { + for (auto it = interceptors; it; it = it->m_next) { + if (it->m_propertyIndex == propertyIndex) + return true; + } + if (auto parentInterceptor = ((parent.isT1() && parent.flag()) ? static_cast<QQmlInterceptorMetaObject *>(parent.asT1()) : nullptr)) + return parentInterceptor->intercepts(propertyIndex); + return false; + } + + void invalidate() { metaObject.setTag(MetaObjectInvalid); } + + QObject *object = nullptr; + QQmlPropertyCache::ConstPtr cache; + +protected: + int metaCall(QObject *o, QMetaObject::Call c, int id, void **a) override; + bool intercept(QMetaObject::Call c, int id, void **a) + { + if (!interceptors) + return false; + + switch (c) { + case QMetaObject::WriteProperty: + if (*reinterpret_cast<int*>(a[3]) & QQmlPropertyData::BypassInterceptor) + return false; + break; + case QMetaObject::BindableProperty: + break; + default: + return false; + } + + return doIntercept(c, id, a); + } + + QBiPointer<QDynamicMetaObjectData, const QMetaObject> parent; + + enum MetaObjectValidity { MetaObjectValid, MetaObjectInvalid }; + QTaggedPointer<const QMetaObject, MetaObjectValidity> metaObject; + +private: + bool doIntercept(QMetaObject::Call c, int id, void **a); + QQmlPropertyValueInterceptor *interceptors = nullptr; +}; + +inline QQmlInterceptorMetaObject *QQmlInterceptorMetaObject::get(QObject *obj) +{ + if (obj) { + if (QQmlData *data = QQmlData::get(obj)) { + if (data->hasInterceptorMetaObject) + return static_cast<QQmlInterceptorMetaObject *>(QObjectPrivate::get(obj)->metaObject); + } + } + + return nullptr; +} + +class QQmlVMEMetaObjectEndpoint; +class Q_QML_EXPORT QQmlVMEMetaObject : public QQmlInterceptorMetaObject +{ +public: + QQmlVMEMetaObject(QV4::ExecutionEngine *engine, QObject *obj, + const QQmlPropertyCache::ConstPtr &cache, + const QQmlRefPointer<QV4::ExecutableCompilationUnit> &qmlCompilationUnit, + int qmlObjectId); + ~QQmlVMEMetaObject() override; + + bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const; + QV4::ReturnedValue vmeMethod(int index) const; + void setVmeMethod(int index, const QV4::Value &function); + QV4::ReturnedValue vmeProperty(int index) const; + void setVMEProperty(int index, const QV4::Value &v); + + void connectAliasSignal(int index, bool indexInSignalRange); + + static inline QQmlVMEMetaObject *get(QObject *o); + static QQmlVMEMetaObject *getForProperty(QObject *o, int coreIndex); + static QQmlVMEMetaObject *getForMethod(QObject *o, int coreIndex); + static QQmlVMEMetaObject *getForSignal(QObject *o, int coreIndex); + + static void list_append(QQmlListProperty<QObject> *prop, QObject *o); + static void list_clear(QQmlListProperty<QObject> *prop); + static void list_append_nosignal(QQmlListProperty<QObject> *prop, QObject *o); + static void list_clear_nosignal(QQmlListProperty<QObject> *prop); + +protected: + int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override; + +public: + QV4::ExecutionEngine *engine; + QQmlGuardedContextData ctxt; + + inline int propOffset() const; + inline int methodOffset() const; + inline int signalOffset() const; + inline int signalCount() const; + + QQmlVMEMetaObjectEndpoint *aliasEndpoints; + + QV4::WeakValue propertyAndMethodStorage; + QV4::MemberData *propertyAndMethodStorageAsMemberData() const; + + int readPropertyAsInt(int id) const; + bool readPropertyAsBool(int id) const; + double readPropertyAsDouble(int id) const; + QString readPropertyAsString(int id) const; + QSizeF readPropertyAsSizeF(int id) const; + QPointF readPropertyAsPointF(int id) const; + QUrl readPropertyAsUrl(int id) const; + QDate readPropertyAsDate(int id) const; + QTime readPropertyAsTime(int id) const; + QDateTime readPropertyAsDateTime(int id) const; + +#if QT_CONFIG(regularexpression) + QRegularExpression readPropertyAsRegularExpression(int id) const; +#endif + + QRectF readPropertyAsRectF(int id) const; + QObject *readPropertyAsQObject(int id) const; + void initPropertyAsList(int id) const; + + void writeProperty(int id, int v); + void writeProperty(int id, bool v); + void writeProperty(int id, double v); + void writeProperty(int id, const QString& v); + + template<typename VariantCompatible> + void writeProperty(int id, const VariantCompatible &v) + { + QV4::MemberData *md = propertyAndMethodStorageAsMemberData(); + if (md) { + QV4::Scope scope(engine); + QV4::Scoped<QV4::MemberData>(scope, md)->set( + engine, id, engine->newVariantObject( + QMetaType::fromType<VariantCompatible>(), &v)); + } + } + + void writeProperty(int id, QObject *v); + + void ensureQObjectWrapper(); + + void mark(QV4::MarkStack *markStack); + + void connectAlias(int aliasId); + + QV4::ReturnedValue method(int) const; + + QV4::ReturnedValue readVarProperty(int) const; + void writeVarProperty(int, const QV4::Value &); + QVariant readPropertyAsVariant(int) const; + void writeProperty(int, const QVariant &); + + inline QQmlVMEMetaObject *parentVMEMetaObject() const; + + void activate(QObject *, int, void **); + + QList<QQmlVMEVariantQObjectPtr *> varObjectGuards; + + QQmlVMEVariantQObjectPtr *getQObjectGuardForProperty(int) const; + + + // keep a reference to the compilation unit in order to still + // do property access when the context has been invalidated. + QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit; + const QV4::CompiledData::Object *compiledObject; +}; + +QQmlVMEMetaObject *QQmlVMEMetaObject::get(QObject *obj) +{ + if (obj) { + if (QQmlData *data = QQmlData::get(obj)) { + if (data->hasVMEMetaObject) + return static_cast<QQmlVMEMetaObject *>(QObjectPrivate::get(obj)->metaObject); + } + } + + return nullptr; +} + +int QQmlVMEMetaObject::propOffset() const +{ + return cache->propertyOffset(); +} + +int QQmlVMEMetaObject::methodOffset() const +{ + return cache->methodOffset(); +} + +int QQmlVMEMetaObject::signalOffset() const +{ + return cache->signalOffset(); +} + +int QQmlVMEMetaObject::signalCount() const +{ + return cache->signalCount(); +} + +QQmlVMEMetaObject *QQmlVMEMetaObject::parentVMEMetaObject() const +{ + if (parent.isT1() && parent.flag()) + return static_cast<QQmlVMEMetaObject *>(parent.asT1()); + + return nullptr; +} + +QT_END_NAMESPACE + +#endif // QQMLVMEMETAOBJECT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlxmlhttprequest_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlxmlhttprequest_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0b44e4b4cf84c7d7392ce4448069fcbd4b6538cc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qqmlxmlhttprequest_p.h @@ -0,0 +1,32 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLXMLHTTPREQUEST_P_H +#define QQMLXMLHTTPREQUEST_P_H + +#include <QtQml/qjsengine.h> +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <private/qtqmlglobal_p.h> + +QT_REQUIRE_CONFIG(qml_xml_http_request); + +QT_BEGIN_NAMESPACE + +void *qt_add_qmlxmlhttprequest(QV4::ExecutionEngine *engine); +void qt_rem_qmlxmlhttprequest(QV4::ExecutionEngine *engine, void *); + +QT_END_NAMESPACE + +#endif // QQMLXMLHTTPREQUEST_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qrecursionwatcher_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qrecursionwatcher_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a910c66da423ae9eadf5a296c105d52592aa225e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qrecursionwatcher_p.h @@ -0,0 +1,67 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRECURSIONWATCHER_P_H +#define QRECURSIONWATCHER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QRecursionNode; +class QRecursionNode { +public: + inline QRecursionNode(); + bool *_r; +}; + +template<class T, QRecursionNode T::*Node> +class QRecursionWatcher { +public: + inline QRecursionWatcher(T *); + inline ~QRecursionWatcher(); + inline bool hasRecursed() const; +private: + T *_t; + bool _r; +}; + +QRecursionNode::QRecursionNode() +: _r(nullptr) +{ +} + +template<class T, QRecursionNode T::*Node> +QRecursionWatcher<T, Node>::QRecursionWatcher(T *t) +: _t(t), _r(false) +{ + if ((_t->*Node)._r) *(_t->*Node)._r = true; + (_t->*Node)._r = &_r; +} + +template<class T, QRecursionNode T::*Node> +QRecursionWatcher<T, Node>::~QRecursionWatcher() +{ + if ((_t->*Node)._r == &_r) (_t->*Node)._r = nullptr; +} + +template<class T, QRecursionNode T::*Node> +bool QRecursionWatcher<T, Node>::hasRecursed() const +{ + return _r; +} + +QT_END_NAMESPACE + +#endif // QRECURSIONWATCHER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qrecyclepool_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qrecyclepool_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ee1001e2452b5db058f580488c0681cb21c68e54 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qrecyclepool_p.h @@ -0,0 +1,164 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QRECYCLEPOOL_P_H +#define QRECYCLEPOOL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +#include <QtCore/q20memory.h> + +QT_BEGIN_NAMESPACE + +#define QRECYCLEPOOLCOOKIE 0x33218ADF + +template<typename T, int Step> +class QRecyclePoolPrivate +{ +public: + QRecyclePoolPrivate() + : recyclePoolHold(true), outstandingItems(0), cookie(QRECYCLEPOOLCOOKIE), + currentPage(nullptr), nextAllocated(nullptr) + { + } + + bool recyclePoolHold; + int outstandingItems; + quint32 cookie; + + struct PoolType : public T { + union { + QRecyclePoolPrivate<T, Step> *pool; + PoolType *nextAllocated; + }; + }; + + struct Page { + Page *nextPage; + unsigned int free; + union { + char array[Step * sizeof(PoolType)]; + qint64 q_for_alignment_1; + double q_for_alignment_2; + }; + }; + + Page *currentPage; + PoolType *nextAllocated; + + inline T *allocate(); + static inline void dispose(T *); + inline void releaseIfPossible(); +}; + +template<typename T, int Step = 1024> +class QRecyclePool +{ +public: + inline QRecyclePool(); + inline ~QRecyclePool(); + + template<typename...Args> + [[nodiscard]] inline T *New(Args&&...args); + + static inline void Delete(T *); + +private: + QRecyclePoolPrivate<T, Step> *d; +}; + +template<typename T, int Step> +QRecyclePool<T, Step>::QRecyclePool() +: d(new QRecyclePoolPrivate<T, Step>()) +{ +} + +template<typename T, int Step> +QRecyclePool<T, Step>::~QRecyclePool() +{ + d->recyclePoolHold = false; + d->releaseIfPossible(); +} + +template<typename T, int Step> +template<typename...Args> +T *QRecyclePool<T, Step>::New(Args&&...args) +{ + return q20::construct_at(d->allocate(), std::forward<Args>(args)...); +} + +template<typename T, int Step> +void QRecyclePool<T, Step>::Delete(T *t) +{ + t->~T(); + QRecyclePoolPrivate<T, Step>::dispose(t); +} + +template<typename T, int Step> +void QRecyclePoolPrivate<T, Step>::releaseIfPossible() +{ + if (recyclePoolHold || outstandingItems) + return; + + Page *p = currentPage; + while (p) { + Page *n = p->nextPage; + free(p); + p = n; + } + + delete this; +} + +template<typename T, int Step> +T *QRecyclePoolPrivate<T, Step>::allocate() +{ + PoolType *rv = nullptr; + if (nextAllocated) { + rv = nextAllocated; + nextAllocated = rv->nextAllocated; + } else if (currentPage && currentPage->free) { + rv = (PoolType *)(currentPage->array + (Step - currentPage->free) * sizeof(PoolType)); + currentPage->free--; + } else { + Page *p = (Page *)malloc(sizeof(Page)); + p->nextPage = currentPage; + p->free = Step; + currentPage = p; + + rv = (PoolType *)currentPage->array; + currentPage->free--; + } + + rv->pool = this; + ++outstandingItems; + return rv; +} + +template<typename T, int Step> +void QRecyclePoolPrivate<T, Step>::dispose(T *t) +{ + PoolType *pt = static_cast<PoolType *>(t); + Q_ASSERT(pt->pool && pt->pool->cookie == QRECYCLEPOOLCOOKIE); + + QRecyclePoolPrivate<T, Step> *This = pt->pool; + pt->nextAllocated = This->nextAllocated; + This->nextAllocated = pt; + --This->outstandingItems; + This->releaseIfPossible(); +} + +QT_END_NAMESPACE + +#endif // QRECYCLEPOOL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qsequentialanimationgroupjob_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qsequentialanimationgroupjob_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6204623e08f5b05e4bac1b022e6c4f39153bdea7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qsequentialanimationgroupjob_p.h @@ -0,0 +1,79 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSEQUENTIALANIMATIONGROUPJOB_P_H +#define QSEQUENTIALANIMATIONGROUPJOB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qanimationgroupjob_p.h> + +QT_REQUIRE_CONFIG(qml_animation); + +QT_BEGIN_NAMESPACE + +class QPauseAnimationJob; +class Q_QML_EXPORT QSequentialAnimationGroupJob : public QAnimationGroupJob +{ + Q_DISABLE_COPY(QSequentialAnimationGroupJob) +public: + QSequentialAnimationGroupJob(); + ~QSequentialAnimationGroupJob(); + + int duration() const override; + + QAbstractAnimationJob *currentAnimation() const { return m_currentAnimation; } + void clear() override; + +protected: + void updateCurrentTime(int) override; + void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override; + void updateDirection(QAbstractAnimationJob::Direction direction) override; + void uncontrolledAnimationFinished(QAbstractAnimationJob *animation) override; + void debugAnimation(QDebug d) const override; + +private: + struct AnimationIndex + { + AnimationIndex() {} + // AnimationIndex points to the animation at timeOffset, skipping 0 duration animations. + // Note that the index semantic is slightly different depending on the direction. + bool afterCurrent = false; //whether animation is before or after m_currentAnimation //TODO: make enum Before/After/Same + int timeOffset = 0; // time offset when the animation at index starts. + const QAbstractAnimationJob *animation = nullptr; //points to the animation at timeOffset + }; + + int animationActualTotalDuration(const QAbstractAnimationJob *anim) const; + AnimationIndex indexForCurrentTime() const; + + void setCurrentAnimation(const QAbstractAnimationJob *anim, bool intermediate = false); + void activateCurrentAnimation(bool intermediate = false); + + void animationInserted(QAbstractAnimationJob *anim) override; + void animationRemoved(QAbstractAnimationJob *anim, QAbstractAnimationJob *, QAbstractAnimationJob *) override; + + bool atEnd() const; + + void restart(); + + // handle time changes + void rewindForwards(const AnimationIndex &newAnimationIndex); + void advanceForwards(const AnimationIndex &newAnimationIndex); + + //state + QAbstractAnimationJob *m_currentAnimation = nullptr; + int m_previousLoop = 0; +}; + +QT_END_NAMESPACE + +#endif //QSEQUENTIALANIMATIONGROUPJOB_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qstringhash_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qstringhash_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a89ba8832293f33c403eb7b2d9eb1221b3d657e2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qstringhash_p.h @@ -0,0 +1,803 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSTRINGHASH_P_H +#define QSTRINGHASH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qhashedstring_p.h> +#include <private/qprimefornumbits_p.h> + +#include <QtCore/qbytearray.h> +#include <QtCore/qstring.h> +#include <QtCore/qtaggedpointer.h> + +QT_BEGIN_NAMESPACE + +static inline QString::DataPointer &mutableStringData(const QHashedString &key) +{ + return const_cast<QHashedString &>(key).data_ptr(); +} + +class QStringHashData; +class QStringHashNode +{ +public: + QStringHashNode() + { + } + + QStringHashNode(const QHashedString &key) + : length(int(key.size())), hash(key.hash()), symbolId(0) + , arrayData(mutableStringData(key).d_ptr()) + , strData(mutableStringData(key).data()) + { + Q_ASSERT(key.size() <= std::numeric_limits<int>::max()); + if (arrayData) + arrayData->ref(); + setQString(true); + } + + QStringHashNode(const QHashedCStringRef &key) + : length(key.length()), hash(key.hash()), symbolId(0), ckey(key.constData()) + { + } + + QStringHashNode(const QStringHashNode &o) + : length(o.length), hash(o.hash), symbolId(o.symbolId), arrayData(o.arrayData) + { + setQString(o.isQString()); + if (isQString()) { + strData = o.strData; + if (arrayData) + arrayData->ref(); + } else { + ckey = o.ckey; + } + } + + ~QStringHashNode() + { + if (isQString() && arrayData && !arrayData->deref()) + QTypedArrayData<char16_t>::deallocate(arrayData); + } + + enum Tag { + NodeIsCString, + NodeIsQString + }; + + QTaggedPointer<QStringHashNode, Tag> next; + + qint32 length = 0; + quint32 hash = 0; + quint32 symbolId = 0; + + QTypedArrayData<char16_t> *arrayData = nullptr; + union { + const char *ckey = nullptr; + char16_t *strData; + }; + + inline QHashedString key() const + { + if (isQString()) { + if (arrayData) + arrayData->ref(); + return QHashedString(QString(QStringPrivate(arrayData, strData, length)), hash); + } + + return QHashedString(QString::fromLatin1(ckey, length), hash); + } + + bool isQString() const { return next.tag() == NodeIsQString; } + void setQString(bool v) { if (v) next.setTag(NodeIsQString); else next.setTag(NodeIsCString); } + + inline qsizetype size() const { return length; } + inline const char *cStrData() const { return ckey; } + inline const char16_t *utf16Data() const { return strData; } + + inline bool equals(const QV4::Value &string) const { + QString s = string.toQStringNoThrow(); + if (isQString()) { + return QStringView(utf16Data(), length) == s; + } else { + return QLatin1String(cStrData(), length) == s; + } + } + + inline bool equals(const QV4::String *string) const { + if (length != string->d()->length() || hash != string->hashValue()) + return false; + if (isQString()) { + return QStringView(utf16Data(), length) == string->toQString(); + } else { + return QLatin1String(cStrData(), length) == string->toQString(); + } + } + + inline bool equals(const QHashedStringRef &string) const { + return length == string.length() && + hash == string.hash() && + (isQString()? string == QStringView {utf16Data(), length}: + QHashedString::compare(string.constData(), cStrData(), length)); + } + + inline bool equals(const QHashedCStringRef &string) const { + return length == string.length() && + hash == string.hash() && + (isQString()?QHashedString::compare((const QChar *)utf16Data(), string.constData(), length): + QHashedString::compare(string.constData(), cStrData(), length)); + } +}; + +class QStringHashData +{ + Q_DISABLE_COPY_MOVE(QStringHashData) +public: + QStringHashData() = default; + ~QStringHashData() = default; + + /* + A QHash has initially around pow(2, MinNumBits) buckets. For + example, if MinNumBits is 4, it has 17 buckets. + */ + enum { MinNumBits = 4 }; + + QStringHashNode **buckets = nullptr; // life cycle managed by QStringHash + int numBuckets = 0; + int size = 0; + short numBits = 0; + + template<typename StringHash> + struct IteratorData { + IteratorData(QStringHashNode *n = nullptr, StringHash *p = nullptr) : n(n), p(p) {} + + template<typename OtherData> + IteratorData(const OtherData &other) : n(other.n), p(other.p) {} + + QStringHashNode *n; + StringHash *p; + }; + + void rehashToBits(short bits) + { + numBits = qMax(short(MinNumBits), bits); + + int nb = qPrimeForNumBits(numBits); + if (nb == numBuckets && buckets) + return; + + QStringHashNode **newBuckets = new QStringHashNode *[nb]; + ::memset(newBuckets, 0, sizeof(QStringHashNode *) * nb); + + // Preserve the existing order within buckets so that items with the + // same key will retain the same find/findNext order + for (int i = 0; i < numBuckets; ++i) { + QStringHashNode *bucket = buckets[i]; + if (bucket) + rehashNode(newBuckets, nb, bucket); + } + + delete [] buckets; + buckets = newBuckets; + numBuckets = nb; + } + + void rehashToSize(int size) + { + short bits = qMax(short(MinNumBits), numBits); + while (qPrimeForNumBits(bits) < size) + bits++; + + if (bits > numBits) + rehashToBits(bits); + } + + void rehashNode(QStringHashNode **newBuckets, int nb, QStringHashNode *node) + { + QStringHashNode *next = node->next.data(); + if (next) + rehashNode(newBuckets, nb, next); + + int bucket = node->hash % nb; + node->next = newBuckets[bucket]; + newBuckets[bucket] = node; + } +}; + +// For a supplied key type, in what form do we need to keep a hashed version? +template<typename T> +struct HashedForm {}; + +template<> struct HashedForm<QString> { typedef QHashedString Type; }; +template<> struct HashedForm<QStringView> { typedef QHashedStringRef Type; }; +template<> struct HashedForm<QHashedString> { typedef const QHashedString &Type; }; +template<> struct HashedForm<QV4::String *> { typedef const QV4::String *Type; }; +template<> struct HashedForm<const QV4::String *> { typedef const QV4::String *Type; }; +template<> struct HashedForm<QHashedStringRef> { typedef const QHashedStringRef &Type; }; +template<> struct HashedForm<QLatin1String> { typedef QHashedCStringRef Type; }; +template<> struct HashedForm<QHashedCStringRef> { typedef const QHashedCStringRef &Type; }; + +class QStringHashBase +{ +public: + static HashedForm<QString>::Type hashedString(const QString &s) { return QHashedString(s);} + static HashedForm<QStringView>::Type hashedString(QStringView s) + { + Q_ASSERT(s.size() <= std::numeric_limits<int>::max()); + return QHashedStringRef(s.constData(), int(s.size())); + } + static HashedForm<QHashedString>::Type hashedString(const QHashedString &s) { return s; } + static HashedForm<QV4::String *>::Type hashedString(QV4::String *s) { return s; } + static HashedForm<const QV4::String *>::Type hashedString(const QV4::String *s) { return s; } + static HashedForm<QHashedStringRef>::Type hashedString(const QHashedStringRef &s) { return s; } + + static HashedForm<QLatin1StringView>::Type hashedString(QLatin1StringView s) + { + Q_ASSERT(s.size() <= std::numeric_limits<int>::max()); + return QHashedCStringRef(s.data(), int(s.size())); + } + static HashedForm<QHashedCStringRef>::Type hashedString(const QHashedCStringRef &s) { return s; } + + static const QString &toQString(const QString &s) { return s; } + static const QString &toQString(const QHashedString &s) { return s; } + static QString toQString(const QV4::String *s) { return s->toQString(); } + static QString toQString(const QHashedStringRef &s) { return s.toString(); } + + static QString toQString(const QLatin1String &s) { return QString(s); } + static QString toQString(const QHashedCStringRef &s) { return s.toUtf16(); } + + static inline quint32 hashOf(const QHashedStringRef &s) { return s.hash(); } + static inline quint32 hashOf(QV4::String *s) { return s->hashValue(); } + static inline quint32 hashOf(const QV4::String *s) { return s->hashValue(); } + + template<typename K> + static inline quint32 hashOf(const K &key) { return hashedString(key).hash(); } +}; + +template<class T> +class QStringHash : public QStringHashBase +{ +public: + typedef QHashedString key_type; + typedef T mapped_type; + + using MutableIteratorData = QStringHashData::IteratorData<QStringHash<T>>; + using ConstIteratorData = QStringHashData::IteratorData<const QStringHash<T>>; + + struct Node : public QStringHashNode { + Node(const QHashedString &key, const T &value) : QStringHashNode(key), value(value) {} + Node(const QHashedCStringRef &key, const T &value) : QStringHashNode(key), value(value) {} + Node(const Node &o) : QStringHashNode(o), value(o.value) {} + Node() {} + T value; + }; + struct NewedNode : public Node { + NewedNode(const QHashedString &key, const T &value) : Node(key, value), nextNewed(nullptr) {} + NewedNode(const QHashedCStringRef &key, const T &value) : Node(key, value), nextNewed(nullptr) {} + NewedNode(const Node &o) : Node(o), nextNewed(nullptr) {} + NewedNode *nextNewed; + }; + struct ReservedNodePool + { + ReservedNodePool() : nodes(nullptr) {} + ~ReservedNodePool() { delete [] nodes; } + int count = 0; + int used = 0; + Node *nodes; + }; + + QStringHashData data; + NewedNode *newedNodes; + ReservedNodePool *nodePool; + + template<typename K> + inline Node *findNode(const K &) const; + + inline Node *createNode(const Node &o); + + template<typename K> + inline Node *createNode(const K &, const T &); + + inline Node *insertNode(Node *, quint32); + + inline void initializeNode(Node *, const QHashedString &key); + inline void initializeNode(Node *, const QHashedCStringRef &key); + + template<typename K> + inline Node *takeNode(const K &key, const T &value); + + inline Node *takeNode(const Node &o); + + inline void copy(const QStringHash<T> &); + + void copyNode(const QStringHashNode *otherNode); + + template<typename StringHash, typename Data> + static inline Data iterateFirst(StringHash *self); + + template<typename Data> + static inline Data iterateNext(const Data &); + +public: + inline QStringHash(); + inline QStringHash(const QStringHash &); + inline ~QStringHash(); + + QStringHash &operator=(const QStringHash<T> &); + + void copyAndReserve(const QStringHash<T> &other, int additionalReserve); + + inline bool isEmpty() const; + inline void clear(); + inline int count() const; + + inline int numBuckets() const; + + template<typename Data, typename Value> + class Iterator { + public: + inline Iterator() = default; + inline Iterator(const Data &d) : d(d) {} + + inline Iterator &operator++() + { + d = QStringHash<T>::iterateNext(d); + return *this; + } + + inline bool operator==(const Iterator &o) const { return d.n == o.d.n; } + inline bool operator!=(const Iterator &o) const { return d.n != o.d.n; } + + template<typename K> + inline bool equals(const K &key) const { return d.n->equals(key); } + + inline QHashedString key() const { return static_cast<Node *>(d.n)->key(); } + inline Value &value() const { return static_cast<Node *>(d.n)->value; } + inline Value &operator*() const { return static_cast<Node *>(d.n)->value; } + + Node *node() const { return static_cast<Node *>(d.n); } + private: + Data d; + }; + + using MutableIterator = Iterator<MutableIteratorData, T>; + using ConstIterator = Iterator<ConstIteratorData, const T>; + + template<typename K> + inline void insert(const K &, const T &); + inline void insert(const MutableIterator &); + inline void insert(const ConstIterator &); + + template<typename K> + inline T *value(const K &) const; + inline T *value(const QV4::String *string) const; + inline T *value(const MutableIterator &) const; + inline T *value(const ConstIterator &) const; + + template<typename K> + inline bool contains(const K &) const; + + template<typename K> + inline T &operator[](const K &); + + inline MutableIterator begin(); + inline ConstIterator begin() const; + inline ConstIterator constBegin() const { return begin(); } + + inline MutableIterator end(); + inline ConstIterator end() const; + inline ConstIterator constEnd() const { return end(); } + + template<typename K> + inline MutableIterator find(const K &); + + template<typename K> + inline ConstIterator find(const K &) const; + + inline void reserve(int); +}; + +template<class T> +QStringHash<T>::QStringHash() +: newedNodes(nullptr), nodePool(nullptr) +{ +} + +template<class T> +QStringHash<T>::QStringHash(const QStringHash<T> &other) +: newedNodes(nullptr), nodePool(nullptr) +{ + data.numBits = other.data.numBits; + data.size = other.data.size; + reserve(other.count()); + copy(other); +} + +template<class T> +QStringHash<T> &QStringHash<T>::operator=(const QStringHash<T> &other) +{ + if (&other == this) + return *this; + + clear(); + + data.numBits = other.data.numBits; + data.size = other.data.size; + reserve(other.count()); + copy(other); + + return *this; +} + +template<class T> +void QStringHash<T>::copyAndReserve(const QStringHash<T> &other, int additionalReserve) +{ + clear(); + data.numBits = other.data.numBits; + reserve(other.count() + additionalReserve); + copy(other); +} + +template<class T> +QStringHash<T>::~QStringHash() +{ + clear(); +} + +template<class T> +void QStringHash<T>::clear() +{ + // Delete the individually allocated nodes + NewedNode *n = newedNodes; + while (n) { + NewedNode *c = n; + n = c->nextNewed; + delete c; + } + // Delete the pool allocated nodes + if (nodePool) delete nodePool; + delete [] data.buckets; + + data.buckets = nullptr; + data.numBuckets = 0; + data.numBits = 0; + data.size = 0; + + newedNodes = nullptr; + nodePool = nullptr; +} + +template<class T> +bool QStringHash<T>::isEmpty() const +{ + return data.size== 0; +} + +template<class T> +int QStringHash<T>::count() const +{ + return data.size; +} + +template<class T> +int QStringHash<T>::numBuckets() const +{ + return data.numBuckets; +} + +template<class T> +void QStringHash<T>::initializeNode(Node *node, const QHashedString &key) +{ + node->length = key.size(); + node->hash = key.hash(); + node->arrayData = mutableStringData(key).d_ptr(); + node->strData = mutableStringData(key).data(); + if (node->arrayData) + node->arrayData->ref(); + node->setQString(true); +} + +template<class T> +void QStringHash<T>::initializeNode(Node *node, const QHashedCStringRef &key) +{ + node->length = key.length(); + node->hash = key.hash(); + node->ckey = key.constData(); +} + +template<class T> +template<class K> +typename QStringHash<T>::Node *QStringHash<T>::takeNode(const K &key, const T &value) +{ + if (nodePool && nodePool->used != nodePool->count) { + Node *rv = nodePool->nodes + nodePool->used++; + initializeNode(rv, hashedString(key)); + rv->value = value; + return rv; + } else { + NewedNode *rv = new NewedNode(hashedString(key), value); + rv->nextNewed = newedNodes; + newedNodes = rv; + return rv; + } +} + +template<class T> +typename QStringHash<T>::Node *QStringHash<T>::takeNode(const Node &o) +{ + if (nodePool && nodePool->used != nodePool->count) { + Node *rv = nodePool->nodes + nodePool->used++; + rv->length = o.length; + rv->hash = o.hash; + rv->arrayData = o.arrayData; + if (o.isQString()) { + rv->strData = o.strData; + rv->setQString(true); + if (rv->arrayData) + rv->arrayData->ref(); + } else { + rv->ckey = o.ckey; + } + rv->symbolId = o.symbolId; + rv->value = o.value; + return rv; + } else { + NewedNode *rv = new NewedNode(o); + rv->nextNewed = newedNodes; + newedNodes = rv; + return rv; + } +} + +template<class T> +void QStringHash<T>::copyNode(const QStringHashNode *otherNode) +{ + // Copy the predecessor before the successor + QStringHashNode *next = otherNode->next.data(); + if (next) + copyNode(next); + + Node *mynode = takeNode(*(const Node *)otherNode); + int bucket = mynode->hash % data.numBuckets; + mynode->next = data.buckets[bucket]; + data.buckets[bucket] = mynode; +} + +template<class T> +void QStringHash<T>::copy(const QStringHash<T> &other) +{ + Q_ASSERT(data.size == 0); + + data.size = other.data.size; + + // Ensure buckets array is created + data.rehashToBits(data.numBits); + + // Preserve the existing order within buckets + for (int i = 0; i < other.data.numBuckets; ++i) { + QStringHashNode *bucket = other.data.buckets[i]; + if (bucket) + copyNode(bucket); + } +} + +template<class T> +template<typename Data> +Data QStringHash<T>::iterateNext(const Data &d) +{ + auto *This = d.p; + Node *node = (Node *)d.n; + + if (This->nodePool && node >= This->nodePool->nodes && + node < (This->nodePool->nodes + This->nodePool->used)) { + node--; + if (node < This->nodePool->nodes) + node = nullptr; + } else { + NewedNode *nn = (NewedNode *)node; + node = nn->nextNewed; + + if (node == nullptr && This->nodePool && This->nodePool->used) + node = This->nodePool->nodes + This->nodePool->used - 1; + } + + Data rv; + rv.n = node; + rv.p = d.p; + return rv; +} + +template<class T> +template<typename StringHash, typename Data> +Data QStringHash<T>::iterateFirst(StringHash *self) +{ + typename StringHash::Node *n = nullptr; + if (self->newedNodes) + n = self->newedNodes; + else if (self->nodePool && self->nodePool->used) + n = self->nodePool->nodes + self->nodePool->used - 1; + + Data rv; + rv.n = n; + rv.p = self; + return rv; +} + +template<class T> +typename QStringHash<T>::Node *QStringHash<T>::createNode(const Node &o) +{ + Node *n = takeNode(o); + return insertNode(n, n->hash); +} + +template<class T> +template<class K> +typename QStringHash<T>::Node *QStringHash<T>::createNode(const K &key, const T &value) +{ + Node *n = takeNode(key, value); + return insertNode(n, hashOf(key)); +} + +template<class T> +typename QStringHash<T>::Node *QStringHash<T>::insertNode(Node *n, quint32 hash) +{ + if (data.size >= data.numBuckets) + data.rehashToBits(data.numBits + 1); + + int bucket = hash % data.numBuckets; + n->next = data.buckets[bucket]; + data.buckets[bucket] = n; + + data.size++; + + return n; +} + +template<class T> +template<class K> +void QStringHash<T>::insert(const K &key, const T &value) +{ + Node *n = findNode(key); + if (n) + n->value = value; + else + createNode(key, value); +} + +template<class T> +void QStringHash<T>::insert(const MutableIterator &iter) +{ + insert(iter.key(), iter.value()); +} + +template<class T> +void QStringHash<T>::insert(const ConstIterator &iter) +{ + insert(iter.key(), iter.value()); +} + +template<class T> +template<class K> +typename QStringHash<T>::Node *QStringHash<T>::findNode(const K &key) const +{ + QStringHashNode *node = data.numBuckets?data.buckets[hashOf(key) % data.numBuckets]:nullptr; + + typename HashedForm<K>::Type hashedKey(hashedString(key)); + while (node && !node->equals(hashedKey)) + node = node->next.data(); + + return (Node *)node; +} + +template<class T> +template<class K> +T *QStringHash<T>::value(const K &key) const +{ + Node *n = findNode(key); + return n?&n->value:nullptr; +} + +template<typename T> +T *QStringHash<T>::value(const MutableIterator &iter) const +{ + return value(iter.node()->key()); +} + +template<class T> +T *QStringHash<T>::value(const ConstIterator &iter) const +{ + return value(iter.node()->key()); +} + +template<class T> +T *QStringHash<T>::value(const QV4::String *string) const +{ + Node *n = findNode(string); + return n?&n->value:nullptr; +} + +template<class T> +template<class K> +bool QStringHash<T>::contains(const K &key) const +{ + return nullptr != value(key); +} + +template<class T> +template<class K> +T &QStringHash<T>::operator[](const K &key) +{ + Node *n = findNode(key); + if (n) return n->value; + else return createNode(key, T())->value; +} + +template<class T> +void QStringHash<T>::reserve(int n) +{ + if (nodePool || 0 == n) + return; + + nodePool = new ReservedNodePool; + nodePool->count = n; + nodePool->used = 0; + nodePool->nodes = new Node[n]; + + data.rehashToSize(n); +} + +template<class T> +typename QStringHash<T>::MutableIterator QStringHash<T>::begin() +{ + return MutableIterator(iterateFirst<QStringHash<T>, MutableIteratorData>(this)); +} + +template<class T> +typename QStringHash<T>::ConstIterator QStringHash<T>::begin() const +{ + return ConstIterator(iterateFirst<const QStringHash<T>, ConstIteratorData>(this)); +} + +template<class T> +typename QStringHash<T>::MutableIterator QStringHash<T>::end() +{ + return MutableIterator(); +} + +template<class T> +typename QStringHash<T>::ConstIterator QStringHash<T>::end() const +{ + return ConstIterator(); +} + +template<class T> +template<class K> +typename QStringHash<T>::MutableIterator QStringHash<T>::find(const K &key) +{ + Node *n = findNode(key); + return n ? MutableIterator(MutableIteratorData(n, this)) : MutableIterator(); +} + +template<class T> +template<class K> +typename QStringHash<T>::ConstIterator QStringHash<T>::find(const K &key) const +{ + Node *n = findNode(key); + return n ? ConstIterator(ConstIteratorData(n, this)) : ConstIterator(); +} + +QT_END_NAMESPACE + +#endif // QSTRINGHASH_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qtqml-config_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qtqml-config_p.h new file mode 100644 index 0000000000000000000000000000000000000000..35f4b9e1acbb787a5e58823eb865a665d69e8636 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qtqml-config_p.h @@ -0,0 +1,39 @@ +#define QT_FEATURE_qml_jit 1 + +#define QT_FEATURE_qml_profiler 1 + +#define QT_FEATURE_qml_preview 1 + +#define QT_FEATURE_qml_xml_http_request 1 + +#define QT_FEATURE_qml_locale 1 + +#define QT_FEATURE_qml_animation 1 + +#define QT_FEATURE_qml_worker_script 1 + +#define QT_FEATURE_qml_itemmodel 1 + +#define QT_FEATURE_qml_xmllistmodel 1 + +#define QT_FEATURE_qml_python 1 + + +#define QT_QML_JIT_SUPPORTED_IMPL 0 +// Unset dummy value +#undef QT_QML_JIT_SUPPORTED_IMPL +// Compute per-arch value and save in extra define +#if QT_CONFIG(qml_jit) && !(defined(Q_OS_MACOS) && defined(Q_PROCESSOR_ARM)) +#define QT_QML_JIT_SUPPORTED_IMPL 1 +#else +#define QT_QML_JIT_SUPPORTED_IMPL 0 +#endif +// Unset original feature value +#undef QT_FEATURE_qml_jit +// Set new value based on previous computation +#if QT_QML_JIT_SUPPORTED_IMPL +#define QT_FEATURE_qml_jit 1 +#else +#define QT_FEATURE_qml_jit -1 +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qtqmlcompilerglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qtqmlcompilerglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d5ad3d9ca116ac92ed8997c73ea54db558b17743 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qtqmlcompilerglobal_p.h @@ -0,0 +1,21 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTQMLCOMPILERGLOBAL_P_H +#define QTQMLCOMPILERGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> +#include <qtqmlcompilerglobal.h> + +#endif // QTQMLCOMPILERGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qtqmlglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qtqmlglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1c09e3a753c87169cccace96e870a7b1d091aac4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qtqmlglobal_p.h @@ -0,0 +1,31 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTQMLGLOBAL_P_H +#define QTQMLGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> +#include <QtQml/qtqmlglobal.h> +#include <QtQml/private/qtqml-config_p.h> +#include <QtQml/qtqmlexports.h> + +#define Q_QML_AUTOTEST_EXPORT Q_AUTOTEST_EXPORT + +#ifdef QT_NO_DEBUG +#define QML_NEARLY_ALWAYS_INLINE Q_ALWAYS_INLINE +#else +#define QML_NEARLY_ALWAYS_INLINE inline +#endif + +#endif // QTQMLGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4alloca_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4alloca_p.h new file mode 100644 index 0000000000000000000000000000000000000000..451e6970e3c0e2946d08242699115fb214402f0a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4alloca_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4_ALLOCA_H +#define QV4_ALLOCA_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +#include <stdlib.h> +#if __has_include(<alloca.h>) +# include <alloca.h> +#endif +#if __has_include(<malloc.h>) +# include <malloc.h> +#endif + +#ifdef Q_CC_MSVC +// This does not matter unless compiling in strict standard mode. +# define alloca _alloca +#endif + +// Define Q_ALLOCA_VAR macro to be used instead of #ifdeffing +// the occurrences of alloca() in case it's not supported. +// Q_ALLOCA_DECLARE and Q_ALLOCA_ASSIGN macros separate +// memory allocation from the declaration and RAII. +#define Q_ALLOCA_VAR(type, name, size) \ + Q_ALLOCA_DECLARE(type, name); \ + Q_ALLOCA_ASSIGN(type, name, size) + +#ifdef alloca + +#define Q_ALLOCA_DECLARE(type, name) \ + type *name = 0 + +#define Q_ALLOCA_ASSIGN(type, name, size) \ + name = static_cast<type*>(alloca(size)) + +#else +# include <memory> + +#define Q_ALLOCA_DECLARE(type, name) \ + std::unique_ptr<char[]> _qt_alloca_##name; \ + type *name = nullptr + +#define Q_ALLOCA_ASSIGN(type, name, size) \ + do { \ + _qt_alloca_##name.reset(new char[size]); \ + name = reinterpret_cast<type*>(_qt_alloca_##name.get()); \ + } while (false) + +#endif + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4argumentsobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4argumentsobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3a65f3d443bf10ba2e1b99830024e94b8e693e32 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4argumentsobject_p.h @@ -0,0 +1,99 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4ARGUMENTSOBJECTS_H +#define QV4ARGUMENTSOBJECTS_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +#define ArgumentsObjectMembers(class, Member) \ + Member(class, Pointer, CallContext *, context) \ + Member(class, NoMark, bool, fullyCreated) \ + Member(class, NoMark, uint, argCount) \ + Member(class, NoMark, quint64, mapped) + +DECLARE_HEAP_OBJECT(ArgumentsObject, Object) { + DECLARE_MARKOBJECTS(ArgumentsObject) + enum { + LengthPropertyIndex = 0, + SymbolIteratorPropertyIndex = 1, + CalleePropertyIndex = 2 + }; + void init(CppStackFrame *frame); +}; + +#define StrictArgumentsObjectMembers(class, Member) + +DECLARE_HEAP_OBJECT(StrictArgumentsObject, Object) { + enum { + LengthPropertyIndex = 0, + SymbolIteratorPropertyIndex = 1, + CalleePropertyIndex = 2, + CalleeSetterPropertyIndex = 3 + }; + void init(JSTypesStackFrame *frame); +}; + +} + +struct ArgumentsObject: Object { + V4_OBJECT2(ArgumentsObject, Object) + Q_MANAGED_TYPE(ArgumentsObject) + + Heap::CallContext *context() const { return d()->context; } + bool fullyCreated() const { return d()->fullyCreated; } + + static bool isNonStrictArgumentsObject(Managed *m) { + return m->vtable() == staticVTable(); + } + + static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *desc, PropertyAttributes attrs); + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static bool virtualDeleteProperty(Managed *m, PropertyKey id); + static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p); + static qint64 virtualGetLength(const Managed *m); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); + + void fullyCreate(); + + // There's a slight hack here, as this limits the amount of mapped arguments to 64, but that should be + // more than enough for all practical uses of arguments + bool isMapped(uint arg) const { + return arg < 64 && (d()->mapped & (1ull << arg)); + } + + void removeMapping(uint arg) { + if (arg < 64) + (d()->mapped &= ~(1ull << arg)); + } + +}; + +struct StrictArgumentsObject : Object { + V4_OBJECT2(StrictArgumentsObject, Object) + Q_MANAGED_TYPE(ArgumentsObject) +}; + +} + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arraybuffer_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arraybuffer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..23ee5367ac1052093121300a7b9c8eebe2de8d92 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arraybuffer_p.h @@ -0,0 +1,159 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4ARRAYBUFFER_H +#define QV4ARRAYBUFFER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" +#include <QtCore/qarraydatapointer.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct SharedArrayBufferCtor : FunctionObject { + void init(QV4::ExecutionEngine *engine); +}; + +struct ArrayBufferCtor : SharedArrayBufferCtor { + void init(QV4::ExecutionEngine *engine); +}; + +struct Q_QML_EXPORT SharedArrayBuffer : Object { + void init(size_t length); + void init(const QByteArray& array); + void destroy(); + + void setSharedArrayBuffer(bool shared) noexcept { isShared = shared; } + bool isSharedArrayBuffer() const noexcept { return isShared; } + + char *arrayData() noexcept { return arrayDataPointer()->data(); } + const char *constArrayData() const noexcept { return constArrayDataPointer()->data(); } + uint arrayDataLength() const noexcept { return constArrayDataPointer().size; } + + bool hasSharedArrayData() const noexcept { return constArrayDataPointer().isShared(); } + bool hasDetachedArrayData() const noexcept { return constArrayDataPointer().isNull(); } + void detachArrayData() noexcept { arrayDataPointer().clear(); } + + bool arrayDataNeedsDetach() const noexcept { return constArrayDataPointer().needsDetach(); } + +private: + const QArrayDataPointer<const char> &constArrayDataPointer() const noexcept + { + return *reinterpret_cast<const QArrayDataPointer<const char> *>(&arrayDataPointerStorage); + } + QArrayDataPointer<char> &arrayDataPointer() noexcept + { + return *reinterpret_cast<QArrayDataPointer<char> *>(&arrayDataPointerStorage); + } + + template <typename T> + struct storage_t { alignas(T) unsigned char data[sizeof(T)]; }; + + storage_t<QArrayDataPointer<char>> + arrayDataPointerStorage; + bool isShared; +}; + +struct Q_QML_EXPORT ArrayBuffer : SharedArrayBuffer { + void init(size_t length) { + SharedArrayBuffer::init(length); + setSharedArrayBuffer(false); + } + void init(const QByteArray& array) { + SharedArrayBuffer::init(array); + setSharedArrayBuffer(false); + } +}; + +} + +struct SharedArrayBufferCtor : FunctionObject +{ + V4_OBJECT2(SharedArrayBufferCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct ArrayBufferCtor : SharedArrayBufferCtor +{ + V4_OBJECT2(ArrayBufferCtor, SharedArrayBufferCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + + static ReturnedValue method_isView(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +struct Q_QML_EXPORT SharedArrayBuffer : Object +{ + V4_OBJECT2(SharedArrayBuffer, Object) + V4_NEEDS_DESTROY + V4_PROTOTYPE(sharedArrayBufferPrototype) + + QByteArray asByteArray() const; + + uint arrayDataLength() const { return d()->arrayDataLength(); } + char *arrayData() { return d()->arrayData(); } + const char *constArrayData() const { return d()->constArrayData(); } + + bool hasSharedArrayData() { return d()->hasSharedArrayData(); } + bool hasDetachedArrayData() const { return d()->hasDetachedArrayData(); } + bool isSharedArrayBuffer() const { return d()->isSharedArrayBuffer(); } +}; + +struct Q_QML_EXPORT ArrayBuffer : SharedArrayBuffer +{ + V4_OBJECT2(ArrayBuffer, SharedArrayBuffer) + V4_NEEDS_DESTROY + V4_PROTOTYPE(arrayBufferPrototype) + + QByteArray asByteArray() const; + uint arrayDataLength() const { return d()->arrayDataLength(); } + char *dataData() { if (d()->arrayDataNeedsDetach()) detach(); return d()->arrayData(); } + // ### is that detach needed? + const char *constArrayData() const { return d()->constArrayData(); } + bool hasSharedArrayData() { return d()->hasSharedArrayData(); } + void detachArrayData() { d()->detachArrayData(); } + + void detach(); +}; + +struct SharedArrayBufferPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, bool shared); +}; + +struct ArrayBufferPrototype : SharedArrayBufferPrototype +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arraydata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arraydata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..81dd1c221d9c22ce0d1ba9f7a53ab91fd6649d6a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arraydata_p.h @@ -0,0 +1,369 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4ARRAYDATA_H +#define QV4ARRAYDATA_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" +#include "qv4managed_p.h" +#include "qv4property_p.h" +#include "qv4sparsearray_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +#define V4_ARRAYDATA(DataClass) \ + public: \ + Q_MANAGED_CHECK \ + typedef QV4::Heap::DataClass Data; \ + static const QV4::ArrayVTable static_vtbl; \ + static inline const QV4::VTable *staticVTable() { return &static_vtbl.vTable; } \ + V4_MANAGED_SIZE_TEST \ + const Data *d() const { return static_cast<const Data *>(m()); } \ + Data *d() { return static_cast<Data *>(m()); } + + +struct ArrayData; + +struct ArrayVTable +{ + VTable vTable; + uint type; + Heap::ArrayData *(*reallocate)(Object *o, uint n, bool enforceAttributes); + ReturnedValue (*get)(const Heap::ArrayData *d, uint index); + bool (*put)(Object *o, uint index, const Value &value); + bool (*putArray)(Object *o, uint index, const Value *values, uint n); + bool (*del)(Object *o, uint index); + void (*setAttribute)(Object *o, uint index, PropertyAttributes attrs); + void (*push_front)(Object *o, const Value *values, uint n); + ReturnedValue (*pop_front)(Object *o); + uint (*truncate)(Object *o, uint newLen); + uint (*length)(const Heap::ArrayData *d); +}; + +namespace Heap { + +#define ArrayDataMembers(class, Member) \ + Member(class, NoMark, ushort, type) \ + Member(class, NoMark, ushort, unused) \ + Member(class, NoMark, uint, offset) \ + Member(class, NoMark, PropertyAttributes *, attrs) \ + Member(class, NoMark, SparseArray *, sparse) \ + Member(class, ValueArray, ValueArray, values) + +DECLARE_HEAP_OBJECT(ArrayData, Base) { + static void markObjects(Heap::Base *base, MarkStack *stack); + + enum Type { Simple = 0, Sparse = 1, Custom = 2 }; + + bool isSparse() const { return type == Sparse; } + + const ArrayVTable *vtable() const { return reinterpret_cast<const ArrayVTable *>(internalClass->vtable); } + + inline ReturnedValue get(uint i) const { + return vtable()->get(this, i); + } + inline bool getProperty(uint index, Property *p, PropertyAttributes *attrs); + inline void setProperty(EngineBase *e, uint index, const Property *p); + inline PropertyIndex getValueOrSetter(uint index, PropertyAttributes *attrs); + inline PropertyAttributes attributes(uint i) const; + + bool isEmpty(uint i) const { + return get(i) == Value::emptyValue().asReturnedValue(); + } + + inline uint length() const { + return vtable()->length(this); + } + + void setArrayData(EngineBase *e, uint index, Value newVal) { + values.set(e, index, newVal); + } + + uint mappedIndex(uint index) const; +}; +Q_STATIC_ASSERT(std::is_trivial_v<ArrayData>); + +struct SimpleArrayData : public ArrayData { + uint mappedIndex(uint index) const { index += offset; if (index >= values.alloc) index -= values.alloc; return index; } + const Value &data(uint index) const { return values[mappedIndex(index)]; } + void setData(EngineBase *e, uint index, Value newVal) { + values.set(e, mappedIndex(index), newVal); + } + + PropertyAttributes attributes(uint i) const { + return attrs ? attrs[i] : Attr_Data; + } +}; +Q_STATIC_ASSERT(std::is_trivial_v<SimpleArrayData>); + +struct SparseArrayData : public ArrayData { + void destroy() { + delete sparse; + ArrayData::destroy(); + } + + uint mappedIndex(uint index) const { + SparseArrayNode *n = sparse->findNode(index); + if (!n) + return UINT_MAX; + return n->value; + } + + PropertyAttributes attributes(uint i) const { + if (!attrs) + return Attr_Data; + uint index = mappedIndex(i); + return index < UINT_MAX ? attrs[index] : Attr_Data; + } +}; + +} + +struct Q_QML_EXPORT ArrayData : public Managed +{ + typedef Heap::ArrayData::Type Type; + V4_MANAGED(ArrayData, Managed) + enum { + IsArrayData = true + }; + + uint alloc() const { return d()->values.alloc; } + uint &alloc() { return d()->values.alloc; } + void setAlloc(uint a) { d()->values.alloc = a; } + Type type() const { return static_cast<Type>(d()->type); } + void setType(Type t) { d()->type = t; } + PropertyAttributes *attrs() const { return d()->attrs; } + void setAttrs(PropertyAttributes *a) { d()->attrs = a; } + const Value *arrayData() const { return d()->values.data(); } + void setArrayData(EngineBase *e, uint index, Value newVal) { + d()->setArrayData(e, index, newVal); + } + + const ArrayVTable *vtable() const { return d()->vtable(); } + bool isSparse() const { return type() == Heap::ArrayData::Sparse; } + + uint length() const { + return d()->length(); + } + + bool hasAttributes() const { + return attrs(); + } + PropertyAttributes attributes(uint i) const { + return d()->attributes(i); + } + + bool isEmpty(uint i) const { + return d()->isEmpty(i); + } + + ReturnedValue get(uint i) const { + return d()->get(i); + } + + static void ensureAttributes(Object *o); + static void realloc(Object *o, Type newType, uint alloc, bool enforceAttributes); + + static void sort(ExecutionEngine *engine, Object *thisObject, const Value &comparefn, uint dataLen); + static uint append(Object *obj, ArrayObject *otherObj, uint n); + static void insert(Object *o, uint index, const Value *v, bool isAccessor = false); +}; + +struct Q_QML_EXPORT SimpleArrayData : public ArrayData +{ + V4_ARRAYDATA(SimpleArrayData) + V4_INTERNALCLASS(SimpleArrayData) + + uint mappedIndex(uint index) const { return d()->mappedIndex(index); } + Value data(uint index) const { return d()->data(index); } + + uint &len() { return d()->values.size; } + uint len() const { return d()->values.size; } + + static Heap::ArrayData *reallocate(Object *o, uint n, bool enforceAttributes); + + static ReturnedValue get(const Heap::ArrayData *d, uint index); + static bool put(Object *o, uint index, const Value &value); + static bool putArray(Object *o, uint index, const Value *values, uint n); + static bool del(Object *o, uint index); + static void setAttribute(Object *o, uint index, PropertyAttributes attrs); + static void push_front(Object *o, const Value *values, uint n); + static ReturnedValue pop_front(Object *o); + static uint truncate(Object *o, uint newLen); + static uint length(const Heap::ArrayData *d); +}; + +struct Q_QML_EXPORT SparseArrayData : public ArrayData +{ + V4_ARRAYDATA(SparseArrayData) + V4_INTERNALCLASS(SparseArrayData) + V4_NEEDS_DESTROY + + SparseArray *sparse() const { return d()->sparse; } + void setSparse(SparseArray *s) { d()->sparse = s; } + + static uint allocate(Object *o, bool doubleSlot = false); + static void free(Heap::ArrayData *d, uint idx); + + uint mappedIndex(uint index) const { return d()->mappedIndex(index); } + + static Heap::ArrayData *reallocate(Object *o, uint n, bool enforceAttributes); + static ReturnedValue get(const Heap::ArrayData *d, uint index); + static bool put(Object *o, uint index, const Value &value); + static bool putArray(Object *o, uint index, const Value *values, uint n); + static bool del(Object *o, uint index); + static void setAttribute(Object *o, uint index, PropertyAttributes attrs); + static void push_front(Object *o, const Value *values, uint n); + static ReturnedValue pop_front(Object *o); + static uint truncate(Object *o, uint newLen); + static uint length(const Heap::ArrayData *d); +}; + +class ArrayElementLessThan +{ +public: + inline ArrayElementLessThan(ExecutionEngine *engine, const Value &comparefn) + : m_engine(engine), m_comparefn(comparefn) {} + + bool operator()(Value v1, Value v2) const; + +private: + ExecutionEngine *m_engine; + const Value &m_comparefn; +}; + +template <typename RandomAccessIterator, typename LessThan> +void sortHelper(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan) +{ +top: + using std::swap; + + int span = int(end - start); + if (span < 2) + return; + + --end; + RandomAccessIterator low = start, high = end - 1; + RandomAccessIterator pivot = start + span / 2; + + if (lessThan(*end, *start)) + swap(*end, *start); + if (span == 2) + return; + + if (lessThan(*pivot, *start)) + swap(*pivot, *start); + if (lessThan(*end, *pivot)) + swap(*end, *pivot); + if (span == 3) + return; + + swap(*pivot, *end); + + while (low < high) { + while (low < high && lessThan(*low, *end)) + ++low; + + while (high > low && lessThan(*end, *high)) + --high; + + if (low < high) { + swap(*low, *high); + ++low; + --high; + } else { + break; + } + } + + if (lessThan(*low, *end)) + ++low; + + swap(*end, *low); + sortHelper(start, low, lessThan); + + start = low + 1; + ++end; + goto top; +} + +namespace Heap { + +inline uint ArrayData::mappedIndex(uint index) const +{ + if (isSparse()) + return static_cast<const SparseArrayData *>(this)->mappedIndex(index); + if (index >= values.size) + return UINT_MAX; + uint idx = static_cast<const SimpleArrayData *>(this)->mappedIndex(index); + return values[idx].isEmpty() ? UINT_MAX : idx; +} + +bool ArrayData::getProperty(uint index, Property *p, PropertyAttributes *attrs) +{ + uint mapped = mappedIndex(index); + if (mapped == UINT_MAX) { + *attrs = Attr_Invalid; + return false; + } + + *attrs = attributes(index); + if (p) { + p->value = *(PropertyIndex{ this, values.values + mapped }); + if (attrs->isAccessor()) + p->set = *(PropertyIndex{ this, values.values + mapped + 1 /*Object::SetterOffset*/ }); + } + return true; +} + +void ArrayData::setProperty(QV4::EngineBase *e, uint index, const Property *p) +{ + uint mapped = mappedIndex(index); + Q_ASSERT(mapped != UINT_MAX); + values.set(e, mapped, p->value); + if (attributes(index).isAccessor()) + values.set(e, mapped + 1 /*QV4::Object::SetterOffset*/, p->set); +} + +inline PropertyAttributes ArrayData::attributes(uint i) const +{ + if (isSparse()) + return static_cast<const SparseArrayData *>(this)->attributes(i); + return static_cast<const SimpleArrayData *>(this)->attributes(i); +} + +PropertyIndex ArrayData::getValueOrSetter(uint index, PropertyAttributes *attrs) +{ + uint idx = mappedIndex(index); + if (idx == UINT_MAX) { + *attrs = Attr_Invalid; + return { nullptr, nullptr }; + } + + *attrs = attributes(index); + if (attrs->isAccessor()) + ++idx; + return { this, values.values + idx }; +} + + + +} + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arrayiterator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arrayiterator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2eef7dd7662e4d588855a4c916ec97ac26e23891 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arrayiterator_p.h @@ -0,0 +1,69 @@ +// Copyright (C) 2017 Crimson AS <info@crimson.no> +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4ARRAYITERATOR_P_H +#define QV4ARRAYITERATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4iterator_p.h" + +QT_BEGIN_NAMESPACE + + +namespace QV4 { + +namespace Heap { + +#define ArrayIteratorObjectMembers(class, Member) \ + Member(class, Pointer, Object *, iteratedObject) \ + Member(class, NoMark, IteratorKind, iterationKind) \ + Member(class, NoMark, quint32, nextIndex) + +DECLARE_HEAP_OBJECT(ArrayIteratorObject, Object) { + DECLARE_MARKOBJECTS(ArrayIteratorObject) + void init(Object *obj, QV4::ExecutionEngine *engine) + { + Object::init(); + this->iteratedObject.set(engine, obj); + this->nextIndex = 0; + } +}; + +} + +struct ArrayIteratorPrototype : Object +{ + V4_PROTOTYPE(iteratorPrototype) + void init(ExecutionEngine *engine); + + static ReturnedValue method_next(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); +}; + +struct ArrayIteratorObject : Object +{ + V4_OBJECT2(ArrayIteratorObject, Object) + Q_MANAGED_TYPE(ArrayIteratorObject) + V4_PROTOTYPE(arrayIteratorPrototype) + + void init(ExecutionEngine *engine); +}; + + +} + +QT_END_NAMESPACE + +#endif // QV4ARRAYITERATOR_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arrayobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arrayobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a39070ec54e1338aac68196b5e511d04d172fc93 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4arrayobject_p.h @@ -0,0 +1,113 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4ARRAYOBJECT_H +#define QV4ARRAYOBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" +#include <QtCore/qnumeric.h> + +QT_BEGIN_NAMESPACE + +inline bool qIsAtMostUintLimit(qsizetype length, uint limit = std::numeric_limits<uint>::max()) +{ + // Use the type with the larger positive range to do the comparison. + + Q_ASSERT(length >= 0); + if constexpr (sizeof(qsizetype) > sizeof(uint)) { + return length <= qsizetype(limit); + } else { + return uint(length) <= limit; + } +} + +inline bool qIsAtMostSizetypeLimit(uint length, qsizetype limit = std::numeric_limits<qsizetype>::max()) +{ + // Use the type with the larger positive range to do the comparison. + + Q_ASSERT(limit >= 0); + if constexpr (sizeof(qsizetype) > sizeof(uint)) { + return qsizetype(length) <= limit; + } else { + return length <= uint(limit); + } +} + + +namespace QV4 { + +namespace Heap { + +struct ArrayCtor : FunctionObject { + void init(QV4::ExecutionEngine *engine); +}; + +} + +struct ArrayCtor: FunctionObject +{ + V4_OBJECT2(ArrayCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct ArrayPrototype: ArrayObject +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_isArray(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_from(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_of(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toLocaleString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_concat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_copyWithin(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_find(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_findIndex(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_join(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_pop(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_push(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_reverse(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_shift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_splice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_unshift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_includes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_every(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_fill(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_some(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_map(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_filter(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_reduce(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_reduceRight(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + // while this function is implemented here, it's the same for many other JS classes, so the corresponding JS function + // is instantiated in the engine, and it can be added to any JS object through Object::addSymbolSpecies() + static ReturnedValue method_get_species(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4ECMAOBJECTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4assemblercommon_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4assemblercommon_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5de51ec5ae0df85fe6964d317e00d4e7ce6adb7a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4assemblercommon_p.h @@ -0,0 +1,713 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4PLATFORMASSEMBLER_P_H +#define QV4PLATFORMASSEMBLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4engine_p.h> +#include <private/qv4function_p.h> +#include <private/qv4global_p.h> +#include <private/qv4stackframe_p.h> + +#include <wtf/Vector.h> +#include <assembler/MacroAssembler.h> + +#include <QtCore/qhash.h> + +#if QT_CONFIG(qml_jit) + +QT_BEGIN_NAMESPACE + +namespace QV4 { +namespace JIT { + +#if defined(Q_PROCESSOR_X86_64) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES) +#if defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_FREEBSD) || defined(Q_OS_DARWIN) || defined(Q_OS_SOLARIS) || defined(Q_OS_VXWORKS) + +class PlatformAssembler_X86_64_SysV : public JSC::MacroAssembler<JSC::MacroAssemblerX86_64> +{ +public: + static constexpr int NativeStackAlignment = 16; + + static const RegisterID NoRegister = RegisterID::none; + + static const RegisterID ReturnValueRegister = RegisterID::eax; + static const RegisterID ReturnValueRegisterValue = ReturnValueRegister; + static const RegisterID AccumulatorRegister = RegisterID::eax; + static const RegisterID AccumulatorRegisterValue = AccumulatorRegister; + static const RegisterID ScratchRegister = RegisterID::r10; + static const RegisterID ScratchRegister2 = RegisterID::r9; // Note: overlaps with Arg5Reg, so do not use while setting up a call! + static const RegisterID JSStackFrameRegister = RegisterID::r12; + static const RegisterID CppStackFrameRegister = RegisterID::r13; + static const RegisterID EngineRegister = RegisterID::r14; + static const RegisterID StackPointerRegister = RegisterID::esp; + static const RegisterID FramePointerRegister = RegisterID::ebp; + static const FPRegisterID FPScratchRegister = FPRegisterID::xmm1; + static const FPRegisterID FPScratchRegister2 = FPRegisterID::xmm2; + + static const RegisterID Arg0Reg = RegisterID::edi; + static const RegisterID Arg1Reg = RegisterID::esi; + static const RegisterID Arg2Reg = RegisterID::edx; + static const RegisterID Arg3Reg = RegisterID::ecx; + static const RegisterID Arg4Reg = RegisterID::r8; + static const RegisterID Arg5Reg = RegisterID::r9; + static const RegisterID Arg6Reg = NoRegister; + static const RegisterID Arg7Reg = NoRegister; + static const int ArgInRegCount = 6; + + void popValue() + { + addPtr(TrustedImmPtr(sizeof(ReturnedValue)), StackPointerRegister); + } + + void generatePlatformFunctionEntry() + { + push(FramePointerRegister); + move(StackPointerRegister, FramePointerRegister); + move(TrustedImmPtr(nullptr), AccumulatorRegister); push(AccumulatorRegister); // exceptionHandler + push(JSStackFrameRegister); + push(CppStackFrameRegister); + push(EngineRegister); + move(Arg0Reg, CppStackFrameRegister); + move(Arg1Reg, EngineRegister); + } + + void generatePlatformFunctionExit(bool tailCall = false) + { + pop(EngineRegister); + pop(CppStackFrameRegister); + pop(JSStackFrameRegister); + pop(); // exceptionHandler + pop(FramePointerRegister); + if (!tailCall) + ret(); + } + + void callAbsolute(const void *funcPtr) + { + move(TrustedImmPtr(funcPtr), ScratchRegister); + call(ScratchRegister); + } + + void jumpAbsolute(const void *funcPtr) + { + move(TrustedImmPtr(funcPtr), ScratchRegister); + jump(ScratchRegister); + } + + void pushAligned(RegisterID reg) + { + subPtr(TrustedImm32(PointerSize), StackPointerRegister); + push(reg); + } + + void popAligned(RegisterID reg) + { + pop(reg); + addPtr(TrustedImm32(PointerSize), StackPointerRegister); + } +}; + +typedef PlatformAssembler_X86_64_SysV PlatformAssemblerBase; + +#endif +#if defined(Q_OS_WIN) + +class PlatformAssembler_Win64 : public JSC::MacroAssembler<JSC::MacroAssemblerX86_64> +{ +public: + static const RegisterID NoRegister = RegisterID::none; + + static const RegisterID ReturnValueRegister = RegisterID::eax; + static const RegisterID ReturnValueRegisterValue = ReturnValueRegister; + static const RegisterID AccumulatorRegister = RegisterID::eax; + static const RegisterID AccumulatorRegisterValue = AccumulatorRegister; + static const RegisterID ScratchRegister = RegisterID::r10; + static const RegisterID ScratchRegister2 = RegisterID::r9; // Note: overlaps with Arg3Reg, so do not use while setting up a call! + static const RegisterID JSStackFrameRegister = RegisterID::r12; + static const RegisterID CppStackFrameRegister = RegisterID::r13; + static const RegisterID EngineRegister = RegisterID::r14; + static const RegisterID StackPointerRegister = RegisterID::esp; + static const RegisterID FramePointerRegister = RegisterID::ebp; + static const FPRegisterID FPScratchRegister = FPRegisterID::xmm1; + + static const RegisterID Arg0Reg = RegisterID::ecx; + static const RegisterID Arg1Reg = RegisterID::edx; + static const RegisterID Arg2Reg = RegisterID::r8; + static const RegisterID Arg3Reg = RegisterID::r9; + static const RegisterID Arg4Reg = NoRegister; + static const RegisterID Arg5Reg = NoRegister; + static const RegisterID Arg6Reg = NoRegister; + static const RegisterID Arg7Reg = NoRegister; + static const int ArgInRegCount = 4; + + void popValue() + { + addPtr(TrustedImmPtr(sizeof(ReturnedValue)), StackPointerRegister); + } + + void generatePlatformFunctionEntry() + { + push(FramePointerRegister); + move(StackPointerRegister, FramePointerRegister); + move(TrustedImmPtr(nullptr), AccumulatorRegister); push(AccumulatorRegister); // exceptionHandler + push(JSStackFrameRegister); + push(CppStackFrameRegister); + push(EngineRegister); + move(Arg0Reg, CppStackFrameRegister); + move(Arg1Reg, EngineRegister); + } + + void generatePlatformFunctionExit(bool tailCall = false) + { + pop(EngineRegister); + pop(CppStackFrameRegister); + pop(JSStackFrameRegister); + pop(); // exceptionHandler + pop(FramePointerRegister); + if (!tailCall) + ret(); + } + + void callAbsolute(const void *funcPtr) + { + move(TrustedImmPtr(funcPtr), ScratchRegister); + subPtr(TrustedImm32(4 * PointerSize), StackPointerRegister); + call(ScratchRegister); + addPtr(TrustedImm32(4 * PointerSize), StackPointerRegister); + } + + void jumpAbsolute(const void *funcPtr) + { + move(TrustedImmPtr(funcPtr), ScratchRegister); + jump(ScratchRegister); + } + + void pushAligned(RegisterID reg) + { + subPtr(TrustedImm32(PointerSize), StackPointerRegister); + push(reg); + } + + void popAligned(RegisterID reg) + { + pop(reg); + addPtr(TrustedImm32(PointerSize), StackPointerRegister); + } +}; + +typedef PlatformAssembler_Win64 PlatformAssemblerBase; + +#endif +#endif + +#if (defined(Q_PROCESSOR_X86) && !defined(Q_PROCESSOR_X86_64)) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES) + +class PlatformAssembler_X86_All : public JSC::MacroAssembler<JSC::MacroAssemblerX86> +{ +public: + static const RegisterID NoRegister = RegisterID::none; + + static const RegisterID ReturnValueRegisterValue = RegisterID::eax; + static const RegisterID ReturnValueRegisterTag = RegisterID::edx; + static const RegisterID ScratchRegister = RegisterID::ecx; + static const RegisterID AccumulatorRegisterValue = ReturnValueRegisterValue; + static const RegisterID AccumulatorRegisterTag = ReturnValueRegisterTag; + static const RegisterID JSStackFrameRegister = RegisterID::ebx; + static const RegisterID CppStackFrameRegister = RegisterID::esi; + static const RegisterID EngineRegister = RegisterID::edi; + static const RegisterID StackPointerRegister = RegisterID::esp; + static const RegisterID FramePointerRegister = RegisterID::ebp; + static const FPRegisterID FPScratchRegister = FPRegisterID::xmm1; + + static const RegisterID Arg0Reg = NoRegister; + static const RegisterID Arg1Reg = NoRegister; + static const RegisterID Arg2Reg = NoRegister; + static const RegisterID Arg3Reg = NoRegister; + static const RegisterID Arg4Reg = NoRegister; + static const RegisterID Arg5Reg = NoRegister; + static const RegisterID Arg6Reg = NoRegister; + static const RegisterID Arg7Reg = NoRegister; + static const int ArgInRegCount = 0; + + void popValue() + { + addPtr(TrustedImmPtr(sizeof(ReturnedValue)), StackPointerRegister); + } + + void generatePlatformFunctionEntry() + { + push(RegisterID::ebp); + move(RegisterID::esp, RegisterID::ebp); + move(TrustedImmPtr(nullptr), AccumulatorRegisterValue); push(AccumulatorRegisterValue); // exceptionHandler + push(JSStackFrameRegister); + push(CppStackFrameRegister); + push(EngineRegister); + // Ensure the stack is 16-byte aligned in order for compiler generated aligned SSE2 + // instructions to be able to target the stack. + subPtr(TrustedImm32(8), StackPointerRegister); + loadPtr(Address(FramePointerRegister, 2 * PointerSize), CppStackFrameRegister); + loadPtr(Address(FramePointerRegister, 3 * PointerSize), EngineRegister); + } + + void generatePlatformFunctionExit(bool tailCall = false) + { + addPtr(TrustedImm32(8), StackPointerRegister); + pop(EngineRegister); + pop(CppStackFrameRegister); + pop(JSStackFrameRegister); + pop(); // exceptionHandler + pop(RegisterID::ebp); + if (!tailCall) + ret(); + } + + void callAbsolute(const void *funcPtr) + { + move(TrustedImmPtr(funcPtr), ScratchRegister); + call(ScratchRegister); + } + + void jumpAbsolute(const void *funcPtr) + { + move(TrustedImmPtr(funcPtr), ScratchRegister); + jump(ScratchRegister); + } + + void pushAligned(RegisterID reg) + { + subPtr(TrustedImm32(3 * PointerSize), StackPointerRegister); + push(reg); + } + + void popAligned(RegisterID reg) + { + pop(reg); + addPtr(TrustedImm32(3 * PointerSize), StackPointerRegister); + } +}; + +typedef PlatformAssembler_X86_All PlatformAssemblerBase; + +#endif + +#if defined(Q_PROCESSOR_ARM_64) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES) + +class PlatformAssembler_ARM64 : public JSC::MacroAssembler<JSC::MacroAssemblerARM64> +{ +public: + static const RegisterID NoRegister = RegisterID::none; + + static const RegisterID ReturnValueRegister = JSC::ARM64Registers::x0; + static const RegisterID ReturnValueRegisterValue = ReturnValueRegister; + static const RegisterID AccumulatorRegister = JSC::ARM64Registers::x9; + static const RegisterID AccumulatorRegisterValue = AccumulatorRegister; + static const RegisterID ScratchRegister = JSC::ARM64Registers::x10; + static const RegisterID ScratchRegister2 = JSC::ARM64Registers::x7; // Note: overlaps with Arg7Reg, so do not use while setting up a call! + static const RegisterID JSStackFrameRegister = JSC::ARM64Registers::x19; + static const RegisterID CppStackFrameRegister = JSC::ARM64Registers::x20; + static const RegisterID EngineRegister = JSC::ARM64Registers::x21; + static const RegisterID StackPointerRegister = JSC::ARM64Registers::sp; + static const RegisterID FramePointerRegister = JSC::ARM64Registers::fp; + static const FPRegisterID FPScratchRegister = JSC::ARM64Registers::q1; + + static const RegisterID Arg0Reg = JSC::ARM64Registers::x0; + static const RegisterID Arg1Reg = JSC::ARM64Registers::x1; + static const RegisterID Arg2Reg = JSC::ARM64Registers::x2; + static const RegisterID Arg3Reg = JSC::ARM64Registers::x3; + static const RegisterID Arg4Reg = JSC::ARM64Registers::x4; + static const RegisterID Arg5Reg = JSC::ARM64Registers::x5; + static const RegisterID Arg6Reg = JSC::ARM64Registers::x6; + static const RegisterID Arg7Reg = JSC::ARM64Registers::x7; + static const int ArgInRegCount = 8; + + void push(RegisterID src) + { + pushToSave(src); + } + + void pop(RegisterID dest) + { + popToRestore(dest); + } + + void pop() + { + add64(TrustedImm32(16), stackPointerRegister); + } + + void popValue() + { + pop(); + } + + void generatePlatformFunctionEntry() + { + pushPair(JSC::ARM64Registers::fp, JSC::ARM64Registers::lr); + move(RegisterID::sp, RegisterID::fp); + move(TrustedImmPtr(nullptr), AccumulatorRegister); // exceptionHandler + pushPair(JSStackFrameRegister, AccumulatorRegister); + pushPair(EngineRegister, CppStackFrameRegister); + move(Arg0Reg, CppStackFrameRegister); + move(Arg1Reg, EngineRegister); + } + + void generatePlatformFunctionExit(bool tailCall = false) + { + if (!tailCall) // do not overwrite arg0 (used in the tail call) + move(AccumulatorRegister, ReturnValueRegister); + popPair(EngineRegister, CppStackFrameRegister); + popPair(JSStackFrameRegister, AccumulatorRegister); + popPair(JSC::ARM64Registers::fp, JSC::ARM64Registers::lr); + if (!tailCall) + ret(); + } + + void callAbsolute(const void *funcPtr) + { + move(TrustedImmPtr(funcPtr), ScratchRegister); + call(ScratchRegister); + } + + void jumpAbsolute(const void *funcPtr) + { + move(TrustedImmPtr(funcPtr), ScratchRegister); + jump(ScratchRegister); + } + + void pushAligned(RegisterID reg) + { + pushToSave(reg); + } + + void popAligned(RegisterID reg) + { + popToRestore(reg); + } +}; + +typedef PlatformAssembler_ARM64 PlatformAssemblerBase; + +#endif + +#if defined(Q_PROCESSOR_ARM_32) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES) + +class PlatformAssembler_ARM32 : public JSC::MacroAssembler<JSC::MacroAssemblerARMv7> +{ +public: + static const RegisterID NoRegister = RegisterID::none; + + static const RegisterID ReturnValueRegisterValue = JSC::ARMRegisters::r0; + static const RegisterID ReturnValueRegisterTag = JSC::ARMRegisters::r1; + static const RegisterID ScratchRegister = JSC::ARMRegisters::r2; + static const RegisterID AccumulatorRegisterValue = JSC::ARMRegisters::r4; + static const RegisterID AccumulatorRegisterTag = JSC::ARMRegisters::r5; + // r6 is used by MacroAssemblerARMv7 + static const RegisterID JSStackFrameRegister = JSC::ARMRegisters::r8; + static const RegisterID CppStackFrameRegister = JSC::ARMRegisters::r10; +#if CPU(ARM_THUMB2) + static const RegisterID FramePointerRegister = JSC::ARMRegisters::r7; + static const RegisterID EngineRegister = JSC::ARMRegisters::r11; +#else // Thumbs down + static const RegisterID FramePointerRegister = JSC::ARMRegisters::r11; + static const RegisterID EngineRegister = JSC::ARMRegisters::r7; +#endif + static const RegisterID StackPointerRegister = JSC::ARMRegisters::r13; + static const FPRegisterID FPScratchRegister = JSC::ARMRegisters::d1; + + static const RegisterID Arg0Reg = JSC::ARMRegisters::r0; + static const RegisterID Arg1Reg = JSC::ARMRegisters::r1; + static const RegisterID Arg2Reg = JSC::ARMRegisters::r2; + static const RegisterID Arg3Reg = JSC::ARMRegisters::r3; + static const RegisterID Arg4Reg = NoRegister; + static const RegisterID Arg5Reg = NoRegister; + static const RegisterID Arg6Reg = NoRegister; + static const RegisterID Arg7Reg = NoRegister; + static const int ArgInRegCount = 4; + + void popValue() + { + addPtr(TrustedImm32(sizeof(ReturnedValue)), StackPointerRegister); + } + + void generatePlatformFunctionEntry() + { + push(JSC::ARMRegisters::lr); + push(FramePointerRegister); + move(StackPointerRegister, FramePointerRegister); + push(TrustedImm32(0)); // exceptionHandler + push(AccumulatorRegisterValue); + push(AccumulatorRegisterTag); + push(addressTempRegister); + push(JSStackFrameRegister); + push(CppStackFrameRegister); + push(EngineRegister); + subPtr(TrustedImm32(4), StackPointerRegister); // stack alignment + move(Arg0Reg, CppStackFrameRegister); + move(Arg1Reg, EngineRegister); + } + + void generatePlatformFunctionExit(bool tailCall = false) + { + if (!tailCall) { // do not overwrite arg0 and arg1 (used in the tail call) + move(AccumulatorRegisterValue, ReturnValueRegisterValue); + move(AccumulatorRegisterTag, ReturnValueRegisterTag); + } + addPtr(TrustedImm32(4), StackPointerRegister); // stack alignment + pop(EngineRegister); + pop(CppStackFrameRegister); + pop(JSStackFrameRegister); + pop(addressTempRegister); + pop(AccumulatorRegisterTag); + pop(AccumulatorRegisterValue); + pop(); // exceptionHandler + pop(FramePointerRegister); + pop(JSC::ARMRegisters::lr); + if (!tailCall) + ret(); + } + + void callAbsolute(const void *funcPtr) + { + move(TrustedImmPtr(funcPtr), dataTempRegister); + call(dataTempRegister); + } + + void jumpAbsolute(const void *funcPtr) + { + move(TrustedImmPtr(funcPtr), dataTempRegister); + jump(dataTempRegister); + } + + void pushAligned(RegisterID reg) + { + subPtr(TrustedImm32(PointerSize), StackPointerRegister); + push(reg); + } + + void popAligned(RegisterID reg) + { + pop(reg); + addPtr(TrustedImm32(PointerSize), StackPointerRegister); + } +}; + +typedef PlatformAssembler_ARM32 PlatformAssemblerBase; +#endif + +class PlatformAssemblerCommon : public JIT::PlatformAssemblerBase +{ +public: + PlatformAssemblerCommon(const Value *constantTable) + : constantTable(constantTable) + {} + + virtual ~PlatformAssemblerCommon(); + + Address exceptionHandlerAddress() const + { + return Address(FramePointerRegister, -1 * PointerSize); + } + + Address contextAddress() const + { + return Address(JSStackFrameRegister, offsetof(CallData, context)); + } + + RegisterID registerForArg(int arg) const + { + Q_ASSERT(arg >= 0); + Q_ASSERT(arg < ArgInRegCount); + switch (arg) { + case 0: return Arg0Reg; + case 1: return Arg1Reg; + case 2: return Arg2Reg; + case 3: return Arg3Reg; + case 4: return Arg4Reg; + case 5: return Arg5Reg; + case 6: return Arg6Reg; + case 7: return Arg7Reg; + default: + Q_UNIMPLEMENTED(); + Q_UNREACHABLE(); + } + } + + Address loadFunctionPtr(RegisterID target) + { + Address addr(CppStackFrameRegister, offsetof(JSTypesStackFrame, v4Function)); + loadPtr(addr, target); + return Address(target); + } + + Address loadCompilationUnitPtr(RegisterID target) + { + Address addr = loadFunctionPtr(target); + addr.offset = offsetof(QV4::FunctionData, compilationUnit); + loadPtr(addr, target); + return Address(target); + } + + Address loadConstAddress(int constIndex, RegisterID baseReg = ScratchRegister) + { + Address addr = loadCompilationUnitPtr(baseReg); + addr.offset = offsetof(QV4::CompilationUnitRuntimeData, constants); + loadPtr(addr, baseReg); + addr.offset = constIndex * int(sizeof(QV4::Value)); + return addr; + } + + Address loadStringAddress(int stringId) + { + Address addr = loadCompilationUnitPtr(ScratchRegister); + addr.offset = offsetof(QV4::CompilationUnitRuntimeData, runtimeStrings); + loadPtr(addr, ScratchRegister); + return Address(ScratchRegister, stringId * PointerSize); + } + + void passAsArg(RegisterID src, int arg) + { + move(src, registerForArg(arg)); + } + + void generateCatchTrampoline(std::function<void()> loadUndefined) + { + for (Jump j : catchyJumps) + j.link(this); + + // We don't need to check for isInterrupted here because if that is set, + // then the first checkException() in any exception handler will find another "exception" + // and jump out of the exception handler. + loadPtr(exceptionHandlerAddress(), ScratchRegister); + Jump exitFunction = branchPtr(Equal, ScratchRegister, TrustedImmPtr(0)); + loadUndefined(); + jump(ScratchRegister); + exitFunction.link(this); + + if (functionExit.isSet()) + jump(functionExit); + else + generateFunctionExit(); + } + + void checkException() + { + // This actually reads 4 bytes, starting at hasException. + // Therefore, it also reads the isInterrupted flag, and triggers an exception on that. + addCatchyJump( + branch32(NotEqual, + Address(EngineRegister, offsetof(EngineBase, hasException)), + TrustedImm32(0))); + } + + void addCatchyJump(Jump j) + { + Q_ASSERT(j.isSet()); + catchyJumps.push_back(j); + } + + void generateFunctionEntry() + { + generatePlatformFunctionEntry(); + loadPtr(Address(CppStackFrameRegister, offsetof(JSTypesStackFrame, jsFrame)), + JSStackFrameRegister); + allocateStackSpace(); + } + + virtual void allocateStackSpace() {} + + void generateFunctionExit() + { + if (functionExit.isSet()) { + jump(functionExit); + return; + } + + functionExit = label(); + freeStackSpace(); + generatePlatformFunctionExit(); + } + + virtual void freeStackSpace() {} + + void addLabelForOffset(int offset) + { + if (!labelForOffset.contains(offset)) + labelForOffset.insert(offset, label()); + } + + void addJumpToOffset(const Jump &jump, int offset) + { + jumpsToLink.push_back({ jump, offset }); + } + + void addEHTarget(const DataLabelPtr &label, int offset) + { + ehTargets.push_back({ label, offset }); + } + + void link(Function *function, const char *jitKind); + + Value constant(int idx) const + { return constantTable[idx]; } + + // stuff for runtime calls + void prepareCallWithArgCount(int argc); + void storeInstructionPointer(int instructionOffset); + void passAccumulatorAsArg(int arg); + void pushAccumulatorAsArg(int arg); + void passFunctionAsArg(int arg); + void passEngineAsArg(int arg); + void passJSSlotAsArg(int reg, int arg); + void passAddressAsArg(Address addr, int arg); + void passCppFrameAsArg(int arg); + void passInt32AsArg(int value, int arg); + void passPointerAsArg(void *ptr, int arg); + void callRuntime(const void *funcPtr, const char *functionName = nullptr); + void callRuntimeUnchecked(const void *funcPtr, const char *functionName = nullptr); + void tailCallRuntime(const void *funcPtr, const char *functionName = nullptr); + void setTailCallArg(RegisterID src, int arg); + Address jsAlloca(int slotCount); + void storeInt32AsValue(int srcInt, Address destAddr); + +private: + void passAccumulatorAsArg_internal(int arg, bool doPush); + static Address argStackAddress(int arg); + +private: + const Value* constantTable; + struct JumpTarget { JSC::MacroAssemblerBase::Jump jump; int offset; }; + std::vector<JumpTarget> jumpsToLink; + struct ExceptionHanlderTarget { JSC::MacroAssemblerBase::DataLabelPtr label; int offset; }; + std::vector<ExceptionHanlderTarget> ehTargets; + QHash<int, JSC::MacroAssemblerBase::Label> labelForOffset; + QHash<const void *, const char *> functions; + std::vector<Jump> catchyJumps; + Label functionExit; + +#ifndef QT_NO_DEBUG + enum { NoCall = -1 }; + int remainingArgcForCall = NoCall; +#endif + int argcOnStackForCall = 0; +}; + +} // JIT namespace +} // QV4 namespace + +QT_END_NAMESPACE + +#endif // QT_CONFIG(qml_jit) + +#endif // QV4PLATFORMASSEMBLER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4atomics_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4atomics_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6931e66ed8ab023d106757f1b97e1878dbd30d73 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4atomics_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4ATOMICS_H +#define QV4ATOMICS_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct Atomics : Object { + void init(); +}; + +} + +struct Atomics : Object +{ + V4_OBJECT2(Atomics, Object) + + static ReturnedValue method_add(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_and(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_compareExchange(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_exchange(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isLockFree(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_load(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_or(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_store(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_sub(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_wait(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_wake(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_xor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4baselineassembler_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4baselineassembler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..492e8dfa763f34f33586cded89c12a5205b300ca --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4baselineassembler_p.h @@ -0,0 +1,152 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4BASELINEASSEMBLER_P_H +#define QV4BASELINEASSEMBLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <private/qv4function_p.h> +#include <QHash> + +#if QT_CONFIG(qml_jit) + +QT_BEGIN_NAMESPACE + +namespace QV4 { +namespace JIT { + +#define GENERATE_RUNTIME_CALL(function, destination) \ + callRuntime(reinterpret_cast<void *>(&Runtime::function::call), \ + destination) +#define GENERATE_TAIL_CALL(function) \ + tailCallRuntime(reinterpret_cast<void *>(&function)) + +class BaselineAssembler { +public: + BaselineAssembler(const Value* constantTable); + ~BaselineAssembler(); + + // codegen infrastructure + void generatePrologue(); + void generateEpilogue(); + void link(Function *function); + void addLabel(int offset); + + // loads/stores/moves + void loadConst(int constIndex); + void copyConst(int constIndex, int destReg); + void loadReg(int reg); + void moveReg(int sourceReg, int destReg); + void storeReg(int reg); + void loadLocal(int index, int level = 0); + void storeLocal(int index, int level = 0); + void loadString(int stringId); + void loadValue(ReturnedValue value); + void storeHeapObject(int reg); + void loadImport(int index); + + // numeric ops + void unot(); + void toNumber(); + void uminus(); + void ucompl(); + void inc(); + void dec(); + void add(int lhs); + void bitAnd(int lhs); + void bitOr(int lhs); + void bitXor(int lhs); + void ushr(int lhs); + void shr(int lhs); + void shl(int lhs); + void bitAndConst(int rhs); + void bitOrConst(int rhs); + void bitXorConst(int rhs); + void ushrConst(int rhs); + void shrConst(int rhs); + void shlConst(int rhs); + void mul(int lhs); + void div(int lhs); + void mod(int lhs); + void sub(int lhs); + + // comparissons + void cmpeqNull(); + void cmpneNull(); + void cmpeqInt(int lhs); + void cmpneInt(int lhs); + void cmpeq(int lhs); + void cmpne(int lhs); + void cmpgt(int lhs); + void cmpge(int lhs); + void cmplt(int lhs); + void cmple(int lhs); + void cmpStrictEqual(int lhs); + void cmpStrictNotEqual(int lhs); + + // jumps + Q_REQUIRED_RESULT int jump(int offset); + Q_REQUIRED_RESULT int jumpTrue(int offset); + Q_REQUIRED_RESULT int jumpFalse(int offset); + Q_REQUIRED_RESULT int jumpNoException(int offset); + Q_REQUIRED_RESULT int jumpNotUndefined(int offset); + Q_REQUIRED_RESULT int jumpEqNull(int offset); + + // stuff for runtime calls + void prepareCallWithArgCount(int argc); + void storeInstructionPointer(int instructionOffset); + void passAccumulatorAsArg(int arg); + void passFunctionAsArg(int arg); + void passEngineAsArg(int arg); + void passJSSlotAsArg(int reg, int arg); + void passCppFrameAsArg(int arg); + void passInt32AsArg(int value, int arg); + void passPointerAsArg(void *ptr, int arg); + void callRuntime(const void *funcPtr, CallResultDestination dest); + void saveAccumulatorInFrame(); + void loadAccumulatorFromFrame(); + void jsTailCall(int func, int thisObject, int argc, int argv); + + // exception/context stuff + void checkException(); + void gotoCatchException(); + void getException(); + void setException(); + Q_REQUIRED_RESULT int setUnwindHandler(int offset); + void clearUnwindHandler(); + void unwindDispatch(); + Q_REQUIRED_RESULT int unwindToLabel(int level, int offset); + void pushCatchContext(int index, int name); + void popContext(); + void deadTemporalZoneCheck(int offsetForSavedIP, int variableName); + + // other stuff + void ret(); + +protected: + void *d; + +private: + typedef unsigned(*CmpFunc)(const Value&,const Value&); + void cmp(int cond, CmpFunc function, int lhs); +}; + +} // namespace JIT +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QT_CONFIG(qml_jit) + +#endif // QV4BASELINEASSEMBLER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4baselinejit_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4baselinejit_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bb43991a66af2e48aa2331384d5ee49c670c7742 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4baselinejit_p.h @@ -0,0 +1,192 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4JIT_P_H +#define QV4JIT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <private/qv4function_p.h> +#include <private/qv4instr_moth_p.h> +#include <private/qv4bytecodehandler_p.h> +#include <QtCore/qset.h> + +#if QT_CONFIG(qml_jit) + +QT_BEGIN_NAMESPACE + +namespace QV4 { +namespace JIT { + +class BaselineAssembler; + +class BaselineJIT final: public Moth::ByteCodeHandler +{ +public: + Q_AUTOTEST_EXPORT BaselineJIT(QV4::Function *); + Q_AUTOTEST_EXPORT ~BaselineJIT() override; + + Q_AUTOTEST_EXPORT void generate(); + + void generate_Ret() override; + void generate_Debug() override; + void generate_LoadConst(int index) override; + void generate_LoadZero() override; + void generate_LoadTrue() override; + void generate_LoadFalse() override; + void generate_LoadNull() override; + void generate_LoadUndefined() override; + void generate_LoadInt(int value) override; + void generate_MoveConst(int constIndex, int destTemp) override; + void generate_LoadReg(int reg) override; + void generate_StoreReg(int reg) override; + void generate_MoveReg(int srcReg, int destReg) override; + void generate_LoadImport(int index) override; + void generate_LoadLocal(int index) override; + void generate_StoreLocal(int index) override; + void generate_LoadScopedLocal(int scope, int index) override; + void generate_StoreScopedLocal(int scope, int index) override; + void generate_LoadRuntimeString(int stringId) override; + void generate_MoveRegExp(int regExpId, int destReg) override; + void generate_LoadClosure(int value) override; + void generate_LoadName(int name) override; + void generate_LoadGlobalLookup(int index) override; + void generate_LoadQmlContextPropertyLookup(int index) override; + void generate_StoreNameSloppy(int name) override; + void generate_StoreNameStrict(int name) override; + void generate_LoadElement(int base) override; + void generate_StoreElement(int base, int index) override; + void generate_LoadProperty(int name) override; + void generate_LoadOptionalProperty(int name, int offset) override; + void generate_GetLookup(int index) override; + void generate_GetOptionalLookup(int index, int offset) override; + void generate_StoreProperty(int name, int base) override; + void generate_SetLookup(int index, int base) override; + void generate_LoadSuperProperty(int property) override; + void generate_StoreSuperProperty(int property) override; + void generate_Yield() override; + void generate_YieldStar() override; + void generate_Resume(int) override; + + void generate_CallValue(int name, int argc, int argv) override; + void generate_CallWithReceiver(int name, int thisObject, int argc, int argv) override; + void generate_CallProperty(int name, int base, int argc, int argv) override; + void generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv) override; + void generate_CallName(int name, int argc, int argv) override; + void generate_CallPossiblyDirectEval(int argc, int argv) override; + void generate_CallGlobalLookup(int index, int argc, int argv) override; + void generate_CallQmlContextPropertyLookup(int index, int argc, int argv) override; + void generate_CallWithSpread(int func, int thisObject, int argc, int argv) override; + void generate_TailCall(int func, int thisObject, int argc, int argv) override; + void generate_Construct(int func, int argc, int argv) override; + void generate_ConstructWithSpread(int func, int argc, int argv) override; + void generate_SetUnwindHandler(int offset) override; + void generate_UnwindDispatch() override; + void generate_UnwindToLabel(int level, int offset) override; + void generate_DeadTemporalZoneCheck(int name) override; + void generate_ThrowException() override; + void generate_GetException() override; + void generate_SetException() override; + void generate_CreateCallContext() override; + void generate_PushCatchContext(int index, int name) override; + void generate_PushWithContext() override; + void generate_PushBlockContext(int index) override; + void generate_CloneBlockContext() override; + void generate_PushScriptContext(int index) override; + void generate_PopScriptContext() override; + void generate_PopContext() override; + void generate_GetIterator(int iterator) override; + void generate_IteratorNext(int value, int offset) override; + void generate_IteratorNextForYieldStar(int iterator, int object, int offset) override; + void generate_IteratorClose() override; + void generate_DestructureRestElement() override; + void generate_DeleteProperty(int base, int index) override; + void generate_DeleteName(int name) override; + void generate_TypeofName(int name) override; + void generate_TypeofValue() override; + void generate_DeclareVar(int varName, int isDeletable) override; + void generate_DefineArray(int argc, int args) override; + void generate_DefineObjectLiteral(int internalClassId, int argc, int args) override; + void generate_CreateClass(int classIndex, int heritage, int computedNames) override; + void generate_CreateMappedArgumentsObject() override; + void generate_CreateUnmappedArgumentsObject() override; + void generate_CreateRestParameter(int argIndex) override; + void generate_ConvertThisToObject() override; + void generate_LoadSuperConstructor() override; + void generate_ToObject() override; + void generate_Jump(int offset) override; + void generate_JumpTrue(int offset) override; + void generate_JumpFalse(int offset) override; + void generate_JumpNoException(int offset) override; + void generate_JumpNotUndefined(int offset) override; + void generate_CheckException() override; + void generate_CmpEqNull() override; + void generate_CmpNeNull() override; + void generate_CmpEqInt(int lhs) override; + void generate_CmpNeInt(int lhs) override; + void generate_CmpEq(int lhs) override; + void generate_CmpNe(int lhs) override; + void generate_CmpGt(int lhs) override; + void generate_CmpGe(int lhs) override; + void generate_CmpLt(int lhs) override; + void generate_CmpLe(int lhs) override; + void generate_CmpStrictEqual(int lhs) override; + void generate_CmpStrictNotEqual(int lhs) override; + void generate_CmpIn(int lhs) override; + void generate_CmpInstanceOf(int lhs) override; + void generate_As(int lhs) override; + void generate_UNot() override; + void generate_UPlus() override; + void generate_UMinus() override; + void generate_UCompl() override; + void generate_Increment() override; + void generate_Decrement() override; + void generate_Add(int lhs) override; + void generate_BitAnd(int lhs) override; + void generate_BitOr(int lhs) override; + void generate_BitXor(int lhs) override; + void generate_UShr(int lhs) override; + void generate_Shr(int lhs) override; + void generate_Shl(int lhs) override; + void generate_BitAndConst(int rhs) override; + void generate_BitOrConst(int rhs) override; + void generate_BitXorConst(int rhs) override; + void generate_UShrConst(int rhs) override; + void generate_ShrConst(int rhs) override; + void generate_ShlConst(int rhs) override; + void generate_Exp(int lhs) override; + void generate_Mul(int lhs) override; + void generate_Div(int lhs) override; + void generate_Mod(int lhs) override; + void generate_Sub(int lhs) override; + void generate_InitializeBlockDeadTemporalZone(int firstReg, int count) override; + void generate_ThrowOnNullOrUndefined() override; + void generate_GetTemplateObject(int index) override; + + Verdict startInstruction(Moth::Instr::Type instr) override; + void endInstruction(Moth::Instr::Type instr) override; + +private: + QV4::Function *function; + QScopedPointer<BaselineAssembler> as; + QSet<int> labels; +}; + +} // namespace JIT +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QT_CONFIG(qml_jit) + +#endif // QV4JIT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4booleanobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4booleanobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..75e8179fb23ce5a0b2350aefcf54d6a14869697b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4booleanobject_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4BOOLEANOBJECT_H +#define QV4BOOLEANOBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" +#include <QtCore/qnumeric.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct BooleanCtor : FunctionObject { + void init(ExecutionEngine *engine); +}; + +} + +struct BooleanCtor: FunctionObject +{ + V4_OBJECT2(BooleanCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct BooleanPrototype: BooleanObject +{ + V4_PROTOTYPE(objectPrototype) + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + + +} + +QT_END_NAMESPACE + +#endif // QV4ECMAOBJECTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4bytecodegenerator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4bytecodegenerator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..930c490d67f40af97b68a7c60e68a4eaf813e5cb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4bytecodegenerator_p.h @@ -0,0 +1,321 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4BYTECODEGENERATOR_P_H +#define QV4BYTECODEGENERATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +#include <private/qv4instr_moth_p.h> +#include <private/qv4compileddata_p.h> +#include <private/qv4compilercontext_p.h> +#include <private/qqmljssourcelocation_p.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +class SourceLocation; +} + +namespace QV4 { + +namespace Compiler { +struct Context; +} + +namespace Moth { + +class BytecodeGenerator { +public: + BytecodeGenerator(int line, bool debug, bool storeSourceLocation = false) + : startLine(line), debugMode(debug) + { + if (storeSourceLocation) + m_sourceLocationTable.reset(new QV4::Compiler::Context::SourceLocationTable {}); + } + + struct Label { + enum LinkMode { + LinkNow, + LinkLater + }; + Label() = default; + Label(BytecodeGenerator *generator, LinkMode mode = LinkNow) + : generator(generator), + index(generator->labels.size()) { + generator->labels.append(-1); + if (mode == LinkNow) + link(); + } + + void link() const { + Q_ASSERT(index >= 0); + Q_ASSERT(generator->labels[index] == -1); + generator->labels[index] = generator->instructions.size(); + generator->clearLastInstruction(); + } + bool isValid() const { return generator != nullptr; } + + BytecodeGenerator *generator = nullptr; + int index = -1; + }; + + struct Jump { + Jump(BytecodeGenerator *generator, int instruction) + : generator(generator), + index(instruction) + { Q_ASSERT(generator && index != -1); } + + ~Jump() { + Q_ASSERT(index == -1 || generator->instructions[index].linkedLabel != -1); // make sure link() got called + } + + Jump(Jump &&j) { + std::swap(generator, j.generator); + std::swap(index, j.index); + } + + BytecodeGenerator *generator = nullptr; + int index = -1; + + void link() { + link(generator->label()); + } + void link(Label l) { + Q_ASSERT(l.index >= 0); + Q_ASSERT(generator->instructions[index].linkedLabel == -1); + generator->instructions[index].linkedLabel = l.index; + } + + private: + // make this type move-only: + Q_DISABLE_COPY(Jump) + // we never move-assign this type anywhere, so disable it: + Jump &operator=(Jump &&) = delete; + }; + + struct ExceptionHandler : public Label { + ExceptionHandler() = default; + ExceptionHandler(BytecodeGenerator *generator) + : Label(generator, LinkLater) + { + } + ~ExceptionHandler() + { + Q_ASSERT(!generator || generator->currentExceptionHandler != this); + } + bool isValid() const { return generator != nullptr; } + }; + + Label label() { + return Label(this, Label::LinkNow); + } + + Label newLabel() { + return Label(this, Label::LinkLater); + } + + ExceptionHandler newExceptionHandler() { + return ExceptionHandler(this); + } + + template<int InstrT> + void addInstruction(const InstrData<InstrT> &data) + { + Instr genericInstr; + InstrMeta<InstrT>::setData(genericInstr, data); + addInstructionHelper(Moth::Instr::Type(InstrT), genericInstr); + } + + Q_REQUIRED_RESULT Jump jump() + { +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // broken gcc warns about Instruction::Debug() + Instruction::Jump data; + return addJumpInstruction(data); +QT_WARNING_POP + } + + Q_REQUIRED_RESULT Jump jumpTrue() + { + return addJumpInstruction(Instruction::JumpTrue()); + } + + Q_REQUIRED_RESULT Jump jumpFalse() + { + return addJumpInstruction(Instruction::JumpFalse()); + } + + Q_REQUIRED_RESULT Jump jumpNotUndefined() + { + Instruction::JumpNotUndefined data{}; + return addJumpInstruction(data); + } + + Q_REQUIRED_RESULT Jump jumpNoException() + { + Instruction::JumpNoException data{}; + return addJumpInstruction(data); + } + + Q_REQUIRED_RESULT Jump jumpOptionalLookup(int index) + { + Instruction::GetOptionalLookup data{}; + data.index = index; + return addJumpInstruction(data); + } + + Q_REQUIRED_RESULT Jump jumpOptionalProperty(int name) + { + Instruction::LoadOptionalProperty data{}; + data.name = name; + return addJumpInstruction(data); + } + + void jumpStrictEqual(const StackSlot &lhs, const Label &target) + { + Instruction::CmpStrictEqual cmp; + cmp.lhs = lhs; + addInstruction(std::move(cmp)); + addJumpInstruction(Instruction::JumpTrue()).link(target); + } + + void jumpStrictNotEqual(const StackSlot &lhs, const Label &target) + { + Instruction::CmpStrictNotEqual cmp; + cmp.lhs = lhs; + addInstruction(std::move(cmp)); + addJumpInstruction(Instruction::JumpTrue()).link(target); + } + + void checkException() + { + Instruction::CheckException chk; + addInstruction(chk); + } + + void setUnwindHandler(ExceptionHandler *handler) + { + currentExceptionHandler = handler; + Instruction::SetUnwindHandler data; + data.offset = 0; + if (!handler) + addInstruction(data); + else + addJumpInstruction(data).link(*handler); + } + + void unwindToLabel(int level, const Label &target) + { + if (level) { + Instruction::UnwindToLabel unwind; + unwind.level = level; + addJumpInstruction(unwind).link(target); + } else { + jump().link(target); + } + } + + + + void setLocation(const QQmlJS::SourceLocation &loc); + void incrementStatement(); + + ExceptionHandler *exceptionHandler() const { + return currentExceptionHandler; + } + + int newRegister(); + int newRegisterArray(int n); + int registerCount() const { return regCount; } + int currentRegister() const { return currentReg; } + + void finalize(Compiler::Context *context); + + template<int InstrT> + Jump addJumpInstruction(const InstrData<InstrT> &data) + { + Instr genericInstr; + InstrMeta<InstrT>::setData(genericInstr, data); + return Jump(this, addInstructionHelper(Moth::Instr::Type(InstrT), genericInstr, offsetof(InstrData<InstrT>, offset))); + } + + void addCJumpInstruction(bool jumpOnFalse, const Label *trueLabel, const Label *falseLabel) + { + if (jumpOnFalse) + addJumpInstruction(Instruction::JumpFalse()).link(*falseLabel); + else + addJumpInstruction(Instruction::JumpTrue()).link(*trueLabel); + } + + void clearLastInstruction() + { + lastInstrType = -1; + } + + void addLoopStart(const Label &start) + { + _labelInfos.push_back({ start.index }); + } + +private: + friend struct Jump; + friend struct Label; + friend struct ExceptionHandler; + + int addInstructionHelper(Moth::Instr::Type type, const Instr &i, int offsetOfOffset = -1); + + struct I { + Moth::Instr::Type type; + short size; + uint position; + int line; + int statement; + int offsetForJump; + int linkedLabel; + unsigned char packed[sizeof(Instr) + 2]; // 2 for instruction type + }; + + void compressInstructions(); + void packInstruction(I &i); + void adjustJumpOffsets(); + + QVector<I> instructions; + QVector<int> labels; + ExceptionHandler *currentExceptionHandler = nullptr; + int regCount = 0; +public: + int currentReg = 0; +private: + int startLine = 0; + int currentLine = 0; + int currentStatement = 0; + QQmlJS::SourceLocation currentSourceLocation; + std::unique_ptr<QV4::Compiler::Context::SourceLocationTable> m_sourceLocationTable; + bool debugMode = false; + + int lastInstrType = -1; + Moth::Instr lastInstr; + + struct LabelInfo { + int labelIndex; + }; + std::vector<LabelInfo> _labelInfos; +}; + +} +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4bytecodehandler_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4bytecodehandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a275c467336833c3873621f2161b192fdcaa9a2f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4bytecodehandler_p.h @@ -0,0 +1,91 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4BYTECODEHANDLER_P_H +#define QV4BYTECODEHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlcompilerglobal_p.h> +#include <private/qv4instr_moth_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { +namespace Moth { + +#define BYTECODE_HANDLER_DEFINE_ARGS(nargs, ...) \ + MOTH_EXPAND_FOR_MSVC(BYTECODE_HANDLER_DEFINE_ARGS##nargs(__VA_ARGS__)) + +#define BYTECODE_HANDLER_DEFINE_ARGS0() +#define BYTECODE_HANDLER_DEFINE_ARGS1(arg) \ + int arg +#define BYTECODE_HANDLER_DEFINE_ARGS2(arg1, arg2) \ + int arg1, \ + int arg2 +#define BYTECODE_HANDLER_DEFINE_ARGS3(arg1, arg2, arg3) \ + int arg1, \ + int arg2, \ + int arg3 +#define BYTECODE_HANDLER_DEFINE_ARGS4(arg1, arg2, arg3, arg4) \ + int arg1, \ + int arg2, \ + int arg3, \ + int arg4 +#define BYTECODE_HANDLER_DEFINE_ARGS5(arg1, arg2, arg3, arg4, arg5) \ + int arg1, \ + int arg2, \ + int arg3, \ + int arg4, \ + int arg5 + +#define BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER_INSTRUCTION(name, nargs, ...) \ + virtual void generate_##name( \ + BYTECODE_HANDLER_DEFINE_ARGS(nargs, __VA_ARGS__) \ + ) = 0; + +#define BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER(instr) \ + INSTR_##instr(BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER) + +class Q_QML_COMPILER_EXPORT ByteCodeHandler +{ + Q_DISABLE_COPY_MOVE(ByteCodeHandler) +public: + ByteCodeHandler() = default; + virtual ~ByteCodeHandler(); + + void decode(const char *code, uint len); + void reset() { _currentOffset = _nextOffset = 0; } + + int currentInstructionOffset() const { return _currentOffset; } + int nextInstructionOffset() const { return _nextOffset; } + int absoluteOffset(int relativeOffset) const + { return nextInstructionOffset() + relativeOffset; } + +protected: + FOR_EACH_MOTH_INSTR(BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER) + + enum Verdict { ProcessInstruction, SkipInstruction }; + virtual Verdict startInstruction(Moth::Instr::Type instr) = 0; + virtual void endInstruction(Moth::Instr::Type instr) = 0; + +private: + int _currentOffset = 0; + int _nextOffset = 0; +}; + +} // Moth namespace +} // QV4 namespace + +QT_END_NAMESPACE + +#endif // QV4BYTECODEHANDLER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4calldata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4calldata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..05c5acae078afb3d9b8507b9be784c956fd76f9a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4calldata_p.h @@ -0,0 +1,87 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4CALLDATA_P_H +#define QV4CALLDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4staticvalue_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct CallData +{ + enum Offsets { + Function = 0, + Context = 1, + Accumulator = 2, + This = 3, + NewTarget = 4, + Argc = 5, + + LastOffset = Argc, + OffsetCount = LastOffset + 1 + }; + + StaticValue function; + StaticValue context; + StaticValue accumulator; + StaticValue thisObject; + StaticValue newTarget; + StaticValue _argc; + + int argc() const { + Q_ASSERT(_argc.isInteger()); + return _argc.int_32(); + } + + void setArgc(int argc) { + Q_ASSERT(argc >= 0); + _argc.setInt_32(argc); + } + + inline ReturnedValue argument(int i) const { + return i < argc() ? args[i].asReturnedValue() + : StaticValue::undefinedValue().asReturnedValue(); + } + + StaticValue args[1]; + + static constexpr int HeaderSize() + { + return offsetof(CallData, args) / sizeof(QV4::StaticValue); + } + + template<typename Value> + Value *argValues(); + + template<typename Value> + const Value *argValues() const; +}; + +Q_STATIC_ASSERT(std::is_standard_layout<CallData>::value); +Q_STATIC_ASSERT(offsetof(CallData, function ) == CallData::Function * sizeof(StaticValue)); +Q_STATIC_ASSERT(offsetof(CallData, context ) == CallData::Context * sizeof(StaticValue)); +Q_STATIC_ASSERT(offsetof(CallData, accumulator) == CallData::Accumulator * sizeof(StaticValue)); +Q_STATIC_ASSERT(offsetof(CallData, thisObject ) == CallData::This * sizeof(StaticValue)); +Q_STATIC_ASSERT(offsetof(CallData, newTarget ) == CallData::NewTarget * sizeof(StaticValue)); +Q_STATIC_ASSERT(offsetof(CallData, _argc ) == CallData::Argc * sizeof(StaticValue)); +Q_STATIC_ASSERT(offsetof(CallData, args ) == 6 * sizeof(StaticValue)); + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4CALLDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4codegen_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4codegen_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e7c4960e829fb1fcca9ba01e433c99a3257aeab4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4codegen_p.h @@ -0,0 +1,871 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4CODEGEN_P_H +#define QV4CODEGEN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmljsastvisitor_p.h> +#include <private/qqmljsengine_p.h> +#include <private/qqmljsast_p.h> +#include <private/qqmljsdiagnosticmessage_p.h> +#include <private/qv4compiler_p.h> +#include <private/qv4compilercontext_p.h> +#include <private/qv4util_p.h> +#include <private/qv4bytecodegenerator_p.h> +#include <private/qv4calldata_p.h> + +#include <QtCore/qsharedpointer.h> +#include <stack> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Moth { +struct Instruction; +} + +namespace CompiledData { +struct CompilationUnit; +} + +namespace Compiler { + +struct ControlFlow; +struct ControlFlowCatch; +struct ControlFlowFinally; + +class Q_QML_COMPILER_EXPORT CodegenWarningInterface +{ +public: + virtual void reportVarUsedBeforeDeclaration(const QString &name, const QString &fileName, + QQmlJS::SourceLocation declarationLocation, + QQmlJS::SourceLocation accessLocation); + virtual ~CodegenWarningInterface() = default; +}; + +inline CodegenWarningInterface *defaultCodegenWarningInterface() +{ + static CodegenWarningInterface iface; + return &iface; +} + +class Q_QML_COMPILER_EXPORT Codegen: protected QQmlJS::AST::Visitor +{ +protected: + using BytecodeGenerator = QV4::Moth::BytecodeGenerator; + using Instruction = QV4::Moth::Instruction; +public: + Codegen(QV4::Compiler::JSUnitGenerator *jsUnitGenerator, bool strict, + CodegenWarningInterface *iface = defaultCodegenWarningInterface(), + bool storeSourceLocations = false); + + void generateFromProgram(const QString &fileName, + const QString &finalUrl, + const QString &sourceCode, + QQmlJS::AST::Program *ast, + Module *module, + ContextType contextType = ContextType::Global); + + void generateFromModule(const QString &fileName, + const QString &finalUrl, + const QString &sourceCode, + QQmlJS::AST::ESModule *ast, + Module *module); + +public: + class VolatileMemoryLocationScanner; + class VolatileMemoryLocations { + friend VolatileMemoryLocationScanner; + bool allVolatile = false; + QList<QStringView> specificLocations; + public: + bool isVolatile(QStringView name) { + if (allVolatile) + return true; + return specificLocations.contains(name); + } + + void add(QStringView name) { if (!allVolatile) specificLocations.append(name); } + void setAllVolatile() { allVolatile = true; } + }; + class RValue { + Codegen *codegen; + enum Type { + Invalid, + Accumulator, + StackSlot, + Const + } type; + union { + Moth::StackSlot theStackSlot; + QV4::ReturnedValue constant; + }; + + public: + static RValue fromStackSlot(Codegen *codegen, Moth::StackSlot stackSlot) { + RValue r; + r.codegen = codegen; + r.type = StackSlot; + r.theStackSlot = stackSlot; + return r; + } + static RValue fromAccumulator(Codegen *codegen) { + RValue r; + r.codegen = codegen; + r.type = Accumulator; + return r; + } + static RValue fromConst(Codegen *codegen, QV4::ReturnedValue value) { + RValue r; + r.codegen = codegen; + r.type = Const; + r.constant = value; + return r; + } + + bool operator==(const RValue &other) const; + + bool isValid() const { return type != Invalid; } + bool isAccumulator() const { return type == Accumulator; } + bool isStackSlot() const { return type == StackSlot; } + bool isConst() const { return type == Const; } + + Moth::StackSlot stackSlot() const { + Q_ASSERT(isStackSlot()); + return theStackSlot; + } + + QV4::ReturnedValue constantValue() const { + Q_ASSERT(isConst()); + return constant; + } + + Q_REQUIRED_RESULT RValue storeOnStack() const; + void loadInAccumulator() const; + }; + struct Reference { + enum Type { + Invalid, + Accumulator, + Super, + SuperProperty, + StackSlot, + ScopedLocal, + Name, + Member, + Subscript, + Import, + LastLValue = Import, + Const + } type = Invalid; + + bool isLValue() const { return !isReadonly && type > Accumulator; } + + Reference(Codegen *cg, Type t = Invalid) : Reference() + { + type = t; + codegen = cg; + } + + Reference(const QString &name = QString()) : + constant(0), + name(name), + isArgOrEval(false), + isReadonly(false), + isReferenceToConst(false), + requiresTDZCheck(false), + subscriptRequiresTDZCheck(false), + stackSlotIsLocalOrArgument(false), + isVolatile(false), + global(false), + qmlGlobal(false), + throwsReferenceError(false), + subscriptLoadedForCall(false), + isOptional(false), + hasSavedCallBaseSlot(false) + {} + + Reference(const Reference &) = default; + Reference(Reference &&) = default; + Reference &operator =(const Reference &) = default; + Reference &operator =(Reference &&) = default; + + bool operator==(const Reference &other) const; + bool operator!=(const Reference &other) const + { return !(*this == other); } + + bool isValid() const { return type != Invalid; } + bool loadTriggersSideEffect() const { + switch (type) { + case Name: + case Member: + case Subscript: + case SuperProperty: + return true; + default: + return requiresTDZCheck; + } + } + bool isConstant() const { return type == Const; } + bool isAccumulator() const { return type == Accumulator; } + bool isSuper() const { return type == Super; } + bool isSuperProperty() const { return type == SuperProperty; } + bool isStackSlot() const { return type == StackSlot; } + bool isRegister() const { + return isStackSlot(); + } + + static Reference fromAccumulator(Codegen *cg) { + return Reference(cg, Accumulator); + } + static Reference fromSuper(Codegen *cg) { + return Reference(cg, Super); + } + static Reference fromStackSlot(Codegen *cg, int tempIndex = -1, bool isLocal = false) { + Reference r(cg, StackSlot); + if (tempIndex == -1) + tempIndex = cg->bytecodeGenerator->newRegister(); + r.theStackSlot = Moth::StackSlot::createRegister(tempIndex); + r.stackSlotIsLocalOrArgument = isLocal; + return r; + } + static Reference fromScopedLocal(Codegen *cg, int index, int scope) { + Reference r(cg, ScopedLocal); + r.index = index; + r.scope = scope; + return r; + } + static Reference fromImport(Codegen *cg, int index) { + Reference r(cg, Import); + r.index = index; + return r; + } + static Reference fromName(Codegen *cg, const QString &name) { + Reference r(cg, Name); + r.name = name; + return r; + } + static Reference + fromMember(const Reference &baseRef, const QString &name, + QQmlJS::SourceLocation sourceLocation = QQmlJS::SourceLocation(), + bool isOptional = false, + std::vector<Moth::BytecodeGenerator::Jump> *optionalChainJumpsToPatch = nullptr) + { + Q_ASSERT(baseRef.isValid()); + Reference r(baseRef.codegen, Member); + r.propertyBase = baseRef.asRValue(); + r.propertyNameIndex = r.codegen->registerString(name); + r.requiresTDZCheck = baseRef.requiresTDZCheck; + r.sourceLocation = sourceLocation; + r.optionalChainJumpsToPatch = optionalChainJumpsToPatch; + r.isOptional = isOptional; + return r; + } + static Reference fromSuperProperty(const Reference &property) { + Q_ASSERT(property.isStackSlot()); + Reference r(property.codegen, SuperProperty); + r.property = property.stackSlot(); + r.subscriptRequiresTDZCheck = property.requiresTDZCheck; + return r; + } + static Reference fromSubscript(const Reference &baseRef, const Reference &subscript) { + Q_ASSERT(baseRef.isStackSlot()); + Reference r(baseRef.codegen, Subscript); + r.elementBase = baseRef.stackSlot(); + r.elementSubscript = subscript.asRValue(); + r.requiresTDZCheck = baseRef.requiresTDZCheck; + r.subscriptRequiresTDZCheck = subscript.requiresTDZCheck; + return r; + } + static Reference fromConst(Codegen *cg, QV4::ReturnedValue constant) { + Reference r(cg, Const); + r.constant = constant; + r.isReadonly = true; + return r; + } + static Reference fromThis(Codegen *cg) { + Reference r = fromStackSlot(cg, CallData::This); + r.isReadonly = true; + // ### Optimize this. Functions that are not derived constructors or arrow functions can't have an + // empty this object + r.requiresTDZCheck = true; + return r; + } + + RValue asRValue() const; + Reference asLValue() const; + + Q_REQUIRED_RESULT static Reference storeConstOnStack(Codegen *cg, QV4::ReturnedValue constant) + { return Reference::fromConst(cg, constant).storeOnStack(); } + + static void storeConstOnStack(Codegen *cg, QV4::ReturnedValue constant, int stackSlot) + { Reference::fromConst(cg, constant).storeOnStack(stackSlot); } + + Q_REQUIRED_RESULT Reference storeOnStack() const; + void storeOnStack(int tempIndex) const; + Q_REQUIRED_RESULT Reference storeRetainAccumulator() const; + Reference storeConsumeAccumulator() const; + + Q_REQUIRED_RESULT Reference baseObject() const; + + bool storeWipesAccumulator() const; + void loadInAccumulator() const; + + int nameAsIndex() const { + Q_ASSERT(type == Name); + return codegen->registerString(name); + } + + Moth::StackSlot stackSlot() const { + if (Q_UNLIKELY(!isStackSlot())) + Q_UNREACHABLE(); + return theStackSlot; + } + + void tdzCheck() const + { + if (isAccumulator()) + tdzCheck(requiresTDZCheck, throwsReferenceError); + else if (isStackSlot()) + tdzCheckStackSlot(stackSlot(), requiresTDZCheck, throwsReferenceError); + } + + union { + Moth::StackSlot theStackSlot; + QV4::ReturnedValue constant; + struct { // Scoped arguments/Local + int index; + int scope; + }; + struct { + RValue propertyBase; + int propertyNameIndex; + }; + struct { + Moth::StackSlot elementBase; + union { + RValue elementSubscript; + Moth::StackSlot element; + }; + }; + Moth::StackSlot property; // super property + }; + QString name; + Codegen *codegen = nullptr; + + quint32 isArgOrEval:1; + quint32 isReadonly:1; + quint32 isReferenceToConst:1; + quint32 requiresTDZCheck:1; + quint32 subscriptRequiresTDZCheck:1; + quint32 stackSlotIsLocalOrArgument:1; + quint32 isVolatile:1; + quint32 global:1; + quint32 qmlGlobal:1; + quint32 throwsReferenceError:1; + quint32 subscriptLoadedForCall:1; + quint32 isOptional: 1; + quint32 hasSavedCallBaseSlot: 1; + QQmlJS::SourceLocation sourceLocation = QQmlJS::SourceLocation(); + std::vector<Moth::BytecodeGenerator::Jump> *optionalChainJumpsToPatch = nullptr; + int savedCallBaseSlot = -1; + int savedCallPropertyNameIndex = -1; + + private: + void storeAccumulator() const; + Reference doStoreOnStack(int tempIndex) const; + void tdzCheck(bool requiresCheck, bool throwsReferenceError) const; + void tdzCheckStackSlot( + Moth::StackSlot slot, bool requiresCheck, bool throwsReferenceError) const; + }; + + struct RegisterScope { + RegisterScope(Codegen *cg) + : generator(cg->bytecodeGenerator), + regCountForScope(generator->currentReg) {} + ~RegisterScope() { + generator->currentReg = regCountForScope; + } + BytecodeGenerator *generator; + int regCountForScope; + }; + + struct ObjectPropertyValue { + ObjectPropertyValue() {} + + Reference rvalue; + int getter = -1; // index in _module->functions or -1 if not set + int setter = -1; + uint keyAsIndex = UINT_MAX; + + bool hasGetter() const { return getter >= 0; } + bool hasSetter() const { return setter >= 0; } + }; +protected: + + enum Format { ex, cx, nx }; + class Result { + Reference _result; + + const BytecodeGenerator::Label *_iftrue = nullptr; + const BytecodeGenerator::Label *_iffalse = nullptr; + Format _format = ex; + Format _requested; + bool _trueBlockFollowsCondition = false; + + public: + explicit Result(const QString &name) + : _result(name) + , _requested(ex) + {} + + explicit Result(const Reference &lrvalue) + : _result(lrvalue) + , _requested(ex) + {} + + explicit Result(Format requested = ex) + : _requested(requested) {} + + explicit Result(const BytecodeGenerator::Label *iftrue, + const BytecodeGenerator::Label *iffalse, + bool trueBlockFollowsCondition) + : _iftrue(iftrue) + , _iffalse(iffalse) + , _requested(cx) + , _trueBlockFollowsCondition(trueBlockFollowsCondition) + { + Q_ASSERT(iftrue); + Q_ASSERT(iffalse); + } + + const BytecodeGenerator::Label *iftrue() const { + Q_ASSERT(_requested == cx); + return _iftrue; + } + + const BytecodeGenerator::Label *iffalse() const { + Q_ASSERT(_requested == cx); + return _iffalse; + } + + Format format() const { + return _format; + } + + bool accept(Format f) + { + if (_requested == f) { + _format = f; + return true; + } + return false; + } + + bool trueBlockFollowsCondition() const { + return _trueBlockFollowsCondition; + } + + const Reference &result() const { + return _result; + } + + void setResult(const Reference &result) { + _result = result; + } + + void setResult(Reference &&result) { + _result = std::move(result); + } + + void clearResultName() { + _result.name.clear(); + } + }; + + void enterContext(QQmlJS::AST::Node *node); + int leaveContext(); +public: + Context *enterBlock(QQmlJS::AST::Node *node); + int leaveBlock() { return leaveContext(); } +protected: + void leaveLoop(); + + enum UnaryOperation { + UPlus, + UMinus, + PreIncrement, + PreDecrement, + PostIncrement, + PostDecrement, + Not, + Compl + }; + + Reference unop(UnaryOperation op, const Reference &expr); + + void addCJump(); + +public: + int registerString(const QString &name) { + return jsUnitGenerator->registerString(name); + } + int registerConstant(QV4::ReturnedValue v) + { + return jsUnitGenerator->registerConstant(v); + } + int registerGetterLookup(int nameIndex, JSUnitGenerator::LookupMode mode) + { + return jsUnitGenerator->registerGetterLookup(nameIndex, mode); + } + int registerSetterLookup(int nameIndex) + { + return jsUnitGenerator->registerSetterLookup(nameIndex); + } + int registerGlobalGetterLookup(int nameIndex, JSUnitGenerator::LookupMode mode) + { + return jsUnitGenerator->registerGlobalGetterLookup(nameIndex, mode); + } + int registerQmlContextPropertyGetterLookup(int nameIndex, JSUnitGenerator::LookupMode mode) + { + return jsUnitGenerator->registerQmlContextPropertyGetterLookup(nameIndex, mode); + } + + // Returns index in _module->functions + virtual int defineFunction(const QString &name, QQmlJS::AST::Node *ast, + QQmlJS::AST::FormalParameterList *formals, + QQmlJS::AST::StatementList *body); + +protected: + void statement(QQmlJS::AST::Statement *ast); + void statement(QQmlJS::AST::ExpressionNode *ast); + void condition(QQmlJS::AST::ExpressionNode *ast, const BytecodeGenerator::Label *iftrue, + const BytecodeGenerator::Label *iffalse, + bool trueBlockFollowsCondition); + + inline Reference expression(QQmlJS::AST::ExpressionNode *ast, const QString &name = QString()) + { + if (!ast || hasError()) + return Reference(); + + pushExpr(name); + ast->accept(this); + return popResult(); + } + + inline void accept(QQmlJS::AST::Node *node) + { + if (!hasError() && node) + node->accept(this); + } + + void program(QQmlJS::AST::Program *ast); + void statementList(QQmlJS::AST::StatementList *ast); + void variableDeclaration(QQmlJS::AST::PatternElement *ast); + void variableDeclarationList(QQmlJS::AST::VariableDeclarationList *ast); + + Reference targetForPatternElement(QQmlJS::AST::PatternElement *p); + void initializeAndDestructureBindingElement(QQmlJS::AST::PatternElement *e, const Reference &baseRef = Reference(), bool isDefinition = false); + void destructurePropertyList(const Reference &object, QQmlJS::AST::PatternPropertyList *bindingList, bool isDefinition = false); + void destructureElementList(const Reference &array, QQmlJS::AST::PatternElementList *bindingList, bool isDefinition = false); + void destructurePattern(QQmlJS::AST::Pattern *p, const Reference &rhs); + + Reference referenceForPropertyName(const Codegen::Reference &object, QQmlJS::AST::PropertyName *name); + + void emitReturn(const Reference &expr); + + // nodes + bool visit(QQmlJS::AST::ArgumentList *ast) override; + bool visit(QQmlJS::AST::CaseBlock *ast) override; + bool visit(QQmlJS::AST::CaseClause *ast) override; + bool visit(QQmlJS::AST::CaseClauses *ast) override; + bool visit(QQmlJS::AST::Catch *ast) override; + bool visit(QQmlJS::AST::DefaultClause *ast) override; + bool visit(QQmlJS::AST::Elision *ast) override; + bool visit(QQmlJS::AST::Finally *ast) override; + bool visit(QQmlJS::AST::FormalParameterList *ast) override; + bool visit(QQmlJS::AST::Program *ast) override; + bool visit(QQmlJS::AST::StatementList *ast) override; + bool visit(QQmlJS::AST::UiArrayMemberList *ast) override; + bool visit(QQmlJS::AST::UiImport *ast) override; + bool visit(QQmlJS::AST::UiHeaderItemList *ast) override; + bool visit(QQmlJS::AST::UiPragmaValueList *ast) override; + bool visit(QQmlJS::AST::UiPragma *ast) override; + bool visit(QQmlJS::AST::UiObjectInitializer *ast) override; + bool visit(QQmlJS::AST::UiObjectMemberList *ast) override; + bool visit(QQmlJS::AST::UiParameterList *ast) override; + bool visit(QQmlJS::AST::UiProgram *ast) override; + bool visit(QQmlJS::AST::UiQualifiedId *ast) override; + bool visit(QQmlJS::AST::VariableDeclarationList *ast) override; + + bool visit(QQmlJS::AST::PatternElement *ast) override; + bool visit(QQmlJS::AST::PatternElementList *ast) override; + bool visit(QQmlJS::AST::PatternProperty *ast) override; + bool visit(QQmlJS::AST::PatternPropertyList *ast) override; + + bool visit(QQmlJS::AST::ExportDeclaration *ast) override; + + bool visit(QQmlJS::AST::TypeAnnotation *ast) override; + + // expressions + bool visit(QQmlJS::AST::Expression *ast) override; + bool visit(QQmlJS::AST::ArrayPattern *ast) override; + bool visit(QQmlJS::AST::ArrayMemberExpression *ast) override; + bool visit(QQmlJS::AST::BinaryExpression *ast) override; + bool visit(QQmlJS::AST::CallExpression *ast) override; + void endVisit(QQmlJS::AST::CallExpression *ast) override; + bool visit(QQmlJS::AST::ConditionalExpression *ast) override; + bool visit(QQmlJS::AST::DeleteExpression *ast) override; + void endVisit(QQmlJS::AST::DeleteExpression *ast) override; + bool visit(QQmlJS::AST::FalseLiteral *ast) override; + bool visit(QQmlJS::AST::SuperLiteral *ast) override; + bool visit(QQmlJS::AST::FieldMemberExpression *ast) override; + void endVisit(QQmlJS::AST::FieldMemberExpression *ast) override; + bool visit(QQmlJS::AST::TaggedTemplate *ast) override; + bool visit(QQmlJS::AST::FunctionExpression *ast) override; + bool visit(QQmlJS::AST::IdentifierExpression *ast) override; + bool visit(QQmlJS::AST::NestedExpression *ast) override; + bool visit(QQmlJS::AST::NewExpression *ast) override; + bool visit(QQmlJS::AST::NewMemberExpression *ast) override; + bool visit(QQmlJS::AST::NotExpression *ast) override; + bool visit(QQmlJS::AST::NullExpression *ast) override; + bool visit(QQmlJS::AST::NumericLiteral *ast) override; + bool visit(QQmlJS::AST::ObjectPattern *ast) override; + bool visit(QQmlJS::AST::PostDecrementExpression *ast) override; + bool visit(QQmlJS::AST::PostIncrementExpression *ast) override; + bool visit(QQmlJS::AST::PreDecrementExpression *ast) override; + bool visit(QQmlJS::AST::PreIncrementExpression *ast) override; + bool visit(QQmlJS::AST::RegExpLiteral *ast) override; + bool visit(QQmlJS::AST::StringLiteral *ast) override; + bool visit(QQmlJS::AST::TemplateLiteral *ast) override; + bool visit(QQmlJS::AST::ThisExpression *ast) override; + bool visit(QQmlJS::AST::TildeExpression *ast) override; + bool visit(QQmlJS::AST::TrueLiteral *ast) override; + bool visit(QQmlJS::AST::TypeOfExpression *ast) override; + bool visit(QQmlJS::AST::UnaryMinusExpression *ast) override; + bool visit(QQmlJS::AST::UnaryPlusExpression *ast) override; + bool visit(QQmlJS::AST::VoidExpression *ast) override; + bool visit(QQmlJS::AST::FunctionDeclaration *ast) override; + bool visit(QQmlJS::AST::YieldExpression *ast) override; + bool visit(QQmlJS::AST::ClassExpression *ast) override; + bool visit(QQmlJS::AST::ClassDeclaration *ast) override; + + // statements + bool visit(QQmlJS::AST::Block *ast) override; + bool visit(QQmlJS::AST::BreakStatement *ast) override; + bool visit(QQmlJS::AST::ContinueStatement *ast) override; + bool visit(QQmlJS::AST::DebuggerStatement *ast) override; + bool visit(QQmlJS::AST::DoWhileStatement *ast) override; + bool visit(QQmlJS::AST::EmptyStatement *ast) override; + bool visit(QQmlJS::AST::ExpressionStatement *ast) override; + bool visit(QQmlJS::AST::ForEachStatement *ast) override; + bool visit(QQmlJS::AST::ForStatement *ast) override; + bool visit(QQmlJS::AST::IfStatement *ast) override; + bool visit(QQmlJS::AST::LabelledStatement *ast) override; + bool visit(QQmlJS::AST::ReturnStatement *ast) override; + bool visit(QQmlJS::AST::SwitchStatement *ast) override; + bool visit(QQmlJS::AST::ThrowStatement *ast) override; + bool visit(QQmlJS::AST::TryStatement *ast) override; + bool visit(QQmlJS::AST::VariableStatement *ast) override; + bool visit(QQmlJS::AST::WhileStatement *ast) override; + bool visit(QQmlJS::AST::WithStatement *ast) override; + + // ui object members + bool visit(QQmlJS::AST::UiArrayBinding *ast) override; + bool visit(QQmlJS::AST::UiObjectBinding *ast) override; + bool visit(QQmlJS::AST::UiObjectDefinition *ast) override; + bool visit(QQmlJS::AST::UiPublicMember *ast) override; + bool visit(QQmlJS::AST::UiScriptBinding *ast) override; + bool visit(QQmlJS::AST::UiSourceElement *ast) override; + + bool throwSyntaxErrorOnEvalOrArgumentsInStrictMode(const Reference &r, + const QQmlJS::SourceLocation &loc); + virtual void throwSyntaxError(const QQmlJS::SourceLocation &loc, const QString &detail); + virtual void throwReferenceError(const QQmlJS::SourceLocation &loc, const QString &detail); + void throwRecursionDepthError() override + { + throwSyntaxError(QQmlJS::SourceLocation(), + QStringLiteral("Maximum statement or expression depth exceeded")); + } + +public: + enum ErrorType { + NoError, + SyntaxError, + ReferenceError + }; + + ErrorType errorType() const { return _errorType; } + bool hasError() const { return _errorType != NoError; } + QQmlJS::DiagnosticMessage error() const; + QUrl url() const; + + Reference binopHelper(QQmlJS::AST::BinaryExpression *ast, QSOperator::Op oper, Reference &left, + Reference &right); + Reference jumpBinop(QSOperator::Op oper, Reference &left, Reference &right); + struct Arguments { int argc; int argv; bool hasSpread; }; + Arguments pushArgs(QQmlJS::AST::ArgumentList *args); + void handleCall(Reference &base, Arguments calldata, int slotForFunction, int slotForThisObject, bool optional = false); + + Arguments pushTemplateArgs(QQmlJS::AST::TemplateLiteral *args); + bool handleTaggedTemplate(Reference base, QQmlJS::AST::TaggedTemplate *ast); + void createTemplateObject(QQmlJS::AST::TemplateLiteral *t); + + void setUseFastLookups(bool b) { useFastLookups = b; } + + void handleTryCatch(QQmlJS::AST::TryStatement *ast); + void handleTryFinally(QQmlJS::AST::TryStatement *ast); + + + Reference referenceForName( + const QString &name, bool lhs, + const QQmlJS::SourceLocation &accessLocation = QQmlJS::SourceLocation()); + + QQmlRefPointer<QV4::CompiledData::CompilationUnit> generateCompilationUnit( + bool generateUnitData = true); + static QQmlRefPointer<QV4::CompiledData::CompilationUnit> compileModule( + bool debugMode, const QString &url, const QString &sourceCode, + const QDateTime &sourceTimeStamp, QList<QQmlJS::DiagnosticMessage> *diagnostics); + + Context *currentContext() const { return _context; } + BytecodeGenerator *generator() const { return bytecodeGenerator; } + + void loadClosure(int index); + + Module *module() const { return _module; } + + BytecodeGenerator::Label returnLabel() { + if (!_returnLabel) + _returnLabel = new BytecodeGenerator::Label(bytecodeGenerator->newLabel()); + return *_returnLabel; + } + + void setGlobalNames(const QSet<QString>& globalNames) { + m_globalNames = globalNames; + } + + static const char *s_globalNames[]; + +protected: + friend class ScanFunctions; + friend struct ControlFlow; + friend struct ControlFlowCatch; + friend struct ControlFlowFinally; + + inline void setExprResult(const Reference &result) { m_expressions.back().setResult(result); } + inline void setExprResult(Reference &&result) { m_expressions.back().setResult(std::move(result)); } + inline Reference exprResult() const { return m_expressions.back().result(); } + inline void clearExprResultName() { m_expressions.back().clearResultName(); } + + inline bool exprAccept(Format f) { return m_expressions.back().accept(f); } + + inline const Result ¤tExpr() const { return m_expressions.back(); } + + inline void pushExpr(Result &&expr) { m_expressions.push_back(std::move(expr)); } + inline void pushExpr(const Result &expr) { m_expressions.push_back(expr); } + inline void pushExpr(const QString &name = QString()) { m_expressions.emplace_back(name); } + + inline Result popExpr() + { + const Result result = m_expressions.back(); + m_expressions.pop_back(); + return result; + } + + inline Reference popResult() { + const Reference result = m_expressions.back().result(); + m_expressions.pop_back(); + return result; + } + + std::vector<Result> m_expressions; + VolatileMemoryLocations _volatileMemoryLocations; + Module *_module; + int _returnAddress; + Context *_context; + Context *_functionContext = nullptr; + QQmlJS::AST::LabelledStatement *_labelledStatement; + QV4::Compiler::JSUnitGenerator *jsUnitGenerator; + BytecodeGenerator *bytecodeGenerator = nullptr; + Moth::BytecodeGenerator::Label *_returnLabel = nullptr; + bool _strictMode; + bool useFastLookups = true; + bool requiresReturnValue = false; + bool insideSwitch = false; + bool inFormalParameterList = false; + bool functionEndsWithReturn = false; + bool _tailCallsAreAllowed = true; + bool storeSourceLocations = false; + QSet<QString> m_globalNames; + + struct OptionalChainState + { + QQmlJS::AST::Node *tailNodeOfChain = nullptr; + std::vector<Moth::BytecodeGenerator::Jump> jumpsToPatch; + bool actuallyHasOptionals = false; + }; + QSet<QQmlJS::AST::Node*> m_seenOptionalChainNodes; + std::stack<OptionalChainState> m_optionalChainsStates; + + ControlFlow *controlFlow = nullptr; + + bool _fileNameIsUrl; + ErrorType _errorType = NoError; + QQmlJS::DiagnosticMessage _error; + CodegenWarningInterface *_interface; + + class TailCallBlocker + { + public: + TailCallBlocker(Codegen *cg, bool onoff = false) + : _cg(cg) + , _saved(_cg->_tailCallsAreAllowed) + , _onoff(onoff) + { _cg->_tailCallsAreAllowed = onoff; } + + ~TailCallBlocker() + { _cg->_tailCallsAreAllowed = _saved; } + + void unblock() const + { _cg->_tailCallsAreAllowed = _saved; } + + void reblock() const + { _cg->_tailCallsAreAllowed = _onoff; } + + private: + Codegen *_cg; + bool _saved; + bool _onoff; + }; + +private: + Q_DISABLE_COPY(Codegen) + VolatileMemoryLocations scanVolatileMemoryLocations(QQmlJS::AST::Node *ast); + void handleConstruct(const Reference &base, QQmlJS::AST::ArgumentList *args); + void throwError(ErrorType errorType, const QQmlJS::SourceLocation &loc, + const QString &detail); + bool traverseOptionalChain(QQmlJS::AST::Node *node); + void optionalChainFinalizer(const Reference &expressionResult, bool tailOfChain, + bool isDeleteExpression = false); + Reference loadSubscriptForCall(const Reference &base); + void generateThrowException(const QString &type, const QString &text = QString()); +}; + +} + +} + +QT_END_NAMESPACE + +#endif // QV4CODEGEN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilationunitmapper_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilationunitmapper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fed961b3daadaad04df99639e1ceddefa506e189 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilationunitmapper_p.h @@ -0,0 +1,51 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4COMPILATIONUNITMAPPER_H +#define QV4COMPILATIONUNITMAPPER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <QFile> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace CompiledData { +struct Unit; +} + +class CompilationUnitMapper +{ +public: + CompiledData::Unit *get( + const QString &cacheFilePath, const QDateTime &sourceTimeStamp, QString *errorString); + static void invalidate(const QString &cacheFilePath); + +private: + CompiledData::Unit *open( + const QString &cacheFilePath, const QDateTime &sourceTimeStamp, QString *errorString); + void close(); + +#if defined(Q_OS_UNIX) + size_t length = 0; +#endif + void *dataPtr = nullptr; +}; + +} + +QT_END_NAMESPACE + +#endif // QV4COMPILATIONUNITMAPPER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compileddata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compileddata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6fa96da9934702e91e7a6dfa6c0938c1b0279f4c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compileddata_p.h @@ -0,0 +1,1842 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4COMPILEDDATA_P_H +#define QV4COMPILEDDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <functional> + +#include <QtCore/qcryptographichash.h> +#include <QtCore/qhash.h> +#include <QtCore/qhashfunctions.h> +#include <QtCore/qlocale.h> +#include <QtCore/qscopeguard.h> +#include <QtCore/qstring.h> +#include <QtCore/qstringlist.h> +#include <QtCore/qurl.h> +#include <QtCore/qvector.h> +#include <QtCore/qversionnumber.h> + +#if QT_CONFIG(temporaryfile) +#include <QtCore/qsavefile.h> +#endif + +#include <private/qendian_p.h> +#include <private/qqmlnullablevalue_p.h> +#include <private/qqmlpropertycachevector_p.h> +#include <private/qqmlrefcount_p.h> +#include <private/qqmltype_p.h> +#include <private/qv4compilationunitmapper_p.h> +#include <private/qv4staticvalue_p.h> + +#include <functional> +#include <limits.h> + +QT_BEGIN_NAMESPACE + +// Bump this whenever the compiler data structures change in an incompatible way. +// +// IMPORTANT: +// +// Also change the comment behind the number to describe the latest change. This has the added +// benefit that if another patch changes the version too, it will result in a merge conflict, and +// not get removed silently. +#define QV4_DATA_STRUCTURE_VERSION 0x42 // Change metatype computation of AOT-compiled functions + +class QIODevice; +class QQmlTypeNameCache; +class QQmlType; +class QQmlEngine; +class QQmlPropertyData; +class QQmlScriptData; + +namespace QQmlPrivate { +struct AOTCompiledFunction; +} + +namespace QmlIR { +struct Document; +} + +namespace QV4 { +namespace Heap { +struct Module; +struct String; +struct InternalClass; +}; + +struct Function; +class EvalISelFactory; +class ResolvedTypeReference; + +namespace CompiledData { + +// index is per-object binding index +using BindingPropertyData = QVector<const QQmlPropertyData *>; + +// map from name index +struct ResolvedTypeReferenceMap: public QHash<int, ResolvedTypeReference*> +{ + bool addToHash(QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums) const; +}; + +struct String; +struct Function; +struct Lookup; +struct RegExp; +struct Unit; + +template <typename ItemType, typename Container, const ItemType *(Container::*IndexedGetter)(int index) const> +struct TableIterator +{ + TableIterator(const Container *container, int index) : container(container), index(index) {} + const Container *container; + int index; + + const ItemType *operator->() { return (container->*IndexedGetter)(index); } + ItemType operator*() {return *operator->();} + void operator++() { ++index; } + bool operator==(const TableIterator &rhs) const { return index == rhs.index; } + bool operator!=(const TableIterator &rhs) const { return index != rhs.index; } +}; + +struct Location +{ + Location() : m_data(QSpecialIntegerBitfieldZero) {} + Location(quint32 l, quint32 c) : Location() + { + m_data.set<LineField>(l); + m_data.set<ColumnField>(c); + Q_ASSERT(m_data.get<LineField>() == l); + Q_ASSERT(m_data.get<ColumnField>() == c); + } + + inline bool operator<(const Location &other) const { + return m_data.get<LineField>() < other.m_data.get<LineField>() + || (m_data.get<LineField>() == other.m_data.get<LineField>() + && m_data.get<ColumnField>() < other.m_data.get<ColumnField>()); + } + + friend size_t qHash(const Location &location, size_t seed = 0) + { + return QT_PREPEND_NAMESPACE(qHash)(location.m_data.data(), seed); + } + + friend bool operator==(const Location &a, const Location &b) + { + return a.m_data.data()== b.m_data.data(); + } + + void set(quint32 line, quint32 column) + { + m_data.set<LineField>(line); + m_data.set<ColumnField>(column); + } + + quint32 line() const { return m_data.get<LineField>(); } + quint32 column() const { return m_data.get<ColumnField>(); } + +private: + using LineField = quint32_le_bitfield_member<0, 20>; + using ColumnField = quint32_le_bitfield_member<20, 12>; + + quint32_le_bitfield_union<LineField, ColumnField> m_data; +}; +static_assert(sizeof(Location) == 4, "Location structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct RegExp +{ + enum Flags : unsigned int { + RegExp_NoFlags = 0x0, + RegExp_Global = 0x01, + RegExp_IgnoreCase = 0x02, + RegExp_Multiline = 0x04, + RegExp_Sticky = 0x08, + RegExp_Unicode = 0x10, + }; + + RegExp() : m_data(QSpecialIntegerBitfieldZero) {} + RegExp(quint32 flags, quint32 stringIndex) : RegExp() + { + m_data.set<FlagsField>(flags); + m_data.set<StringIndexField>(stringIndex); + } + + quint32 flags() const { return m_data.get<FlagsField>(); } + quint32 stringIndex() const { return m_data.get<StringIndexField>(); } + +private: + using FlagsField = quint32_le_bitfield_member<0, 5>; + using StringIndexField = quint32_le_bitfield_member<5, 27>; + quint32_le_bitfield_union<FlagsField, StringIndexField> m_data; +}; +static_assert(sizeof(RegExp) == 4, "RegExp structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Lookup +{ + enum Type : unsigned int { + Type_Getter = 0, + Type_Setter = 1, + Type_GlobalGetter = 2, + Type_QmlContextPropertyGetter = 3 + }; + + enum Mode : unsigned int { + Mode_ForStorage = 0, + Mode_ForCall = 1 + }; + + quint32 type() const { return m_data.get<TypeField>(); } + quint32 nameIndex() const { return m_data.get<NameIndexField>(); } + quint32 mode() const { return m_data.get<ModeField>(); } + + Lookup() : m_data(QSpecialIntegerBitfieldZero) {} + Lookup(Type type, Mode mode, quint32 nameIndex) : Lookup() + { + m_data.set<TypeField>(type); + m_data.set<ModeField>(mode); + m_data.set<NameIndexField>(nameIndex); + } + +private: + using TypeField = quint32_le_bitfield_member<0, 2>; + using ModeField = quint32_le_bitfield_member<2, 1>; + // 1 bit left + using NameIndexField = quint32_le_bitfield_member<4, 28>; + quint32_le_bitfield_union<TypeField, ModeField, NameIndexField> m_data; +}; +static_assert(sizeof(Lookup) == 4, "Lookup structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct JSClassMember +{ + JSClassMember() : m_data(QSpecialIntegerBitfieldZero) {} + + void set(quint32 nameOffset, bool isAccessor) + { + m_data.set<NameOffsetField>(nameOffset); + m_data.set<IsAccessorField>(isAccessor ? 1 : 0); + } + + quint32 nameOffset() const { return m_data.get<NameOffsetField>(); } + bool isAccessor() const { return m_data.get<IsAccessorField>() != 0; } + +private: + using NameOffsetField = quint32_le_bitfield_member<0, 31>; + using IsAccessorField = quint32_le_bitfield_member<31, 1>; + quint32_le_bitfield_union<NameOffsetField, IsAccessorField> m_data; +}; +static_assert(sizeof(JSClassMember) == 4, "JSClassMember structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct JSClass +{ + quint32_le nMembers; + // JSClassMember[nMembers] + + static int calculateSize(int nMembers) { return (sizeof(JSClass) + nMembers * sizeof(JSClassMember) + 7) & ~7; } +}; +static_assert(sizeof(JSClass) == 4, "JSClass structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct String +{ + qint32_le size; + + static int calculateSize(const QString &str) { + // we cannot enconuter strings larger than INT_MAX anyway, as such a string + // would already break in other parts of the compilation process + return (sizeof(String) + (int(str.size()) + 1) * sizeof(quint16) + 7) & ~0x7; + } +}; + +static_assert (sizeof (String) == 4, "String structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct CodeOffsetToLineAndStatement { + quint32_le codeOffset; + qint32_le line; // signed because debug instructions get negative line numbers + quint32_le statement; +}; +static_assert(sizeof(CodeOffsetToLineAndStatement) == 12, "CodeOffsetToLineAndStatement structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Block +{ + quint32_le nLocals; + quint32_le localsOffset; + quint16_le sizeOfLocalTemporalDeadZone; + quint16_le padding; + + const quint32_le *localsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + localsOffset); } + + static int calculateSize(int nLocals) { + int trailingData = nLocals*sizeof (quint32); + size_t size = align(align(sizeof(Block)) + size_t(trailingData)); + Q_ASSERT(size < INT_MAX); + return int(size); + } + + static size_t align(size_t a) { + return (a + 7) & ~size_t(7); + } +}; +static_assert(sizeof(Block) == 12, "Block structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +enum class NamedBuiltin: unsigned int { + Void, Var, Int, Bool, Real, String, Url, DateTime, RegExp +}; + +enum class CommonType : unsigned int { + // Actual named builtins + Void = uint(NamedBuiltin::Void), + Var = uint(NamedBuiltin::Var), + Int = uint(NamedBuiltin::Int), + Bool = uint(NamedBuiltin::Bool), + Real = uint(NamedBuiltin::Real), + String = uint(NamedBuiltin::String), + Url = uint(NamedBuiltin::Url), + DateTime = uint(NamedBuiltin::DateTime), + RegExp = uint(NamedBuiltin::RegExp), + + // Optimization for very common other types + Time, Date, Rect, Point, Size, + + // No type specified or not recognized + Invalid +}; + +struct ParameterType +{ + enum Flag { + NoFlag = 0x0, + Common = 0x1, + List = 0x2, + }; + Q_DECLARE_FLAGS(Flags, Flag); + + void set(Flags flags, quint32 typeNameIndexOrCommonType) + { + m_data.set<IsListField>(flags.testFlag(List) ? 1 : 0); + m_data.set<IndexIsCommonTypeField>(flags.testFlag(Common) ? 1 : 0); + m_data.set<TypeNameIndexOrCommonTypeField>(typeNameIndexOrCommonType); + } + + bool indexIsCommonType() const + { + return m_data.get<IndexIsCommonTypeField>() != 0; + } + + bool isList() const + { + return m_data.get<IsListField>() != 0; + } + + quint32 typeNameIndexOrCommonType() const + { + return m_data.get<TypeNameIndexOrCommonTypeField>(); + } + +private: + using IndexIsCommonTypeField = quint32_le_bitfield_member<0, 1>; + using IsListField = quint32_le_bitfield_member<1, 1>; + using TypeNameIndexOrCommonTypeField = quint32_le_bitfield_member<2, 30>; + quint32_le_bitfield_union<IndexIsCommonTypeField, IsListField, TypeNameIndexOrCommonTypeField> m_data; +}; +static_assert(sizeof(ParameterType) == 4, "ParameterType structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Parameter +{ + quint32_le nameIndex; + ParameterType type; +}; +static_assert(sizeof(Parameter) == 8, "Parameter structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +// Function is aligned on an 8-byte boundary to make sure there are no bus errors or penalties +// for unaligned access. The ordering of the fields is also from largest to smallest. +struct Function +{ + enum Flags : unsigned int { + IsStrict = 0x1, + IsArrowFunction = 0x2, + IsGenerator = 0x4, + IsClosureWrapper = 0x8, + }; + + // Absolute offset into file where the code for this function is located. + quint32_le codeOffset; + quint32_le codeSize; + + quint32_le nameIndex; + quint16_le length; + quint16_le nFormals; + quint32_le formalsOffset; // Can't turn this into a calculated offset because of the mutation in CompilationUnit::createUnitData. + ParameterType returnType; + quint32_le localsOffset; + quint16_le nLocals; + quint16_le nLineAndStatementNumbers; + size_t lineAndStatementNumberOffset() const { return localsOffset + nLocals * sizeof(quint32); } + quint32_le nestedFunctionIndex; // for functions that only return a single closure, used in signal handlers + + quint32_le nRegisters; + Location location; + quint32_le nLabelInfos; + + quint16_le sizeOfLocalTemporalDeadZone; + quint16_le firstTemporalDeadZoneRegister; + quint16_le sizeOfRegisterTemporalDeadZone; + + size_t labelInfosOffset() const + { + return lineAndStatementNumberOffset() + nLineAndStatementNumbers * sizeof(CodeOffsetToLineAndStatement); + } + + // Keep all unaligned data at the end + quint8 flags; + quint8 padding1; + + // quint32 formalsIndex[nFormals] + // quint32 localsIndex[nLocals] + + const Parameter *formalsTable() const + { + return reinterpret_cast<const Parameter *>( + reinterpret_cast<const char *>(this) + formalsOffset); + } + const quint32_le *localsTable() const + { + return reinterpret_cast<const quint32_le *>( + reinterpret_cast<const char *>(this) + localsOffset); + } + const CodeOffsetToLineAndStatement *lineAndStatementNumberTable() const + { + return reinterpret_cast<const CodeOffsetToLineAndStatement *>( + reinterpret_cast<const char *>(this) + lineAndStatementNumberOffset()); + } + + // --- QQmlPropertyCacheCreator interface + const Parameter *formalsBegin() const { return formalsTable(); } + const Parameter *formalsEnd() const { return formalsTable() + nFormals; } + // --- + + const quint32_le *labelInfoTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + labelInfosOffset()); } + + const char *code() const { return reinterpret_cast<const char *>(this) + codeOffset; } + + static int calculateSize( + int nFormals, int nLocals, int nLinesAndStatements, int nInnerfunctions, + int labelInfoSize, int codeSize) + { + int trailingData = nFormals * sizeof(Parameter) + + (nLocals + nInnerfunctions + labelInfoSize) * sizeof (quint32) + + nLinesAndStatements * sizeof(CodeOffsetToLineAndStatement); + size_t size = align(align(sizeof(Function)) + size_t(trailingData)) + align(codeSize); + Q_ASSERT(size < INT_MAX); + return int(size); + } + + static size_t align(size_t a) { + return (a + 7) & ~size_t(7); + } +}; +static_assert(sizeof(Function) == 56, "Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Method { + enum Type { + Regular, + Getter, + Setter + }; + + quint32_le name; + quint32_le type; + quint32_le function; +}; +static_assert(sizeof(Method) == 12, "Method structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Class +{ + quint32_le nameIndex; + quint32_le scopeIndex; + quint32_le constructorFunction; + quint32_le nStaticMethods; + quint32_le nMethods; + quint32_le methodTableOffset; + + const Method *methodTable() const { return reinterpret_cast<const Method *>(reinterpret_cast<const char *>(this) + methodTableOffset); } + + static int calculateSize(int nStaticMethods, int nMethods) { + int trailingData = (nStaticMethods + nMethods) * sizeof(Method); + size_t size = align(sizeof(Class) + trailingData); + Q_ASSERT(size < INT_MAX); + return int(size); + } + + static size_t align(size_t a) { + return (a + 7) & ~size_t(7); + } +}; +static_assert(sizeof(Class) == 24, "Class structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct TemplateObject +{ + quint32_le size; + + static int calculateSize(int size) { + int trailingData = 2 * size * sizeof(quint32_le); + size_t s = align(sizeof(TemplateObject) + trailingData); + Q_ASSERT(s < INT_MAX); + return int(s); + } + + static size_t align(size_t a) { + return (a + 7) & ~size_t(7); + } + + const quint32_le *stringTable() const { + return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this + 1)); + } + + uint stringIndexAt(uint i) const { + return stringTable()[i]; + } + uint rawStringIndexAt(uint i) const { + return stringTable()[size + i]; + } +}; +static_assert(sizeof(TemplateObject) == 4, "Template object structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct ExportEntry +{ + quint32_le exportName; + quint32_le moduleRequest; + quint32_le importName; + quint32_le localName; + Location location; +}; +static_assert(sizeof(ExportEntry) == 20, "ExportEntry structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct ImportEntry +{ + quint32_le moduleRequest; + quint32_le importName; + quint32_le localName; + Location location; +}; +static_assert(sizeof(ImportEntry) == 16, "ImportEntry structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +// Qml data structures + +struct TranslationData +{ + enum { NoContextIndex = std::numeric_limits<quint32>::max() }; + quint32_le stringIndex; + quint32_le commentIndex; + qint32_le number; + quint32_le contextIndex; +}; +static_assert(sizeof(TranslationData) == 16, "TranslationData structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Binding +{ + quint32_le propertyNameIndex; + + enum Type : unsigned int { + Type_Invalid, + Type_Boolean, + Type_Number, + Type_String, + Type_Null, + Type_Translation, + Type_TranslationById, + Type_Script, + Type_Object, + Type_AttachedProperty, + Type_GroupProperty + }; + + enum Flag : unsigned int { + IsSignalHandlerExpression = 0x1, + IsSignalHandlerObject = 0x2, + IsOnAssignment = 0x4, + InitializerForReadOnlyDeclaration = 0x8, + IsResolvedEnum = 0x10, + IsListItem = 0x20, + IsBindingToAlias = 0x40, + IsDeferredBinding = 0x80, + IsCustomParserBinding = 0x100, + IsFunctionExpression = 0x200, + IsPropertyObserver = 0x400 + }; + Q_DECLARE_FLAGS(Flags, Flag); + + using FlagsField = quint32_le_bitfield_member<0, 16>; + using TypeField = quint32_le_bitfield_member<16, 16>; + quint32_le_bitfield_union<FlagsField, TypeField> flagsAndType; + + void clearFlags() { flagsAndType.set<FlagsField>(0); } + void setFlag(Flag flag) { flagsAndType.set<FlagsField>(flagsAndType.get<FlagsField>() | flag); } + bool hasFlag(Flag flag) const { return Flags(flagsAndType.get<FlagsField>()) & flag; } + Flags flags() const { return Flags(flagsAndType.get<FlagsField>()); } + + void setType(Type type) { flagsAndType.set<TypeField>(type); } + Type type() const { return Type(flagsAndType.get<TypeField>()); } + + union { + bool b; + quint32_le constantValueIndex; + quint32_le compiledScriptIndex; // used when Type_Script + quint32_le objectIndex; + quint32_le translationDataIndex; // used when Type_Translation + quint32 nullMarker; + } value; + quint32_le stringIndex; // Set for Type_String and Type_Script (the latter because of script strings) + + Location location; + Location valueLocation; + + bool hasSignalHandlerBindingFlag() const + { + const Flags bindingFlags = flags(); + return bindingFlags & IsSignalHandlerExpression + || bindingFlags & IsSignalHandlerObject + || bindingFlags & IsPropertyObserver; + } + + bool isValueBinding() const + { + switch (type()) { + case Type_AttachedProperty: + case Type_GroupProperty: + return false; + default: + return !hasSignalHandlerBindingFlag(); + } + } + + bool isValueBindingNoAlias() const { return isValueBinding() && !hasFlag(IsBindingToAlias); } + bool isValueBindingToAlias() const { return isValueBinding() && hasFlag(IsBindingToAlias); } + + bool isSignalHandler() const + { + if (hasSignalHandlerBindingFlag()) { + Q_ASSERT(!isValueBinding()); + Q_ASSERT(!isAttachedProperty()); + Q_ASSERT(!isGroupProperty()); + return true; + } + return false; + } + + bool isAttachedProperty() const + { + if (type() == Type_AttachedProperty) { + Q_ASSERT(!isValueBinding()); + Q_ASSERT(!isSignalHandler()); + Q_ASSERT(!isGroupProperty()); + return true; + } + return false; + } + + bool isGroupProperty() const + { + if (type() == Type_GroupProperty) { + Q_ASSERT(!isValueBinding()); + Q_ASSERT(!isSignalHandler()); + Q_ASSERT(!isAttachedProperty()); + return true; + } + return false; + } + + bool isFunctionExpression() const { return hasFlag(IsFunctionExpression); } + + //reverse of Lexer::singleEscape() + static QString escapedString(const QString &string) + { + QString tmp = QLatin1String("\""); + for (int i = 0; i < string.size(); ++i) { + const QChar &c = string.at(i); + switch (c.unicode()) { + case 0x08: + tmp += QLatin1String("\\b"); + break; + case 0x09: + tmp += QLatin1String("\\t"); + break; + case 0x0A: + tmp += QLatin1String("\\n"); + break; + case 0x0B: + tmp += QLatin1String("\\v"); + break; + case 0x0C: + tmp += QLatin1String("\\f"); + break; + case 0x0D: + tmp += QLatin1String("\\r"); + break; + case 0x22: + tmp += QLatin1String("\\\""); + break; + case 0x27: + tmp += QLatin1String("\\\'"); + break; + case 0x5C: + tmp += QLatin1String("\\\\"); + break; + default: + tmp += c; + break; + } + } + tmp += QLatin1Char('\"'); + return tmp; + } + + bool isTranslationBinding() const + { + const Binding::Type bindingType = type(); + return bindingType == Type_Translation || bindingType == Type_TranslationById; + } + bool evaluatesToString() const { return type() == Type_String || isTranslationBinding(); } + + bool isNumberBinding() const { return type() == Type_Number; } + + bool valueAsBoolean() const + { + if (type() == Type_Boolean) + return value.b; + return false; + } +}; + +static_assert(sizeof(Binding) == 24, "Binding structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct InlineComponent +{ + quint32_le objectIndex; + quint32_le nameIndex; + Location location; +}; + +static_assert(sizeof(InlineComponent) == 12, "InlineComponent structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct EnumValue +{ + quint32_le nameIndex; + qint32_le value; + Location location; +}; +static_assert(sizeof(EnumValue) == 12, "EnumValue structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Enum +{ + quint32_le nameIndex; + quint32_le nEnumValues; + Location location; + + const EnumValue *enumValueAt(int idx) const { + return reinterpret_cast<const EnumValue*>(this + 1) + idx; + } + + static int calculateSize(int nEnumValues) { + return (sizeof(Enum) + + nEnumValues * sizeof(EnumValue) + + 7) & ~0x7; + } + + // --- QQmlPropertyCacheCreatorInterface + const EnumValue *enumValuesBegin() const { return enumValueAt(0); } + const EnumValue *enumValuesEnd() const { return enumValueAt(nEnumValues); } + int enumValueCount() const { return nEnumValues; } + // --- +}; +static_assert(sizeof(Enum) == 12, "Enum structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Signal +{ + quint32_le nameIndex; + quint32_le nParameters; + Location location; + // Parameter parameters[1]; + + const Parameter *parameterAt(int idx) const { + return reinterpret_cast<const Parameter*>(this + 1) + idx; + } + + static int calculateSize(int nParameters) { + return (sizeof(Signal) + + nParameters * sizeof(Parameter) + + 7) & ~0x7; + } + + // --- QQmlPropertyCacheCceatorInterface + const Parameter *parametersBegin() const { return parameterAt(0); } + const Parameter *parametersEnd() const { return parameterAt(nParameters); } + int parameterCount() const { return nParameters; } + // --- +}; +static_assert(sizeof(Signal) == 12, "Signal structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Property +{ +private: + using CommonTypeOrTypeNameIndexField = quint32_le_bitfield_member<0, 28>; + using IsRequiredField = quint32_le_bitfield_member<28, 1>; + using IsCommonTypeField = quint32_le_bitfield_member<29, 1>; + using IsListField = quint32_le_bitfield_member<30, 1>; + using IsReadOnlyField = quint32_le_bitfield_member<31, 1>; + +public: + quint32_le nameIndex; + quint32_le_bitfield_union< + CommonTypeOrTypeNameIndexField, + IsRequiredField, + IsCommonTypeField, + IsListField, + IsReadOnlyField> data; + Location location; + + void setCommonType(CommonType t) + { + data.set<CommonTypeOrTypeNameIndexField>(static_cast<quint32>(t)); + data.set<IsCommonTypeField>(true); + } + + CommonType commonType() const { + if (data.get<IsCommonTypeField>() != 0) + return CommonType(data.get<CommonTypeOrTypeNameIndexField>()); + return CommonType::Invalid; + } + + void setTypeNameIndex(int nameIndex) + { + data.set<CommonTypeOrTypeNameIndexField>(nameIndex); + data.set<IsCommonTypeField>(false); + } + + int typeNameIndex() const + { + return data.get<IsCommonTypeField>() ? -1 : data.get<CommonTypeOrTypeNameIndexField>(); + } + + bool isCommonType() const { return data.get<IsCommonTypeField>(); } + uint commonTypeOrTypeNameIndex() const { return data.get<CommonTypeOrTypeNameIndexField>(); } + + bool isList() const { return data.get<IsListField>(); } + void setIsList(bool isList) { data.set<IsListField>(isList); } + + bool isRequired() const { return data.get<IsRequiredField>(); } + void setIsRequired(bool isRequired) { data.set<IsRequiredField>(isRequired); } + + bool isReadOnly() const { return data.get<IsReadOnlyField>(); } + void setIsReadOnly(bool isReadOnly) { data.set<IsReadOnlyField>(isReadOnly); } +}; +static_assert(sizeof(Property) == 12, "Property structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct RequiredPropertyExtraData { + quint32_le nameIndex; +}; + +static_assert (sizeof(RequiredPropertyExtraData) == 4, "RequiredPropertyExtraData structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Alias { +private: + using NameIndexField = quint32_le_bitfield_member<0, 29>; + using FlagsField = quint32_le_bitfield_member<29, 3>; + + // object id index (in QQmlContextData::idValues) + using TargetObjectIdField = quint32_le_bitfield_member<0, 31>; + using AliasToLocalAliasField = quint32_le_bitfield_member<31, 1>; + using IdIndexField = quint32_le_bitfield_member<0, 32>; + +public: + + enum Flag : unsigned int { + IsReadOnly = 0x1, + Resolved = 0x2, + AliasPointsToPointerObject = 0x4 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + quint32_le_bitfield_union<NameIndexField, FlagsField> nameIndexAndFlags; + quint32_le_bitfield_union<IdIndexField, TargetObjectIdField, AliasToLocalAliasField> + idIndexAndTargetObjectIdAndAliasToLocalAlias; + + union { + quint32_le propertyNameIndex; // string index + qint32_le encodedMetaPropertyIndex; + quint32_le localAliasIndex; // index in list of aliases local to the object (if targetObjectId == objectId) + }; + Location location; + Location referenceLocation; + + bool hasFlag(Flag flag) const + { + return nameIndexAndFlags.get<FlagsField>() & flag; + } + + void setFlag(Flag flag) + { + nameIndexAndFlags.set<FlagsField>(nameIndexAndFlags.get<FlagsField>() | flag); + } + + void clearFlags() + { + nameIndexAndFlags.set<FlagsField>(0); + } + + quint32 nameIndex() const + { + return nameIndexAndFlags.get<NameIndexField>(); + } + + void setNameIndex(quint32 nameIndex) + { + nameIndexAndFlags.set<NameIndexField>(nameIndex); + } + + bool isObjectAlias() const + { + Q_ASSERT(hasFlag(Resolved)); + return encodedMetaPropertyIndex == -1; + } + + quint32 idIndex() const + { + return idIndexAndTargetObjectIdAndAliasToLocalAlias.get<IdIndexField>(); + } + + void setIdIndex(quint32 idIndex) + { + idIndexAndTargetObjectIdAndAliasToLocalAlias.set<IdIndexField>(idIndex); + } + + + bool isAliasToLocalAlias() const + { + return idIndexAndTargetObjectIdAndAliasToLocalAlias.get<AliasToLocalAliasField>(); + } + + void setIsAliasToLocalAlias(bool isAliasToLocalAlias) + { + idIndexAndTargetObjectIdAndAliasToLocalAlias.set<AliasToLocalAliasField>(isAliasToLocalAlias); + } + + quint32 targetObjectId() const + { + return idIndexAndTargetObjectIdAndAliasToLocalAlias.get<TargetObjectIdField>(); + } + + void setTargetObjectId(quint32 targetObjectId) + { + idIndexAndTargetObjectIdAndAliasToLocalAlias.set<TargetObjectIdField>(targetObjectId); + } +}; +static_assert(sizeof(Alias) == 20, "Alias structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Object +{ +private: + using FlagsField = quint32_le_bitfield_member<0, 15>; + using DefaultPropertyIsAliasField = quint32_le_bitfield_member<15, 1>; + using IdField = quint32_le_bitfield_member<16, 16, qint32>; +public: + enum Flag : unsigned int { + NoFlag = 0x0, + IsComponent = 0x1, // object was identified to be an explicit or implicit component boundary + HasDeferredBindings = 0x2, // any of the bindings are deferred + HasCustomParserBindings = 0x4, + IsInlineComponentRoot = 0x8, + IsPartOfInlineComponent = 0x10 + }; + Q_DECLARE_FLAGS(Flags, Flag); + + // Depending on the use, this may be the type name to instantiate before instantiating this + // object. For grouped properties the type name will be empty and for attached properties + // it will be the name of the attached type. + quint32_le inheritedTypeNameIndex; + quint32_le idNameIndex; + quint32_le_bitfield_union<FlagsField, DefaultPropertyIsAliasField, IdField> + flagsAndDefaultPropertyIsAliasAndId; + qint32_le indexOfDefaultPropertyOrAlias; // -1 means no default property declared in this object + quint16_le nFunctions; + quint16_le nProperties; + quint32_le offsetToFunctions; + quint32_le offsetToProperties; + quint32_le offsetToAliases; + quint16_le nAliases; + quint16_le nEnums; + quint32_le offsetToEnums; // which in turn will be a table with offsets to variable-sized Enum objects + quint32_le offsetToSignals; // which in turn will be a table with offsets to variable-sized Signal objects + quint16_le nSignals; + quint16_le nBindings; + quint32_le offsetToBindings; + quint32_le nNamedObjectsInComponent; + quint32_le offsetToNamedObjectsInComponent; + Location location; + Location locationOfIdProperty; + quint32_le offsetToInlineComponents; + quint16_le nInlineComponents; + quint32_le offsetToRequiredPropertyExtraData; + quint16_le nRequiredPropertyExtraData; +// Function[] +// Property[] +// Signal[] +// Binding[] +// InlineComponent[] +// RequiredPropertyExtraData[] + + Flags flags() const + { + return Flags(flagsAndDefaultPropertyIsAliasAndId.get<FlagsField>()); + } + + bool hasFlag(Flag flag) const + { + return flagsAndDefaultPropertyIsAliasAndId.get<FlagsField>() & flag; + } + + void setFlag(Flag flag) + { + flagsAndDefaultPropertyIsAliasAndId.set<FlagsField>( + flagsAndDefaultPropertyIsAliasAndId.get<FlagsField>() | flag); + } + + void setFlags(Flags flags) + { + flagsAndDefaultPropertyIsAliasAndId.set<FlagsField>(flags); + } + + bool hasAliasAsDefaultProperty() const + { + return flagsAndDefaultPropertyIsAliasAndId.get<DefaultPropertyIsAliasField>(); + } + + void setHasAliasAsDefaultProperty(bool defaultAlias) + { + flagsAndDefaultPropertyIsAliasAndId.set<DefaultPropertyIsAliasField>(defaultAlias); + } + + qint32 objectId() const + { + return flagsAndDefaultPropertyIsAliasAndId.get<IdField>(); + } + + void setObjectId(qint32 id) + { + flagsAndDefaultPropertyIsAliasAndId.set<IdField>(id); + } + + + static int calculateSizeExcludingSignalsAndEnums(int nFunctions, int nProperties, int nAliases, int nEnums, int nSignals, int nBindings, int nNamedObjectsInComponent, int nInlineComponents, int nRequiredPropertyExtraData) + { + return ( sizeof(Object) + + nFunctions * sizeof(quint32) + + nProperties * sizeof(Property) + + nAliases * sizeof(Alias) + + nEnums * sizeof(quint32) + + nSignals * sizeof(quint32) + + nBindings * sizeof(Binding) + + nNamedObjectsInComponent * sizeof(int) + + nInlineComponents * sizeof(InlineComponent) + + nRequiredPropertyExtraData * sizeof(RequiredPropertyExtraData) + + 0x7 + ) & ~0x7; + } + + const quint32_le *functionOffsetTable() const + { + return reinterpret_cast<const quint32_le*>(reinterpret_cast<const char *>(this) + offsetToFunctions); + } + + const Property *propertyTable() const + { + return reinterpret_cast<const Property*>(reinterpret_cast<const char *>(this) + offsetToProperties); + } + + const Alias *aliasTable() const + { + return reinterpret_cast<const Alias*>(reinterpret_cast<const char *>(this) + offsetToAliases); + } + + const Binding *bindingTable() const + { + return reinterpret_cast<const Binding*>(reinterpret_cast<const char *>(this) + offsetToBindings); + } + + const Enum *enumAt(int idx) const + { + const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToEnums); + const quint32_le offset = offsetTable[idx]; + return reinterpret_cast<const Enum*>(reinterpret_cast<const char*>(this) + offset); + } + + const Signal *signalAt(int idx) const + { + const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToSignals); + const quint32_le offset = offsetTable[idx]; + return reinterpret_cast<const Signal*>(reinterpret_cast<const char*>(this) + offset); + } + + const InlineComponent *inlineComponentAt(int idx) const + { + return inlineComponentTable() + idx; + } + + const quint32_le *namedObjectsInComponentTable() const + { + return reinterpret_cast<const quint32_le*>(reinterpret_cast<const char *>(this) + offsetToNamedObjectsInComponent); + } + + const InlineComponent *inlineComponentTable() const + { + return reinterpret_cast<const InlineComponent*>(reinterpret_cast<const char *>(this) + offsetToInlineComponents); + } + + const RequiredPropertyExtraData *requiredPropertyExtraDataAt(int idx) const + { + return requiredPropertyExtraDataTable() + idx; + } + + const RequiredPropertyExtraData *requiredPropertyExtraDataTable() const + { + return reinterpret_cast<const RequiredPropertyExtraData*>(reinterpret_cast<const char *>(this) + offsetToRequiredPropertyExtraData); + } + + // --- QQmlPropertyCacheCreator interface + int propertyCount() const { return nProperties; } + int aliasCount() const { return nAliases; } + int enumCount() const { return nEnums; } + int signalCount() const { return nSignals; } + int functionCount() const { return nFunctions; } + + const Binding *bindingsBegin() const { return bindingTable(); } + const Binding *bindingsEnd() const { return bindingTable() + nBindings; } + int bindingCount() const { return nBindings; } + + const Property *propertiesBegin() const { return propertyTable(); } + const Property *propertiesEnd() const { return propertyTable() + nProperties; } + + const Alias *aliasesBegin() const { return aliasTable(); } + const Alias *aliasesEnd() const { return aliasTable() + nAliases; } + + typedef TableIterator<Enum, Object, &Object::enumAt> EnumIterator; + EnumIterator enumsBegin() const { return EnumIterator(this, 0); } + EnumIterator enumsEnd() const { return EnumIterator(this, nEnums); } + + typedef TableIterator<Signal, Object, &Object::signalAt> SignalIterator; + SignalIterator signalsBegin() const { return SignalIterator(this, 0); } + SignalIterator signalsEnd() const { return SignalIterator(this, nSignals); } + + typedef TableIterator<InlineComponent, Object, &Object::inlineComponentAt> InlineComponentIterator; + InlineComponentIterator inlineComponentsBegin() const {return InlineComponentIterator(this, 0);} + InlineComponentIterator inlineComponentsEnd() const {return InlineComponentIterator(this, nInlineComponents);} + + typedef TableIterator<RequiredPropertyExtraData, Object, &Object::requiredPropertyExtraDataAt> RequiredPropertyExtraDataIterator; + RequiredPropertyExtraDataIterator requiredPropertyExtraDataBegin() const {return RequiredPropertyExtraDataIterator(this, 0); } + RequiredPropertyExtraDataIterator requiredPropertyExtraDataEnd() const {return RequiredPropertyExtraDataIterator(this, nRequiredPropertyExtraData); } + + int namedObjectsInComponentCount() const { return nNamedObjectsInComponent; } + // --- +}; +static_assert(sizeof(Object) == 84, "Object structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct Import +{ + enum ImportType : unsigned int { + ImportLibrary = 0x1, + ImportFile = 0x2, + ImportScript = 0x3, + ImportInlineComponent = 0x4 + }; + quint32_le type; + + quint32_le uriIndex; + quint32_le qualifierIndex; + + Location location; + QTypeRevision version; + quint16_le reserved; + + Import() + { + type = 0; uriIndex = 0; qualifierIndex = 0; version = QTypeRevision::zero(); reserved = 0; + } +}; +static_assert(sizeof(Import) == 20, "Import structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct QmlUnit +{ + quint32_le nImports; + quint32_le offsetToImports; + quint32_le nObjects; + quint32_le offsetToObjects; + + const Import *importAt(int idx) const { + return reinterpret_cast<const Import*>((reinterpret_cast<const char *>(this)) + offsetToImports + idx * sizeof(Import)); + } + + const Object *objectAt(int idx) const { + const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToObjects); + const quint32_le offset = offsetTable[idx]; + return reinterpret_cast<const Object*>(reinterpret_cast<const char*>(this) + offset); + } +}; +static_assert(sizeof(QmlUnit) == 16, "QmlUnit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +enum { QmlCompileHashSpace = 48 }; +static const char magic_str[] = "qv4cdata"; + +struct Unit +{ + // DO NOT CHANGE THESE FIELDS EVER + char magic[8]; + quint32_le version; + quint32_le qtVersion; + qint64_le sourceTimeStamp; + quint32_le unitSize; // Size of the Unit and any depending data. + // END DO NOT CHANGE THESE FIELDS EVER + + char libraryVersionHash[QmlCompileHashSpace]; + + char md5Checksum[16]; // checksum of all bytes following this field. + char dependencyMD5Checksum[16]; + + enum : unsigned int { + IsJavascript = 0x1, + StaticData = 0x2, // Unit data persistent in memory? + IsSingleton = 0x4, + IsSharedLibrary = 0x8, // .pragma shared? + IsESModule = 0x10, + PendingTypeCompilation = 0x20, // the QML data structures present are incomplete and require type compilation + IsStrict = 0x40, + ListPropertyAssignReplaceIfDefault = 0x80, + ListPropertyAssignReplaceIfNotDefault = 0x100, + ListPropertyAssignReplace + = ListPropertyAssignReplaceIfDefault | ListPropertyAssignReplaceIfNotDefault, + ComponentsBound = 0x200, + FunctionSignaturesIgnored = 0x400, + NativeMethodsAcceptThisObject = 0x800, + ValueTypesCopied = 0x1000, + ValueTypesAddressable = 0x2000, + ValueTypesAssertable = 0x4000, + }; + quint32_le flags; + quint32_le stringTableSize; + quint32_le offsetToStringTable; + quint32_le functionTableSize; + quint32_le offsetToFunctionTable; + quint32_le classTableSize; + quint32_le offsetToClassTable; + quint32_le templateObjectTableSize; + quint32_le offsetToTemplateObjectTable; + quint32_le blockTableSize; + quint32_le offsetToBlockTable; + quint32_le lookupTableSize; + quint32_le offsetToLookupTable; + quint32_le regexpTableSize; + quint32_le offsetToRegexpTable; + quint32_le constantTableSize; + quint32_le offsetToConstantTable; + quint32_le jsClassTableSize; + quint32_le offsetToJSClassTable; + quint32_le translationTableSize; + quint32_le offsetToTranslationTable; + quint32_le localExportEntryTableSize; + quint32_le offsetToLocalExportEntryTable; + quint32_le indirectExportEntryTableSize; + quint32_le offsetToIndirectExportEntryTable; + quint32_le starExportEntryTableSize; + quint32_le offsetToStarExportEntryTable; + quint32_le importEntryTableSize; + quint32_le offsetToImportEntryTable; + quint32_le moduleRequestTableSize; + quint32_le offsetToModuleRequestTable; + qint32_le indexOfRootFunction; + quint32_le sourceFileIndex; + quint32_le finalUrlIndex; + + quint32_le offsetToQmlUnit; + + /* QML specific fields */ + + const QmlUnit *qmlUnit() const { + return reinterpret_cast<const QmlUnit *>(reinterpret_cast<const char *>(this) + offsetToQmlUnit); + } + + QmlUnit *qmlUnit() { + return reinterpret_cast<QmlUnit *>(reinterpret_cast<char *>(this) + offsetToQmlUnit); + } + + bool isSingleton() const { + return flags & Unit::IsSingleton; + } + /* end QML specific fields*/ + + QString stringAtInternal(uint idx) const { + Q_ASSERT(idx < stringTableSize); + const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToStringTable); + const quint32_le offset = offsetTable[idx]; + const String *str = reinterpret_cast<const String*>(reinterpret_cast<const char *>(this) + offset); + Q_ASSERT(str->size >= 0); +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + const QChar *characters = reinterpret_cast<const QChar *>(str + 1); + if (flags & StaticData) + return QString::fromRawData(characters, str->size); + return QString(characters, str->size); +#else + const quint16_le *characters = reinterpret_cast<const quint16_le *>(str + 1); + QString qstr(str->size, Qt::Uninitialized); + QChar *ch = qstr.data(); + for (int i = 0; i < str->size; ++i) + ch[i] = QChar(characters[i]); + return qstr; +#endif + } + + const quint32_le *functionOffsetTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToFunctionTable); } + const quint32_le *classOffsetTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToClassTable); } + const quint32_le *templateObjectOffsetTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToTemplateObjectTable); } + const quint32_le *blockOffsetTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToBlockTable); } + + const Function *functionAt(int idx) const { + const quint32_le *offsetTable = functionOffsetTable(); + const quint32_le offset = offsetTable[idx]; + return reinterpret_cast<const Function*>(reinterpret_cast<const char *>(this) + offset); + } + + const Class *classAt(int idx) const { + const quint32_le *offsetTable = classOffsetTable(); + const quint32_le offset = offsetTable[idx]; + return reinterpret_cast<const Class *>(reinterpret_cast<const char *>(this) + offset); + } + + const TemplateObject *templateObjectAt(int idx) const { + const quint32_le *offsetTable = templateObjectOffsetTable(); + const quint32_le offset = offsetTable[idx]; + return reinterpret_cast<const TemplateObject *>(reinterpret_cast<const char *>(this) + offset); + } + + const Block *blockAt(int idx) const { + const quint32_le *offsetTable = blockOffsetTable(); + const quint32_le offset = offsetTable[idx]; + return reinterpret_cast<const Block *>(reinterpret_cast<const char *>(this) + offset); + } + + const Lookup *lookupTable() const { return reinterpret_cast<const Lookup*>(reinterpret_cast<const char *>(this) + offsetToLookupTable); } + const RegExp *regexpAt(int index) const { + return reinterpret_cast<const RegExp*>(reinterpret_cast<const char *>(this) + offsetToRegexpTable + index * sizeof(RegExp)); + } + const quint64_le *constants() const { + return reinterpret_cast<const quint64_le*>(reinterpret_cast<const char *>(this) + offsetToConstantTable); + } + + const JSClassMember *jsClassAt(int idx, int *nMembers) const { + const quint32_le *offsetTable = reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + offsetToJSClassTable); + const quint32_le offset = offsetTable[idx]; + const char *ptr = reinterpret_cast<const char *>(this) + offset; + const JSClass *klass = reinterpret_cast<const JSClass *>(ptr); + *nMembers = klass->nMembers; + return reinterpret_cast<const JSClassMember*>(ptr + sizeof(JSClass)); + } + + const TranslationData *translations() const { + return reinterpret_cast<const TranslationData *>(reinterpret_cast<const char *>(this) + offsetToTranslationTable); + } + + const quint32_le *translationContextIndex() const{ + if ( translationTableSize == 0) + return nullptr; + return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + + offsetToTranslationTable + + translationTableSize * sizeof(CompiledData::TranslationData)); } + + quint32_le *translationContextIndex() { + if ( translationTableSize == 0) + return nullptr; + return reinterpret_cast<quint32_le*>((reinterpret_cast<char *>(this)) + + offsetToTranslationTable + + translationTableSize * sizeof(CompiledData::TranslationData)); } + + const ImportEntry *importEntryTable() const { return reinterpret_cast<const ImportEntry *>(reinterpret_cast<const char *>(this) + offsetToImportEntryTable); } + const ExportEntry *localExportEntryTable() const { return reinterpret_cast<const ExportEntry *>(reinterpret_cast<const char *>(this) + offsetToLocalExportEntryTable); } + const ExportEntry *indirectExportEntryTable() const { return reinterpret_cast<const ExportEntry *>(reinterpret_cast<const char *>(this) + offsetToIndirectExportEntryTable); } + const ExportEntry *starExportEntryTable() const { return reinterpret_cast<const ExportEntry *>(reinterpret_cast<const char *>(this) + offsetToStarExportEntryTable); } + + const quint32_le *moduleRequestTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToModuleRequestTable); } + + bool verifyHeader(QDateTime expectedSourceTimeStamp, QString *errorString) const; +}; + +static_assert(sizeof(Unit) == 248, "Unit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); + +struct TypeReference +{ + TypeReference(const Location &loc) + : location(loc) + , needsCreation(false) + , errorWhenNotFound(false) + {} + Location location; // first use + bool needsCreation : 1; // whether the type needs to be creatable or not + bool errorWhenNotFound: 1; +}; + +// Map from name index to location of first use. +struct TypeReferenceMap : QHash<int, TypeReference> +{ + TypeReference &add(int nameIndex, const Location &loc) { + Iterator it = find(nameIndex); + if (it != end()) + return *it; + return *insert(nameIndex, loc); + } + + template <typename CompiledObject> + void collectFromObject(const CompiledObject *obj) + { + if (obj->inheritedTypeNameIndex != 0) { + TypeReference &r = this->add(obj->inheritedTypeNameIndex, obj->location); + r.needsCreation = true; + r.errorWhenNotFound = true; + } + + auto prop = obj->propertiesBegin(); + auto const propEnd = obj->propertiesEnd(); + for ( ; prop != propEnd; ++prop) { + if (!prop->isCommonType()) { + TypeReference &r = this->add(prop->commonTypeOrTypeNameIndex(), prop->location); + r.errorWhenNotFound = true; + } + } + + auto binding = obj->bindingsBegin(); + auto const bindingEnd = obj->bindingsEnd(); + for ( ; binding != bindingEnd; ++binding) { + if (binding->type() == QV4::CompiledData::Binding::Type_AttachedProperty) + this->add(binding->propertyNameIndex, binding->location); + } + + auto ic = obj->inlineComponentsBegin(); + auto const icEnd = obj->inlineComponentsEnd(); + for (; ic != icEnd; ++ic) { + this->add(ic->nameIndex, ic->location); + } + } + + template <typename Iterator> + void collectFromObjects(Iterator it, Iterator end) + { + for (; it != end; ++it) + collectFromObject(*it); + } +}; + +using DependentTypesHasher = std::function<QByteArray()>; + +struct InlineComponentData { + + InlineComponentData() = default; + InlineComponentData( + const QQmlType &qmlType, int objectIndex, int nameIndex, int totalObjectCount, + int totalBindingCount, int totalParserStatusCount) + : qmlType(qmlType) + , objectIndex(objectIndex) + , nameIndex(nameIndex) + , totalObjectCount(totalObjectCount) + , totalBindingCount(totalBindingCount) + , totalParserStatusCount(totalParserStatusCount) + {} + + QQmlType qmlType; + int objectIndex = -1; + int nameIndex = -1; + int totalObjectCount = 0; + int totalBindingCount = 0; + int totalParserStatusCount = 0; +}; + +struct CompilationUnit final : public QQmlRefCounted<CompilationUnit> +{ + Q_DISABLE_COPY_MOVE(CompilationUnit) + + const Unit *data = nullptr; + const QmlUnit *qmlData = nullptr; + QStringList dynamicStrings; + const QQmlPrivate::AOTCompiledFunction *aotCompiledFunctions = nullptr; + + // pointers either to data->constants() or little-endian memory copy. + const StaticValue *constants = nullptr; + + std::unique_ptr<CompilationUnitMapper> backingFile; + + int m_totalBindingsCount = 0; // Number of bindings used in this type + int m_totalParserStatusCount = 0; // Number of instantiated types that are QQmlParserStatus subclasses + int m_totalObjectCount = 0; // Number of objects explicitly instantiated + + std::unique_ptr<QString> icRootName; + QHash<QString, InlineComponentData> inlineComponentData; + + // index is object index. This allows fast access to the + // property data when initializing bindings, avoiding expensive + // lookups by string (property name). + QVector<BindingPropertyData> bindingPropertyDataPerObject; + + ResolvedTypeReferenceMap resolvedTypes; + QQmlRefPointer<QQmlTypeNameCache> typeNameCache; + + QQmlPropertyCacheVector propertyCaches; + + QQmlType qmlType; + + QVector<QQmlRefPointer<QQmlScriptData>> dependentScripts; + +public: + // --- interface for QQmlPropertyCacheCreator + using CompiledObject = const CompiledData::Object; + using CompiledFunction = const CompiledData::Function; + using CompiledBinding = const CompiledData::Binding; + + // Empty dummy. We don't need to do this when loading from cache. + class IdToObjectMap + { + public: + void insert(int, int) {} + void clear() {} + + // We have already checked uniqueness of IDs when creating the CU + bool contains(int) { return false; } + }; + + explicit CompilationUnit(const Unit *unitData, const QQmlPrivate::AOTCompiledFunction *aotCompiledFunctions, + const QString &fileName = QString(), const QString &finalUrlString = QString()) + : CompilationUnit(unitData, fileName, finalUrlString) + { + this->aotCompiledFunctions = aotCompiledFunctions; + } + + Q_QML_EXPORT CompilationUnit( + const Unit *unitData = nullptr, const QString &fileName = QString(), + const QString &finalUrlString = QString()); + + Q_QML_EXPORT ~CompilationUnit(); + + const Unit *unitData() const { return data; } + + void setUnitData(const Unit *unitData, const QmlUnit *qmlUnit = nullptr, + const QString &fileName = QString(), const QString &finalUrlString = QString()) + { + data = unitData; + qmlData = nullptr; +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + delete [] constants; +#endif + constants = nullptr; + m_fileName.clear(); + m_finalUrlString.clear(); + if (!data) + return; + + qmlData = qmlUnit ? qmlUnit : data->qmlUnit(); + +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + StaticValue *bigEndianConstants = new StaticValue[data->constantTableSize]; + const quint64_le *littleEndianConstants = data->constants(); + for (uint i = 0; i < data->constantTableSize; ++i) + bigEndianConstants[i] = StaticValue::fromReturnedValue(littleEndianConstants[i]); + constants = bigEndianConstants; +#else + constants = reinterpret_cast<const StaticValue*>(data->constants()); +#endif + + m_fileName = !fileName.isEmpty() ? fileName : stringAt(data->sourceFileIndex); + m_finalUrlString = !finalUrlString.isEmpty() ? finalUrlString : stringAt(data->finalUrlIndex); + } + + QString stringAt(uint index) const + { + if (index < data->stringTableSize) + return data->stringAtInternal(index); + + const qsizetype dynamicIndex = index - data->stringTableSize; + Q_ASSERT(dynamicIndex < dynamicStrings.size()); + return dynamicStrings.at(dynamicIndex); + } + + QString fileName() const { return m_fileName; } + QString finalUrlString() const { return m_finalUrlString; } + + QString bindingValueAsString(const CompiledData::Binding *binding) const + { + using namespace CompiledData; + switch (binding->type()) { + case Binding::Type_Script: + case Binding::Type_String: + return stringAt(binding->stringIndex); + case Binding::Type_Null: + return QStringLiteral("null"); + case Binding::Type_Boolean: + return binding->value.b ? QStringLiteral("true") : QStringLiteral("false"); + case Binding::Type_Number: + return QString::number(bindingValueAsNumber(binding), 'g', QLocale::FloatingPointShortest); + case Binding::Type_Invalid: + return QString(); + case Binding::Type_TranslationById: + case Binding::Type_Translation: + return stringAt(data->translations()[binding->value.translationDataIndex].stringIndex); + default: + break; + } + return QString(); + } + + QString bindingValueAsScriptString(const CompiledData::Binding *binding) const + { + return (binding->type() == CompiledData::Binding::Type_String) + ? CompiledData::Binding::escapedString(stringAt(binding->stringIndex)) + : bindingValueAsString(binding); + } + + double bindingValueAsNumber(const CompiledData::Binding *binding) const + { + if (binding->type() != CompiledData::Binding::Type_Number) + return 0.0; + return constants[binding->value.constantValueIndex].doubleValue(); + } + + Q_QML_EXPORT static QString localCacheFilePath(const QUrl &url); + Q_QML_EXPORT bool loadFromDisk( + const QUrl &url, const QDateTime &sourceTimeStamp, QString *errorString); + Q_QML_EXPORT bool saveToDisk(const QUrl &unitUrl, QString *errorString); + + int importCount() const { return qmlData->nImports; } + const CompiledData::Import *importAt(int index) const { return qmlData->importAt(index); } + + Q_QML_EXPORT QStringList moduleRequests() const; + + // url() and fileName() shall be used to load the actual QML/JS code or to show errors or + // warnings about that code. They include any potential URL interceptions and thus represent the + // "physical" location of the code. + // + // finalUrl() and finalUrlString() shall be used to resolve further URLs referred to in the code + // They are _not_ intercepted and thus represent the "logical" name for the code. + + QUrl url() const + { + if (!m_url.isValid()) + m_url = QUrl(fileName()); + return m_url; + } + + QUrl finalUrl() const + { + if (!m_finalUrl.isValid()) + m_finalUrl = QUrl(finalUrlString()); + return m_finalUrl; + } + + ResolvedTypeReference *resolvedType(int id) const { return resolvedTypes.value(id); } + ResolvedTypeReference *resolvedType(QMetaType type) const; + + QQmlPropertyCache::ConstPtr rootPropertyCache() const + { + return propertyCaches.at(/*root object*/0); + } + + int objectCount() const { return qmlData->nObjects; } + const CompiledObject *objectAt(int index) const { return qmlData->objectAt(index); } + + int totalBindingsCount() const; + int totalParserStatusCount() const; + int totalObjectCount() const; + + int inlineComponentId(const QString &inlineComponentName) const + { + for (uint i = 0; i < qmlData->nObjects; ++i) { + auto *object = qmlData->objectAt(i); + for (auto it = object->inlineComponentsBegin(), end = object->inlineComponentsEnd(); + it != end; ++it) { + if (stringAt(it->nameIndex) == inlineComponentName) + return it->objectIndex; + } + } + return -1; + } + + void finalizeCompositeType(const QQmlType &type); + + bool verifyChecksum(const CompiledData::DependentTypesHasher &dependencyHasher) const; + + enum class ListPropertyAssignBehavior { Append, Replace, ReplaceIfNotDefault }; + ListPropertyAssignBehavior listPropertyAssignBehavior() const + { + if (unitData()->flags & CompiledData::Unit::ListPropertyAssignReplace) + return ListPropertyAssignBehavior::Replace; + if (unitData()->flags & CompiledData::Unit::ListPropertyAssignReplaceIfNotDefault) + return ListPropertyAssignBehavior::ReplaceIfNotDefault; + return ListPropertyAssignBehavior::Append; + } + + bool ignoresFunctionSignature() const + { + return unitData()->flags & CompiledData::Unit::FunctionSignaturesIgnored; + } + + bool nativeMethodsAcceptThisObjects() const + { + return unitData()->flags & CompiledData::Unit::NativeMethodsAcceptThisObject; + } + + bool valueTypesAreCopied() const + { + return unitData()->flags & CompiledData::Unit::ValueTypesCopied; + } + + bool valueTypesAreAddressable() const + { + return unitData()->flags & CompiledData::Unit::ValueTypesAddressable; + } + + bool valueTypesAreAssertable() const + { + return unitData()->flags & CompiledData::Unit::ValueTypesAssertable; + } + + bool componentsAreBound() const + { + return unitData()->flags & CompiledData::Unit::ComponentsBound; + } + + bool isESModule() const + { + return unitData()->flags & CompiledData::Unit::IsESModule; + } + + bool isSharedLibrary() const + { + return unitData()->flags & CompiledData::Unit::IsSharedLibrary; + } + + struct FunctionIterator + { + FunctionIterator(const CompiledData::Unit *unit, const CompiledObject *object, int index) + : unit(unit), object(object), index(index) {} + const CompiledData::Unit *unit; + const CompiledObject *object; + int index; + + const CompiledFunction *operator->() const + { + return unit->functionAt(object->functionOffsetTable()[index]); + } + + void operator++() { ++index; } + bool operator==(const FunctionIterator &rhs) const { return index == rhs.index; } + bool operator!=(const FunctionIterator &rhs) const { return index != rhs.index; } + }; + + FunctionIterator objectFunctionsBegin(const CompiledObject *object) const + { + return FunctionIterator(unitData(), object, 0); + } + + FunctionIterator objectFunctionsEnd(const CompiledObject *object) const + { + return FunctionIterator(unitData(), object, object->nFunctions); + } + + QQmlType qmlTypeForComponent(const QString &inlineComponentName = QString()) const; + QMetaType metaType() const { return qmlType.typeId(); } + +private: + QString m_fileName; // initialized from data->sourceFileIndex + QString m_finalUrlString; // initialized from data->finalUrlIndex + + mutable QQmlNullableValue<QUrl> m_url; + mutable QQmlNullableValue<QUrl> m_finalUrl; +}; + +class SaveableUnitPointer +{ + Q_DISABLE_COPY_MOVE(SaveableUnitPointer) +public: + SaveableUnitPointer(const Unit *unit, quint32 temporaryFlags = Unit::StaticData) : + unit(unit), + temporaryFlags(temporaryFlags) + { + } + + ~SaveableUnitPointer() = default; + + template<typename Char> + bool saveToDisk(const std::function<bool(const Char *, quint32)> &writer) const + { + const quint32_le oldFlags = mutableFlags(); + auto cleanup = qScopeGuard([this, oldFlags]() { mutableFlags() = oldFlags; }); + mutableFlags() |= temporaryFlags; + return writer(data<Char>(), size()); + } + + static bool writeDataToFile(const QString &outputFileName, const char *data, quint32 size, + QString *errorString) + { +#if QT_CONFIG(temporaryfile) + QSaveFile cacheFile(outputFileName); + if (!cacheFile.open(QIODevice::WriteOnly | QIODevice::Truncate) + || cacheFile.write(data, size) != size + || !cacheFile.commit()) { + *errorString = cacheFile.errorString(); + return false; + } + + errorString->clear(); + return true; +#else + Q_UNUSED(outputFileName); + *errorString = QStringLiteral("features.temporaryfile is disabled."); + return false; +#endif + } + +private: + const Unit *unit; + quint32 temporaryFlags; + + quint32_le &mutableFlags() const + { + return const_cast<Unit *>(unit)->flags; + } + + template<typename Char> + const Char *data() const + { + Q_STATIC_ASSERT(sizeof(Char) == 1); + const Char *dataPtr; + memcpy(&dataPtr, &unit, sizeof(dataPtr)); + return dataPtr; + } + + quint32 size() const + { + return unit->unitSize; + } +}; + + +} // CompiledData namespace +} // QV4 namespace + +Q_DECLARE_OPERATORS_FOR_FLAGS(QV4::CompiledData::ParameterType::Flags); +Q_DECLARE_TYPEINFO(QV4::CompiledData::JSClassMember, Q_PRIMITIVE_TYPE); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compiler_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compiler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5bba7a420e96e5ffedced529137c0474fb5f9679 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compiler_p.h @@ -0,0 +1,143 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4COMPILER_P_H +#define QV4COMPILER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> +#include <QtCore/qhash.h> +#include <QtCore/qstringlist.h> +#include <private/qv4compilerglobal_p.h> +#include <private/qqmljsastfwd_p.h> +#include <private/qv4compileddata_p.h> +#include <private/qv4staticvalue_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlPropertyData; + +namespace QV4 { + +namespace CompiledData { +struct Unit; +struct Lookup; +struct RegExp; +struct JSClassMember; +} + +namespace Compiler { + +struct Context; +struct Module; +struct Class; +struct TemplateObject; + +struct Q_QML_COMPILER_EXPORT StringTableGenerator { + StringTableGenerator(); + + int registerString(const QString &str); + int getStringId(const QString &string) const; + bool hasStringId(const QString &string) const { return stringToId.contains(string); } + QString stringForIndex(int index) const { return strings.at(index); } + uint stringCount() const { return strings.size() - backingUnitTableSize; } + + uint sizeOfTableAndData() const { return stringDataSize + ((stringCount() * sizeof(uint) + 7) & ~7); } + + void freeze() { frozen = true; } + + void clear(); + + void initializeFromBackingUnit(const CompiledData::Unit *unit); + + void serialize(CompiledData::Unit *unit); + QStringList allStrings() const { return strings.mid(backingUnitTableSize); } + +private: + QHash<QString, int> stringToId; + QStringList strings; + uint stringDataSize; + uint backingUnitTableSize = 0; + bool frozen = false; +}; + +struct Q_QML_COMPILER_EXPORT JSUnitGenerator { + enum LookupMode { LookupForStorage, LookupForCall }; + + static void generateUnitChecksum(CompiledData::Unit *unit); + + struct MemberInfo { + QString name; + bool isAccessor; + }; + + JSUnitGenerator(Module *module); + + int registerString(const QString &str) { return stringTable.registerString(str); } + int getStringId(const QString &string) const { return stringTable.getStringId(string); } + bool hasStringId(const QString &string) const { return stringTable.hasStringId(string); } + QString stringForIndex(int index) const { return stringTable.stringForIndex(index); } + + int registerGetterLookup(const QString &name, LookupMode mode); + int registerGetterLookup(int nameIndex, LookupMode mode); + int registerSetterLookup(const QString &name); + int registerSetterLookup(int nameIndex); + int registerGlobalGetterLookup(int nameIndex, LookupMode mode); + int registerQmlContextPropertyGetterLookup(int nameIndex, LookupMode mode); + int lookupNameIndex(int index) const { return lookups[index].nameIndex(); } + QString lookupName(int index) const { return stringForIndex(lookupNameIndex(index)); } + + int registerRegExp(QQmlJS::AST::RegExpLiteral *regexp); + + int registerConstant(ReturnedValue v); + ReturnedValue constant(int idx) const; + + int registerJSClass(const QStringList &members); + int jsClassSize(int jsClassId) const; + QString jsClassMember(int jsClassId, int member) const; + + int registerTranslation(const CompiledData::TranslationData &translation); + + enum GeneratorOption { + GenerateWithStringTable, + GenerateWithoutStringTable + }; + + QV4::CompiledData::Unit *generateUnit(GeneratorOption option = GenerateWithStringTable); + void writeFunction(char *f, Context *irFunction) const; + void writeClass(char *f, const Class &c); + void writeTemplateObject(char *f, const TemplateObject &o); + void writeBlock(char *f, Context *irBlock) const; + + StringTableGenerator stringTable; + QString codeGeneratorName; + +private: + CompiledData::Unit generateHeader(GeneratorOption option, quint32_le *functionOffsets, uint *jsClassDataOffset); + + Module *module; + + QList<CompiledData::Lookup> lookups; + QVector<CompiledData::RegExp> regexps; + QVector<ReturnedValue> constants; + QByteArray jsClassData; + QVector<int> jsClassOffsets; + QVector<CompiledData::TranslationData> translations; +}; + +} + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilercontext_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilercontext_p.h new file mode 100644 index 0000000000000000000000000000000000000000..00b530fb43e0ec4df4a410a4826d75d23128cf34 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilercontext_p.h @@ -0,0 +1,375 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4COMPILERCONTEXT_P_H +#define QV4COMPILERCONTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmljsast_p.h> +#include <private/qv4compileddata_p.h> +#include <QtCore/QStringList> +#include <QtCore/QDateTime> +#include <QtCore/QStack> +#include <QtCore/QHash> +#include <QtCore/QMap> +#include <QtCore/QSet> +#include <QtCore/QVarLengthArray> + +#include <memory> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Moth { +class BytecodeGenerator; +} + +namespace Compiler { + +class Codegen; +struct ControlFlow; + +enum class ContextType { + Global, + Function, + Eval, + Binding, // This is almost the same as Eval, except: + // * function declarations are moved to the return address when encountered + // * return statements are allowed everywhere (like in FunctionCode) + // * variable declarations are treated as true locals (like in FunctionCode) + Block, + ESModule, + ScriptImportedByQML, +}; + +struct Context; + +struct Class { + struct Method { + enum Type { + Regular, + Getter, + Setter + }; + uint nameIndex; + Type type; + uint functionIndex; + }; + + uint nameIndex; + uint constructorIndex = UINT_MAX; + QVector<Method> staticMethods; + QVector<Method> methods; +}; + +struct TemplateObject { + QVector<uint> strings; + QVector<uint> rawStrings; + bool operator==(const TemplateObject &other) { + return strings == other.strings && rawStrings == other.rawStrings; + } +}; + +struct ExportEntry +{ + QString exportName; + QString moduleRequest; + QString importName; + QString localName; + CompiledData::Location location; + + static bool lessThan(const ExportEntry &lhs, const ExportEntry &rhs) + { return lhs.exportName < rhs.exportName; } +}; + +struct ImportEntry +{ + QString moduleRequest; + QString importName; + QString localName; + CompiledData::Location location; +}; + +struct Module { + Module(bool debugMode) + : debugMode(debugMode) + {} + ~Module() { + qDeleteAll(contextMap); + } + + Context *newContext(QQmlJS::AST::Node *node, Context *parent, ContextType compilationMode); + + QHash<QQmlJS::AST::Node *, Context *> contextMap; + QList<Context *> functions; + QList<Context *> blocks; + QVector<Class> classes; + QVector<TemplateObject> templateObjects; + Context *rootContext; + QString fileName; + QString finalUrl; + QDateTime sourceTimeStamp; + uint unitFlags = 0; // flags merged into CompiledData::Unit::flags + bool debugMode = false; + QVector<ExportEntry> localExportEntries; + QVector<ExportEntry> indirectExportEntries; + QVector<ExportEntry> starExportEntries; + QVector<ImportEntry> importEntries; + QStringList moduleRequests; +}; + + +struct Context { + Context *parent; + QString name; + int line = 0; + int column = 0; + int registerCountInFunction = 0; + int functionIndex = -1; + int blockIndex = -1; + + enum MemberType { + UndefinedMember, + ThisFunctionName, + VariableDefinition, + VariableDeclaration, + FunctionDefinition + }; + + struct SourceLocationTable + { + struct Entry + { + quint32 offset; + QQmlJS::SourceLocation location; + }; + QVector<Entry> entries; + }; + + struct Member { + MemberType type = UndefinedMember; + int index = -1; + QQmlJS::AST::VariableScope scope = QQmlJS::AST::VariableScope::Var; + mutable bool canEscape = false; + bool isInjected = false; + QQmlJS::AST::FunctionExpression *function = nullptr; + QQmlJS::SourceLocation declarationLocation; + + bool isLexicallyScoped() const { return this->scope != QQmlJS::AST::VariableScope::Var; } + bool requiresTDZCheck(const QQmlJS::SourceLocation &accessLocation, bool accessAcrossContextBoundaries) const; + }; + typedef QMap<QString, Member> MemberMap; + + MemberMap members; + QSet<QString> usedVariables; + QQmlJS::AST::FormalParameterList *formals = nullptr; + QQmlJS::AST::BoundNames arguments; + QQmlJS::AST::Type *returnType = nullptr; + QStringList locals; + QStringList moduleRequests; + QVector<ImportEntry> importEntries; + QVector<ExportEntry> exportEntries; + QString localNameForDefaultExport; + QVector<Context *> nestedContexts; + + ControlFlow *controlFlow = nullptr; + QByteArray code; + QVector<CompiledData::CodeOffsetToLineAndStatement> lineAndStatementNumberMapping; + std::unique_ptr<SourceLocationTable> sourceLocationTable; + std::vector<unsigned> labelInfo; + + int nRegisters = 0; + int registerOffset = -1; + int sizeOfLocalTemporalDeadZone = 0; + int firstTemporalDeadZoneRegister = 0; + int sizeOfRegisterTemporalDeadZone = 0; + bool hasDirectEval = false; + bool allVarsEscape = false; + bool hasNestedFunctions = false; + bool isStrict = false; + bool isArrowFunction = false; + bool isGenerator = false; + bool usesThis = false; + bool innerFunctionAccessesThis = false; + bool innerFunctionAccessesNewTarget = false; + bool returnsClosure = false; + mutable bool argumentsCanEscape = false; + bool requiresExecutionContext = false; + bool isWithBlock = false; + bool isCatchBlock = false; + QString caughtVariable; + QQmlJS::SourceLocation lastBlockInitializerLocation; + + enum UsesArgumentsObject { + ArgumentsObjectUnknown, + ArgumentsObjectNotUsed, + ArgumentsObjectUsed + }; + + UsesArgumentsObject usesArgumentsObject = ArgumentsObjectUnknown; + + ContextType contextType; + + template <typename T> + class SmallSet: public QVarLengthArray<T, 8> + { + public: + void insert(int value) + { + for (auto it : *this) { + if (it == value) + return; + } + this->append(value); + } + }; + + // Map from meta property index (existence implies dependency) to notify signal index + struct KeyValuePair + { + quint32 _key = 0; + quint32 _value = 0; + + KeyValuePair() {} + KeyValuePair(quint32 key, quint32 value): _key(key), _value(value) {} + + quint32 key() const { return _key; } + quint32 value() const { return _value; } + }; + + class PropertyDependencyMap: public QVarLengthArray<KeyValuePair, 8> + { + public: + void insert(quint32 key, quint32 value) + { + for (auto it = begin(), eit = end(); it != eit; ++it) { + if (it->_key == key) { + it->_value = value; + return; + } + } + append(KeyValuePair(key, value)); + } + }; + + Context(Context *parent, ContextType type) + : parent(parent) + , contextType(type) + { + if (parent && parent->isStrict) + isStrict = true; + } + + bool hasArgument(const QString &name) const + { + return arguments.contains(name); + } + + int findArgument(const QString &name, bool *isInjected) const + { + // search backwards to handle duplicate argument names correctly + for (int i = arguments.size() - 1; i >= 0; --i) { + const auto &arg = arguments.at(i); + if (arg.id == name) { + *isInjected = arg.isInjected(); + return i; + } + } + return -1; + } + + Member findMember(const QString &name) const + { + MemberMap::const_iterator it = members.find(name); + if (it == members.end()) + return Member(); + Q_ASSERT(it->index != -1 || !parent); + return (*it); + } + + bool memberInfo(const QString &name, const Member **m) const + { + Q_ASSERT(m); + MemberMap::const_iterator it = members.find(name); + if (it == members.end()) { + *m = nullptr; + return false; + } + *m = &(*it); + return true; + } + + bool requiresImplicitReturnValue() const { + return contextType == ContextType::Binding || + contextType == ContextType::Eval || + contextType == ContextType::Global || contextType == ContextType::ScriptImportedByQML; + } + + void addUsedVariable(const QString &name) { + usedVariables.insert(name); + } + + bool addLocalVar( + const QString &name, MemberType contextType, QQmlJS::AST::VariableScope scope, + QQmlJS::AST::FunctionExpression *function = nullptr, + const QQmlJS::SourceLocation &declarationLocation = QQmlJS::SourceLocation(), + bool isInjected = false); + + struct ResolvedName { + enum Type { + Unresolved, + QmlGlobal, + Global, + Local, + Stack, + Import + }; + Type type = Unresolved; + bool isArgOrEval = false; + bool isConst = false; + bool requiresTDZCheck = false; + bool isInjected = false; + int scope = -1; + int index = -1; + QQmlJS::SourceLocation declarationLocation; + bool isValid() const { return type != Unresolved; } + }; + ResolvedName resolveName(const QString &name, const QQmlJS::SourceLocation &accessLocation); + void emitBlockHeader(Compiler::Codegen *codegen); + void emitBlockFooter(Compiler::Codegen *codegen); + + void setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator); + + bool canHaveTailCalls() const + { + if (!isStrict) + return false; + if (contextType == ContextType::Function) + return !isGenerator; + if (contextType == ContextType::Block && parent) + return parent->canHaveTailCalls(); + return false; + } + + bool isCaseBlock() const + { + return contextType == ContextType::Block && name == u"%CaseBlock"; + } +}; + + +} } // namespace QV4::Compiler + +QT_END_NAMESPACE + +#endif // QV4CODEGEN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilercontrolflow_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilercontrolflow_p.h new file mode 100644 index 0000000000000000000000000000000000000000..99297bceaa5b016a669118ccd9ef2585a57f7a33 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilercontrolflow_p.h @@ -0,0 +1,404 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4COMPILERCONTROLFLOW_P_H +#define QV4COMPILERCONTROLFLOW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4codegen_p.h> +#include <private/qqmljsast_p.h> +#include <private/qv4bytecodegenerator_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Compiler { + +struct ControlFlow { + using Reference = Codegen::Reference; + using BytecodeGenerator = Moth::BytecodeGenerator; + using Instruction = Moth::Instruction; + + enum Type { + Loop, + With, + Block, + Finally, + Catch + }; + + enum UnwindType { + Break, + Continue, + Return + }; + + struct UnwindTarget { + BytecodeGenerator::Label linkLabel; + int unwindLevel; + }; + + Codegen *cg; + ControlFlow *parent; + Type type; + + ControlFlow(Codegen *cg, Type type) + : cg(cg), parent(cg->controlFlow), type(type) + { + cg->controlFlow = this; + } + + virtual ~ControlFlow() { + cg->controlFlow = parent; + } + + UnwindTarget unwindTarget(UnwindType type, const QString &label = QString()) + { + Q_ASSERT(type == Break || type == Continue || type == Return); + ControlFlow *flow = this; + int level = 0; + while (flow) { + BytecodeGenerator::Label l = flow->getUnwindTarget(type, label); + if (l.isValid()) + return UnwindTarget{l, level}; + if (flow->requiresUnwind()) + ++level; + flow = flow->parent; + } + if (type == Return) + return UnwindTarget{ cg->returnLabel(), level }; + return UnwindTarget(); + } + + virtual QString label() const { return QString(); } + + bool hasLoop() const { + const ControlFlow *flow = this; + while (flow) { + if (flow->type == Loop) + return true; + flow = flow->parent; + } + return false; + } + +protected: + virtual BytecodeGenerator::Label getUnwindTarget(UnwindType, const QString & = QString()) { + return BytecodeGenerator::Label(); + } + virtual bool requiresUnwind() { + return false; + } + +public: + BytecodeGenerator::ExceptionHandler *parentUnwindHandler() { + return parent ? parent->unwindHandler() : nullptr; + } + + virtual BytecodeGenerator::ExceptionHandler *unwindHandler() { + return parentUnwindHandler(); + } + + +protected: + QString loopLabel() const { + QString label; + if (cg->_labelledStatement) { + label = cg->_labelledStatement->label.toString(); + cg->_labelledStatement = nullptr; + } + return label; + } + BytecodeGenerator *generator() const { + return cg->bytecodeGenerator; + } +}; + +struct ControlFlowUnwind : public ControlFlow +{ + BytecodeGenerator::ExceptionHandler unwindLabel; + + ControlFlowUnwind(Codegen *cg, Type type) + : ControlFlow(cg, type) + { + } + + void setupUnwindHandler() + { + unwindLabel = generator()->newExceptionHandler(); + } + + void emitUnwindHandler() + { + Q_ASSERT(requiresUnwind()); + + Instruction::UnwindDispatch dispatch; + generator()->addInstruction(dispatch); + } + + virtual BytecodeGenerator::ExceptionHandler *unwindHandler() override { + return unwindLabel.isValid() ? &unwindLabel : parentUnwindHandler(); + } +}; + +struct ControlFlowUnwindCleanup : public ControlFlowUnwind +{ + std::function<void()> cleanup = nullptr; + + ControlFlowUnwindCleanup(Codegen *cg, std::function<void()> cleanup, Type type = Block) + : ControlFlowUnwind(cg, type), cleanup(cleanup) + { + if (cleanup) { + setupUnwindHandler(); + generator()->setUnwindHandler(&unwindLabel); + } + } + + ~ControlFlowUnwindCleanup() { + if (cleanup) { + unwindLabel.link(); + cleanup(); + generator()->setUnwindHandler(parentUnwindHandler()); + emitUnwindHandler(); + } + } + + bool requiresUnwind() override { + return cleanup != nullptr; + } +}; + +struct ControlFlowLoop : public ControlFlowUnwindCleanup +{ + QString loopLabel; + BytecodeGenerator::Label *breakLabel = nullptr; + BytecodeGenerator::Label *continueLabel = nullptr; + + ControlFlowLoop(Codegen *cg, BytecodeGenerator::Label *breakLabel, BytecodeGenerator::Label *continueLabel = nullptr, std::function<void()> cleanup = nullptr) + : ControlFlowUnwindCleanup(cg, cleanup, Loop), loopLabel(ControlFlow::loopLabel()), breakLabel(breakLabel), continueLabel(continueLabel) + { + } + + BytecodeGenerator::Label getUnwindTarget(UnwindType type, const QString &label) override { + switch (type) { + case Break: + if (breakLabel && (label.isEmpty() || label == loopLabel)) + return *breakLabel; + break; + case Continue: + if (continueLabel && (label.isEmpty() || label == loopLabel)) + return *continueLabel; + break; + default: + break; + } + return BytecodeGenerator::Label(); + } + + QString label() const override { return loopLabel; } +}; + + +struct ControlFlowWith : public ControlFlowUnwind +{ + ControlFlowWith(Codegen *cg) + : ControlFlowUnwind(cg, With) + { + setupUnwindHandler(); + + // assumes the with object is in the accumulator + Instruction::PushWithContext pushScope; + generator()->addInstruction(pushScope); + generator()->setUnwindHandler(&unwindLabel); + } + + ~ControlFlowWith() { + // emit code for unwinding + unwindLabel.link(); + + generator()->setUnwindHandler(parentUnwindHandler()); + Instruction::PopContext pop; + generator()->addInstruction(pop); + + emitUnwindHandler(); + } + + bool requiresUnwind() override { + return true; + } + + +}; + +struct ControlFlowBlock : public ControlFlowUnwind +{ + ControlFlowBlock(Codegen *cg, QQmlJS::AST::Node *ast) + : ControlFlowUnwind(cg, Block) + { + block = cg->enterBlock(ast); + block->emitBlockHeader(cg); + + if (block->requiresExecutionContext) { + setupUnwindHandler(); + generator()->setUnwindHandler(&unwindLabel); + } + } + + virtual ~ControlFlowBlock() { + // emit code for unwinding + if (block->requiresExecutionContext) { + unwindLabel.link(); + generator()->setUnwindHandler(parentUnwindHandler()); + } + + block->emitBlockFooter(cg); + + if (block->requiresExecutionContext ) + emitUnwindHandler(); + cg->leaveBlock(); + } + + virtual bool requiresUnwind() override { + return block->requiresExecutionContext; + } + + Context *block; +}; + +struct ControlFlowCatch : public ControlFlowUnwind +{ + QQmlJS::AST::Catch *catchExpression; + bool insideCatch = false; + BytecodeGenerator::ExceptionHandler exceptionLabel; + + ControlFlowCatch(Codegen *cg, QQmlJS::AST::Catch *catchExpression) + : ControlFlowUnwind(cg, Catch), catchExpression(catchExpression), + exceptionLabel(generator()->newExceptionHandler()) + { + generator()->setUnwindHandler(&exceptionLabel); + } + + virtual bool requiresUnwind() override { + return true; + } + + BytecodeGenerator::ExceptionHandler *unwindHandler() override { + return insideCatch ? &unwindLabel : &exceptionLabel; + } + + ~ControlFlowCatch() { + // emit code for unwinding + insideCatch = true; + setupUnwindHandler(); + + Codegen::RegisterScope scope(cg); + + // exceptions inside the try block go here + exceptionLabel.link(); + BytecodeGenerator::Jump noException = generator()->jumpNoException(); + + Context *block = cg->enterBlock(catchExpression); + + block->emitBlockHeader(cg); + + generator()->setUnwindHandler(&unwindLabel); + + if (catchExpression->patternElement->bindingIdentifier.isEmpty()) + // destructuring pattern + cg->initializeAndDestructureBindingElement(catchExpression->patternElement, Reference::fromName(cg, QStringLiteral("@caught"))); + // skip the additional block + cg->statementList(catchExpression->statement->statements); + + // exceptions inside catch and break/return statements go here + unwindLabel.link(); + block->emitBlockFooter(cg); + + cg->leaveBlock(); + + noException.link(); + generator()->setUnwindHandler(parentUnwindHandler()); + + emitUnwindHandler(); + insideCatch = false; + } +}; + +struct ControlFlowFinally : public ControlFlowUnwind +{ + QQmlJS::AST::Finally *finally; + bool insideFinally = false; + + ControlFlowFinally(Codegen *cg, QQmlJS::AST::Finally *finally, bool hasCatchBlock) + : ControlFlowUnwind(cg, Finally), finally(finally) + { + Q_ASSERT(finally != nullptr); + setupUnwindHandler(); + + // No need to set the handler for the finally now if there is a catch block. + // In that case, a handler for the latter will be set immediately after this. + if (!hasCatchBlock) { + generator()->setUnwindHandler(&unwindLabel); + } + } + + virtual bool requiresUnwind() override { + return !insideFinally; + } + + BytecodeGenerator::ExceptionHandler *unwindHandler() override { + return insideFinally ? parentUnwindHandler() : ControlFlowUnwind::unwindHandler(); + } + + ~ControlFlowFinally() { + // emit code for unwinding + unwindLabel.link(); + + Codegen::RegisterScope scope(cg); + + insideFinally = true; + int returnValueTemp = -1; + if (cg->requiresReturnValue) { + returnValueTemp = generator()->newRegister(); + Instruction::MoveReg move; + move.srcReg = cg->_returnAddress; + move.destReg = returnValueTemp; + generator()->addInstruction(move); + } + int exceptionTemp = generator()->newRegister(); + Instruction::GetException instr; + generator()->addInstruction(instr); + Reference::fromStackSlot(cg, exceptionTemp).storeConsumeAccumulator(); + + generator()->setUnwindHandler(parentUnwindHandler()); + cg->statement(finally->statement); + insideFinally = false; + + if (cg->requiresReturnValue) { + Instruction::MoveReg move; + move.srcReg = returnValueTemp; + move.destReg = cg->_returnAddress; + generator()->addInstruction(move); + } + Reference::fromStackSlot(cg, exceptionTemp).loadInAccumulator(); + Instruction::SetException setException; + generator()->addInstruction(setException); + + emitUnwindHandler(); + } +}; + +} } // QV4::Compiler namespace + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilerglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilerglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f7fa1092ba468cdac6669d3604f6b01a832f2e09 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilerglobal_p.h @@ -0,0 +1,38 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4COMPILERGLOBAL_H +#define QV4COMPILERGLOBAL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QString> + +#include <private/qtqmlcompilerglobal_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +enum class ObjectLiteralArgument { + Value, + Method, + Getter, + Setter +}; + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4COMPILERGLOBAL_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilerscanfunctions_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilerscanfunctions_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d25f675472a14214d5cb5c30c50280eec79a7d90 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4compilerscanfunctions_p.h @@ -0,0 +1,168 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4COMPILERSCANFUNCTIONS_P_H +#define QV4COMPILERSCANFUNCTIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlcompilerglobal_p.h> +#include <private/qqmljsastvisitor_p.h> +#include <private/qqmljsast_p.h> +#include <private/qqmljsengine_p.h> +#include <private/qv4compilercontext_p.h> +#include <private/qv4util_p.h> +#include <QtCore/QStringList> +#include <QStack> +#include <QScopedValueRollback> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Moth { +struct Instruction; +} + +namespace CompiledData { +struct CompilationUnit; +} + +namespace Compiler { + +class Codegen; + +class ScanFunctions: protected QQmlJS::AST::Visitor +{ + typedef QScopedValueRollback<bool> TemporaryBoolAssignment; +public: + ScanFunctions(Codegen *cg, const QString &sourceCode, ContextType defaultProgramType); + void operator()(QQmlJS::AST::Node *node); + + // see comment at its call site in generateJSCodeForFunctionsAndBindings + // for why this function is necessary + void handleTopLevelFunctionFormals(QQmlJS::AST::FunctionExpression *node) { + if (node && node->formals) + node->formals->accept(this); + } + + void enterGlobalEnvironment(ContextType compilationMode); + void enterEnvironment(QQmlJS::AST::Node *node, ContextType compilationMode, + const QString &name); + void leaveEnvironment(); + + void enterQmlFunction(QQmlJS::AST::FunctionExpression *ast) + { enterFunction(ast, FunctionNameContext::None); } + +protected: + // Function declarations add their name to the outer scope, but not the + // inner scope. Function expressions add their name to the inner scope, + // unless the name is actually picked from the outer scope rather than + // given after the function token. QML functions don't add their name + // anywhere because the name is already recorded in the QML element. + // This enum is used to control the behavior of enterFunction(). + enum class FunctionNameContext { + None, Inner, Outer + }; + + using Visitor::visit; + using Visitor::endVisit; + + void checkDirectivePrologue(QQmlJS::AST::StatementList *ast); + + void checkName(QStringView name, const QQmlJS::SourceLocation &loc); + + bool visit(QQmlJS::AST::Program *ast) override; + void endVisit(QQmlJS::AST::Program *) override; + + bool visit(QQmlJS::AST::ESModule *ast) override; + void endVisit(QQmlJS::AST::ESModule *) override; + + bool visit(QQmlJS::AST::ExportDeclaration *declaration) override; + bool visit(QQmlJS::AST::ImportDeclaration *declaration) override; + + bool visit(QQmlJS::AST::CallExpression *ast) override; + bool visit(QQmlJS::AST::PatternElement *ast) override; + bool visit(QQmlJS::AST::IdentifierExpression *ast) override; + bool visit(QQmlJS::AST::ExpressionStatement *ast) override; + bool visit(QQmlJS::AST::FunctionExpression *ast) override; + bool visit(QQmlJS::AST::TemplateLiteral *ast) override; + bool visit(QQmlJS::AST::SuperLiteral *) override; + bool visit(QQmlJS::AST::FieldMemberExpression *) override; + bool visit(QQmlJS::AST::ArrayPattern *) override; + + bool enterFunction(QQmlJS::AST::FunctionExpression *ast, + FunctionNameContext nameContext); + + void endVisit(QQmlJS::AST::FunctionExpression *) override; + + bool visit(QQmlJS::AST::ObjectPattern *ast) override; + + bool visit(QQmlJS::AST::PatternProperty *ast) override; + void endVisit(QQmlJS::AST::PatternProperty *) override; + + bool visit(QQmlJS::AST::FunctionDeclaration *ast) override; + void endVisit(QQmlJS::AST::FunctionDeclaration *) override; + + bool visit(QQmlJS::AST::ClassExpression *ast) override; + void endVisit(QQmlJS::AST::ClassExpression *) override; + + bool visit(QQmlJS::AST::ClassDeclaration *ast) override; + void endVisit(QQmlJS::AST::ClassDeclaration *) override; + + bool visit(QQmlJS::AST::DoWhileStatement *ast) override; + bool visit(QQmlJS::AST::ForStatement *ast) override; + void endVisit(QQmlJS::AST::ForStatement *) override; + bool visit(QQmlJS::AST::ForEachStatement *ast) override; + void endVisit(QQmlJS::AST::ForEachStatement *) override; + + bool visit(QQmlJS::AST::ThisExpression *ast) override; + + bool visit(QQmlJS::AST::Block *ast) override; + void endVisit(QQmlJS::AST::Block *ast) override; + + bool visit(QQmlJS::AST::CaseBlock *ast) override; + void endVisit(QQmlJS::AST::CaseBlock *ast) override; + + bool visit(QQmlJS::AST::Catch *ast) override; + void endVisit(QQmlJS::AST::Catch *ast) override; + + bool visit(QQmlJS::AST::WithStatement *ast) override; + void endVisit(QQmlJS::AST::WithStatement *ast) override; + + void throwRecursionDepthError() override; + +protected: + bool enterFunction(QQmlJS::AST::Node *ast, const QString &name, + QQmlJS::AST::FormalParameterList *formals, + QQmlJS::AST::StatementList *body, FunctionNameContext nameContext); + + void calcEscapingVariables(); +// fields: + Codegen *_cg; + const QString _sourceCode; + Context *_context; + QStack<Context *> _contextStack; + + bool _allowFuncDecls; + ContextType defaultProgramType; + +private: + static constexpr QQmlJS::AST::Node *astNodeForGlobalEnvironment = nullptr; +}; + +} + +} + +QT_END_NAMESPACE + +#endif // QV4CODEGEN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4context_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4context_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5b9e7ec4dcf860d77d3b7073654f8310c7980e23 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4context_p.h @@ -0,0 +1,174 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QMLJS_ENVIRONMENT_H +#define QMLJS_ENVIRONMENT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" +#include "qv4managed_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + + +namespace Heap { + +#define ExecutionContextMembers(class, Member) \ + Member(class, Pointer, ExecutionContext *, outer) \ + Member(class, Pointer, Object *, activation) + +DECLARE_HEAP_OBJECT(ExecutionContext, Base) { + DECLARE_MARKOBJECTS(ExecutionContext) + + enum ContextType { + Type_GlobalContext = 0x1, + Type_WithContext = 0x2, + Type_QmlContext = 0x3, + Type_BlockContext = 0x4, + Type_CallContext = 0x5 + }; + + void init(ContextType t) + { + Base::init(); + + type = t; + } + + const VTable *vtable() const { + return internalClass->vtable; + } + + quint32 type : 8; + quint32 nArgs : 24; +#if QT_POINTER_SIZE == 8 + quint8 padding_[4]; +#endif +}; +Q_STATIC_ASSERT(std::is_trivial_v<ExecutionContext>); +Q_STATIC_ASSERT(sizeof(ExecutionContext) == sizeof(Base) + sizeof(ExecutionContextData) + QT_POINTER_SIZE); + +Q_STATIC_ASSERT(std::is_standard_layout<ExecutionContextData>::value); +Q_STATIC_ASSERT(offsetof(ExecutionContextData, outer) == 0); +Q_STATIC_ASSERT(offsetof(ExecutionContextData, activation) == offsetof(ExecutionContextData, outer) + QT_POINTER_SIZE); + +#define CallContextMembers(class, Member) \ + Member(class, Pointer, JavaScriptFunctionObject *, function) \ + Member(class, ValueArray, ValueArray, locals) + +DECLARE_HEAP_OBJECT(CallContext, ExecutionContext) { + DECLARE_MARKOBJECTS(CallContext) + + void init() + { + ExecutionContext::init(Type_CallContext); + } + + int argc() const { + return static_cast<int>(nArgs); + } + const Value *args() const { + return locals.data() + locals.size; + } + void setArg(uint index, Value v); + + template <typename BlockOrFunction> + void setupLocalTemporalDeadZone(BlockOrFunction *bof) { + for (uint i = bof->nLocals - bof->sizeOfLocalTemporalDeadZone; i < bof->nLocals; ++i) + locals.values[i] = Value::emptyValue(); + } +}; +Q_STATIC_ASSERT(std::is_trivial_v<CallContext>); +Q_STATIC_ASSERT(std::is_standard_layout<CallContextData>::value); +Q_STATIC_ASSERT(offsetof(CallContextData, function) == 0); +//### The following size check fails on Win8. With the ValueArray at the end of the +// CallContextMembers, it doesn't look very useful. +//#if defined(Q_PROCESSOR_ARM_32) && !defined(Q_OS_IOS) +//Q_STATIC_ASSERT(sizeof(CallContext) == sizeof(ExecutionContext) + sizeof(CallContextData) + QT_POINTER_SIZE); +//#else +//Q_STATIC_ASSERT(sizeof(CallContext) == sizeof(ExecutionContext) + sizeof(CallContextData)); +//#endif + + +} + +struct Q_QML_EXPORT ExecutionContext : public Managed +{ + enum { + IsExecutionContext = true + }; + + V4_MANAGED(ExecutionContext, Managed) + Q_MANAGED_TYPE(ExecutionContext) + V4_INTERNALCLASS(ExecutionContext) + + static Heap::CallContext *newBlockContext(QV4::CppStackFrame *frame, int blockIndex); + static Heap::CallContext *cloneBlockContext(ExecutionEngine *engine, + Heap::CallContext *callContext); + static Heap::CallContext *newCallContext(JSTypesStackFrame *frame); + Heap::ExecutionContext *newWithContext(Heap::Object *with) const; + static Heap::ExecutionContext *newCatchContext(CppStackFrame *frame, int blockIndex, Heap::String *exceptionVarName); + + void createMutableBinding(String *name, bool deletable); + + enum Error { + NoError, + TypeError, + RangeError + }; + + Error setProperty(String *name, const Value &value); + + ReturnedValue getProperty(String *name); + ReturnedValue getPropertyAndBase(String *name, Value *base); + bool deleteProperty(String *name); + + inline CallContext *asCallContext(); + inline const CallContext *asCallContext() const; + +protected: + // vtable method required for compilation + static bool virtualDeleteProperty(Managed *, PropertyKey) { + Q_UNREACHABLE(); + } +}; + +struct Q_QML_EXPORT CallContext : public ExecutionContext +{ + V4_MANAGED(CallContext, ExecutionContext) + V4_INTERNALCLASS(CallContext) + + int argc() const { + return d()->argc(); + } + const Value *args() const { + return d()->args(); + } +}; + +inline CallContext *ExecutionContext::asCallContext() +{ + return d()->type == Heap::ExecutionContext::Type_CallContext ? static_cast<CallContext *>(this) : nullptr; +} + +inline const CallContext *ExecutionContext::asCallContext() const +{ + return d()->type == Heap::ExecutionContext::Type_CallContext ? static_cast<const CallContext *>(this) : nullptr; +} + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4dataview_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4dataview_p.h new file mode 100644 index 0000000000000000000000000000000000000000..641243aba259f9a8505c042640657de4ad048217 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4dataview_p.h @@ -0,0 +1,82 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4DATAVIEW_H +#define QV4DATAVIEW_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct DataViewCtor : FunctionObject { + void init(ExecutionEngine *engine); +}; + +#define DataViewMembers(class, Member) \ + Member(class, Pointer, SharedArrayBuffer *, buffer) \ + Member(class, NoMark, uint, byteLength) \ + Member(class, NoMark, uint, byteOffset) + +DECLARE_HEAP_OBJECT(DataView, Object) { + DECLARE_MARKOBJECTS(DataView) + void init() { Object::init(); } +}; + +} + +struct DataViewCtor: FunctionObject +{ + V4_OBJECT2(DataViewCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct DataView : Object +{ + V4_OBJECT2(DataView, Object) + V4_PROTOTYPE(dataViewPrototype) +}; + +struct DataViewPrototype: Object +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_get_buffer(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_byteOffset(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + template <typename T> + static ReturnedValue method_getChar(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + template <typename T> + static ReturnedValue method_get(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + template <typename T> + static ReturnedValue method_getFloat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + template <typename T> + static ReturnedValue method_setChar(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + template <typename T> + static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + template <typename T> + static ReturnedValue method_setFloat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4dateobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4dateobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..16d2d9e50451521d5d069a9a13836ef078c7cfe7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4dateobject_p.h @@ -0,0 +1,298 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4DATEOBJECT_P_H +#define QV4DATEOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" +#include "qv4referenceobject_p.h" +#include <QtCore/private/qnumeric_p.h> +#include <QtCore/qdatetime.h> + +QT_BEGIN_NAMESPACE + +class QDateTime; + +namespace QV4 { + +struct Date +{ + static constexpr quint64 MaxDateVal = 8.64e15; + + void init() { storage = InvalidDateVal; } + void init(double value); + void init(const QDateTime &dateTime); + void init(QDate date); + void init(QTime time, ExecutionEngine *engine); + + Date &operator=(double value) + { + storage = (storage & (HasQDate | HasQTime)) | encode(value); + return *this; + } + + operator double() const + { + const quint64 raw = (storage & ~(HasQDate | HasQTime)); + if (raw == 0) + return qt_qnan(); + + if (raw > MaxDateVal) + return double(raw - MaxDateVal - Extra); + + return double(raw) - double(MaxDateVal) - double(Extra); + } + + QDate toQDate() const; + QTime toQTime() const; + QDateTime toQDateTime() const; + QVariant toVariant() const; + + template<typename Function> + bool withStoragePointer(Function function) + { + switch (storage & (HasQDate | HasQTime)) { + case HasQDate: { + QDate date = toQDate(); + return function(&date); + } + case HasQTime: { + QTime time = toQTime(); + return function(&time); + } + case (HasQTime | HasQDate): { + QDateTime dateTime = toQDateTime(); + return function(&dateTime); + } + default: + return false; + } + } + +private: + static constexpr quint64 InvalidDateVal = 0; + static constexpr quint64 Extra = 1; + static constexpr quint64 HasQDate = 1ull << 63; + static constexpr quint64 HasQTime = 1ull << 62; + + // Make all our dates fit into quint64, leaving space for the flags + static_assert(((MaxDateVal * 2 + Extra) & (HasQDate | HasQTime)) == 0ull); + + static quint64 encode(double value); + static quint64 encode(const QDateTime &dateTime); + + quint64 storage; +}; + +namespace Heap { + +#define DateObjectMembers(class, Member) +DECLARE_HEAP_OBJECT(DateObject, ReferenceObject) { + DECLARE_MARKOBJECTS(DateObject); + + void doSetLocation() + { + if (CppStackFrame *frame = internalClass->engine->currentStackFrame) + setLocation(frame->v4Function, frame->statementNumber()); + } + + void init() + { + ReferenceObject::init(nullptr, -1, {}); + m_date.init(); + } + + void init(double dateTime) + { + ReferenceObject::init(nullptr, -1, {}); + m_date.init(dateTime); + } + + void init(const QDateTime &dateTime) + { + ReferenceObject::init(nullptr, -1, {}); + m_date.init(dateTime); + } + + void init(const QDateTime &dateTime, Heap::Object *parent, int property, Flags flags) + { + ReferenceObject::init(parent, property, flags | EnforcesLocation); + doSetLocation(); + m_date.init(dateTime); + }; + + void init(QDate date, Heap::Object *parent, int property, Flags flags) + { + ReferenceObject::init(parent, property, flags | EnforcesLocation); + doSetLocation(); + m_date.init(date); + }; + + void init(QTime time, Heap::Object *parent, int property, Flags flags) + { + ReferenceObject::init(parent, property, flags | EnforcesLocation); + doSetLocation(); + m_date.init(time, internalClass->engine); + }; + + void setDate(double newDate) + { + m_date = newDate; + if (isAttachedToProperty()) + writeBack(); + } + + double date() const + { + return m_date; + } + + QVariant toVariant() const { return m_date.toVariant(); } + QDateTime toQDateTime() const { return m_date.toQDateTime(); } + +private: + bool writeBack() + { + if (!object() || !canWriteBack()) + return false; + + QV4::Scope scope(internalClass->engine); + QV4::ScopedObject o(scope, object()); + + int flags = 0; + int status = -1; + if (isVariant()) { + QVariant variant = toVariant(); + void *a[] = { &variant, nullptr, &status, &flags }; + return o->metacall(QMetaObject::WriteProperty, property(), a); + } + + return m_date.withStoragePointer([&](void *storagePointer) { + void *a[] = { storagePointer, nullptr, &status, &flags }; + return o->metacall(QMetaObject::WriteProperty, property(), a); + }); + } + + Date m_date; +}; + + +struct DateCtor : FunctionObject { + void init(QV4::ExecutionEngine *engine); +}; + +} + +struct DateObject: ReferenceObject { + V4_OBJECT2(DateObject, ReferenceObject) + Q_MANAGED_TYPE(DateObject) + V4_PROTOTYPE(datePrototype) + + void setDate(double date) { d()->setDate(date); } + double date() const { return d()->date(); } + + Q_QML_EXPORT QDateTime toQDateTime() const; + QString toString() const; + + static QString dateTimeToString(const QDateTime &dateTime, ExecutionEngine *engine); + static double dateTimeToNumber(const QDateTime &dateTime); + static QDate dateTimeToDate(const QDateTime &dateTime); + static QDateTime stringToDateTime(const QString &string, ExecutionEngine *engine); + static QDateTime timestampToDateTime(double timestamp, QTimeZone zone = QTimeZone::LocalTime); + static double componentsToTimestamp( + double year, double month, double day, + double hours, double mins, double secs, double ms, + ExecutionEngine *v4); +}; + +template<> +inline const DateObject *Value::as() const { + return isManaged() && m()->internalClass->vtable->type == Managed::Type_DateObject ? static_cast<const DateObject *>(this) : nullptr; +} + +struct DateCtor: FunctionObject +{ + V4_OBJECT2(DateCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int); +}; + +struct DatePrototype: Object +{ + V4_PROTOTYPE(objectPrototype) + + void init(ExecutionEngine *engine, Object *ctor); + + static double getThisDate(ExecutionEngine *v4, const Value *thisObject); + + static ReturnedValue method_parse(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_UTC(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_now(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toDateString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toTimeString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toLocaleString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toLocaleDateString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toLocaleTimeString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getTime(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getFullYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getUTCFullYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getMonth(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getUTCMonth(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getDate(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getUTCDate(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getDay(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getUTCDay(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getHours(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getUTCHours(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getMinutes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getUTCMinutes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getSeconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getUTCSeconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getMilliseconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getUTCMilliseconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getTimezoneOffset(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setTime(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setMilliseconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setUTCMilliseconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setSeconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setUTCSeconds(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setMinutes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setUTCMinutes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setHours(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setUTCHours(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setDate(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setUTCDate(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setMonth(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setUTCMonth(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setFullYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setUTCFullYear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toUTCString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toISOString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toJSON(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_symbolToPrimitive(const FunctionObject *f, const Value *thisObject, const Value *, int); + + static void timezoneUpdated(ExecutionEngine *e); +}; + +} + +QT_END_NAMESPACE + +#endif // QV4ECMAOBJECTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4debugging_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4debugging_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8e28fd4ece616cfb3796afb21fe1f581e32c2cdb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4debugging_p.h @@ -0,0 +1,61 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4DEBUGGING_H +#define QV4DEBUGGING_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qv4global_p.h> +#include <QtQml/private/qv4staticvalue_p.h> +#include <QtCore/qobject.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { +namespace Debugging { + +#if !QT_CONFIG(qml_debug) + +class Debugger +{ +public: + bool pauseAtNextOpportunity() const { return false; } + void maybeBreakAtInstruction() {} + void enteringFunction() {} + void leavingFunction(const ReturnedValue &) {} + void aboutToThrow() {} +}; + +#else + +class Q_QML_EXPORT Debugger : public QObject +{ + Q_OBJECT + +public: + ~Debugger() override; + virtual bool pauseAtNextOpportunity() const = 0; + virtual void maybeBreakAtInstruction() = 0; + virtual void enteringFunction() = 0; + virtual void leavingFunction(const ReturnedValue &retVal) = 0; + virtual void aboutToThrow() = 0; +}; + +#endif // QT_NO_QML_DEBUGGING + +} // namespace Debugging +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4DEBUGGING_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4domerrors_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4domerrors_p.h new file mode 100644 index 0000000000000000000000000000000000000000..40e9560f8d5535d25bf72b15592293ccbc87e002 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4domerrors_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV8DOMERRORS_P_H +#define QV8DOMERRORS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE +// From DOM-Level-3-Core spec +// http://www.w3.org/TR/DOM-Level-3-Core/core.html +#define DOMEXCEPTION_INDEX_SIZE_ERR 1 +#define DOMEXCEPTION_DOMSTRING_SIZE_ERR 2 +#define DOMEXCEPTION_HIERARCHY_REQUEST_ERR 3 +#define DOMEXCEPTION_WRONG_DOCUMENT_ERR 4 +#define DOMEXCEPTION_INVALID_CHARACTER_ERR 5 +#define DOMEXCEPTION_NO_DATA_ALLOWED_ERR 6 +#define DOMEXCEPTION_NO_MODIFICATION_ALLOWED_ERR 7 +#define DOMEXCEPTION_NOT_FOUND_ERR 8 +#define DOMEXCEPTION_NOT_SUPPORTED_ERR 9 +#define DOMEXCEPTION_INUSE_ATTRIBUTE_ERR 10 +#define DOMEXCEPTION_INVALID_STATE_ERR 11 +#define DOMEXCEPTION_SYNTAX_ERR 12 +#define DOMEXCEPTION_INVALID_MODIFICATION_ERR 13 +#define DOMEXCEPTION_NAMESPACE_ERR 14 +#define DOMEXCEPTION_INVALID_ACCESS_ERR 15 +#define DOMEXCEPTION_VALIDATION_ERR 16 +#define DOMEXCEPTION_TYPE_MISMATCH_ERR 17 + +#define THROW_DOM(error, string) { \ + QV4::ScopedValue v(scope, scope.engine->newString(QStringLiteral(string))); \ + QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \ + ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, QV4::Value::fromInt32(error))); \ + return scope.engine->throwError(ex); \ +} + +namespace QV4 { +struct ExecutionEngine; +} + + +void qt_add_domexceptions(QV4::ExecutionEngine *e); + +QT_END_NAMESPACE + +#endif // QV8DOMERRORS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4engine_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4engine_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b8aad2e7bff20faf7cf8fbb1d881d33d80d7e25a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4engine_p.h @@ -0,0 +1,950 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4ENGINE_H +#define QV4ENGINE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qintrusivelist_p.h> +#include <private/qqmldelayedcallqueue_p.h> +#include <private/qqmlrefcount_p.h> +#include <private/qv4compileddata_p.h> +#include <private/qv4context_p.h> +#include <private/qv4enginebase_p.h> +#include <private/qv4executablecompilationunit_p.h> +#include <private/qv4function_p.h> +#include <private/qv4global_p.h> +#include <private/qv4stacklimits_p.h> + +#include <QtCore/qelapsedtimer.h> +#include <QtCore/qmutex.h> +#include <QtCore/qprocessordetection.h> +#include <QtCore/qset.h> + +namespace WTF { +class BumpPointerAllocator; +class PageAllocation; +} + +#define V4_DEFINE_EXTENSION(dataclass, datafunction) \ + static inline dataclass *datafunction(QV4::ExecutionEngine *engine) \ + { \ + static int extensionId = -1; \ + if (extensionId == -1) { \ + QV4::ExecutionEngine::registrationMutex()->lock(); \ + if (extensionId == -1) \ + extensionId = QV4::ExecutionEngine::registerExtension(); \ + QV4::ExecutionEngine::registrationMutex()->unlock(); \ + } \ + dataclass *rv = (dataclass *)engine->extensionData(extensionId); \ + if (!rv) { \ + rv = new dataclass(engine); \ + engine->setExtensionData(extensionId, rv); \ + } \ + return rv; \ + } \ + + +QT_BEGIN_NAMESPACE + +#if QT_CONFIG(qml_network) +class QNetworkAccessManager; + +namespace QV4 { +struct QObjectMethod; +namespace detail { +QNetworkAccessManager *getNetworkAccessManager(ExecutionEngine *engine); +} +} +#else +namespace QV4 { struct QObjectMethod; } +#endif // qml_network + +// Used to allow a QObject method take and return raw V4 handles without having to expose +// 48 in the public API. +// Use like this: +// class MyClass : public QObject { +// Q_OBJECT +// ... +// Q_INVOKABLE void myMethod(QQmlV4FunctionPtr); +// }; +// The QQmlV8Function - and consequently the arguments and return value - only remains +// valid during the call. If the return value isn't set within myMethod(), the will return +// undefined. + +class QQmlV4Function +{ +public: + int length() const { return callData->argc(); } + QV4::ReturnedValue operator[](int idx) const { return (idx < callData->argc() ? callData->args[idx].asReturnedValue() : QV4::Encode::undefined()); } + void setReturnValue(QV4::ReturnedValue rv) { *retVal = rv; } + QV4::ExecutionEngine *v4engine() const { return e; } +private: + friend struct QV4::QObjectMethod; + QQmlV4Function(); + QQmlV4Function(const QQmlV4Function &); + QQmlV4Function &operator=(const QQmlV4Function &); + + QQmlV4Function(QV4::CallData *callData, QV4::Value *retVal, QV4::ExecutionEngine *e) + : callData(callData), retVal(retVal), e(e) + { + callData->thisObject = QV4::Encode::undefined(); + } + + QV4::CallData *callData; + QV4::Value *retVal; + QV4::ExecutionEngine *e; +}; + +class QQmlError; +class QJSEngine; +class QQmlEngine; +class QQmlContextData; +class QQmlTypeLoader; + +namespace QV4 { +namespace Debugging { +class Debugger; +} // namespace Debugging +namespace Profiling { +class Profiler; +} // namespace Profiling +namespace CompiledData { +struct CompilationUnit; +} + +namespace Heap { +struct Module; +}; + +struct Function; + +namespace Promise { +class ReactionHandler; +}; + +struct Q_QML_EXPORT ExecutionEngine : public EngineBase +{ +private: + friend struct ExecutionContextSaver; + friend struct ExecutionContext; + friend struct Heap::ExecutionContext; +public: + enum class DiskCache { + Disabled = 0, + AotByteCode = 1 << 0, + AotNative = 1 << 1, + QmlcRead = 1 << 2, + QmlcWrite = 1 << 3, + Aot = AotByteCode | AotNative, + Qmlc = QmlcRead | QmlcWrite, + Enabled = Aot | Qmlc, + + }; + + Q_DECLARE_FLAGS(DiskCacheOptions, DiskCache); + + ExecutableAllocator *executableAllocator; + ExecutableAllocator *regExpAllocator; + + WTF::BumpPointerAllocator *bumperPointerAllocator; // Used by Yarr Regex engine. + + WTF::PageAllocation *jsStack; + + WTF::PageAllocation *gcStack; + + QML_NEARLY_ALWAYS_INLINE Value *jsAlloca(int nValues) { + Value *ptr = jsStackTop; + jsStackTop = ptr + nValues; + return ptr; + } + + Function *globalCode; + + QJSEngine *jsEngine() const { return publicEngine; } + QQmlEngine *qmlEngine() const { return m_qmlEngine; } + QJSEngine *publicEngine; + + template<typename TypeLoader = QQmlTypeLoader> + TypeLoader *typeLoader() + { + if (m_qmlEngine) + return TypeLoader::get(m_qmlEngine); + return nullptr; + } + + enum JSObjects { + RootContext, + ScriptContext, + IntegerNull, // Has to come after the RootContext to make the context stack safe + ObjectProto, + SymbolProto, + ArrayProto, + ArrayProtoValues, + PropertyListProto, + StringProto, + NumberProto, + BooleanProto, + DateProto, + FunctionProto, + GeneratorProto, + RegExpProto, + ErrorProto, + EvalErrorProto, + RangeErrorProto, + ReferenceErrorProto, + SyntaxErrorProto, + TypeErrorProto, + URIErrorProto, + PromiseProto, + VariantProto, + SequenceProto, + SharedArrayBufferProto, + ArrayBufferProto, + DataViewProto, + WeakSetProto, + SetProto, + WeakMapProto, + MapProto, + IntrinsicTypedArrayProto, + ValueTypeProto, + TypeWrapperProto, + SignalHandlerProto, + IteratorProto, + ForInIteratorProto, + SetIteratorProto, + MapIteratorProto, + ArrayIteratorProto, + StringIteratorProto, + UrlProto, + UrlSearchParamsProto, + + Object_Ctor, + String_Ctor, + Symbol_Ctor, + Number_Ctor, + Boolean_Ctor, + Array_Ctor, + Function_Ctor, + GeneratorFunction_Ctor, + Date_Ctor, + RegExp_Ctor, + Error_Ctor, + EvalError_Ctor, + RangeError_Ctor, + ReferenceError_Ctor, + SyntaxError_Ctor, + TypeError_Ctor, + URIError_Ctor, + SharedArrayBuffer_Ctor, + Promise_Ctor, + ArrayBuffer_Ctor, + DataView_Ctor, + WeakSet_Ctor, + Set_Ctor, + WeakMap_Ctor, + Map_Ctor, + IntrinsicTypedArray_Ctor, + Url_Ctor, + UrlSearchParams_Ctor, + + GetSymbolSpecies, + + Eval_Function, + GetStack_Function, + ThrowerObject, + NJSObjects + }; + Value *jsObjects; + enum { NTypedArrayTypes = 9 }; // == TypedArray::NValues, avoid header dependency + + ExecutionContext *rootContext() const { return reinterpret_cast<ExecutionContext *>(jsObjects + RootContext); } + ExecutionContext *scriptContext() const { return reinterpret_cast<ExecutionContext *>(jsObjects + ScriptContext); } + void setScriptContext(ReturnedValue c) { jsObjects[ScriptContext] = c; } + FunctionObject *objectCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Object_Ctor); } + FunctionObject *stringCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + String_Ctor); } + FunctionObject *symbolCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Symbol_Ctor); } + FunctionObject *numberCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Number_Ctor); } + FunctionObject *booleanCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Boolean_Ctor); } + FunctionObject *arrayCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Array_Ctor); } + FunctionObject *functionCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Function_Ctor); } + FunctionObject *generatorFunctionCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + GeneratorFunction_Ctor); } + FunctionObject *dateCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Date_Ctor); } + FunctionObject *regExpCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + RegExp_Ctor); } + FunctionObject *errorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Error_Ctor); } + FunctionObject *evalErrorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + EvalError_Ctor); } + FunctionObject *rangeErrorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + RangeError_Ctor); } + FunctionObject *referenceErrorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + ReferenceError_Ctor); } + FunctionObject *syntaxErrorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + SyntaxError_Ctor); } + FunctionObject *typeErrorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + TypeError_Ctor); } + FunctionObject *uRIErrorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + URIError_Ctor); } + FunctionObject *sharedArrayBufferCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + SharedArrayBuffer_Ctor); } + FunctionObject *promiseCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Promise_Ctor); } + FunctionObject *arrayBufferCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + ArrayBuffer_Ctor); } + FunctionObject *dataViewCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + DataView_Ctor); } + FunctionObject *weakSetCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + WeakSet_Ctor); } + FunctionObject *setCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Set_Ctor); } + FunctionObject *weakMapCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + WeakMap_Ctor); } + FunctionObject *mapCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Map_Ctor); } + FunctionObject *intrinsicTypedArrayCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + IntrinsicTypedArray_Ctor); } + FunctionObject *urlCtor() const + { + return reinterpret_cast<FunctionObject *>(jsObjects + Url_Ctor); + } + FunctionObject *urlSearchParamsCtor() const + { + return reinterpret_cast<FunctionObject *>(jsObjects + UrlSearchParams_Ctor); + } + FunctionObject *typedArrayCtors; + + FunctionObject *getSymbolSpecies() const { return reinterpret_cast<FunctionObject *>(jsObjects + GetSymbolSpecies); } + + Object *objectPrototype() const { return reinterpret_cast<Object *>(jsObjects + ObjectProto); } + Object *symbolPrototype() const { return reinterpret_cast<Object *>(jsObjects + SymbolProto); } + Object *arrayPrototype() const { return reinterpret_cast<Object *>(jsObjects + ArrayProto); } + Object *arrayProtoValues() const { return reinterpret_cast<Object *>(jsObjects + ArrayProtoValues); } + Object *propertyListPrototype() const { return reinterpret_cast<Object *>(jsObjects + PropertyListProto); } + Object *stringPrototype() const { return reinterpret_cast<Object *>(jsObjects + StringProto); } + Object *numberPrototype() const { return reinterpret_cast<Object *>(jsObjects + NumberProto); } + Object *booleanPrototype() const { return reinterpret_cast<Object *>(jsObjects + BooleanProto); } + Object *datePrototype() const { return reinterpret_cast<Object *>(jsObjects + DateProto); } + Object *functionPrototype() const { return reinterpret_cast<Object *>(jsObjects + FunctionProto); } + Object *generatorPrototype() const { return reinterpret_cast<Object *>(jsObjects + GeneratorProto); } + Object *regExpPrototype() const { return reinterpret_cast<Object *>(jsObjects + RegExpProto); } + Object *errorPrototype() const { return reinterpret_cast<Object *>(jsObjects + ErrorProto); } + Object *evalErrorPrototype() const { return reinterpret_cast<Object *>(jsObjects + EvalErrorProto); } + Object *rangeErrorPrototype() const { return reinterpret_cast<Object *>(jsObjects + RangeErrorProto); } + Object *referenceErrorPrototype() const { return reinterpret_cast<Object *>(jsObjects + ReferenceErrorProto); } + Object *syntaxErrorPrototype() const { return reinterpret_cast<Object *>(jsObjects + SyntaxErrorProto); } + Object *typeErrorPrototype() const { return reinterpret_cast<Object *>(jsObjects + TypeErrorProto); } + Object *uRIErrorPrototype() const { return reinterpret_cast<Object *>(jsObjects + URIErrorProto); } + Object *promisePrototype() const { return reinterpret_cast<Object *>(jsObjects + PromiseProto); } + Object *variantPrototype() const { return reinterpret_cast<Object *>(jsObjects + VariantProto); } + Object *sequencePrototype() const { return reinterpret_cast<Object *>(jsObjects + SequenceProto); } + + Object *sharedArrayBufferPrototype() const { return reinterpret_cast<Object *>(jsObjects + SharedArrayBufferProto); } + Object *arrayBufferPrototype() const { return reinterpret_cast<Object *>(jsObjects + ArrayBufferProto); } + Object *dataViewPrototype() const { return reinterpret_cast<Object *>(jsObjects + DataViewProto); } + Object *weakSetPrototype() const { return reinterpret_cast<Object *>(jsObjects + WeakSetProto); } + Object *setPrototype() const { return reinterpret_cast<Object *>(jsObjects + SetProto); } + Object *weakMapPrototype() const { return reinterpret_cast<Object *>(jsObjects + WeakMapProto); } + Object *mapPrototype() const { return reinterpret_cast<Object *>(jsObjects + MapProto); } + Object *intrinsicTypedArrayPrototype() const { return reinterpret_cast<Object *>(jsObjects + IntrinsicTypedArrayProto); } + Object *typedArrayPrototype; + + Object *valueTypeWrapperPrototype() const { return reinterpret_cast<Object *>(jsObjects + ValueTypeProto); } + Object *signalHandlerPrototype() const { return reinterpret_cast<Object *>(jsObjects + SignalHandlerProto); } + Object *typeWrapperPrototype() const { return reinterpret_cast<Object *>(jsObjects + TypeWrapperProto); } + Object *iteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + IteratorProto); } + Object *forInIteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + ForInIteratorProto); } + Object *setIteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + SetIteratorProto); } + Object *mapIteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + MapIteratorProto); } + Object *arrayIteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + ArrayIteratorProto); } + Object *stringIteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + StringIteratorProto); } + Object *urlPrototype() const { return reinterpret_cast<Object *>(jsObjects + UrlProto); } + Object *urlSearchParamsPrototype() const { return reinterpret_cast<Object *>(jsObjects + UrlSearchParamsProto); } + + EvalFunction *evalFunction() const { return reinterpret_cast<EvalFunction *>(jsObjects + Eval_Function); } + FunctionObject *getStackFunction() const { return reinterpret_cast<FunctionObject *>(jsObjects + GetStack_Function); } + FunctionObject *thrower() const { return reinterpret_cast<FunctionObject *>(jsObjects + ThrowerObject); } + +#if QT_CONFIG(qml_network) + QNetworkAccessManager* (*networkAccessManager)(ExecutionEngine*) = detail::getNetworkAccessManager; +#endif + + enum JSStrings { + String_Empty, + String_undefined, + String_null, + String_true, + String_false, + String_boolean, + String_number, + String_string, + String_default, + String_symbol, + String_object, + String_function, + String_length, + String_prototype, + String_constructor, + String_arguments, + String_caller, + String_callee, + String_this, + String___proto__, + String_enumerable, + String_configurable, + String_writable, + String_value, + String_get, + String_set, + String_eval, + String_uintMax, + String_name, + String_index, + String_input, + String_toString, + String_toLocaleString, + String_destroy, + String_valueOf, + String_byteLength, + String_byteOffset, + String_buffer, + String_lastIndex, + String_next, + String_done, + String_return, + String_throw, + String_global, + String_ignoreCase, + String_multiline, + String_unicode, + String_sticky, + String_source, + String_flags, + + NJSStrings + }; + Value *jsStrings; + + enum JSSymbols { + Symbol_hasInstance, + Symbol_isConcatSpreadable, + Symbol_iterator, + Symbol_match, + Symbol_replace, + Symbol_search, + Symbol_species, + Symbol_split, + Symbol_toPrimitive, + Symbol_toStringTag, + Symbol_unscopables, + Symbol_revokableProxy, + NJSSymbols + }; + Value *jsSymbols; + + String *id_empty() const { return reinterpret_cast<String *>(jsStrings + String_Empty); } + String *id_undefined() const { return reinterpret_cast<String *>(jsStrings + String_undefined); } + String *id_null() const { return reinterpret_cast<String *>(jsStrings + String_null); } + String *id_true() const { return reinterpret_cast<String *>(jsStrings + String_true); } + String *id_false() const { return reinterpret_cast<String *>(jsStrings + String_false); } + String *id_boolean() const { return reinterpret_cast<String *>(jsStrings + String_boolean); } + String *id_number() const { return reinterpret_cast<String *>(jsStrings + String_number); } + String *id_string() const { return reinterpret_cast<String *>(jsStrings + String_string); } + String *id_default() const { return reinterpret_cast<String *>(jsStrings + String_default); } + String *id_symbol() const { return reinterpret_cast<String *>(jsStrings + String_symbol); } + String *id_object() const { return reinterpret_cast<String *>(jsStrings + String_object); } + String *id_function() const { return reinterpret_cast<String *>(jsStrings + String_function); } + String *id_length() const { return reinterpret_cast<String *>(jsStrings + String_length); } + String *id_prototype() const { return reinterpret_cast<String *>(jsStrings + String_prototype); } + String *id_constructor() const { return reinterpret_cast<String *>(jsStrings + String_constructor); } + String *id_arguments() const { return reinterpret_cast<String *>(jsStrings + String_arguments); } + String *id_caller() const { return reinterpret_cast<String *>(jsStrings + String_caller); } + String *id_callee() const { return reinterpret_cast<String *>(jsStrings + String_callee); } + String *id_this() const { return reinterpret_cast<String *>(jsStrings + String_this); } + String *id___proto__() const { return reinterpret_cast<String *>(jsStrings + String___proto__); } + String *id_enumerable() const { return reinterpret_cast<String *>(jsStrings + String_enumerable); } + String *id_configurable() const { return reinterpret_cast<String *>(jsStrings + String_configurable); } + String *id_writable() const { return reinterpret_cast<String *>(jsStrings + String_writable); } + String *id_value() const { return reinterpret_cast<String *>(jsStrings + String_value); } + String *id_get() const { return reinterpret_cast<String *>(jsStrings + String_get); } + String *id_set() const { return reinterpret_cast<String *>(jsStrings + String_set); } + String *id_eval() const { return reinterpret_cast<String *>(jsStrings + String_eval); } + String *id_uintMax() const { return reinterpret_cast<String *>(jsStrings + String_uintMax); } + String *id_name() const { return reinterpret_cast<String *>(jsStrings + String_name); } + String *id_index() const { return reinterpret_cast<String *>(jsStrings + String_index); } + String *id_input() const { return reinterpret_cast<String *>(jsStrings + String_input); } + String *id_toString() const { return reinterpret_cast<String *>(jsStrings + String_toString); } + String *id_toLocaleString() const { return reinterpret_cast<String *>(jsStrings + String_toLocaleString); } + String *id_destroy() const { return reinterpret_cast<String *>(jsStrings + String_destroy); } + String *id_valueOf() const { return reinterpret_cast<String *>(jsStrings + String_valueOf); } + String *id_byteLength() const { return reinterpret_cast<String *>(jsStrings + String_byteLength); } + String *id_byteOffset() const { return reinterpret_cast<String *>(jsStrings + String_byteOffset); } + String *id_buffer() const { return reinterpret_cast<String *>(jsStrings + String_buffer); } + String *id_lastIndex() const { return reinterpret_cast<String *>(jsStrings + String_lastIndex); } + String *id_next() const { return reinterpret_cast<String *>(jsStrings + String_next); } + String *id_done() const { return reinterpret_cast<String *>(jsStrings + String_done); } + String *id_return() const { return reinterpret_cast<String *>(jsStrings + String_return); } + String *id_throw() const { return reinterpret_cast<String *>(jsStrings + String_throw); } + String *id_global() const { return reinterpret_cast<String *>(jsStrings + String_global); } + String *id_ignoreCase() const { return reinterpret_cast<String *>(jsStrings + String_ignoreCase); } + String *id_multiline() const { return reinterpret_cast<String *>(jsStrings + String_multiline); } + String *id_unicode() const { return reinterpret_cast<String *>(jsStrings + String_unicode); } + String *id_sticky() const { return reinterpret_cast<String *>(jsStrings + String_sticky); } + String *id_source() const { return reinterpret_cast<String *>(jsStrings + String_source); } + String *id_flags() const { return reinterpret_cast<String *>(jsStrings + String_flags); } + + Symbol *symbol_hasInstance() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_hasInstance); } + Symbol *symbol_isConcatSpreadable() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_isConcatSpreadable); } + Symbol *symbol_iterator() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_iterator); } + Symbol *symbol_match() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_match); } + Symbol *symbol_replace() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_replace); } + Symbol *symbol_search() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_search); } + Symbol *symbol_species() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_species); } + Symbol *symbol_split() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_split); } + Symbol *symbol_toPrimitive() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_toPrimitive); } + Symbol *symbol_toStringTag() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_toStringTag); } + Symbol *symbol_unscopables() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_unscopables); } + Symbol *symbol_revokableProxy() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_revokableProxy); } + + quint32 m_engineId; + + RegExpCache *regExpCache; + + // Scarce resources are "exceptionally high cost" QVariant types where allowing the + // normal JavaScript GC to clean them up is likely to lead to out-of-memory or other + // out-of-resource situations. When such a resource is passed into JavaScript we + // add it to the scarceResources list and it is destroyed when we return from the + // JavaScript execution that created it. The user can prevent this behavior by + // calling preserve() on the object which removes it from this scarceResource list. + class ScarceResourceData { + public: + ScarceResourceData() = default; + ScarceResourceData(const QMetaType type, const void *data) : data(type, data) {} + QVariant data; + QIntrusiveListNode node; + }; + QIntrusiveList<ScarceResourceData, &ScarceResourceData::node> scarceResources; + + // Normally the JS wrappers for QObjects are stored in the QQmlData/QObjectPrivate, + // but any time a QObject is wrapped a second time in another engine, we have to do + // bookkeeping. + MultiplyWrappedQObjectMap *m_multiplyWrappedQObjects; +#if QT_CONFIG(qml_jit) + const bool m_canAllocateExecutableMemory; +#endif + + quintptr protoIdCount = 1; + + ExecutionEngine(QJSEngine *jsEngine = nullptr); + ~ExecutionEngine(); + +#if !QT_CONFIG(qml_debug) + QV4::Debugging::Debugger *debugger() const { return nullptr; } + QV4::Profiling::Profiler *profiler() const { return nullptr; } + + void setDebugger(Debugging::Debugger *) {} + void setProfiler(Profiling::Profiler *) {} + static void setPreviewing(bool) {} +#else + QV4::Debugging::Debugger *debugger() const { return m_debugger.data(); } + QV4::Profiling::Profiler *profiler() const { return m_profiler.data(); } + + void setDebugger(Debugging::Debugger *debugger); + void setProfiler(Profiling::Profiler *profiler); + static void setPreviewing(bool enabled); +#endif // QT_CONFIG(qml_debug) + + // We don't want to #include <private/qv4stackframe_p.h> here, but we still want + // currentContext() to be inline. Therefore we shift the requirement to provide the + // complete type of CppStackFrame to the caller by making this a template. + template<typename StackFrame = CppStackFrame> + ExecutionContext *currentContext() const + { + return static_cast<const StackFrame *>(currentStackFrame)->context(); + } + + // ensure we always get odd prototype IDs. This helps make marking in QV4::Lookup fast + quintptr newProtoId() { return (protoIdCount += 2); } + + Heap::InternalClass *newInternalClass(const VTable *vtable, Object *prototype); + + Heap::Object *newObject(); + Heap::Object *newObject(Heap::InternalClass *internalClass); + + Heap::String *newString(char16_t c) { return newString(QChar(c)); } + Heap::String *newString(const QString &s = QString()); + Heap::String *newIdentifier(const QString &text); + + Heap::Object *newStringObject(const String *string); + Heap::Object *newSymbolObject(const Symbol *symbol); + Heap::Object *newNumberObject(double value); + Heap::Object *newBooleanObject(bool b); + + Heap::ArrayObject *newArrayObject(int count = 0); + Heap::ArrayObject *newArrayObject(const Value *values, int length); + Heap::ArrayObject *newArrayObject(const QStringList &list); + Heap::ArrayObject *newArrayObject(Heap::InternalClass *ic); + + Heap::ArrayBuffer *newArrayBuffer(const QByteArray &array); + Heap::ArrayBuffer *newArrayBuffer(size_t length); + + Heap::DateObject *newDateObject(double dateTime); + Heap::DateObject *newDateObject(const QDateTime &dateTime); + Heap::DateObject *newDateObject(QDate date, Heap::Object *parent, int index, uint flags); + Heap::DateObject *newDateObject(QTime time, Heap::Object *parent, int index, uint flags); + Heap::DateObject *newDateObject(QDateTime dateTime, Heap::Object *parent, int index, uint flags); + + Heap::RegExpObject *newRegExpObject(const QString &pattern, int flags); + Heap::RegExpObject *newRegExpObject(RegExp *re); +#if QT_CONFIG(regularexpression) + Heap::RegExpObject *newRegExpObject(const QRegularExpression &re); +#endif + + Heap::UrlObject *newUrlObject(); + Heap::UrlObject *newUrlObject(const QUrl &url); + Heap::UrlSearchParamsObject *newUrlSearchParamsObject(); + + Heap::Object *newErrorObject(const Value &value); + Heap::Object *newErrorObject(const QString &message); + Heap::Object *newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column); + Heap::Object *newSyntaxErrorObject(const QString &message); + Heap::Object *newReferenceErrorObject(const QString &message); + Heap::Object *newReferenceErrorObject(const QString &message, const QString &fileName, int line, int column); + Heap::Object *newTypeErrorObject(const QString &message); + Heap::Object *newRangeErrorObject(const QString &message); + Heap::Object *newURIErrorObject(const QString &message); + Heap::Object *newURIErrorObject(const Value &message); + Heap::Object *newEvalErrorObject(const QString &message); + + Heap::PromiseObject *newPromiseObject(); + Heap::Object *newPromiseObject(const QV4::FunctionObject *thisObject, const QV4::PromiseCapability *capability); + Promise::ReactionHandler *getPromiseReactionHandler(); + + Heap::Object *newVariantObject(const QMetaType type, const void *data); + + Heap::Object *newForInIteratorObject(Object *o); + Heap::Object *newSetIteratorObject(Object *o); + Heap::Object *newMapIteratorObject(Object *o); + Heap::Object *newArrayIteratorObject(Object *o); + + static Heap::ExecutionContext *qmlContext(Heap::ExecutionContext *ctx) + { + Heap::ExecutionContext *outer = ctx->outer; + + if (ctx->type != Heap::ExecutionContext::Type_QmlContext && !outer) + return nullptr; + + while (outer && outer->type != Heap::ExecutionContext::Type_GlobalContext) { + ctx = outer; + outer = ctx->outer; + } + + Q_ASSERT(ctx); + if (ctx->type != Heap::ExecutionContext::Type_QmlContext) + return nullptr; + + return ctx; + } + + Heap::QmlContext *qmlContext() const; + QObject *qmlScopeObject() const; + QQmlRefPointer<QQmlContextData> callingQmlContext() const; + + + StackTrace stackTrace(int frameLimit = -1) const; + QUrl resolvedUrl(const QString &file); + + void markObjects(MarkStack *markStack); + + void initRootContext(); + + Heap::InternalClass *newClass(Heap::InternalClass *other); + + StackTrace exceptionStackTrace; + + ReturnedValue throwError(const Value &value); + ReturnedValue catchException(StackTrace *trace = nullptr); + + ReturnedValue throwError(const QString &message); + ReturnedValue throwSyntaxError(const QString &message); + ReturnedValue throwSyntaxError(const QString &message, const QString &fileName, int lineNumber, int column); + ReturnedValue throwTypeError(); + ReturnedValue throwTypeError(const QString &message); + ReturnedValue throwReferenceError(const Value &value); + ReturnedValue throwReferenceError(const QString &name); + ReturnedValue throwReferenceError(const QString &value, const QString &fileName, int lineNumber, int column); + ReturnedValue throwRangeError(const Value &value); + ReturnedValue throwRangeError(const QString &message); + ReturnedValue throwURIError(const Value &msg); + ReturnedValue throwUnimplemented(const QString &message); + + // Use only inside catch(...) -- will re-throw if no JS exception + QQmlError catchExceptionAsQmlError(); + + // variant conversions + static QVariant toVariant( + const QV4::Value &value, QMetaType typeHint, bool createJSValueForObjectsAndSymbols = true); + static QVariant toVariantLossy(const QV4::Value &value); + QV4::ReturnedValue fromVariant(const QVariant &); + QV4::ReturnedValue fromVariant( + const QVariant &variant, Heap::Object *parent, int property, uint flags); + + static QVariantMap variantMapFromJS(const QV4::Object *o); + + static bool metaTypeFromJS(const Value &value, QMetaType type, void *data); + QV4::ReturnedValue metaTypeToJS(QMetaType type, const void *data); + + int maxJSStackSize() const; + int maxGCStackSize() const; + + bool checkStackLimits(); + int safeForAllocLength(qint64 len64); + + bool canJIT(Function *f = nullptr) + { +#if QT_CONFIG(qml_jit) + if (!m_canAllocateExecutableMemory) + return false; + if (f) { + return f->kind != Function::AotCompiled + && !f->isGenerator() + && f->interpreterCallCount >= s_jitCallCountThreshold; + } + return true; +#else + Q_UNUSED(f); + return false; +#endif + } + + QV4::ReturnedValue global(); + void initQmlGlobalObject(); + void initializeGlobal(); + void createQtObject(); + + void freezeObject(const QV4::Value &value); + void lockObject(const QV4::Value &value); + + // Return the list of illegal id names (the names of the properties on the global object) + const QSet<QString> &illegalNames() const; + +#if QT_CONFIG(qml_xml_http_request) + void *xmlHttpRequestData() const { return m_xmlHttpRequestData; } +#endif + + void setQmlEngine(QQmlEngine *engine); + + QQmlDelayedCallQueue *delayedCallQueue() { return &m_delayedCallQueue; } + + // used for console.time(), console.timeEnd() + void startTimer(const QString &timerName); + qint64 stopTimer(const QString &timerName, bool *wasRunning); + + // used for console.count() + int consoleCountHelper(const QString &file, quint16 line, quint16 column); + + struct Deletable { + virtual ~Deletable() {} + }; + + static QMutex *registrationMutex(); + static int registerExtension(); + + void setExtensionData(int, Deletable *); + Deletable *extensionData(int index) const + { + if (index < m_extensionData.size()) + return m_extensionData[index]; + else + return nullptr; + } + + double localTZA = 0.0; // local timezone, initialized at startup + + QQmlRefPointer<ExecutableCompilationUnit> compileModule(const QUrl &url); + QQmlRefPointer<ExecutableCompilationUnit> compileModule( + const QUrl &url, const QString &sourceCode, const QDateTime &sourceTimeStamp); + + QQmlRefPointer<ExecutableCompilationUnit> compilationUnitForUrl(const QUrl &url) const; + + QQmlRefPointer<ExecutableCompilationUnit> executableCompilationUnit( + QQmlRefPointer<QV4::CompiledData::CompilationUnit> &&unit); + + QQmlRefPointer<ExecutableCompilationUnit> insertCompilationUnit( + QQmlRefPointer<QV4::CompiledData::CompilationUnit> &&unit); + + QMultiHash<QUrl, QQmlRefPointer<ExecutableCompilationUnit>> compilationUnits() const + { + return m_compilationUnits; + } + void trimCompilationUnits(); + + QV4::Value *registerNativeModule(const QUrl &url, const QV4::Value &module); + + struct Module { + QQmlRefPointer<ExecutableCompilationUnit> compiled; + + // We can pass a raw value pointer here, but nowhere else. See below. + Value *native = nullptr; + }; + + Module moduleForUrl(const QUrl &_url, const ExecutableCompilationUnit *referrer = nullptr) const; + Module loadModule(const QUrl &_url, const ExecutableCompilationUnit *referrer = nullptr); + + DiskCacheOptions diskCacheOptions() const; + + void callInContext(QV4::Function *function, QObject *self, QV4::ExecutionContext *ctxt, + int argc, void **args, QMetaType *types); + QV4::ReturnedValue callInContext(QV4::Function *function, QObject *self, + QV4::ExecutionContext *ctxt, int argc, const QV4::Value *argv); + + QV4::ReturnedValue fromData( + QMetaType type, const void *ptr, + Heap::Object *parent = nullptr, int property = -1, uint flags = 0); + + + static void setMaxCallDepth(int maxCallDepth) { s_maxCallDepth = maxCallDepth; } + static int maxCallDepth() { return s_maxCallDepth; } + + template<typename Value> + static QJSPrimitiveValue createPrimitive(const Value &v) + { + if (v->isUndefined()) + return QJSPrimitiveValue(QJSPrimitiveUndefined()); + if (v->isNull()) + return QJSPrimitiveValue(QJSPrimitiveNull()); + if (v->isBoolean()) + return QJSPrimitiveValue(v->toBoolean()); + if (v->isInteger()) + return QJSPrimitiveValue(v->integerValue()); + if (v->isDouble()) + return QJSPrimitiveValue(v->doubleValue()); + bool ok; + const QString result = v->toQString(&ok); + return ok ? QJSPrimitiveValue(result) : QJSPrimitiveValue(QJSPrimitiveUndefined()); + } + + ReturnedValue nativeModule(const QUrl &url) const + { + const auto it = nativeModules.find(url); + return it == nativeModules.end() + ? QV4::Value::emptyValue().asReturnedValue() + : (*it)->asReturnedValue(); + } + +private: + template<int Frames> + friend struct ExecutionEngineCallDepthRecorder; + + static void initializeStaticMembers(); + + bool inStack(const void *current) const + { +#if Q_STACK_GROWTH_DIRECTION > 0 + return current < cppStackLimit && current >= cppStackBase; +#else + return current > cppStackLimit && current <= cppStackBase; +#endif + } + + bool hasCppStackOverflow() + { + if (s_maxCallDepth >= 0) + return callDepth >= s_maxCallDepth; + + if (inStack(currentStackPointer())) + return false; + + // Double check the stack limits on failure. + // We may have moved to a different thread. + const StackProperties stack = stackProperties(); + cppStackBase = stack.base; + cppStackLimit = stack.softLimit; + return !inStack(currentStackPointer()); + } + + bool hasJsStackOverflow() const + { + return jsStackTop > jsStackLimit; + } + + bool hasStackOverflow() + { + return hasJsStackOverflow() || hasCppStackOverflow(); + } + + static int s_maxCallDepth; + static int s_jitCallCountThreshold; + static int s_maxJSStackSize; + static int s_maxGCStackSize; + +#if QT_CONFIG(qml_debug) + QScopedPointer<QV4::Debugging::Debugger> m_debugger; + QScopedPointer<QV4::Profiling::Profiler> m_profiler; +#endif + QSet<QString> m_illegalNames; + + // used by generated Promise objects to handle 'then' events + QScopedPointer<QV4::Promise::ReactionHandler> m_reactionHandler; + +#if QT_CONFIG(qml_xml_http_request) + void *m_xmlHttpRequestData; +#endif + + QQmlEngine *m_qmlEngine; + + QQmlDelayedCallQueue m_delayedCallQueue; + + QElapsedTimer m_time; + QHash<QString, qint64> m_startedTimers; + + QHash<QString, quint32> m_consoleCount; + + QVector<Deletable *> m_extensionData; + + QMultiHash<QUrl, QQmlRefPointer<ExecutableCompilationUnit>> m_compilationUnits; + + // QV4::PersistentValue would be preferred, but using QHash will create copies, + // and QV4::PersistentValue doesn't like creating copies. + // Instead, we allocate a raw pointer using the same manual memory management + // technique in QV4::PersistentValue. + QHash<QUrl, Value *> nativeModules; +}; + +#define CHECK_STACK_LIMITS(v4) \ + if (v4->checkStackLimits()) \ + return Encode::undefined(); \ + ExecutionEngineCallDepthRecorder _executionEngineCallDepthRecorder(v4); + +template<int Frames = 1> +struct ExecutionEngineCallDepthRecorder +{ + ExecutionEngine *ee; + + ExecutionEngineCallDepthRecorder(ExecutionEngine *e): ee(e) + { + if (ExecutionEngine::s_maxCallDepth >= 0) + ee->callDepth += Frames; + } + + ~ExecutionEngineCallDepthRecorder() + { + if (ExecutionEngine::s_maxCallDepth >= 0) + ee->callDepth -= Frames; + } + + bool hasOverflow() const + { + return ee->hasCppStackOverflow(); + } +}; + +inline bool ExecutionEngine::checkStackLimits() +{ + if (Q_UNLIKELY(hasStackOverflow())) { + throwRangeError(QStringLiteral("Maximum call stack size exceeded.")); + return true; + } + + return false; +} + +Q_DECLARE_OPERATORS_FOR_FLAGS(ExecutionEngine::DiskCacheOptions); + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4ENGINE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4enginebase_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4enginebase_p.h new file mode 100644 index 0000000000000000000000000000000000000000..62792820685e2e1ed66538763f2d62d9084d01ff --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4enginebase_p.h @@ -0,0 +1,124 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4ENGINEBASE_P_H +#define QV4ENGINEBASE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <private/qv4runtimeapi_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct CppStackFrame; + +// Base class for the execution engine +struct Q_QML_EXPORT EngineBase { + + CppStackFrame *currentStackFrame = nullptr; + + Value *jsStackTop = nullptr; + + // The JIT expects hasException and isInterrupted to be in the same 32bit word in memory. + quint8 hasException = false; + // isInterrupted is expected to be set from a different thread +#if defined(Q_ATOMIC_INT8_IS_SUPPORTED) + QAtomicInteger<quint8> isInterrupted = false; + quint16 unused = 0; +#elif defined(Q_ATOMIC_INT16_IS_SUPPORTED) + quint8 unused = 0; + QAtomicInteger<quint16> isInterrupted = false; +#else +# error V4 needs either 8bit or 16bit atomics. +#endif + + quint8 isExecutingInRegExpJIT = false; + quint8 isInitialized = false; + quint8 inShutdown = false; + quint8 isGCOngoing = false; // incremental gc is ongoing (but mutator might be running) + MemoryManager *memoryManager = nullptr; + + union { + const void *cppStackBase = nullptr; + struct { + qint32 callDepth; +#if QT_POINTER_SIZE == 8 + quint32 padding2; +#endif + }; + }; + const void *cppStackLimit = nullptr; + + Object *globalObject = nullptr; + Value *jsStackLimit = nullptr; + Value *jsStackBase = nullptr; + + IdentifierTable *identifierTable = nullptr; + + // Exception handling + Value *exceptionValue = nullptr; + + enum InternalClassType { + Class_Empty, + Class_String, + Class_MemberData, + Class_SimpleArrayData, + Class_SparseArrayData, + Class_ExecutionContext, + Class_CallContext, + Class_QmlContext, + Class_Object, + Class_ArrayObject, + Class_FunctionObject, + Class_ArrowFunction, + Class_GeneratorFunction, + Class_GeneratorObject, + Class_StringObject, + Class_SymbolObject, + Class_ScriptFunction, + Class_ConstructorFunction, + Class_MemberFunction, + Class_MemberGeneratorFunction, + Class_ObjectProto, + Class_RegExp, + Class_RegExpObject, + Class_RegExpExecArray, + Class_ArgumentsObject, + Class_StrictArgumentsObject, + Class_ErrorObject, + Class_ErrorObjectWithMessage, + Class_ErrorProto, + Class_QmlContextWrapper, + Class_ProxyObject, + Class_ProxyFunctionObject, + Class_Symbol, + NClasses + }; + Heap::InternalClass *classes[NClasses]; + Heap::InternalClass *internalClasses(InternalClassType icType) { return classes[icType]; } +}; + +Q_STATIC_ASSERT(std::is_standard_layout<EngineBase>::value); +Q_STATIC_ASSERT(offsetof(EngineBase, currentStackFrame) == 0); +Q_STATIC_ASSERT(offsetof(EngineBase, jsStackTop) == offsetof(EngineBase, currentStackFrame) + QT_POINTER_SIZE); +Q_STATIC_ASSERT(offsetof(EngineBase, hasException) == offsetof(EngineBase, jsStackTop) + QT_POINTER_SIZE); +Q_STATIC_ASSERT(offsetof(EngineBase, memoryManager) == offsetof(EngineBase, hasException) + 8); +Q_STATIC_ASSERT(offsetof(EngineBase, isInterrupted) + sizeof(EngineBase::isInterrupted) <= offsetof(EngineBase, hasException) + 4); +Q_STATIC_ASSERT(offsetof(EngineBase, globalObject) % QT_POINTER_SIZE == 0); + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4errorobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4errorobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1ba9c5fbc2fc4acebdda80a4f5ae8093b52aa4a9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4errorobject_p.h @@ -0,0 +1,329 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4ERROROBJECT_H +#define QV4ERROROBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct SyntaxErrorObject; + +namespace Heap { + + +#define ErrorObjectMembers(class, Member) \ + Member(class, Pointer, String *, stack) + +DECLARE_HEAP_OBJECT(ErrorObject, Object) { + DECLARE_MARKOBJECTS(ErrorObject) + enum ErrorType { + Error, + EvalError, + RangeError, + ReferenceError, + SyntaxError, + TypeError, + URIError + }; + StackTrace *stackTrace; + ErrorType errorType; + + void init(); + void init(const Value &message, ErrorType t = Error); + void init(const Value &message, const QString &fileName, int line, int column, ErrorType t = Error); + void destroy() { + delete stackTrace; + Object::destroy(); + } +}; + +struct EvalErrorObject : ErrorObject { + void init(const Value &message); +}; + +struct RangeErrorObject : ErrorObject { + void init(const Value &message); +}; + +struct ReferenceErrorObject : ErrorObject { + void init(const Value &message); + void init(const Value &msg, const QString &fileName, int lineNumber, int columnNumber); +}; + +struct SyntaxErrorObject : ErrorObject { + void init(const Value &message); + void init(const Value &msg, const QString &fileName, int lineNumber, int columnNumber); +}; + +struct TypeErrorObject : ErrorObject { + void init(const Value &message); +}; + +struct URIErrorObject : ErrorObject { + void init(const Value &message); +}; + +struct ErrorCtor : FunctionObject { + void init(ExecutionEngine *engine); + void init(ExecutionEngine *engine, const QString &name); +}; + +struct EvalErrorCtor : ErrorCtor { + void init(ExecutionEngine *engine); +}; + +struct RangeErrorCtor : ErrorCtor { + void init(ExecutionEngine *engine); +}; + +struct ReferenceErrorCtor : ErrorCtor { + void init(ExecutionEngine *engine); +}; + +struct SyntaxErrorCtor : ErrorCtor { + void init(ExecutionEngine *engine); +}; + +struct TypeErrorCtor : ErrorCtor { + void init(ExecutionEngine *engine); +}; + +struct URIErrorCtor : ErrorCtor { + void init(ExecutionEngine *engine); +}; + +} + +struct ErrorObject: Object { + enum { + IsErrorObject = true + }; + + enum { + Index_Stack = 0, // Accessor Property + Index_StackSetter = 1, // Accessor Property + Index_FileName = 2, + Index_LineNumber = 3, + Index_Message = 4 + }; + + V4_OBJECT2(ErrorObject, Object) + Q_MANAGED_TYPE(ErrorObject) + V4_INTERNALCLASS(ErrorObject) + V4_PROTOTYPE(errorPrototype) + V4_NEEDS_DESTROY + + template <typename T> + static Heap::Object *create(ExecutionEngine *e, const Value &message, const Value *newTarget); + template <typename T> + static Heap::Object *create(ExecutionEngine *e, const QString &message); + template <typename T> + static Heap::Object *create(ExecutionEngine *e, const QString &message, const QString &filename, int line, int column); + + SyntaxErrorObject *asSyntaxError(); + + static const char *className(Heap::ErrorObject::ErrorType t); + + static ReturnedValue method_get_stack(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +template<> +inline const ErrorObject *Value::as() const { + return isManaged() && m()->internalClass->vtable->isErrorObject ? reinterpret_cast<const ErrorObject *>(this) : nullptr; +} + +struct EvalErrorObject: ErrorObject { + typedef Heap::EvalErrorObject Data; + V4_PROTOTYPE(evalErrorPrototype) + const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); } + Data *d() { return static_cast<Data *>(ErrorObject::d()); } +}; + +struct RangeErrorObject: ErrorObject { + typedef Heap::RangeErrorObject Data; + V4_PROTOTYPE(rangeErrorPrototype) + const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); } + Data *d() { return static_cast<Data *>(ErrorObject::d()); } +}; + +struct ReferenceErrorObject: ErrorObject { + typedef Heap::ReferenceErrorObject Data; + V4_PROTOTYPE(referenceErrorPrototype) + const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); } + Data *d() { return static_cast<Data *>(ErrorObject::d()); } +}; + +struct SyntaxErrorObject: ErrorObject { + typedef Heap::SyntaxErrorObject Data; + V4_PROTOTYPE(syntaxErrorPrototype) + const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); } + Data *d() { return static_cast<Data *>(ErrorObject::d()); } +}; + +struct TypeErrorObject: ErrorObject { + typedef Heap::TypeErrorObject Data; + V4_PROTOTYPE(typeErrorPrototype) + const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); } + Data *d() { return static_cast<Data *>(ErrorObject::d()); } +}; + +struct URIErrorObject: ErrorObject { + typedef Heap::URIErrorObject Data; + V4_PROTOTYPE(uRIErrorPrototype) + const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); } + Data *d() { return static_cast<Data *>(ErrorObject::d()); } +}; + +struct ErrorCtor: FunctionObject +{ + V4_OBJECT2(ErrorCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct EvalErrorCtor: ErrorCtor +{ + V4_OBJECT2(EvalErrorCtor, FunctionObject) + V4_PROTOTYPE(errorCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + +struct RangeErrorCtor: ErrorCtor +{ + V4_OBJECT2(RangeErrorCtor, FunctionObject) + V4_PROTOTYPE(errorCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + +struct ReferenceErrorCtor: ErrorCtor +{ + V4_OBJECT2(ReferenceErrorCtor, FunctionObject) + V4_PROTOTYPE(errorCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + +struct SyntaxErrorCtor: ErrorCtor +{ + V4_OBJECT2(SyntaxErrorCtor, FunctionObject) + V4_PROTOTYPE(errorCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + +struct TypeErrorCtor: ErrorCtor +{ + V4_OBJECT2(TypeErrorCtor, FunctionObject) + V4_PROTOTYPE(errorCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + +struct URIErrorCtor: ErrorCtor +{ + V4_OBJECT2(URIErrorCtor, FunctionObject) + V4_PROTOTYPE(errorCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + + +struct ErrorPrototype : Object +{ + enum { + Index_Constructor = 0, + Index_Message = 1, + Index_Name = 2 + }; + void init(ExecutionEngine *engine, Object *ctor) { init(engine, ctor, this, Heap::ErrorObject::Error); } + + static void init(ExecutionEngine *engine, Object *ctor, Object *obj, Heap::ErrorObject::ErrorType t); + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +struct EvalErrorPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::EvalError); } +}; + +struct RangeErrorPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::RangeError); } +}; + +struct ReferenceErrorPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::ReferenceError); } +}; + +struct SyntaxErrorPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::SyntaxError); } +}; + +struct TypeErrorPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::TypeError); } +}; + +struct URIErrorPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::URIError); } +}; + + +inline SyntaxErrorObject *ErrorObject::asSyntaxError() +{ + return d()->errorType == QV4::Heap::ErrorObject::SyntaxError ? static_cast<SyntaxErrorObject *>(this) : nullptr; +} + + +template <typename T> +Heap::Object *ErrorObject::create(ExecutionEngine *e, const Value &message, const Value *newTarget) { + EngineBase::InternalClassType klass = message.isUndefined() ? EngineBase::Class_ErrorObject : EngineBase::Class_ErrorObjectWithMessage; + Scope scope(e); + ScopedObject proto(scope, static_cast<const Object *>(newTarget)->get(scope.engine->id_prototype())); + Scoped<InternalClass> ic(scope, e->internalClasses(klass)->changePrototype(proto->d())); + return e->memoryManager->allocObject<T>(ic->d(), message); +} +template <typename T> +Heap::Object *ErrorObject::create(ExecutionEngine *e, const QString &message) { + Scope scope(e); + ScopedValue v(scope, message.isEmpty() ? Encode::undefined() : e->newString(message)->asReturnedValue()); + EngineBase::InternalClassType klass = v->isUndefined() ? EngineBase::Class_ErrorObject : EngineBase::Class_ErrorObjectWithMessage; + Scoped<InternalClass> ic(scope, e->internalClasses(klass)->changePrototype(T::defaultPrototype(e)->d())); + return e->memoryManager->allocObject<T>(ic->d(), v); +} +template <typename T> +Heap::Object *ErrorObject::create(ExecutionEngine *e, const QString &message, const QString &filename, int line, int column) { + Scope scope(e); + ScopedValue v(scope, message.isEmpty() ? Encode::undefined() : e->newString(message)->asReturnedValue()); + EngineBase::InternalClassType klass = v->isUndefined() ? EngineBase::Class_ErrorObject : EngineBase::Class_ErrorObjectWithMessage; + Scoped<InternalClass> ic(scope, e->internalClasses(klass)->changePrototype(T::defaultPrototype(e)->d())); + return e->memoryManager->allocObject<T>(ic->d(), v, filename, line, column); +} + + +} + +QT_END_NAMESPACE + +#endif // QV4ECMAOBJECTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4estable_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4estable_p.h new file mode 100644 index 0000000000000000000000000000000000000000..eb918933b2d30c144a5421c3d11382c610ccfde4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4estable_p.h @@ -0,0 +1,86 @@ +// Copyright (C) 2018 Crimson AS <info@crimson.no> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QV4ESTABLE_P_H +#define QV4ESTABLE_P_H + +#include <vector> +#include <limits> + +#include "qv4value_p.h" + +class tst_qv4estable; + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +class Q_AUTOTEST_EXPORT ESTable +{ +public: + // Can be used to observe changes in the position of the element at index pivot by registering an instance + // with `observeShifts`. + // This is used by implementations of `forEach`, for `ESTable` + // backed collections, to respect the correct order of iteration + // in the face of a `callbackFn` that mutates the collection + // itself. + struct ShiftObserver { + static constexpr uint OUT_OF_TABLE = std::numeric_limits<uint>::max(); + + uint pivot = 0; + + void next() { + pivot = pivot == OUT_OF_TABLE ? 0 : pivot + 1; + } + }; + +public: + ESTable(); + ~ESTable(); + + void markObjects(MarkStack *s, bool isWeakMap); + void clear(); + void set(const Value &k, const Value &v); + bool has(const Value &k) const; + ReturnedValue get(const Value &k, bool *hasValue = nullptr) const; + bool remove(const Value &k); + uint size() const; + void iterate(uint idx, Value *k, Value *v); + + void removeUnmarkedKeys(); + + inline void observeShifts(ShiftObserver& observer) { + if (std::find(m_observers.cbegin(), m_observers.cend(), &observer) == m_observers.cend()) + m_observers.push_back(&observer); + } + inline void stopObservingShifts(ShiftObserver& observer) { + m_observers.erase(std::remove(m_observers.begin(), m_observers.end(), &observer)); + } + +private: + friend class ::tst_qv4estable; + + Value *m_keys = nullptr; + Value *m_values = nullptr; + uint m_size = 0; + uint m_capacity = 0; + + std::vector<ShiftObserver*> m_observers; +}; + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4executableallocator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4executableallocator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8b7a93f733b07b5a35e2e7d970e75c7e14e4ee86 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4executableallocator_p.h @@ -0,0 +1,110 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4EXECUTABLEALLOCATOR_H +#define QV4EXECUTABLEALLOCATOR_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QMultiMap> +#include <QHash> +#include <QVector> +#include <QByteArray> +#include <QMutex> + +#include <QtQml/private/qtqmlglobal_p.h> + +namespace WTF { +class PageAllocation; +} + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +class Q_QML_AUTOTEST_EXPORT ExecutableAllocator +{ +public: + struct ChunkOfPages; + struct Allocation; + + ExecutableAllocator(); + ~ExecutableAllocator(); + + Allocation *allocate(size_t size); + void free(Allocation *allocation); + + struct Allocation + { + Allocation() + : size(0) + , free(true) + {} + + void *memoryStart() const; + size_t memorySize() const { return size; } + + void *exceptionHandlerStart() const; + size_t exceptionHandlerSize() const; + + void *codeStart() const; + + void invalidate() { addr = 0; } + bool isValid() const { return addr != 0; } + void deallocate(ExecutableAllocator *allocator); + + private: + ~Allocation() {} + + friend class ExecutableAllocator; + + Allocation *split(size_t dividingSize); + bool mergeNext(ExecutableAllocator *allocator); + bool mergePrevious(ExecutableAllocator *allocator); + + quintptr addr = 0; + uint size : 31; // More than 2GB of function code? nah :) + uint free : 1; + Allocation *next = nullptr; + Allocation *prev = nullptr; + }; + + // for debugging / unit-testing + int freeAllocationCount() const { return freeAllocations.size(); } + int chunkCount() const { return chunks.size(); } + + struct ChunkOfPages + { + ChunkOfPages() + + {} + ~ChunkOfPages(); + + WTF::PageAllocation *pages = nullptr; + Allocation *firstAllocation = nullptr; + + bool contains(Allocation *alloc) const; + }; + + ChunkOfPages *chunkForAllocation(Allocation *allocation) const; + +private: + QMultiMap<size_t, Allocation*> freeAllocations; + QMap<quintptr, ChunkOfPages*> chunks; + mutable QMutex mutex; +}; + +} + +QT_END_NAMESPACE + +#endif // QV4EXECUTABLEALLOCATOR_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4executablecompilationunit_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4executablecompilationunit_p.h new file mode 100644 index 0000000000000000000000000000000000000000..58f42083142b36b8dc4ddcc3039a355f4313da8e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4executablecompilationunit_p.h @@ -0,0 +1,286 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4EXECUTABLECOMPILATIONUNIT_P_H +#define QV4EXECUTABLECOMPILATIONUNIT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qintrusivelist_p.h> +#include <private/qqmlmetatype_p.h> +#include <private/qqmlnullablevalue_p.h> +#include <private/qqmlpropertycachevector_p.h> +#include <private/qqmlrefcount_p.h> +#include <private/qqmltype_p.h> +#include <private/qqmltypenamecache_p.h> +#include <private/qv4compileddata_p.h> +#include <private/qv4identifierhash_p.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +class QQmlScriptData; +class QQmlEnginePrivate; + +namespace QV4 { + +class CompilationUnitMapper; + +struct CompilationUnitRuntimeData +{ + Heap::String **runtimeStrings = nullptr; // Array + + // pointers either to data->constants() or little-endian memory copy. + // We keep this member twice so that the JIT can access it via standard layout. + const StaticValue *constants = nullptr; + + QV4::StaticValue *runtimeRegularExpressions = nullptr; + Heap::InternalClass **runtimeClasses = nullptr; + const StaticValue **imports = nullptr; + + QV4::Lookup *runtimeLookups = nullptr; + QVector<QV4::Function *> runtimeFunctions; + QVector<QV4::Heap::InternalClass *> runtimeBlocks; + mutable QVector<QV4::Heap::Object *> templateObjects; +}; + +static_assert(std::is_standard_layout_v<CompilationUnitRuntimeData>); +static_assert(offsetof(CompilationUnitRuntimeData, runtimeStrings) == 0); +static_assert(offsetof(CompilationUnitRuntimeData, constants) == sizeof(QV4::Heap::String **)); +static_assert(offsetof(CompilationUnitRuntimeData, runtimeRegularExpressions) == offsetof(CompilationUnitRuntimeData, constants) + sizeof(const StaticValue *)); +static_assert(offsetof(CompilationUnitRuntimeData, runtimeClasses) == offsetof(CompilationUnitRuntimeData, runtimeRegularExpressions) + sizeof(const StaticValue *)); +static_assert(offsetof(CompilationUnitRuntimeData, imports) == offsetof(CompilationUnitRuntimeData, runtimeClasses) + sizeof(const StaticValue *)); + +class Q_QML_EXPORT ExecutableCompilationUnit final + : public CompilationUnitRuntimeData, + public QQmlRefCounted<ExecutableCompilationUnit> +{ + Q_DISABLE_COPY_MOVE(ExecutableCompilationUnit) +public: + friend class QQmlRefCounted<ExecutableCompilationUnit>; + friend class QQmlRefPointer<ExecutableCompilationUnit>; + friend struct ExecutionEngine; + + ExecutionEngine *engine = nullptr; + + QString finalUrlString() const { return m_compilationUnit->finalUrlString(); } + QString fileName() const { return m_compilationUnit->fileName(); } + + QUrl url() const { return m_compilationUnit->url(); } + QUrl finalUrl() const { return m_compilationUnit->finalUrl(); } + + QQmlRefPointer<QQmlTypeNameCache> typeNameCache() const + { + return m_compilationUnit->typeNameCache; + } + + QQmlPropertyCacheVector *propertyCachesPtr() + { + return &m_compilationUnit->propertyCaches; + } + + QQmlPropertyCache::ConstPtr rootPropertyCache() const + { + return m_compilationUnit->rootPropertyCache(); + } + + // mapping from component object index (CompiledData::Unit object index that points to component) to identifier hash of named objects + // this is initialized on-demand by QQmlContextData + QHash<int, IdentifierHash> namedObjectsPerComponentCache; + inline IdentifierHash namedObjectsPerComponent(int componentObjectIndex); + + int totalBindingsCount() const { return m_compilationUnit->totalBindingsCount(); } + int totalParserStatusCount() const { return m_compilationUnit->totalParserStatusCount(); } + int totalObjectCount() const { return m_compilationUnit->totalObjectCount(); } + + ResolvedTypeReference *resolvedType(int id) const + { + return m_compilationUnit->resolvedType(id); + } + + QQmlType qmlTypeForComponent(const QString &inlineComponentName = QString()) const + { + return m_compilationUnit->qmlTypeForComponent(inlineComponentName); + } + + QMetaType metaType() const { return m_compilationUnit->qmlType.typeId(); } + + int inlineComponentId(const QString &inlineComponentName) const + { + return m_compilationUnit->inlineComponentId(inlineComponentName); + } + + // --- interface for QQmlPropertyCacheCreator + using CompiledObject = CompiledData::CompilationUnit::CompiledObject; + using CompiledFunction = CompiledData::CompilationUnit::CompiledFunction; + using CompiledBinding = CompiledData::CompilationUnit::CompiledBinding; + using IdToObjectMap = CompiledData::CompilationUnit::IdToObjectMap; + + bool nativeMethodsAcceptThisObjects() const + { + return m_compilationUnit->nativeMethodsAcceptThisObjects(); + } + + bool ignoresFunctionSignature() const { return m_compilationUnit->ignoresFunctionSignature(); } + bool valueTypesAreCopied() const { return m_compilationUnit->valueTypesAreCopied(); } + bool valueTypesAreAddressable() const { return m_compilationUnit->valueTypesAreAddressable(); } + bool valueTypesAreAssertable() const { return m_compilationUnit->valueTypesAreAssertable(); } + bool componentsAreBound() const { return m_compilationUnit->componentsAreBound(); } + bool isESModule() const { return m_compilationUnit->isESModule(); } + + int objectCount() const { return m_compilationUnit->objectCount(); } + const CompiledObject *objectAt(int index) const + { + return m_compilationUnit->objectAt(index); + } + + Heap::Object *templateObjectAt(int index) const; + + Heap::Module *instantiate(); + const Value *resolveExport(QV4::String *exportName) + { + QVector<ResolveSetEntry> resolveSet; + return resolveExportRecursively(exportName, &resolveSet); + } + + QStringList exportedNames() const + { + QStringList names; + QVector<const ExecutableCompilationUnit*> exportNameSet; + getExportedNamesRecursively(&names, &exportNameSet); + names.sort(); + auto last = std::unique(names.begin(), names.end()); + names.erase(last, names.end()); + return names; + } + + void evaluate(); + void evaluateModuleRequests(); + + void mark(MarkStack *markStack) const { markObjects(markStack); } + void markObjects(MarkStack *markStack) const; + + QString bindingValueAsString(const CompiledData::Binding *binding) const; + double bindingValueAsNumber(const CompiledData::Binding *binding) const + { + return m_compilationUnit->bindingValueAsNumber(binding); + } + QString bindingValueAsScriptString(const CompiledData::Binding *binding) const + { + return m_compilationUnit->bindingValueAsScriptString(binding); + } + + struct TranslationDataIndex + { + uint index; + bool byId; + }; + + QString translateFrom(TranslationDataIndex index) const; + + Heap::Module *module() const; + void setModule(Heap::Module *module); + + ReturnedValue value() const { return m_valueOrModule.asReturnedValue(); } + void setValue(const QV4::Value &value) { m_valueOrModule = value; } + + const CompiledData::Unit *unitData() const { return m_compilationUnit->data; } + + QString stringAt(uint index) const { return m_compilationUnit->stringAt(index); } + + const QVector<QQmlRefPointer<QQmlScriptData>> *dependentScriptsPtr() const + { + return &m_compilationUnit->dependentScripts; + } + + const CompiledData::BindingPropertyData *bindingPropertyDataPerObjectAt( + qsizetype objectIndex) const + { + return &m_compilationUnit->bindingPropertyDataPerObject.at(objectIndex); + } + + const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &baseCompilationUnit() const + { + return m_compilationUnit; + } + + QV4::Function *rootFunction() + { + if (!runtimeStrings) + populate(); + + const auto *data = unitData(); + return data->indexOfRootFunction != -1 + ? runtimeFunctions[data->indexOfRootFunction] + : nullptr; + } + + void populate(); + void clear(); + +protected: + quint32 totalStringCount() const + { return unitData()->stringTableSize; } + +private: + friend struct ExecutionEngine; + + QQmlRefPointer<CompiledData::CompilationUnit> m_compilationUnit; + Value m_valueOrModule = QV4::Value::emptyValue(); + + struct ResolveSetEntry + { + ResolveSetEntry() {} + ResolveSetEntry(ExecutableCompilationUnit *module, QV4::String *exportName) + : module(module), exportName(exportName) {} + ExecutableCompilationUnit *module = nullptr; + QV4::String *exportName = nullptr; + }; + + ExecutableCompilationUnit(); + ExecutableCompilationUnit(QQmlRefPointer<CompiledData::CompilationUnit> &&compilationUnit); + ~ExecutableCompilationUnit(); + + static QQmlRefPointer<ExecutableCompilationUnit> create( + QQmlRefPointer<CompiledData::CompilationUnit> &&compilationUnit, + ExecutionEngine *engine); + + const Value *resolveExportRecursively(QV4::String *exportName, + QVector<ResolveSetEntry> *resolveSet); + + QUrl urlAt(int index) const { return QUrl(stringAt(index)); } + + Q_NEVER_INLINE IdentifierHash createNamedObjectsPerComponent(int componentObjectIndex); + const CompiledData::ExportEntry *lookupNameInExportTable( + const CompiledData::ExportEntry *firstExportEntry, int tableSize, + QV4::String *name) const; + + void getExportedNamesRecursively( + QStringList *names, QVector<const ExecutableCompilationUnit *> *exportNameSet, + bool includeDefaultExport = true) const; +}; + +IdentifierHash ExecutableCompilationUnit::namedObjectsPerComponent(int componentObjectIndex) +{ + auto it = namedObjectsPerComponentCache.constFind(componentObjectIndex); + if (Q_UNLIKELY(it == namedObjectsPerComponentCache.cend())) + return createNamedObjectsPerComponent(componentObjectIndex); + Q_ASSERT(!it->isEmpty()); + return *it; +} + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4EXECUTABLECOMPILATIONUNIT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4function_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4function_p.h new file mode 100644 index 0000000000000000000000000000000000000000..26bac232534e6501e1bab20dc885ded5fe06cfb3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4function_p.h @@ -0,0 +1,141 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4FUNCTION_H +#define QV4FUNCTION_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qqmlprivate.h> +#include "qv4global_p.h" +#include <private/qv4executablecompilationunit_p.h> +#include <private/qv4context_p.h> +#include <private/qv4string_p.h> + +namespace JSC { +class MacroAssemblerCodeRef; +} + +QT_BEGIN_NAMESPACE + +struct QQmlSourceLocation; + +namespace QV4 { + +struct Q_QML_EXPORT FunctionData +{ + WriteBarrier::HeapObjectWrapper<CompilationUnitRuntimeData, 1> compilationUnit; + + // Intentionally require an ExecutableCompilationUnit but save only a pointer to + // CompilationUnitBase. This is so that we can take advantage of the standard layout + // of CompilationUnitBase in the JIT. Furthermore we can safely static_cast to + // ExecutableCompilationUnit where we need it. + FunctionData(EngineBase *engine, ExecutableCompilationUnit *compilationUnit_); +}; +// Make sure this class can be accessed through offsetof (done by the assemblers): +Q_STATIC_ASSERT(std::is_standard_layout< FunctionData >::value); + +struct Q_QML_EXPORT Function : public FunctionData { +protected: + Function(ExecutionEngine *engine, ExecutableCompilationUnit *unit, + const CompiledData::Function *function, const QQmlPrivate::AOTCompiledFunction *aotFunction); + ~Function(); + +public: + struct JSTypedFunction { + QVarLengthArray<QQmlType, 4> types; + }; + + struct AOTCompiledFunction { + QVarLengthArray<QMetaType, 4> types; + }; + + QV4::ExecutableCompilationUnit *executableCompilationUnit() const + { + // This is safe: We require an ExecutableCompilationUnit in the ctor. + return static_cast<QV4::ExecutableCompilationUnit *>(compilationUnit.get()); + } + + QV4::Heap::String *runtimeString(uint i) const + { + return compilationUnit->runtimeStrings[i]; + } + + bool call(QObject *thisObject, void **a, const QMetaType *types, int argc, + ExecutionContext *context); + ReturnedValue call(const Value *thisObject, const Value *argv, int argc, + ExecutionContext *context); + + const CompiledData::Function *compiledFunction = nullptr; + const char *codeData = nullptr; + JSC::MacroAssemblerCodeRef *codeRef = nullptr; + + typedef ReturnedValue (*JittedCode)(CppStackFrame *, ExecutionEngine *); + typedef void (*AotCompiledCode)(const QQmlPrivate::AOTCompiledContext *context, void **argv); + + union { + void *noFunction = nullptr; + JSTypedFunction jsTypedFunction; + AOTCompiledFunction aotCompiledFunction; + }; + + union { + JittedCode jittedCode = nullptr; + AotCompiledCode aotCompiledCode; + }; + + // first nArguments names in internalClass are the actual arguments + QV4::WriteBarrier::Pointer<Heap::InternalClass> internalClass; + int interpreterCallCount = 0; + quint16 nFormals = 0; + enum Kind : quint8 { JsUntyped, JsTyped, AotCompiled, Eval }; + Kind kind = JsUntyped; + bool detectedInjectedParameters = false; + + static Function *create(ExecutionEngine *engine, ExecutableCompilationUnit *unit, + const CompiledData::Function *function, + const QQmlPrivate::AOTCompiledFunction *aotFunction); + void destroy(); + + void mark(QV4::MarkStack *ms); + + // used when dynamically assigning signal handlers (QQmlConnection) + void updateInternalClass(ExecutionEngine *engine, const QList<QByteArray> ¶meters); + + inline Heap::String *name() const { + return runtimeString(compiledFunction->nameIndex); + } + + static QString prettyName(const Function *function, const void *address); + + inline QString sourceFile() const { return executableCompilationUnit()->fileName(); } + inline QUrl finalUrl() const { return executableCompilationUnit()->finalUrl(); } + + inline bool isStrict() const { return compiledFunction->flags & CompiledData::Function::IsStrict; } + inline bool isArrowFunction() const { return compiledFunction->flags & CompiledData::Function::IsArrowFunction; } + inline bool isGenerator() const { return compiledFunction->flags & CompiledData::Function::IsGenerator; } + inline bool isClosureWrapper() const { return compiledFunction->flags & CompiledData::Function::IsClosureWrapper; } + + QQmlSourceLocation sourceLocation() const; + + Function *nestedFunction() const + { + if (compiledFunction->nestedFunctionIndex == std::numeric_limits<uint32_t>::max()) + return nullptr; + return executableCompilationUnit()->runtimeFunctions[compiledFunction->nestedFunctionIndex]; + } +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4functionobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4functionobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3457d02fd5c302dd26af15ba3fcc0e5117a7a12a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4functionobject_p.h @@ -0,0 +1,378 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4FUNCTIONOBJECT_H +#define QV4FUNCTIONOBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4function_p.h" +#include "qv4context_p.h" +#include <private/qv4mm_p.h> + +QT_BEGIN_NAMESPACE + +struct QQmlSourceLocation; + +namespace QV4 { + +struct IndexedBuiltinFunction; +struct JSCallData; + +// A FunctionObject is generally something that can be called, either with a JavaScript +// signature (QV4::Value etc) or with a C++ signature (QMetaType etc). For this, it has +// the Call and CallWithMetaTypes VTable entries. +// Some FunctionObjects need to select the actual implementation of the call at run time. +// This comese in two flavors: +// 1. The implementation is a JavaScript function. For these we have +// JavaScriptFunctionObject that holds a QV4::Function member to defer the call to. +// 2. The implementation is a C++ function. For these we have DynamicFunctionObject that +// holds another Call member in the heap object to defer the call to. +// In addition, a FunctionObject may want to be called as constructor. For this we have +// another VTable entry and a flag in the heap object. + +namespace Heap { + +#define FunctionObjectMembers(class, Member) +DECLARE_HEAP_OBJECT(FunctionObject, Object) { + enum { + Index_ProtoConstructor = 0, + Index_Prototype = 0, + Index_HasInstance = 1, + }; + + Q_QML_EXPORT void init(QV4::ExecutionEngine *engine, QV4::String *name = nullptr); + Q_QML_EXPORT void init(QV4::ExecutionEngine *engine, const QString &name); + Q_QML_EXPORT void init(); +}; + +#define JavaScriptFunctionObjectMembers(class, Member) \ + Member(class, Pointer, ExecutionContext *, scope) \ + Member(class, NoMark, Function *, function) + +DECLARE_HEAP_OBJECT(JavaScriptFunctionObject, FunctionObject) { + DECLARE_MARKOBJECTS(JavaScriptFunctionObject) + + void init(QV4::ExecutionContext *scope, QV4::Function *function, QV4::String *n = nullptr); + Q_QML_EXPORT void destroy(); + + void setFunction(Function *f); + + unsigned int formalParameterCount() { return function ? function->nFormals : 0; } + unsigned int varCount() { return function ? function->compiledFunction->nLocals : 0; } +}; + +#define DynamicFunctionObjectMembers(class, Member) \ + Member(class, NoMark, VTable::Call, jsCall) + +DECLARE_HEAP_OBJECT(DynamicFunctionObject, FunctionObject) { + // NB: We might add a CallWithMetaTypes member to this struct and implement our + // builtins with metatypes, to be called from C++ code. This would make them + // available to qmlcachegen's C++ code generation. + void init(ExecutionEngine *engine, QV4::String *name, VTable::Call call); +}; + +struct FunctionCtor : FunctionObject { + void init(QV4::ExecutionEngine *engine); +}; + +struct FunctionPrototype : FunctionObject { + void init(); +}; + +// A function object with an additional index into a list. +// Used by Models to refer to property roles. +struct IndexedBuiltinFunction : DynamicFunctionObject { + inline void init(QV4::ExecutionEngine *engine, qsizetype index, VTable::Call call); + qsizetype index; +}; + +struct ArrowFunction : JavaScriptFunctionObject { + enum { + Index_Name = Index_HasInstance + 1, + Index_Length + }; + void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name = nullptr); +}; + +#define ScriptFunctionMembers(class, Member) \ + Member(class, Pointer, InternalClass *, cachedClassForConstructor) + +DECLARE_HEAP_OBJECT(ScriptFunction, ArrowFunction) { + DECLARE_MARKOBJECTS(ScriptFunction) + void init(QV4::ExecutionContext *scope, Function *function); +}; + +#define MemberFunctionMembers(class, Member) \ + Member(class, Pointer, Object *, homeObject) + +DECLARE_HEAP_OBJECT(MemberFunction, ArrowFunction) { + DECLARE_MARKOBJECTS(MemberFunction) + + void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name = nullptr) { + ArrowFunction::init(scope, function, name); + } +}; + +#define ConstructorFunctionMembers(class, Member) \ + Member(class, Pointer, Object *, homeObject) + +DECLARE_HEAP_OBJECT(ConstructorFunction, ScriptFunction) { + DECLARE_MARKOBJECTS(ConstructorFunction) + bool isDerivedConstructor; +}; + +#define DefaultClassConstructorFunctionMembers(class, Member) \ + Member(class, Pointer, ExecutionContext *, scope) + +DECLARE_HEAP_OBJECT(DefaultClassConstructorFunction, FunctionObject) { + DECLARE_MARKOBJECTS(DefaultClassConstructorFunction) + + bool isDerivedConstructor; + + void init(QV4::ExecutionContext *scope); +}; + +#define BoundFunctionMembers(class, Member) \ + Member(class, Pointer, FunctionObject *, target) \ + Member(class, HeapValue, HeapValue, boundThis) \ + Member(class, Pointer, MemberData *, boundArgs) + +DECLARE_HEAP_OBJECT(BoundFunction, JavaScriptFunctionObject) { + DECLARE_MARKOBJECTS(BoundFunction) + + void init(QV4::FunctionObject *target, const Value &boundThis, QV4::MemberData *boundArgs); +}; + +struct BoundConstructor : BoundFunction {}; + +} + +struct Q_QML_EXPORT FunctionObject: Object { + V4_OBJECT2(FunctionObject, Object) + Q_MANAGED_TYPE(FunctionObject) + V4_INTERNALCLASS(FunctionObject) + V4_PROTOTYPE(functionPrototype) + enum { NInlineProperties = 1 }; + + bool canBeTailCalled() const { return vtable()->isTailCallable; } + + ReturnedValue name() const; + + void setName(String *name) { + defineReadonlyConfigurableProperty(engine()->id_name(), *name); + } + void createDefaultPrototypeProperty(uint protoConstructorSlot); + + ReturnedValue callAsConstructor( + const Value *argv, int argc, const Value *newTarget = nullptr) const + { + if (const auto callAsConstructor = vtable()->callAsConstructor) + return callAsConstructor(this, argv, argc, newTarget ? newTarget : this); + return failCallAsConstructor(); + } + + ReturnedValue call(const Value *thisObject, const Value *argv, int argc) const + { + if (const auto call = vtable()->call) + return call(this, thisObject, argv, argc); + return failCall(); + } + + void call(QObject *thisObject, void **argv, const QMetaType *types, int argc) const + { + if (const auto callWithMetaTypes = vtable()->callWithMetaTypes) + callWithMetaTypes(this, thisObject, argv, types, argc); + else + failCall(); + } + + inline ReturnedValue callAsConstructor(const JSCallData &data) const; + inline ReturnedValue call(const JSCallData &data) const; + + ReturnedValue failCall() const; + ReturnedValue failCallAsConstructor() const; + static void virtualConvertAndCall( + const FunctionObject *f, QObject *thisObject, + void **argv, const QMetaType *types, int argc); + + static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function); + static Heap::FunctionObject *createConstructorFunction(ExecutionContext *scope, Function *function, Object *homeObject, bool isDerivedConstructor); + static Heap::FunctionObject *createMemberFunction(ExecutionContext *scope, Function *function, Object *homeObject, String *name); + static Heap::FunctionObject *createBuiltinFunction(ExecutionEngine *engine, StringOrSymbol *nameOrSymbol, VTable::Call code, int argumentCount); + + bool isBinding() const; + bool isBoundFunction() const; + bool isConstructor() const { return vtable()->callAsConstructor; } + + ReturnedValue getHomeObject() const; + + ReturnedValue protoProperty() const { + return getValueByIndex(Heap::FunctionObject::Index_Prototype); + } + bool hasHasInstanceProperty() const { + return !internalClass()->propertyData.at(Heap::FunctionObject::Index_HasInstance).isEmpty(); + } +}; + +template<> +inline const FunctionObject *Value::as() const { + if (!isManaged()) + return nullptr; + + const VTable *vtable = m()->internalClass->vtable; + return (vtable->call || vtable->callAsConstructor) + ? reinterpret_cast<const FunctionObject *>(this) + : nullptr; +} + +struct Q_QML_EXPORT JavaScriptFunctionObject: FunctionObject +{ + V4_OBJECT2(JavaScriptFunctionObject, FunctionObject) + V4_NEEDS_DESTROY + + Heap::ExecutionContext *scope() const { return d()->scope; } + + Function *function() const { return d()->function; } + unsigned int formalParameterCount() const { return d()->formalParameterCount(); } + unsigned int varCount() const { return d()->varCount(); } + bool strictMode() const { return d()->function ? d()->function->isStrict() : false; } + QQmlSourceLocation sourceLocation() const; +}; + +struct Q_QML_EXPORT DynamicFunctionObject: FunctionObject +{ + V4_OBJECT2(DynamicFunctionObject, FunctionObject) + + static ReturnedValue virtualCall( + const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct FunctionCtor: FunctionObject +{ + V4_OBJECT2(FunctionCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +protected: + enum Type { + Type_Function, + Type_Generator + }; + static QQmlRefPointer<ExecutableCompilationUnit> parse(ExecutionEngine *engine, const Value *argv, int argc, Type t = Type_Function); +}; + +struct FunctionPrototype: FunctionObject +{ + V4_OBJECT2(FunctionPrototype, FunctionObject) + + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue virtualCall( + const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_apply(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_call(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_bind(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_hasInstance(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +struct Q_QML_EXPORT IndexedBuiltinFunction : DynamicFunctionObject +{ + V4_OBJECT2(IndexedBuiltinFunction, DynamicFunctionObject) +}; + +void Heap::IndexedBuiltinFunction::init( + QV4::ExecutionEngine *engine, qsizetype index, VTable::Call call) +{ + Heap::FunctionObject::init(engine); + this->jsCall = call; + this->index = index; +} + +struct ArrowFunction : JavaScriptFunctionObject { + V4_OBJECT2(ArrowFunction, JavaScriptFunctionObject) + V4_INTERNALCLASS(ArrowFunction) + enum { + NInlineProperties = 3, + IsTailCallable = true, + }; + + static void virtualCallWithMetaTypes(const FunctionObject *f, QObject *thisObject, + void **a, const QMetaType *types, int argc); + static ReturnedValue virtualCall(const QV4::FunctionObject *f, const QV4::Value *thisObject, + const QV4::Value *argv, int argc); +}; + +struct ScriptFunction : ArrowFunction { + V4_OBJECT2(ScriptFunction, ArrowFunction) + V4_INTERNALCLASS(ScriptFunction) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *); + + Heap::InternalClass *classForConstructor() const; +}; + +struct MemberFunction : ArrowFunction { + V4_OBJECT2(MemberFunction, ArrowFunction) + V4_INTERNALCLASS(MemberFunction) +}; + +struct ConstructorFunction : ScriptFunction { + V4_OBJECT2(ConstructorFunction, ScriptFunction) + V4_INTERNALCLASS(ConstructorFunction) + static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct DefaultClassConstructorFunction : FunctionObject { + V4_OBJECT2(DefaultClassConstructorFunction, FunctionObject) + + Heap::ExecutionContext *scope() const { return d()->scope; } + static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct BoundFunction: JavaScriptFunctionObject { + V4_OBJECT2(BoundFunction, JavaScriptFunctionObject) + + Heap::FunctionObject *target() const { return d()->target; } + Value boundThis() const { return d()->boundThis; } + Heap::MemberData *boundArgs() const { return d()->boundArgs; } + + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct BoundConstructor: BoundFunction { + V4_OBJECT2(BoundConstructor, BoundFunction) + + static ReturnedValue virtualCallAsConstructor( + const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + +inline bool FunctionObject::isBoundFunction() const +{ + const VTable *vtable = d()->vtable(); + return vtable == BoundFunction::staticVTable() || vtable == BoundConstructor::staticVTable(); +} + +inline ReturnedValue checkedResult(QV4::ExecutionEngine *v4, ReturnedValue result) +{ + return v4->hasException ? QV4::Encode::undefined() : result; +} + +} + +QT_END_NAMESPACE + +#endif // QMLJS_OBJECTS_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4functiontable_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4functiontable_p.h new file mode 100644 index 0000000000000000000000000000000000000000..11a53a410f633911760780a89ecacd028feb2f98 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4functiontable_p.h @@ -0,0 +1,39 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4FUNCTIONTABLE_P_H +#define QV4FUNCTIONTABLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qqmlglobal_p.h> + +namespace JSC { +class MacroAssemblerCodeRef; +} + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct Function; + +void generateFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef); +void destroyFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef); + +size_t exceptionHandlerSize(); + +} + +QT_END_NAMESPACE + +#endif // QV4FUNCTIONTABLE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4generatorobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4generatorobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..91c2f9b78c159020de3f3655fb67204d8660c2a0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4generatorobject_p.h @@ -0,0 +1,119 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4GENERATOROBJECT_P_H +#define QV4GENERATOROBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4functionobject_p.h" +#include "qv4stackframe_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +enum class GeneratorState { + Undefined, + SuspendedStart, + SuspendedYield, + Executing, + Completed +}; + +namespace Heap { + +struct GeneratorFunctionCtor : FunctionObject { + void init(ExecutionEngine *engine); +}; + +struct GeneratorFunction : ArrowFunction { + void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name = nullptr) { + ArrowFunction::init(scope, function, name); + } +}; + +struct MemberGeneratorFunction : MemberFunction { +}; + +struct GeneratorPrototype : FunctionObject { + void init(); +}; + +#define GeneratorObjectMembers(class, Member) \ + Member(class, Pointer, ExecutionContext *, context) \ + Member(class, NoMark, GeneratorState, state) \ + Member(class, NoMark, JSTypesStackFrame, cppFrame) \ + Member(class, Pointer, ArrayObject *, values) \ + Member(class, Pointer, ArrayObject *, jsFrame) + +DECLARE_HEAP_OBJECT(GeneratorObject, Object) { + DECLARE_MARKOBJECTS(GeneratorObject) +}; + +} + +struct GeneratorFunctionCtor : FunctionCtor +{ + V4_OBJECT2(GeneratorFunctionCtor, FunctionCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct GeneratorFunction : ArrowFunction +{ + V4_OBJECT2(GeneratorFunction, ArrowFunction) + V4_INTERNALCLASS(GeneratorFunction) + + static inline constexpr quint8 IsTailCallable = false; + + static Heap::FunctionObject *create(ExecutionContext *scope, Function *function); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct MemberGeneratorFunction : MemberFunction +{ + V4_OBJECT2(MemberGeneratorFunction, MemberFunction) + V4_INTERNALCLASS(MemberGeneratorFunction) + + static inline constexpr quint8 IsTailCallable = false; + + static Heap::FunctionObject *create(ExecutionContext *scope, Function *function, Object *homeObject, String *name); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct GeneratorPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_next(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_return(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_throw(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + + +struct GeneratorObject : Object { + V4_OBJECT2(GeneratorObject, Object) + Q_MANAGED_TYPE(GeneratorObject) + V4_INTERNALCLASS(GeneratorObject) + V4_PROTOTYPE(generatorPrototype) + + ReturnedValue resume(ExecutionEngine *engine, const Value &arg, std::optional<Value>) const; +}; + +} + +QT_END_NAMESPACE + +#endif // QV4GENERATORFUNCTION_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4global_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4global_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b6e312a6133f227c25a03d78be6e78e1efe7dc4a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4global_p.h @@ -0,0 +1,305 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4GLOBAL_H +#define QV4GLOBAL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <private/qv4compilerglobal_p.h> +#include <QString> + +#include <qtqmlglobal.h> +#include <private/qtqmlglobal_p.h> + +// Do certain things depending on whether the JIT is enabled or disabled + +#if QT_CONFIG(qml_jit) +#define ENABLE_YARR_JIT 1 +#define ENABLE_JIT 1 +#define ENABLE_ASSEMBLER 1 +#else +#define ENABLE_YARR_JIT 0 +#define ENABLE_ASSEMBLER 0 +#define ENABLE_JIT 0 +#endif + +#if defined(Q_OS_QNX) && defined(_CPPLIB_VER) +#include <math.h> +#undef isnan +#undef isfinite +#undef isinf +#undef signbit +#endif + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Compiler { + struct Module; + struct Context; + struct JSUnitGenerator; + class Codegen; +} + +namespace Moth { + class BytecodeGenerator; +} + +namespace Heap { + struct Base; + struct MemberData; + struct ArrayData; + + struct StringOrSymbol; + struct String; + struct Symbol; + struct Object; + struct ObjectPrototype; + + struct ExecutionContext; + struct CallContext; + struct QmlContext; + struct ScriptFunction; + struct InternalClass; + + struct BooleanObject; + struct NumberObject; + struct StringObject; + struct ArrayObject; + struct DateObject; + struct FunctionObject; + struct JavaScriptFunctionObject; + struct ErrorObject; + struct ArgumentsObject; + struct QObjectWrapper; + struct RegExpObject; + struct UrlObject; + struct UrlSearchParamsObject; + struct RegExp; + struct EvalFunction; + + struct SharedArrayBuffer; + struct ArrayBuffer; + struct DataView; + struct TypedArray; + + struct MapObject; + struct SetObject; + + struct PromiseObject; + struct PromiseCapability; + + template <typename T, size_t> struct Pointer; +} + +struct CppStackFrame; +struct JSTypesStackFrame; +struct MetaTypesStackFrame; +class MemoryManager; +class ExecutableAllocator; +struct PropertyKey; +struct StringOrSymbol; +struct String; +struct Symbol; +struct Object; +struct ObjectPrototype; +struct ObjectIterator; +struct ExecutionContext; +struct CallContext; +struct QmlContext; +struct ScriptFunction; +struct InternalClass; +struct Property; +struct Value; +template<size_t> struct HeapValue; +template<size_t> struct ValueArray; +struct Lookup; +struct ArrayData; +struct VTable; +struct Function; + +struct BooleanObject; +struct NumberObject; +struct StringObject; +struct ArrayObject; +struct DateObject; +struct FunctionObject; +struct ErrorObject; +struct ArgumentsObject; +struct Managed; +struct ExecutionEngine; +struct QObjectWrapper; +struct RegExpObject; +struct RegExp; +struct EvalFunction; + +struct SharedArrayBuffer; +struct ArrayBuffer; +struct DataView; +struct TypedArray; + +struct MapObject; +struct SetMapObject; + +struct PromiseObject; +struct PromiseCapability; + +struct CallData; +struct Scope; +struct ScopedValue; +template<typename T> struct Scoped; +typedef Scoped<String> ScopedString; +typedef Scoped<StringOrSymbol> ScopedStringOrSymbol; +typedef Scoped<Object> ScopedObject; +typedef Scoped<ArrayObject> ScopedArrayObject; +typedef Scoped<FunctionObject> ScopedFunctionObject; +typedef Scoped<ExecutionContext> ScopedContext; + +struct PersistentValueStorage; +class PersistentValue; +class WeakValue; +struct MarkStack; + +struct IdentifierTable; +class RegExpCache; +class MultiplyWrappedQObjectMap; + +enum PropertyFlag { + Attr_Data = 0, + Attr_Accessor = 0x1, + Attr_NotWritable = 0x2, + Attr_NotEnumerable = 0x4, + Attr_NotConfigurable = 0x8, + Attr_ReadOnly = Attr_NotWritable|Attr_NotEnumerable|Attr_NotConfigurable, + Attr_ReadOnly_ButConfigurable = Attr_NotWritable|Attr_NotEnumerable, + Attr_Invalid = 0xff +}; + +Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag) +Q_DECLARE_OPERATORS_FOR_FLAGS(PropertyFlags) + +struct PropertyAttributes +{ + QT_WARNING_PUSH + QT_WARNING_DISABLE_MSVC(4201) // nonstandard extension used: nameless struct/union + union { + uchar m_all; + struct { + uchar m_flags : 4; + uchar m_mask : 4; + }; + struct { + uchar m_type : 1; + uchar m_writable : 1; + uchar m_enumerable : 1; + uchar m_configurable : 1; + uchar type_set : 1; + uchar writable_set : 1; + uchar enumerable_set : 1; + uchar configurable_set : 1; + }; + }; + QT_WARNING_POP + + enum Type { + Data = 0, + Accessor = 1, + Generic = 2 + }; + + PropertyAttributes() : m_all(0) {} + PropertyAttributes(PropertyFlag f) : m_all(0) { + if (f != Attr_Invalid) { + setType(f & Attr_Accessor ? Accessor : Data); + if (!(f & Attr_Accessor)) + setWritable(!(f & Attr_NotWritable)); + setEnumerable(!(f & Attr_NotEnumerable)); + setConfigurable(!(f & Attr_NotConfigurable)); + } + } + PropertyAttributes(PropertyFlags f) : m_all(0) { + if (f != Attr_Invalid) { + setType(f & Attr_Accessor ? Accessor : Data); + if (!(f & Attr_Accessor)) + setWritable(!(f & Attr_NotWritable)); + setEnumerable(!(f & Attr_NotEnumerable)); + setConfigurable(!(f & Attr_NotConfigurable)); + } + } + + void setType(Type t) { m_type = t; type_set = true; } + Type type() const { return type_set ? (Type)m_type : Generic; } + + bool isData() const { return type() == PropertyAttributes::Data || writable_set; } + bool isAccessor() const { return type() == PropertyAttributes::Accessor; } + bool isGeneric() const { return type() == PropertyAttributes::Generic && !writable_set; } + + bool hasType() const { return type_set; } + bool hasWritable() const { return writable_set; } + bool hasConfigurable() const { return configurable_set; } + bool hasEnumerable() const { return enumerable_set; } + + void setWritable(bool b) { m_writable = b; writable_set = true; } + void setConfigurable(bool b) { m_configurable = b; configurable_set = true; } + void setEnumerable(bool b) { m_enumerable = b; enumerable_set = true; } + + void resolve() { m_mask = 0xf; if (m_type == Accessor) { m_writable = false; writable_set = false; } } + + bool isWritable() const { return m_type != Data || m_writable; } + bool isEnumerable() const { return m_enumerable; } + bool isConfigurable() const { return m_configurable; } + + void clearType() { m_type = Data; type_set = false; } + void clearWritable() { m_writable = false; writable_set = false; } + void clearEnumerable() { m_enumerable = false; enumerable_set = false; } + void clearConfigurable() { m_configurable = false; configurable_set = false; } + + void clear() { m_all = 0; } + bool isEmpty() const { return !m_all; } + + uint all() const { return m_all; } + + bool operator==(PropertyAttributes other) { + return m_all == other.m_all; + } + bool operator!=(PropertyAttributes other) { + return m_all != other.m_all; + } +}; + +struct Q_QML_EXPORT StackFrame { + QString source; + QString function; + int line = -1; + int column = -1; +}; +typedef QVector<StackFrame> StackTrace; + +namespace JIT { + +enum class CallResultDestination { + Ignore, + InAccumulator, +}; + +} // JIT namespace + +} // QV4 namespace + +Q_DECLARE_TYPEINFO(QV4::PropertyAttributes, Q_PRIMITIVE_TYPE); + +QT_END_NAMESPACE + +#endif // QV4GLOBAL_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4globalobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4globalobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..939fc54771852c372de8f8fe1ff4708797c6e913 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4globalobject_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4GLOBALOBJECT_H +#define QV4GLOBALOBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qqmlglobal_p.h> +#include "qv4functionobject_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct EvalFunction : FunctionObject { + void init(ExecutionEngine *engine); +}; + +} + +struct Q_QML_EXPORT EvalFunction : FunctionObject +{ + V4_OBJECT2(EvalFunction, FunctionObject) + + ReturnedValue evalCall(const Value *thisObject, const Value *argv, int argc, bool directCall) const; + + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct GlobalFunctions +{ + static ReturnedValue method_parseInt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_parseFloat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isNaN(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isFinite(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_decodeURI(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_decodeURIComponent(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_encodeURI(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_encodeURIComponent(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_escape(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_unescape(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +} + +QT_END_NAMESPACE + +#endif // QMLJS_OBJECTS_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4heap_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4heap_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f6ca8291c61cd54986e06a161132661d66d5ef50 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4heap_p.h @@ -0,0 +1,227 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4HEAP_P_H +#define QV4HEAP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <private/qv4mmdefs_p.h> +#include <private/qv4writebarrier_p.h> +#include <private/qv4vtable_p.h> +#include <QtCore/QSharedPointer> + +// To check if Heap::Base::init is called (meaning, all subclasses did their init and called their +// parent's init all up the inheritance chain), define QML_CHECK_INIT_DESTROY_CALLS below. +#undef QML_CHECK_INIT_DESTROY_CALLS + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +template <typename T, size_t o> +struct Pointer { + static constexpr size_t offset = o; + T operator->() const { return get(); } + operator T () const { return get(); } + + Base *base(); + + void set(EngineBase *e, T newVal) { + WriteBarrier::write(e, base(), &ptr, reinterpret_cast<Base *>(newVal)); + } + + T get() const { return reinterpret_cast<T>(ptr); } + + template <typename Type> + Type *cast() { return static_cast<Type *>(ptr); } + + Base *heapObject() const { return ptr; } + +private: + Base *ptr; +}; +typedef Pointer<char *, 0> V4PointerCheck; +Q_STATIC_ASSERT(std::is_trivial_v<V4PointerCheck>); + +struct Q_QML_EXPORT Base { + void *operator new(size_t) = delete; + + static void markObjects(Base *, MarkStack *); + + Pointer<InternalClass *, 0> internalClass; + + inline ReturnedValue asReturnedValue() const; + inline void mark(QV4::MarkStack *markStack); + + inline bool isMarked() const { + const HeapItem *h = reinterpret_cast<const HeapItem *>(this); + Chunk *c = h->chunk(); + Q_ASSERT(!Chunk::testBit(c->extendsBitmap, h - c->realBase())); + return Chunk::testBit(c->blackBitmap, h - c->realBase()); + } + inline void setMarkBit() { + const HeapItem *h = reinterpret_cast<const HeapItem *>(this); + Chunk *c = h->chunk(); + Q_ASSERT(!Chunk::testBit(c->extendsBitmap, h - c->realBase())); + return Chunk::setBit(c->blackBitmap, h - c->realBase()); + } + + inline bool inUse() const { + const HeapItem *h = reinterpret_cast<const HeapItem *>(this); + Chunk *c = h->chunk(); + Q_ASSERT(!Chunk::testBit(c->extendsBitmap, h - c->realBase())); + return Chunk::testBit(c->objectBitmap, h - c->realBase()); + } + + void *operator new(size_t, Managed *m) { return m; } + void *operator new(size_t, Base *m) { return m; } + void operator delete(void *, Base *) {} + + void init() { _setInitialized(); } + void destroy() { _setDestroyed(); } +#ifdef QML_CHECK_INIT_DESTROY_CALLS + enum { Uninitialized = 0, Initialized, Destroyed } _livenessStatus; + void _checkIsInitialized() { + if (_livenessStatus == Uninitialized) + fprintf(stderr, "ERROR: use of object '%s' before call to init() !!\n", + vtable()->className); + else if (_livenessStatus == Destroyed) + fprintf(stderr, "ERROR: use of object '%s' after call to destroy() !!\n", + vtable()->className); + Q_ASSERT(_livenessStatus == Initialized); + } + void _checkIsDestroyed() { + if (_livenessStatus == Initialized) + fprintf(stderr, "ERROR: object '%s' was never destroyed completely !!\n", + vtable()->className); + Q_ASSERT(_livenessStatus == Destroyed); + } + void _setInitialized() { Q_ASSERT(_livenessStatus == Uninitialized); _livenessStatus = Initialized; } + void _setDestroyed() { + if (_livenessStatus == Uninitialized) + fprintf(stderr, "ERROR: attempting to destroy an uninitialized object '%s' !!\n", + vtable()->className); + else if (_livenessStatus == Destroyed) + fprintf(stderr, "ERROR: attempting to destroy repeatedly object '%s' !!\n", + vtable()->className); + Q_ASSERT(_livenessStatus == Initialized); + _livenessStatus = Destroyed; + } +#else + Q_ALWAYS_INLINE void _checkIsInitialized() {} + Q_ALWAYS_INLINE void _checkIsDestroyed() {} + Q_ALWAYS_INLINE void _setInitialized() {} + Q_ALWAYS_INLINE void _setDestroyed() {} +#endif +}; +Q_STATIC_ASSERT(std::is_trivial_v<Base>); +// This class needs to consist only of pointer sized members to allow +// for a size/offset translation when cross-compiling between 32- and +// 64-bit. +Q_STATIC_ASSERT(std::is_standard_layout<Base>::value); +Q_STATIC_ASSERT(offsetof(Base, internalClass) == 0); +Q_STATIC_ASSERT(sizeof(Base) == QT_POINTER_SIZE); + +inline +void Base::mark(QV4::MarkStack *markStack) +{ + Q_ASSERT(inUse()); + const HeapItem *h = reinterpret_cast<const HeapItem *>(this); + Chunk *c = h->chunk(); + size_t index = h - c->realBase(); + Q_ASSERT(!Chunk::testBit(c->extendsBitmap, index)); + quintptr *bitmap = c->blackBitmap + Chunk::bitmapIndex(index); + quintptr bit = Chunk::bitForIndex(index); + if (!(*bitmap & bit)) { + *bitmap |= bit; + markStack->push(this); + } +} + +template<typename T, size_t o> +Base *Pointer<T, o>::base() { + Base *base = reinterpret_cast<Base *>(this) - (offset/sizeof(Base *)); + Q_ASSERT(base->inUse()); + return base; +} + +} + +#ifdef QT_NO_QOBJECT +template <class T> +struct QV4QPointer { +}; +#else +template <class T> +struct QV4QPointer { + void init() + { + d = nullptr; + qObject = nullptr; + } + + void init(T *o) + { + Q_ASSERT(d == nullptr); + Q_ASSERT(qObject == nullptr); + if (o) { + d = QtSharedPointer::ExternalRefCountData::getAndRef(o); + qObject = o; + } + } + + void destroy() + { + if (d && !d->weakref.deref()) + delete d; + d = nullptr; + qObject = nullptr; + } + + T *data() const { + return d == nullptr || d->strongref.loadRelaxed() == 0 ? nullptr : qObject; + } + operator T*() const { return data(); } + inline T* operator->() const { return data(); } + QV4QPointer &operator=(T *o) + { + if (d) + destroy(); + init(o); + return *this; + } + + bool isNull() const noexcept + { + return !isValid() || d->strongref.loadRelaxed() == 0; + } + + bool isValid() const noexcept + { + return d != nullptr && qObject != nullptr; + } + +private: + QtSharedPointer::ExternalRefCountData *d; + T *qObject; +}; +Q_STATIC_ASSERT(std::is_trivial_v<QV4QPointer<QObject>>); +#endif + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4identifierhash_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4identifierhash_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c7331cec8ceac847b448b966e823839df3180bff --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4identifierhash_p.h @@ -0,0 +1,63 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4IDENTIFIERHASH_P_H +#define QV4IDENTIFIERHASH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qstring.h> +#include <private/qv4global_p.h> +#include <private/qv4propertykey_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct IdentifierHashEntry; +struct IdentifierHashData; +struct Q_QML_EXPORT IdentifierHash +{ + IdentifierHash() = default; + IdentifierHash(ExecutionEngine *engine); + IdentifierHash(const IdentifierHash &other); + ~IdentifierHash(); + IdentifierHash &operator=(const IdentifierHash &other); + + bool isEmpty() const { return !d; } + + int count() const; + + void detach(); + + void add(const QString &str, int value); + void add(Heap::String *str, int value); + + int value(const QString &str) const; + int value(String *str) const; + QString findId(int value) const; + +private: + inline IdentifierHashEntry *addEntry(PropertyKey i); + inline const IdentifierHashEntry *lookup(PropertyKey identifier) const; + inline const IdentifierHashEntry *lookup(const QString &str) const; + inline const IdentifierHashEntry *lookup(String *str) const; + inline const PropertyKey toIdentifier(const QString &str) const; + inline const PropertyKey toIdentifier(Heap::String *str) const; + + IdentifierHashData *d = nullptr; +}; + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4_IDENTIFIERHASH_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4identifierhashdata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4identifierhashdata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c80dbd4e9cb60b00696025c6656cbab927d8f0ab --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4identifierhashdata_p.h @@ -0,0 +1,86 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4IDENTIFIERHASHDATA_H +#define QV4IDENTIFIERHASHDATA_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <private/qv4propertykey_p.h> +#include <private/qv4identifiertable_p.h> +#include <QtCore/qatomic.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct IdentifierHashEntry { + PropertyKey identifier; + int value; +}; + +struct IdentifierHashData +{ + IdentifierHashData(IdentifierTable *table, int numBits) + : size(0) + , numBits(numBits) + , identifierTable(table) + { + refCount.storeRelaxed(1); + alloc = qPrimeForNumBits(numBits); + entries = (IdentifierHashEntry *)malloc(alloc*sizeof(IdentifierHashEntry)); + memset(entries, 0, alloc*sizeof(IdentifierHashEntry)); + identifierTable->addIdentifierHash(this); + } + + explicit IdentifierHashData(IdentifierHashData *other) + : size(other->size) + , numBits(other->numBits) + , identifierTable(other->identifierTable) + { + refCount.storeRelaxed(1); + alloc = other->alloc; + entries = (IdentifierHashEntry *)malloc(alloc*sizeof(IdentifierHashEntry)); + memcpy(entries, other->entries, alloc*sizeof(IdentifierHashEntry)); + identifierTable->addIdentifierHash(this); + } + + ~IdentifierHashData() { + free(entries); + if (identifierTable) + identifierTable->removeIdentifierHash(this); + } + + void markObjects(MarkStack *markStack) const + { + IdentifierHashEntry *e = entries; + IdentifierHashEntry *end = e + alloc; + while (e < end) { + if (Heap::Base *o = e->identifier.asStringOrSymbol()) + o->mark(markStack); + ++e; + } + } + + QBasicAtomicInt refCount; + int alloc; + int size; + int numBits; + IdentifierTable *identifierTable; + IdentifierHashEntry *entries; +}; + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4IDENTIFIERHASHDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4identifiertable_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4identifiertable_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fe1a741002d0fe56aabe0a3df3887b60a45adf04 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4identifiertable_p.h @@ -0,0 +1,85 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4IDENTIFIERTABLE_H +#define QV4IDENTIFIERTABLE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4identifierhash_p.h" +#include "qv4string_p.h" +#include "qv4engine_p.h" +#include <qset.h> +#include <limits.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct Q_QML_EXPORT IdentifierTable +{ + ExecutionEngine *engine; + + uint alloc; + uint size; + int numBits; + Heap::StringOrSymbol **entriesByHash; + Heap::StringOrSymbol **entriesById; + + QSet<IdentifierHashData *> idHashes; + + void addEntry(Heap::StringOrSymbol *str); + +public: + + IdentifierTable(ExecutionEngine *engine, int numBits = 8); + ~IdentifierTable(); + + Heap::String *insertString(const QString &s); + Heap::Symbol *insertSymbol(const QString &s); + + PropertyKey asPropertyKey(const Heap::String *str) { + if (str->identifier.isValid()) + return str->identifier; + return asPropertyKeyImpl(str); + } + PropertyKey asPropertyKey(const QV4::String *str) { + return asPropertyKey(str->d()); + } + + enum KeyConversionBehavior { Default, ForceConversionToId }; + PropertyKey asPropertyKey(const QString &s, KeyConversionBehavior conversionBehavior = Default); + + PropertyKey asPropertyKeyImpl(const Heap::String *str); + + Heap::StringOrSymbol *resolveId(PropertyKey i) const; + Heap::String *stringForId(PropertyKey i) const; + Heap::Symbol *symbolForId(PropertyKey i) const; + + void markObjects(MarkStack *markStack); + void sweep(); + + void addIdentifierHash(IdentifierHashData *h) { + idHashes.insert(h); + } + void removeIdentifierHash(IdentifierHashData *h) { + idHashes.remove(h); + } + +private: + Heap::String *resolveStringEntry(const QString &s, uint hash, uint subtype); +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4include_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4include_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b44120bd51f202d3374578d501daabd49d2ee62f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4include_p.h @@ -0,0 +1,78 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4INCLUDE_P_H +#define QV4INCLUDE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtCore/qurl.h> +#include <QtCore/qpointer.h> + +#include <private/qv4value_p.h> +#include <private/qv4context_p.h> +#include <private/qv4persistent_p.h> + +QT_BEGIN_NAMESPACE + +class QJSEngine; +class QJSValue; +#if QT_CONFIG(qml_network) +class QNetworkAccessManager; +#endif +class QNetworkReply; +class QV4Include : public QObject +{ + Q_OBJECT +public: + enum Status { + Ok = 0, + Loading = 1, + NetworkError = 2, + Exception = 3 + }; + + static QJSValue method_include(QV4::ExecutionEngine *engine, const QUrl &url, + const QJSValue &callbackFunction); + +private Q_SLOTS: + void finished(); + +private: + QV4Include(const QUrl &url, QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, + const QV4::Value &callback); + ~QV4Include(); + + QV4::ReturnedValue result(); + + static QV4::ReturnedValue resultValue(QV4::ExecutionEngine *v4, Status status = Loading, + const QString &statusText = QString()); + static void callback(const QV4::Value &callback, const QV4::Value &status); + + QV4::ExecutionEngine *v4; + QUrl m_url; + +#if QT_CONFIG(qml_network) + QNetworkAccessManager *m_network; + QPointer<QNetworkReply> m_reply; +#endif + + QV4::PersistentValue m_callbackFunction; + QV4::PersistentValue m_resultObject; + QV4::PersistentValue m_qmlContext; +}; + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4instr_moth_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4instr_moth_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3715c73c4be839cdee6408c7974c46a1c035fa03 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4instr_moth_p.h @@ -0,0 +1,593 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4INSTR_MOTH_P_H +#define QV4INSTR_MOTH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4staticvalue_p.h> +#include <private/qv4compileddata_p.h> // for CompiledData::CodeOffsetToLine used by the dumper +#include <qendian.h> + +QT_BEGIN_NAMESPACE + +#define INSTRUCTION(op, name, nargs, ...) \ + op##_INSTRUCTION(name, nargs, __VA_ARGS__) + +/* for all jump instructions, the offset has to come last, to simplify the job of the bytecode generator */ +#define INSTR_Nop(op) INSTRUCTION(op, Nop, 0) +#define INSTR_Ret(op) INSTRUCTION(op, Ret, 0) +#define INSTR_Debug(op) INSTRUCTION(op, Debug, 0) +#define INSTR_LoadConst(op) INSTRUCTION(op, LoadConst, 1, index) +#define INSTR_LoadZero(op) INSTRUCTION(op, LoadZero, 0) +#define INSTR_LoadTrue(op) INSTRUCTION(op, LoadTrue, 0) +#define INSTR_LoadFalse(op) INSTRUCTION(op, LoadFalse, 0) +#define INSTR_LoadNull(op) INSTRUCTION(op, LoadNull, 0) +#define INSTR_LoadUndefined(op) INSTRUCTION(op, LoadUndefined, 0) +#define INSTR_LoadInt(op) INSTRUCTION(op, LoadInt, 1, value) +#define INSTR_MoveConst(op) INSTRUCTION(op, MoveConst, 2, constIndex, destTemp) +#define INSTR_LoadReg(op) INSTRUCTION(op, LoadReg, 1, reg) +#define INSTR_StoreReg(op) INSTRUCTION(op, StoreReg, 1, reg) +#define INSTR_MoveReg(op) INSTRUCTION(op, MoveReg, 2, srcReg, destReg) +#define INSTR_LoadImport(op) INSTRUCTION(op, LoadImport, 1, index) +#define INSTR_LoadLocal(op) INSTRUCTION(op, LoadLocal, 1, index) +#define INSTR_StoreLocal(op) INSTRUCTION(op, StoreLocal, 1, index) +#define INSTR_LoadScopedLocal(op) INSTRUCTION(op, LoadScopedLocal, 2, scope, index) +#define INSTR_StoreScopedLocal(op) INSTRUCTION(op, StoreScopedLocal, 2, scope, index) +#define INSTR_LoadRuntimeString(op) INSTRUCTION(op, LoadRuntimeString, 1, stringId) +#define INSTR_MoveRegExp(op) INSTRUCTION(op, MoveRegExp, 2, regExpId, destReg) +#define INSTR_LoadClosure(op) INSTRUCTION(op, LoadClosure, 1, value) +#define INSTR_LoadName(op) INSTRUCTION(op, LoadName, 1, name) +#define INSTR_LoadGlobalLookup(op) INSTRUCTION(op, LoadGlobalLookup, 1, index) +#define INSTR_LoadQmlContextPropertyLookup(op) INSTRUCTION(op, LoadQmlContextPropertyLookup, 1, index) +#define INSTR_StoreNameSloppy(op) INSTRUCTION(op, StoreNameSloppy, 1, name) +#define INSTR_StoreNameStrict(op) INSTRUCTION(op, StoreNameStrict, 1, name) +#define INSTR_LoadProperty(op) INSTRUCTION(op, LoadProperty, 1, name) +#define INSTR_LoadOptionalProperty(op) INSTRUCTION(op, LoadOptionalProperty, 2, name, offset) +#define INSTR_GetLookup(op) INSTRUCTION(op, GetLookup, 1, index) +#define INSTR_GetOptionalLookup(op) INSTRUCTION(op, GetOptionalLookup, 2, index, offset) +#define INSTR_LoadIdObject(op) INSTRUCTION(op, LoadIdObject, 2, index, base) +#define INSTR_Yield(op) INSTRUCTION(op, Yield, 0) +#define INSTR_YieldStar(op) INSTRUCTION(op, YieldStar, 0) +#define INSTR_Resume(op) INSTRUCTION(op, Resume, 1, offset) +#define INSTR_IteratorNextForYieldStar(op) INSTRUCTION(op, IteratorNextForYieldStar, 3, iterator, object, offset) +#define INSTR_StoreProperty(op) INSTRUCTION(op, StoreProperty, 2, name, base) +#define INSTR_SetLookup(op) INSTRUCTION(op, SetLookup, 2, index, base) +#define INSTR_LoadSuperProperty(op) INSTRUCTION(op, LoadSuperProperty, 1, property) +#define INSTR_StoreSuperProperty(op) INSTRUCTION(op, StoreSuperProperty, 1, property) +#define INSTR_LoadElement(op) INSTRUCTION(op, LoadElement, 1, base) +#define INSTR_StoreElement(op) INSTRUCTION(op, StoreElement, 2, base, index) +#define INSTR_CallValue(op) INSTRUCTION(op, CallValue, 3, name, argc, argv) +#define INSTR_CallWithReceiver(op) INSTRUCTION(op, CallWithReceiver, 4, name, thisObject, argc, argv) +#define INSTR_CallProperty(op) INSTRUCTION(op, CallProperty, 4, name, base, argc, argv) +#define INSTR_CallPropertyLookup(op) INSTRUCTION(op, CallPropertyLookup, 4, lookupIndex, base, argc, argv) +#define INSTR_CallName(op) INSTRUCTION(op, CallName, 3, name, argc, argv) +#define INSTR_CallPossiblyDirectEval(op) INSTRUCTION(op, CallPossiblyDirectEval, 2, argc, argv) +#define INSTR_CallGlobalLookup(op) INSTRUCTION(op, CallGlobalLookup, 3, index, argc, argv) +#define INSTR_CallQmlContextPropertyLookup(op) INSTRUCTION(op, CallQmlContextPropertyLookup, 3, index, argc, argv) +#define INSTR_CallWithSpread(op) INSTRUCTION(op, CallWithSpread, 4, func, thisObject, argc, argv) +#define INSTR_Construct(op) INSTRUCTION(op, Construct, 3, func, argc, argv) +#define INSTR_ConstructWithSpread(op) INSTRUCTION(op, ConstructWithSpread, 3, func, argc, argv) +#define INSTR_SetUnwindHandler(op) INSTRUCTION(op, SetUnwindHandler, 1, offset) +#define INSTR_UnwindDispatch(op) INSTRUCTION(op, UnwindDispatch, 0) +#define INSTR_UnwindToLabel(op) INSTRUCTION(op, UnwindToLabel, 2, level, offset) +#define INSTR_DeadTemporalZoneCheck(op) INSTRUCTION(op, DeadTemporalZoneCheck, 1, name) +#define INSTR_ThrowException(op) INSTRUCTION(op, ThrowException, 0) +#define INSTR_GetException(op) INSTRUCTION(op, GetException, 0) +#define INSTR_SetException(op) INSTRUCTION(op, SetException, 0) +#define INSTR_CreateCallContext(op) INSTRUCTION(op, CreateCallContext, 0) +#define INSTR_PushCatchContext(op) INSTRUCTION(op, PushCatchContext, 2, index, name) +#define INSTR_PushWithContext(op) INSTRUCTION(op, PushWithContext, 0) +#define INSTR_PushBlockContext(op) INSTRUCTION(op, PushBlockContext, 1, index) +#define INSTR_CloneBlockContext(op) INSTRUCTION(op, CloneBlockContext, 0) +#define INSTR_PushScriptContext(op) INSTRUCTION(op, PushScriptContext, 1, index) +#define INSTR_PopScriptContext(op) INSTRUCTION(op, PopScriptContext, 0) +#define INSTR_PopContext(op) INSTRUCTION(op, PopContext, 0) +#define INSTR_GetIterator(op) INSTRUCTION(op, GetIterator, 1, iterator) +#define INSTR_IteratorNext(op) INSTRUCTION(op, IteratorNext, 2, value, offset) +#define INSTR_IteratorClose(op) INSTRUCTION(op, IteratorClose, 0) +#define INSTR_DestructureRestElement(op) INSTRUCTION(op, DestructureRestElement, 0) +#define INSTR_DeleteProperty(op) INSTRUCTION(op, DeleteProperty, 2, base, index) +#define INSTR_DeleteName(op) INSTRUCTION(op, DeleteName, 1, name) +#define INSTR_TypeofName(op) INSTRUCTION(op, TypeofName, 1, name) +#define INSTR_TypeofValue(op) INSTRUCTION(op, TypeofValue, 0) +#define INSTR_DeclareVar(op) INSTRUCTION(op, DeclareVar, 2, varName, isDeletable) +#define INSTR_DefineArray(op) INSTRUCTION(op, DefineArray, 2, argc, args) +#define INSTR_DefineObjectLiteral(op) INSTRUCTION(op, DefineObjectLiteral, 3, internalClassId, argc, args) +#define INSTR_CreateClass(op) INSTRUCTION(op, CreateClass, 3, classIndex, heritage, computedNames) +#define INSTR_CreateMappedArgumentsObject(op) INSTRUCTION(op, CreateMappedArgumentsObject, 0) +#define INSTR_CreateUnmappedArgumentsObject(op) INSTRUCTION(op, CreateUnmappedArgumentsObject, 0) +#define INSTR_CreateRestParameter(op) INSTRUCTION(op, CreateRestParameter, 1, argIndex) +#define INSTR_ConvertThisToObject(op) INSTRUCTION(op, ConvertThisToObject, 0) +#define INSTR_LoadSuperConstructor(op) INSTRUCTION(op, LoadSuperConstructor, 0) +#define INSTR_ToObject(op) INSTRUCTION(op, ToObject, 0) +#define INSTR_Jump(op) INSTRUCTION(op, Jump, 1, offset) +#define INSTR_JumpTrue(op) INSTRUCTION(op, JumpTrue, 1, offset) +#define INSTR_JumpFalse(op) INSTRUCTION(op, JumpFalse, 1, offset) +#define INSTR_JumpNotUndefined(op) INSTRUCTION(op, JumpNotUndefined, 1, offset) +#define INSTR_JumpNoException(op) INSTRUCTION(op, JumpNoException, 1, offset) +#define INSTR_CheckException(op) INSTRUCTION(op, CheckException, 0) +#define INSTR_CmpEqNull(op) INSTRUCTION(op, CmpEqNull, 0) +#define INSTR_CmpNeNull(op) INSTRUCTION(op, CmpNeNull, 0) +#define INSTR_CmpEqInt(op) INSTRUCTION(op, CmpEqInt, 1, lhs) +#define INSTR_CmpNeInt(op) INSTRUCTION(op, CmpNeInt, 1, lhs) +#define INSTR_CmpEq(op) INSTRUCTION(op, CmpEq, 1, lhs) +#define INSTR_CmpNe(op) INSTRUCTION(op, CmpNe, 1, lhs) +#define INSTR_CmpGt(op) INSTRUCTION(op, CmpGt, 1, lhs) +#define INSTR_CmpGe(op) INSTRUCTION(op, CmpGe, 1, lhs) +#define INSTR_CmpLt(op) INSTRUCTION(op, CmpLt, 1, lhs) +#define INSTR_CmpLe(op) INSTRUCTION(op, CmpLe, 1, lhs) +#define INSTR_CmpStrictEqual(op) INSTRUCTION(op, CmpStrictEqual, 1, lhs) +#define INSTR_CmpStrictNotEqual(op) INSTRUCTION(op, CmpStrictNotEqual, 1, lhs) +#define INSTR_CmpIn(op) INSTRUCTION(op, CmpIn, 1, lhs) +#define INSTR_CmpInstanceOf(op) INSTRUCTION(op, CmpInstanceOf, 1, lhs) +#define INSTR_UNot(op) INSTRUCTION(op, UNot, 0) +#define INSTR_UPlus(op) INSTRUCTION(op, UPlus, 0) +#define INSTR_UMinus(op) INSTRUCTION(op, UMinus, 0) +#define INSTR_UCompl(op) INSTRUCTION(op, UCompl, 0) +#define INSTR_Increment(op) INSTRUCTION(op, Increment, 0) +#define INSTR_Decrement(op) INSTRUCTION(op, Decrement, 0) +#define INSTR_Add(op) INSTRUCTION(op, Add, 1, lhs) +#define INSTR_BitAnd(op) INSTRUCTION(op, BitAnd, 1, lhs) +#define INSTR_BitOr(op) INSTRUCTION(op, BitOr, 1, lhs) +#define INSTR_BitXor(op) INSTRUCTION(op, BitXor, 1, lhs) +#define INSTR_UShr(op) INSTRUCTION(op, UShr, 1, lhs) +#define INSTR_Shr(op) INSTRUCTION(op, Shr, 1, lhs) +#define INSTR_Shl(op) INSTRUCTION(op, Shl, 1, lhs) +#define INSTR_BitAndConst(op) INSTRUCTION(op, BitAndConst, 1, rhs) +#define INSTR_BitOrConst(op) INSTRUCTION(op, BitOrConst, 1, rhs) +#define INSTR_BitXorConst(op) INSTRUCTION(op, BitXorConst, 1, rhs) +#define INSTR_UShrConst(op) INSTRUCTION(op, UShrConst, 1, rhs) +#define INSTR_ShrConst(op) INSTRUCTION(op, ShrConst, 1, rhs) +#define INSTR_ShlConst(op) INSTRUCTION(op, ShlConst, 1, rhs) +#define INSTR_Exp(op) INSTRUCTION(op, Exp, 1, lhs) +#define INSTR_Mul(op) INSTRUCTION(op, Mul, 1, lhs) +#define INSTR_Div(op) INSTRUCTION(op, Div, 1, lhs) +#define INSTR_Mod(op) INSTRUCTION(op, Mod, 1, lhs) +#define INSTR_Sub(op) INSTRUCTION(op, Sub, 1, lhs) +#define INSTR_As(op) INSTRUCTION(op, As, 1, lhs) +#define INSTR_LoadQmlImportedScripts(op) INSTRUCTION(op, LoadQmlImportedScripts, 1, result) +#define INSTR_InitializeBlockDeadTemporalZone(op) INSTRUCTION(op, InitializeBlockDeadTemporalZone, 2, firstReg, count) +#define INSTR_ThrowOnNullOrUndefined(op) INSTRUCTION(op, ThrowOnNullOrUndefined, 0) +#define INSTR_GetTemplateObject(op) INSTRUCTION(op, GetTemplateObject, 1, index) +#define INSTR_TailCall(op) INSTRUCTION(op, TailCall, 4, func, thisObject, argc, argv) + +#define FOR_EACH_MOTH_INSTR_ALL(F) \ + F(Nop) \ + FOR_EACH_MOTH_INSTR(F) + +#define FOR_EACH_MOTH_INSTR(F) \ + F(Ret) \ + F(LoadConst) \ + F(LoadZero) \ + F(LoadTrue) \ + F(LoadFalse) \ + F(LoadNull) \ + F(LoadUndefined) \ + F(LoadInt) \ + F(LoadRuntimeString) \ + F(MoveConst) \ + F(LoadReg) \ + F(StoreReg) \ + F(MoveReg) \ + F(LoadImport) \ + F(LoadLocal) \ + F(StoreLocal) \ + F(LoadScopedLocal) \ + F(StoreScopedLocal) \ + F(MoveRegExp) \ + F(LoadClosure) \ + F(LoadName) \ + F(LoadGlobalLookup) \ + F(LoadQmlContextPropertyLookup) \ + F(StoreNameSloppy) \ + F(StoreNameStrict) \ + F(LoadElement) \ + F(StoreElement) \ + F(LoadProperty) \ + F(LoadOptionalProperty) \ + F(GetLookup) \ + F(GetOptionalLookup) \ + F(StoreProperty) \ + F(SetLookup) \ + F(LoadSuperProperty) \ + F(StoreSuperProperty) \ + F(ConvertThisToObject) \ + F(ToObject) \ + F(Jump) \ + F(JumpTrue) \ + F(JumpFalse) \ + F(JumpNoException) \ + F(JumpNotUndefined) \ + F(CheckException) \ + F(CmpEqNull) \ + F(CmpNeNull) \ + F(CmpEqInt) \ + F(CmpNeInt) \ + F(CmpEq) \ + F(CmpNe) \ + F(CmpGt) \ + F(CmpGe) \ + F(CmpLt) \ + F(CmpLe) \ + F(CmpStrictEqual) \ + F(CmpStrictNotEqual) \ + F(CmpIn) \ + F(CmpInstanceOf) \ + F(UNot) \ + F(UPlus) \ + F(UMinus) \ + F(UCompl) \ + F(Increment) \ + F(Decrement) \ + F(Add) \ + F(BitAnd) \ + F(BitOr) \ + F(BitXor) \ + F(UShr) \ + F(Shr) \ + F(Shl) \ + F(BitAndConst) \ + F(BitOrConst) \ + F(BitXorConst) \ + F(UShrConst) \ + F(ShrConst) \ + F(ShlConst) \ + F(Exp) \ + F(Mul) \ + F(Div) \ + F(Mod) \ + F(Sub) \ + F(As) \ + F(CallValue) \ + F(CallWithReceiver) \ + F(CallProperty) \ + F(CallPropertyLookup) \ + F(CallName) \ + F(CallPossiblyDirectEval) \ + F(CallGlobalLookup) \ + F(CallQmlContextPropertyLookup) \ + F(CallWithSpread) \ + F(Construct) \ + F(ConstructWithSpread) \ + F(SetUnwindHandler) \ + F(UnwindDispatch) \ + F(UnwindToLabel) \ + F(DeadTemporalZoneCheck) \ + F(ThrowException) \ + F(GetException) \ + F(SetException) \ + F(CreateCallContext) \ + F(PushCatchContext) \ + F(PushWithContext) \ + F(PushBlockContext) \ + F(CloneBlockContext) \ + F(PopContext) \ + F(GetIterator) \ + F(IteratorNext) \ + F(IteratorClose) \ + F(DestructureRestElement) \ + F(DeleteProperty) \ + F(DeleteName) \ + F(TypeofName) \ + F(TypeofValue) \ + F(DeclareVar) \ + F(DefineArray) \ + F(DefineObjectLiteral) \ + F(CreateMappedArgumentsObject) \ + F(CreateUnmappedArgumentsObject) \ + F(CreateRestParameter) \ + F(Yield) \ + F(YieldStar) \ + F(Resume) \ + F(IteratorNextForYieldStar) \ + F(CreateClass) \ + F(LoadSuperConstructor) \ + F(PushScriptContext) \ + F(PopScriptContext) \ + F(InitializeBlockDeadTemporalZone) \ + F(ThrowOnNullOrUndefined) \ + F(GetTemplateObject) \ + F(TailCall) \ + F(Debug) \ + +#define MOTH_NUM_INSTRUCTIONS() (static_cast<int>(Moth::Instr::Type::Debug_Wide) + 1) + +#if defined(Q_CC_GNU) +#if defined(Q_OS_WASM) && !defined(__asmjs) +// Upstream llvm does not support computed goto for the wasm target, unlike the 'fastcomp' llvm fork +// shipped with the emscripten SDK. Disable computed goto usage for non-fastcomp llvm on Wasm. +#else +# define MOTH_COMPUTED_GOTO +#endif +#endif + +#define MOTH_INSTR_ALIGN_MASK (alignof(QV4::Moth::Instr) - 1) + +#define MOTH_INSTR_ENUM(I) I, I##_Wide, +#define MOTH_INSTR_SIZE(I) (sizeof(QV4::Moth::Instr::instr_##I)) + +#define MOTH_EXPAND_FOR_MSVC(x) x +#define MOTH_DEFINE_ARGS(nargs, ...) \ + MOTH_EXPAND_FOR_MSVC(MOTH_DEFINE_ARGS##nargs(__VA_ARGS__)) + +#define MOTH_DEFINE_ARGS0() +#define MOTH_DEFINE_ARGS1(arg) \ + int arg; +#define MOTH_DEFINE_ARGS2(arg1, arg2) \ + int arg1; \ + int arg2; +#define MOTH_DEFINE_ARGS3(arg1, arg2, arg3) \ + int arg1; \ + int arg2; \ + int arg3; +#define MOTH_DEFINE_ARGS4(arg1, arg2, arg3, arg4) \ + int arg1; \ + int arg2; \ + int arg3; \ + int arg4; +#define MOTH_DEFINE_ARGS5(arg1, arg2, arg3, arg4, arg5) \ + int arg1; \ + int arg2; \ + int arg3; \ + int arg4; \ + int arg5; + +#define MOTH_COLLECT_ENUMS(instr) \ + INSTR_##instr(MOTH_GET_ENUM) +#define MOTH_GET_ENUM_INSTRUCTION(name, ...) \ + name, + +#define MOTH_EMIT_STRUCTS(instr) \ + INSTR_##instr(MOTH_EMIT_STRUCT) +#define MOTH_EMIT_STRUCT_INSTRUCTION(name, nargs, ...) \ + struct instr_##name { \ + MOTH_DEFINE_ARGS(nargs, __VA_ARGS__) \ + }; + +#define MOTH_EMIT_INSTR_MEMBERS(instr) \ + INSTR_##instr(MOTH_EMIT_INSTR_MEMBER) +#define MOTH_EMIT_INSTR_MEMBER_INSTRUCTION(name, nargs, ...) \ + instr_##name name; + +#define MOTH_COLLECT_NARGS(instr) \ + INSTR_##instr(MOTH_COLLECT_ARG_COUNT) +#define MOTH_COLLECT_ARG_COUNT_INSTRUCTION(name, nargs, ...) \ + nargs, nargs, + +#define MOTH_DECODE_ARG(arg, type, nargs, offset) \ + arg = qFromLittleEndian<type>(qFromUnaligned<type>(reinterpret_cast<const type *>(code) - nargs + offset)); +#define MOTH_ADJUST_CODE(type, nargs) \ + code += static_cast<quintptr>(nargs*sizeof(type) + 1) + +#define MOTH_DECODE_INSTRUCTION(name, nargs, ...) \ + MOTH_DEFINE_ARGS(nargs, __VA_ARGS__) \ + op_int_##name: \ + MOTH_ADJUST_CODE(int, nargs); \ + MOTH_DECODE_ARGS(name, int, nargs, __VA_ARGS__) \ + goto op_main_##name; \ + op_byte_##name: \ + MOTH_ADJUST_CODE(qint8, nargs); \ + MOTH_DECODE_ARGS(name, qint8, nargs, __VA_ARGS__) \ + op_main_##name: \ + ; \ + +#define MOTH_DECODE_WITH_BASE_INSTRUCTION(name, nargs, ...) \ + MOTH_DEFINE_ARGS(nargs, __VA_ARGS__) \ + const char *base_ptr; \ + op_int_##name: \ + base_ptr = code; \ + MOTH_ADJUST_CODE(int, nargs); \ + MOTH_DECODE_ARGS(name, int, nargs, __VA_ARGS__) \ + goto op_main_##name; \ + op_byte_##name: \ + base_ptr = code; \ + MOTH_ADJUST_CODE(qint8, nargs); \ + MOTH_DECODE_ARGS(name, qint8, nargs, __VA_ARGS__) \ + op_main_##name: \ + ; \ + +#define MOTH_DECODE_ARGS(name, type, nargs, ...) \ + MOTH_EXPAND_FOR_MSVC(MOTH_DECODE_ARGS##nargs(name, type, nargs, __VA_ARGS__)) + +#define MOTH_DECODE_ARGS0(name, type, nargs, dummy) +#define MOTH_DECODE_ARGS1(name, type, nargs, arg) \ + MOTH_DECODE_ARG(arg, type, nargs, 0); +#define MOTH_DECODE_ARGS2(name, type, nargs, arg1, arg2) \ + MOTH_DECODE_ARGS1(name, type, nargs, arg1); \ + MOTH_DECODE_ARG(arg2, type, nargs, 1); +#define MOTH_DECODE_ARGS3(name, type, nargs, arg1, arg2, arg3) \ + MOTH_DECODE_ARGS2(name, type, nargs, arg1, arg2); \ + MOTH_DECODE_ARG(arg3, type, nargs, 2); +#define MOTH_DECODE_ARGS4(name, type, nargs, arg1, arg2, arg3, arg4) \ + MOTH_DECODE_ARGS3(name, type, nargs, arg1, arg2, arg3); \ + MOTH_DECODE_ARG(arg4, type, nargs, 3); +#define MOTH_DECODE_ARGS5(name, type, nargs, arg1, arg2, arg3, arg4, arg5) \ + MOTH_DECODE_ARGS4(name, type, nargs, arg1, arg2, arg3, arg4); \ + MOTH_DECODE_ARG(arg5, type, nargs, 4); + +#ifdef MOTH_COMPUTED_GOTO +/* collect jump labels */ +#define COLLECT_LABELS(instr) \ + INSTR_##instr(GET_LABEL) \ + INSTR_##instr(GET_LABEL_WIDE) +#define GET_LABEL_INSTRUCTION(name, ...) \ + &&op_byte_##name, +#define GET_LABEL_WIDE_INSTRUCTION(name, ...) \ + &&op_int_##name, + +#define MOTH_JUMP_TABLE \ + static const void *jumpTable[] = { \ + FOR_EACH_MOTH_INSTR_ALL(COLLECT_LABELS) \ + }; + +#define MOTH_DISPATCH_SINGLE() \ + goto *jumpTable[*reinterpret_cast<const uchar *>(code)]; + +#define MOTH_DISPATCH() \ + MOTH_DISPATCH_SINGLE() \ + op_byte_Nop: \ + ++code; \ + MOTH_DISPATCH_SINGLE() \ + op_int_Nop: /* wide prefix */ \ + ++code; \ + goto *jumpTable[0x100 | *reinterpret_cast<const uchar *>(code)]; +#else +#define MOTH_JUMP_TABLE + +#define MOTH_INSTR_CASE_AND_JUMP(instr) \ + INSTR_##instr(GET_CASE_AND_JUMP) \ + INSTR_##instr(GET_CASE_AND_JUMP_WIDE) +#define GET_CASE_AND_JUMP_INSTRUCTION(name, ...) \ + case Instr::Type::name: goto op_byte_##name; +#define GET_CASE_AND_JUMP_WIDE_INSTRUCTION(name, ...) \ + case Instr::Type::name##_Wide: goto op_int_##name; + +#define MOTH_DISPATCH() \ + Instr::Type type = Instr::Type(static_cast<uchar>(*code)); \ + dispatch: \ + switch (type) { \ + case Instr::Type::Nop: \ + ++code; \ + type = Instr::Type(static_cast<uchar>(*code)); \ + goto dispatch; \ + case Instr::Type::Nop_Wide: /* wide prefix */ \ + ++code; \ + type = Instr::Type(0x100 | static_cast<uchar>(*code)); \ + goto dispatch; \ + FOR_EACH_MOTH_INSTR(MOTH_INSTR_CASE_AND_JUMP) \ + } +#endif + +namespace QV4 { + +namespace CompiledData { +struct CodeOffsetToLineAndStatement; +} + +namespace Moth { + +class StackSlot { + int index; + +public: + static StackSlot createRegister(int index) { + Q_ASSERT(index >= 0); + StackSlot t; + t.index = index; + return t; + } + + int stackSlot() const { return index; } + operator int() const { return index; } +}; + +inline bool operator==(const StackSlot &l, const StackSlot &r) { return l.stackSlot() == r.stackSlot(); } +inline bool operator!=(const StackSlot &l, const StackSlot &r) { return l.stackSlot() != r.stackSlot(); } + +// When making changes to the instructions, make sure to bump QV4_DATA_STRUCTURE_VERSION in qv4compileddata_p.h + +Q_QML_EXPORT +QString dumpBytecode( + const char *bytecode, int len, int nLocals, int nFormals, int beginOffset, int endOffset, + const QVector<CompiledData::CodeOffsetToLineAndStatement> &lineAndStatementNumberMapping = + QVector<CompiledData::CodeOffsetToLineAndStatement>()); +QString dumpBytecode( + const char *bytecode, int len, int nLocals, int nFormals, int startLine = 1, + const QVector<CompiledData::CodeOffsetToLineAndStatement> &lineAndStatementNumberMapping = + QVector<CompiledData::CodeOffsetToLineAndStatement>()); +inline QString dumpBytecode( + const QByteArray &bytecode, int nLocals, int nFormals, int startLine = 1, + const QVector<CompiledData::CodeOffsetToLineAndStatement> &lineAndStatementNumberMapping = + QVector<CompiledData::CodeOffsetToLineAndStatement>()) +{ + return dumpBytecode(bytecode.constData(), bytecode.size(), nLocals, nFormals, startLine, + lineAndStatementNumberMapping); +} + +union Instr +{ + enum class Type { + FOR_EACH_MOTH_INSTR_ALL(MOTH_INSTR_ENUM) + }; + + static Type wideInstructionType(Type t) { return Type(int(t) | 1); } + static Type narrowInstructionType(Type t) { return Type(int(t) & ~1); } + static bool isWide(Type t) { return int(t) & 1; } + static bool isNarrow(Type t) { return !(int(t) & 1); } + static int encodedLength(Type t) { return int(t) >= 256 ? 2 : 1; } + + static Type unpack(const uchar *c) { if (c[0] == 0x1) return Type(0x100 + c[1]); return Type(c[0]); } + static uchar *pack(uchar *c, Type t) { + if (uint(t) >= 256) { + c[0] = 0x1; + c[1] = uint(t) &0xff; + return c + 2; + } + c[0] = uchar(uint(t)); + return c + 1; + } + + FOR_EACH_MOTH_INSTR_ALL(MOTH_EMIT_STRUCTS) + + FOR_EACH_MOTH_INSTR_ALL(MOTH_EMIT_INSTR_MEMBERS) + + int argumentsAsInts[4]; +}; + +struct InstrInfo +{ + static const int argumentCount[]; + static int size(Instr::Type type); +}; + +template<int N> +struct InstrMeta { +}; + +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Wuninitialized") +QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") +#define MOTH_INSTR_META_TEMPLATE(I) \ + template<> struct InstrMeta<int(Instr::Type::I)> { \ + enum { Size = MOTH_INSTR_SIZE(I) }; \ + typedef Instr::instr_##I DataType; \ + static const DataType &data(const Instr &instr) { return instr.I; } \ + static void setData(Instr &instr, const DataType &v) \ + { memcpy(reinterpret_cast<char *>(&instr.I), \ + reinterpret_cast<const char *>(&v), \ + Size); } \ + }; +FOR_EACH_MOTH_INSTR_ALL(MOTH_INSTR_META_TEMPLATE); +#undef MOTH_INSTR_META_TEMPLATE +QT_WARNING_POP + +template<int InstrType> +class InstrData : public InstrMeta<InstrType>::DataType +{ +}; + +struct Instruction { +#define MOTH_INSTR_DATA_TYPEDEF(I) typedef InstrData<int(Instr::Type::I)> I; +FOR_EACH_MOTH_INSTR_ALL(MOTH_INSTR_DATA_TYPEDEF) +#undef MOTH_INSTR_DATA_TYPEDEF +private: + Instruction(); +}; + +} // namespace Moth +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4INSTR_MOTH_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4internalclass_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4internalclass_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e481b764a2bedff6493749b21b106358603acebf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4internalclass_p.h @@ -0,0 +1,497 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4INTERNALCLASS_H +#define QV4INTERNALCLASS_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" + +#include <QHash> +#include <QVarLengthArray> +#include <climits> // for UINT_MAX +#include <private/qv4propertykey_p.h> +#include <private/qv4heap_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct VTable; +struct MarkStack; + +struct InternalClassEntry { + uint index; + uint setterIndex; + PropertyAttributes attributes; + bool isValid() const { return !attributes.isEmpty(); } +}; + +struct PropertyHashData; +struct PropertyHash +{ + struct Entry { + PropertyKey identifier; + uint index; + uint setterIndex; + }; + + PropertyHashData *d; + + inline PropertyHash(); + inline PropertyHash(const PropertyHash &other); + inline ~PropertyHash(); + PropertyHash &operator=(const PropertyHash &other); + + void addEntry(const Entry &entry, int classSize); + Entry *lookup(PropertyKey identifier) const; + void detach(bool grow, int classSize); +}; + +struct PropertyHashData +{ + PropertyHashData(int numBits); + ~PropertyHashData() { + free(entries); + } + + int refCount; + int alloc; + int size; + int numBits; + PropertyHash::Entry *entries; +}; + +inline PropertyHash::PropertyHash() +{ + d = new PropertyHashData(3); +} + +inline PropertyHash::PropertyHash(const PropertyHash &other) +{ + d = other.d; + ++d->refCount; +} + +inline PropertyHash::~PropertyHash() +{ + if (!--d->refCount) + delete d; +} + +inline PropertyHash &PropertyHash::operator=(const PropertyHash &other) +{ + ++other.d->refCount; + if (!--d->refCount) + delete d; + d = other.d; + return *this; +} + + + +inline PropertyHash::Entry *PropertyHash::lookup(PropertyKey identifier) const +{ + Q_ASSERT(d->entries); + + uint idx = identifier.id() % d->alloc; + while (1) { + if (d->entries[idx].identifier == identifier) + return d->entries + idx; + if (!d->entries[idx].identifier.isValid()) + return nullptr; + ++idx; + idx %= d->alloc; + } +} + +template<class T> +struct SharedInternalClassDataPrivate {}; + +template<> +struct SharedInternalClassDataPrivate<PropertyAttributes> { + SharedInternalClassDataPrivate(ExecutionEngine *engine) + : refcount(1), + m_alloc(0), + m_size(0), + m_data(nullptr), + m_engine(engine) + { } + SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate<PropertyAttributes> &other); + SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate<PropertyAttributes> &other, + uint pos, PropertyAttributes value); + ~SharedInternalClassDataPrivate(); + + void grow(); + + void markIfNecessary(const PropertyAttributes &) {} + + uint alloc() const { return m_alloc; } + uint size() const { return m_size; } + void setSize(uint s) { m_size = s; } + + PropertyAttributes at(uint i) const { Q_ASSERT(i < m_alloc); return data(i); } + void set(uint i, PropertyAttributes t) { Q_ASSERT(i < m_alloc); setData(i, t); } + + void mark(MarkStack *) {} + + int refcount = 1; +private: + uint m_alloc; + uint m_size; + + enum { + SizeOfAttributesPointer = sizeof(PropertyAttributes *), + SizeOfAttributes = sizeof(PropertyAttributes), + NumAttributesInPointer = SizeOfAttributesPointer / SizeOfAttributes, + }; + + static_assert(NumAttributesInPointer > 0); + + PropertyAttributes data(uint i) const { + return m_alloc > NumAttributesInPointer ? m_data[i] : m_inlineData[i]; + } + + void setData(uint i, PropertyAttributes t) { + if (m_alloc > NumAttributesInPointer) + m_data[i] = t; + else + m_inlineData[i] = t; + } + + union { + PropertyAttributes *m_data; + PropertyAttributes m_inlineData[NumAttributesInPointer]; + }; + ExecutionEngine *m_engine; +}; + +template<> +struct SharedInternalClassDataPrivate<PropertyKey> { + SharedInternalClassDataPrivate(ExecutionEngine *e) : refcount(1), engine(e) {} + SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate &other); + SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate &other, uint pos, PropertyKey value); + ~SharedInternalClassDataPrivate() {} + + template<typename StringOrSymbol = Heap::StringOrSymbol> + void markIfNecessary(const PropertyKey &value); + + void grow(); + uint alloc() const; + uint size() const; + void setSize(uint s); + + PropertyKey at(uint i) const; + void set(uint i, PropertyKey t); + + void mark(MarkStack *s); + + int refcount = 1; +private: + ExecutionEngine *engine; + WriteBarrier::Pointer<Heap::MemberData> data; +}; + +template<typename StringOrSymbol> +void QV4::SharedInternalClassDataPrivate<PropertyKey>::markIfNecessary(const PropertyKey &value) +{ + QV4::WriteBarrier::markCustom(engine, [&](QV4::MarkStack *stack) { + if constexpr (QV4::WriteBarrier::isInsertionBarrier) { + if (auto s = value.asStringOrSymbol<StringOrSymbol>()) + s->mark(stack); + } + }); +} + +template <typename T> +struct SharedInternalClassData { + using Private = SharedInternalClassDataPrivate<T>; + Private *d; + + inline SharedInternalClassData(ExecutionEngine *e) { + d = new Private(e); + } + + inline SharedInternalClassData(const SharedInternalClassData &other) + : d(other.d) + { + ++d->refcount; + } + inline ~SharedInternalClassData() { + if (!--d->refcount) + delete d; + } + SharedInternalClassData &operator=(const SharedInternalClassData &other) { + ++other.d->refcount; + if (!--d->refcount) + delete d; + d = other.d; + return *this; + } + + void add(uint pos, T value) { + d->markIfNecessary(value); + if (pos < d->size()) { + Q_ASSERT(d->refcount > 1); + // need to detach + Private *dd = new Private(*d, pos, value); + --d->refcount; + d = dd; + return; + } + Q_ASSERT(pos == d->size()); + if (pos == d->alloc()) + d->grow(); + if (pos >= d->alloc()) { + qBadAlloc(); + } else { + d->setSize(d->size() + 1); + d->set(pos, value); + } + } + + void set(uint pos, T value) { + Q_ASSERT(pos < d->size()); + d->markIfNecessary(value); + if (d->refcount > 1) { + // need to detach + Private *dd = new Private(*d); + --d->refcount; + d = dd; + } + d->set(pos, value); + } + + T at(uint i) const { + Q_ASSERT(i < d->size()); + return d->at(i); + } + T operator[] (uint i) { + Q_ASSERT(i < d->size()); + return d->at(i); + } + + void mark(MarkStack *s) { d->mark(s); } +}; + +struct InternalClassTransition +{ + union { + PropertyKey id; + const VTable *vtable; + Heap::Object *prototype; + }; + Heap::InternalClass *lookup; + int flags; + enum { + // range 0-0xff is reserved for attribute changes + StructureChange = 0x100, + NotExtensible = StructureChange | (1 << 0), + VTableChange = StructureChange | (1 << 1), + PrototypeChange = StructureChange | (1 << 2), + ProtoClass = StructureChange | (1 << 3), + Sealed = StructureChange | (1 << 4), + Frozen = StructureChange | (1 << 5), + Locked = StructureChange | (1 << 6), + }; + + bool operator==(const InternalClassTransition &other) const + { return id == other.id && flags == other.flags; } + + bool operator<(const InternalClassTransition &other) const + { return flags < other.flags || (flags == other.flags && id < other.id); } +}; + +namespace Heap { + +struct InternalClass : Base { + enum Flag { + NotExtensible = 1 << 0, + Sealed = 1 << 1, + Frozen = 1 << 2, + UsedAsProto = 1 << 3, + Locked = 1 << 4, + }; + enum { MaxRedundantTransitions = 255 }; + + ExecutionEngine *engine; + const VTable *vtable; + quintptr protoId; // unique across the engine, gets changed whenever the proto chain changes + Heap::Object *prototype; + InternalClass *parent; + + PropertyHash propertyTable; // id to valueIndex + SharedInternalClassData<PropertyKey> nameMap; + SharedInternalClassData<PropertyAttributes> propertyData; + + typedef InternalClassTransition Transition; + QVarLengthArray<Transition, 1> transitions; + InternalClassTransition &lookupOrInsertTransition(const InternalClassTransition &t); + + uint size; + quint8 numRedundantTransitions; + quint8 flags; + + bool isExtensible() const { return !(flags & NotExtensible); } + bool isSealed() const { return flags & Sealed; } + bool isFrozen() const { return flags & Frozen; } + bool isUsedAsProto() const { return flags & UsedAsProto; } + bool isLocked() const { return flags & Locked; } + + void init(ExecutionEngine *engine); + void init(InternalClass *other); + void destroy(); + + Q_QML_EXPORT ReturnedValue keyAt(uint index) const; + Q_REQUIRED_RESULT InternalClass *nonExtensible(); + Q_REQUIRED_RESULT InternalClass *locked(); + + static void addMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, InternalClassEntry *entry); + Q_REQUIRED_RESULT InternalClass *addMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry = nullptr); + Q_REQUIRED_RESULT InternalClass *changeMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry = nullptr); + static void changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, InternalClassEntry *entry = nullptr); + static void removeMember(QV4::Object *object, PropertyKey identifier); + PropertyHash::Entry *findEntry(const PropertyKey id) + { + Q_ASSERT(id.isStringOrSymbol()); + + PropertyHash::Entry *e = propertyTable.lookup(id); + if (e && e->index < size) + return e; + + return nullptr; + } + + InternalClassEntry find(const PropertyKey id) + { + Q_ASSERT(id.isStringOrSymbol()); + + PropertyHash::Entry *e = propertyTable.lookup(id); + if (e && e->index < size) { + PropertyAttributes a = propertyData.at(e->index); + if (!a.isEmpty()) + return { e->index, e->setterIndex, a }; + } + + return { UINT_MAX, UINT_MAX, Attr_Invalid }; + } + + struct IndexAndAttribute { + uint index; + PropertyAttributes attrs; + bool isValid() const { return index != UINT_MAX; } + }; + + IndexAndAttribute findValueOrGetter(const PropertyKey id) + { + Q_ASSERT(id.isStringOrSymbol()); + + PropertyHash::Entry *e = propertyTable.lookup(id); + if (e && e->index < size) { + PropertyAttributes a = propertyData.at(e->index); + if (!a.isEmpty()) + return { e->index, a }; + } + + return { UINT_MAX, Attr_Invalid }; + } + + IndexAndAttribute findValueOrSetter(const PropertyKey id) + { + Q_ASSERT(id.isStringOrSymbol()); + + PropertyHash::Entry *e = propertyTable.lookup(id); + if (e && e->index < size) { + PropertyAttributes a = propertyData.at(e->index); + if (!a.isEmpty()) { + if (a.isAccessor()) { + Q_ASSERT(e->setterIndex != UINT_MAX); + return { e->setterIndex, a }; + } + return { e->index, a }; + } + } + + return { UINT_MAX, Attr_Invalid }; + } + + uint indexOfValueOrGetter(const PropertyKey id) + { + Q_ASSERT(id.isStringOrSymbol()); + + PropertyHash::Entry *e = propertyTable.lookup(id); + if (e && e->index < size) { + Q_ASSERT(!propertyData.at(e->index).isEmpty()); + return e->index; + } + + return UINT_MAX; + } + + bool verifyIndex(const PropertyKey id, uint index) + { + Q_ASSERT(id.isStringOrSymbol()); + + PropertyHash::Entry *e = propertyTable.lookup(id); + if (e && e->index < size) { + Q_ASSERT(!propertyData.at(e->index).isEmpty()); + return e->index == index; + } + + return false; + } + + Q_REQUIRED_RESULT InternalClass *sealed(); + Q_REQUIRED_RESULT InternalClass *frozen(); + Q_REQUIRED_RESULT InternalClass *canned(); // sealed + nonExtensible + Q_REQUIRED_RESULT InternalClass *cryopreserved(); // frozen + sealed + nonExtensible + bool isImplicitlyFrozen() const; + + Q_REQUIRED_RESULT InternalClass *asProtoClass(); + + Q_REQUIRED_RESULT InternalClass *changeVTable(const VTable *vt) { + if (vtable == vt) + return this; + return changeVTableImpl(vt); + } + Q_REQUIRED_RESULT InternalClass *changePrototype(Heap::Object *proto) { + if (prototype == proto) + return this; + return changePrototypeImpl(proto); + } + + void updateProtoUsage(Heap::Object *o); + + static void markObjects(Heap::Base *ic, MarkStack *stack); + +private: + Q_QML_EXPORT InternalClass *changeVTableImpl(const VTable *vt); + Q_QML_EXPORT InternalClass *changePrototypeImpl(Heap::Object *proto); + InternalClass *addMemberImpl(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry); + + void removeChildEntry(InternalClass *child); + friend struct ::QV4::ExecutionEngine; +}; + +inline +void Base::markObjects(Base *b, MarkStack *stack) +{ + b->internalClass->mark(stack); +} + +} + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4iterator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4iterator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..da8db7bfe6490688b1262f15a77d34c39639c4fa --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4iterator_p.h @@ -0,0 +1,45 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4ITERATOR_P_H +#define QV4ITERATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" + +QT_BEGIN_NAMESPACE + + +namespace QV4 { + +enum IteratorKind { + KeyIteratorKind, + ValueIteratorKind, + KeyValueIteratorKind +}; + +struct IteratorPrototype : Object +{ + void init(ExecutionEngine *engine); + + static ReturnedValue method_iterator(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue createIterResultObject(ExecutionEngine *engine, const Value &value, bool done); +}; + +} + +QT_END_NAMESPACE + +#endif // QV4ARRAYITERATOR_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4jscall_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4jscall_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6d60e302ddf2fd2d04ef8117fbff7a5aaba2cd74 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4jscall_p.h @@ -0,0 +1,587 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4JSCALL_H +#define QV4JSCALL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmllistwrapper_p.h> +#include <private/qqmlvaluetypewrapper_p.h> + +#include <private/qv4alloca_p.h> +#include <private/qv4dateobject_p.h> +#include <private/qv4function_p.h> +#include <private/qv4functionobject_p.h> +#include <private/qv4qobjectwrapper_p.h> +#include <private/qv4regexpobject_p.h> +#include <private/qv4scopedvalue_p.h> +#include <private/qv4sequenceobject_p.h> +#include <private/qv4urlobject_p.h> +#include <private/qv4variantobject_p.h> + +#if QT_CONFIG(regularexpression) +#include <QtCore/qregularexpression.h> +#endif + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +template<typename Args> +CallData *callDatafromJS(const Scope &scope, const Args *args, const FunctionObject *f = nullptr) +{ + int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + args->argc; + CallData *ptr = reinterpret_cast<CallData *>(scope.alloc<Scope::Uninitialized>(size)); + ptr->function = Encode::undefined(); + ptr->context = Encode::undefined(); + ptr->accumulator = Encode::undefined(); + ptr->thisObject = args->thisObject ? args->thisObject->asReturnedValue() : Encode::undefined(); + ptr->newTarget = Encode::undefined(); + ptr->setArgc(args->argc); + if (args->argc) + memcpy(ptr->args, args->args, args->argc*sizeof(Value)); + if (f) + ptr->function = f->asReturnedValue(); + return ptr; +} + +struct JSCallArguments +{ + JSCallArguments(const Scope &scope, int argc = 0) + : thisObject(scope.alloc()), args(scope.alloc(argc)), argc(argc) + { + } + + CallData *callData(const Scope &scope, const FunctionObject *f = nullptr) const + { + return callDatafromJS(scope, this, f); + } + + Value *thisObject; + Value *args; + const int argc; +}; + +struct JSCallData +{ + JSCallData(const Value *thisObject, const Value *argv, int argc) + : thisObject(thisObject), args(argv), argc(argc) + { + } + + Q_IMPLICIT JSCallData(const JSCallArguments &args) + : thisObject(args.thisObject), args(args.args), argc(args.argc) + { + } + + CallData *callData(const Scope &scope, const FunctionObject *f = nullptr) const + { + return callDatafromJS(scope, this, f); + } + + const Value *thisObject; + const Value *args; + const int argc; +}; + +inline +ReturnedValue FunctionObject::callAsConstructor(const JSCallData &data) const +{ + return callAsConstructor(data.args, data.argc, this); +} + +inline +ReturnedValue FunctionObject::call(const JSCallData &data) const +{ + return call(data.thisObject, data.args, data.argc); +} + +void populateJSCallArguments(ExecutionEngine *v4, JSCallArguments &jsCall, int argc, + void **args, const QMetaType *types); + +template<typename Callable> +ReturnedValue convertAndCall( + ExecutionEngine *engine, const Function::AOTCompiledFunction *aotFunction, + const Value *thisObject, const Value *argv, int argc, Callable call) +{ + const qsizetype numFunctionArguments = aotFunction->types.length() - 1; + Q_ALLOCA_VAR(void *, values, (numFunctionArguments + 1) * sizeof(void *)); + Q_ALLOCA_VAR(QMetaType, types, (numFunctionArguments + 1) * sizeof(QMetaType)); + + for (qsizetype i = 0; i < numFunctionArguments; ++i) { + const QMetaType argumentType = aotFunction->types[i + 1]; + types[i + 1] = argumentType; + if (const qsizetype argumentSize = argumentType.sizeOf()) { + Q_ALLOCA_VAR(void, argument, argumentSize); + if (argumentType.flags() & QMetaType::NeedsConstruction) { + argumentType.construct(argument); + if (i < argc) + ExecutionEngine::metaTypeFromJS(argv[i], argumentType, argument); + } else if (i >= argc + || !ExecutionEngine::metaTypeFromJS(argv[i], argumentType, argument)) { + // If we can't convert the argument, we need to default-construct it even if it + // doesn't formally need construction. + // E.g. an int doesn't need construction, but we still want it to be 0. + argumentType.construct(argument); + } + + values[i + 1] = argument; + } else { + values[i + 1] = nullptr; + } + } + + Q_ALLOCA_DECLARE(void, returnValue); + types[0] = aotFunction->types[0]; + if (const qsizetype returnSize = types[0].sizeOf()) { + Q_ALLOCA_ASSIGN(void, returnValue, returnSize); + values[0] = returnValue; + if (types[0].flags() & QMetaType::NeedsConstruction) + types[0].construct(returnValue); + } else { + values[0] = nullptr; + } + + if (const QV4::QObjectWrapper *cppThisObject = thisObject + ? thisObject->as<QV4::QObjectWrapper>() + : nullptr) { + call(cppThisObject->object(), values, types, argc); + } else { + call(nullptr, values, types, argc); + } + + ReturnedValue result; + if (values[0]) { + result = engine->metaTypeToJS(types[0], values[0]); + if (types[0].flags() & QMetaType::NeedsDestruction) + types[0].destruct(values[0]); + } else { + result = Encode::undefined(); + } + + for (qsizetype i = 1, end = numFunctionArguments + 1; i < end; ++i) { + if (types[i].flags() & QMetaType::NeedsDestruction) + types[i].destruct(values[i]); + } + + return result; +} + +template<typename Callable> +bool convertAndCall(ExecutionEngine *engine, QObject *thisObject, + void **a, const QMetaType *types, int argc, Callable call) +{ + Scope scope(engine); + QV4::JSCallArguments jsCallData(scope, argc); + + for (int ii = 0; ii < argc; ++ii) + jsCallData.args[ii] = engine->metaTypeToJS(types[ii + 1], a[ii + 1]); + + ScopedObject jsThisObject(scope); + if (thisObject) { + // The result of wrap() can only be null, undefined, or an object. + jsThisObject = QV4::QObjectWrapper::wrap(engine, thisObject); + if (!jsThisObject) + jsThisObject = engine->globalObject; + } else { + jsThisObject = engine->globalObject; + } + + ScopedValue jsResult(scope, call(jsThisObject, jsCallData.args, argc)); + void *result = a[0]; + if (!result) + return !jsResult->isUndefined(); + + const QMetaType resultType = types[0]; + if (scope.hasException()) { + // Clear the return value + resultType.destruct(result); + resultType.construct(result); + } else if (resultType == QMetaType::fromType<QVariant>()) { + // When the return type is QVariant, JS objects are to be returned as + // QJSValue wrapped in QVariant. metaTypeFromJS unwraps them, unfortunately. + *static_cast<QVariant *>(result) = ExecutionEngine::toVariant(jsResult, QMetaType {}); + } else if (!ExecutionEngine::metaTypeFromJS(jsResult, resultType, result)) { + // If we cannot convert, also clear the return value. + // The caller may have given us an uninitialized QObject*, expecting it to be overwritten. + resultType.destruct(result); + resultType.construct(result); + } + return !jsResult->isUndefined(); +} + +inline ReturnedValue coerce( + ExecutionEngine *engine, const Value &value, const QQmlType &qmlType, bool isList); + +inline QObject *coerceQObject(const Value &value, const QQmlType &qmlType) +{ + QObject *o; + if (const QV4::QObjectWrapper *wrapper = value.as<QV4::QObjectWrapper>()) + o = wrapper->object(); + else if (const QV4::QQmlTypeWrapper *wrapper = value.as<QQmlTypeWrapper>()) + o = wrapper->object(); + else + return nullptr; + + return (o && qmlobject_can_qml_cast(o, qmlType)) ? o : nullptr; +} + +enum CoercionProblem +{ + InsufficientAnnotation, + InvalidListType +}; + +Q_QML_EXPORT void warnAboutCoercionToVoid( + ExecutionEngine *engine, const Value &value, CoercionProblem problem); + +inline ReturnedValue coerceListType( + ExecutionEngine *engine, const Value &value, const QQmlType &qmlType) +{ + QMetaType type = qmlType.qListTypeId(); + const auto metaSequence = [&]() { + // TODO: We should really add the metasequence to the same QQmlType that holds + // all the other type information. Then we can get rid of the extra + // QQmlMetaType::qmlListType() here. + return qmlType.isSequentialContainer() + ? qmlType.listMetaSequence() + : QQmlMetaType::qmlListType(type).listMetaSequence(); + }; + + if (const QV4::Sequence *sequence = value.as<QV4::Sequence>()) { + if (sequence->d()->listType() == type) + return value.asReturnedValue(); + } + + if (const QmlListWrapper *list = value.as<QmlListWrapper>()) { + if (list->d()->propertyType() == type) + return value.asReturnedValue(); + } + + QMetaType listValueType = qmlType.typeId(); + if (!listValueType.isValid()) { + warnAboutCoercionToVoid(engine, value, InvalidListType); + return value.asReturnedValue(); + } + + QV4::Scope scope(engine); + + const ArrayObject *array = value.as<ArrayObject>(); + if (!array) { + return (listValueType.flags() & QMetaType::PointerToQObject) + ? QmlListWrapper::create(engine, listValueType) + : SequencePrototype::fromData(engine, type, metaSequence(), nullptr); + } + + if (listValueType.flags() & QMetaType::PointerToQObject) { + QV4::Scoped<QmlListWrapper> newList(scope, QmlListWrapper::create(engine, type)); + QQmlListProperty<QObject> *listProperty = newList->d()->property(); + + const qsizetype length = array->getLength(); + qsizetype i = 0; + for (; i < length; ++i) { + ScopedValue v(scope, array->get(i)); + listProperty->append(listProperty, coerceQObject(v, qmlType)); + } + + return newList->asReturnedValue(); + } + + QV4::Scoped<Sequence> sequence( + scope, SequencePrototype::fromData(engine, type, metaSequence(), nullptr)); + const qsizetype length = array->getLength(); + for (qsizetype i = 0; i < length; ++i) + sequence->containerPutIndexed(i, array->get(i)); + return sequence->asReturnedValue(); +} + +inline ReturnedValue coerce( + ExecutionEngine *engine, const Value &value, const QQmlType &qmlType, bool isList) +{ + // These are all the named non-list, non-QObject builtins. Only those need special handling. + // Some of them may be wrapped in VariantObject because that is how they are stored in VME + // properties. + if (isList) + return coerceListType(engine, value, qmlType); + + const QMetaType metaType = qmlType.typeId(); + if (!metaType.isValid()) { + if (!value.isUndefined()) + warnAboutCoercionToVoid(engine, value, InsufficientAnnotation); + return value.asReturnedValue(); + } + + switch (metaType.id()) { + case QMetaType::Void: + return Encode::undefined(); + case QMetaType::QVariant: + return value.asReturnedValue(); + case QMetaType::Int: + return Encode(value.toInt32()); + case QMetaType::Double: + return value.convertedToNumber(); + case QMetaType::QString: + return value.toString(engine)->asReturnedValue(); + case QMetaType::Bool: + return Encode(value.toBoolean()); + case QMetaType::QDateTime: + if (value.as<DateObject>()) + return value.asReturnedValue(); + if (const VariantObject *varObject = value.as<VariantObject>()) { + const QVariant &var = varObject->d()->data(); + switch (var.metaType().id()) { + case QMetaType::QDateTime: + return engine->newDateObject(var.value<QDateTime>())->asReturnedValue(); + case QMetaType::QTime: + return engine->newDateObject(var.value<QTime>(), nullptr, -1, 0)->asReturnedValue(); + case QMetaType::QDate: + return engine->newDateObject(var.value<QDate>(), nullptr, -1, 0)->asReturnedValue(); + default: + break; + } + } + return engine->newDateObject(QDateTime())->asReturnedValue(); + case QMetaType::QUrl: + if (value.as<UrlObject>()) + return value.asReturnedValue(); + if (const VariantObject *varObject = value.as<VariantObject>()) { + const QVariant &var = varObject->d()->data(); + return var.metaType() == QMetaType::fromType<QUrl>() + ? engine->newUrlObject(var.value<QUrl>())->asReturnedValue() + : engine->newUrlObject()->asReturnedValue(); + } + // Since URL properties are stored as string, we need to support the string conversion here. + if (const String *string = value.stringValue()) + return engine->newUrlObject(QUrl(string->toQString()))->asReturnedValue(); + return engine->newUrlObject()->asReturnedValue(); +#if QT_CONFIG(regularexpression) + case QMetaType::QRegularExpression: + if (value.as<RegExpObject>()) + return value.asReturnedValue(); + if (const VariantObject *varObject = value.as<VariantObject>()) { + const QVariant &var = varObject->d()->data(); + if (var.metaType() == QMetaType::fromType<QRegularExpression>()) + return engine->newRegExpObject(var.value<QRegularExpression>())->asReturnedValue(); + } + return engine->newRegExpObject(QString(), 0)->asReturnedValue(); +#endif + default: + break; + } + + if (metaType.flags() & QMetaType::PointerToQObject) { + return coerceQObject(value, qmlType) + ? value.asReturnedValue() + : Encode::null(); + } + + if (const QQmlValueTypeWrapper *wrapper = value.as<QQmlValueTypeWrapper>()) { + if (wrapper->type() == metaType) + return value.asReturnedValue(); + } + + if (void *target = QQmlValueTypeProvider::heapCreateValueType(qmlType, value, engine)) { + Heap::QQmlValueTypeWrapper *wrapper = engine->memoryManager->allocate<QQmlValueTypeWrapper>( + nullptr, metaType, qmlType.metaObjectForValueType(), + nullptr, -1, Heap::ReferenceObject::NoFlag); + Q_ASSERT(!wrapper->gadgetPtr()); + wrapper->setGadgetPtr(target); + return wrapper->asReturnedValue(); + } + + return Encode::undefined(); +} + +template<typename Callable> +ReturnedValue coerceAndCall( + ExecutionEngine *engine, + const Function::JSTypedFunction *typedFunction, const CompiledData::Function *compiledFunction, + const Value *argv, int argc, Callable call) +{ + Scope scope(engine); + + QV4::JSCallArguments jsCallData(scope, typedFunction->types.size() - 1); + const CompiledData::Parameter *formals = compiledFunction->formalsTable(); + for (qsizetype i = 0; i < jsCallData.argc; ++i) { + jsCallData.args[i] = coerce( + engine, i < argc ? argv[i] : Encode::undefined(), + typedFunction->types[i + 1], formals[i].type.isList()); + } + + ScopedValue result(scope, call(jsCallData.args, jsCallData.argc)); + return coerce(engine, result, typedFunction->types[0], compiledFunction->returnType.isList()); +} + +// Note: \a to is unininitialized here! This is in contrast to most other related functions. +inline void coerce( + ExecutionEngine *engine, QMetaType fromType, const void *from, QMetaType toType, void *to) +{ + if ((fromType.flags() & QMetaType::PointerToQObject) + && (toType.flags() & QMetaType::PointerToQObject)) { + QObject *fromObj = *static_cast<QObject * const*>(from); + *static_cast<QObject **>(to) + = (fromObj && fromObj->metaObject()->inherits(toType.metaObject())) + ? fromObj + : nullptr; + return; + } + + if (toType == QMetaType::fromType<QVariant>()) { + new (to) QVariant(fromType, from); + return; + } + + if (toType == QMetaType::fromType<QJSPrimitiveValue>()) { + new (to) QJSPrimitiveValue(fromType, from); + return; + } + + if (fromType == QMetaType::fromType<QVariant>()) { + const QVariant *fromVariant = static_cast<const QVariant *>(from); + if (fromVariant->metaType() == toType) + toType.construct(to, fromVariant->data()); + else + coerce(engine, fromVariant->metaType(), fromVariant->data(), toType, to); + return; + } + + if (fromType == QMetaType::fromType<QJSPrimitiveValue>()) { + const QJSPrimitiveValue *fromPrimitive = static_cast<const QJSPrimitiveValue *>(from); + if (fromPrimitive->metaType() == toType) + toType.construct(to, fromPrimitive->data()); + else + coerce(engine, fromPrimitive->metaType(), fromPrimitive->data(), toType, to); + return; + } + + // TODO: This is expensive. We might establish a direct C++-to-C++ type coercion, like we have + // for JS-to-JS. However, we shouldn't need this very often. Most of the time the compiler + // will generate code that passes the right arguments. + if (toType.flags() & QMetaType::NeedsConstruction) + toType.construct(to); + QV4::Scope scope(engine); + QV4::ScopedValue value(scope, engine->fromData(fromType, from)); + if (!ExecutionEngine::metaTypeFromJS(value, toType, to)) + QMetaType::convert(fromType, from, toType, to); +} + +template<typename TypedFunction, typename Callable> +void coerceAndCall( + ExecutionEngine *engine, const TypedFunction *typedFunction, + void **argv, const QMetaType *types, int argc, Callable call) +{ + const qsizetype numFunctionArguments = typedFunction->parameterCount(); + + Q_ALLOCA_DECLARE(void *, transformedArguments); + Q_ALLOCA_DECLARE(void, transformedResult); + + const QMetaType returnType = typedFunction->returnMetaType(); + const QMetaType frameReturn = types[0]; + bool returnsQVariantWrapper = false; + if (argv[0] && returnType != frameReturn) { + Q_ALLOCA_ASSIGN(void *, transformedArguments, (numFunctionArguments + 1) * sizeof(void *)); + memcpy(transformedArguments, argv, (argc + 1) * sizeof(void *)); + + if (frameReturn == QMetaType::fromType<QVariant>()) { + QVariant *returnValue = static_cast<QVariant *>(argv[0]); + *returnValue = QVariant(returnType); + transformedResult = transformedArguments[0] = returnValue->data(); + returnsQVariantWrapper = true; + } else if (returnType.sizeOf() > 0) { + Q_ALLOCA_ASSIGN(void, transformedResult, returnType.sizeOf()); + transformedArguments[0] = transformedResult; + if (returnType.flags() & QMetaType::NeedsConstruction) + returnType.construct(transformedResult); + } else { + transformedResult = transformedArguments[0] = &argc; // Some non-null marker value + } + } + + for (qsizetype i = 0; i < numFunctionArguments; ++i) { + const bool isValid = argc > i; + const QMetaType frameType = isValid ? types[i + 1] : QMetaType(); + + const QMetaType argumentType = typedFunction->parameterMetaType(i); + if (isValid && argumentType == frameType) + continue; + + if (transformedArguments == nullptr) { + Q_ALLOCA_ASSIGN(void *, transformedArguments, (numFunctionArguments + 1) * sizeof(void *)); + memcpy(transformedArguments, argv, (argc + 1) * sizeof(void *)); + } + + if (argumentType.sizeOf() == 0) { + transformedArguments[i + 1] = nullptr; + continue; + } + + void *frameVal = isValid ? argv[i + 1] : nullptr; + if (isValid && frameType == QMetaType::fromType<QVariant>()) { + QVariant *variant = static_cast<QVariant *>(frameVal); + + const QMetaType variantType = variant->metaType(); + if (variantType == argumentType) { + // Slightly nasty, but we're allowed to do this. + // We don't want to destruct() the QVariant's data() below. + transformedArguments[i + 1] = argv[i + 1] = variant->data(); + } else { + Q_ALLOCA_VAR(void, arg, argumentType.sizeOf()); + coerce(engine, variantType, variant->constData(), argumentType, arg); + transformedArguments[i + 1] = arg; + } + continue; + } + + Q_ALLOCA_VAR(void, arg, argumentType.sizeOf()); + + if (isValid) + coerce(engine, frameType, frameVal, argumentType, arg); + else + argumentType.construct(arg); + + transformedArguments[i + 1] = arg; + } + + if (!transformedArguments) { + call(argv, numFunctionArguments); + return; + } + + call(transformedArguments, numFunctionArguments); + + if (transformedResult && !returnsQVariantWrapper) { + if (frameReturn.sizeOf() > 0) { + if (frameReturn.flags() & QMetaType::NeedsDestruction) + frameReturn.destruct(argv[0]); + coerce(engine, returnType, transformedResult, frameReturn, argv[0]); + } + if (returnType.flags() & QMetaType::NeedsDestruction) + returnType.destruct(transformedResult); + } + + for (qsizetype i = 0; i < numFunctionArguments; ++i) { + void *arg = transformedArguments[i + 1]; + if (arg == nullptr) + continue; + if (i >= argc || arg != argv[i + 1]) { + const QMetaType argumentType = typedFunction->parameterMetaType(i); + if (argumentType.flags() & QMetaType::NeedsDestruction) + argumentType.destruct(arg); + } + } +} + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4JSCALL_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4jsonobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4jsonobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9fac4365df1beaee94c07c1b6126a0c2561d85c7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4jsonobject_p.h @@ -0,0 +1,107 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4JSONOBJECT_H +#define QV4JSONOBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include <qjsonarray.h> +#include <qjsonobject.h> +#include <qjsonvalue.h> +#include <qjsondocument.h> +#include <qhash.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct JsonObject : Object { + void init(); +}; + +} + +struct ObjectItem { + const QV4::Object *o; + ObjectItem(const QV4::Object *o) : o(o) {} +}; + +inline bool operator ==(const ObjectItem &a, const ObjectItem &b) +{ return a.o->d() == b.o->d(); } + +inline size_t qHash(const ObjectItem &i, size_t seed = 0) +{ return ::qHash((void *)i.o->d(), seed); } + +struct JsonObject : Object { + Q_MANAGED_TYPE(JsonObject) + V4_OBJECT2(JsonObject, Object) +private: + + typedef QSet<ObjectItem> V4ObjectSet; +public: + + static ReturnedValue method_parse(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_stringify(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue fromJsonValue(ExecutionEngine *engine, const QJsonValue &value); + static ReturnedValue fromJsonObject(ExecutionEngine *engine, const QJsonObject &object); + static ReturnedValue fromJsonArray(ExecutionEngine *engine, const QJsonArray &array); + + static inline QJsonValue toJsonValue(const QV4::Value &value) + { V4ObjectSet visitedObjects; return toJsonValue(value, visitedObjects); } + static inline QJsonObject toJsonObject(const QV4::Object *o) + { V4ObjectSet visitedObjects; return toJsonObject(o, visitedObjects); } + static inline QJsonArray toJsonArray(const QV4::Object *o) + { V4ObjectSet visitedObjects; return toJsonArray(o, visitedObjects); } + +private: + static QJsonValue toJsonValue(const QV4::Value &value, V4ObjectSet &visitedObjects); + static QJsonObject toJsonObject(const Object *o, V4ObjectSet &visitedObjects); + static QJsonArray toJsonArray(const Object *o, V4ObjectSet &visitedObjects); +}; + +class JsonParser +{ +public: + JsonParser(ExecutionEngine *engine, const QChar *json, int length); + + ReturnedValue parse(QJsonParseError *error); + +private: + inline bool eatSpace(); + inline QChar nextToken(); + + ReturnedValue parseObject(); + ReturnedValue parseArray(); + bool parseMember(Object *o); + bool parseString(QString *string); + bool parseValue(Value *val); + bool parseNumber(Value *val); + + ExecutionEngine *engine; + const QChar *head; + const QChar *json; + const QChar *end; + + int nestingLevel; + QJsonParseError::ParseError lastError; +}; + +} + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4lookup_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4lookup_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4d5a850a1603c0e07239d5ada6115f5c2b04c97c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4lookup_p.h @@ -0,0 +1,298 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4LOOKUP_H +#define QV4LOOKUP_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4engine_p.h" +#include "qv4object_p.h" +#include "qv4internalclass_p.h" +#include "qv4qmlcontext_p.h" +#include <private/qqmltypewrapper_p.h> +#include <private/qv4mm_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + struct QObjectMethod; +} + +template <typename T, int PhantomTag> +using HeapObjectWrapper = WriteBarrier::HeapObjectWrapper<T, PhantomTag>; + +// Note: We cannot hide the copy ctor and assignment operator of this class because it needs to +// be trivially copyable. But you should never ever copy it. There are refcounted members +// in there. +struct Q_QML_EXPORT Lookup { + union { + ReturnedValue (*getter)(Lookup *l, ExecutionEngine *engine, const Value &object); + ReturnedValue (*globalGetter)(Lookup *l, ExecutionEngine *engine); + ReturnedValue (*qmlContextPropertyGetter)(Lookup *l, ExecutionEngine *engine, Value *thisObject); + bool (*setter)(Lookup *l, ExecutionEngine *engine, Value &object, const Value &v); + }; + // NOTE: gc assumes the first two entries in the struct are pointers to heap objects or null + // or that the least significant bit is 1 (see the Lookup::markObjects function) + union { + struct { + Heap::Base *h1; + Heap::Base *h2; + quintptr unused; + quintptr unused2; + } markDef; + struct { + HeapObjectWrapper<Heap::InternalClass, 0> ic; + quintptr unused; + uint index; + uint offset; + } objectLookup; + struct { + quintptr protoId; + quintptr _unused; + const Value *data; + } protoLookup; + struct { + HeapObjectWrapper<Heap::InternalClass, 1> ic; + HeapObjectWrapper<Heap::InternalClass, 2> ic2; + uint offset; + uint offset2; + } objectLookupTwoClasses; + struct { + quintptr protoId; + quintptr protoId2; + const Value *data; + const Value *data2; + } protoLookupTwoClasses; + struct { + // Make sure the next two values are in sync with protoLookup + quintptr protoId; + HeapObjectWrapper<Heap::Object, 3> proto; + const Value *data; + quintptr type; + } primitiveLookup; + struct { + HeapObjectWrapper<Heap::InternalClass, 4> newClass; + quintptr protoId; + uint offset; + uint unused; + } insertionLookup; + struct { + quintptr _unused; + quintptr _unused2; + uint index; + uint unused; + } indexedLookup; + struct { + HeapObjectWrapper<Heap::InternalClass, 5> ic; + HeapObjectWrapper<Heap::InternalClass, 6> qmlTypeIc; // only used when lookup goes through QQmlTypeWrapper + const QQmlPropertyCache *propertyCache; + const QQmlPropertyData *propertyData; + } qobjectLookup; + struct { + HeapObjectWrapper<Heap::InternalClass, 7> ic; + HeapObjectWrapper<Heap::QObjectMethod, 8> method; + const QQmlPropertyCache *propertyCache; + const QQmlPropertyData *propertyData; + } qobjectMethodLookup; + struct { + quintptr isConstant; // This is a bool, encoded as 0 or 1. Both values are ignored by gc + quintptr metaObject; // a (const QMetaObject* & 1) or nullptr + int coreIndex; + int notifyIndex; + } qobjectFallbackLookup; + struct { + HeapObjectWrapper<Heap::InternalClass, 9> ic; + quintptr metaObject; // a (const QMetaObject* & 1) or nullptr + const QtPrivate::QMetaTypeInterface *metaType; // cannot use QMetaType; class must be trivial + quint16 coreIndex; + bool isFunction; + bool isEnum; + } qgadgetLookup; + struct { + quintptr unused1; + quintptr unused2; + int scriptIndex; + } qmlContextScriptLookup; + struct { + HeapObjectWrapper<Heap::Base, 10> singletonObject; + quintptr unused2; + QV4::ReturnedValue singletonValue; + } qmlContextSingletonLookup; + struct { + quintptr unused1; + quintptr unused2; + int objectId; + } qmlContextIdObjectLookup; + struct { + // Same as protoLookup, as used for global lookups + quintptr reserved1; + quintptr reserved2; + quintptr reserved3; + ReturnedValue (*getterTrampoline)(Lookup *l, ExecutionEngine *engine); + } qmlContextGlobalLookup; + struct { + HeapObjectWrapper<Heap::Base, 11> qmlTypeWrapper; + quintptr unused2; + } qmlTypeLookup; + struct { + HeapObjectWrapper<Heap::InternalClass, 12> ic; + quintptr unused; + ReturnedValue encodedEnumValue; + const QtPrivate::QMetaTypeInterface *metaType; + } qmlEnumValueLookup; + struct { + HeapObjectWrapper<Heap::InternalClass, 13> ic; + HeapObjectWrapper<Heap::Object, 14> qmlScopedEnumWrapper; + } qmlScopedEnumWrapperLookup; + }; + + uint nameIndex: 28; // Same number of bits we store in the compilation unit for name indices + uint forCall: 1; // Whether we are looking up a value in order to call it right away + uint reserved: 3; + + ReturnedValue resolveGetter(ExecutionEngine *engine, const Object *object); + ReturnedValue resolvePrimitiveGetter(ExecutionEngine *engine, const Value &object); + ReturnedValue resolveGlobalGetter(ExecutionEngine *engine); + void resolveProtoGetter(PropertyKey name, const Heap::Object *proto); + + static ReturnedValue getterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterFallback(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterFallbackAsVariant(Lookup *l, ExecutionEngine *engine, const Value &object); + + static ReturnedValue getter0MemberData(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getter0Inline(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterProto(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getter0Inlinegetter0Inline(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getter0Inlinegetter0MemberData(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getter0MemberDatagetter0MemberData(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterProtoTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterAccessor(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterProtoAccessor(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterProtoAccessorTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterIndexed(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterQObject(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterQObjectAsVariant(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue getterQObjectMethod(Lookup *l, ExecutionEngine *engine, const Value &object); + + static ReturnedValue primitiveGetterProto(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue primitiveGetterAccessor(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue stringLengthGetter(Lookup *l, ExecutionEngine *engine, const Value &object); + + static ReturnedValue globalGetterGeneric(Lookup *l, ExecutionEngine *engine); + static ReturnedValue globalGetterProto(Lookup *l, ExecutionEngine *engine); + static ReturnedValue globalGetterProtoAccessor(Lookup *l, ExecutionEngine *engine); + + bool resolveSetter(ExecutionEngine *engine, Object *object, const Value &value); + static bool setterGeneric(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + Q_NEVER_INLINE static bool setterTwoClasses(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + static bool setterFallback(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + static bool setterFallbackAsVariant(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + static bool setter0MemberData(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + static bool setter0Inline(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + static bool setter0setter0(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + static bool setterInsert(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + static bool setterQObject(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + static bool setterQObjectAsVariant(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + static bool arrayLengthSetter(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + + void markObjects(MarkStack *stack) { + if (markDef.h1 && !(reinterpret_cast<quintptr>(markDef.h1) & 1)) + markDef.h1->mark(stack); + if (markDef.h2 && !(reinterpret_cast<quintptr>(markDef.h2) & 1)) + markDef.h2->mark(stack); + } + + void releasePropertyCache() + { + if (getter == getterQObject + || getter == QQmlTypeWrapper::lookupSingletonProperty + || setter == setterQObject + || qmlContextPropertyGetter == QQmlContextWrapper::lookupScopeObjectProperty + || qmlContextPropertyGetter == QQmlContextWrapper::lookupContextObjectProperty + || getter == getterQObjectAsVariant + || setter == setterQObjectAsVariant) { + if (const QQmlPropertyCache *pc = qobjectLookup.propertyCache) + pc->release(); + } else if (getter == getterQObjectMethod + || getter == QQmlTypeWrapper::lookupSingletonMethod + || qmlContextPropertyGetter == QQmlContextWrapper::lookupScopeObjectMethod + || qmlContextPropertyGetter == QQmlContextWrapper::lookupContextObjectMethod) { + if (const QQmlPropertyCache *pc = qobjectMethodLookup.propertyCache) + pc->release(); + } + } +}; + +Q_STATIC_ASSERT(std::is_standard_layout<Lookup>::value); +// Ensure that these offsets are always at this point to keep generated code compatible +// across 32-bit and 64-bit (matters when cross-compiling). +Q_STATIC_ASSERT(offsetof(Lookup, getter) == 0); + +inline void setupQObjectLookup( + Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData) +{ + lookup->releasePropertyCache(); + Q_ASSERT(!ddata->propertyCache.isNull()); + lookup->qobjectLookup.propertyCache = ddata->propertyCache.data(); + lookup->qobjectLookup.propertyCache->addref(); + lookup->qobjectLookup.propertyData = propertyData; +} + +inline void setupQObjectLookup( + Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData, + const Object *self) +{ + setupQObjectLookup(lookup, ddata, propertyData); + lookup->qobjectLookup.ic.set(self->engine(), self->internalClass()); +} + + +inline void setupQObjectLookup( + Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData, + const Object *self, const Object *qmlType) +{ + setupQObjectLookup(lookup, ddata, propertyData, self); + lookup->qobjectLookup.qmlTypeIc.set(self->engine(), qmlType->internalClass()); +} + +// template parameter is an ugly trick to avoid pulling in the QObjectMethod header here +template<typename QObjectMethod = Heap::QObjectMethod> +inline void setupQObjectMethodLookup( + Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData, + const Object *self, QObjectMethod *method) +{ + lookup->releasePropertyCache(); + Q_ASSERT(!ddata->propertyCache.isNull()); + auto engine = self->engine(); + lookup->qobjectMethodLookup.method.set(engine, method); + lookup->qobjectMethodLookup.ic.set(engine, self->internalClass()); + lookup->qobjectMethodLookup.propertyCache = ddata->propertyCache.data(); + lookup->qobjectMethodLookup.propertyCache->addref(); + lookup->qobjectMethodLookup.propertyData = propertyData; +} + +inline bool qualifiesForMethodLookup(const QQmlPropertyData *propertyData) +{ + return propertyData->isFunction() + && !propertyData->isSignalHandler() // TODO: Optimize SignalHandler, too + && !propertyData->isVMEFunction() // Handled by QObjectLookup + && !propertyData->isVarProperty(); +} + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4managed_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4managed_p.h new file mode 100644 index 0000000000000000000000000000000000000000..722ccf313e72e9e6dce33d73e28b7ca9f557922e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4managed_p.h @@ -0,0 +1,218 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QMLJS_MANAGED_H +#define QMLJS_MANAGED_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" +#include "qv4value_p.h" +#include "qv4enginebase_p.h" +#include <private/qv4heap_p.h> +#include <private/qv4vtable_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +#define Q_MANAGED_CHECK \ + template <typename Type> inline void qt_check_for_QMANAGED_macro(const Type *_q_argument) const \ + { int i = qYouForgotTheQ_MANAGED_Macro(this, _q_argument); i = i + 1; } + +template <typename T> +inline int qYouForgotTheQ_MANAGED_Macro(T, T) { return 0; } + +template <typename T1, typename T2> +inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {} + +#define V4_MANAGED_SIZE_TEST void __dataTest() { static_assert (sizeof(*this) == sizeof(Managed), "Classes derived from Managed can't have own data members."); } + +#define V4_NEEDS_DESTROY static void virtualDestroy(QV4::Heap::Base *b) { static_cast<Data *>(b)->destroy(); } + + +#define V4_MANAGED_ITSELF(DataClass, superClass) \ + public: \ + Q_MANAGED_CHECK \ + typedef QV4::Heap::DataClass Data; \ + typedef superClass SuperClass; \ + static const QV4::VTable static_vtbl; \ + static inline const QV4::VTable *staticVTable() { return &static_vtbl; } \ + V4_MANAGED_SIZE_TEST \ + QV4::Heap::DataClass *d_unchecked() const { return static_cast<QV4::Heap::DataClass *>(m()); } \ + QV4::Heap::DataClass *d() const { \ + QV4::Heap::DataClass *dptr = d_unchecked(); \ + dptr->_checkIsInitialized(); \ + return dptr; \ + } + +#define V4_MANAGED(DataClass, superClass) \ + private: \ + DataClass() = delete; \ + Q_DISABLE_COPY(DataClass) \ + V4_MANAGED_ITSELF(DataClass, superClass) \ + Q_STATIC_ASSERT(std::is_trivial_v<QV4::Heap::DataClass>); + +#define Q_MANAGED_TYPE(type) \ + public: \ + enum { MyType = Type_##type }; + +#define V4_INTERNALCLASS(c) \ + static Heap::InternalClass *defaultInternalClass(QV4::EngineBase *e) \ + { return e->internalClasses(QV4::EngineBase::Class_##c); } + +struct Q_QML_EXPORT Managed : Value, VTableBase +{ + V4_MANAGED_ITSELF(Base, Managed) + enum { + IsExecutionContext = false, + IsString = false, + IsStringOrSymbol = false, + IsObject = false, + IsTailCallable = false, + IsErrorObject = false, + IsArrayData = false + }; +private: + void *operator new(size_t); + Managed() = delete; + Q_DISABLE_COPY(Managed) + +public: + enum { NInlineProperties = 0 }; + + enum Type { + Type_Invalid, + Type_String, + Type_Object, + Type_Symbol, + Type_ArrayObject, + Type_FunctionObject, + Type_GeneratorObject, + Type_BooleanObject, + Type_NumberObject, + Type_StringObject, + Type_SymbolObject, + Type_DateObject, + Type_RegExpObject, + Type_ErrorObject, + Type_ArgumentsObject, + Type_JsonObject, + Type_MathObject, + Type_ProxyObject, + Type_UrlObject, + Type_UrlSearchParamsObject, + + Type_ExecutionContext, + Type_InternalClass, + Type_SetIteratorObject, + Type_MapIteratorObject, + Type_ArrayIteratorObject, + Type_StringIteratorObject, + Type_ForInIterator, + Type_RegExp, + + Type_V4Sequence, + Type_QmlListProperty, + + }; + Q_MANAGED_TYPE(Invalid) + + Heap::InternalClass *internalClass() const { return d()->internalClass; } + const VTable *vtable() const { return d()->internalClass->vtable; } + inline ExecutionEngine *engine() const { return internalClass()->engine; } + + bool isV4SequenceType() const { return d()->internalClass->vtable->type == Type_V4Sequence; } + bool isQmlListPropertyType() const { return d()->internalClass->vtable->type == Type_QmlListProperty; } + bool isArrayLike() const { return isArrayObject() || isV4SequenceType() || isQmlListPropertyType(); } + + bool isArrayObject() const { return d()->internalClass->vtable->type == Type_ArrayObject; } + bool isStringObject() const { return d()->internalClass->vtable->type == Type_StringObject; } + bool isSymbolObject() const { return d()->internalClass->vtable->type == Type_SymbolObject; } + + QString className() const; + + bool isEqualTo(const Managed *other) const + { return d()->internalClass->vtable->isEqualTo(const_cast<Managed *>(this), const_cast<Managed *>(other)); } + + bool inUse() const { return d()->inUse(); } + bool markBit() const { return d()->isMarked(); } + inline void mark(MarkStack *markStack); + + Q_ALWAYS_INLINE Heap::Base *heapObject() const { + return m(); + } + + template<typename T> inline T *cast() { + return static_cast<T *>(this); + } + template<typename T> inline const T *cast() const { + return static_cast<const T *>(this); + } + +protected: + static bool virtualIsEqualTo(Managed *m, Managed *other); + +private: + friend class MemoryManager; + friend struct Identifiers; + friend struct ObjectIterator; +}; + +inline void Managed::mark(MarkStack *markStack) +{ + Q_ASSERT(m()); + m()->mark(markStack); +} + +template<> +inline const Managed *Value::as() const { + return managed(); +} + +template<> +inline const Object *Value::as() const { + return objectValue(); +} + + +struct InternalClass : Managed +{ + V4_MANAGED_ITSELF(InternalClass, Managed) + Q_MANAGED_TYPE(InternalClass) + V4_INTERNALCLASS(Empty) + V4_NEEDS_DESTROY + + Q_REQUIRED_RESULT Heap::InternalClass *changeVTable(const VTable *vt) { + return d()->changeVTable(vt); + } + Q_REQUIRED_RESULT Heap::InternalClass *changePrototype(Heap::Object *proto) { + return d()->changePrototype(proto); + } + Q_REQUIRED_RESULT Heap::InternalClass *addMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry = nullptr) { + return d()->addMember(identifier, data, entry); + } + + Q_REQUIRED_RESULT Heap::InternalClass *changeMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry = nullptr) { + return d()->changeMember(identifier, data, entry); + } + + void operator =(Heap::InternalClass *ic) { + Value::operator=(ic); + } +}; + +} + + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mapiterator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mapiterator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..400805c52ec55e2f55cb364ec7b153248db3a2ed --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mapiterator_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2018 Crimson AS <info@crimson.no> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4MAPITERATOR_P_H +#define QV4MAPITERATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4iterator_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +#define MapIteratorObjectMembers(class, Member) \ + Member(class, Pointer, Object *, iteratedMap) \ + Member(class, NoMark, IteratorKind, iterationKind) \ + Member(class, NoMark, quint32, mapNextIndex) + +DECLARE_HEAP_OBJECT(MapIteratorObject, Object) { + DECLARE_MARKOBJECTS(MapIteratorObject) + void init(Object *obj, QV4::ExecutionEngine *engine) + { + Object::init(); + this->iteratedMap.set(engine, obj); + this->mapNextIndex = 0; + } +}; + +} + +struct MapIteratorPrototype : Object +{ + V4_PROTOTYPE(iteratorPrototype) + void init(ExecutionEngine *engine); + + static ReturnedValue method_next(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); +}; + +struct MapIteratorObject : Object +{ + V4_OBJECT2(MapIteratorObject, Object) + Q_MANAGED_TYPE(MapIteratorObject) + V4_PROTOTYPE(mapIteratorPrototype) + + void init(ExecutionEngine *engine); +}; + + +} + +QT_END_NAMESPACE + +#endif // QV4MAPITERATOR_P_H + + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mapobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mapobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2548c187596d9ab9a922a5e4a2b0ea397c356e26 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mapobject_p.h @@ -0,0 +1,107 @@ +// Copyright (C) 2018 Crimson AS <info@crimson.no> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4MAPOBJECT_P_H +#define QV4MAPOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +class ESTable; + +namespace Heap { + +struct WeakMapCtor : FunctionObject { + void init(ExecutionEngine *engine); +}; + +struct MapCtor : WeakMapCtor { + void init(ExecutionEngine *engine); +}; + +struct MapObject : Object { + static void markObjects(Heap::Base *that, MarkStack *markStack); + void init(); + void destroy(); + void removeUnmarkedKeys(); + + MapObject *nextWeakMap; + ESTable *esTable; + bool isWeakMap; +}; + +} + +struct WeakMapCtor: FunctionObject +{ + V4_OBJECT2(WeakMapCtor, FunctionObject) + + static ReturnedValue construct(const FunctionObject *f, const Value *argv, int argc, const Value *, bool weakMap); + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct MapCtor : WeakMapCtor +{ + V4_OBJECT2(MapCtor, WeakMapCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + +struct MapObject : Object +{ + V4_OBJECT2(MapObject, Object) + V4_PROTOTYPE(mapPrototype) + V4_NEEDS_DESTROY +}; + +struct WeakMapPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + Q_AUTOTEST_EXPORT static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +struct MapPrototype : WeakMapPrototype +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_clear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + Q_AUTOTEST_EXPORT static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_size(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + + +} // namespace QV4 + + +QT_END_NAMESPACE + +#endif // QV4MAPOBJECT_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4math_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4math_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ed29b891e8065c43da496e7ba9b5ceac6c0cf8fc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4math_p.h @@ -0,0 +1,69 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QMLJS_MATH_H +#define QMLJS_MATH_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qglobal.h> + +#include <private/qv4staticvalue_p.h> +#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> +#include <cmath> + +#if defined(Q_CC_GNU) +#define QMLJS_READONLY __attribute((const)) +#else +#define QMLJS_READONLY +#endif + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +static inline QMLJS_READONLY ReturnedValue add_int32(int a, int b) +{ + int result; + if (Q_UNLIKELY(qAddOverflow(a, b, &result))) + return StaticValue::fromDouble(static_cast<double>(a) + b).asReturnedValue(); + return StaticValue::fromInt32(result).asReturnedValue(); +} + +static inline QMLJS_READONLY ReturnedValue sub_int32(int a, int b) +{ + int result; + if (Q_UNLIKELY(qSubOverflow(a, b, &result))) + return StaticValue::fromDouble(static_cast<double>(a) - b).asReturnedValue(); + return StaticValue::fromInt32(result).asReturnedValue(); +} + +static inline QMLJS_READONLY ReturnedValue mul_int32(int a, int b) +{ + int result; + if (Q_UNLIKELY(qMulOverflow(a, b, &result))) + return StaticValue::fromDouble(static_cast<double>(a) * b).asReturnedValue(); + // need to handle the case where one number is negative and the other 0 ==> -0 + if (((a < 0) xor (b < 0)) && (result == 0)) + return StaticValue::fromDouble(-0.0).asReturnedValue(); + return StaticValue::fromInt32(result).asReturnedValue(); +} + +} + +QT_END_NAMESPACE + +#ifdef QMLJS_READONLY +#undef QMLJS_READONLY +#endif + +#endif // QMLJS_MATH_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mathobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mathobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7e283051d124c82a8ec9809caefd3051a908954c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mathobject_p.h @@ -0,0 +1,77 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4MATHOBJECT_H +#define QV4MATHOBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct MathObject : Object { + void init(); +}; + +} + +struct MathObject: Object +{ + V4_OBJECT2(MathObject, Object) + Q_MANAGED_TYPE(MathObject) + + static ReturnedValue method_abs(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_acos(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_acosh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_asin(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_asinh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_atan(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_atanh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_atan2(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_cbrt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_ceil(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_clz32(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_cos(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_cosh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_exp(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_expm1(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_floor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_fround(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_hypot(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_imul(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_log(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_log10(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_log1p(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_log2(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_max(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_min(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_pow(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_random(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_round(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_sign(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_sin(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_sinh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_sqrt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_tan(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_tanh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_trunc(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +} + +QT_END_NAMESPACE + +#endif // QMLJS_OBJECTS_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4memberdata_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4memberdata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..289fc6c22d845e7f5b5328b7e2c19c751cb8800b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4memberdata_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4MEMBERDATA_H +#define QV4MEMBERDATA_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" +#include "qv4managed_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +#define MemberDataMembers(class, Member) \ + Member(class, ValueArray, ValueArray, values) + +DECLARE_HEAP_OBJECT(MemberData, Base) { + DECLARE_MARKOBJECTS(MemberData) +}; +Q_STATIC_ASSERT(std::is_trivial_v<MemberData>); + +} + +struct MemberData : Managed +{ + V4_MANAGED(MemberData, Managed) + V4_INTERNALCLASS(MemberData) + + const Value &operator[] (uint idx) const { return d()->values[idx]; } + const Value *data() const { return d()->values.data(); } + void set(EngineBase *e, uint index, Value v) { d()->values.set(e, index, v); } + void set(EngineBase *e, uint index, Heap::Base *b) { d()->values.set(e, index, b); } + + inline uint size() const { return d()->values.size; } + + static Heap::MemberData *allocate(QV4::ExecutionEngine *e, uint n, Heap::MemberData *old = nullptr); +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mm_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mm_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9f49ea676ddc56c0e8d0dd973b7a988c1efc57d0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mm_p.h @@ -0,0 +1,499 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4GC_H +#define QV4GC_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <private/qv4value_p.h> +#include <private/qv4scopedvalue_p.h> +#include <private/qv4object_p.h> +#include <private/qv4mmdefs_p.h> +#include <QVector> + +#define MM_DEBUG 0 + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct GCData { virtual ~GCData(){};}; + +struct GCIteratorStorage { + PersistentValueStorage::Iterator it{nullptr, 0}; +}; + +struct GCStateMachine { + Q_GADGET_EXPORT(Q_QML_EXPORT) + +public: + enum GCState { + MarkStart = 0, + MarkGlobalObject, + MarkJSStack, + InitMarkPersistentValues, + MarkPersistentValues, + InitMarkWeakValues, + MarkWeakValues, + MarkDrain, + MarkReady, + InitCallDestroyObjects, + CallDestroyObjects, + FreeWeakMaps, + FreeWeakSets, + HandleQObjectWrappers, + DoSweep, + Invalid, + Count, + }; + Q_ENUM(GCState) + + struct StepTiming { + qint64 rolling_sum = 0; + qint64 count = 0; + }; + + struct GCStateInfo { + using ExtraData = std::variant<std::monostate, GCIteratorStorage>; + GCState (*execute)(GCStateMachine *, ExtraData &) = nullptr; // Function to execute for this state, returns true if ready to transition + bool breakAfter{false}; + }; + + using ExtraData = GCStateInfo::ExtraData; + GCState state{GCState::Invalid}; + std::chrono::microseconds timeLimit{}; + QDeadlineTimer deadline; + std::array<GCStateInfo, GCState::Count> stateInfoMap; + std::array<StepTiming, GCState::Count> executionTiming{}; + MemoryManager *mm = nullptr; + ExtraData stateData; // extra date for specific states + bool collectTimings = false; + + GCStateMachine(); + + inline void step() { + if (!inProgress()) { + reset(); + } + transition(); + } + + inline bool inProgress() { + return state != GCState::Invalid; + } + + inline void reset() { + state = GCState::MarkStart; + } + + Q_QML_EXPORT void transition(); + + inline void handleTimeout(GCState state) { + Q_UNUSED(state); + } +}; + +using GCState = GCStateMachine::GCState; +using GCStateInfo = GCStateMachine::GCStateInfo; + +struct ChunkAllocator; +struct MemorySegment; + +struct BlockAllocator { + BlockAllocator(ChunkAllocator *chunkAllocator, ExecutionEngine *engine) + : chunkAllocator(chunkAllocator), engine(engine) + { + memset(freeBins, 0, sizeof(freeBins)); + } + + enum { NumBins = 8 }; + + static inline size_t binForSlots(size_t nSlots) { + return nSlots >= NumBins ? NumBins - 1 : nSlots; + } + + HeapItem *allocate(size_t size, bool forceAllocation = false); + + size_t totalSlots() const { + return Chunk::AvailableSlots*chunks.size(); + } + + size_t allocatedMem() const { + return chunks.size()*Chunk::DataSize; + } + size_t usedMem() const { + uint used = 0; + for (auto c : chunks) + used += c->nUsedSlots()*Chunk::SlotSize; + return used; + } + + void sweep(); + void freeAll(); + void resetBlackBits(); + + // bump allocations + HeapItem *nextFree = nullptr; + size_t nFree = 0; + size_t usedSlotsAfterLastSweep = 0; + HeapItem *freeBins[NumBins]; + ChunkAllocator *chunkAllocator; + ExecutionEngine *engine; + std::vector<Chunk *> chunks; + uint *allocationStats = nullptr; +}; + +struct HugeItemAllocator { + HugeItemAllocator(ChunkAllocator *chunkAllocator, ExecutionEngine *engine) + : chunkAllocator(chunkAllocator), engine(engine) + {} + + HeapItem *allocate(size_t size); + void sweep(ClassDestroyStatsCallback classCountPtr); + void freeAll(); + void resetBlackBits(); + + size_t usedMem() const { + size_t used = 0; + for (const auto &c : chunks) + used += c.size; + return used; + } + + ChunkAllocator *chunkAllocator; + ExecutionEngine *engine; + struct HugeChunk { + MemorySegment *segment; + Chunk *chunk; + size_t size; + }; + + std::vector<HugeChunk> chunks; +}; + + +class Q_QML_EXPORT MemoryManager +{ + Q_DISABLE_COPY(MemoryManager); + +public: + MemoryManager(ExecutionEngine *engine); + ~MemoryManager(); + + template <typename ToBeMarked> + friend struct GCCriticalSection; + + // TODO: this is only for 64bit (and x86 with SSE/AVX), so exend it for other architectures to be slightly more efficient (meaning, align on 8-byte boundaries). + // Note: all occurrences of "16" in alloc/dealloc are also due to the alignment. + constexpr static inline std::size_t align(std::size_t size) + { return (size + Chunk::SlotSize - 1) & ~(Chunk::SlotSize - 1); } + + /* NOTE: allocManaged comes in various overloads. If size is not passed explicitly + sizeof(ManagedType::Data) is used for size. However, there are quite a few cases + where we allocate more than sizeof(ManagedType::Data); that's generally the case + when the Object has a ValueArray member. + If no internal class pointer is provided, ManagedType::defaultInternalClass(engine) + will be used as the internal class. + */ + + template<typename ManagedType> + inline typename ManagedType::Data *allocManaged(std::size_t size, Heap::InternalClass *ic) + { + Q_STATIC_ASSERT(std::is_trivial_v<typename ManagedType::Data>); + size = align(size); + typename ManagedType::Data *d = static_cast<typename ManagedType::Data *>(allocData(size)); + d->internalClass.set(engine, ic); + Q_ASSERT(d->internalClass && d->internalClass->vtable); + Q_ASSERT(ic->vtable == ManagedType::staticVTable()); + return d; + } + + template<typename ManagedType> + inline typename ManagedType::Data *allocManaged(Heap::InternalClass *ic) + { + return allocManaged<ManagedType>(sizeof(typename ManagedType::Data), ic); + } + + template<typename ManagedType> + inline typename ManagedType::Data *allocManaged(std::size_t size, InternalClass *ic) + { + return allocManaged<ManagedType>(size, ic->d()); + } + + template<typename ManagedType> + inline typename ManagedType::Data *allocManaged(InternalClass *ic) + { + return allocManaged<ManagedType>(sizeof(typename ManagedType::Data), ic); + } + + template<typename ManagedType> + inline typename ManagedType::Data *allocManaged(std::size_t size) + { + Scope scope(engine); + Scoped<InternalClass> ic(scope, ManagedType::defaultInternalClass(engine)); + return allocManaged<ManagedType>(size, ic); + } + + template<typename ManagedType> + inline typename ManagedType::Data *allocManaged() + { + auto constexpr size = sizeof(typename ManagedType::Data); + Scope scope(engine); + Scoped<InternalClass> ic(scope, ManagedType::defaultInternalClass(engine)); + return allocManaged<ManagedType>(size, ic); + } + + template <typename ObjectType> + typename ObjectType::Data *allocateObject(Heap::InternalClass *ic) + { + Heap::Object *o = allocObjectWithMemberData(ObjectType::staticVTable(), ic->size); + o->internalClass.set(engine, ic); + Q_ASSERT(o->internalClass.get() && o->vtable()); + Q_ASSERT(o->vtable() == ObjectType::staticVTable()); + return static_cast<typename ObjectType::Data *>(o); + } + + template <typename ObjectType> + typename ObjectType::Data *allocateObject(InternalClass *ic) + { + return allocateObject<ObjectType>(ic->d()); + } + + template <typename ObjectType> + typename ObjectType::Data *allocateObject() + { + Scope scope(engine); + Scoped<InternalClass> ic(scope, ObjectType::defaultInternalClass(engine)); + ic = ic->changeVTable(ObjectType::staticVTable()); + ic = ic->changePrototype(ObjectType::defaultPrototype(engine)->d()); + return allocateObject<ObjectType>(ic); + } + + template <typename ManagedType, typename Arg1> + typename ManagedType::Data *allocWithStringData(std::size_t unmanagedSize, Arg1 &&arg1) + { + typename ManagedType::Data *o = reinterpret_cast<typename ManagedType::Data *>(allocString(unmanagedSize)); + o->internalClass.set(engine, ManagedType::defaultInternalClass(engine)); + Q_ASSERT(o->internalClass && o->internalClass->vtable); + o->init(std::forward<Arg1>(arg1)); + return o; + } + + template <typename ObjectType, typename... Args> + typename ObjectType::Data *allocObject(Heap::InternalClass *ic, Args&&... args) + { + typename ObjectType::Data *d = allocateObject<ObjectType>(ic); + d->init(std::forward<Args>(args)...); + return d; + } + + template <typename ObjectType, typename... Args> + typename ObjectType::Data *allocObject(InternalClass *ic, Args&&... args) + { + typename ObjectType::Data *d = allocateObject<ObjectType>(ic); + d->init(std::forward<Args>(args)...); + return d; + } + + template <typename ObjectType, typename... Args> + typename ObjectType::Data *allocate(Args&&... args) + { + Scope scope(engine); + Scoped<ObjectType> t(scope, allocateObject<ObjectType>()); + t->d_unchecked()->init(std::forward<Args>(args)...); + return t->d(); + } + + template <typename ManagedType, typename... Args> + typename ManagedType::Data *alloc(Args&&... args) + { + Scope scope(engine); + Scoped<ManagedType> t(scope, allocManaged<ManagedType>()); + t->d_unchecked()->init(std::forward<Args>(args)...); + return t->d(); + } + + void runGC(); + bool tryForceGCCompletion(); + void runFullGC(); + + void dumpStats() const; + + size_t getUsedMem() const; + size_t getAllocatedMem() const; + size_t getLargeItemsMem() const; + + // called when a JS object grows itself. Specifically: Heap::String::append + // and InternalClassDataPrivate<PropertyAttributes>. + void changeUnmanagedHeapSizeUsage(qptrdiff delta) { unmanagedHeapSize += delta; } + + // called at the end of a gc cycle + void updateUnmanagedHeapSizeGCLimit(); + + template<typename ManagedType> + typename ManagedType::Data *allocIC() + { + Heap::Base *b = *allocate(&icAllocator, align(sizeof(typename ManagedType::Data))); + return static_cast<typename ManagedType::Data *>(b); + } + + void registerWeakMap(Heap::MapObject *map); + void registerWeakSet(Heap::SetObject *set); + + void onEventLoop(); + + //GC related methods + void setGCTimeLimit(int timeMs); + MarkStack* markStack() { return m_markStack.get(); } + +protected: + /// expects size to be aligned + Heap::Base *allocString(std::size_t unmanagedSize); + Heap::Base *allocData(std::size_t size); + Heap::Object *allocObjectWithMemberData(const QV4::VTable *vtable, uint nMembers); + +private: + enum { + MinUnmanagedHeapSizeGCLimit = 128 * 1024 + }; + +public: + void collectFromJSStack(MarkStack *markStack) const; + void sweep(bool lastSweep = false, ClassDestroyStatsCallback classCountPtr = nullptr); + void cleanupDeletedQObjectWrappersInSweep(); + bool isAboveUnmanagedHeapLimit() + { + const bool incrementalGCIsAlreadyRunning = m_markStack != nullptr; + const bool aboveUnmanagedHeapLimit = incrementalGCIsAlreadyRunning + ? unmanagedHeapSize > 3 * unmanagedHeapSizeGCLimit / 2 + : unmanagedHeapSize > unmanagedHeapSizeGCLimit; + return aboveUnmanagedHeapLimit; + } +private: + bool shouldRunGC() const; + + HeapItem *allocate(BlockAllocator *allocator, std::size_t size) + { + const bool incrementalGCIsAlreadyRunning = m_markStack != nullptr; + + bool didGCRun = false; + if (aggressiveGC) { + runFullGC(); + didGCRun = true; + } + + if (isAboveUnmanagedHeapLimit()) { + if (!didGCRun) + incrementalGCIsAlreadyRunning ? (void) tryForceGCCompletion() : runGC(); + didGCRun = true; + } + + if (size > Chunk::DataSize) + return hugeItemAllocator.allocate(size); + + if (HeapItem *m = allocator->allocate(size)) + return m; + + if (!didGCRun && shouldRunGC()) + runGC(); + + return allocator->allocate(size, true); + } + +public: + QV4::ExecutionEngine *engine; + ChunkAllocator *chunkAllocator; + BlockAllocator blockAllocator; + BlockAllocator icAllocator; + HugeItemAllocator hugeItemAllocator; + PersistentValueStorage *m_persistentValues; + PersistentValueStorage *m_weakValues; + QVector<Value *> m_pendingFreedObjectWrapperValue; + Heap::MapObject *weakMaps = nullptr; + Heap::SetObject *weakSets = nullptr; + + std::unique_ptr<GCStateMachine> gcStateMachine{nullptr}; + std::unique_ptr<MarkStack> m_markStack{nullptr}; + + std::size_t unmanagedHeapSize = 0; // the amount of bytes of heap that is not managed by the memory manager, but which is held onto by managed items. + std::size_t unmanagedHeapSizeGCLimit; + std::size_t usedSlotsAfterLastFullSweep = 0; + + enum Blockness : quint8 {Unblocked, NormalBlocked, InCriticalSection }; + Blockness gcBlocked = Unblocked; + bool aggressiveGC = false; + bool gcStats = false; + bool gcCollectorStats = false; + + int allocationCount = 0; + size_t lastAllocRequestedSlots = 0; + + struct { + size_t maxReservedMem = 0; + size_t maxAllocatedMem = 0; + size_t maxUsedMem = 0; + uint allocations[BlockAllocator::NumBins]; + } statistics; +}; + +/*! + \internal + GCCriticalSection prevets the gc from running, until it is destructed. + In its dtor, it runs a check whether we've reached the unmanaegd heap limit, + and triggers a gc run if necessary. + Lastly, it can optionally mark an object passed to it before runnig the gc. + */ +template <typename ToBeMarked = void> +struct GCCriticalSection { + Q_DISABLE_COPY_MOVE(GCCriticalSection) + + Q_NODISCARD_CTOR GCCriticalSection(QV4::ExecutionEngine *engine, ToBeMarked *toBeMarked = nullptr) + : m_engine(engine) + , m_oldState(std::exchange(engine->memoryManager->gcBlocked, MemoryManager::InCriticalSection)) + , m_toBeMarked(toBeMarked) + { + // disallow nested critical sections + Q_ASSERT(m_oldState != MemoryManager::InCriticalSection); + } + ~GCCriticalSection() + { + m_engine->memoryManager->gcBlocked = m_oldState; + if (m_oldState != MemoryManager::Unblocked) + if constexpr (!std::is_same_v<ToBeMarked, void>) + if (m_toBeMarked) + m_toBeMarked->markObjects(m_engine->memoryManager->markStack()); + /* because we blocked the gc, we might be using too much memoryon the unmanaged heap + and did not run the normal fixup logic. So recheck again, and trigger a gc run + if necessary*/ + if (!m_engine->memoryManager->isAboveUnmanagedHeapLimit()) + return; + if (!m_engine->isGCOngoing) { + m_engine->memoryManager->runGC(); + } else { + [[maybe_unused]] bool gcFinished = m_engine->memoryManager->tryForceGCCompletion(); + Q_ASSERT(gcFinished); + } + } + +private: + QV4::ExecutionEngine *m_engine; + MemoryManager::Blockness m_oldState; + ToBeMarked *m_toBeMarked; +}; + +} + +QT_END_NAMESPACE + +#endif // QV4GC_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mmdefs_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mmdefs_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d8977ff561780b3190c84372301a51db46efe119 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4mmdefs_p.h @@ -0,0 +1,345 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4MMDEFS_P_H +#define QV4MMDEFS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <private/qv4runtimeapi_p.h> +#include <QtCore/qalgorithms.h> +#include <QtCore/qmath.h> + +QT_BEGIN_NAMESPACE + +class QDeadlineTimer; + +namespace QV4 { + +struct MarkStack; + +typedef void(*ClassDestroyStatsCallback)(const char *); + +/* + * Chunks are the basic structure containing GC managed objects. + * + * Chunks are 64k aligned in memory, so that retrieving the Chunk pointer from a Heap object + * is a simple masking operation. Each Chunk has 4 bitmaps for managing purposes, + * and 32byte wide slots for the objects following afterwards. + * + * The gray and black bitmaps are used for mark/sweep. + * The object bitmap has a bit set if this location represents the start of a Heap object. + * The extends bitmap denotes the extend of an object. It has a cleared bit at the start of the object + * and a set bit for all following slots used by the object. + * + * Free memory has both used and extends bits set to 0. + * + * This gives the following operations when allocating an object of size s: + * Find s/Alignment consecutive free slots in the chunk. Set the object bit for the first + * slot to 1. Set the extends bits for all following slots to 1. + * + * All used slots can be found by object|extents. + * + * When sweeping, simply copy the black bits over to the object bits. + * + */ +struct HeapItem; +struct Chunk { + enum { + ChunkSize = 64*1024, + ChunkShift = 16, + SlotSize = 32, + SlotSizeShift = 5, + NumSlots = ChunkSize/SlotSize, + BitmapSize = NumSlots/8, + HeaderSize = 3*BitmapSize, + DataSize = ChunkSize - HeaderSize, + AvailableSlots = DataSize/SlotSize, +#if QT_POINTER_SIZE == 8 + Bits = 64, + BitShift = 6, +#else + Bits = 32, + BitShift = 5, +#endif + EntriesInBitmap = BitmapSize/sizeof(quintptr) + }; + quintptr blackBitmap[BitmapSize/sizeof(quintptr)]; + quintptr objectBitmap[BitmapSize/sizeof(quintptr)]; + quintptr extendsBitmap[BitmapSize/sizeof(quintptr)]; + char data[ChunkSize - HeaderSize]; + + HeapItem *realBase(); + HeapItem *first(); + + static Q_ALWAYS_INLINE size_t bitmapIndex(size_t index) { + return index >> BitShift; + } + static Q_ALWAYS_INLINE quintptr bitForIndex(size_t index) { + return static_cast<quintptr>(1) << (index & (Bits - 1)); + } + + static void setBit(quintptr *bitmap, size_t index) { +// Q_ASSERT(index >= HeaderSize/SlotSize && index < ChunkSize/SlotSize); + bitmap += bitmapIndex(index); + quintptr bit = bitForIndex(index); + *bitmap |= bit; + } + static void clearBit(quintptr *bitmap, size_t index) { +// Q_ASSERT(index >= HeaderSize/SlotSize && index < ChunkSize/SlotSize); + bitmap += bitmapIndex(index); + quintptr bit = bitForIndex(index); + *bitmap &= ~bit; + } + static bool testBit(quintptr *bitmap, size_t index) { +// Q_ASSERT(index >= HeaderSize/SlotSize && index < ChunkSize/SlotSize); + bitmap += bitmapIndex(index); + quintptr bit = bitForIndex(index); + return (*bitmap & bit); + } + static void setBits(quintptr *bitmap, size_t index, size_t nBits) { +// Q_ASSERT(index >= HeaderSize/SlotSize && index + nBits <= ChunkSize/SlotSize); + if (!nBits) + return; + bitmap += index >> BitShift; + index &= (Bits - 1); + while (1) { + size_t bitsToSet = qMin(nBits, Bits - index); + quintptr mask = static_cast<quintptr>(-1) >> (Bits - bitsToSet) << index; + *bitmap |= mask; + nBits -= bitsToSet; + if (!nBits) + return; + index = 0; + ++bitmap; + } + } + static bool hasNonZeroBit(quintptr *bitmap) { + for (uint i = 0; i < EntriesInBitmap; ++i) + if (bitmap[i]) + return true; + return false; + } + static uint lowestNonZeroBit(quintptr *bitmap) { + for (uint i = 0; i < EntriesInBitmap; ++i) { + if (bitmap[i]) { + quintptr b = bitmap[i]; + return i*Bits + qCountTrailingZeroBits(b); + } + } + return 0; + } + + uint nFreeSlots() const { + return AvailableSlots - nUsedSlots(); + } + uint nUsedSlots() const { + uint usedSlots = 0; + for (uint i = 0; i < EntriesInBitmap; ++i) { + quintptr used = objectBitmap[i] | extendsBitmap[i]; + usedSlots += qPopulationCount(used); + } + return usedSlots; + } + + bool sweep(ClassDestroyStatsCallback classCountPtr); + void resetBlackBits(); + bool sweep(ExecutionEngine *engine); + void freeAll(ExecutionEngine *engine); + + void sortIntoBins(HeapItem **bins, uint nBins); +}; + +struct HeapItem { + union { + struct { + HeapItem *next; + size_t availableSlots; + } freeData; + quint64 payload[Chunk::SlotSize/sizeof(quint64)]; + }; + operator Heap::Base *() { return reinterpret_cast<Heap::Base *>(this); } + + template<typename T> + T *as() { return static_cast<T *>(reinterpret_cast<Heap::Base *>(this)); } + + Chunk *chunk() const { + return reinterpret_cast<Chunk *>(reinterpret_cast<quintptr>(this) >> Chunk::ChunkShift << Chunk::ChunkShift); + } + + bool isBlack() const { + Chunk *c = chunk(); + std::ptrdiff_t index = this - c->realBase(); + return Chunk::testBit(c->blackBitmap, index); + } + bool isInUse() const { + Chunk *c = chunk(); + std::ptrdiff_t index = this - c->realBase(); + return Chunk::testBit(c->objectBitmap, index); + } + + void setAllocatedSlots(size_t nSlots) { +// Q_ASSERT(size && !(size % sizeof(HeapItem))); + Chunk *c = chunk(); + size_t index = this - c->realBase(); +// Q_ASSERT(!Chunk::testBit(c->objectBitmap, index)); + Chunk::setBit(c->objectBitmap, index); + Chunk::setBits(c->extendsBitmap, index + 1, nSlots - 1); +// for (uint i = index + 1; i < nBits - 1; ++i) +// Q_ASSERT(Chunk::testBit(c->extendsBitmap, i)); +// Q_ASSERT(!Chunk::testBit(c->extendsBitmap, index)); + } + + // Doesn't report correctly for huge items + size_t size() const { + Chunk *c = chunk(); + std::ptrdiff_t index = this - c->realBase(); + Q_ASSERT(Chunk::testBit(c->objectBitmap, index)); + // ### optimize me + std::ptrdiff_t end = index + 1; + while (end < Chunk::NumSlots && Chunk::testBit(c->extendsBitmap, end)) + ++end; + return (end - index)*sizeof(HeapItem); + } +}; + +inline HeapItem *Chunk::realBase() +{ + return reinterpret_cast<HeapItem *>(this); +} + +inline HeapItem *Chunk::first() +{ + return reinterpret_cast<HeapItem *>(data); +} + +Q_STATIC_ASSERT(sizeof(Chunk) == Chunk::ChunkSize); +Q_STATIC_ASSERT((1 << Chunk::ChunkShift) == Chunk::ChunkSize); +Q_STATIC_ASSERT(1 << Chunk::SlotSizeShift == Chunk::SlotSize); +Q_STATIC_ASSERT(sizeof(HeapItem) == Chunk::SlotSize); +Q_STATIC_ASSERT(QT_POINTER_SIZE*8 == Chunk::Bits); +Q_STATIC_ASSERT((1 << Chunk::BitShift) == Chunk::Bits); + +struct Q_QML_EXPORT MarkStack { + MarkStack(ExecutionEngine *engine); + ~MarkStack() { /* we drain manually */ } + + void push(Heap::Base *m) { + *(m_top++) = m; + + if (m_top < m_softLimit) + return; + + // If at or above soft limit, partition the remaining space into at most 64 segments and + // allow one C++ recursion of drain() per segment, plus one for the fence post. + const quintptr segmentSize = qNextPowerOfTwo(quintptr(m_hardLimit - m_softLimit) / 64u); + if (m_drainRecursion * segmentSize <= quintptr(m_top - m_softLimit)) { + ++m_drainRecursion; + drain(); + --m_drainRecursion; + } else if (m_top == m_hardLimit) { + qFatal("GC mark stack overrun. Either simplify your application or" + "increase QV4_GC_MAX_STACK_SIZE"); + } + } + + bool isEmpty() const { return m_top == m_base; } + + qptrdiff remainingBeforeSoftLimit() const + { + return m_softLimit - m_top; + } + + ExecutionEngine *engine() const { return m_engine; } + + void drain(); + enum class DrainState { Ongoing, Complete }; + DrainState drain(QDeadlineTimer deadline); + void setSoftLimit(size_t size); +private: + Heap::Base *pop() { return *(--m_top); } + + Heap::Base **m_top = nullptr; + Heap::Base **m_base = nullptr; + Heap::Base **m_softLimit = nullptr; + Heap::Base **m_hardLimit = nullptr; + + ExecutionEngine *m_engine = nullptr; + + quintptr m_drainRecursion = 0; +}; + +// Some helper to automate the generation of our +// functions used for marking objects + +#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION(c, gcType, type, name) \ + HEAP_OBJECT_OFFSET_MEMBER_EXPANSION_##gcType(c, type, name) + +#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION_Pointer(c, type, name) Pointer<type, 0> name; +#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION_NoMark(c, type, name) type name; +#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION_HeapValue(c, type, name) HeapValue<0> name; +#define HEAP_OBJECT_OFFSET_MEMBER_EXPANSION_ValueArray(c, type, name) type<0> name; + +#define HEAP_OBJECT_MEMBER_EXPANSION(c, gcType, type, name) \ + HEAP_OBJECT_MEMBER_EXPANSION_##gcType(c, type, name) + +#define HEAP_OBJECT_MEMBER_EXPANSION_Pointer(c, type, name) \ + Pointer<type, offsetof(c##OffsetStruct, name) + baseOffset> name; +#define HEAP_OBJECT_MEMBER_EXPANSION_NoMark(c, type, name) \ + type name; +#define HEAP_OBJECT_MEMBER_EXPANSION_HeapValue(c, type, name) \ + HeapValue<offsetof(c##OffsetStruct, name) + baseOffset> name; +#define HEAP_OBJECT_MEMBER_EXPANSION_ValueArray(c, type, name) \ + type<offsetof(c##OffsetStruct, name) + baseOffset> name; + +#define HEAP_OBJECT_MARKOBJECTS_EXPANSION(c, gcType, type, name) \ + HEAP_OBJECT_MARKOBJECTS_EXPANSION_##gcType(c, type, name) +#define HEAP_OBJECT_MARKOBJECTS_EXPANSION_Pointer(c, type, name) \ + if (o->name) o->name.heapObject()->mark(stack); +#define HEAP_OBJECT_MARKOBJECTS_EXPANSION_NoMark(c, type, name) +#define HEAP_OBJECT_MARKOBJECTS_EXPANSION_HeapValue(c, type, name) \ + o->name.mark(stack); +#define HEAP_OBJECT_MARKOBJECTS_EXPANSION_ValueArray(c, type, name) \ + o->name.mark(stack); + + +#define DECLARE_HEAP_OBJECT_BASE(name, base) \ + struct name##OffsetStruct { \ + name##Members(name, HEAP_OBJECT_OFFSET_MEMBER_EXPANSION) \ + }; \ + struct name##SizeStruct : base, name##OffsetStruct {}; \ + struct name##Data { \ + typedef base SuperClass; \ + static constexpr size_t baseOffset = sizeof(name##SizeStruct) - sizeof(name##OffsetStruct); \ + name##Members(name, HEAP_OBJECT_MEMBER_EXPANSION) \ + }; \ + Q_STATIC_ASSERT(sizeof(name##SizeStruct) == sizeof(name##Data) + name##Data::baseOffset); \ + +#define DECLARE_HEAP_OBJECT(name, base) \ + DECLARE_HEAP_OBJECT_BASE(name, base) \ + struct name : base, name##Data +#define DECLARE_EXPORTED_HEAP_OBJECT(name, base) \ + DECLARE_HEAP_OBJECT_BASE(name, base) \ + struct Q_QML_EXPORT name : base, name##Data + +#define DECLARE_MARKOBJECTS(class) \ + static void markObjects(Heap::Base *b, MarkStack *stack) { \ + class *o = static_cast<class *>(b); \ + class##Data::SuperClass::markObjects(o, stack); \ + class##Members(class, HEAP_OBJECT_MARKOBJECTS_EXPANSION) \ + } + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4module_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4module_p.h new file mode 100644 index 0000000000000000000000000000000000000000..70f74241502e22080ae9a8746ffda271af28da80 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4module_p.h @@ -0,0 +1,63 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4MODULE +#define QV4MODULE + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4context_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +#define ModuleMembers(class, Member) \ + Member(class, NoMark, ExecutableCompilationUnit *, unit) \ + Member(class, Pointer, CallContext *, scope) \ + Member(class, HeapValue, HeapValue, self) \ + Member(class, NoMark, bool, evaluated) + +DECLARE_EXPORTED_HEAP_OBJECT(Module, Object) { + DECLARE_MARKOBJECTS(Module) + + void init(ExecutionEngine *engine, ExecutableCompilationUnit *moduleUnit); +}; + +} + +struct Q_QML_EXPORT Module : public Object { + V4_OBJECT2(Module, Object) + + void evaluate(); + const Value *resolveExport(PropertyKey key) const; + + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p); + static bool virtualHasProperty(const Managed *m, PropertyKey id); + static bool virtualPreventExtensions(Managed *); + static bool virtualDefineOwnProperty(Managed *, PropertyKey, const Property *, PropertyAttributes); + static bool virtualPut(Managed *, PropertyKey, const Value &, Value *); + static bool virtualDeleteProperty(Managed *m, PropertyKey id); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); + static Heap::Object *virtualGetPrototypeOf(const Managed *); + static bool virtualSetPrototypeOf(Managed *, const Object *proto); + static bool virtualIsExtensible(const Managed *); +}; + +} + +QT_END_NAMESPACE + +#endif // QV4MODULE diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4numberobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4numberobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..51869a2c5ebb0cc9b034ea650f9db2479009cd0e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4numberobject_p.h @@ -0,0 +1,72 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4NUMBEROBJECT_H +#define QV4NUMBEROBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" +#include <QtCore/qnumeric.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct NumberCtor : FunctionObject { + void init(ExecutionEngine *engine); +}; + +} + +class NumberLocale : public QLocale +{ +public: + static const NumberLocale *instance(); + const int defaultDoublePrecision; +protected: + NumberLocale(); +}; + +struct NumberCtor: FunctionObject +{ + V4_OBJECT2(NumberCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +struct NumberPrototype: NumberObject +{ + V4_PROTOTYPE(objectPrototype) + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_isFinite(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isInteger(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isSafeInteger(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isNaN(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toLocaleString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toFixed(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toExponential(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toPrecision(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + + +} + +QT_END_NAMESPACE + +#endif // QV4ECMAOBJECTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4object_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4object_p.h new file mode 100644 index 0000000000000000000000000000000000000000..13320dad09e716b7f03f44f0ef130546ccec9ebc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4object_p.h @@ -0,0 +1,528 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4_OBJECT_H +#define QV4_OBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4managed_p.h" +#include "qv4memberdata_p.h" +#include "qv4arraydata_p.h" +#include "qv4engine_p.h" +#include "qv4scopedvalue_p.h" +#include "qv4value_p.h" +#include "qv4internalclass_p.h" + +QT_BEGIN_NAMESPACE + + +namespace QV4 { + +namespace Heap { + +#define ObjectMembers(class, Member) \ + Member(class, Pointer, MemberData *, memberData) \ + Member(class, Pointer, ArrayData *, arrayData) + +DECLARE_EXPORTED_HEAP_OBJECT(Object, Base) { + static void markObjects(Heap::Base *base, MarkStack *stack); + void init() { Base::init(); } + + const VTable *vtable() const { + return internalClass->vtable; + } + + const Value *inlinePropertyDataWithOffset(uint indexWithOffset) const { + Q_ASSERT(indexWithOffset >= vtable()->inlinePropertyOffset && indexWithOffset < uint(vtable()->inlinePropertyOffset + vtable()->nInlineProperties)); + return reinterpret_cast<const Value *>(this) + indexWithOffset; + } + const Value *inlinePropertyData(uint index) const { + Q_ASSERT(index < vtable()->nInlineProperties); + return reinterpret_cast<const Value *>(this) + vtable()->inlinePropertyOffset + index; + } + void setInlinePropertyWithOffset(ExecutionEngine *e, uint indexWithOffset, Value v) { + Q_ASSERT(indexWithOffset >= vtable()->inlinePropertyOffset && indexWithOffset < uint(vtable()->inlinePropertyOffset + vtable()->nInlineProperties)); + Value *prop = reinterpret_cast<Value *>(this) + indexWithOffset; + WriteBarrier::write(e, this, prop->data_ptr(), v.asReturnedValue()); + } + void setInlinePropertyWithOffset(ExecutionEngine *e, uint indexWithOffset, Heap::Base *b) { + Q_ASSERT(indexWithOffset >= vtable()->inlinePropertyOffset && indexWithOffset < uint(vtable()->inlinePropertyOffset + vtable()->nInlineProperties)); + Value *prop = reinterpret_cast<Value *>(this) + indexWithOffset; + WriteBarrier::write(e, this, prop->data_ptr(), Value::fromHeapObject(b).asReturnedValue()); + } + + PropertyIndex writablePropertyData(uint index) { + uint nInline = vtable()->nInlineProperties; + if (index < nInline) + return PropertyIndex{ this, reinterpret_cast<Value *>(this) + vtable()->inlinePropertyOffset + index}; + index -= nInline; + return PropertyIndex{ memberData, memberData->values.values + index }; + } + + const Value *propertyData(uint index) const { + uint nInline = vtable()->nInlineProperties; + if (index < nInline) + return reinterpret_cast<const Value *>(this) + vtable()->inlinePropertyOffset + index; + index -= nInline; + return memberData->values.data() + index; + } + void setProperty(ExecutionEngine *e, uint index, Value v) { + uint nInline = vtable()->nInlineProperties; + if (index < nInline) { + setInlinePropertyWithOffset(e, index + vtable()->inlinePropertyOffset, v); + return; + } + index -= nInline; + memberData->values.set(e, index, v); + } + void setProperty(ExecutionEngine *e, uint index, Heap::Base *b) { + uint nInline = vtable()->nInlineProperties; + if (index < nInline) { + setInlinePropertyWithOffset(e, index + vtable()->inlinePropertyOffset, b); + return; + } + index -= nInline; + memberData->values.set(e, index, b); + } + + void setUsedAsProto(); + + Heap::Object *prototype() const { return internalClass->prototype; } +}; + +} + +struct Q_QML_EXPORT Object: Managed { + V4_OBJECT2(Object, Object) + Q_MANAGED_TYPE(Object) + V4_INTERNALCLASS(Object) + V4_PROTOTYPE(objectPrototype) + + enum { NInlineProperties = 2 }; + + enum { + IsObject = true, + GetterOffset = 0, + SetterOffset = 1 + }; + + void setInternalClass(Heap::InternalClass *ic); + + const Value *propertyData(uint index) const { return d()->propertyData(index); } + + Heap::ArrayData *arrayData() const { return d()->arrayData; } + void setArrayData(ArrayData *a) { d()->arrayData.set(engine(), a ? a->d() : nullptr); } + + void getProperty(const InternalClassEntry &entry, Property *p) const; + void setProperty(const InternalClassEntry &entry, const Property *p); + void setProperty(uint index, Value v) const { d()->setProperty(engine(), index, v); } + void setProperty(uint index, Heap::Base *b) const { d()->setProperty(engine(), index, b); } + void setProperty(ExecutionEngine *engine, uint index, Value v) const { d()->setProperty(engine, index, v); } + void setProperty(ExecutionEngine *engine, uint index, Heap::Base *b) const { d()->setProperty(engine, index, b); } + + const VTable *vtable() const { return d()->vtable(); } + + PropertyAttributes getOwnProperty(PropertyKey id, Property *p = nullptr) const { + return vtable()->getOwnProperty(this, id, p); + } + + PropertyIndex getValueOrSetter(PropertyKey id, PropertyAttributes *attrs); + + bool hasProperty(PropertyKey id) const { + return vtable()->hasProperty(this, id); + } + + bool defineOwnProperty(PropertyKey id, const Property *p, PropertyAttributes attrs) { + return vtable()->defineOwnProperty(this, id, p, attrs); + } + + // + // helpers + // + static ReturnedValue getValue(const Value *thisObject, const Value &v, PropertyAttributes attrs) { + if (attrs.isData()) + return v.asReturnedValue(); + return getValueAccessor(thisObject, v, attrs); + } + ReturnedValue getValue(const Value &v, PropertyAttributes attrs) const { + return getValue(this, v, attrs); + } + ReturnedValue getValueByIndex(uint propertyIndex) const { + PropertyAttributes attrs = internalClass()->propertyData.at(propertyIndex); + const Value *v = propertyData(propertyIndex); + if (!attrs.isAccessor()) + return v->asReturnedValue(); + return getValueAccessor(this, *v, attrs); + } + static ReturnedValue getValueAccessor(const Value *thisObject, const Value &v, PropertyAttributes attrs); + + bool putValue(uint memberIndex, PropertyAttributes attrs, const Value &value); + + /* The spec default: Writable: true, Enumerable: false, Configurable: true */ + void defineDefaultProperty(StringOrSymbol *name, const Value &value, PropertyAttributes attributes = Attr_Data|Attr_NotEnumerable) { + insertMember(name, value, attributes); + } + void defineDefaultProperty(const QString &name, const Value &value, PropertyAttributes attributes = Attr_Data|Attr_NotEnumerable); + void defineDefaultProperty(const QString &name, VTable::Call code, + int argumentCount = 0, PropertyAttributes attributes = Attr_Data|Attr_NotEnumerable); + void defineDefaultProperty(StringOrSymbol *name, VTable::Call code, + int argumentCount = 0, PropertyAttributes attributes = Attr_Data|Attr_NotEnumerable); + void defineAccessorProperty(const QString &name, VTable::Call getter, VTable::Call setter); + void defineAccessorProperty(StringOrSymbol *name, VTable::Call getter, VTable::Call setter); + /* Fixed: Writable: false, Enumerable: false, Configurable: false */ + void defineReadonlyProperty(const QString &name, const Value &value); + void defineReadonlyProperty(String *name, const Value &value); + + /* Fixed: Writable: false, Enumerable: false, Configurable: true */ + void defineReadonlyConfigurableProperty(const QString &name, const Value &value); + void defineReadonlyConfigurableProperty(StringOrSymbol *name, const Value &value); + + void addSymbolSpecies(); + + void insertMember(StringOrSymbol *s, const Value &v, PropertyAttributes attributes = Attr_Data) { + Scope scope(engine()); + ScopedProperty p(scope); + p->value = v; + insertMember(s, p, attributes); + } + void insertMember(StringOrSymbol *s, const Property *p, PropertyAttributes attributes); + + bool isExtensible() const { return vtable()->isExtensible(this); } + bool preventExtensions() { return vtable()->preventExtensions(this); } + Heap::Object *getPrototypeOf() const { return vtable()->getPrototypeOf(this); } + bool setPrototypeOf(const Object *p) { return vtable()->setPrototypeOf(this, p); } + void setPrototypeUnchecked(const Object *p); + + // Array handling + +public: + void copyArrayData(Object *other); + + bool setArrayLength(uint newLen); + void setArrayLengthUnchecked(uint l); + + void arraySet(uint index, const Property *p, PropertyAttributes attributes = Attr_Data); + void arraySet(uint index, const Value &value); + + bool arrayPut(uint index, const Value &value) { + return arrayData()->vtable()->put(this, index, value); + } + bool arrayPut(uint index, const Value *values, uint n) { + return arrayData()->vtable()->putArray(this, index, values, n); + } + void setArrayAttributes(uint i, PropertyAttributes a) { + Q_ASSERT(arrayData()); + if (d()->arrayData->attrs || a != Attr_Data) { + ArrayData::ensureAttributes(this); + a.resolve(); + arrayData()->vtable()->setAttribute(this, i, a); + } + } + + void push_back(const Value &v); + + ArrayData::Type arrayType() const { + return arrayData() ? static_cast<ArrayData::Type>(d()->arrayData->type) : Heap::ArrayData::Simple; + } + // ### remove me + void setArrayType(ArrayData::Type t) { + Q_ASSERT(t != Heap::ArrayData::Simple && t != Heap::ArrayData::Sparse); + arrayCreate(); + d()->arrayData->type = t; + } + + inline void arrayReserve(uint n) { + ArrayData::realloc(this, Heap::ArrayData::Simple, n, false); + } + + void arrayCreate() { + if (!arrayData()) + ArrayData::realloc(this, Heap::ArrayData::Simple, 0, false); +#ifdef CHECK_SPARSE_ARRAYS + initSparseArray(); +#endif + } + + void initSparseArray(); + SparseArrayNode *sparseBegin() const { return arrayType() == Heap::ArrayData::Sparse ? d()->arrayData->sparse->begin() : nullptr; } + SparseArrayNode *sparseEnd() const { return arrayType() == Heap::ArrayData::Sparse ? d()->arrayData->sparse->end() : nullptr; } + + inline bool protoHasArray() { + Scope scope(engine()); + ScopedObject p(scope, this); + + while ((p = p->getPrototypeOf())) + if (p->arrayData()) + return true; + + return false; + } + + inline ReturnedValue get(StringOrSymbol *name, bool *hasProperty = nullptr, const Value *receiver = nullptr) const + { if (!receiver) receiver = this; return vtable()->get(this, name->toPropertyKey(), receiver, hasProperty); } + inline ReturnedValue get(uint idx, bool *hasProperty = nullptr, const Value *receiver = nullptr) const + { if (!receiver) receiver = this; return vtable()->get(this, PropertyKey::fromArrayIndex(idx), receiver, hasProperty); } + QT_DEPRECATED inline ReturnedValue getIndexed(uint idx, bool *hasProperty = nullptr) const + { return get(idx, hasProperty); } + inline ReturnedValue get(PropertyKey id, const Value *receiver = nullptr, bool *hasProperty = nullptr) const + { if (!receiver) receiver = this; return vtable()->get(this, id, receiver, hasProperty); } + + // use the set variants instead, to customize throw behavior + inline bool put(StringOrSymbol *name, const Value &v, Value *receiver = nullptr) + { if (!receiver) receiver = this; return vtable()->put(this, name->toPropertyKey(), v, receiver); } + inline bool put(uint idx, const Value &v, Value *receiver = nullptr) + { if (!receiver) receiver = this; return vtable()->put(this, PropertyKey::fromArrayIndex(idx), v, receiver); } + QT_DEPRECATED inline bool putIndexed(uint idx, const Value &v) + { return put(idx, v); } + inline bool put(PropertyKey id, const Value &v, Value *receiver = nullptr) + { if (!receiver) receiver = this; return vtable()->put(this, id, v, receiver); } + + enum ThrowOnFailure { + DoThrowOnRejection, + DoNotThrow + }; + + // This is the same as set(), but it doesn't require creating a string key, + // which is much more efficient for the array case. + inline bool setIndexed(uint idx, const Value &v, ThrowOnFailure shouldThrow) + { + bool ret = vtable()->put(this, PropertyKey::fromArrayIndex(idx), v, this); + // ES6: 7.3.3, 6: If success is false and Throw is true, throw a TypeError exception. + if (!ret && shouldThrow == ThrowOnFailure::DoThrowOnRejection) { + ExecutionEngine *e = engine(); + if (!e->hasException) { // allow a custom set impl to throw itself + QString message = QLatin1String("Cannot assign to read-only property \"") + + QString::number(idx) + QLatin1Char('\"'); + e->throwTypeError(message); + } + } + return ret; + } + + // ES6: 7.3.3 Set (O, P, V, Throw) + inline bool set(StringOrSymbol *name, const Value &v, ThrowOnFailure shouldThrow) + { + bool ret = vtable()->put(this, name->toPropertyKey(), v, this); + // ES6: 7.3.3, 6: If success is false and Throw is true, throw a TypeError exception. + if (!ret && shouldThrow == ThrowOnFailure::DoThrowOnRejection) { + ExecutionEngine *e = engine(); + if (!e->hasException) { // allow a custom set impl to throw itself + QString message = QLatin1String("Cannot assign to read-only property \"") + + name->toQString() + QLatin1Char('\"'); + e->throwTypeError(message); + } + } + return ret; + } + + bool deleteProperty(PropertyKey id) + { return vtable()->deleteProperty(this, id); } + OwnPropertyKeyIterator *ownPropertyKeys(Value *target) const + { return vtable()->ownPropertyKeys(this, target); } + qint64 getLength() const { return vtable()->getLength(this); } + ReturnedValue instanceOf(const Value &var) const + { return vtable()->instanceOf(this, var); } + + bool isConcatSpreadable() const; + bool isArray() const; + const FunctionObject *speciesConstructor(Scope &scope, const FunctionObject *defaultConstructor) const; + + bool setProtoFromNewTarget(const Value *newTarget); + + ReturnedValue resolveLookupGetter(ExecutionEngine *engine, Lookup *lookup) const + { return vtable()->resolveLookupGetter(this, engine, lookup); } + ReturnedValue resolveLookupSetter(ExecutionEngine *engine, Lookup *lookup, const Value &value) + { return vtable()->resolveLookupSetter(this, engine, lookup, value); } + + int metacall(QMetaObject::Call call, int index, void **a) + { return vtable()->metacall(this, call, index, a); } + +protected: + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver,bool *hasProperty); + static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static bool virtualDeleteProperty(Managed *m, PropertyKey id); + static bool virtualHasProperty(const Managed *m, PropertyKey id); + static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p); + static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs); + static bool virtualIsExtensible(const Managed *m); + static bool virtualPreventExtensions(Managed *); + static Heap::Object *virtualGetPrototypeOf(const Managed *); + static bool virtualSetPrototypeOf(Managed *, const Object *); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); + static qint64 virtualGetLength(const Managed *m); + static ReturnedValue virtualInstanceOf(const Object *typeObject, const Value &var); + static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup); + static bool virtualResolveLookupSetter(Object *object, ExecutionEngine *engine, Lookup *lookup, const Value &value); + static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a); +public: + // qv4runtime uses this directly + static ReturnedValue checkedInstanceOf(ExecutionEngine *engine, const FunctionObject *typeObject, const Value &var); + +private: + bool internalDefineOwnProperty(ExecutionEngine *engine, uint index, const InternalClassEntry *memberEntry, const Property *p, PropertyAttributes attrs); + ReturnedValue internalGet(PropertyKey id, const Value *receiver, bool *hasProperty) const; + bool internalPut(PropertyKey id, const Value &value, Value *receiver); + bool internalDeleteProperty(PropertyKey id); + + friend struct ObjectIterator; + friend struct ObjectPrototype; +}; + +struct Q_QML_EXPORT ObjectOwnPropertyKeyIterator : OwnPropertyKeyIterator +{ + uint arrayIndex = 0; + uint memberIndex = 0; + bool iterateOverSymbols = false; + ~ObjectOwnPropertyKeyIterator() override = default; + PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override; + +}; + +namespace Heap { + +struct BooleanObject : Object { + void init() { Object::init(); } + void init(bool b) { + Object::init(); + this->b = b; + } + + bool b; +}; + +struct NumberObject : Object { + void init() { Object::init(); } + void init(double val) { + Object::init(); + value = val; + } + + double value; +}; + +struct ArrayObject : Object { + enum { + LengthPropertyIndex = 0 + }; + + void init() { + Object::init(); + commonInit(); + } + + void init(const QStringList &list); + +private: + void commonInit() + { setProperty(internalClass->engine, LengthPropertyIndex, Value::fromInt32(0)); } +}; + +} + +struct BooleanObject: Object { + V4_OBJECT2(BooleanObject, Object) + Q_MANAGED_TYPE(BooleanObject) + V4_PROTOTYPE(booleanPrototype) + + bool value() const { return d()->b; } + +}; + +struct NumberObject: Object { + V4_OBJECT2(NumberObject, Object) + Q_MANAGED_TYPE(NumberObject) + V4_PROTOTYPE(numberPrototype) + + double value() const { return d()->value; } +}; + +struct ArrayObject: Object { + V4_OBJECT2(ArrayObject, Object) + Q_MANAGED_TYPE(ArrayObject) + V4_INTERNALCLASS(ArrayObject) + V4_PROTOTYPE(arrayPrototype) + + void init(ExecutionEngine *engine); + + static qint64 virtualGetLength(const Managed *m); + + QStringList toQStringList() const; +protected: + static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs); + +}; + +inline void Object::setArrayLengthUnchecked(uint l) +{ + if (isArrayObject()) + setProperty(Heap::ArrayObject::LengthPropertyIndex, Value::fromUInt32(l)); +} + +inline void Object::push_back(const Value &v) +{ + arrayCreate(); + + const auto length = getLength(); + if (Q_UNLIKELY(length == std::numeric_limits<uint>::max())) { + engine()->throwRangeError(QLatin1String("Too many elements.")); + return; + } + uint idx = uint(length); + arrayReserve(idx + 1); + arrayPut(idx, v); + setArrayLengthUnchecked(idx + 1); +} + +inline void Object::arraySet(uint index, const Property *p, PropertyAttributes attributes) +{ + // ### Clean up + arrayCreate(); + if (attributes.isAccessor() || (index > 0x1000 && index > 2*d()->arrayData->values.alloc)) { + initSparseArray(); + } else { + arrayData()->vtable()->reallocate(this, index + 1, false); + } + setArrayAttributes(index, attributes); + ArrayData::insert(this, index, &p->value, attributes.isAccessor()); + if (isArrayObject() && index >= getLength()) + setArrayLengthUnchecked(index + 1); +} + + +inline void Object::arraySet(uint index, const Value &value) +{ + arrayCreate(); + if (index > 0x1000 && index > 2*d()->arrayData->values.alloc) { + initSparseArray(); + } + ArrayData::insert(this, index, &value); + if (isArrayObject() && index >= getLength()) + setArrayLengthUnchecked(index + 1); +} + + +template<> +inline const ArrayObject *Value::as() const { + return isManaged() && m()->internalClass->vtable->type == Managed::Type_ArrayObject ? static_cast<const ArrayObject *>(this) : nullptr; +} + +template<> +inline ReturnedValue value_convert<Object>(ExecutionEngine *e, const Value &v) +{ + return v.toObject(e)->asReturnedValue(); +} + +} + +QT_END_NAMESPACE + +#endif // QMLJS_OBJECTS_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4objectiterator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4objectiterator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a5019679f02509e4c40ea9ce71baadb73862b5a0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4objectiterator_p.h @@ -0,0 +1,111 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4OBJECTITERATOR_H +#define QV4OBJECTITERATOR_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" +#include "qv4object_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct Q_QML_EXPORT ObjectIterator +{ + enum Flags { + NoFlags = 0, + EnumerableOnly = 0x1, + WithSymbols = 0x2 + }; + + ExecutionEngine *engine; + Object *object; + OwnPropertyKeyIterator *iterator = nullptr; + uint flags; + + ObjectIterator(Scope &scope, const Object *o, uint flags) + { + engine = scope.engine; + object = static_cast<Object *>(scope.alloc()); + this->flags = flags; + object->setM(o ? o->m() : nullptr); + if (o) + iterator = object->ownPropertyKeys(object); + } + ~ObjectIterator() + { + delete iterator; + } + + PropertyKey next(Property *pd = nullptr, PropertyAttributes *attributes = nullptr); + ReturnedValue nextPropertyName(Value *value); + ReturnedValue nextPropertyNameAsString(Value *value); + ReturnedValue nextPropertyNameAsString(); +}; + +namespace Heap { + +#define ForInIteratorObjectMembers(class, Member) \ + Member(class, Pointer, Object *, object) \ + Member(class, Pointer, Object *, current) \ + Member(class, Pointer, Object *, target) \ + Member(class, NoMark, OwnPropertyKeyIterator *, iterator) + +DECLARE_HEAP_OBJECT(ForInIteratorObject, Object) { + void init(QV4::Object *o); + Value workArea[2]; + + static void markObjects(Heap::Base *that, MarkStack *markStack); + void destroy(); +}; + +} + +struct ForInIteratorPrototype : Object +{ + V4_PROTOTYPE(iteratorPrototype) + void init(ExecutionEngine *engine); + + static ReturnedValue method_next(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); +}; + +struct ForInIteratorObject: Object { + V4_OBJECT2(ForInIteratorObject, Object) + Q_MANAGED_TYPE(ForInIterator) + V4_PROTOTYPE(forInIteratorPrototype) + V4_NEEDS_DESTROY + + PropertyKey nextProperty() const; +}; + +inline +void Heap::ForInIteratorObject::init(QV4::Object *o) +{ + Object::init(); + if (!o) + return; + object.set(o->engine(), o->d()); + current.set(o->engine(), o->d()); + Scope scope(o); + ScopedObject obj(scope); + iterator = o->ownPropertyKeys(obj.getRef()); + target.set(o->engine(), obj->d()); +} + + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4objectproto_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4objectproto_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1e9783812d8a2c6d282eaccb3927575c6fc4d09b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4objectproto_p.h @@ -0,0 +1,90 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4ECMAOBJECTS_P_H +#define QV4ECMAOBJECTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" +#include <QtCore/qnumeric.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct ObjectCtor : FunctionObject { + void init(ExecutionEngine *engine); +}; + +} + +struct ObjectCtor: FunctionObject +{ + V4_OBJECT2(ObjectCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *m, const Value *thisObject, const Value *argv, int argc); +}; + +struct Q_QML_EXPORT ObjectPrototype: Object +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_assign(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_create(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_defineProperties(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_defineProperty(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_freeze(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getOwnPropertyDescriptor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getOwnPropertyDescriptors(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getOwnPropertyNames(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getOwnPropertySymbols(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getPrototypeOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_is(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isExtensible(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isFrozen(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isSealed(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_preventExtensions(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_seal(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setPrototypeOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toLocaleString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_hasOwnProperty(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isPrototypeOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_propertyIsEnumerable(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_defineGetter(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_defineSetter(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_get_proto(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_set_proto(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static void toPropertyDescriptor(ExecutionEngine *engine, const Value &v, Property *desc, PropertyAttributes *attrs); + static ReturnedValue fromPropertyDescriptor(ExecutionEngine *engine, const Property *desc, PropertyAttributes attrs); + + static Heap::ArrayObject *getOwnPropertyNames(ExecutionEngine *v4, const Value &o); +}; + + +} + +QT_END_NAMESPACE + +#endif // QV4ECMAOBJECTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4persistent_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4persistent_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0378ba3737e0a7d8d4b1cc83e5160bb8e4312964 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4persistent_p.h @@ -0,0 +1,183 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4PERSISTENT_H +#define QV4PERSISTENT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4value_p.h" +#include "qv4managed_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct Q_QML_EXPORT PersistentValueStorage +{ + PersistentValueStorage(ExecutionEngine *engine); + ~PersistentValueStorage(); + + Value *allocate(); + static void free(Value *v) + { + if (v) + freeUnchecked(v); + } + + void mark(MarkStack *markStack); + + struct Iterator { + Iterator(void *p, int idx); + Iterator(const Iterator &o); + Iterator & operator=(const Iterator &o); + ~Iterator(); + void *p; + int index; + Iterator &operator++(); + bool operator !=(const Iterator &other) { + return p != other.p || index != other.index; + } + Value &operator *(); + }; + Iterator begin() { return Iterator(firstPage, 0); } + Iterator end() { return Iterator(nullptr, 0); } + + void clearFreePageHint(); + + static ExecutionEngine *getEngine(const Value *v); + + ExecutionEngine *engine; + void *firstPage; + void *freePageHint = nullptr; +private: + static void freeUnchecked(Value *v); + static void freePage(void *page); +}; + +class Q_QML_EXPORT PersistentValue +{ +public: + constexpr PersistentValue() noexcept = default; + PersistentValue(const PersistentValue &other); + PersistentValue &operator=(const PersistentValue &other); + + PersistentValue(PersistentValue &&other) noexcept : val(std::exchange(other.val, nullptr)) {} + void swap(PersistentValue &other) noexcept { qt_ptr_swap(val, other.val); } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(PersistentValue) + ~PersistentValue() { PersistentValueStorage::free(val); } + + PersistentValue &operator=(const WeakValue &other); + PersistentValue &operator=(Object *object); + + PersistentValue(ExecutionEngine *engine, const Value &value); + PersistentValue(ExecutionEngine *engine, ReturnedValue value); + PersistentValue(ExecutionEngine *engine, Object *object); + + void set(ExecutionEngine *engine, const Value &value); + void set(ExecutionEngine *engine, ReturnedValue value); + void set(ExecutionEngine *engine, Heap::Base *obj); + + ReturnedValue value() const { + return (val ? val->asReturnedValue() : Encode::undefined()); + } + Value *valueRef() const { + return val; + } + Managed *asManaged() const { + if (!val) + return nullptr; + return val->managed(); + } + template<typename T> + T *as() const { + if (!val) + return nullptr; + return val->as<T>(); + } + + ExecutionEngine *engine() const { + if (!val) + return nullptr; + return PersistentValueStorage::getEngine(val); + } + + bool isUndefined() const { return !val || val->isUndefined(); } + bool isNullOrUndefined() const { return !val || val->isNullOrUndefined(); } + void clear() { + PersistentValueStorage::free(val); + val = nullptr; + } + bool isEmpty() { return !val; } + +private: + Value *val = nullptr; +}; + +class Q_QML_EXPORT WeakValue +{ +public: + WeakValue() {} + WeakValue(const WeakValue &other); + WeakValue(ExecutionEngine *engine, const Value &value); + WeakValue &operator=(const WeakValue &other); + ~WeakValue(); + + void set(ExecutionEngine *engine, const Value &value); + + void set(ExecutionEngine *engine, ReturnedValue value); + + void set(ExecutionEngine *engine, Heap::Base *obj); + + ReturnedValue value() const { + return (val ? val->asReturnedValue() : Encode::undefined()); + } + Value *valueRef() const { + return val; + } + Managed *asManaged() const { + if (!val) + return nullptr; + return val->managed(); + } + template <typename T> + T *as() const { + if (!val) + return nullptr; + return val->as<T>(); + } + + ExecutionEngine *engine() const { + if (!val) + return nullptr; + return PersistentValueStorage::getEngine(val); + } + + bool isUndefined() const { return !val || val->isUndefined(); } + bool isNullOrUndefined() const { return !val || val->isNullOrUndefined(); } + void clear() { free(); } + + void markOnce(MarkStack *markStack); + +private: + Value *val = nullptr; + +private: + Q_NEVER_INLINE void allocVal(ExecutionEngine *engine); + + void free(); +}; + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4profiling_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4profiling_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8ac1197110969cfb730d16e8640bdff483e6031c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4profiling_p.h @@ -0,0 +1,298 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4PROFILING_H +#define QV4PROFILING_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qv4global_p.h> +#include "qv4engine_p.h" +#include "qv4function_p.h" + +#include <QElapsedTimer> + +#if !QT_CONFIG(qml_debug) + +#define Q_V4_PROFILE_ALLOC(engine, size, type) Q_UNUSED(engine) +#define Q_V4_PROFILE_DEALLOC(engine, size, type) Q_UNUSED(engine) + +QT_BEGIN_NAMESPACE + +namespace QV4 { +namespace Profiling { +class Profiler {}; +class FunctionCallProfiler { +public: + FunctionCallProfiler(ExecutionEngine *, Function *) {} +}; +} +} + +QT_END_NAMESPACE + +#else + +#define Q_V4_PROFILE_ALLOC(engine, size, type)\ + (engine->profiler() &&\ + (engine->profiler()->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\ + engine->profiler()->trackAlloc(size, type) : false) + +#define Q_V4_PROFILE_DEALLOC(engine, size, type) \ + (engine->profiler() &&\ + (engine->profiler()->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\ + engine->profiler()->trackDealloc(size, type) : false) + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Profiling { + +enum Features { + FeatureFunctionCall, + FeatureMemoryAllocation +}; + +enum MemoryType { + HeapPage, + LargeItem, + SmallItem +}; + +struct FunctionCallProperties { + qint64 start; + qint64 end; + quintptr id; +}; + +struct FunctionLocation { + FunctionLocation(const QString &name = QString(), const QString &file = QString(), + int line = -1, int column = -1) : + name(name), file(file), line(line), column(column) + {} + + bool isValid() + { + return !name.isEmpty(); + } + + QString name; + QString file; + int line; + int column; +}; + +typedef QHash<quintptr, QV4::Profiling::FunctionLocation> FunctionLocationHash; + +struct MemoryAllocationProperties { + qint64 timestamp; + qint64 size; + MemoryType type; +}; + +class FunctionCall { +public: + FunctionCall() : m_function(nullptr), m_start(0), m_end(0) {} + + FunctionCall(Function *function, qint64 start, qint64 end) : + m_function(function), m_start(start), m_end(end) + { m_function->executableCompilationUnit()->addref(); } + + FunctionCall(const FunctionCall &other) : + m_function(other.m_function), m_start(other.m_start), m_end(other.m_end) + { m_function->executableCompilationUnit()->addref(); } + + FunctionCall(FunctionCall &&other) noexcept + : m_function(std::exchange(other.m_function, nullptr)) + , m_start(std::exchange(other.m_start, 0)) + , m_end(std::exchange(other.m_end, 0)) + {} + + ~FunctionCall() + { + if (m_function) + m_function->executableCompilationUnit()->release(); + } + + FunctionCall &operator=(const FunctionCall &other) { + if (&other != this) { + if (other.m_function) + other.m_function->executableCompilationUnit()->addref(); + if (m_function) + m_function->executableCompilationUnit()->release(); + m_function = other.m_function; + m_start = other.m_start; + m_end = other.m_end; + } + return *this; + } + + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(FunctionCall) + + void swap(FunctionCall &other) noexcept + { + qt_ptr_swap(m_function, other.m_function); + std::swap(m_start, other.m_start); + std::swap(m_end, other.m_end); + } + + Function *function() const + { + return m_function; + } + + FunctionLocation resolveLocation() const; + FunctionCallProperties properties() const; + +private: + friend bool operator<(const FunctionCall &call1, const FunctionCall &call2); + + Function *m_function; + qint64 m_start; + qint64 m_end; +}; + +class Q_QML_EXPORT Profiler : public QObject { + Q_OBJECT +public: + struct SentMarker { + SentMarker() : m_function(nullptr) {} + + SentMarker(const SentMarker &other) : m_function(other.m_function) + { + if (m_function) + m_function->executableCompilationUnit()->addref(); + } + + ~SentMarker() + { + if (m_function) + m_function->executableCompilationUnit()->release(); + } + + SentMarker &operator=(const SentMarker &other) + { + if (&other != this) { + if (m_function) + m_function->executableCompilationUnit()->release(); + m_function = other.m_function; + m_function->executableCompilationUnit()->addref(); + } + return *this; + } + + void setFunction(Function *function) + { + Q_ASSERT(m_function == nullptr); + m_function = function; + m_function->executableCompilationUnit()->addref(); + } + + bool isValid() const + { return m_function != nullptr; } + + private: + Function *m_function; + }; + + Profiler(QV4::ExecutionEngine *engine); + + bool trackAlloc(size_t size, MemoryType type) + { + if (size) { + MemoryAllocationProperties allocation = {m_timer.nsecsElapsed(), (qint64)size, type}; + m_memory_data.append(allocation); + return true; + } else { + return false; + } + } + + bool trackDealloc(size_t size, MemoryType type) + { + if (size) { + MemoryAllocationProperties allocation = {m_timer.nsecsElapsed(), -(qint64)size, type}; + m_memory_data.append(allocation); + return true; + } else { + return false; + } + } + + quint64 featuresEnabled; + + void stopProfiling(); + void startProfiling(quint64 features); + void reportData(); + void setTimer(const QElapsedTimer &timer) { m_timer = timer; } + +Q_SIGNALS: + void dataReady(const QV4::Profiling::FunctionLocationHash &, + const QVector<QV4::Profiling::FunctionCallProperties> &, + const QVector<QV4::Profiling::MemoryAllocationProperties> &); + +private: + QV4::ExecutionEngine *m_engine; + QElapsedTimer m_timer; + QVector<FunctionCall> m_data; + QVector<MemoryAllocationProperties> m_memory_data; + QHash<quintptr, SentMarker> m_sentLocations; + + friend class FunctionCallProfiler; +}; + +class FunctionCallProfiler { + Q_DISABLE_COPY(FunctionCallProfiler) +public: + + // It's enough to ref() the function in the destructor as it will probably not disappear while + // it's executing ... + FunctionCallProfiler(ExecutionEngine *engine, Function *f) + { + Profiler *p = engine->profiler(); + if (Q_UNLIKELY(p) && (p->featuresEnabled & (1 << Profiling::FeatureFunctionCall))) { + profiler = p; + function = f; + startTime = profiler->m_timer.nsecsElapsed(); + } + } + + ~FunctionCallProfiler() + { + if (profiler) + profiler->m_data.append(FunctionCall(function, startTime, profiler->m_timer.nsecsElapsed())); + } + + Profiler *profiler = nullptr; + Function *function = nullptr; + qint64 startTime = 0; +}; + + +} // namespace Profiling +} // namespace QV4 + +Q_DECLARE_TYPEINFO(QV4::Profiling::MemoryAllocationProperties, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QV4::Profiling::FunctionCallProperties, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QV4::Profiling::FunctionCall, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QV4::Profiling::FunctionLocation, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QV4::Profiling::Profiler::SentMarker, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE +Q_DECLARE_METATYPE(QV4::Profiling::FunctionLocationHash) +Q_DECLARE_METATYPE(QVector<QV4::Profiling::FunctionCallProperties>) +Q_DECLARE_METATYPE(QVector<QV4::Profiling::MemoryAllocationProperties>) + +#endif // QT_CONFIG(qml_debug) + +#endif // QV4PROFILING_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4promiseobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4promiseobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..01f8026d0dac2492224c2af9b1a90414d27150cf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4promiseobject_p.h @@ -0,0 +1,241 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4PROMISEOBJECT_H +#define QV4PROMISEOBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct PromiseCapability; + +namespace Promise { + +struct ReactionEvent; +struct ResolveThenableEvent; + +class ReactionHandler : public QObject +{ + Q_OBJECT + +public: + ReactionHandler(QObject *parent = nullptr); + ~ReactionHandler() override; + + void addReaction(ExecutionEngine *e, const Value *reaction, const Value *value); + void addResolveThenable(ExecutionEngine *e, const PromiseObject *promise, const Object *thenable, const FunctionObject *then); + +protected: + void customEvent(QEvent *event) override; + void executeReaction(ReactionEvent *event); + void executeResolveThenable(ResolveThenableEvent *event); +}; + +} // Promise + +namespace Heap { + +struct PromiseCtor : FunctionObject { + void init(ExecutionEngine *engine); +}; + +#define PromiseObjectMembers(class, Member) \ + Member(class, HeapValue, HeapValue, resolution) \ + Member(class, HeapValue, HeapValue, fulfillReactions) \ + Member(class, HeapValue, HeapValue, rejectReactions) + +DECLARE_HEAP_OBJECT(PromiseObject, Object) { + DECLARE_MARKOBJECTS(PromiseObject) + void init(ExecutionEngine *e); + + enum State { + Pending, + Fulfilled, + Rejected + }; + + void setState(State); + bool isSettled() const; + bool isPending() const; + bool isFulfilled() const; + bool isRejected() const; + + State state; + + void triggerFullfillReactions(ExecutionEngine *e); + void triggerRejectReactions(ExecutionEngine *e); +}; + +#define PromiseCapabilityMembers(class, Member) \ + Member(class, HeapValue, HeapValue, promise) \ + Member(class, HeapValue, HeapValue, resolve) \ + Member(class, HeapValue, HeapValue, reject) + +DECLARE_HEAP_OBJECT(PromiseCapability, Object) { + DECLARE_MARKOBJECTS(PromiseCapability) +}; + +#define PromiseReactionMembers(class, Member) \ + Member(class, HeapValue, HeapValue, handler) \ + Member(class, Pointer, PromiseCapability*, capability) + +DECLARE_HEAP_OBJECT(PromiseReaction, Object) { + DECLARE_MARKOBJECTS(PromiseReaction) + + static Heap::PromiseReaction *createFulfillReaction(ExecutionEngine* e, const QV4::PromiseCapability *capability, const QV4::FunctionObject *onFulfilled); + static Heap::PromiseReaction *createRejectReaction(ExecutionEngine* e, const QV4::PromiseCapability *capability, const QV4::FunctionObject *onRejected); + + void triggerWithValue(ExecutionEngine *e, const Value *value); + + enum Type { + Function, + Identity, + Thrower + }; + + Type type; + + friend class ReactionHandler; +}; + +#define CapabilitiesExecutorWrapperMembers(class, Member) \ + Member(class, Pointer, PromiseCapability*, capabilities) + +DECLARE_HEAP_OBJECT(CapabilitiesExecutorWrapper, FunctionObject) { + DECLARE_MARKOBJECTS(CapabilitiesExecutorWrapper) + void init(); + void destroy(); +}; + +#define PromiseExecutionStateMembers(class, Member) \ + Member(class, HeapValue, HeapValue, values) \ + Member(class, HeapValue, HeapValue, capability) + +DECLARE_HEAP_OBJECT(PromiseExecutionState, FunctionObject) { + DECLARE_MARKOBJECTS(PromiseExecutionState) + void init(); + + uint index; + uint remainingElementCount; +}; + +#define ResolveElementWrapperMembers(class, Member) \ + Member(class, HeapValue, HeapValue, state) + +DECLARE_HEAP_OBJECT(ResolveElementWrapper, FunctionObject) { + DECLARE_MARKOBJECTS(ResolveElementWrapper) + void init(); + + uint index; + bool alreadyResolved; +}; + +#define ResolveWrapperMembers(class, Member) \ + Member(class, Pointer, PromiseObject*, promise) + +DECLARE_HEAP_OBJECT(ResolveWrapper, FunctionObject) { + DECLARE_MARKOBJECTS(ResolveWrapper) + void init(); + + bool alreadyResolved; +}; + +#define RejectWrapperMembers(class, Member) \ + Member(class, Pointer, PromiseObject*, promise) + +DECLARE_HEAP_OBJECT(RejectWrapper, FunctionObject) { + DECLARE_MARKOBJECTS(RejectWrapper) + void init(); + + bool alreadyResolved; +}; + +} // Heap + +struct PromiseReaction : Object +{ + V4_OBJECT2(PromiseReaction, Object) +}; + +struct PromiseCapability : Object +{ + V4_OBJECT2(PromiseCapability, Object) +}; + +struct PromiseExecutionState : Object +{ + V4_OBJECT2(PromiseExecutionState, Object) +}; + +struct Q_QML_EXPORT PromiseObject : Object +{ + V4_OBJECT2(PromiseObject, Object) + V4_NEEDS_DESTROY + V4_PROTOTYPE(promisePrototype) +}; + +struct PromiseCtor: FunctionObject +{ + V4_OBJECT2(PromiseCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_resolve(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_reject(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_all(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_race(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct PromisePrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_then(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_catch(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct CapabilitiesExecutorWrapper: FunctionObject { + V4_OBJECT2(CapabilitiesExecutorWrapper, FunctionObject) + + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct ResolveElementWrapper : FunctionObject { + V4_OBJECT2(ResolveElementWrapper, FunctionObject) + + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct ResolveWrapper : FunctionObject { + V4_OBJECT2(ResolveWrapper, FunctionObject) + + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct RejectWrapper : FunctionObject { + V4_OBJECT2(RejectWrapper, FunctionObject) + + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +} // QV4 + +QT_END_NAMESPACE + +#endif // QV4PROMISEOBJECT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4property_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4property_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a72efd8bd176f933af9667f04c9cf02c66beeeb2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4property_p.h @@ -0,0 +1,178 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4PROPERTYDESCRIPTOR_H +#define QV4PROPERTYDESCRIPTOR_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" +#include "qv4value_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct FunctionObject; + +struct Property { + Value value; + Value set; + + // Section 8.10 + inline void fullyPopulated(PropertyAttributes *attrs) { + if (!attrs->hasType()) { + value = Value::undefinedValue(); + } + if (attrs->type() == PropertyAttributes::Accessor) { + attrs->clearWritable(); + if (value.isEmpty()) + value = Value::undefinedValue(); + if (set.isEmpty()) + set = Value::undefinedValue(); + } + attrs->resolve(); + } + + // ES8: 6.2.5.6 + void completed(PropertyAttributes *attrs) { + if (value.isEmpty()) + value = Encode::undefined(); + if (attrs->isGeneric() || attrs->isData()) { + attrs->setType(PropertyAttributes::Data); + if (!attrs->hasWritable()) + attrs->setWritable(false); + } else { + if (set.isEmpty()) + set = Encode::undefined(); + } + if (!attrs->hasEnumerable()) + attrs->setEnumerable(false); + if (!attrs->hasConfigurable()) + attrs->setConfigurable(false); + } + + inline bool isSubset(const PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const; + inline void merge(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs); + + inline Heap::FunctionObject *getter() const { return reinterpret_cast<Heap::FunctionObject *>(value.heapObject()); } + inline Heap::FunctionObject *setter() const { return reinterpret_cast<Heap::FunctionObject *>(set.heapObject()); } + inline void setGetter(FunctionObject *g) { value = reinterpret_cast<Managed *>(g); } + inline void setSetter(FunctionObject *s) { set = (s ? reinterpret_cast<Managed *>(s) : nullptr); } + + void copy(const Property *other, PropertyAttributes attrs) { + value = other->value; + if (attrs.isAccessor()) + set = other->set; + } + + // ES8, section 9.1.6.2/9,.1.6.3 + bool isCompatible(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const { + if (otherAttrs.isEmpty()) + return true; + if (!attrs.isConfigurable()) { + if (otherAttrs.hasConfigurable() && otherAttrs.isConfigurable()) + return false; + if (otherAttrs.hasEnumerable() && otherAttrs.isEnumerable() != attrs.isEnumerable()) + return false; + } + if (otherAttrs.isGeneric()) + return true; + if (attrs.isData() != otherAttrs.isData()) { + if (!attrs.isConfigurable()) + return false; + } else if (attrs.isData() && otherAttrs.isData()) { + if (!attrs.isConfigurable() && !attrs.isWritable()) { + if (otherAttrs.hasWritable() && otherAttrs.isWritable()) + return false; + if (!other->value.isEmpty() && !value.sameValue(other->value)) + return false; + } + } else if (attrs.isAccessor() && otherAttrs.isAccessor()) { + if (!attrs.isConfigurable()) { + if (!other->value.isEmpty() && !value.sameValue(other->value)) + return false; + if (!other->set.isEmpty() && !set.sameValue(other->set)) + return false; + } + } + return true; + } + + + explicit Property() { value = Encode::undefined(); set = Value::fromHeapObject(nullptr); } + Property(Heap::FunctionObject *getter, Heap::FunctionObject *setter) { + value.setM(reinterpret_cast<Heap::Base *>(getter)); + set.setM(reinterpret_cast<Heap::Base *>(setter)); + } +private: + Q_DISABLE_COPY(Property) +}; + +inline bool Property::isSubset(const PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const +{ + if (attrs.type() != PropertyAttributes::Generic && attrs.type() != otherAttrs.type()) + return false; + if (attrs.hasEnumerable() && attrs.isEnumerable() != otherAttrs.isEnumerable()) + return false; + if (attrs.hasConfigurable() && attrs.isConfigurable() != otherAttrs.isConfigurable()) + return false; + if (attrs.hasWritable() && attrs.isWritable() != otherAttrs.isWritable()) + return false; + if (attrs.type() == PropertyAttributes::Data && !value.sameValue(other->value)) + return false; + if (attrs.type() == PropertyAttributes::Accessor) { + if (value.heapObject() != other->value.heapObject()) + return false; + if (set.heapObject() != other->set.heapObject()) + return false; + } + return true; +} + +inline void Property::merge(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) +{ + if (otherAttrs.hasEnumerable()) + attrs.setEnumerable(otherAttrs.isEnumerable()); + if (otherAttrs.hasConfigurable()) + attrs.setConfigurable(otherAttrs.isConfigurable()); + if (otherAttrs.hasWritable()) + attrs.setWritable(otherAttrs.isWritable()); + if (otherAttrs.type() == PropertyAttributes::Accessor) { + attrs.setType(PropertyAttributes::Accessor); + if (!other->value.isEmpty()) + value = other->value; + if (!other->set.isEmpty()) + set = other->set; + } else if (otherAttrs.type() == PropertyAttributes::Data){ + attrs.setType(PropertyAttributes::Data); + value = other->value; + } +} + +struct PropertyIndex { + Heap::Base *base; + Value *slot; + + void set(EngineBase *e, Value newVal) { + WriteBarrier::write(e, base, slot->data_ptr(), newVal.asReturnedValue()); + } + const Value *operator->() const { return slot; } + const Value &operator*() const { return *slot; } + bool isNull() const { return !slot; } +}; + + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4propertykey_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4propertykey_p.h new file mode 100644 index 0000000000000000000000000000000000000000..28cef76488c71199bea9e9e0dc636a8b8ca9eadd --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4propertykey_p.h @@ -0,0 +1,128 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4PROPERTYKEY_H +#define QV4PROPERTYKEY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4writebarrier_p.h> +#include <private/qv4global_p.h> +#include <private/qv4staticvalue_p.h> +#include <QtCore/qhashfunctions.h> + +QT_BEGIN_NAMESPACE + +class QString; + +namespace QV4 { + +struct PropertyKey +{ +private: + // Property keys are Strings, Symbols or unsigned integers. + // For convenience we derive them from Values, allowing us to store them + // on the JS stack + // + // They do however behave somewhat different than a Value: + // * If the key is a String, the pointer to the string is stored in the identifier + // table and thus unique. + // * If the key is a Symbol it simply points to the referenced symbol object + // * if the key is an array index (a uint < UINT_MAX), it's encoded as an + // integer value + QV4::StaticValue val; + + inline bool isManaged() const { return val.isManaged(); } + inline quint32 value() const { return val.value(); } + +public: + static PropertyKey invalid() + { + PropertyKey key; + key.val = StaticValue::undefinedValue(); + return key; + } + + static PropertyKey fromArrayIndex(uint idx) + { + PropertyKey key; + key.val.setInt_32(idx); + return key; + } + + bool isStringOrSymbol() const { return isManaged(); } + uint asArrayIndex() const + { + Q_ASSERT(isArrayIndex()); + return value(); + } + + bool isArrayIndex() const { return val.isInteger(); } + bool isValid() const { return !val.isUndefined(); } + + // We cannot #include the declaration of Heap::StringOrSymbol here. + // Therefore we do some gymnastics to enforce the type safety. + + template<typename StringOrSymbol = Heap::StringOrSymbol, typename Engine = QV4::EngineBase> + static PropertyKey fromStringOrSymbol(Engine *engine, StringOrSymbol *b) + { + static_assert(std::is_base_of_v<Heap::StringOrSymbol, StringOrSymbol>); + PropertyKey key; + QV4::WriteBarrier::markCustom(engine, [&](QV4::MarkStack *stack) { + if constexpr (QV4::WriteBarrier::isInsertionBarrier) { + // treat this as an insertion - the StringOrSymbol becomes reachable + // via the propertykey, so we consequently need to mark it durnig gc + b->mark(stack); + } + }); + key.val.setM(b); + Q_ASSERT(key.isManaged()); + return key; + } + + template<typename StringOrSymbol = Heap::StringOrSymbol> + StringOrSymbol *asStringOrSymbol() const + { + static_assert(std::is_base_of_v<Heap::StringOrSymbol, StringOrSymbol>); + if (!isManaged()) + return nullptr; + return static_cast<StringOrSymbol *>(val.m()); + } + + Q_QML_EXPORT bool isString() const; + Q_QML_EXPORT bool isSymbol() const; + bool isCanonicalNumericIndexString() const; + + Q_QML_EXPORT QString toQString() const; + Heap::StringOrSymbol *toStringOrSymbol(ExecutionEngine *e); + quint64 id() const { return val._val; } + static PropertyKey fromId(quint64 id) { + PropertyKey key; key.val._val = id; return key; + } + + enum FunctionNamePrefix { + None, + Getter, + Setter + }; + Heap::String *asFunctionName(ExecutionEngine *e, FunctionNamePrefix prefix) const; + + bool operator ==(const PropertyKey &other) const { return val._val == other.val._val; } + bool operator !=(const PropertyKey &other) const { return val._val != other.val._val; } + bool operator <(const PropertyKey &other) const { return val._val < other.val._val; } + friend size_t qHash(const PropertyKey &key, size_t seed = 0) { return qHash(key.val._val, seed); } +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4proxy_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4proxy_p.h new file mode 100644 index 0000000000000000000000000000000000000000..341ffe4a63425b62771e95f9e23e735b1d7940af --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4proxy_p.h @@ -0,0 +1,109 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4PROXY_P_H +#define QV4PROXY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +#define ProxyObjectMembers(class, Member) \ + Member(class, Pointer, Object *, target) \ + Member(class, Pointer, Object *, handler) + +DECLARE_HEAP_OBJECT(ProxyObject, FunctionObject) { + DECLARE_MARKOBJECTS(ProxyObject) + + void init(const QV4::Object *target, const QV4::Object *handler); +}; + +struct ProxyFunctionObject : ProxyObject { + void init(const QV4::FunctionObject *target, const QV4::Object *handler); +}; + +struct ProxyConstructorObject : ProxyFunctionObject {}; + +#define ProxyMembers(class, Member) \ + Member(class, Pointer, Symbol *, revokableProxySymbol) \ + +DECLARE_HEAP_OBJECT(Proxy, FunctionObject) { + DECLARE_MARKOBJECTS(Proxy) + + void init(ExecutionEngine *engine); +}; + +} + +/* + * The inheritance from FunctionObject is a hack. Regular proxy objects are no function objects. + * But this helps implement the proxy for function objects, where we need this and thus gives us + * all the virtual methods from ProxyObject without having to duplicate them. + * + * But it does require a few hacks to make sure we don't recognize regular proxy objects as function + * objects in the runtime. + */ +struct ProxyObject : FunctionObject { + V4_OBJECT2(ProxyObject, Object) + Q_MANAGED_TYPE(ProxyObject) + V4_INTERNALCLASS(ProxyObject) + + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static bool virtualDeleteProperty(Managed *m, PropertyKey id); + static bool virtualHasProperty(const Managed *m, PropertyKey id); + static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p); + static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs); + static bool virtualIsExtensible(const Managed *m); + static bool virtualPreventExtensions(Managed *); + static Heap::Object *virtualGetPrototypeOf(const Managed *); + static bool virtualSetPrototypeOf(Managed *, const Object *); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *iteratorTarget); +}; + +struct ProxyFunctionObject : ProxyObject { + V4_OBJECT2(ProxyFunctionObject, FunctionObject) + Q_MANAGED_TYPE(ProxyObject) + V4_INTERNALCLASS(ProxyFunctionObject) + + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct ProxyConstructorObject : ProxyFunctionObject { + V4_OBJECT2(ProxyConstructorObject, ProxyFunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + +struct Proxy : FunctionObject +{ + V4_OBJECT2(Proxy, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_revocable(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_revoke(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +} + +QT_END_NAMESPACE + +#endif // QV4ECMAOBJECTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4qmetaobjectwrapper_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4qmetaobjectwrapper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4544fd8f51093b8427aa884420bda090c4c5777f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4qmetaobjectwrapper_p.h @@ -0,0 +1,120 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4QMETAOBJECTWRAPPER_P_H +#define QV4QMETAOBJECTWRAPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4functionobject_p.h> +#include <private/qv4value_p.h> + +#include <QtCore/qmetaobject.h> + +QT_BEGIN_NAMESPACE + +class QQmlPropertyData; + +namespace QV4 { +namespace Heap { + +struct QMetaObjectWrapper : FunctionObject +{ + void init(const QMetaObject *metaObject); + void destroy(); + + const QMetaObject *metaObject() const { return m_metaObject; } + QMetaType metaType() const + { + const QMetaType type = m_metaObject->metaType(); + if (type.flags() & QMetaType::IsGadget) + return type; + + // QObject* is our best guess because we can't get from a metatype to + // the metatype of its pointer. + return QMetaType::fromType<QObject *>(); + } + + const QQmlPropertyData *ensureConstructorsCache( + const QMetaObject *metaObject, QMetaType metaType) + { + Q_ASSERT(metaObject); + if (!m_constructors) + m_constructors = createConstructors(metaObject, metaType); + return m_constructors; + } + + + static const QQmlPropertyData *createConstructors( + const QMetaObject *metaObject, QMetaType metaType) + { + Q_ASSERT(metaObject); + const int count = metaObject->constructorCount(); + if (count == 0) + return nullptr; + + QQmlPropertyData *constructors = new QQmlPropertyData[count]; + + for (int i = 0; i < count; ++i) { + QMetaMethod method = metaObject->constructor(i); + QQmlPropertyData &d = constructors[i]; + d.load(method); + d.setPropType(metaType); + d.setCoreIndex(i); + } + + return constructors; + } + +private: + const QMetaObject *m_metaObject; + const QQmlPropertyData *m_constructors; +}; + +} // namespace Heap + +struct Q_QML_EXPORT QMetaObjectWrapper : public FunctionObject +{ + V4_OBJECT2(QMetaObjectWrapper, FunctionObject) + V4_NEEDS_DESTROY + + static ReturnedValue create(ExecutionEngine *engine, const QMetaObject* metaObject); + const QMetaObject *metaObject() const { return d()->metaObject(); } + + template<typename HeapObject> + ReturnedValue static construct(HeapObject *d, const Value *argv, int argc) + { + const QMetaObject *mo = d->metaObject(); + return constructInternal( + mo, d->ensureConstructorsCache(mo, d->metaType()), d, argv, argc); + } + +protected: + static ReturnedValue virtualCallAsConstructor( + const FunctionObject *, const Value *argv, int argc, const Value *); + static bool virtualIsEqualTo(Managed *a, Managed *b); + +private: + void init(ExecutionEngine *engine); + + static ReturnedValue constructInternal( + const QMetaObject *mo, const QQmlPropertyData *constructors, Heap::FunctionObject *d, + const Value *argv, int argc); +}; + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4QMETAOBJECTWRAPPER_P_H + + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4qmlcontext_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4qmlcontext_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2463b24c06d228d0df1b3e65b746e4320adc3eb2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4qmlcontext_p.h @@ -0,0 +1,111 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4QMLCONTEXT_P_H +#define QV4QMLCONTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlcontextdata_p.h> +#include <private/qtqmlglobal_p.h> +#include <private/qv4context_p.h> +#include <private/qv4object_p.h> + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct QQmlContextWrapper; + +namespace Heap { + +#define QQmlContextWrapperMembers(class, Member) \ + Member(class, Pointer, Module *, module) + +DECLARE_HEAP_OBJECT(QQmlContextWrapper, Object) { + DECLARE_MARKOBJECTS(QQmlContextWrapper) + + void init(QQmlRefPointer<QQmlContextData> context, QObject *scopeObject); + void destroy(); + + // This has to be a plain pointer because object needs to be a POD type. + QQmlContextData *context; + QV4QPointer<QObject> scopeObject; +}; + +#define QmlContextMembers(class, Member) + +DECLARE_HEAP_OBJECT(QmlContext, ExecutionContext) { + DECLARE_MARKOBJECTS(QmlContext) + + QQmlContextWrapper *qml() { return static_cast<QQmlContextWrapper *>(activation.get()); } + void init(QV4::ExecutionContext *outerContext, QV4::QQmlContextWrapper *qml); +}; + +} + +struct Q_QML_EXPORT QQmlContextWrapper : Object +{ + V4_OBJECT2(QQmlContextWrapper, Object) + V4_NEEDS_DESTROY + V4_INTERNALCLASS(QmlContextWrapper) + + inline QObject *getScopeObject() const { return d()->scopeObject; } + inline QQmlRefPointer<QQmlContextData> getContext() const { return d()->context; } + + static ReturnedValue getPropertyAndBase(const QQmlContextWrapper *resource, PropertyKey id, const Value *receiver, + bool *hasProperty, Value *base, Lookup *lookup = nullptr); + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); + + static ReturnedValue resolveQmlContextPropertyLookupGetter(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupScript(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupSingleton(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupValueSingleton(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupIdObject(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupIdObjectInParentContext(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupScopeObjectProperty(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupScopeObjectMethod(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupScopeFallbackProperty(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupContextObjectProperty(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupContextObjectMethod(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupInGlobalObject(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupInParentContextHierarchy(Lookup *l, ExecutionEngine *engine, Value *base); + static ReturnedValue lookupType(Lookup *l, ExecutionEngine *engine, Value *base); +}; + +struct Q_QML_EXPORT QmlContext : public ExecutionContext +{ + V4_MANAGED(QmlContext, ExecutionContext) + V4_INTERNALCLASS(QmlContext) + + static Heap::QmlContext *create( + QV4::ExecutionContext *parent, QQmlRefPointer<QQmlContextData> context, + QObject *scopeObject); + + QObject *qmlScope() const { + return d()->qml()->scopeObject; + } + + QQmlRefPointer<QQmlContextData> qmlContext() const { + return d()->qml()->context; + } +}; + +} + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4qobjectwrapper_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4qobjectwrapper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..923423179d269af3f1bacba1d38c9babef6788b7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4qobjectwrapper_p.h @@ -0,0 +1,495 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4QOBJECTWRAPPER_P_H +#define QV4QOBJECTWRAPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qbipointer_p.h> +#include <private/qintrusivelist_p.h> +#include <private/qqmldata_p.h> +#include <private/qv4functionobject_p.h> +#include <private/qv4lookup_p.h> +#include <private/qv4value_p.h> + +#include <QtCore/qglobal.h> +#include <QtCore/qmetatype.h> +#include <QtCore/qpair.h> +#include <QtCore/qhash.h> + +QT_BEGIN_NAMESPACE + +class QObject; +class QQmlData; +class QQmlPropertyCache; +class QQmlPropertyData; +class QQmlObjectOrGadget; + +namespace QV4 { +struct QObjectSlotDispatcher; + +namespace Heap { + +struct QQmlValueTypeWrapper; + +struct Q_QML_EXPORT QObjectWrapper : Object { + void init(QObject *object) + { + Object::init(); + qObj.init(object); + } + + void destroy() { + qObj.destroy(); + Object::destroy(); + } + + QObject *object() const { return qObj.data(); } + static void markObjects(Heap::Base *that, MarkStack *markStack); + +private: + QV4QPointer<QObject> qObj; +}; + +#define QObjectMethodMembers(class, Member) \ + Member(class, Pointer, Object *, wrapper) \ + +DECLARE_EXPORTED_HEAP_OBJECT(QObjectMethod, FunctionObject) { + DECLARE_MARKOBJECTS(QObjectMethod) + + QQmlPropertyData *methods; + alignas(alignof(QQmlPropertyData)) std::byte _singleMethod[sizeof(QQmlPropertyData)]; + int methodCount; + int index; + + void init(QV4::ExecutionEngine *engine, Object *wrapper, int index); + void destroy() + { + if (methods != reinterpret_cast<const QQmlPropertyData *>(&_singleMethod)) + delete[] methods; + FunctionObject::destroy(); + } + + void ensureMethodsCache(const QMetaObject *thisMeta); + QString name() const; + + const QMetaObject *metaObject() const; + QObject *object() const; + + bool isDetached() const; + bool isAttachedTo(QObject *o) const; + + enum ThisObjectMode { + Invalid, + Included, + Explicit, + }; + + QV4::Heap::QObjectMethod::ThisObjectMode checkThisObject(const QMetaObject *thisMeta) const; +}; + +struct QmlSignalHandler : Object { + void init(QObject *object, int signalIndex); + void destroy() { + qObj.destroy(); + Object::destroy(); + } + int signalIndex; + + QObject *object() const { return qObj.data(); } + void setObject(QObject *o) { qObj = o; } + +private: + QV4QPointer<QObject> qObj; +}; + +} + +struct Q_QML_EXPORT QObjectWrapper : public Object +{ + V4_OBJECT2(QObjectWrapper, Object) + V4_NEEDS_DESTROY + + enum Flag { + NoFlag = 0x0, + CheckRevision = 0x1, + AttachMethods = 0x2, + AllowOverride = 0x4, + IncludeImports = 0x8, + }; + + Q_DECLARE_FLAGS(Flags, Flag); + + static void initializeBindings(ExecutionEngine *engine); + + const QMetaObject *metaObject() const + { + if (QObject *o = object()) + return o->metaObject(); + return nullptr; + } + + QObject *object() const { return d()->object(); } + + ReturnedValue getQmlProperty( + const QQmlRefPointer<QQmlContextData> &qmlContext, String *name, + Flags flags, bool *hasProperty = nullptr) const; + + static ReturnedValue getQmlProperty( + ExecutionEngine *engine, const QQmlRefPointer<QQmlContextData> &qmlContext, + Heap::Object *wrapper, QObject *object, String *name, Flags flags, + bool *hasProperty = nullptr, const QQmlPropertyData **property = nullptr); + + static bool setQmlProperty( + ExecutionEngine *engine, const QQmlRefPointer<QQmlContextData> &qmlContext, + QObject *object, String *name, Flags flags, const Value &value); + + Q_NODISCARD_X("Use ensureWrapper if you don't need the return value") + static ReturnedValue wrap(ExecutionEngine *engine, QObject *object); + Q_NODISCARD_X("Throwing the const wrapper away can cause it to be garbage collected") + static ReturnedValue wrapConst(ExecutionEngine *engine, QObject *object); + static void ensureWrapper(ExecutionEngine *engine, QObject *object); + static void markWrapper(QObject *object, MarkStack *markStack); + + using Object::get; + + static void setProperty(ExecutionEngine *engine, QObject *object, int propertyIndex, const Value &value); + void setProperty(ExecutionEngine *engine, int propertyIndex, const Value &value); + static void setProperty( + ExecutionEngine *engine, QObject *object, + const QQmlPropertyData *property, const Value &value); + + void destroyObject(bool lastCall); + + static ReturnedValue getProperty( + ExecutionEngine *engine, Heap::Object *wrapper, QObject *object, + const QQmlPropertyData *property, Flags flags); + + static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup); + static ReturnedValue lookupAttached(Lookup *l, ExecutionEngine *engine, const Value &object); + + template <typename ReversalFunctor> static ReturnedValue lookupPropertyGetterImpl( + Lookup *l, ExecutionEngine *engine, const Value &object, + Flags flags, ReversalFunctor revert); + template <typename ReversalFunctor> static ReturnedValue lookupMethodGetterImpl( + Lookup *l, ExecutionEngine *engine, const Value &object, + Flags flags, ReversalFunctor revert); + static bool virtualResolveLookupSetter( + Object *object, ExecutionEngine *engine, Lookup *lookup, const Value &value); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); + + static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a); + + static QString objectToString( + ExecutionEngine *engine, const QMetaObject *metaObject, QObject *object); + +protected: + static bool virtualIsEqualTo(Managed *that, Managed *o); + static ReturnedValue create(ExecutionEngine *engine, QObject *object); + + static const QQmlPropertyData *findProperty( + QObject *o, const QQmlRefPointer<QQmlContextData> &qmlContext, + String *name, Flags flags, QQmlPropertyData *local); + + const QQmlPropertyData *findProperty( + const QQmlRefPointer<QQmlContextData> &qmlContext, + String *name, Flags flags, QQmlPropertyData *local) const; + + static ReturnedValue virtualGet( + const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p); + + static ReturnedValue method_connect( + const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_disconnect( + const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + +private: + Q_NEVER_INLINE static ReturnedValue wrap_slowPath(ExecutionEngine *engine, QObject *object); + Q_NEVER_INLINE static ReturnedValue wrapConst_slowPath(ExecutionEngine *engine, QObject *object); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QObjectWrapper::Flags) + +// We generally musn't pass ReturnedValue as arguments to other functions. +// In this case, we do it solely for marking purposes so it's fine. +inline void markIfPastMarkWeakValues(ExecutionEngine *engine, ReturnedValue rv) +{ + const auto gcState = engine->memoryManager->gcStateMachine->state; + if (gcState != GCStateMachine::Invalid && gcState >= GCState::MarkWeakValues) { + QV4::WriteBarrier::markCustom(engine, [rv](QV4::MarkStack *ms) { + auto *m = StaticValue::fromReturnedValue(rv).m(); + m->mark(ms); + }); + } +} + +inline ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object) +{ + if (Q_UNLIKELY(QQmlData::wasDeleted(object))) + return QV4::Encode::null(); + + auto ddata = QQmlData::get(object); + if (Q_LIKELY(ddata && ddata->jsEngineId == engine->m_engineId && !ddata->jsWrapper.isUndefined())) { + // We own the JS object + return ddata->jsWrapper.value(); + } + + const auto rv = wrap_slowPath(engine, object); + markIfPastMarkWeakValues(engine, rv); + return rv; +} + +// Unfortunately we still need a non-const QObject* here because QQmlData needs to register itself in QObjectPrivate. +inline ReturnedValue QObjectWrapper::wrapConst(ExecutionEngine *engine, QObject *object) +{ + if (Q_UNLIKELY(QQmlData::wasDeleted(object))) + return QV4::Encode::null(); + + const auto rv = wrapConst_slowPath(engine, object); + markIfPastMarkWeakValues(engine, rv); + return rv; +} + +inline bool canConvert(const QQmlPropertyCache *fromMo, const QQmlPropertyCache *toMo) +{ + while (fromMo) { + if (fromMo == toMo) + return true; + fromMo = fromMo->parent().data(); + } + return false; +} + +template <typename ReversalFunctor> +inline ReturnedValue QObjectWrapper::lookupPropertyGetterImpl( + Lookup *lookup, ExecutionEngine *engine, const Value &object, + QObjectWrapper::Flags flags, ReversalFunctor revertLookup) +{ + // we can safely cast to a QV4::Object here. If object is something else, + // the internal class won't match + Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); + if (!o || o->internalClass != lookup->qobjectLookup.ic) + return revertLookup(); + + Heap::QObjectWrapper *This = static_cast<Heap::QObjectWrapper *>(o); + QObject *qobj = This->object(); + if (QQmlData::wasDeleted(qobj)) + return QV4::Encode::undefined(); + + QQmlData *ddata = QQmlData::get(qobj, /*create*/false); + if (!ddata) + return revertLookup(); + + const QQmlPropertyData *property = lookup->qobjectLookup.propertyData; + if (ddata->propertyCache.data() != lookup->qobjectLookup.propertyCache) { + // If the property is overridden and the lookup allows overrides to be considered, + // we have to revert here and redo the lookup from scratch. + if (property->isOverridden() + && ((flags & AllowOverride) + || property->isFunction() + || property->isSignalHandler())) { + return revertLookup(); + } + + if (!canConvert(ddata->propertyCache.data(), lookup->qobjectLookup.propertyCache)) + return revertLookup(); + } + + return getProperty(engine, This, qobj, property, flags); +} + +template <typename ReversalFunctor> +inline ReturnedValue QObjectWrapper::lookupMethodGetterImpl( + Lookup *lookup, ExecutionEngine *engine, const Value &object, + QObjectWrapper::Flags flags, ReversalFunctor revertLookup) +{ + // we can safely cast to a QV4::Object here. If object is something else, + // the internal class won't match + Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); + if (!o || o->internalClass != lookup->qobjectMethodLookup.ic) + return revertLookup(); + + Heap::QObjectWrapper *This = static_cast<Heap::QObjectWrapper *>(o); + QObject *qobj = This->object(); + if (QQmlData::wasDeleted(qobj)) + return QV4::Encode::undefined(); + + QQmlData *ddata = QQmlData::get(qobj, /*create*/false); + if (!ddata) + return revertLookup(); + + const QQmlPropertyData *property = lookup->qobjectMethodLookup.propertyData; + if (ddata->propertyCache.data() != lookup->qobjectMethodLookup.propertyCache) { + if (property && property->isOverridden()) + return revertLookup(); + + if (!canConvert(ddata->propertyCache.data(), lookup->qobjectMethodLookup.propertyCache)) + return revertLookup(); + } + + if (Heap::QObjectMethod *method = lookup->qobjectMethodLookup.method) { + if (method->isDetached()) + return method->asReturnedValue(); + } + + if (!property) // was toString() or destroy() + return revertLookup(); + + QV4::Scope scope(engine); + QV4::ScopedValue v(scope, getProperty(engine, This, qobj, property, flags)); + if (!v->as<QObjectMethod>()) + return revertLookup(); + + lookup->qobjectMethodLookup.method.set(engine, static_cast<Heap::QObjectMethod *>(v->heapObject())); + return v->asReturnedValue(); +} + +struct QQmlValueTypeWrapper; + +struct Q_QML_EXPORT QObjectMethod : public QV4::FunctionObject +{ + V4_OBJECT2(QObjectMethod, QV4::FunctionObject) + V4_NEEDS_DESTROY + + enum { DestroyMethod = -1, ToStringMethod = -2 }; + + static ReturnedValue create(ExecutionEngine *engine, Heap::Object *wrapper, int index); + static ReturnedValue create( + ExecutionEngine *engine, Heap::QQmlValueTypeWrapper *valueType, int index); + static ReturnedValue create( + ExecutionEngine *engine, Heap::QObjectMethod *cloneFrom, + Heap::Object *wrapper, Heap::Object *object); + + int methodIndex() const { return d()->index; } + QObject *object() const { return d()->object(); } + + QV4::ReturnedValue method_toString(QV4::ExecutionEngine *engine, QObject *o) const; + QV4::ReturnedValue method_destroy( + QV4::ExecutionEngine *ctx, QObject *o, const Value *args, int argc) const; + void method_destroy( + QV4::ExecutionEngine *engine, QObject *o, + void **argv, const QMetaType *types, int argc) const; + + static ReturnedValue virtualCall( + const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static void virtualCallWithMetaTypes( + const FunctionObject *m, QObject *thisObject, + void **argv, const QMetaType *types, int argc); + + ReturnedValue callInternal( + const Value *thisObject, const Value *argv, int argc) const; + void callInternalWithMetaTypes( + QObject *thisObject, void **argv, const QMetaType *types, int argc) const; + + static QPair<QObject *, int> extractQtMethod(const QV4::FunctionObject *function); + + static bool isExactMatch( + const QMetaMethod &method, void **argv, int argc, const QMetaType *types); + +private: + friend struct QMetaObjectWrapper; + + static const QQmlPropertyData *resolveOverloaded( + const QQmlObjectOrGadget &object, const QQmlPropertyData *methods, int methodCount, + ExecutionEngine *engine, CallData *callArgs); + + static const QQmlPropertyData *resolveOverloaded( + const QQmlPropertyData *methods, int methodCount, + void **argv, int argc, const QMetaType *types); + + static ReturnedValue callPrecise( + const QQmlObjectOrGadget &object, const QQmlPropertyData &data, + ExecutionEngine *engine, CallData *callArgs, + QMetaObject::Call callType = QMetaObject::InvokeMetaMethod); +}; + +struct Q_QML_EXPORT QmlSignalHandler : public QV4::Object +{ + V4_OBJECT2(QmlSignalHandler, QV4::Object) + V4_PROTOTYPE(signalHandlerPrototype) + V4_NEEDS_DESTROY + + int signalIndex() const { return d()->signalIndex; } + QObject *object() const { return d()->object(); } + + ReturnedValue call(const Value *thisObject, const Value *argv, int argc) const; + + static void initProto(ExecutionEngine *v4); +}; + +using QObjectBiPointer = QBiPointer<QObject, const QObject>; + +class MultiplyWrappedQObjectMap : public QObject, + private QHash<QObjectBiPointer, QV4::WeakValue> +{ + Q_OBJECT +public: + typedef QHash<QObjectBiPointer, QV4::WeakValue>::ConstIterator ConstIterator; + typedef QHash<QObjectBiPointer, QV4::WeakValue>::Iterator Iterator; + + using value_type = QHash<QObjectBiPointer, QV4::WeakValue>::value_type; + + ConstIterator begin() const { return QHash<QObjectBiPointer, QV4::WeakValue>::constBegin(); } + Iterator begin() { return QHash<QObjectBiPointer, QV4::WeakValue>::begin(); } + ConstIterator end() const { return QHash<QObjectBiPointer, QV4::WeakValue>::constEnd(); } + Iterator end() { return QHash<QObjectBiPointer, QV4::WeakValue>::end(); } + + template<typename Pointer> + void insert(Pointer key, Heap::Object *value) + { + QHash<QObjectBiPointer, WeakValue>::operator[](key).set(value->internalClass->engine, value); + connect(key, SIGNAL(destroyed(QObject*)), this, SLOT(removeDestroyedObject(QObject*))); + } + + template<typename Pointer> + ReturnedValue value(Pointer key) const + { + ConstIterator it = find(key); + return it == end() + ? QV4::WeakValue().value() + : it->value(); + } + + Iterator erase(Iterator it); + + template<typename Pointer> + void remove(Pointer key) + { + Iterator it = find(key); + if (it == end()) + return; + erase(it); + } + + template<typename Pointer> + void mark(Pointer key, MarkStack *markStack) + { + Iterator it = find(key); + if (it == end()) + return; + it->markOnce(markStack); + } + +private Q_SLOTS: + void removeDestroyedObject(QObject*); +}; + +} + +QT_END_NAMESPACE + +#endif // QV4QOBJECTWRAPPER_P_H + + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4referenceobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4referenceobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..defef7c1473c9d0f7dc9dccb6d20d32a67517535 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4referenceobject_p.h @@ -0,0 +1,171 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4REFERENCEOBJECT_P_H +#define QV4REFERENCEOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4object_p.h> +#include <private/qv4stackframe_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { +namespace Heap { + + +#define ReferenceObjectMembers(class, Member) \ + Member(class, Pointer, Object *, m_object) + +DECLARE_HEAP_OBJECT(ReferenceObject, Object) { + DECLARE_MARKOBJECTS(ReferenceObject); + + enum Flag : quint8 { + NoFlag = 0, + CanWriteBack = 1 << 0, + IsVariant = 1 << 1, + EnforcesLocation = 1 << 2, + }; + Q_DECLARE_FLAGS(Flags, Flag); + + void init(Object *object, int property, Flags flags) + { + setObject(object); + m_property = property; + m_flags = flags; + Object::init(); + } + + Flags flags() const { return Flags(m_flags); } + + Object *object() const { return m_object.get(); } + void setObject(Object *object) { m_object.set(internalClass->engine, object); } + + int property() const { return m_property; } + + bool canWriteBack() const { return hasFlag(CanWriteBack); } + bool isVariant() const { return hasFlag(IsVariant); } + bool enforcesLocation() const { return hasFlag(EnforcesLocation); } + + void setLocation(const Function *function, quint16 statement) + { + m_function = function; + m_statementIndex = statement; + } + + const Function *function() const { return m_function; } + quint16 statementIndex() const { return m_statementIndex; } + + bool isAttachedToProperty() const + { + if (enforcesLocation()) { + if (CppStackFrame *frame = internalClass->engine->currentStackFrame) { + if (frame->v4Function != function() || frame->statementNumber() != statementIndex()) + return false; + } else { + return false; + } + } + + return true; + } + + bool isReference() const { return m_object; } + +private: + + bool hasFlag(Flag flag) const + { + return m_flags & quint8(flag); + } + + void setFlag(Flag flag, bool set) + { + m_flags = set ? (m_flags | quint8(flag)) : (m_flags & ~quint8(flag)); + } + + const Function *m_function; + int m_property; + quint16 m_statementIndex; + quint8 m_flags; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(ReferenceObject::Flags) + +} // namespace Heap + + +struct ReferenceObject : public Object +{ + V4_OBJECT2(ReferenceObject, Object) + V4_NEEDS_DESTROY + +public: + static constexpr const int AllProperties = -1; + + template<typename HeapObject> + static bool readReference(HeapObject *ref) + { + if (!ref->object()) + return false; + + QV4::Scope scope(ref->internalClass->engine); + QV4::ScopedObject object(scope, ref->object()); + + if (ref->isVariant()) { + QVariant variant; + void *a[] = { &variant }; + return object->metacall(QMetaObject::ReadProperty, ref->property(), a) + && ref->setVariant(variant); + } + + void *a[] = { ref->storagePointer() }; + return object->metacall(QMetaObject::ReadProperty, ref->property(), a); + } + + template<typename HeapObject> + static bool writeBack(HeapObject *ref, int internalIndex = AllProperties) + { + if (!ref->object() || !ref->canWriteBack()) + return false; + + QV4::Scope scope(ref->internalClass->engine); + QV4::ScopedObject object(scope, ref->object()); + + int flags = QQmlPropertyData::HasInternalIndex; + int status = -1; + if (ref->isVariant()) { + QVariant variant = ref->toVariant(); + void *a[] = { &variant, nullptr, &status, &flags, &internalIndex }; + return object->metacall(QMetaObject::WriteProperty, ref->property(), a); + } + + void *a[] = { ref->storagePointer(), nullptr, &status, &flags, &internalIndex }; + return object->metacall(QMetaObject::WriteProperty, ref->property(), a); + } + + template<typename HeapObject> + static HeapObject *detached(HeapObject *ref) + { + if (ref->object() && !ref->enforcesLocation() && !readReference(ref)) + return ref; // It's dead. No point in detaching it anymore + + return ref->detached(); + } +}; + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4REFERENCEOBJECT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4reflect_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4reflect_p.h new file mode 100644 index 0000000000000000000000000000000000000000..96cb95068bb1d5db87923fa71e54766e1a5c3ceb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4reflect_p.h @@ -0,0 +1,53 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4REFLECT_H +#define QV4REFLECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct Reflect : Object { + void init(); +}; + +} + +struct Reflect : Object { + V4_OBJECT2(Reflect, Object) + + static ReturnedValue method_apply(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_construct(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_defineProperty(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_deleteProperty(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getOwnPropertyDescriptor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_getPrototypeOf(const FunctionObject *, const Value *, const Value *argv, int argc); + static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_isExtensible(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_ownKeys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_preventExtensions(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_setPrototypeOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4regexp_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4regexp_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d19c5e5e9ff63cdb7087742a1d5136dd15324c22 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4regexp_p.h @@ -0,0 +1,148 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4REGEXP_H +#define QV4REGEXP_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QString> +#include <QVector> + +#include <wtf/RefPtr.h> +#include <wtf/FastAllocBase.h> +#include <wtf/BumpPointerAllocator.h> + +#include <limits.h> + +#include <yarr/Yarr.h> +#include <yarr/YarrInterpreter.h> +#include <yarr/YarrJIT.h> + +#include "qv4managed_p.h" +#include "qv4engine_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct ExecutionEngine; +struct RegExpCacheKey; + +namespace Heap { + +struct RegExp : Base { + void init(ExecutionEngine *engine, const QString& pattern, uint flags); + void destroy(); + + QString *pattern; + JSC::Yarr::BytecodePattern *byteCode; +#if ENABLE(YARR_JIT) + JSC::Yarr::YarrCodeBlock *jitCode; +#endif + bool hasValidJITCode() const { +#if ENABLE(YARR_JIT) + return jitCode && !jitCode->failureReason().has_value() && jitCode->has16BitCode(); +#else + return false; +#endif + } + + bool ignoreCase() const { return flags & CompiledData::RegExp::RegExp_IgnoreCase; } + bool multiLine() const { return flags & CompiledData::RegExp::RegExp_Multiline; } + bool global() const { return flags & CompiledData::RegExp::RegExp_Global; } + bool unicode() const { return flags & CompiledData::RegExp::RegExp_Unicode; } + bool sticky() const { return flags & CompiledData::RegExp::RegExp_Sticky; } + + RegExpCache *cache; + int subPatternCount; + uint flags; + bool valid; + bool jitFailed; + quint8 matchCount; + + QString flagsAsString() const; + int captureCount() const { return subPatternCount + 1; } +}; +Q_STATIC_ASSERT(std::is_trivial_v<RegExp>); + +} + +struct RegExp : public Managed +{ + V4_MANAGED(RegExp, Managed) + Q_MANAGED_TYPE(RegExp) + V4_NEEDS_DESTROY + V4_INTERNALCLASS(RegExp) + + QString pattern() const { return *d()->pattern; } + JSC::Yarr::BytecodePattern *byteCode() { return d()->byteCode; } +#if ENABLE(YARR_JIT) + JSC::Yarr::YarrCodeBlock *jitCode() const { return d()->jitCode; } +#endif + RegExpCache *cache() const { return d()->cache; } + int subPatternCount() const { return d()->subPatternCount; } + bool ignoreCase() const { return d()->ignoreCase(); } + bool multiLine() const { return d()->multiLine(); } + bool global() const { return d()->global(); } + bool unicode() const { return d()->unicode(); } + bool sticky() const { return d()->sticky(); } + + static Heap::RegExp *create(ExecutionEngine* engine, const QString& pattern, uint flags = CompiledData::RegExp::RegExp_NoFlags); + + bool isValid() const { return d()->valid; } + + uint match(const QString& string, int start, uint *matchOffsets); + + int captureCount() const { return subPatternCount() + 1; } + + static QString getSubstitution(const QString &matched, const QString &str, int position, const Value *captures, int nCaptures, const QString &replacement); + + friend class RegExpCache; +}; + +struct RegExpCacheKey +{ + RegExpCacheKey(const QString &pattern, uint flags) + : pattern(pattern), flags(flags) + { } + explicit inline RegExpCacheKey(const RegExp::Data *re); + + bool operator==(const RegExpCacheKey &other) const + { return pattern == other.pattern && flags == other.flags;; } + bool operator!=(const RegExpCacheKey &other) const + { return !operator==(other); } + + QString pattern; + uint flags; +}; + +inline RegExpCacheKey::RegExpCacheKey(const RegExp::Data *re) + : pattern(*re->pattern) + , flags(re->flags) +{} + +inline size_t qHash(const RegExpCacheKey& key, size_t seed = 0) noexcept +{ return qHash(key.pattern, seed); } + +class RegExpCache : public QHash<RegExpCacheKey, WeakValue> +{ +public: + ~RegExpCache(); +}; + + + +} + +QT_END_NAMESPACE + +#endif // QV4REGEXP_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4regexpobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4regexpobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..74aafd9e2be8456c4192e392692ac8bea14d36f5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4regexpobject_p.h @@ -0,0 +1,178 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4REGEXPOBJECT_H +#define QV4REGEXPOBJECT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4context_p.h> +#include <private/qv4engine_p.h> +#include <private/qv4functionobject_p.h> +#include <private/qv4managed_p.h> + +#include <QtCore/qhash.h> +#include <QtCore/qstring.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +#define RegExpObjectMembers(class, Member) \ + Member(class, Pointer, RegExp *, value) + +DECLARE_HEAP_OBJECT(RegExpObject, Object) { + DECLARE_MARKOBJECTS(RegExpObject) + + void init(); + void init(QV4::RegExp *value); +#if QT_CONFIG(regularexpression) + void init(const QRegularExpression &re); +#endif +}; + +#define RegExpCtorMembers(class, Member) \ + Member(class, HeapValue, HeapValue, lastMatch) \ + Member(class, Pointer, String *, lastInput) \ + Member(class, NoMark, int, lastMatchStart) \ + Member(class, NoMark, int, lastMatchEnd) + +DECLARE_HEAP_OBJECT(RegExpCtor, FunctionObject) { + DECLARE_MARKOBJECTS(RegExpCtor) + + void init(ExecutionEngine *engine); + void clearLastMatch(); +}; + +} + +struct Q_QML_EXPORT RegExpObject: Object { + V4_OBJECT2(RegExpObject, Object) + Q_MANAGED_TYPE(RegExpObject) + V4_INTERNALCLASS(RegExpObject) + V4_PROTOTYPE(regExpPrototype) + + // needs to be compatible with the flags in qv4compileddata_p.h + enum Flags { + RegExp_Global = 0x01, + RegExp_IgnoreCase = 0x02, + RegExp_Multiline = 0x04, + RegExp_Unicode = 0x08, + RegExp_Sticky = 0x10 + }; + + enum { + Index_LastIndex = 0, + Index_ArrayIndex = Heap::ArrayObject::LengthPropertyIndex + 1, + Index_ArrayInput = Index_ArrayIndex + 1 + }; + + enum { NInlineProperties = 5 }; + + + void initProperties(); + + int lastIndex() const { + Q_ASSERT(internalClass()->verifyIndex(engine()->id_lastIndex()->propertyKey(), Index_LastIndex)); + return propertyData(Index_LastIndex)->toInt32(); + } + void setLastIndex(int index) { + Q_ASSERT(internalClass()->verifyIndex(engine()->id_lastIndex()->propertyKey(), Index_LastIndex)); + if (!internalClass()->propertyData[Index_LastIndex].isWritable()) { + engine()->throwTypeError(); + return; + } + return setProperty(Index_LastIndex, Value::fromInt32(index)); + } + +#if QT_CONFIG(regularexpression) + QRegularExpression toQRegularExpression() const; +#endif + QString toString() const; + QString source() const + { + Scope scope(engine()); + ScopedValue s(scope, get(scope.engine->id_source())); + return s->toQString(); + } + + // We cannot name Heap::RegExp here since we don't want to include qv4regexp_p.h but we still + // want to keep the methods inline. We shift the requirement to name the type to the caller by + // making it a template. + template<typename RegExp = Heap::RegExp> + RegExp *value() const { return d()->value; } + template<typename RegExp = Heap::RegExp> + uint flags() const { return value<RegExp>()->flags; } + template<typename RegExp = Heap::RegExp> + bool global() const { return value<RegExp>()->global(); } + template<typename RegExp = Heap::RegExp> + bool sticky() const { return value<RegExp>()->sticky(); } + template<typename RegExp = Heap::RegExp> + bool unicode() const { return value<RegExp>()->unicode(); } + + ReturnedValue builtinExec(ExecutionEngine *engine, const String *s); +}; + +struct RegExpCtor: FunctionObject +{ + V4_OBJECT2(RegExpCtor, FunctionObject) + + Value lastMatch() { return d()->lastMatch; } + Heap::String *lastInput() { return d()->lastInput; } + int lastMatchStart() { return d()->lastMatchStart; } + int lastMatchEnd() { return d()->lastMatchEnd; } + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct RegExpPrototype: Object +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_exec(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_flags(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_global(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_ignoreCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_match(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_multiline(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_replace(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_search(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_source(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_split(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_sticky(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_test(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_unicode(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + // Web extension + static ReturnedValue method_compile(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + // properties on the constructor, web extensions + template <uint index> + static ReturnedValue method_get_lastMatch_n(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_lastParen(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_input(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_leftContext(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_rightContext(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue execFirstMatch(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue exec(ExecutionEngine *engine, const Object *o, const String *s); +}; + +} + +QT_END_NAMESPACE + +#endif // QMLJS_OBJECTS_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4resolvedtypereference_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4resolvedtypereference_p.h new file mode 100644 index 0000000000000000000000000000000000000000..df2a7787f9cbb484144e01234db6d1ad3c825a45 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4resolvedtypereference_p.h @@ -0,0 +1,113 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4RESOLVEDTYPEREFERNCE_P_H +#define QV4RESOLVEDTYPEREFERNCE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qtqmlglobal_p.h> +#include <QtQml/private/qqmlrefcount_p.h> +#include <QtQml/private/qqmlpropertycache_p.h> +#include <QtQml/private/qqmltype_p.h> +#include <QtQml/private/qv4compileddata_p.h> + +QT_BEGIN_NAMESPACE + +class QCryptographicHash; +namespace QV4 { + +class ResolvedTypeReference +{ + Q_DISABLE_COPY_MOVE(ResolvedTypeReference) +public: + ResolvedTypeReference() = default; + ~ResolvedTypeReference() + { + if (m_stronglyReferencesCompilationUnit && m_compilationUnit) + m_compilationUnit->release(); + } + + QQmlPropertyCache::ConstPtr propertyCache() const; + QQmlPropertyCache::ConstPtr createPropertyCache(); + bool addToHash(QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums); + + void doDynamicTypeCheck(); + + QQmlType type() const { return m_type; } + void setType(QQmlType type) { m_type = std::move(type); } + + QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit() + { + return m_compilationUnit; + } + + void setCompilationUnit(QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit) + { + if (m_compilationUnit == unit.data()) + return; + if (m_stronglyReferencesCompilationUnit) { + if (m_compilationUnit) + m_compilationUnit->release(); + m_compilationUnit = unit.take(); + } else { + m_compilationUnit = unit.data(); + } + } + + bool referencesCompilationUnit() const { return m_stronglyReferencesCompilationUnit; } + void setReferencesCompilationUnit(bool doReference) + { + if (doReference == m_stronglyReferencesCompilationUnit) + return; + m_stronglyReferencesCompilationUnit = doReference; + if (!m_compilationUnit) + return; + if (doReference) { + m_compilationUnit->addref(); + } else if (m_compilationUnit->count() == 1) { + m_compilationUnit->release(); + m_compilationUnit = nullptr; + } else { + m_compilationUnit->release(); + } + } + + QQmlPropertyCache::ConstPtr typePropertyCache() const { return m_typePropertyCache; } + void setTypePropertyCache(QQmlPropertyCache::ConstPtr cache) + { + m_typePropertyCache = std::move(cache); + } + + QTypeRevision version() const { return m_version; } + void setVersion(QTypeRevision version) { m_version = version; } + + bool isFullyDynamicType() const { return m_isFullyDynamicType; } + void setFullyDynamicType(bool fullyDynamic) { m_isFullyDynamicType = fullyDynamic; } + +private: + QQmlType m_type; + QQmlPropertyCache::ConstPtr m_typePropertyCache; + QV4::CompiledData::CompilationUnit *m_compilationUnit = nullptr; + + QTypeRevision m_version = QTypeRevision::zero(); + // Types such as QQmlPropertyMap can add properties dynamically at run-time and + // therefore cannot have a property cache installed when instantiated. + bool m_isFullyDynamicType = false; + bool m_stronglyReferencesCompilationUnit = true; +}; + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4RESOLVEDTYPEREFERNCE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4runtime_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4runtime_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8179020ff499fac67cb0dc48efa83fb70a49eb76 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4runtime_p.h @@ -0,0 +1,97 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QMLJS_RUNTIME_H +#define QMLJS_RUNTIME_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" +#include "qv4value_p.h" +#include "qv4runtimeapi_p.h" +#include <QtCore/qnumeric.h> + +QT_BEGIN_NAMESPACE + +#undef QV4_COUNT_RUNTIME_FUNCTIONS + +namespace QV4 { + +#ifdef QV4_COUNT_RUNTIME_FUNCTIONS +class RuntimeCounters +{ +public: + RuntimeCounters(); + ~RuntimeCounters(); + + static RuntimeCounters *instance; + + void count(const char *func); + void count(const char *func, uint tag); + void count(const char *func, uint tag1, uint tag2); + +private: + struct Data; + Data *d; +}; + +# define TRACE0() RuntimeCounters::instance->count(Q_FUNC_INFO); +# define TRACE1(x) RuntimeCounters::instance->count(Q_FUNC_INFO, x.type()); +# define TRACE2(x, y) RuntimeCounters::instance->count(Q_FUNC_INFO, x.type(), y.type()); +#else +# define TRACE0() +# define TRACE1(x) +# define TRACE2(x, y) +#endif // QV4_COUNT_RUNTIME_FUNCTIONS + +enum TypeHint { + PREFERREDTYPE_HINT, + NUMBER_HINT, + STRING_HINT +}; + +struct Q_QML_EXPORT RuntimeHelpers { + static ReturnedValue objectDefaultValue(const Object *object, int typeHint); + static ReturnedValue toPrimitive(const Value &value, TypeHint typeHint); + static ReturnedValue ordinaryToPrimitive(ExecutionEngine *engine, const Object *object, String *typeHint); + + static double stringToNumber(const QString &s); + static Heap::String *stringFromNumber(ExecutionEngine *engine, double number); + static double toNumber(const Value &value); + static void numberToString(QString *result, double num, int radix = 10); + + static Heap::String *convertToString(ExecutionEngine *engine, Value value, TypeHint = STRING_HINT); + static Heap::Object *convertToObject(ExecutionEngine *engine, const Value &value); + + static Bool equalHelper(const Value &x, const Value &y); + static Bool strictEqual(const Value &x, const Value &y); + + static ReturnedValue addHelper(ExecutionEngine *engine, const Value &left, const Value &right); +}; + + +// type conversion and testing +inline ReturnedValue RuntimeHelpers::toPrimitive(const Value &value, TypeHint typeHint) +{ + if (!value.isObject()) + return value.asReturnedValue(); + return RuntimeHelpers::objectDefaultValue(&reinterpret_cast<const Object &>(value), typeHint); +} + +inline double RuntimeHelpers::toNumber(const Value &value) +{ + return value.toNumber(); +} +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QMLJS_RUNTIME_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4runtimeapi_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4runtimeapi_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e31a905d511c2c7f7ff648542d50cce1359528d2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4runtimeapi_p.h @@ -0,0 +1,485 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4RUNTIMEAPI_P_H +#define QV4RUNTIMEAPI_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <private/qv4staticvalue_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +typedef uint Bool; + +struct Q_QML_EXPORT Runtime { + typedef ReturnedValue (*UnaryOperation)(const Value &value); + typedef ReturnedValue (*BinaryOperation)(const Value &left, const Value &right); + typedef ReturnedValue (*BinaryOperationContext)(ExecutionEngine *, const Value &left, const Value &right); + + enum class Throws { No, Yes }; + enum class ChangesContext { No, Yes }; + enum class Pure { No, Yes }; + enum class LastArgumentIsOutputValue { No, Yes }; + + template<Throws t, ChangesContext c = ChangesContext::No, Pure p = Pure::No, + LastArgumentIsOutputValue out = LastArgumentIsOutputValue::No> + struct Method + { + static constexpr bool throws = t == Throws::Yes; + static constexpr bool changesContext = c == ChangesContext::Yes; + static constexpr bool pure = p == Pure::Yes; + static constexpr bool lastArgumentIsOutputValue = out == LastArgumentIsOutputValue::Yes; + }; + using PureMethod = Method<Throws::No, ChangesContext::No, Pure::Yes>; + using IteratorMethod = Method<Throws::No, ChangesContext::No, Pure::No, + LastArgumentIsOutputValue::Yes>; + + /* call */ + struct Q_QML_EXPORT CallGlobalLookup : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, uint, Value[], int); + }; + struct Q_QML_EXPORT CallQmlContextPropertyLookup : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, uint, Value[], int); + }; + struct Q_QML_EXPORT CallName : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, int, Value[], int); + }; + struct Q_QML_EXPORT CallProperty : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, int, Value[], int); + }; + struct Q_QML_EXPORT CallPropertyLookup : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, uint, Value[], int); + }; + struct Q_QML_EXPORT CallValue : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, Value[], int); + }; + struct Q_QML_EXPORT CallWithReceiver : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, const Value &, Value[], int); + }; + struct Q_QML_EXPORT CallPossiblyDirectEval : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, Value[], int); + }; + struct Q_QML_EXPORT CallWithSpread : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, const Value &, Value[], int); + }; + struct Q_QML_EXPORT TailCall : Method<Throws::Yes> + { + static ReturnedValue call(JSTypesStackFrame *, ExecutionEngine *engine); + }; + + /* construct */ + struct Q_QML_EXPORT Construct : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, const Value &, Value[], int); + }; + struct Q_QML_EXPORT ConstructWithSpread : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, const Value &, Value[], int); + }; + + /* load & store */ + struct Q_QML_EXPORT StoreNameStrict : Method<Throws::Yes> + { + static void call(ExecutionEngine *, int, const Value &); + }; + struct Q_QML_EXPORT StoreNameSloppy : Method<Throws::Yes> + { + static void call(ExecutionEngine *, int, const Value &); + }; + struct Q_QML_EXPORT StoreProperty : Method<Throws::Yes> + { + static void call(ExecutionEngine *, const Value &, int, const Value &); + }; + struct Q_QML_EXPORT StoreElement : Method<Throws::Yes> + { + static void call(ExecutionEngine *, const Value &, const Value &, const Value &); + }; + struct Q_QML_EXPORT LoadProperty : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, int); + }; + struct Q_QML_EXPORT LoadName : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, int); + }; + struct Q_QML_EXPORT LoadElement : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, const Value &); + }; + struct Q_QML_EXPORT LoadSuperProperty : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &); + }; + struct Q_QML_EXPORT StoreSuperProperty : Method<Throws::Yes> + { + static void call(ExecutionEngine *, const Value &, const Value &); + }; + struct Q_QML_EXPORT LoadSuperConstructor : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &); + }; + struct Q_QML_EXPORT LoadGlobalLookup : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, Function *, int); + }; + struct Q_QML_EXPORT LoadQmlContextPropertyLookup : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, uint); + }; + struct Q_QML_EXPORT GetLookup : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, Function *, const Value &, int); + }; + struct Q_QML_EXPORT SetLookupStrict : Method<Throws::Yes> + { + static void call(Function *, const Value &, int, const Value &); + }; + struct Q_QML_EXPORT SetLookupSloppy : Method<Throws::Yes> + { + static void call(Function *, const Value &, int, const Value &); + }; + + /* typeof */ + struct Q_QML_EXPORT TypeofValue : PureMethod + { + static ReturnedValue call(ExecutionEngine *, const Value &); + }; + struct Q_QML_EXPORT TypeofName : Method<Throws::No> + { + static ReturnedValue call(ExecutionEngine *, int); + }; + + /* delete */ + struct Q_QML_EXPORT DeleteProperty_NoThrow : Method<Throws::No> + { + static Bool call(ExecutionEngine *, const Value &, const Value &); + }; + struct Q_QML_EXPORT DeleteProperty : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, Function *, const Value &, const Value &); + }; + struct Q_QML_EXPORT DeleteName_NoThrow : Method<Throws::No> + { + static Bool call(ExecutionEngine *, int); + }; + struct Q_QML_EXPORT DeleteName : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, Function *, int); + }; + + /* exceptions & scopes */ + struct Q_QML_EXPORT ThrowException : Method<Throws::Yes> + { + static void call(ExecutionEngine *, const Value &); + }; + struct Q_QML_EXPORT PushCallContext : Method<Throws::No, ChangesContext::Yes> + { + static void call(JSTypesStackFrame *); + }; + struct Q_QML_EXPORT PushWithContext : Method<Throws::Yes, ChangesContext::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &); + }; + struct Q_QML_EXPORT PushCatchContext : Method<Throws::No, ChangesContext::Yes> + { + static void call(ExecutionEngine *, int, int); + }; + struct Q_QML_EXPORT PushBlockContext : Method<Throws::No, ChangesContext::Yes> + { + static void call(ExecutionEngine *, int); + }; + struct Q_QML_EXPORT CloneBlockContext : Method<Throws::No, ChangesContext::Yes> + { + static void call(ExecutionEngine *); + }; + struct Q_QML_EXPORT PushScriptContext : Method<Throws::No, ChangesContext::Yes> + { + static void call(ExecutionEngine *, int); + }; + struct Q_QML_EXPORT PopScriptContext : Method<Throws::No, ChangesContext::Yes> + { + static void call(ExecutionEngine *); + }; + struct Q_QML_EXPORT ThrowReferenceError : Method<Throws::Yes> + { + static void call(ExecutionEngine *, int); + }; + struct Q_QML_EXPORT ThrowOnNullOrUndefined : Method<Throws::Yes> + { + static void call(ExecutionEngine *, const Value &); + }; + + /* garbage collection */ + struct Q_QML_EXPORT MarkCustom : PureMethod + { + static void call(const Value &toBeMarked); + }; + + /* closures */ + struct Q_QML_EXPORT Closure : Method<Throws::No> + { + static ReturnedValue call(ExecutionEngine *, int); + }; + + /* Function header */ + struct Q_QML_EXPORT ConvertThisToObject : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &); + }; + struct Q_QML_EXPORT DeclareVar : Method<Throws::Yes> + { + static void call(ExecutionEngine *, Bool, int); + }; + struct Q_QML_EXPORT CreateMappedArgumentsObject : Method<Throws::No> + { + static ReturnedValue call(ExecutionEngine *); + }; + struct Q_QML_EXPORT CreateUnmappedArgumentsObject : Method<Throws::No> + { + static ReturnedValue call(ExecutionEngine *); + }; + struct Q_QML_EXPORT CreateRestParameter : PureMethod + { + static ReturnedValue call(ExecutionEngine *, int); + }; + + /* literals */ + struct Q_QML_EXPORT ArrayLiteral : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, Value[], uint); + }; + struct Q_QML_EXPORT ObjectLiteral : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, int, Value[], int); + }; + struct Q_QML_EXPORT CreateClass : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, int, const Value &, Value[]); + }; + + /* for-in, for-of and array destructuring */ + struct Q_QML_EXPORT GetIterator : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, int); + }; + struct Q_QML_EXPORT IteratorNext : IteratorMethod + { + static ReturnedValue call(ExecutionEngine *, const Value &, Value *); + }; + struct Q_QML_EXPORT IteratorNextForYieldStar : IteratorMethod + { + static ReturnedValue call(ExecutionEngine *, const Value &, const Value &, Value *); + }; + struct Q_QML_EXPORT IteratorClose : Method<Throws::No> + { + static ReturnedValue call(ExecutionEngine *, const Value &); + }; + struct Q_QML_EXPORT DestructureRestElement : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &); + }; + + /* conversions */ + struct Q_QML_EXPORT ToObject : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &); + }; + struct Q_QML_EXPORT ToBoolean : PureMethod + { + static Bool call(const Value &); + }; + struct Q_QML_EXPORT ToNumber : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &); + }; + /* unary operators */ + struct Q_QML_EXPORT UMinus : Method<Throws::Yes> + { + static ReturnedValue call(const Value &); + }; + + /* binary operators */ + struct Q_QML_EXPORT Instanceof : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, const Value &); + }; + struct Q_QML_EXPORT As : Method<Throws::No> + { + static ReturnedValue call(ExecutionEngine *, const Value &, const Value &); + }; + struct Q_QML_EXPORT In : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, const Value &); + }; + struct Q_QML_EXPORT Add : Method<Throws::Yes> + { + static ReturnedValue call(ExecutionEngine *, const Value &, const Value &); + }; + struct Q_QML_EXPORT Sub : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT Mul : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT Div : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT Mod : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT Exp : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT BitAnd : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT BitOr : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT BitXor : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT Shl : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT Shr : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT UShr : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT GreaterThan : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT LessThan : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT GreaterEqual : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT LessEqual : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT Equal : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT NotEqual : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT StrictEqual : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + struct Q_QML_EXPORT StrictNotEqual : Method<Throws::Yes> + { + static ReturnedValue call(const Value &, const Value &); + }; + + /* comparisons */ + struct Q_QML_EXPORT CompareGreaterThan : Method<Throws::Yes> + { + static Bool call(const Value &, const Value &); + }; + struct Q_QML_EXPORT CompareLessThan : Method<Throws::Yes> + { + static Bool call(const Value &, const Value &); + }; + struct Q_QML_EXPORT CompareGreaterEqual : Method<Throws::Yes> + { + static Bool call(const Value &, const Value &); + }; + struct Q_QML_EXPORT CompareLessEqual : Method<Throws::Yes> + { + static Bool call(const Value &, const Value &); + }; + struct Q_QML_EXPORT CompareEqual : Method<Throws::Yes> + { + static Bool call(const Value &, const Value &); + }; + struct Q_QML_EXPORT CompareNotEqual : Method<Throws::Yes> + { + static Bool call(const Value &, const Value &); + }; + struct Q_QML_EXPORT CompareStrictEqual : Method<Throws::Yes> + { + static Bool call(const Value &, const Value &); + }; + struct Q_QML_EXPORT CompareStrictNotEqual : Method<Throws::Yes> + { + static Bool call(const Value &, const Value &); + }; + + struct Q_QML_EXPORT CompareInstanceof : Method<Throws::Yes> + { + static Bool call(ExecutionEngine *, const Value &, const Value &); + }; + struct Q_QML_EXPORT CompareIn : Method<Throws::Yes> + { + static Bool call(ExecutionEngine *, const Value &, const Value &); + }; + + struct Q_QML_EXPORT RegexpLiteral : PureMethod + { + static ReturnedValue call(ExecutionEngine *, int); + }; + struct Q_QML_EXPORT GetTemplateObject : PureMethod + { + static ReturnedValue call(Function *, int); + }; + + struct StackOffsets { + static const int tailCall_function = -1; + static const int tailCall_thisObject = -2; + static const int tailCall_argv = -3; + static const int tailCall_argc = -4; + }; + + static QHash<const void *, const char *> symbolTable(); +}; + +static_assert(std::is_standard_layout<Runtime>::value, "Runtime needs to be standard layout in order for us to be able to use offsetof"); +static_assert(sizeof(Runtime::BinaryOperation) == sizeof(void*), "JIT expects a function pointer to fit into a regular pointer, for cross-compilation offset translation"); + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4RUNTIMEAPI_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4runtimecodegen_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4runtimecodegen_p.h new file mode 100644 index 0000000000000000000000000000000000000000..359fe38064c484456feccc2c63d4d576fd76583f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4runtimecodegen_p.h @@ -0,0 +1,47 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4RUNTIMECODEGEN_P_H +#define QV4RUNTIMECODEGEN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4codegen_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +class RuntimeCodegen : public Compiler::Codegen +{ +public: + RuntimeCodegen(ExecutionEngine *engine, Compiler::JSUnitGenerator *jsUnitGenerator, bool strict) + : Codegen(jsUnitGenerator, strict) + , engine(engine) + {} + + void generateFromFunctionExpression(const QString &fileName, + const QString &sourceCode, + QQmlJS::AST::FunctionExpression *ast, + Compiler::Module *module); + + void throwSyntaxError(const QQmlJS::SourceLocation &loc, const QString &detail) override; + void throwReferenceError(const QQmlJS::SourceLocation &loc, const QString &detail) override; + +private: + ExecutionEngine *engine; +}; + +} + +QT_END_NAMESPACE + +#endif // QV4CODEGEN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4scopedvalue_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4scopedvalue_p.h new file mode 100644 index 0000000000000000000000000000000000000000..47dd621d3ff2d447b165766e906b240cc4c2e9f3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4scopedvalue_p.h @@ -0,0 +1,434 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4SCOPEDVALUE_P_H +#define QV4SCOPEDVALUE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4engine_p.h" +#include "qv4value_p.h" +#include "qv4property_p.h" +#include "qv4propertykey_p.h" + +#ifdef V4_USE_VALGRIND +#include <valgrind/memcheck.h> +#endif + +QT_BEGIN_NAMESPACE + +#define SAVE_JS_STACK(ctx) Value *__jsStack = ctx->engine->jsStackTop +#define CHECK_JS_STACK(ctx) Q_ASSERT(__jsStack == ctx->engine->jsStackTop) + +namespace QV4 { + +struct ScopedValue; + +inline bool hasExceptionOrIsInterrupted(ExecutionEngine *engine) +{ + return engine->hasException || engine->isInterrupted.loadRelaxed(); +} + +#define CHECK_EXCEPTION() \ + do { \ + if (hasExceptionOrIsInterrupted(scope.engine)) { \ + return QV4::Encode::undefined(); \ + } \ + } while (false) + +#define RETURN_UNDEFINED() \ + return QV4::Encode::undefined() + +#define RETURN_RESULT(r) \ + return QV4::Encode(r) + +#define THROW_TYPE_ERROR() \ + return scope.engine->throwTypeError() + +#define THROW_GENERIC_ERROR(str) \ + return scope.engine->throwError(QString::fromUtf8(str)) + +struct Scope { + explicit Scope(ExecutionContext *ctx) + : engine(ctx->engine()) + , mark(engine->jsStackTop) + { + } + + explicit Scope(ExecutionEngine *e) + : engine(e) + , mark(engine->jsStackTop) + { + } + + explicit Scope(const Managed *m) + : engine(m->engine()) + , mark(engine->jsStackTop) + { + } + + ~Scope() { +#ifndef QT_NO_DEBUG + Q_ASSERT(engine->jsStackTop >= mark); +// Q_ASSERT(engine->currentContext < mark); + memset(mark, 0, (engine->jsStackTop - mark)*sizeof(Value)); +#endif +#ifdef V4_USE_VALGRIND + VALGRIND_MAKE_MEM_UNDEFINED(mark, (engine->jsStackLimit - mark) * sizeof(Value)); +#endif + engine->jsStackTop = mark; + } + + enum AllocMode { + Undefined, + Empty, + /* Be careful when using Uninitialized, the stack has to be fully initialized before calling into the memory manager again */ + Uninitialized + }; + + template <AllocMode mode = Undefined> + Value *alloc(qint64 nValues) const = delete; // use safeForAllocLength + + template <AllocMode mode = Undefined> + QML_NEARLY_ALWAYS_INLINE Value *alloc(int nValues) const + { + Value *ptr = engine->jsAlloca(nValues); + switch (mode) { + case Undefined: + for (int i = 0; i < nValues; ++i) + ptr[i] = Value::undefinedValue(); + break; + case Empty: + for (int i = 0; i < nValues; ++i) + ptr[i] = Value::emptyValue(); + break; + case Uninitialized: + break; + } + return ptr; + } + template <AllocMode mode = Undefined> + QML_NEARLY_ALWAYS_INLINE Value *alloc() const + { + Value *ptr = engine->jsAlloca(1); + switch (mode) { + case Undefined: + *ptr = Value::undefinedValue(); + break; + case Empty: + *ptr = Value::emptyValue(); + break; + case Uninitialized: + break; + } + return ptr; + } + + bool hasException() const { + return engine->hasException; + } + + ExecutionEngine *engine; + Value *mark; + +private: + Q_DISABLE_COPY(Scope) +}; + +struct ScopedValue +{ + ScopedValue(const ScopedValue &) = default; + ScopedValue(ScopedValue &&) = default; + + ScopedValue(const Scope &scope) + { + ptr = scope.alloc<Scope::Uninitialized>(); + ptr->setRawValue(0); + } + + ScopedValue(const Scope &scope, const Value &v) + { + ptr = scope.alloc<Scope::Uninitialized>(); + *ptr = v; + } + + ScopedValue(const Scope &scope, Heap::Base *o) + { + ptr = scope.alloc<Scope::Uninitialized>(); + ptr->setM(o); + } + + ScopedValue(const Scope &scope, Managed *m) + { + ptr = scope.alloc<Scope::Uninitialized>(); + ptr->setRawValue(m->asReturnedValue()); + } + + ScopedValue(const Scope &scope, const ReturnedValue &v) + { + ptr = scope.alloc<Scope::Uninitialized>(); + ptr->setRawValue(v); + } + + ScopedValue &operator=(const Value &v) { + *ptr = v; + return *this; + } + + ScopedValue &operator=(Heap::Base *o) { + ptr->setM(o); + return *this; + } + + ScopedValue &operator=(Managed *m) { + *ptr = *m; + return *this; + } + + ScopedValue &operator=(const ReturnedValue &v) { + ptr->setRawValue(v); + return *this; + } + + ScopedValue &operator=(const ScopedValue &other) { + *ptr = *other.ptr; + return *this; + } + + Value *operator->() { + return ptr; + } + + const Value *operator->() const { + return ptr; + } + + operator Value *() { return ptr; } + operator const Value &() const { return *ptr; } + + Value *ptr; +}; + + +struct ScopedPropertyKey +{ + ScopedPropertyKey(const Scope &scope) + { + ptr = reinterpret_cast<PropertyKey *>(scope.alloc<Scope::Uninitialized>()); + *ptr = PropertyKey::invalid(); + } + + ScopedPropertyKey(const Scope &scope, const PropertyKey &v) + { + ptr = reinterpret_cast<PropertyKey *>(scope.alloc<Scope::Uninitialized>()); + *ptr = v; + } + + ScopedPropertyKey &operator=(const PropertyKey &other) { + *ptr = other; + return *this; + } + + PropertyKey *operator->() { + return ptr; + } + operator PropertyKey() const { + return *ptr; + } + + bool operator==(const PropertyKey &other) const { + return *ptr == other; + } + bool operator==(const ScopedPropertyKey &other) const { + return *ptr == *other.ptr; + } + bool operator!=(const PropertyKey &other) const { + return *ptr != other; + } + bool operator!=(const ScopedPropertyKey &other) const { + return *ptr != *other.ptr; + } + + PropertyKey *ptr; +}; + + +template<typename T> +struct Scoped +{ + enum ConvertType { Convert }; + + QML_NEARLY_ALWAYS_INLINE void setPointer(const Managed *p) { + ptr->setM(p ? p->m() : nullptr); + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope) + { + ptr = scope.alloc<Scope::Undefined>(); + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value &v) + { + ptr = scope.alloc<Scope::Uninitialized>(); + setPointer(v.as<T>()); + } + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, Heap::Base *o) + { + Value v; + v = o; + ptr = scope.alloc<Scope::Uninitialized>(); + setPointer(v.as<T>()); + } + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ScopedValue &v) + { + ptr = scope.alloc<Scope::Uninitialized>(); + setPointer(v.ptr->as<T>()); + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value &v, ConvertType) + { + ptr = scope.alloc<Scope::Uninitialized>(); + ptr->setRawValue(value_convert<T>(scope.engine, v)); + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value *v) + { + ptr = scope.alloc<Scope::Uninitialized>(); + setPointer(v ? v->as<T>() : nullptr); + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, T *t) + { + ptr = scope.alloc<Scope::Uninitialized>(); + setPointer(t); + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const T *t) + { + ptr = scope.alloc<Scope::Uninitialized>(); + setPointer(t); + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, typename T::Data *t) + { + ptr = scope.alloc<Scope::Uninitialized>(); + *ptr = t; + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ReturnedValue &v) + { + ptr = scope.alloc<Scope::Uninitialized>(); + setPointer(QV4::Value::fromReturnedValue(v).as<T>()); + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ReturnedValue &v, ConvertType) + { + ptr = scope.alloc<Scope::Uninitialized>(); + ptr->setRawValue(value_convert<T>(scope.engine, QV4::Value::fromReturnedValue(v))); + } + + Scoped<T> &operator=(Heap::Base *o) { + setPointer(Value::fromHeapObject(o).as<T>()); + return *this; + } + Scoped<T> &operator=(typename T::Data *t) { + *ptr = t; + return *this; + } + Scoped<T> &operator=(const Value &v) { + setPointer(v.as<T>()); + return *this; + } + Scoped<T> &operator=(Value *v) { + setPointer(v ? v->as<T>() : nullptr); + return *this; + } + + Scoped<T> &operator=(const ReturnedValue &v) { + setPointer(QV4::Value::fromReturnedValue(v).as<T>()); + return *this; + } + + Scoped<T> &operator=(T *t) { + setPointer(t); + return *this; + } + + operator T *() { + return static_cast<T *>(ptr->managed()); + } + operator const Value &() const { + return *ptr; + } + + T *operator->() { + return getPointer(); + } + + const T *operator->() const { + return getPointer(); + } + + explicit operator bool() const { + return ptr->m(); + } + + T *getPointer() { + return reinterpret_cast<T *>(ptr); + } + + const T *getPointer() const { + return reinterpret_cast<T *>(ptr); + } + + Value *getRef() { + return ptr; + } + + QML_NEARLY_ALWAYS_INLINE ReturnedValue asReturnedValue() const { + return ptr->rawValue(); + } + + Value *ptr; +}; + +inline Value &Value::operator =(const ScopedValue &v) +{ + _val = v.ptr->rawValue(); + return *this; +} + +template<typename T> +inline Value &Value::operator=(const Scoped<T> &t) +{ + _val = t.ptr->rawValue(); + return *this; +} + +struct ScopedProperty +{ + ScopedProperty(Scope &scope) + { + property = reinterpret_cast<Property*>(scope.alloc(int(sizeof(Property) / sizeof(Value)))); + } + + Property *operator->() { return property; } + operator const Property *() const { return property; } + operator Property *() { return property; } + + Property *property; +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4script_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4script_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e1736ebcb4882c3796f1641f164b33e6059ef860 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4script_p.h @@ -0,0 +1,81 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4SCRIPT_H +#define QV4SCRIPT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" +#include "qv4engine_p.h" +#include "qv4functionobject_p.h" +#include "qv4qmlcontext_p.h" +#include "private/qv4compilercontext_p.h" + +#include <QQmlError> + +QT_BEGIN_NAMESPACE + +class QQmlContextData; + +namespace QQmlJS { +class Engine; +} + +namespace QV4 { + +struct Q_QML_EXPORT Script { + Script(ExecutionContext *scope, QV4::Compiler::ContextType mode, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0) + : sourceFile(source), line(line), column(column), sourceCode(sourceCode) + , context(scope), strictMode(false), inheritContext(false), parsed(false), contextType(mode) + , parseAsBinding(false) {} + Script(ExecutionEngine *engine, QmlContext *qml, bool parseAsBinding, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0) + : sourceFile(source), line(line), column(column), sourceCode(sourceCode) + , context(engine->rootContext()), strictMode(false), inheritContext(true), parsed(false) + , parseAsBinding(parseAsBinding) { + if (qml) + qmlContext.set(engine, *qml); + } + Script(ExecutionEngine *engine, QmlContext *qml, const QQmlRefPointer<ExecutableCompilationUnit> &compilationUnit); + ~Script(); + QString sourceFile; + int line; + int column; + QString sourceCode; + ExecutionContext *context; + bool strictMode; + bool inheritContext; + bool parsed; + QV4::Compiler::ContextType contextType = QV4::Compiler::ContextType::Eval; + QV4::PersistentValue qmlContext; + QQmlRefPointer<ExecutableCompilationUnit> compilationUnit; + QV4::WriteBarrier::Pointer<Function> vmFunction; + bool parseAsBinding; + + void parse(); + ReturnedValue run(const QV4::Value *thisObject = nullptr); + + Function *function(); + + static QQmlRefPointer<QV4::CompiledData::CompilationUnit> precompile( + QV4::Compiler::Module *module, QQmlJS::Engine *jsEngine, + Compiler::JSUnitGenerator *unitGenerator, const QString &fileName, + const QString &finalUrl, const QString &source, + QList<QQmlError> *reportedErrors = nullptr, + QV4::Compiler::ContextType contextType = QV4::Compiler::ContextType::Global); + static Script *createFromFileOrCache(ExecutionEngine *engine, QmlContext *qmlContext, const QString &fileName, const QUrl &originalUrl, QString *error); +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4sequenceobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4sequenceobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3ce2878703313d4b78f703210d9682049b4ba2c5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4sequenceobject_p.h @@ -0,0 +1,155 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4SEQUENCEWRAPPER_P_H +#define QV4SEQUENCEWRAPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtCore/qvariant.h> +#include <QtQml/qqml.h> + +#include <private/qv4referenceobject_p.h> +#include <private/qv4value_p.h> +#include <private/qv4object_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct Sequence; +struct Q_QML_EXPORT SequencePrototype : public QV4::Object +{ + V4_PROTOTYPE(arrayPrototype) + void init(); + + static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_shift(const FunctionObject *b, const Value *thisObject, const Value *, int); + + static ReturnedValue newSequence( + QV4::ExecutionEngine *engine, QMetaType type, QMetaSequence metaSequence, const void *data, + Heap::Object *object, int propertyIndex, Heap::ReferenceObject::Flags flags); + static ReturnedValue fromVariant(QV4::ExecutionEngine *engine, const QVariant &vd); + static ReturnedValue fromData( + QV4::ExecutionEngine *engine, QMetaType type, QMetaSequence metaSequence, const void *data); + + static QMetaType metaTypeForSequence(const Sequence *object); + static QVariant toVariant(const Sequence *object); + static QVariant toVariant(const Value &array, QMetaType targetType); + static void *getRawContainerPtr(const Sequence *object, QMetaType typeHint); +}; + +namespace Heap { + +struct Sequence : ReferenceObject +{ + void init(QMetaType listType, QMetaSequence metaSequence, const void *container); + void init(QMetaType listType, QMetaSequence metaSequence, const void *container, + Object *object, int propertyIndex, Heap::ReferenceObject::Flags flags); + + Sequence *detached() const; + void destroy(); + + bool hasData() const { return m_container != nullptr; } + void *storagePointer(); + const void *storagePointer() const { return m_container; } + + bool isReadOnly() const { return m_object && !canWriteBack(); } + + bool setVariant(const QVariant &variant); + QVariant toVariant() const; + + QMetaType listType() const { return QMetaType(m_listType); } + QMetaType valueMetaType() const { return QMetaType(m_metaSequence->valueMetaType); } + QMetaSequence metaSequence() const { return QMetaSequence(m_metaSequence); } + +private: + void initTypes(QMetaType listType, QMetaSequence metaSequence); + + void *m_container; + const QtPrivate::QMetaTypeInterface *m_listType; + const QtMetaContainerPrivate::QMetaSequenceInterface *m_metaSequence; +}; + +} + +struct Q_QML_EXPORT Sequence : public QV4::ReferenceObject +{ + V4_OBJECT2(Sequence, QV4::ReferenceObject) + Q_MANAGED_TYPE(V4Sequence) + V4_PROTOTYPE(sequencePrototype) + V4_NEEDS_DESTROY +public: + static QV4::ReturnedValue virtualGet( + const QV4::Managed *that, PropertyKey id, const Value *receiver, bool *hasProperty); + static qint64 virtualGetLength(const Managed *m); + static bool virtualPut(Managed *that, PropertyKey id, const QV4::Value &value, Value *receiver); + static bool virtualDeleteProperty(QV4::Managed *that, PropertyKey id); + static bool virtualIsEqualTo(Managed *that, Managed *other); + static QV4::OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); + static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a); + + qsizetype size() const; + QVariant at(qsizetype index) const; + QVariant shift(); + void append(const QVariant &item); + void append(qsizetype num, const QVariant &item); + void replace(qsizetype index, const QVariant &item); + void removeLast(qsizetype num); + + QV4::ReturnedValue containerGetIndexed(qsizetype index, bool *hasProperty) const; + bool containerPutIndexed(qsizetype index, const QV4::Value &value); + bool containerDeleteIndexedProperty(qsizetype index); + bool containerIsEqualTo(Managed *other); + bool sort(const FunctionObject *f, const Value *, const Value *argv, int argc); + void *getRawContainerPtr() const; + bool loadReference() const; + bool storeReference(); +}; + +} + +#define QT_DECLARE_SEQUENTIAL_CONTAINER(LOCAL, FOREIGN, VALUE) \ + struct LOCAL \ + { \ + Q_GADGET \ + QML_ANONYMOUS \ + QML_SEQUENTIAL_CONTAINER(VALUE) \ + QML_FOREIGN(FOREIGN) \ + QML_ADDED_IN_VERSION(2, 0) \ + } + +// We use the original QT_COORD_TYPE name because that will match up with relevant other +// types in plugins.qmltypes (if you use either float or double, that is; otherwise you're +// on your own). +#ifdef QT_COORD_TYPE +QT_DECLARE_SEQUENTIAL_CONTAINER(QStdRealVectorForeign, std::vector<qreal>, QT_COORD_TYPE); +QT_DECLARE_SEQUENTIAL_CONTAINER(QRealListForeign, QList<qreal>, QT_COORD_TYPE); +#else +QT_DECLARE_SEQUENTIAL_CONTAINER(QRealStdVectorForeign, std::vector<qreal>, double); +QT_DECLARE_SEQUENTIAL_CONTAINER(QRealListForeign, QList<qreal>, double); +#endif + +QT_DECLARE_SEQUENTIAL_CONTAINER(QDoubleStdVectorForeign, std::vector<double>, double); +QT_DECLARE_SEQUENTIAL_CONTAINER(QFloatStdVectorForeign, std::vector<float>, float); +QT_DECLARE_SEQUENTIAL_CONTAINER(QIntStdVectorForeign, std::vector<int>, int); +QT_DECLARE_SEQUENTIAL_CONTAINER(QBoolStdVectorForeign, std::vector<bool>, bool); +QT_DECLARE_SEQUENTIAL_CONTAINER(QStringStdVectorForeign, std::vector<QString>, QString); +QT_DECLARE_SEQUENTIAL_CONTAINER(QUrlStdVectorForeign, std::vector<QUrl>, QUrl); + +#undef QT_DECLARE_SEQUENTIAL_CONTAINER + +QT_END_NAMESPACE + +#endif // QV4SEQUENCEWRAPPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4setiterator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4setiterator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4343987a2a1352d51a8f1262f253ca488131c4a0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4setiterator_p.h @@ -0,0 +1,67 @@ +// Copyright (C) 2018 Crimson AS <info@crimson.no> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4SETITERATOR_P_H +#define QV4SETITERATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4iterator_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +#define SetIteratorObjectMembers(class, Member) \ + Member(class, Pointer, Object *, iteratedSet) \ + Member(class, NoMark, IteratorKind, iterationKind) \ + Member(class, NoMark, quint32, setNextIndex) + +DECLARE_HEAP_OBJECT(SetIteratorObject, Object) { + DECLARE_MARKOBJECTS(SetIteratorObject) + void init(Object *obj, QV4::ExecutionEngine *engine) + { + Object::init(); + this->iteratedSet.set(engine, obj); + this->setNextIndex = 0; + } +}; + +} + +struct SetIteratorPrototype : Object +{ + V4_PROTOTYPE(iteratorPrototype) + void init(ExecutionEngine *engine); + + static ReturnedValue method_next(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); +}; + +struct SetIteratorObject : Object +{ + V4_OBJECT2(SetIteratorObject, Object) + Q_MANAGED_TYPE(SetIteratorObject) + V4_PROTOTYPE(setIteratorPrototype) + + void init(ExecutionEngine *engine); +}; + + +} + +QT_END_NAMESPACE + +#endif // QV4SETITERATOR_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4setobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4setobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8b2075d3894ac84f90e7a23fd56dcf12bae16910 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4setobject_p.h @@ -0,0 +1,108 @@ +// Copyright (C) 2018 Crimson AS <info@crimson.no> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4SETOBJECT_P_H +#define QV4SETOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4objectproto_p.h" +#include "qv4functionobject_p.h" +#include "qv4string_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +class ESTable; + +namespace Heap { + +struct WeakSetCtor : FunctionObject { + void init(ExecutionEngine *engine); +}; + + +struct SetCtor : WeakSetCtor { + void init(ExecutionEngine *engine); +}; + +struct SetObject : Object { + static void markObjects(Heap::Base *that, MarkStack *markStack); + void init(); + void destroy(); + void removeUnmarkedKeys(); + + ESTable *esTable; + SetObject *nextWeakSet; + bool isWeakSet; +}; + +} + + +struct WeakSetCtor: FunctionObject +{ + V4_OBJECT2(WeakSetCtor, FunctionObject) + + static ReturnedValue construct(const FunctionObject *f, const Value *argv, int argc, const Value *, bool weakSet); + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct SetCtor : WeakSetCtor +{ + V4_OBJECT2(SetCtor, WeakSetCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + +struct SetObject : Object +{ + V4_OBJECT2(SetObject, Object) + V4_PROTOTYPE(setPrototype) + V4_NEEDS_DESTROY +}; + +struct WeakSetPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor); + + Q_AUTOTEST_EXPORT static ReturnedValue method_add(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + + +struct SetPrototype : WeakSetPrototype +{ + void init(ExecutionEngine *engine, Object *ctor); + + Q_AUTOTEST_EXPORT static ReturnedValue method_add(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_clear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_size(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + + +} // namespace QV4 + + +QT_END_NAMESPACE + +#endif // QV4SETOBJECT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4sparsearray_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4sparsearray_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dfffde88212c4a7dd7b1a3f9a1454d76eb1fe53b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4sparsearray_p.h @@ -0,0 +1,335 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4SPARSEARRAY_H +#define QV4SPARSEARRAY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" +#include "qv4value_p.h" +#include <QtCore/qlist.h> + +//#define Q_MAP_DEBUG +#ifdef Q_MAP_DEBUG +#include <QtCore/qdebug.h> +#endif + +#include <new> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct SparseArray; + +struct SparseArrayNode +{ + quintptr p; + SparseArrayNode *left; + SparseArrayNode *right; + uint size_left; + uint value; + + enum Color { Red = 0, Black = 1 }; + enum { Mask = 3 }; // reserve the second bit as well + + const SparseArrayNode *nextNode() const; + SparseArrayNode *nextNode() { return const_cast<SparseArrayNode *>(const_cast<const SparseArrayNode *>(this)->nextNode()); } + const SparseArrayNode *previousNode() const; + SparseArrayNode *previousNode() { return const_cast<SparseArrayNode *>(const_cast<const SparseArrayNode *>(this)->previousNode()); } + + Color color() const { return Color(p & 1); } + void setColor(Color c) { if (c == Black) p |= Black; else p &= ~Black; } + SparseArrayNode *parent() const { return reinterpret_cast<SparseArrayNode *>(p & ~Mask); } + void setParent(SparseArrayNode *pp) { p = (p & Mask) | quintptr(pp); } + + uint key() const { + uint k = size_left; + const SparseArrayNode *n = this; + while (SparseArrayNode *p = n->parent()) { + if (p && p->right == n) + k += p->size_left; + n = p; + } + return k; + } + + SparseArrayNode *copy(SparseArray *d) const; + + SparseArrayNode *lowerBound(uint key); + SparseArrayNode *upperBound(uint key); +}; + + +inline SparseArrayNode *SparseArrayNode::lowerBound(uint akey) +{ + SparseArrayNode *n = this; + SparseArrayNode *last = nullptr; + while (n) { + if (akey <= n->size_left) { + last = n; + n = n->left; + } else { + akey -= n->size_left; + n = n->right; + } + } + return last; +} + + +inline SparseArrayNode *SparseArrayNode::upperBound(uint akey) +{ + SparseArrayNode *n = this; + SparseArrayNode *last = nullptr; + while (n) { + if (akey < n->size_left) { + last = n; + n = n->left; + } else { + akey -= n->size_left; + n = n->right; + } + } + return last; +} + + + +struct Q_QML_EXPORT SparseArray +{ + SparseArray(); + ~SparseArray() { + if (SparseArrayNode *n = root()) + freeTree(n, alignof(SparseArrayNode)); + } + + SparseArray(const SparseArray &other); + + Value freeList; +private: + SparseArray &operator=(const SparseArray &other); + + int numEntries; + SparseArrayNode header; + SparseArrayNode *mostLeftNode; + + void rotateLeft(SparseArrayNode *x); + void rotateRight(SparseArrayNode *x); + void rebalance(SparseArrayNode *x); + void recalcMostLeftNode(); + + SparseArrayNode *root() const { return header.left; } + + void deleteNode(SparseArrayNode *z); + + +public: + SparseArrayNode *createNode(uint sl, SparseArrayNode *parent, bool left); + void freeTree(SparseArrayNode *root, int alignment); + + SparseArrayNode *findNode(uint akey) const; + + uint nEntries() const { return numEntries; } + + uint pop_front(); + void push_front(uint at); + uint pop_back(uint len); + void push_back(uint at, uint len); + + QList<int> keys() const; + + const SparseArrayNode *end() const { return &header; } + SparseArrayNode *end() { return &header; } + const SparseArrayNode *begin() const { if (root()) return mostLeftNode; return end(); } + SparseArrayNode *begin() { if (root()) return mostLeftNode; return end(); } + + SparseArrayNode *erase(SparseArrayNode *n); + + SparseArrayNode *lowerBound(uint key); + const SparseArrayNode *lowerBound(uint key) const; + SparseArrayNode *upperBound(uint key); + const SparseArrayNode *upperBound(uint key) const; + SparseArrayNode *insert(uint akey); + + // STL compatibility + typedef uint key_type; + typedef int mapped_type; + typedef qptrdiff difference_type; + typedef int size_type; + +#ifdef Q_MAP_DEBUG + void dump() const; +#endif +}; + +inline SparseArrayNode *SparseArray::findNode(uint akey) const +{ + SparseArrayNode *n = root(); + + while (n) { + if (akey == n->size_left) { + return n; + } else if (akey < n->size_left) { + n = n->left; + } else { + akey -= n->size_left; + n = n->right; + } + } + + return nullptr; +} + +inline uint SparseArray::pop_front() +{ + uint idx = UINT_MAX ; + + SparseArrayNode *n = findNode(0); + if (n) { + idx = n->value; + deleteNode(n); + // adjust all size_left indices on the path to leftmost item by 1 + SparseArrayNode *rootNode = root(); + while (rootNode) { + rootNode->size_left -= 1; + rootNode = rootNode->left; + } + } + return idx; +} + +inline void SparseArray::push_front(uint value) +{ + // adjust all size_left indices on the path to leftmost item by 1 + SparseArrayNode *n = root(); + while (n) { + n->size_left += 1; + n = n->left; + } + n = insert(0); + n->value = value; +} + +inline uint SparseArray::pop_back(uint len) +{ + uint idx = UINT_MAX; + if (!len) + return idx; + + SparseArrayNode *n = findNode(len - 1); + if (n) { + idx = n->value; + deleteNode(n); + } + return idx; +} + +inline void SparseArray::push_back(uint index, uint len) +{ + SparseArrayNode *n = insert(len); + n->value = index; +} + +#ifdef Q_MAP_DEBUG +inline void SparseArray::dump() const +{ + const SparseArrayNode *it = begin(); + qDebug() << "map dump:"; + while (it != end()) { + const SparseArrayNode *n = it; + int depth = 0; + while (n && n != root()) { + ++depth; + n = n->parent(); + } + QByteArray space(4*depth, ' '); + qDebug() << space << (it->color() == SparseArrayNode::Red ? "Red " : "Black") << it << it->size_left << it->left << it->right + << it->key() << it->value; + it = it->nextNode(); + } + qDebug() << "---------"; +} +#endif + + +inline SparseArrayNode *SparseArray::erase(SparseArrayNode *n) +{ + if (n == end()) + return n; + + SparseArrayNode *next = n->nextNode(); + deleteNode(n); + return next; +} + +inline QList<int> SparseArray::keys() const +{ + QList<int> res; + res.reserve(numEntries); + SparseArrayNode *n = mostLeftNode; + while (n != end()) { + res.append(n->key()); + n = n->nextNode(); + } + return res; +} + +inline const SparseArrayNode *SparseArray::lowerBound(uint akey) const +{ + if (SparseArrayNode *n = root()) { + if (const SparseArrayNode *lb = n->lowerBound(akey)) + return lb; + } + + return end(); +} + + +inline SparseArrayNode *SparseArray::lowerBound(uint akey) +{ + if (SparseArrayNode *n = root()) { + if (SparseArrayNode *lb = n->lowerBound(akey)) + return lb; + } + + return end(); +} + + +inline const SparseArrayNode *SparseArray::upperBound(uint akey) const +{ + if (SparseArrayNode *n = root()) { + if (const SparseArrayNode *ub = n->upperBound(akey)) + return ub; + } + + return end(); +} + + +inline SparseArrayNode *SparseArray::upperBound(uint akey) +{ + if (SparseArrayNode *n = root()) { + if (SparseArrayNode *ub = n->upperBound(akey)) + return ub; + } + + return end(); +} + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4sqlerrors_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4sqlerrors_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a9330948b52ebb7bc362325b77f6952061fde592 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4sqlerrors_p.h @@ -0,0 +1,38 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV8SQLERRORS_P_H +#define QV8SQLERRORS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE +#define SQLEXCEPTION_UNKNOWN_ERR 1 +#define SQLEXCEPTION_DATABASE_ERR 2 +#define SQLEXCEPTION_VERSION_ERR 3 +#define SQLEXCEPTION_TOO_LARGE_ERR 4 +#define SQLEXCEPTION_QUOTA_ERR 5 +#define SQLEXCEPTION_SYNTAX_ERR 6 +#define SQLEXCEPTION_CONSTRAINT_ERR 7 +#define SQLEXCEPTION_TIMEOUT_ERR 8 + +namespace QV4 { +struct ExecutionEngine; +} + +void qt_add_sqlexceptions(QV4::ExecutionEngine *engine); + +QT_END_NAMESPACE + +#endif // QV8SQLERRORS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stackframe_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stackframe_p.h new file mode 100644 index 0000000000000000000000000000000000000000..661c7131793474da42c97d44fcaa6dfb1d04714b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stackframe_p.h @@ -0,0 +1,331 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4STACKFRAME_H +#define QV4STACKFRAME_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4scopedvalue_p.h> +#include <private/qv4context_p.h> +#include <private/qv4enginebase_p.h> +#include <private/qv4calldata_p.h> +#include <private/qv4function_p.h> + +#include <type_traits> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct CppStackFrame; +struct Q_QML_EXPORT CppStackFrameBase +{ + enum class Kind : quint8 { JS, Meta }; + + CppStackFrame *parent; + Function *v4Function; + int originalArgumentsCount; + int instructionPointer; + + QT_WARNING_PUSH + QT_WARNING_DISABLE_MSVC(4201) // nonstandard extension used: nameless struct/union + union { + struct { + Value *savedStackTop; + CallData *jsFrame; + const Value *originalArguments; + const char *yield; + const char *unwindHandler; + const char *unwindLabel; + int unwindLevel; + bool yieldIsIterator; + bool callerCanHandleTailCall; + bool pendingTailCall; + bool isTailCalling; + }; + struct { + ExecutionContext *context; + QObject *thisObject; + const QMetaType *metaTypes; + void **returnAndArgs; + bool returnValueIsUndefined; + }; + }; + QT_WARNING_POP + + Kind kind; +}; + +struct Q_QML_EXPORT CppStackFrame : protected CppStackFrameBase +{ + // We want to have those public but we can't declare them as public without making the struct + // non-standard layout. So we have this other struct with "using" in between. + using CppStackFrameBase::instructionPointer; + using CppStackFrameBase::v4Function; + + void init(Function *v4Function, int argc, Kind kind) { + this->v4Function = v4Function; + originalArgumentsCount = argc; + instructionPointer = 0; + this->kind = kind; + } + + bool isJSTypesFrame() const { return kind == Kind::JS; } + bool isMetaTypesFrame() const { return kind == Kind::Meta; } + + QString source() const; + QString function() const; + int lineNumber() const; + int statementNumber() const; + + int missingLineNumber() const; + + CppStackFrame *parentFrame() const { return parent; } + void setParentFrame(CppStackFrame *parentFrame) { parent = parentFrame; } + + int argc() const { return originalArgumentsCount; } + + inline ExecutionContext *context() const; + + Heap::CallContext *callContext() const { return callContext(context()->d()); } + ReturnedValue thisObject() const; + +protected: + CppStackFrame() = default; + + void push(EngineBase *engine) + { + Q_ASSERT(kind == Kind::JS || kind == Kind::Meta); + parent = engine->currentStackFrame; + engine->currentStackFrame = this; + } + + void pop(EngineBase *engine) + { + engine->currentStackFrame = parent; + } + + Heap::CallContext *callContext(Heap::ExecutionContext *ctx) const + { + while (ctx->type != Heap::ExecutionContext::Type_CallContext) + ctx = ctx->outer; + return static_cast<Heap::CallContext *>(ctx); + } +}; + +struct Q_QML_EXPORT MetaTypesStackFrame : public CppStackFrame +{ + using CppStackFrame::push; + using CppStackFrame::pop; + + void init(Function *v4Function, QObject *thisObject, ExecutionContext *context, + void **returnAndArgs, const QMetaType *metaTypes, int argc) + { + CppStackFrame::init(v4Function, argc, Kind::Meta); + CppStackFrameBase::thisObject = thisObject; + CppStackFrameBase::context = context; + CppStackFrameBase::metaTypes = metaTypes; + CppStackFrameBase::returnAndArgs = returnAndArgs; + CppStackFrameBase::returnValueIsUndefined = false; + } + + QMetaType returnType() const { return metaTypes[0]; } + void *returnValue() const { return returnAndArgs[0]; } + + bool isReturnValueUndefined() const { return CppStackFrameBase::returnValueIsUndefined; } + void setReturnValueUndefined() { CppStackFrameBase::returnValueIsUndefined = true; } + + const QMetaType *argTypes() const { return metaTypes + 1; } + void **argv() const { return returnAndArgs + 1; } + + const QMetaType *returnAndArgTypes() const { return metaTypes; } + void **returnAndArgValues() const { return returnAndArgs; } + + QObject *thisObject() const { return CppStackFrameBase::thisObject; } + + ExecutionContext *context() const { return CppStackFrameBase::context; } + void setContext(ExecutionContext *context) { CppStackFrameBase::context = context; } + + Heap::CallContext *callContext() const + { + return CppStackFrame::callContext(CppStackFrameBase::context->d()); + } +}; + +struct Q_QML_EXPORT JSTypesStackFrame : public CppStackFrame +{ + using CppStackFrame::jsFrame; + + // The JIT needs to poke directly into those using offsetof + using CppStackFrame::unwindHandler; + using CppStackFrame::unwindLabel; + using CppStackFrame::unwindLevel; + + void init(Function *v4Function, const Value *argv, int argc, + bool callerCanHandleTailCall = false) + { + CppStackFrame::init(v4Function, argc, Kind::JS); + CppStackFrame::originalArguments = argv; + CppStackFrame::yield = nullptr; + CppStackFrame::unwindHandler = nullptr; + CppStackFrame::yieldIsIterator = false; + CppStackFrame::callerCanHandleTailCall = callerCanHandleTailCall; + CppStackFrame::pendingTailCall = false; + CppStackFrame::isTailCalling = false; + CppStackFrame::unwindLabel = nullptr; + CppStackFrame::unwindLevel = 0; + } + + const Value *argv() const { return originalArguments; } + + static uint requiredJSStackFrameSize(uint nRegisters) { + return CallData::HeaderSize() + nRegisters; + } + static uint requiredJSStackFrameSize(Function *v4Function) { + return CallData::HeaderSize() + v4Function->compiledFunction->nRegisters; + } + uint requiredJSStackFrameSize() const { + return requiredJSStackFrameSize(v4Function); + } + + void setupJSFrame(Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope, + const Value &thisObject, const Value &newTarget = Value::undefinedValue()) { + setupJSFrame(stackSpace, function, scope, thisObject, newTarget, + v4Function->compiledFunction->nFormals, + v4Function->compiledFunction->nRegisters); + } + + void setupJSFrame( + Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope, + const Value &thisObject, const Value &newTarget, uint nFormals, uint nRegisters) + { + jsFrame = reinterpret_cast<CallData *>(stackSpace); + jsFrame->function = function; + jsFrame->context = scope->asReturnedValue(); + jsFrame->accumulator = Encode::undefined(); + jsFrame->thisObject = thisObject; + jsFrame->newTarget = newTarget; + + uint argc = uint(originalArgumentsCount); + if (argc > nFormals) + argc = nFormals; + jsFrame->setArgc(argc); + + // memcpy requires non-null ptr, even if argc * sizeof(Value) == 0 + if (originalArguments) + memcpy(jsFrame->args, originalArguments, argc * sizeof(Value)); + Q_STATIC_ASSERT(Encode::undefined() == 0); + memset(jsFrame->args + argc, 0, (nRegisters - argc) * sizeof(Value)); + + if (v4Function && v4Function->compiledFunction) { + const int firstDeadZoneRegister + = v4Function->compiledFunction->firstTemporalDeadZoneRegister; + const int registerDeadZoneSize + = v4Function->compiledFunction->sizeOfRegisterTemporalDeadZone; + + const Value * tdzEnd = stackSpace + firstDeadZoneRegister + registerDeadZoneSize; + for (Value *v = stackSpace + firstDeadZoneRegister; v < tdzEnd; ++v) + *v = Value::emptyValue().asReturnedValue(); + } + } + + ExecutionContext *context() const + { + return static_cast<ExecutionContext *>(&jsFrame->context); + } + + void setContext(ExecutionContext *context) + { + jsFrame->context = context; + } + + Heap::CallContext *callContext() const + { + return CppStackFrame::callContext(static_cast<ExecutionContext &>(jsFrame->context).d()); + } + + bool isTailCalling() const { return CppStackFrame::isTailCalling; } + void setTailCalling(bool tailCalling) { CppStackFrame::isTailCalling = tailCalling; } + + bool pendingTailCall() const { return CppStackFrame::pendingTailCall; } + void setPendingTailCall(bool pending) { CppStackFrame::pendingTailCall = pending; } + + const char *yield() const { return CppStackFrame::yield; } + void setYield(const char *yield) { CppStackFrame::yield = yield; } + + bool yieldIsIterator() const { return CppStackFrame::yieldIsIterator; } + void setYieldIsIterator(bool isIter) { CppStackFrame::yieldIsIterator = isIter; } + + bool callerCanHandleTailCall() const { return CppStackFrame::callerCanHandleTailCall; } + + ReturnedValue thisObject() const + { + return jsFrame->thisObject.asReturnedValue(); + } + + Value *framePointer() const { return savedStackTop; } + + void push(EngineBase *engine) { + CppStackFrame::push(engine); + savedStackTop = engine->jsStackTop; + } + + void pop(EngineBase *engine) { + CppStackFrame::pop(engine); + engine->jsStackTop = savedStackTop; + } +}; + +inline ExecutionContext *CppStackFrame::context() const +{ + if (isJSTypesFrame()) + return static_cast<const JSTypesStackFrame *>(this)->context(); + + Q_ASSERT(isMetaTypesFrame()); + return static_cast<const MetaTypesStackFrame *>(this)->context(); +} + +struct ScopedStackFrame +{ + ScopedStackFrame(const Scope &scope, ExecutionContext *context) + : engine(scope.engine) + { + if (auto currentFrame = engine->currentStackFrame) { + frame.init(currentFrame->v4Function, nullptr, context, nullptr, nullptr, 0); + frame.instructionPointer = currentFrame->instructionPointer; + } else { + frame.init(nullptr, nullptr, context, nullptr, nullptr, 0); + } + frame.push(engine); + } + + ~ScopedStackFrame() + { + frame.pop(engine); + } + +private: + ExecutionEngine *engine = nullptr; + MetaTypesStackFrame frame; +}; + +Q_STATIC_ASSERT(sizeof(CppStackFrame) == sizeof(JSTypesStackFrame)); +Q_STATIC_ASSERT(sizeof(CppStackFrame) == sizeof(MetaTypesStackFrame)); +Q_STATIC_ASSERT(std::is_standard_layout_v<CppStackFrame>); +Q_STATIC_ASSERT(std::is_standard_layout_v<JSTypesStackFrame>); +Q_STATIC_ASSERT(std::is_standard_layout_v<MetaTypesStackFrame>); + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stacklimits_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stacklimits_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2219b9327a0b1d5aed0035eb5b295707e04661ff --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stacklimits_p.h @@ -0,0 +1,74 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4STACKLIMITS_P_H +#define QV4STACKLIMITS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> + +#ifndef Q_STACK_GROWTH_DIRECTION +# ifdef Q_PROCESSOR_HPPA +# define Q_STACK_GROWTH_DIRECTION (1) +# else +# define Q_STACK_GROWTH_DIRECTION (-1) +# endif +#endif + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +// Note: This does not return a completely accurate stack pointer. +// Depending on whether this function is inlined or not, we may get the address of +// this function's stack frame or the caller's stack frame. +// Always use a safety margin when determining stack limits. +inline const void *currentStackPointer() +{ + // TODO: How often do we actually need the assembler mess below? Is that worth it? + + void *stackPointer; +#if defined(Q_CC_GNU) || __has_builtin(__builtin_frame_address) + stackPointer = __builtin_frame_address(0); +#elif defined(Q_CC_MSVC) + stackPointer = &stackPointer; +#elif defined(Q_PROCESSOR_X86_64) + __asm__ __volatile__("movq %%rsp, %0" : "=r"(stackPointer) : :); +#elif defined(Q_PROCESSOR_X86) + __asm__ __volatile__("movl %%esp, %0" : "=r"(stackPointer) : :); +#elif defined(Q_PROCESSOR_ARM_64) && defined(__ILP32__) + quint64 stackPointerRegister = 0; + __asm__ __volatile__("mov %0, sp" : "=r"(stackPointerRegister) : :); + stackPointer = reinterpret_cast<void *>(stackPointerRegister); +#elif defined(Q_PROCESSOR_ARM_64) || defined(Q_PROCESSOR_ARM_32) + __asm__ __volatile__("mov %0, sp" : "=r"(stackPointer) : :); +#else + stackPointer = &stackPointer; +#endif + return stackPointer; +} + +struct StackProperties +{ + const void *base = nullptr; + const void *softLimit = nullptr; + const void *hardLimit = nullptr; +}; + +StackProperties stackProperties(); + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4STACKLIMITS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4staticvalue_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4staticvalue_p.h new file mode 100644 index 0000000000000000000000000000000000000000..07e80d47254f342a986528e48a080eedffff4605 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4staticvalue_p.h @@ -0,0 +1,683 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4STATICVALUE_P_H +#define QV4STATICVALUE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qjsnumbercoercion.h> + +#include <QtCore/private/qnumeric_p.h> +#include <private/qtqmlglobal_p.h> + +#include <cstring> + +#ifdef QT_NO_DEBUG +#define QV4_NEARLY_ALWAYS_INLINE Q_ALWAYS_INLINE +#else +#define QV4_NEARLY_ALWAYS_INLINE inline +#endif + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +// ReturnedValue is used to return values from runtime methods +// the type has to be a primitive type (no struct or union), so that the compiler +// will return it in a register on all platforms. +// It will be returned in rax on x64, [eax,edx] on x86 and [r0,r1] on arm +typedef quint64 ReturnedValue; + +namespace Heap { +struct Base; +} + +struct StaticValue +{ + using HeapBasePtr = Heap::Base *; + + StaticValue() = default; + constexpr StaticValue(quint64 val) : _val(val) {} + + StaticValue &operator=(ReturnedValue v) + { + _val = v; + return *this; + } + + template<typename Value> + StaticValue &operator=(const Value &); + + template<typename Value> + const Value &asValue() const; + + template<typename Value> + Value &asValue(); + + /* + We use 8 bytes for a value. In order to store all possible values we employ a variant of NaN + boxing. A "special" Double is indicated by a number that has the 11 exponent bits set to 1. + Those can be NaN, positive or negative infinity. We only store one variant of NaN: The sign + bit has to be off and the bit after the exponent ("quiet bit") has to be on. However, since + the exponent bits are enough to identify special doubles, we can use a different bit as + discriminator to tell us how the rest of the bits (including quiet and sign) are to be + interpreted. This bit is bit 48. If set, we have an unmanaged value, which includes the + special doubles and various other values. If unset, we have a managed value, and all of the + other bits can be used to assemble a pointer. + + On 32bit systems the pointer can just live in the lower 4 bytes. On 64 bit systems the lower + 48 bits can be used for verbatim pointer bits. However, since all our heap objects are + aligned to 32 bytes, we can use the 5 least significant bits of the pointer to store, e.g. + pointer tags on android. The same holds for the 3 bits between the double exponent and + bit 48. + + With that out of the way, we can use the other bits to store different values. + + We xor Doubles with (0x7ff48000 << 32). That has the effect that any double with all the + exponent bits set to 0 is one of our special doubles. Those special doubles then get the + other two bits in the mask (Special and Number) set to 1, as they cannot have 1s in those + positions to begin with. + + We dedicate further bits to integer-convertible and bool-or-int. With those bits we can + describe all values we need to store. + + Undefined is encoded as a managed pointer with value 0. This is the same as a nullptr. + + Specific bit-sequences: + 0 = always 0 + 1 = always 1 + x = stored value + y = stored value, shifted to different position + a = xor-ed bits, where at least one bit is set + b = xor-ed bits + + 32109876 54321098 76543210 98765432 10987654 32109876 54321098 76543210 | + 66665555 55555544 44444444 33333333 33222222 22221111 11111100 00000000 | JS Value + ------------------------------------------------------------------------+-------------- + 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 | Undefined + y0000000 0000yyy0 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxyyyyy | Managed (heap pointer) + 00000000 00001101 10000000 00000000 00000000 00000000 00000000 00000000 | NaN + 00000000 00000101 10000000 00000000 00000000 00000000 00000000 00000000 | +Inf + 10000000 00000101 10000000 00000000 00000000 00000000 00000000 00000000 | -Inf + xaaaaaaa aaaaxbxb bxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx | double + 00000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000 | empty (non-sparse array hole) + 00000000 00000011 00000000 00000000 00000000 00000000 00000000 00000000 | Null + 00000000 00000011 10000000 00000000 00000000 00000000 00000000 0000000x | Bool + 00000000 00000011 11000000 00000000 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx | Int + ^ ^^^ ^^ + | ||| || + | ||| |+-> Number + | ||| +--> Int or Bool + | ||+----> Unmanaged + | |+-----> Integer compatible + | +------> Special double + +--------------------> Double sign, also used for special doubles + */ + + quint64 _val; + + QV4_NEARLY_ALWAYS_INLINE constexpr quint64 &rawValueRef() { return _val; } + QV4_NEARLY_ALWAYS_INLINE constexpr quint64 rawValue() const { return _val; } + QV4_NEARLY_ALWAYS_INLINE constexpr void setRawValue(quint64 raw) { _val = raw; } + +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + static inline int valueOffset() { return 0; } + static inline int tagOffset() { return 4; } +#else // !Q_LITTLE_ENDIAN + static inline int valueOffset() { return 4; } + static inline int tagOffset() { return 0; } +#endif + static inline constexpr quint64 tagValue(quint32 tag, quint32 value) { return quint64(tag) << Tag_Shift | value; } + QV4_NEARLY_ALWAYS_INLINE constexpr void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << Tag_Shift | value; } + QV4_NEARLY_ALWAYS_INLINE constexpr quint32 value() const { return _val & quint64(~quint32(0)); } + QV4_NEARLY_ALWAYS_INLINE constexpr quint32 tag() const { return _val >> Tag_Shift; } + QV4_NEARLY_ALWAYS_INLINE constexpr void setTag(quint32 tag) { setTagValue(tag, value()); } + + QV4_NEARLY_ALWAYS_INLINE constexpr int int_32() const + { + return int(value()); + } + QV4_NEARLY_ALWAYS_INLINE constexpr void setInt_32(int i) + { + setTagValue(quint32(QuickType::Integer), quint32(i)); + } + QV4_NEARLY_ALWAYS_INLINE uint uint_32() const { return value(); } + + QV4_NEARLY_ALWAYS_INLINE constexpr void setEmpty() + { + setTagValue(quint32(QuickType::Empty), 0); + } + + enum class TagBit { + // s: sign bit + // e: double exponent bit + // u: upper 3 bits if managed + // m: bit 48, denotes "unmanaged" if 1 + // p: significant pointer bits (some re-used for non-managed) + // seeeeeeeeeeeuuumpppp + SpecialNegative = 0b10000000000000000000 << 12, + SpecialQNaN = 0b00000000000010000000 << 12, + Special = 0b00000000000001000000 << 12, + IntCompat = 0b00000000000000100000 << 12, + Unmanaged = 0b00000000000000010000 << 12, + IntOrBool = 0b00000000000000001000 << 12, + Number = 0b00000000000000000100 << 12, + }; + + static inline constexpr quint64 tagBitMask(TagBit bit) { return quint64(bit) << Tag_Shift; } + + enum Type { + // Managed, Double and undefined are not directly encoded + Managed_Type = 0, + Double_Type = 1, + Undefined_Type = 2, + + Empty_Type = quint32(TagBit::Unmanaged), + Null_Type = Empty_Type | quint32(TagBit::IntCompat), + Boolean_Type = Null_Type | quint32(TagBit::IntOrBool), + Integer_Type = Boolean_Type | quint32(TagBit::Number) + }; + + enum { + Tag_Shift = 32, + + IsIntegerConvertible_Shift = 48, + IsIntegerConvertible_Value = 3, // Unmanaged | IntCompat after shifting + + IsIntegerOrBool_Shift = 47, + IsIntegerOrBool_Value = 7, // Unmanaged | IntCompat | IntOrBool after shifting + }; + + static_assert(IsIntegerConvertible_Value == + (quint32(TagBit::IntCompat) | quint32(TagBit::Unmanaged)) + >> (IsIntegerConvertible_Shift - Tag_Shift)); + + static_assert(IsIntegerOrBool_Value == + (quint32(TagBit::IntOrBool) | quint32(TagBit::IntCompat) | quint32(TagBit::Unmanaged)) + >> (IsIntegerOrBool_Shift - Tag_Shift)); + + static constexpr quint64 ExponentMask = 0b0111111111110000ull << 48; + + static constexpr quint64 Top1Mask = 0b1000000000000000ull << 48; + static constexpr quint64 Upper3Mask = 0b0000000000001110ull << 48; + static constexpr quint64 Lower5Mask = 0b0000000000011111ull; + + static constexpr quint64 ManagedMask = ExponentMask | quint64(TagBit::Unmanaged) << Tag_Shift; + static constexpr quint64 DoubleMask = ManagedMask | quint64(TagBit::Special) << Tag_Shift; + static constexpr quint64 NumberMask = ManagedMask | quint64(TagBit::Number) << Tag_Shift; + static constexpr quint64 IntOrBoolMask = ManagedMask | quint64(TagBit::IntOrBool) << Tag_Shift; + static constexpr quint64 IntCompatMask = ManagedMask | quint64(TagBit::IntCompat) << Tag_Shift; + + static constexpr quint64 EncodeMask = DoubleMask | NumberMask; + + static constexpr quint64 DoubleDiscriminator + = ((quint64(TagBit::Unmanaged) | quint64(TagBit::Special)) << Tag_Shift); + static constexpr quint64 NumberDiscriminator + = ((quint64(TagBit::Unmanaged) | quint64(TagBit::Number)) << Tag_Shift); + + // Things we can immediately determine by just looking at the upper 4 bytes. + enum class QuickType : quint32 { + // Managed takes precedence over all others. That is, other bits may be set if it's managed. + // However, since all others include the Unmanaged bit, we can still check them with simple + // equality operations. + Managed = Managed_Type, + + Empty = Empty_Type, + Null = Null_Type, + Boolean = Boolean_Type, + Integer = Integer_Type, + + PlusInf = quint32(TagBit::Number) | quint32(TagBit::Special) | quint32(TagBit::Unmanaged), + MinusInf = PlusInf | quint32(TagBit::SpecialNegative), + NaN = PlusInf | quint32(TagBit::SpecialQNaN), + MinusNaN = NaN | quint32(TagBit::SpecialNegative), // Can happen with UMinus on NaN + // All other values are doubles + }; + + // Aliases for easier porting. Remove those when possible + using ValueTypeInternal = QuickType; + enum { + QT_Empty = Empty_Type, + QT_Null = Null_Type, + QT_Bool = Boolean_Type, + QT_Int = Integer_Type, + QuickType_Shift = Tag_Shift, + }; + + inline Type type() const + { + const quint64 masked = _val & DoubleMask; + if (masked >= DoubleDiscriminator) + return Double_Type; + + // Any bit set in the exponent would have been caught above, as well as both bits being set. + // None of them being set as well as only Special being set means "managed". + // Only Unmanaged being set means "unmanaged". That's all remaining options. + if (masked != tagBitMask(TagBit::Unmanaged)) { + Q_ASSERT((_val & tagBitMask(TagBit::Unmanaged)) == 0); + return isUndefined() ? Undefined_Type : Managed_Type; + } + + const Type ret = Type(tag()); + Q_ASSERT( + ret == Empty_Type || + ret == Null_Type || + ret == Boolean_Type || + ret == Integer_Type); + return ret; + } + + inline quint64 quickType() const { return (_val >> QuickType_Shift); } + + // used internally in property + inline bool isEmpty() const { return tag() == quint32(ValueTypeInternal::Empty); } + inline bool isNull() const { return tag() == quint32(ValueTypeInternal::Null); } + inline bool isBoolean() const { return tag() == quint32(ValueTypeInternal::Boolean); } + inline bool isInteger() const { return tag() == quint32(ValueTypeInternal::Integer); } + inline bool isNullOrUndefined() const { return isNull() || isUndefined(); } + inline bool isUndefined() const { return _val == 0; } + + inline bool isDouble() const + { + // If any of the flipped exponent bits are 1, it's a regular double, and the masked tag is + // larger than Unmanaged | Special. + // + // If all (flipped) exponent bits are 0: + // 1. If Unmanaged bit is 0, it's managed + // 2. If the Unmanaged bit it is 1, and the Special bit is 0, it's not a special double + // 3. If both are 1, it is a special double and the masked tag equals Unmanaged | Special. + + return (_val & DoubleMask) >= DoubleDiscriminator; + } + + inline bool isNumber() const + { + // If any of the flipped exponent bits are 1, it's a regular double, and the masked tag is + // larger than Unmanaged | Number. + // + // If all (flipped) exponent bits are 0: + // 1. If Unmanaged bit is 0, it's managed + // 2. If the Unmanaged bit it is 1, and the Number bit is 0, it's not number + // 3. If both are 1, it is a number and masked tag equals Unmanaged | Number. + + return (_val & NumberMask) >= NumberDiscriminator; + } + + inline bool isManagedOrUndefined() const { return (_val & ManagedMask) == 0; } + + // If any other bit is set in addition to the managed mask, it's not undefined. + inline bool isManaged() const + { + return isManagedOrUndefined() && !isUndefined(); + } + + inline bool isIntOrBool() const + { + // It's an int or bool if all the exponent bits are 0, + // and the "int or bool" bit as well as the "umanaged" bit are set, + return (_val >> IsIntegerOrBool_Shift) == IsIntegerOrBool_Value; + } + + inline bool integerCompatible() const { + Q_ASSERT(!isEmpty()); + return (_val >> IsIntegerConvertible_Shift) == IsIntegerConvertible_Value; + } + + static inline bool integerCompatible(StaticValue a, StaticValue b) { + return a.integerCompatible() && b.integerCompatible(); + } + + static inline bool bothDouble(StaticValue a, StaticValue b) { + return a.isDouble() && b.isDouble(); + } + + inline bool isNaN() const + { + switch (QuickType(tag())) { + case QuickType::NaN: + case QuickType::MinusNaN: + return true; + default: + return false; + } + } + + inline bool isPositiveInt() const { + return isInteger() && int_32() >= 0; + } + + QV4_NEARLY_ALWAYS_INLINE double doubleValue() const { + Q_ASSERT(isDouble()); + double d; + const quint64 unmasked = _val ^ EncodeMask; + memcpy(&d, &unmasked, 8); + return d; + } + + QV4_NEARLY_ALWAYS_INLINE void setDouble(double d) { + if (qt_is_nan(d)) { + // We cannot store just any NaN. It has to be a NaN with only the quiet bit + // set in the upper bits of the mantissa and the sign bit either on or off. + // qt_qnan() happens to produce such a thing via std::numeric_limits, + // but this is actually not guaranteed. Therefore, we make our own. + _val = (quint64(std::signbit(d) ? QuickType::MinusNaN : QuickType::NaN) << Tag_Shift); + Q_ASSERT(isNaN()); + } else { + memcpy(&_val, &d, 8); + _val ^= EncodeMask; + } + + Q_ASSERT(isDouble()); + } + + inline bool isInt32() { + if (tag() == quint32(QuickType::Integer)) + return true; + if (isDouble()) { + double d = doubleValue(); + if (isInt32(d)) { + setInt_32(int(d)); + return true; + } + } + return false; + } + + QV4_NEARLY_ALWAYS_INLINE static bool isInt32(double d) { + int i = QJSNumberCoercion::toInteger(d); + return (i == d && !(d == 0 && std::signbit(d))); + } + + double asDouble() const { + if (tag() == quint32(QuickType::Integer)) + return int_32(); + return doubleValue(); + } + + bool booleanValue() const { + return int_32(); + } + + int integerValue() const { + return int_32(); + } + + inline bool tryIntegerConversion() { + bool b = integerCompatible(); + if (b) + setTagValue(quint32(QuickType::Integer), value()); + return b; + } + + bool toBoolean() const { + if (integerCompatible()) + return static_cast<bool>(int_32()); + + if (isManagedOrUndefined()) + return false; + + // double + const double d = doubleValue(); + return d && !std::isnan(d); + } + + inline int toInt32() const + { + switch (type()) { + case Null_Type: + case Boolean_Type: + case Integer_Type: + return int_32(); + case Double_Type: + return QJSNumberCoercion::toInteger(doubleValue()); + case Empty_Type: + case Undefined_Type: + case Managed_Type: + return 0; // Coercion of NaN to int, results in 0; + } + + Q_UNREACHABLE_RETURN(0); + } + + ReturnedValue *data_ptr() { return &_val; } + constexpr ReturnedValue asReturnedValue() const { return _val; } + constexpr static StaticValue fromReturnedValue(ReturnedValue val) { return {val}; } + + inline static constexpr StaticValue emptyValue() { return { tagValue(quint32(QuickType::Empty), 0) }; } + static inline constexpr StaticValue fromBoolean(bool b) { return { tagValue(quint32(QuickType::Boolean), b) }; } + static inline constexpr StaticValue fromInt32(int i) { return { tagValue(quint32(QuickType::Integer), quint32(i)) }; } + inline static constexpr StaticValue undefinedValue() { return { 0 }; } + static inline constexpr StaticValue nullValue() { return { tagValue(quint32(QuickType::Null), 0) }; } + + static inline StaticValue fromDouble(double d) + { + StaticValue v; + v.setDouble(d); + return v; + } + + static inline StaticValue fromUInt32(uint i) + { + StaticValue v; + if (i < uint(std::numeric_limits<int>::max())) { + v.setTagValue(quint32(QuickType::Integer), i); + } else { + v.setDouble(i); + } + return v; + } + + static double toInteger(double d) + { + if (std::isnan(d)) + return +0; + if (!d || std::isinf(d)) + return d; + return d >= 0 ? std::floor(d) : std::ceil(d); + } + + static int toInt32(double d) + { + return QJSNumberCoercion::toInteger(d); + } + + static unsigned int toUInt32(double d) + { + return static_cast<uint>(toInt32(d)); + } + + // While a value containing a Heap::Base* is not actually static, we still implement + // the setting and retrieving of heap pointers here in order to have the encoding + // scheme completely in one place. + +#if QT_POINTER_SIZE == 8 + + // All pointer shifts are from more significant to less significant bits. + // When encoding, we shift right by that amount. When decoding, we shift left. + // Negative numbers mean shifting the other direction. 0 means no shifting. + // + // The IA64 and Sparc64 cases are mostly there to demonstrate the idea. Sparc64 + // and IA64 are not officially supported, but we can expect more platforms with + // similar "problems" in the future. + enum PointerShift { +#if 0 && defined(Q_OS_ANDROID) && defined(Q_PROCESSOR_ARM_64) + // We used to assume that Android on arm64 uses the top byte to store pointer tags. + // However, at least currently, the pointer tags are only applied on new/malloc and + // delete/free, not on mmap() and munmap(). We manage the JS heap directly using + // mmap, so we don't have to preserve any tags. + // + // If this ever changes, here is how to preserve the top byte: + // Move it to Upper3 and Lower5. + Top1Shift = 0, + Upper3Shift = 12, + Lower5Shift = 56, +#elif defined(Q_PROCESSOR_IA64) + // On ia64, bits 63-61 in a 64-bit pointer are used to store the virtual region + // number. We can move those to Upper3. + Top1Shift = 0, + Upper3Shift = 12, + Lower5Shift = 0, +#elif defined(Q_PROCESSOR_SPARC_64) + // Sparc64 wants to use 52 bits for pointers. + // Upper3 can stay where it is, bit48 moves to the top bit. + Top1Shift = -15, + Upper3Shift = 0, + Lower5Shift = 0, +#elif 0 // TODO: Once we need 5-level page tables, add the appropriate check here. + // With 5-level page tables (as possible on linux) we need 57 address bits. + // Upper3 can stay where it is, bit48 moves to the top bit, the rest moves to Lower5. + Top1Shift = -15, + Upper3Shift = 0, + Lower5Shift = 52, +#else + Top1Shift = 0, + Upper3Shift = 0, + Lower5Shift = 0 +#endif + }; + + template<int Offset, quint64 Mask> + static constexpr quint64 movePointerBits(quint64 val) + { + if constexpr (Offset > 0) + return (val & ~Mask) | ((val & Mask) >> Offset); + if constexpr (Offset < 0) + return (val & ~Mask) | ((val & Mask) << -Offset); + return val; + } + + template<int Offset, quint64 Mask> + static constexpr quint64 storePointerBits(quint64 val) + { + constexpr quint64 OriginMask = movePointerBits<-Offset, Mask>(Mask); + return movePointerBits<Offset, OriginMask>(val); + } + + template<int Offset, quint64 Mask> + static constexpr quint64 retrievePointerBits(quint64 val) + { + return movePointerBits<-Offset, Mask>(val); + } + + QML_NEARLY_ALWAYS_INLINE HeapBasePtr m() const + { + Q_ASSERT(!(_val & ManagedMask)); + + // Re-assemble the pointer from its fragments. + const quint64 tmp = retrievePointerBits<Top1Shift, Top1Mask>( + retrievePointerBits<Upper3Shift, Upper3Mask>( + retrievePointerBits<Lower5Shift, Lower5Mask>(_val))); + + HeapBasePtr b; + memcpy(&b, &tmp, 8); + return b; + } + QML_NEARLY_ALWAYS_INLINE void setM(HeapBasePtr b) + { + quint64 tmp; + memcpy(&tmp, &b, 8); + + // Has to be aligned to 32 bytes + Q_ASSERT(!(tmp & Lower5Mask)); + + // MinGW produces a bogus warning about array bounds. + // There is no array access here. + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Warray-bounds") + + // Encode the pointer. + _val = storePointerBits<Top1Shift, Top1Mask>( + storePointerBits<Upper3Shift, Upper3Mask>( + storePointerBits<Lower5Shift, Lower5Mask>(tmp))); + + QT_WARNING_POP + } +#elif QT_POINTER_SIZE == 4 + QML_NEARLY_ALWAYS_INLINE HeapBasePtr m() const + { + Q_STATIC_ASSERT(sizeof(HeapBasePtr) == sizeof(quint32)); + HeapBasePtr b; + quint32 v = value(); + memcpy(&b, &v, 4); + return b; + } + QML_NEARLY_ALWAYS_INLINE void setM(HeapBasePtr b) + { + quint32 v; + memcpy(&v, &b, 4); + setTagValue(quint32(QuickType::Managed), v); + } +#else +# error "unsupported pointer size" +#endif +}; +Q_STATIC_ASSERT(std::is_trivial_v<StaticValue>); + +struct Encode { + static constexpr ReturnedValue undefined() { + return StaticValue::undefinedValue().asReturnedValue(); + } + static constexpr ReturnedValue null() { + return StaticValue::nullValue().asReturnedValue(); + } + + explicit constexpr Encode(bool b) + : val(StaticValue::fromBoolean(b).asReturnedValue()) + { + } + explicit Encode(double d) { + val = StaticValue::fromDouble(d).asReturnedValue(); + } + explicit constexpr Encode(int i) + : val(StaticValue::fromInt32(i).asReturnedValue()) + { + } + explicit Encode(uint i) { + val = StaticValue::fromUInt32(i).asReturnedValue(); + } + explicit constexpr Encode(ReturnedValue v) + : val(v) + { + } + constexpr Encode(StaticValue v) + : val(v.asReturnedValue()) + { + } + + template<typename HeapBase> + explicit Encode(HeapBase *o); + + explicit Encode(StaticValue *o) { + Q_ASSERT(o); + val = o->asReturnedValue(); + } + + static ReturnedValue smallestNumber(double d) { + if (StaticValue::isInt32(d)) + return Encode(static_cast<int>(d)); + else + return Encode(d); + } + + constexpr operator ReturnedValue() const { + return val; + } + quint64 val; +private: + explicit Encode(void *); +}; + +} + +QT_END_NAMESPACE + +#endif // QV4STATICVALUE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4string_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4string_p.h new file mode 100644 index 0000000000000000000000000000000000000000..324f49501df61222f3d12ecaa6b30d50b1be054b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4string_p.h @@ -0,0 +1,286 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4STRING_H +#define QV4STRING_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> +#include "qv4managed_p.h" +#include <QtCore/private/qnumeric_p.h> +#include "qv4enginebase_p.h" +#include <private/qv4stringtoarrayindex_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct ExecutionEngine; +struct PropertyKey; + +namespace Heap { + +struct Q_QML_EXPORT StringOrSymbol : Base +{ + enum StringType { + StringType_Symbol, + StringType_Regular, + StringType_ArrayIndex, + StringType_Unknown, + StringType_AddedString, + StringType_SubString, + StringType_Complex = StringType_AddedString + }; + + void init() { + Base::init(); + new (&textStorage) QStringPrivate; + } + + void init(QStringPrivate text) + { + Base::init(); + new (&textStorage) QStringPrivate(std::move(text)); + } + + mutable struct { alignas(QStringPrivate) unsigned char data[sizeof(QStringPrivate)]; } textStorage; + mutable PropertyKey identifier; + mutable uint subtype; + mutable uint stringHash; + + static void markObjects(Heap::Base *that, MarkStack *markStack); + void destroy(); + + QStringPrivate &text() const { return *reinterpret_cast<QStringPrivate *>(&textStorage); } + + inline QString toQString() const { + QStringPrivate dd = text(); + return QString(std::move(dd)); + } + void createHashValue() const; + inline unsigned hashValue() const { + if (subtype >= StringType_Unknown) + createHashValue(); + Q_ASSERT(subtype < StringType_Complex); + + return stringHash; + } +}; + +struct Q_QML_EXPORT String : StringOrSymbol { + static void markObjects(Heap::Base *that, MarkStack *markStack); + + const VTable *vtable() const { + return internalClass->vtable; + } + + void init(const QString &text); + void simplifyString() const; + int length() const; + std::size_t retainedTextSize() const { + return subtype >= StringType_Complex ? 0 : (std::size_t(text().size) * sizeof(QChar)); + } + inline QString toQString() const { + if (subtype >= StringType_Complex) + simplifyString(); + return StringOrSymbol::toQString(); + } + inline bool isEqualTo(const String *other) const { + if (this == other) + return true; + if (hashValue() != other->hashValue()) + return false; + Q_ASSERT(subtype < StringType_Complex); + if (identifier.isValid() && identifier == other->identifier) + return true; + if (subtype == Heap::String::StringType_ArrayIndex && other->subtype == Heap::String::StringType_ArrayIndex) + return true; + + return toQString() == other->toQString(); + } + + bool startsWithUpper() const; + +private: + static void append(const String *data, QChar *ch); +}; +Q_STATIC_ASSERT(std::is_trivial_v<String>); + +struct ComplexString : String { + void init(String *l, String *n); + void init(String *ref, int from, int len); + mutable String *left; + mutable String *right; + union { + mutable int largestSubLength; + int from; + }; + int len; +}; +Q_STATIC_ASSERT(std::is_trivial_v<ComplexString>); + +inline +int String::length() const { + // TODO: ensure that our strings never actually grow larger than INT_MAX + return subtype < StringType_AddedString ? int(text().size) : static_cast<const ComplexString *>(this)->len; +} + +} + +struct Q_QML_EXPORT StringOrSymbol : public Managed { + V4_MANAGED(StringOrSymbol, Managed) + V4_NEEDS_DESTROY + enum { + IsStringOrSymbol = true + }; + +private: + inline void createPropertyKey() const; +public: + PropertyKey propertyKey() const { Q_ASSERT(d()->identifier.isValid()); return d()->identifier; } + PropertyKey toPropertyKey() const; + + + inline QString toQString() const { + return d()->toQString(); + } +}; + +struct Q_QML_EXPORT String : public StringOrSymbol { + V4_MANAGED(String, StringOrSymbol) + Q_MANAGED_TYPE(String) + V4_INTERNALCLASS(String) + enum { + IsString = true + }; + + uchar subtype() const { return d()->subtype; } + void setSubtype(uchar subtype) const { d()->subtype = subtype; } + + bool equals(String *other) const { + return d()->isEqualTo(other->d()); + } + inline bool isEqualTo(const String *other) const { + return d()->isEqualTo(other->d()); + } + + inline bool lessThan(const String *other) { + return toQString() < other->toQString(); + } + + inline QString toQString() const { + return d()->toQString(); + } + + inline unsigned hashValue() const { + return d()->hashValue(); + } + uint toUInt(bool *ok) const; + + // slow path + Q_NEVER_INLINE void createPropertyKeyImpl() const; + + static uint createHashValue(const QChar *ch, int length, uint *subtype) + { + const QChar *end = ch + length; + return calculateHashValue(ch, end, subtype); + } + + static uint createHashValueDisallowingArrayIndex(const QChar *ch, int length, uint *subtype) + { + const QChar *end = ch + length; + return calculateHashValue<String::DisallowArrayIndex>(ch, end, subtype); + } + + static uint createHashValue(const char *ch, int length, uint *subtype) + { + const char *end = ch + length; + return calculateHashValue(ch, end, subtype); + } + + bool startsWithUpper() const { return d()->startsWithUpper(); } + +protected: + static bool virtualIsEqualTo(Managed *that, Managed *o); + static qint64 virtualGetLength(const Managed *m); + +public: + enum IndicesBehavior {Default, DisallowArrayIndex}; + template <IndicesBehavior Behavior = Default, typename T> + static inline uint calculateHashValue(const T *ch, const T* end, uint *subtype) + { + // array indices get their number as hash value + uint h = UINT_MAX; + if constexpr (Behavior != DisallowArrayIndex) { + h = stringToArrayIndex(ch, end); + if (h != UINT_MAX) { + if (subtype) + *subtype = Heap::StringOrSymbol::StringType_ArrayIndex; + return h; + } + } + + while (ch < end) { + h = 31 * h + charToUInt(ch); + ++ch; + } + + if (subtype) + *subtype = (ch != end && charToUInt(ch) == '@') ? Heap::StringOrSymbol::StringType_Symbol : Heap::StringOrSymbol::StringType_Regular; + return h; + } +}; + +struct ComplexString : String { + typedef QV4::Heap::ComplexString Data; + QV4::Heap::ComplexString *d_unchecked() const { return static_cast<QV4::Heap::ComplexString *>(m()); } + QV4::Heap::ComplexString *d() const { + QV4::Heap::ComplexString *dptr = d_unchecked(); + dptr->_checkIsInitialized(); + return dptr; + } +}; + +inline +void StringOrSymbol::createPropertyKey() const { + Q_ASSERT(!d()->identifier.isValid()); + Q_ASSERT(isString()); + static_cast<const String *>(this)->createPropertyKeyImpl(); +} + +inline PropertyKey StringOrSymbol::toPropertyKey() const { + if (!d()->identifier.isValid()) + createPropertyKey(); + return d()->identifier; +} + +template<> +inline const StringOrSymbol *Value::as() const { + return isManaged() && m()->internalClass->vtable->isStringOrSymbol ? static_cast<const String *>(this) : nullptr; +} + +template<> +inline const String *Value::as() const { + return isManaged() && m()->internalClass->vtable->isString ? static_cast<const String *>(this) : nullptr; +} + +template<> +inline ReturnedValue value_convert<String>(ExecutionEngine *e, const Value &v) +{ + return v.toString(e)->asReturnedValue(); +} + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stringiterator_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stringiterator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c23d399df42fb7a360114879b074371cfe16ad16 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stringiterator_p.h @@ -0,0 +1,67 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4STRINGITERATOR_P_H +#define QV4STRINGITERATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4string_p.h" + +QT_BEGIN_NAMESPACE + + +namespace QV4 { + +namespace Heap { + +#define StringIteratorObjectMembers(class, Member) \ + Member(class, Pointer, String *, iteratedString) \ + Member(class, NoMark, quint32, nextIndex) + +DECLARE_HEAP_OBJECT(StringIteratorObject, Object) { + DECLARE_MARKOBJECTS(StringIteratorObject) + void init(String *str, QV4::ExecutionEngine *engine) + { + Object::init(); + this->iteratedString.set(engine, str); + this->nextIndex = 0; + } +}; + +} + +struct StringIteratorPrototype : Object +{ + V4_PROTOTYPE(iteratorPrototype) + void init(ExecutionEngine *engine); + + static ReturnedValue method_next(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); +}; + +struct StringIteratorObject : Object +{ + V4_OBJECT2(StringIteratorObject, Object) + Q_MANAGED_TYPE(StringIteratorObject) + V4_PROTOTYPE(stringIteratorPrototype) + + void init(ExecutionEngine *engine); +}; + + +} + +QT_END_NAMESPACE + +#endif // QV4ARRAYITERATOR_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stringobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stringobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7246a70f51fd268af1850c2e242633621e594b26 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stringobject_p.h @@ -0,0 +1,123 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4STRINGOBJECT_P_H +#define QV4STRINGOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" +#include <QtCore/qnumeric.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +#define StringObjectMembers(class, Member) \ + Member(class, Pointer, String *, string) + +DECLARE_HEAP_OBJECT(StringObject, Object) { + DECLARE_MARKOBJECTS(StringObject) + + enum { + LengthPropertyIndex = 0 + }; + + void init(bool /*don't init*/) + { Object::init(); } + void init(); + void init(const QV4::String *string); + + Heap::String *getIndex(uint index) const; + uint length() const; +}; + +struct StringCtor : FunctionObject { + void init(QV4::ExecutionEngine *engine); +}; + +} + +struct StringObject: Object { + V4_OBJECT2(StringObject, Object) + Q_MANAGED_TYPE(StringObject) + V4_INTERNALCLASS(StringObject) + V4_PROTOTYPE(stringPrototype) + + Heap::String *getIndex(uint index) const { + return d()->getIndex(index); + } + uint length() const { + return d()->length(); + } + + using Object::getOwnProperty; +protected: + static bool virtualDeleteProperty(Managed *m, PropertyKey id); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); + static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p); +}; + +struct StringCtor: FunctionObject +{ + V4_OBJECT2(StringCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_fromCharCode(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_fromCodePoint(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_raw(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +struct StringPrototype: StringObject +{ + V4_PROTOTYPE(objectPrototype) + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_charAt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_charCodeAt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_codePointAt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_concat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_endsWith(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_includes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_localeCompare(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_match(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_normalize(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_padEnd(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_padStart(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_repeat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_replace(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_search(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_split(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_startsWith(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_substr(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_substring(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toLowerCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toLocaleLowerCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toUpperCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toLocaleUpperCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_trim(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_iterator(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +} + +QT_END_NAMESPACE + +#endif // QV4ECMAOBJECTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stringtoarrayindex_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stringtoarrayindex_p.h new file mode 100644 index 0000000000000000000000000000000000000000..aa727ac062e0de0b29d39ac6f53cc8d8c8df8461 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4stringtoarrayindex_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4STRINGTOARRAYINDEX_P_H +#define QV4STRINGTOARRAYINDEX_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qnumeric_p.h> +#include <QtCore/qstring.h> +#include <limits> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +inline uint charToUInt(const QChar *ch) { return ch->unicode(); } +inline uint charToUInt(const char *ch) { return static_cast<unsigned char>(*ch); } + +template <typename T> +uint stringToArrayIndex(const T *ch, const T *end) +{ + if (ch == end) + return std::numeric_limits<uint>::max(); + uint i = charToUInt(ch) - '0'; + if (i > 9) + return std::numeric_limits<uint>::max(); + ++ch; + // reject "01", "001", ... + if (i == 0 && ch != end) + return std::numeric_limits<uint>::max(); + + while (ch < end) { + uint x = charToUInt(ch) - '0'; + if (x > 9) + return std::numeric_limits<uint>::max(); + if (qMulOverflow(i, uint(10), &i) || qAddOverflow(i, x, &i)) // i = i * 10 + x + return std::numeric_limits<uint>::max(); + ++ch; + } + return i; +} + +inline uint stringToArrayIndex(const QString &str) +{ + return stringToArrayIndex(str.constData(), str.constData() + str.size()); +} + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4STRINGTOARRAYINDEX_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4symbol_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4symbol_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3b08104c5d3c4228aac44b9f7b2c711a10f9f53a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4symbol_p.h @@ -0,0 +1,90 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4_SYMBOL_H +#define QV4_SYMBOL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4string_p.h" +#include "qv4functionobject_p.h" + +QT_BEGIN_NAMESPACE + + +namespace QV4 { + +namespace Heap { + +struct SymbolCtor : FunctionObject { + void init(ExecutionEngine *engine); +}; + +struct Symbol : StringOrSymbol { + void init(const QString &s); +}; + +#define SymbolObjectMembers(class, Member) \ + Member(class, Pointer, Symbol *, symbol) + +DECLARE_HEAP_OBJECT(SymbolObject, Object) { + DECLARE_MARKOBJECTS(SymbolObject) + void init(const QV4::Symbol *s); +}; + +} + +struct SymbolCtor : FunctionObject +{ + V4_OBJECT2(SymbolCtor, FunctionObject) + + static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *newTarget); + static ReturnedValue method_for(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_keyFor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +struct SymbolPrototype : Object +{ + V4_PROTOTYPE(objectPrototype) + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_symbolToPrimitive(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +struct Symbol : StringOrSymbol +{ + V4_MANAGED(Symbol, StringOrSymbol) + Q_MANAGED_TYPE(Symbol) + V4_INTERNALCLASS(Symbol) + V4_NEEDS_DESTROY + + static Heap::Symbol *create(ExecutionEngine *e, const QString &s); + + QString descriptiveString() const; +}; + +struct SymbolObject : Object +{ + V4_OBJECT2(SymbolObject, Object) + Q_MANAGED_TYPE(SymbolObject) + V4_INTERNALCLASS(SymbolObject) + V4_PROTOTYPE(symbolPrototype) +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4typedarray_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4typedarray_p.h new file mode 100644 index 0000000000000000000000000000000000000000..87bbaf5a25c2cc9078c6ac94c5f5cc1f2365eda3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4typedarray_p.h @@ -0,0 +1,215 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4TYPEDARRAY_H +#define QV4TYPEDARRAY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" +#include "qv4arraybuffer_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct ArrayBuffer; + +enum TypedArrayType { + Int8Array, + UInt8Array, + Int16Array, + UInt16Array, + Int32Array, + UInt32Array, + UInt8ClampedArray, + Float32Array, + Float64Array, + NTypedArrayTypes +}; + +enum AtomicModifyOps { + AtomicAdd, + AtomicAnd, + AtomicExchange, + AtomicOr, + AtomicSub, + AtomicXor, + NAtomicModifyOps +}; + +struct TypedArrayOperations { + typedef ReturnedValue (*Read)(const char *data); + typedef void (*Write)(char *data, Value value); + typedef ReturnedValue (*AtomicModify)(char *data, Value value); + typedef ReturnedValue (*AtomicCompareExchange)(char *data, Value expected, Value v); + typedef ReturnedValue (*AtomicLoad)(char *data); + typedef ReturnedValue (*AtomicStore)(char *data, Value value); + + template<typename T> + static constexpr TypedArrayOperations create(const char *name); + template<typename T> + static constexpr TypedArrayOperations createWithAtomics(const char *name); + + int bytesPerElement; + const char *name; + Read read; + Write write; + AtomicModify atomicModifyOps[AtomicModifyOps::NAtomicModifyOps]; + AtomicCompareExchange atomicCompareExchange; + AtomicLoad atomicLoad; + AtomicStore atomicStore; +}; + +namespace Heap { + +#define TypedArrayMembers(class, Member) \ + Member(class, Pointer, ArrayBuffer *, buffer) \ + Member(class, NoMark, const TypedArrayOperations *, type) \ + Member(class, NoMark, uint, byteLength) \ + Member(class, NoMark, uint, byteOffset) \ + Member(class, NoMark, uint, arrayType) + +DECLARE_HEAP_OBJECT(TypedArray, Object) { + DECLARE_MARKOBJECTS(TypedArray) + using Type = TypedArrayType; + + void init(Type t); +}; + +struct IntrinsicTypedArrayCtor : FunctionObject { +}; + +struct TypedArrayCtor : FunctionObject { + void init(ExecutionEngine *engine, TypedArray::Type t); + + TypedArray::Type type; +}; + +struct IntrinsicTypedArrayPrototype : Object { +}; + +struct TypedArrayPrototype : Object { + inline void init(TypedArray::Type t); + TypedArray::Type type; +}; + + +} + +struct Q_QML_EXPORT TypedArray : Object +{ + V4_OBJECT2(TypedArray, Object) + + static Heap::TypedArray *create(QV4::ExecutionEngine *e, Heap::TypedArray::Type t); + + uint byteOffset() const noexcept { return d()->byteOffset; } + uint byteLength() const noexcept { return d()->byteLength; } + int bytesPerElement() const noexcept { return d()->type->bytesPerElement; } + uint length() const noexcept { return d()->byteLength / d()->type->bytesPerElement; } + + char *arrayData() noexcept { return d()->buffer->arrayData(); } + const char *constArrayData() const noexcept { return d()->buffer->constArrayData(); } + bool hasDetachedArrayData() const noexcept { return d()->buffer->hasDetachedArrayData(); } + uint arrayDataLength() const noexcept { return d()->buffer->arrayDataLength(); } + + Heap::TypedArray::Type arrayType() const noexcept + { + return static_cast<Heap::TypedArray::Type>(d()->arrayType); + } + using Object::get; + + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool virtualHasProperty(const Managed *m, PropertyKey id); + static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p); + static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); + +}; + +struct IntrinsicTypedArrayCtor: FunctionObject +{ + V4_OBJECT2(IntrinsicTypedArrayCtor, FunctionObject) + + static ReturnedValue method_of(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_from(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +struct TypedArrayCtor: FunctionObject +{ + V4_OBJECT2(TypedArrayCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); + static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); +}; + +struct IntrinsicTypedArrayPrototype : Object +{ + V4_OBJECT2(IntrinsicTypedArrayPrototype, Object) + V4_PROTOTYPE(objectPrototype) + + void init(ExecutionEngine *engine, IntrinsicTypedArrayCtor *ctor); + + static ReturnedValue method_get_buffer(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_byteOffset(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_copyWithin(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_every(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_fill(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_filter(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_find(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_findIndex(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_includes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_join(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_map(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_reduce(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_reduceRight(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_reverse(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_some(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_subarray(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toLocaleString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + + static ReturnedValue method_get_toStringTag(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + +}; + +struct TypedArrayPrototype : Object +{ + V4_OBJECT2(TypedArrayPrototype, Object) + V4_PROTOTYPE(objectPrototype) + + void init(ExecutionEngine *engine, TypedArrayCtor *ctor); +}; + +inline void +Heap::TypedArrayPrototype::init(TypedArray::Type t) +{ + Object::init(); + type = t; +} + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4urlobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4urlobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..74ca22a9c53ae2aad2351318a2408103de38e550 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4urlobject_p.h @@ -0,0 +1,293 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4URLOBJECT_P_H +#define QV4URLOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4functionobject_p.h" + +#include <QtCore/QString> +#include <QtCore/QUrl> + +QT_BEGIN_NAMESPACE + +namespace QV4 { +namespace Heap { +// clang-format off +#define UrlObjectMembers(class, Member) \ + Member(class, Pointer, String *, hash) \ + Member(class, Pointer, String *, host) \ + Member(class, Pointer, String *, hostname) \ + Member(class, Pointer, String *, href) \ + Member(class, Pointer, String *, origin) \ + Member(class, Pointer, String *, password) \ + Member(class, Pointer, String *, pathname) \ + Member(class, Pointer, String *, port) \ + Member(class, Pointer, String *, protocol) \ + Member(class, Pointer, String *, search) \ + Member(class, Pointer, String *, username) +// clang-format on + +DECLARE_HEAP_OBJECT(UrlObject, Object) +{ + DECLARE_MARKOBJECTS(UrlObject) + void init() { Object::init(); } +}; + +struct UrlCtor : FunctionObject +{ + void init(ExecutionEngine *engine); +}; + +// clang-format off +#define UrlSearchParamsObjectMembers(class, Member) \ + Member(class, Pointer, ArrayObject *, params) \ + Member(class, Pointer, ArrayObject *, keys) \ + Member(class, Pointer, ArrayObject *, values) \ + Member(class, Pointer, UrlObject *, url) +// clang-format on + +DECLARE_HEAP_OBJECT(UrlSearchParamsObject, Object) +{ + DECLARE_MARKOBJECTS(UrlSearchParamsObject) + void init() { Object::init(); } +}; + +struct UrlSearchParamsCtor : FunctionObject +{ + void init(ExecutionEngine *engine); +}; +} + +struct UrlObject : Object +{ + V4_OBJECT2(UrlObject, Object) + Q_MANAGED_TYPE(UrlObject) + V4_PROTOTYPE(urlPrototype) + + QString hash() const { return QLatin1String("#") + toQString(d()->hash); } + bool setHash(QString hash); + + QString host() const { return toQString(d()->host); } + bool setHost(QString host); + + QString hostname() const { return toQString(d()->hostname); } + bool setHostname(QString hostname); + + QString href() const { return toQString(d()->href); } + bool setHref(QString href); + + QString origin() const { return toQString(d()->origin); } + + QString password() const { return toQString(d()->password); } + bool setPassword(QString password); + + QString pathname() const { return toQString(d()->pathname); } + bool setPathname(QString pathname); + + QString port() const { return toQString(d()->port); } + bool setPort(QString port); + + QString protocol() const { return toQString(d()->protocol); } + bool setProtocol(QString protocol); + + Q_QML_AUTOTEST_EXPORT QString search() const; + bool setSearch(QString search); + + QString username() const { return toQString(d()->username); } + bool setUsername(QString username); + + QUrl toQUrl() const; + void setUrl(const QUrl &url); + +private: + static QString toQString(const Heap::String *string) + { + return string ? string->toQString() : QString(); + } + + void updateOrigin(); + void updateHost(); +}; + +template<> +inline const UrlObject *Value::as() const +{ + return isManaged() && m()->internalClass->vtable->type == Managed::Type_UrlObject + ? static_cast<const UrlObject *>(this) + : nullptr; +} + +struct UrlCtor : FunctionObject +{ + V4_OBJECT2(UrlCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, + int argc, const Value *); +}; + +struct UrlPrototype : Object +{ + V4_PROTOTYPE(objectPrototype) + + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_getHash(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_setHash(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getHost(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_setHost(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getHostname(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_setHostname(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getHref(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_setHref(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getOrigin(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getPassword(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_setPassword(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getPathname(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_setPathname(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getPort(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_setPort(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getProtocol(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_setProtocol(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getSearch(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_setSearch(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getUsername(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_setUsername(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + + static ReturnedValue method_getSearchParams(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); +}; + +struct UrlSearchParamsObject : Object +{ + V4_OBJECT2(UrlSearchParamsObject, Object) + Q_MANAGED_TYPE(UrlSearchParamsObject) + V4_PROTOTYPE(urlSearchParamsPrototype) + + void initializeParams(); + void initializeParams(QString params); + void initializeParams(ScopedArrayObject& params); + void initializeParams(ScopedObject& params); + + QList<QStringList> params() const; + void setParams(QList<QStringList> params); + Heap::UrlObject *urlObject() const; + void setUrlObject(const UrlObject *url); + + QString searchString() const; + + QString nameAt(int index) const; + Heap::String * nameAtRaw(int index) const; + QString valueAt(int index) const; + Heap::String * valueAtRaw(int index) const; + + void append(Heap::String *name, Heap::String *value); + + int indexOf(QString name, int last = -1) const; + int length() const; + + using Object::getOwnProperty; +protected: + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); + static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p); +private: + QString stringAt(int index, int pairIndex) const; + Heap::String * stringAtRaw(int index, int pairIndex) const; +}; + +template<> +inline const UrlSearchParamsObject *Value::as() const +{ + return isManaged() && m()->internalClass->vtable->type == Managed::Type_UrlSearchParamsObject + ? static_cast<const UrlSearchParamsObject *>(this) + : nullptr; +} + +struct UrlSearchParamsCtor : FunctionObject +{ + V4_OBJECT2(UrlSearchParamsCtor, FunctionObject) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, + int argc, const Value *); +}; + +struct UrlSearchParamsPrototype : Object +{ + V4_PROTOTYPE(objectPrototype) + + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_append(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_get(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_getAll(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, + const Value *argv, int argc); + +}; + +} + +QT_END_NAMESPACE + +#endif // QV4URLOBJECT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4util_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4util_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d741fb4faba3d4c41616ad49e031a62bbe60607b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4util_p.h @@ -0,0 +1,160 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4UTIL_H +#define QV4UTIL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/QBitArray> +#include <QtCore/private/qglobal_p.h> +#include <algorithm> +#include <vector> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +#if !defined(BROKEN_STD_VECTOR_BOOL_OR_BROKEN_STD_FIND) +// Sanity: +class BitVector +{ + std::vector<bool> bits; + +public: + BitVector(int size = 0, bool value = false) + : bits(size, value) + {} + + void clear() + { bits = std::vector<bool>(bits.size(), false); } + + void reserve(int size) + { bits.reserve(size); } + + int size() const + { + Q_ASSERT(bits.size() < INT_MAX); + return static_cast<int>(bits.size()); + } + + void resize(int newSize) + { bits.resize(newSize); } + + void resize(int newSize, bool newValue) + { bits.resize(newSize, newValue); } + + void assign(int newSize, bool value) + { bits.assign(newSize, value); } + + int findNext(int start, bool value, bool wrapAround) const + { + // The ++operator of std::vector<bool>::iterator in libc++ has a bug when using it on an + // iterator pointing to the last element. It will not be set to ::end(), but beyond + // that. (It will be set to the first multiple of the native word size that is bigger + // than size().) + // + // See http://llvm.org/bugs/show_bug.cgi?id=19663 + // + // The work-around is to calculate the distance, and compare it to the size() to see if it's + // beyond the end, or take the minimum of the distance and the size. + + size_t pos = std::distance(bits.begin(), + std::find(bits.begin() + start, bits.end(), value)); + if (wrapAround && pos >= static_cast<size_t>(size())) + pos = std::distance(bits.begin(), + std::find(bits.begin(), bits.begin() + start, value)); + + pos = qMin(pos, static_cast<size_t>(size())); + + Q_ASSERT(pos <= static_cast<size_t>(size())); + Q_ASSERT(pos < INT_MAX); + + return static_cast<int>(pos); + } + + bool at(int idx) const + { return bits.at(idx); } + + void setBit(int idx) + { bits[idx] = true; } + + void clearBit(int idx) + { bits[idx] = false; } +}; +#else // Insanity: +class BitVector +{ + QBitArray bits; + +public: + BitVector(int size = 0, bool value = false) + : bits(size, value) + {} + + void clear() + { bits = QBitArray(bits.size(), false); } + + void reserve(int size) + { Q_UNUSED(size); } + + int size() const + { return bits.size(); } + + void resize(int newSize) + { bits.resize(newSize); } + + void resize(int newSize, bool newValue) + { + int oldSize = bits.size(); + bits.resize(newSize); + bits.fill(newValue, oldSize, bits.size()); + } + + void assign(int newSize, bool value) + { + bits.resize(newSize); + bits.fill(value); + } + + int findNext(int start, bool value, bool wrapAround) const + { + for (int i = start, ei = size(); i < ei; ++i) { + if (at(i) == value) + return i; + } + + if (wrapAround) { + for (int i = 0, ei = start; i < ei; ++i) { + if (at(i) == value) + return i; + } + } + + return size(); + } + + bool at(int idx) const + { return bits.at(idx); } + + void setBit(int idx) + { bits[idx] = true; } + + void clearBit(int idx) + { bits[idx] = false; } +}; +#endif + +} + +QT_END_NAMESPACE + +#endif // QV4UTIL_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4value_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4value_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e9fef3889c4c3736f1f1bf9359bd09602c126f0b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4value_p.h @@ -0,0 +1,479 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4VALUE_P_H +#define QV4VALUE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <limits.h> +#include <cmath> + +#include <QtCore/QString> +#include "qv4global_p.h" +#include <private/qv4heap_p.h> +#include <private/qv4internalclass_p.h> +#include <private/qv4staticvalue_p.h> + +#include <private/qnumeric_p.h> +#include <private/qv4calldata_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + struct Base; +} + +struct Q_QML_EXPORT Value : public StaticValue +{ + using ManagedPtr = Managed *; + + Value() = default; + constexpr Value(quint64 val) : StaticValue(val) {} + + static constexpr Value fromStaticValue(StaticValue staticValue) + { + return {staticValue._val}; + } + + inline bool isString() const; + inline bool isStringOrSymbol() const; + inline bool isSymbol() const; + inline bool isObject() const; + inline bool isFunctionObject() const; + + QML_NEARLY_ALWAYS_INLINE String *stringValue() const { + if (!isString()) + return nullptr; + return reinterpret_cast<String *>(const_cast<Value *>(this)); + } + QML_NEARLY_ALWAYS_INLINE StringOrSymbol *stringOrSymbolValue() const { + if (!isStringOrSymbol()) + return nullptr; + return reinterpret_cast<StringOrSymbol *>(const_cast<Value *>(this)); + } + QML_NEARLY_ALWAYS_INLINE Symbol *symbolValue() const { + if (!isSymbol()) + return nullptr; + return reinterpret_cast<Symbol *>(const_cast<Value *>(this)); + } + QML_NEARLY_ALWAYS_INLINE Object *objectValue() const { + if (!isObject()) + return nullptr; + return reinterpret_cast<Object*>(const_cast<Value *>(this)); + } + QML_NEARLY_ALWAYS_INLINE ManagedPtr managed() const { + if (!isManaged()) + return nullptr; + return reinterpret_cast<Managed*>(const_cast<Value *>(this)); + } + QML_NEARLY_ALWAYS_INLINE Value::HeapBasePtr heapObject() const { + return isManagedOrUndefined() ? m() : nullptr; + } + + static inline Value fromHeapObject(HeapBasePtr m) + { + Value v; + v.setM(m); + return v; + } + + int toUInt16() const; + inline int toInt32() const; + inline unsigned int toUInt32() const; + qint64 toLength() const; + inline qint64 toIndex() const; + + bool toBoolean() const { + if (integerCompatible()) + return static_cast<bool>(int_32()); + + return toBooleanImpl(*this); + } + static bool toBooleanImpl(Value val); + double toInteger() const; + inline ReturnedValue convertedToNumber() const; + inline double toNumber() const; + static double toNumberImpl(Value v); + double toNumberImpl() const { return toNumberImpl(*this); } + + QString toQStringNoThrow() const; + QString toQString() const; + QString toQString(bool *ok) const; + + Heap::String *toString(ExecutionEngine *e) const { + if (isString()) + return reinterpret_cast<Heap::String *>(m()); + return toString(e, *this); + } + QV4::PropertyKey toPropertyKey(ExecutionEngine *e) const; + + static Heap::String *toString(ExecutionEngine *e, Value val); + Heap::Object *toObject(ExecutionEngine *e) const { + if (isObject()) + return reinterpret_cast<Heap::Object *>(m()); + return toObject(e, *this); + } + static Heap::Object *toObject(ExecutionEngine *e, Value val); + + inline bool isPrimitive() const; + + template <typename T> + const T *as() const { + if (!isManaged()) + return nullptr; + + Q_ASSERT(m()->internalClass->vtable); +#if !defined(QT_NO_QOBJECT_CHECK) + static_cast<const T *>(this)->qt_check_for_QMANAGED_macro(static_cast<const T *>(this)); +#endif + const VTable *vt = m()->internalClass->vtable; + while (vt) { + if (vt == T::staticVTable()) + return static_cast<const T *>(this); + vt = vt->parent; + } + return nullptr; + } + template <typename T> + T *as() { + if (isManaged()) + return const_cast<T *>(const_cast<const Value *>(this)->as<T>()); + else + return nullptr; + } + + template<typename T> inline T *cast() { + return static_cast<T *>(managed()); + } + template<typename T> inline const T *cast() const { + return static_cast<const T *>(managed()); + } + + uint asArrayLength(bool *ok) const; + + static constexpr Value fromReturnedValue(ReturnedValue val) + { + return fromStaticValue(StaticValue::fromReturnedValue(val)); + } + + // As per ES specs + bool sameValue(Value other) const; + bool sameValueZero(Value other) const; + + inline void mark(MarkStack *markStack); + + static double toInteger(double d) { return StaticValue::toInteger(d); } + static int toInt32(double d) { return StaticValue::toInt32(d); } + static unsigned int toUInt32(double d) { return StaticValue::toUInt32(d); } + inline static constexpr Value emptyValue() + { + return fromStaticValue(StaticValue::emptyValue()); + } + static inline constexpr Value fromBoolean(bool b) + { + return fromStaticValue(StaticValue::fromBoolean(b)); + } + static inline constexpr Value fromInt32(int i) + { + return fromStaticValue(StaticValue::fromInt32(i)); + } + inline static constexpr Value undefinedValue() + { + return fromStaticValue(StaticValue::undefinedValue()); + } + static inline constexpr Value nullValue() + { + return fromStaticValue(StaticValue::nullValue()); + } + static inline Value fromDouble(double d) + { + return fromStaticValue(StaticValue::fromDouble(d)); + } + static inline Value fromUInt32(uint i) + { + return fromStaticValue(StaticValue::fromUInt32(i)); + } + + Value &operator =(const ScopedValue &v); + Value &operator=(ReturnedValue v) + { + StaticValue::operator=(v); + return *this; + } + Value &operator=(ManagedPtr m) { + if (!m) { + setM(nullptr); + } else { + _val = reinterpret_cast<Value *>(m)->_val; + } + return *this; + } + Value &operator=(HeapBasePtr o) { + setM(o); + return *this; + } + + template<typename T> + Value &operator=(const Scoped<T> &t); +}; +Q_STATIC_ASSERT(std::is_trivial_v<Value>); +Q_STATIC_ASSERT(sizeof(Value) == sizeof(StaticValue)); + +template<> +inline StaticValue &StaticValue::operator=<Value>(const Value &value) +{ + _val = value._val; + return *this; +} + +template<typename Managed> +inline StaticValue &StaticValue::operator=(const Managed &m) +{ + *static_cast<Value *>(this) = m; + return *this; +} + +template<> +inline Value &StaticValue::asValue<Value>() +{ + return *static_cast<Value *>(this); +} + +template<> +inline const Value &StaticValue::asValue<Value>() const +{ + return *static_cast<const Value *>(this); +} + +template<> +inline Value *CallData::argValues<Value>() +{ + return static_cast<Value *>(static_cast<StaticValue *>(args)); +} + +template<> +inline const Value *CallData::argValues<Value>() const +{ + return static_cast<const Value *>(static_cast<const StaticValue *>(args)); +} + +template<typename HeapBase> +inline Encode::Encode(HeapBase *o) +{ + val = Value::fromHeapObject(o).asReturnedValue(); +} + +inline void Value::mark(MarkStack *markStack) +{ + HeapBasePtr o = heapObject(); + if (o) + o->mark(markStack); +} + +inline bool Value::isString() const +{ + HeapBasePtr b = heapObject(); + return b && b->internalClass->vtable->isString; +} + +bool Value::isStringOrSymbol() const +{ + HeapBasePtr b = heapObject(); + return b && b->internalClass->vtable->isStringOrSymbol; +} + +bool Value::isSymbol() const +{ + HeapBasePtr b = heapObject(); + return b && b->internalClass->vtable->isStringOrSymbol && !b->internalClass->vtable->isString; +} + +inline bool Value::isObject() const + +{ + HeapBasePtr b = heapObject(); + return b && b->internalClass->vtable->isObject; +} + +inline bool Value::isFunctionObject() const +{ + HeapBasePtr b = heapObject(); + if (!b) + return false; + const VTable *vtable = b->internalClass->vtable; + return vtable->call || vtable->callAsConstructor; +} + +inline bool Value::isPrimitive() const +{ + return !isObject(); +} + +inline double Value::toNumber() const +{ + if (isInteger()) + return int_32(); + if (isDouble()) + return doubleValue(); + return toNumberImpl(); +} + +inline ReturnedValue Value::convertedToNumber() const +{ + if (isInteger() || isDouble()) + return asReturnedValue(); + Value v; + v.setDouble(toNumberImpl()); + return v.asReturnedValue(); +} + +inline +ReturnedValue Heap::Base::asReturnedValue() const +{ + return Value::fromHeapObject(const_cast<Value::HeapBasePtr>(this)).asReturnedValue(); +} + +// For source compat with older code in other modules +using Primitive = Value; + +template<typename T> +ReturnedValue value_convert(ExecutionEngine *e, const Value &v); + +inline int Value::toInt32() const +{ + if (Q_LIKELY(integerCompatible())) + return int_32(); + + if (Q_LIKELY(isDouble())) + return QJSNumberCoercion::toInteger(doubleValue()); + + return QJSNumberCoercion::toInteger(toNumberImpl()); +} + +inline unsigned int Value::toUInt32() const +{ + return static_cast<unsigned int>(toInt32()); +} + +inline qint64 Value::toLength() const +{ + if (Q_LIKELY(integerCompatible())) + return int_32() < 0 ? 0 : int_32(); + double i = Value::toInteger(isDouble() ? doubleValue() : toNumberImpl()); + if (i <= 0) + return 0; + if (i > (static_cast<qint64>(1) << 53) - 1) + return (static_cast<qint64>(1) << 53) - 1; + return static_cast<qint64>(i); +} + +inline qint64 Value::toIndex() const +{ + qint64 idx; + if (Q_LIKELY(integerCompatible())) { + idx = int_32(); + } else { + idx = static_cast<qint64>(Value::toInteger(isDouble() ? doubleValue() : toNumberImpl())); + } + if (idx > (static_cast<qint64>(1) << 53) - 1) + idx = -1; + return idx; +} + +inline double Value::toInteger() const +{ + if (integerCompatible()) + return int_32(); + + return Value::toInteger(isDouble() ? doubleValue() : toNumberImpl()); +} + + +template <size_t o> +struct HeapValue : Value { + static constexpr size_t offset = o; + HeapBasePtr base() { + HeapBasePtr base = reinterpret_cast<HeapBasePtr>(this) - (offset/sizeof(Heap::Base)); + Q_ASSERT(base->inUse()); + return base; + } + + void set(EngineBase *e, const Value &newVal) { + WriteBarrier::write(e, base(), data_ptr(), newVal.asReturnedValue()); + } + void set(EngineBase *e, HeapBasePtr b) { + WriteBarrier::write(e, base(), data_ptr(), b->asReturnedValue()); + } +}; + +template <size_t o> +struct ValueArray { + static constexpr size_t offset = o; + uint size; + uint alloc; + Value values[1]; + + Value::HeapBasePtr base() { + Value::HeapBasePtr base = reinterpret_cast<Value::HeapBasePtr>(this) + - (offset/sizeof(Heap::Base)); + Q_ASSERT(base->inUse()); + return base; + } + + void set(EngineBase *e, uint index, Value v) { + WriteBarrier::write(e, base(), values[index].data_ptr(), v.asReturnedValue()); + } + void set(EngineBase *e, uint index, Value::HeapBasePtr b) { + WriteBarrier::write(e, base(), values[index].data_ptr(), Value::fromHeapObject(b).asReturnedValue()); + } + inline const Value &operator[] (uint index) const { + Q_ASSERT(index < alloc); + return values[index]; + } + inline const Value *data() const { + return values; + } + + void mark(MarkStack *markStack) { + for (Value *v = values, *end = values + alloc; v < end; ++v) + v->mark(markStack); + } +}; + +// It's really important that the offset of values in this structure is +// constant across all architecture, otherwise JIT cross-compiled code will +// have wrong offsets between host and target. +Q_STATIC_ASSERT(offsetof(ValueArray<0>, values) == 8); + +class OptionalReturnedValue { + ReturnedValue value; +public: + + OptionalReturnedValue() : value(Value::emptyValue().asReturnedValue()) {} + explicit OptionalReturnedValue(ReturnedValue v) + : value(v) + { + Q_ASSERT(!Value::fromReturnedValue(v).isEmpty()); + } + + ReturnedValue operator->() const { return value; } + ReturnedValue operator*() const { return value; } + explicit operator bool() const { return !Value::fromReturnedValue(value).isEmpty(); } +}; + +} + +QT_END_NAMESPACE + +#endif // QV4VALUE_DEF_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4variantobject_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4variantobject_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5a36e589c4a15b0109aca896a1d6236e6ff6984c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4variantobject_p.h @@ -0,0 +1,87 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4VARIANTOBJECT_P_H +#define QV4VARIANTOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtQml/qqmllist.h> +#include <QtCore/qvariant.h> + +#include <private/qv4value_p.h> +#include <private/qv4object_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +namespace Heap { + +struct VariantObject : Object +{ + void init(); + void init(const QMetaType type, const void *data); + void destroy() { + Q_ASSERT(scarceData); + if (isScarce()) + addVmePropertyReference(); + delete scarceData; + Object::destroy(); + } + bool isScarce() const; + int vmePropertyReferenceCount; + + const QVariant &data() const { return scarceData->data; } + QVariant &data() { return scarceData->data; } + + void addVmePropertyReference() { scarceData->node.remove(); } + void removeVmePropertyReference() { internalClass->engine->scarceResources.insert(scarceData); } + +private: + ExecutionEngine::ScarceResourceData *scarceData; +}; + +} + +struct Q_QML_EXPORT VariantObject : Object +{ + V4_OBJECT2(VariantObject, Object) + V4_PROTOTYPE(variantPrototype) + V4_NEEDS_DESTROY + + void addVmePropertyReference() const; + void removeVmePropertyReference() const; + +protected: + static bool virtualIsEqualTo(Managed *m, Managed *other); +}; + +struct VariantPrototype : VariantObject +{ +public: + V4_PROTOTYPE(objectPrototype) + void init(); + + static ReturnedValue method_preserve(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_destroy(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +} + +QT_END_NAMESPACE + +#endif + diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4vme_moth_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4vme_moth_p.h new file mode 100644 index 0000000000000000000000000000000000000000..963143677b1c78167ad86ad6a72c40fabefa338a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4vme_moth_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4VME_MOTH_P_H +#define QV4VME_MOTH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <private/qv4staticvalue_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { +namespace Moth { + +class VME +{ +public: + struct ExecData { + QV4::Function *function; + const QV4::ExecutionContext *scope; + }; + + static void exec(MetaTypesStackFrame *frame, ExecutionEngine *engine); + static QV4::ReturnedValue exec(JSTypesStackFrame *frame, ExecutionEngine *engine); + static QV4::ReturnedValue interpret(JSTypesStackFrame *frame, ExecutionEngine *engine, const char *codeEntry); +}; + +} // namespace Moth +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4VME_MOTH_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4vtable_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4vtable_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1acf5d04be32b1683d8c907cf3d0384e29fe1fb6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4vtable_p.h @@ -0,0 +1,299 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4VTABLE_P_H +#define QV4VTABLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4global_p.h" +#include <QtCore/qmetaobject.h> + +QT_BEGIN_NAMESPACE + +class QObject; +namespace QV4 { + +struct Lookup; + +struct Q_QML_EXPORT OwnPropertyKeyIterator { + virtual ~OwnPropertyKeyIterator() = 0; + virtual PropertyKey next(const Object *o, Property *p = nullptr, PropertyAttributes *attrs = nullptr) = 0; +}; + +struct VTable +{ + typedef void (*Destroy)(Heap::Base *); + typedef void (*MarkObjects)(Heap::Base *, MarkStack *markStack); + typedef bool (*IsEqualTo)(Managed *m, Managed *other); + + typedef ReturnedValue (*Get)(const Managed *, PropertyKey id, const Value *receiver, bool *hasProperty); + typedef bool (*Put)(Managed *, PropertyKey id, const Value &value, Value *receiver); + typedef bool (*DeleteProperty)(Managed *m, PropertyKey id); + typedef bool (*HasProperty)(const Managed *m, PropertyKey id); + typedef PropertyAttributes (*GetOwnProperty)(const Managed *m, PropertyKey id, Property *p); + typedef bool (*DefineOwnProperty)(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs); + typedef bool (*IsExtensible)(const Managed *); + typedef bool (*PreventExtensions)(Managed *); + typedef Heap::Object *(*GetPrototypeOf)(const Managed *); + typedef bool (*SetPrototypeOf)(Managed *, const Object *); + typedef qint64 (*GetLength)(const Managed *m); + typedef OwnPropertyKeyIterator *(*OwnPropertyKeys)(const Object *m, Value *target); + typedef ReturnedValue (*InstanceOf)(const Object *typeObject, const Value &var); + + typedef ReturnedValue (*Call)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + typedef void (*CallWithMetaTypes)(const FunctionObject *, QObject *, void **, const QMetaType *, int); + typedef ReturnedValue (*CallAsConstructor)(const FunctionObject *, const Value *argv, int argc, const Value *newTarget); + + typedef ReturnedValue (*ResolveLookupGetter)(const Object *, ExecutionEngine *, Lookup *); + typedef bool (*ResolveLookupSetter)(Object *, ExecutionEngine *, Lookup *, const Value &); + + typedef int (*Metacall)(Object *, QMetaObject::Call, int, void **); + + const VTable * const parent; + quint16 inlinePropertyOffset; + quint16 nInlineProperties; + quint8 isExecutionContext; + quint8 isString; + quint8 isObject; + quint8 isTailCallable; + quint8 isErrorObject; + quint8 isArrayData; + quint8 isStringOrSymbol; + quint8 type; + quint8 unused[4]; + const char *className; + + Destroy destroy; + MarkObjects markObjects; + IsEqualTo isEqualTo; + + Get get; + Put put; + DeleteProperty deleteProperty; + HasProperty hasProperty; + GetOwnProperty getOwnProperty; + DefineOwnProperty defineOwnProperty; + IsExtensible isExtensible; + PreventExtensions preventExtensions; + GetPrototypeOf getPrototypeOf; + SetPrototypeOf setPrototypeOf; + GetLength getLength; + OwnPropertyKeys ownPropertyKeys; + InstanceOf instanceOf; + + Call call; + CallAsConstructor callAsConstructor; + CallWithMetaTypes callWithMetaTypes; + + ResolveLookupGetter resolveLookupGetter; + ResolveLookupSetter resolveLookupSetter; + + Metacall metacall; +}; + +template<VTable::CallWithMetaTypes call> +struct VTableCallWithMetaTypesWrapper { constexpr static VTable::CallWithMetaTypes c = call; }; + +template<VTable::Call call> +struct VTableCallWrapper { constexpr static VTable::Call c = call; }; + +template<class Class> +constexpr VTable::CallWithMetaTypes vtableMetaTypesCallEntry() +{ + // If Class overrides virtualCallWithMetaTypes, return that. + // Otherwise, if it overrides virtualCall, return convertAndCall. + // Otherwise, just return whatever the base class had. + + // A simple == on methods is not considered constexpr, so we have to jump through some hoops. + + static_assert( + std::is_same_v< + VTableCallWithMetaTypesWrapper<Class::virtualCallWithMetaTypes>, + VTableCallWithMetaTypesWrapper<Class::SuperClass::virtualCallWithMetaTypes>> + || !std::is_same_v< + VTableCallWithMetaTypesWrapper<Class::virtualCallWithMetaTypes>, + VTableCallWithMetaTypesWrapper<nullptr>>, + "You mustn't override virtualCallWithMetaTypes with nullptr"); + + static_assert( + std::is_same_v< + VTableCallWithMetaTypesWrapper<Class::virtualConvertAndCall>, + VTableCallWithMetaTypesWrapper<Class::SuperClass::virtualConvertAndCall>> + || !std::is_same_v< + VTableCallWithMetaTypesWrapper<Class::virtualConvertAndCall>, + VTableCallWithMetaTypesWrapper<nullptr>>, + "You mustn't override virtualConvertAndCall with nullptr"); + + if constexpr ( + std::is_same_v< + VTableCallWithMetaTypesWrapper<Class::virtualCallWithMetaTypes>, + VTableCallWithMetaTypesWrapper<Class::SuperClass::virtualCallWithMetaTypes>> + && !std::is_same_v< + VTableCallWrapper<Class::virtualCall>, + VTableCallWrapper<Class::SuperClass::virtualCall>>) { + // Converting from metatypes to JS signature is easy. + return Class::virtualConvertAndCall; + } + + return Class::virtualCallWithMetaTypes; +} + +template<class Class> +constexpr VTable::Call vtableJsTypesCallEntry() +{ + // If Class overrides virtualCall, return that. + // Otherwise, if it overrides virtualCallWithMetaTypes, fail. + // (We cannot determine the target types to call virtualCallWithMetaTypes in that case) + // Otherwise, just return whatever the base class had. + + // A simple == on methods is not considered constexpr, so we have to jump through some hoops. + + static_assert( + !std::is_same_v< + VTableCallWrapper<Class::virtualCall>, + VTableCallWrapper<Class::SuperClass::virtualCall>> + || std::is_same_v< + VTableCallWithMetaTypesWrapper<Class::virtualCallWithMetaTypes>, + VTableCallWithMetaTypesWrapper<Class::SuperClass::virtualCallWithMetaTypes>>, + "If you override virtualCallWithMetaTypes, override virtualCall, too"); + + static_assert( + std::is_same_v< + VTableCallWrapper<Class::virtualCall>, + VTableCallWrapper<Class::SuperClass::virtualCall>> + || VTableCallWrapper<Class::virtualCall>::c != nullptr, + "You mustn't override virtualCall with nullptr"); + + return Class::virtualCall; +} + +struct VTableBase { +protected: + static constexpr VTable::Destroy virtualDestroy = nullptr; + static constexpr VTable::IsEqualTo virtualIsEqualTo = nullptr; + + static constexpr VTable::Get virtualGet = nullptr; + static constexpr VTable::Put virtualPut = nullptr; + static constexpr VTable::DeleteProperty virtualDeleteProperty = nullptr; + static constexpr VTable::HasProperty virtualHasProperty = nullptr; + static constexpr VTable::GetOwnProperty virtualGetOwnProperty = nullptr; + static constexpr VTable::DefineOwnProperty virtualDefineOwnProperty = nullptr; + static constexpr VTable::IsExtensible virtualIsExtensible = nullptr; + static constexpr VTable::PreventExtensions virtualPreventExtensions = nullptr; + static constexpr VTable::GetPrototypeOf virtualGetPrototypeOf = nullptr; + static constexpr VTable::SetPrototypeOf virtualSetPrototypeOf = nullptr; + static constexpr VTable::GetLength virtualGetLength = nullptr; + static constexpr VTable::OwnPropertyKeys virtualOwnPropertyKeys = nullptr; + static constexpr VTable::InstanceOf virtualInstanceOf = nullptr; + + static constexpr VTable::Call virtualCall = nullptr; + static constexpr VTable::CallAsConstructor virtualCallAsConstructor = nullptr; + static constexpr VTable::CallWithMetaTypes virtualCallWithMetaTypes = nullptr; + static constexpr VTable::CallWithMetaTypes virtualConvertAndCall = nullptr; + + static constexpr VTable::ResolveLookupGetter virtualResolveLookupGetter = nullptr; + static constexpr VTable::ResolveLookupSetter virtualResolveLookupSetter = nullptr; + + static constexpr VTable::Metacall virtualMetacall = nullptr; + + template<class Class> + friend constexpr VTable::CallWithMetaTypes vtableMetaTypesCallEntry(); + + template<class Class> + friend constexpr VTable::Call vtableJsTypesCallEntry(); +}; + +#define DEFINE_MANAGED_VTABLE_INT(classname, parentVTable) \ +{ \ + parentVTable, \ + (sizeof(classname::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), \ + (sizeof(classname::Data) + (classname::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) \ + - (sizeof(classname::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), \ + classname::IsExecutionContext, \ + classname::IsString, \ + classname::IsObject, \ + classname::IsTailCallable, \ + classname::IsErrorObject, \ + classname::IsArrayData, \ + classname::IsStringOrSymbol, \ + classname::MyType, \ + { 0, 0, 0, 0 }, \ + #classname, \ + \ + classname::virtualDestroy, \ + classname::Data::markObjects, \ + classname::virtualIsEqualTo, \ + \ + classname::virtualGet, \ + classname::virtualPut, \ + classname::virtualDeleteProperty, \ + classname::virtualHasProperty, \ + classname::virtualGetOwnProperty, \ + classname::virtualDefineOwnProperty, \ + classname::virtualIsExtensible, \ + classname::virtualPreventExtensions, \ + classname::virtualGetPrototypeOf, \ + classname::virtualSetPrototypeOf, \ + classname::virtualGetLength, \ + classname::virtualOwnPropertyKeys, \ + classname::virtualInstanceOf, \ + \ + QV4::vtableJsTypesCallEntry<classname>(), \ + classname::virtualCallAsConstructor, \ + QV4::vtableMetaTypesCallEntry<classname>(), \ + \ + classname::virtualResolveLookupGetter, \ + classname::virtualResolveLookupSetter, \ + classname::virtualMetacall \ +} + +#define DEFINE_MANAGED_VTABLE(classname) \ +const QV4::VTable classname::static_vtbl = DEFINE_MANAGED_VTABLE_INT(classname, 0) + +#define V4_OBJECT2(DataClass, superClass) \ + private: \ + DataClass() = delete; \ + Q_DISABLE_COPY(DataClass) \ + public: \ + Q_MANAGED_CHECK \ + typedef QV4::Heap::DataClass Data; \ + typedef superClass SuperClass; \ + static const QV4::VTable static_vtbl; \ + static inline const QV4::VTable *staticVTable() { return &static_vtbl; } \ + V4_MANAGED_SIZE_TEST \ + QV4::Heap::DataClass *d_unchecked() const { return static_cast<QV4::Heap::DataClass *>(m()); } \ + QV4::Heap::DataClass *d() const { \ + QV4::Heap::DataClass *dptr = d_unchecked(); \ + dptr->_checkIsInitialized(); \ + return dptr; \ + } \ + Q_STATIC_ASSERT(std::is_trivial_v<QV4::Heap::DataClass>); + +#define V4_PROTOTYPE(p) \ + static QV4::Object *defaultPrototype(QV4::ExecutionEngine *e) \ + { return e->p(); } + + +#define DEFINE_OBJECT_VTABLE_BASE(classname) \ + const QV4::VTable classname::static_vtbl = DEFINE_MANAGED_VTABLE_INT(classname, (std::is_same<classname::SuperClass, Object>::value) ? nullptr : &classname::SuperClass::static_vtbl) + +#define DEFINE_OBJECT_VTABLE(classname) \ +DEFINE_OBJECT_VTABLE_BASE(classname) + +#define DEFINE_OBJECT_TEMPLATE_VTABLE(classname) \ +template<> DEFINE_OBJECT_VTABLE_BASE(classname) + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4writebarrier_p.h b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4writebarrier_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cb87b953c2add8a4c063d8d30f1a1a457761a645 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQml/6.8.1/QtQml/private/qv4writebarrier_p.h @@ -0,0 +1,131 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QV4WRITEBARRIER_P_H +#define QV4WRITEBARRIER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qv4global_p.h> +#include <private/qv4enginebase_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { +struct EngineBase; +typedef quint64 ReturnedValue; + +struct WriteBarrier { + + static constexpr bool isInsertionBarrier = true; + + Q_ALWAYS_INLINE static void write(EngineBase *engine, Heap::Base *base, ReturnedValue *slot, ReturnedValue value) + { + if (engine->isGCOngoing) + write_slowpath(engine, base, slot, value); + *slot = value; + } + Q_QML_EXPORT Q_NEVER_INLINE static void write_slowpath( + EngineBase *engine, Heap::Base *base, + ReturnedValue *slot, ReturnedValue value); + + Q_ALWAYS_INLINE static void write(EngineBase *engine, Heap::Base *base, Heap::Base **slot, Heap::Base *value) + { + if (engine->isGCOngoing) + write_slowpath(engine, base, slot, value); + *slot = value; + } + Q_QML_EXPORT Q_NEVER_INLINE static void write_slowpath( + EngineBase *engine, Heap::Base *base, + Heap::Base **slot, Heap::Base *value); + + // MemoryManager isn't a complete type here, so make Engine a template argument + // so that we can still call engine->memoryManager->markStack() + template<typename F, typename Engine = EngineBase> + static void markCustom(Engine *engine, F &&markFunction) { + if (engine->isGCOngoing) + (std::forward<F>(markFunction))(engine->memoryManager->markStack()); + } + + // HeapObjectWrapper(Base) are helper classes to ensure that + // we always use a WriteBarrier when setting heap-objects + // they are also trivial; if triviality is not required, use Pointer instead + struct HeapObjectWrapperBase + { + // enum class avoids accidental construction via brace-init + enum class PointerWrapper : quintptr {}; + PointerWrapper wrapped; + + void clear() { wrapped = PointerWrapper(quintptr(0)); } + }; + + template<typename HeapType> + struct HeapObjectWrapperCommon : HeapObjectWrapperBase + { + HeapType *get() const { return reinterpret_cast<HeapType *>(wrapped); } + operator HeapType *() const { return get(); } + HeapType * operator->() const { return get(); } + + template <typename ConvertibleToHeapType> + void set(QV4::EngineBase *engine, ConvertibleToHeapType *heapObject) + { + WriteBarrier::markCustom(engine, [heapObject](QV4::MarkStack *ms){ + if (heapObject) + heapObject->mark(ms); + }); + wrapped = static_cast<HeapObjectWrapperBase::PointerWrapper>(quintptr(heapObject)); + } + }; + + // all types are trivial; we however want to block copies bypassing the write barrier + // therefore, all members use a PhantomTag to reduce the likelihood + template<typename HeapType, int PhantomTag> + struct HeapObjectWrapper : HeapObjectWrapperCommon<HeapType> {}; + + /* similar Heap::Pointer, but without the Base conversion (and its inUse assert) + and for storing references in engine classes stored on the native heap + Stores a "non-owning" reference to a heap-item (in the C++ sense), but should + generally mark the heap-item; therefore set goes through a write-barrier + */ + template<typename T> + struct Pointer + { + Pointer() = default; + ~Pointer() = default; + Q_DISABLE_COPY_MOVE(Pointer) + T* operator->() const { return get(); } + operator T* () const { return get(); } + + void set(EngineBase *e, T *newVal) { + WriteBarrier::markCustom(e, [newVal](QV4::MarkStack *ms) { + if (newVal) + newVal->mark(ms); + }); + ptr = newVal; + } + + T* get() const { return ptr; } + + + + private: + T *ptr = nullptr; + }; +}; + + // ### this needs to be filled with a real memory fence once marking is concurrent +Q_ALWAYS_INLINE void fence() {} + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlAssetDownloader/6.8.1/QtQmlAssetDownloader/private/qqmlassetdownloader_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlAssetDownloader/6.8.1/QtQmlAssetDownloader/private/qqmlassetdownloader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cbf8c396f8251ab4bda2f10cb744b683b4d9b565 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlAssetDownloader/6.8.1/QtQmlAssetDownloader/private/qqmlassetdownloader_p.h @@ -0,0 +1,51 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLASSETDOWNLOADER_P_H +#define QQMLASSETDOWNLOADER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtExamplesAssetDownloader/assetdownloader.h> +#include <QtQml/qqml.h> + +QT_BEGIN_NAMESPACE + +namespace Assets::Downloader { + +class AssetDownloaderHelper : public AssetDownloader +{ + Q_OBJECT + +public: + AssetDownloaderHelper(QObject *parent = nullptr); + +protected: + virtual QUrl resolvedUrl(const QUrl &url) const override; +}; + +struct QQmlAssetDownloader +{ + Q_GADGET + QML_FOREIGN(AssetDownloaderHelper) + QML_NAMED_ELEMENT(AssetDownloader) + QML_ADDED_IN_VERSION(6, 8) + +public: + static AssetDownloaderHelper *create(QQmlEngine *, QJSEngine *); +}; + +} // namespace Assets::Downloader + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qcoloroutput_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qcoloroutput_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4a4068ebbda2fff098f24ef9626ee490adaccb30 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qcoloroutput_p.h @@ -0,0 +1,96 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QCOLOROUTPUT_H +#define QCOLOROUTPUT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qscopedpointer.h> +#include <QtCore/qstring.h> + +QT_BEGIN_NAMESPACE + +class QColorOutputPrivate; + +class Q_QMLCOMPILER_EXPORT QColorOutput +{ + enum + { + ForegroundShift = 10, + BackgroundShift = 20, + SpecialShift = 20, + ForegroundMask = 0x1f << ForegroundShift, + BackgroundMask = 0x7 << BackgroundShift + }; + +public: + enum ColorCodeComponent + { + BlackForeground = 1 << ForegroundShift, + BlueForeground = 2 << ForegroundShift, + GreenForeground = 3 << ForegroundShift, + CyanForeground = 4 << ForegroundShift, + RedForeground = 5 << ForegroundShift, + PurpleForeground = 6 << ForegroundShift, + BrownForeground = 7 << ForegroundShift, + LightGrayForeground = 8 << ForegroundShift, + DarkGrayForeground = 9 << ForegroundShift, + LightBlueForeground = 10 << ForegroundShift, + LightGreenForeground = 11 << ForegroundShift, + LightCyanForeground = 12 << ForegroundShift, + LightRedForeground = 13 << ForegroundShift, + LightPurpleForeground = 14 << ForegroundShift, + YellowForeground = 15 << ForegroundShift, + WhiteForeground = 16 << ForegroundShift, + + BlackBackground = 1 << BackgroundShift, + BlueBackground = 2 << BackgroundShift, + GreenBackground = 3 << BackgroundShift, + CyanBackground = 4 << BackgroundShift, + RedBackground = 5 << BackgroundShift, + PurpleBackground = 6 << BackgroundShift, + BrownBackground = 7 << BackgroundShift, + DefaultColor = 1 << SpecialShift + }; + + using ColorCode = QFlags<ColorCodeComponent>; + using ColorMapping = QHash<int, ColorCode>; + + QColorOutput(); + ~QColorOutput(); + + bool isSilent() const; + void setSilent(bool silent); + + void insertMapping(int colorID, ColorCode colorCode); + + void writeUncolored(const QString &message); + void write(const QStringView message, int color = -1); + // handle QStringBuilder case + Q_WEAK_OVERLOAD void write(const QString &message, int color = -1) { write(QStringView(message), color); } + void writePrefixedMessage(const QString &message, QtMsgType type, + const QString &prefix = QString()); + QString colorify(QStringView message, int color = -1) const; + +private: + QScopedPointer<QColorOutputPrivate> d; + Q_DISABLE_COPY_MOVE(QColorOutput) +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QColorOutput::ColorCode) + +QT_END_NAMESPACE + +#endif // QCOLOROUTPUT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qdeferredpointer_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qdeferredpointer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..14163eb7ddf2d2cd2c9d6934af8d60327388a7d9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qdeferredpointer_p.h @@ -0,0 +1,253 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QDEFERREDPOINTER_P_H +#define QDEFERREDPOINTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qsharedpointer.h> + +QT_BEGIN_NAMESPACE + +template<typename T> +class QDeferredSharedPointer; + +template<typename T> +class QDeferredWeakPointer; + +template<typename T> +class QDeferredFactory +{ +public: + bool isValid() const; + +private: + friend class QDeferredSharedPointer<const T>; + friend class QDeferredWeakPointer<const T>; + friend class QDeferredSharedPointer<T>; + friend class QDeferredWeakPointer<T>; + void populate(const QSharedPointer<T> &) const; +}; + +template<typename T> +class QDeferredSharedPointer +{ +public: + using Factory = QDeferredFactory<std::remove_const_t<T>>; + + Q_NODISCARD_CTOR QDeferredSharedPointer() = default; + + Q_NODISCARD_CTOR QDeferredSharedPointer(QSharedPointer<T> data) + : m_data(std::move(data)) + {} + + Q_NODISCARD_CTOR QDeferredSharedPointer(QWeakPointer<T> data) + : m_data(std::move(data)) + {} + + Q_NODISCARD_CTOR QDeferredSharedPointer(QSharedPointer<T> data, QSharedPointer<Factory> factory) + : m_data(std::move(data)), m_factory(std::move(factory)) + { + // You have to provide a valid pointer if you provide a factory. We cannot allocate the + // pointer for you because then two copies of the same QDeferredSharedPointer will diverge + // and lazy-load two separate data objects. + Q_ASSERT(!m_data.isNull() || m_factory.isNull()); + } + + [[nodiscard]] operator QSharedPointer<T>() const + { + lazyLoad(); + return m_data; + } + + operator QDeferredSharedPointer<const T>() const { return { m_data, m_factory }; } + + [[nodiscard]] T &operator*() const { return QSharedPointer<T>(*this).operator*(); } + [[nodiscard]] T *operator->() const { return QSharedPointer<T>(*this).operator->(); } + + bool isNull() const + { + return m_data.isNull(); + } + + explicit operator bool() const noexcept { return !isNull(); } + bool operator !() const noexcept { return isNull(); } + + [[nodiscard]] T *data() const { return QSharedPointer<T>(*this).data(); } + [[nodiscard]] T *get() const { return data(); } + + friend size_t qHash(const QDeferredSharedPointer &ptr, size_t seed = 0) + { + // This is a hash of the pointer, not the data. + return qHash(ptr.m_data, seed); + } + + friend bool operator==(const QDeferredSharedPointer &a, const QDeferredSharedPointer &b) + { + // This is a comparison of the pointers, not their data. As we require the pointers to + // be given in the ctor, we can do this. + return a.m_data == b.m_data; + } + + friend bool operator!=(const QDeferredSharedPointer &a, const QDeferredSharedPointer &b) + { + return !(a == b); + } + + friend bool operator<(const QDeferredSharedPointer &a, const QDeferredSharedPointer &b) + { + return a.m_data < b.m_data; + } + + friend bool operator<=(const QDeferredSharedPointer &a, const QDeferredSharedPointer &b) + { + return a.m_data <= b.m_data; + } + + friend bool operator>(const QDeferredSharedPointer &a, const QDeferredSharedPointer &b) + { + return a.m_data > b.m_data; + } + + friend bool operator>=(const QDeferredSharedPointer &a, const QDeferredSharedPointer &b) + { + return a.m_data >= b.m_data; + } + + template <typename U> + friend bool operator==(const QDeferredSharedPointer &a, const QSharedPointer<U> &b) + { + return a.m_data == b; + } + + template <typename U> + friend bool operator!=(const QDeferredSharedPointer &a, const QSharedPointer<U> &b) + { + return !(a == b); + } + + template <typename U> + friend bool operator==(const QSharedPointer<U> &a, const QDeferredSharedPointer &b) + { + return b == a; + } + + template <typename U> + friend bool operator!=(const QSharedPointer<U> &a, const QDeferredSharedPointer &b) + { + return b != a; + } + + Factory *factory() const + { + return (m_factory && m_factory->isValid()) ? m_factory.data() : nullptr; + } + + void resetFactory(const Factory& newFactory) const + { + const bool wasAlreadyLoaded = !factory(); + *m_factory = newFactory; + if (wasAlreadyLoaded) + lazyLoad(); + } + +private: + friend class QDeferredWeakPointer<T>; + + void lazyLoad() const + { + if (Factory *f = factory()) { + Factory localFactory; + std::swap(localFactory, *f); // Swap before executing, to avoid recursion + localFactory.populate(m_data.template constCast<std::remove_const_t<T>>()); + } + } + + QSharedPointer<T> m_data; + QSharedPointer<Factory> m_factory; +}; + +template<typename T> +class QDeferredWeakPointer +{ +public: + using Factory = QDeferredFactory<std::remove_const_t<T>>; + + Q_NODISCARD_CTOR QDeferredWeakPointer() = default; + + Q_NODISCARD_CTOR QDeferredWeakPointer(const QDeferredSharedPointer<T> &strong) + : m_data(strong.m_data), m_factory(strong.m_factory) + { + } + + Q_NODISCARD_CTOR QDeferredWeakPointer(QWeakPointer<T> data, QWeakPointer<Factory> factory) + : m_data(data), m_factory(factory) + {} + + [[nodiscard]] operator QWeakPointer<T>() const + { + lazyLoad(); + return m_data; + } + + [[nodiscard]] operator QDeferredSharedPointer<T>() const + { + return QDeferredSharedPointer<T>(m_data.toStrongRef(), m_factory.toStrongRef()); + } + + operator QDeferredWeakPointer<const T>() const { return {m_data, m_factory}; } + + [[nodiscard]] QSharedPointer<T> toStrongRef() const + { + return QWeakPointer<T>(*this).toStrongRef(); + } + + bool isNull() const { return m_data.isNull(); } + + explicit operator bool() const noexcept { return !isNull(); } + bool operator !() const noexcept { return isNull(); } + + friend bool operator==(const QDeferredWeakPointer &a, const QDeferredWeakPointer &b) + { + return a.m_data == b.m_data; + } + + friend bool operator!=(const QDeferredWeakPointer &a, const QDeferredWeakPointer &b) + { + return !(a == b); + } + +private: + void lazyLoad() const + { + if (m_factory) { + auto factory = m_factory.toStrongRef(); + if (factory->isValid()) { + Factory localFactory; + std::swap(localFactory, *factory); // Swap before executing, to avoid recursion + localFactory.populate( + m_data.toStrongRef().template constCast<std::remove_const_t<T>>()); + } + } + } + + QWeakPointer<T> m_data; + QWeakPointer<Factory> m_factory; +}; + + +QT_END_NAMESPACE + +#endif // QDEFERREDPOINTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsannotation_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsannotation_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ff55473a9c100ba7f812c6ace349f8d082f7bd54 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsannotation_p.h @@ -0,0 +1,76 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSANNOTATION_P_H +#define QQMLJSANNOTATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <QtCore/qglobal.h> +#include <QtCore/qhash.h> + +#include <variant> + +QT_BEGIN_NAMESPACE + +struct QQQmlJSDeprecation +{ + QString reason; +}; + +struct QQmlJSAnnotation +{ + using Value = std::variant<QString, double>; + + QString name; + QHash<QString, Value> bindings; + + bool isDeprecation() const; + QQQmlJSDeprecation deprecation() const; + + friend bool operator==(const QQmlJSAnnotation &a, const QQmlJSAnnotation &b) { + return a.name == b.name && + a.bindings == b.bindings; + } + + friend bool operator!=(const QQmlJSAnnotation &a, const QQmlJSAnnotation &b) { + return !(a == b); + } + + friend size_t qHash(const QQmlJSAnnotation &annotation, size_t seed = 0) + { + QtPrivate::QHashCombine combine; + seed = combine(seed, annotation.name); + + for (auto it = annotation.bindings.constBegin(); it != annotation.bindings.constEnd(); ++it) { + size_t h = combine(seed, it.key()); + // use + to keep the result independent of the ordering of the keys + + const auto &var = it.value(); + + if (var.index() == std::variant_npos) + continue; + + if (std::holds_alternative<double>(var)) + seed += combine(h, std::get<double>(var)); + else if (std::holds_alternative<QString>(var)) + seed += combine(h, std::get<QString>(var)); + else + Q_UNREACHABLE(); + } + + return seed; + } +}; + +QT_END_NAMESPACE + +#endif // QQMLJSANNOTATION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsbasicblocks_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsbasicblocks_p.h new file mode 100644 index 0000000000000000000000000000000000000000..25dbc2877cafc3c01e456d78cd584b9c8fbcf67c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsbasicblocks_p.h @@ -0,0 +1,83 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSBASICBLOCKS_P_H +#define QQMLJSBASICBLOCKS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + + +#include <private/qflatmap_p.h> +#include <private/qqmljscompilepass_p.h> +#include <private/qqmljscompiler_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLCOMPILER_EXPORT QQmlJSBasicBlocks : public QQmlJSCompilePass +{ +public: + QQmlJSBasicBlocks(const QV4::Compiler::Context *context, + const QV4::Compiler::JSUnitGenerator *unitGenerator, + const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger) + : QQmlJSCompilePass(unitGenerator, typeResolver, logger), m_context{ context } + { + } + + ~QQmlJSBasicBlocks() = default; + + QQmlJSCompilePass::BlocksAndAnnotations run(const Function *function, + QQmlJSAotCompiler::Flags compileFlags, + bool &basicBlocksValidationFailed); + + struct BasicBlocksValidationResult { bool success = true; QString errorMessage; }; + BasicBlocksValidationResult basicBlocksValidation(); + + static BasicBlocks::iterator + basicBlockForInstruction(QFlatMap<int, BasicBlock> &container, int instructionOffset); + static BasicBlocks::const_iterator + basicBlockForInstruction(const QFlatMap<int, BasicBlock> &container, int instructionOffset); + + QList<ObjectOrArrayDefinition> objectAndArrayDefinitions() const; + +private: + QV4::Moth::ByteCodeHandler::Verdict startInstruction(QV4::Moth::Instr::Type type) override; + void endInstruction(QV4::Moth::Instr::Type type) override; + + void generate_Jump(int offset) override; + void generate_JumpTrue(int offset) override; + void generate_JumpFalse(int offset) override; + void generate_JumpNoException(int offset) override; + void generate_JumpNotUndefined(int offset) override; + void generate_IteratorNext(int value, int offset) override; + void generate_GetOptionalLookup(int index, int offset) override; + + void generate_Ret() override; + void generate_ThrowException() override; + + void generate_DefineArray(int argc, int argv) override; + void generate_DefineObjectLiteral(int internalClassId, int argc, int args) override; + void generate_Construct(int func, int argc, int argv) override; + + enum JumpMode { Unconditional, Conditional }; + void processJump(int offset, JumpMode mode); + + void dumpBasicBlocks(); + void dumpDOTGraph(); + + const QV4::Compiler::Context *m_context; + QList<ObjectOrArrayDefinition> m_objectAndArrayDefinitions; + bool m_skipUntilNextLabel = false; + bool m_hadBackJumps = false; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSBASICBLOCKS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscodegenerator_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscodegenerator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2df316d511831d8d7c0af0955fb904e38e5838af --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscodegenerator_p.h @@ -0,0 +1,386 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSCODEGENERATOR_P_H +#define QQMLJSCODEGENERATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <private/qqmljscompiler_p.h> +#include <private/qqmljstypepropagator_p.h> +#include <private/qqmljstyperesolver_p.h> + +#include <private/qv4bytecodehandler_p.h> +#include <private/qv4codegen_p.h> + +#include <QtCore/qstring.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +class Q_QMLCOMPILER_EXPORT QQmlJSCodeGenerator : public QQmlJSCompilePass +{ +public: + QQmlJSCodeGenerator(const QV4::Compiler::Context *compilerContext, + const QV4::Compiler::JSUnitGenerator *unitGenerator, + const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger, + BasicBlocks basicBlocks, InstructionAnnotations annotations); + ~QQmlJSCodeGenerator() = default; + + QQmlJSAotFunction run(const Function *function, QQmlJS::DiagnosticMessage *error, + bool basicBlocksValidationFailed); + +protected: + struct CodegenState : public State + { + QString accumulatorVariableIn; + QString accumulatorVariableOut; + }; + + // This is an RAII helper we can use to automatically convert the result of "inflexible" + // operations to the desired type. For example GetLookup can only retrieve the type of + // the property we're looking up. If we want to store a different type, we need to convert. + struct Q_QMLCOMPILER_EXPORT AccumulatorConverter + { + Q_DISABLE_COPY_MOVE(AccumulatorConverter); + AccumulatorConverter(QQmlJSCodeGenerator *generator); + ~AccumulatorConverter(); + + private: + const QQmlJSRegisterContent accumulatorOut; + const QString accumulatorVariableIn; + const QString accumulatorVariableOut; + QQmlJSCodeGenerator *generator = nullptr; + }; + + virtual QString metaObject(const QQmlJSScope::ConstPtr &objectType); + virtual QString metaType(const QQmlJSScope::ConstPtr &type); + + void generate_Ret() override; + void generate_Debug() override; + void generate_LoadConst(int index) override; + void generate_LoadZero() override; + void generate_LoadTrue() override; + void generate_LoadFalse() override; + void generate_LoadNull() override; + void generate_LoadUndefined() override; + void generate_LoadInt(int value) override; + void generate_MoveConst(int constIndex, int destTemp) override; + void generate_LoadReg(int reg) override; + void generate_StoreReg(int reg) override; + void generate_MoveReg(int srcReg, int destReg) override; + void generate_LoadImport(int index) override; + void generate_LoadLocal(int index) override; + void generate_StoreLocal(int index) override; + void generate_LoadScopedLocal(int scope, int index) override; + void generate_StoreScopedLocal(int scope, int index) override; + void generate_LoadRuntimeString(int stringId) override; + void generate_MoveRegExp(int regExpId, int destReg) override; + void generate_LoadClosure(int value) override; + void generate_LoadName(int nameIndex) override; + void generate_LoadGlobalLookup(int index) override; + void generate_LoadQmlContextPropertyLookup(int index) override; + void generate_StoreNameSloppy(int nameIndex) override; + void generate_StoreNameStrict(int name) override; + void generate_LoadElement(int base) override; + void generate_StoreElement(int base, int index) override; + void generate_LoadProperty(int nameIndex) override; + void generate_LoadOptionalProperty(int name, int offset) override; + void generate_GetLookup(int index) override; + void generate_GetOptionalLookup(int index, int offset) override; + void generate_StoreProperty(int name, int baseReg) override; + void generate_SetLookup(int index, int base) override; + void generate_LoadSuperProperty(int property) override; + void generate_StoreSuperProperty(int property) override; + void generate_Yield() override; + void generate_YieldStar() override; + void generate_Resume(int) override; + + void generate_CallValue(int name, int argc, int argv) override; + void generate_CallWithReceiver(int name, int thisObject, int argc, int argv) override; + void generate_CallProperty(int name, int base, int argc, int argv) override; + void generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv) override; + void generate_CallName(int name, int argc, int argv) override; + void generate_CallPossiblyDirectEval(int argc, int argv) override; + void generate_CallGlobalLookup(int index, int argc, int argv) override; + void generate_CallQmlContextPropertyLookup(int index, int argc, int argv) override; + void generate_CallWithSpread(int func, int thisObject, int argc, int argv) override; + void generate_TailCall(int func, int thisObject, int argc, int argv) override; + void generate_Construct(int func, int argc, int argv) override; + void generate_ConstructWithSpread(int func, int argc, int argv) override; + void generate_SetUnwindHandler(int offset) override; + void generate_UnwindDispatch() override; + void generate_UnwindToLabel(int level, int offset) override; + void generate_DeadTemporalZoneCheck(int name) override; + void generate_ThrowException() override; + void generate_GetException() override; + void generate_SetException() override; + void generate_CreateCallContext() override; + void generate_PushCatchContext(int index, int name) override; + void generate_PushWithContext() override; + void generate_PushBlockContext(int index) override; + void generate_CloneBlockContext() override; + void generate_PushScriptContext(int index) override; + void generate_PopScriptContext() override; + void generate_PopContext() override; + void generate_GetIterator(int iterator) override; + void generate_IteratorNext(int value, int offset) override; + void generate_IteratorNextForYieldStar(int iterator, int object, int offset) override; + void generate_IteratorClose() override; + void generate_DestructureRestElement() override; + void generate_DeleteProperty(int base, int index) override; + void generate_DeleteName(int name) override; + void generate_TypeofName(int name) override; + void generate_TypeofValue() override; + void generate_DeclareVar(int varName, int isDeletable) override; + void generate_DefineArray(int argc, int args) override; + void generate_DefineObjectLiteral(int internalClassId, int argc, int args) override; + void generate_CreateClass(int classIndex, int heritage, int computedNames) override; + void generate_CreateMappedArgumentsObject() override; + void generate_CreateUnmappedArgumentsObject() override; + void generate_CreateRestParameter(int argIndex) override; + void generate_ConvertThisToObject() override; + void generate_LoadSuperConstructor() override; + void generate_ToObject() override; + void generate_Jump(int offset) override; + void generate_JumpTrue(int offset) override; + void generate_JumpFalse(int offset) override; + void generate_JumpNoException(int offset) override; + void generate_JumpNotUndefined(int offset) override; + void generate_CheckException() override; + void generate_CmpEqNull() override; + void generate_CmpNeNull() override; + void generate_CmpEqInt(int lhs) override; + void generate_CmpNeInt(int lhs) override; + void generate_CmpEq(int lhs) override; + void generate_CmpNe(int lhs) override; + void generate_CmpGt(int lhs) override; + void generate_CmpGe(int lhs) override; + void generate_CmpLt(int lhs) override; + void generate_CmpLe(int lhs) override; + void generate_CmpStrictEqual(int lhs) override; + void generate_CmpStrictNotEqual(int lhs) override; + void generate_CmpIn(int lhs) override; + void generate_CmpInstanceOf(int lhs) override; + void generate_As(int lhs) override; + void generate_UNot() override; + void generate_UPlus() override; + void generate_UMinus() override; + void generate_UCompl() override; + void generate_Increment() override; + void generate_Decrement() override; + void generate_Add(int lhs) override; + void generate_BitAnd(int lhs) override; + void generate_BitOr(int lhs) override; + void generate_BitXor(int lhs) override; + void generate_UShr(int lhs) override; + void generate_Shr(int lhs) override; + void generate_Shl(int lhs) override; + void generate_BitAndConst(int rhs) override; + void generate_BitOrConst(int rhs) override; + void generate_BitXorConst(int rhs) override; + void generate_UShrConst(int rhs) override; + void generate_ShrConst(int value) override; + void generate_ShlConst(int rhs) override; + void generate_Exp(int lhs) override; + void generate_Mul(int lhs) override; + void generate_Div(int lhs) override; + void generate_Mod(int lhs) override; + void generate_Sub(int lhs) override; + void generate_InitializeBlockDeadTemporalZone(int firstReg, int count) override; + void generate_ThrowOnNullOrUndefined() override; + void generate_GetTemplateObject(int index) override; + + Verdict startInstruction(QV4::Moth::Instr::Type) override; + void endInstruction(QV4::Moth::Instr::Type) override; + + void addInclude(const QString &include) + { + Q_ASSERT(!include.isEmpty()); + m_includes.append(include); + } + + QString conversion(const QQmlJSRegisterContent &from, + const QQmlJSRegisterContent &to, + const QString &variable); + + QString conversion(const QQmlJSScope::ConstPtr &from, + const QQmlJSRegisterContent &to, + const QString &variable) + { + const QQmlJSScope::ConstPtr contained = m_typeResolver->containedType(to); + if (m_typeResolver->equals(to.storedType(), contained) + || m_typeResolver->isNumeric(to.storedType()) + || to.storedType()->isReferenceType() + || m_typeResolver->equals(from, contained)) { + // If: + // * the output is not actually wrapped at all, or + // * the output is a number (as there are no internals to a number) + // * the output is a QObject pointer, or + // * we merely wrap the value into a new container, + // we can convert by stored type. + return convertStored(from, to.storedType(), variable); + } else { + return convertContained(m_typeResolver->globalType(from), to, variable); + } + } + + QString convertStored(const QQmlJSScope::ConstPtr &from, + const QQmlJSScope::ConstPtr &to, + const QString &variable); + + QString convertContained(const QQmlJSRegisterContent &from, + const QQmlJSRegisterContent &to, + const QString &variable); + + void generateReturnError(); + void reject(const QString &thing); + + QString metaTypeFromType(const QQmlJSScope::ConstPtr &type) const; + QString metaTypeFromName(const QQmlJSScope::ConstPtr &type) const; + QString compositeMetaType(const QString &elementName) const; + QString compositeListMetaType(const QString &elementName) const; + + QString contentPointer(const QQmlJSRegisterContent &content, const QString &var); + QString contentType(const QQmlJSRegisterContent &content, const QString &var); + + void generateSetInstructionPointer(); + void generateLookup(const QString &lookup, const QString &initialization, + const QString &resultPreparation = QString()); + QString getLookupPreparation( + const QQmlJSRegisterContent &content, const QString &var, int lookup); + QString setLookupPreparation( + const QQmlJSRegisterContent &content, const QString &arg, int lookup); + void generateEnumLookup(int index); + + QString registerVariable(int index) const; + QString lookupVariable(int lookupIndex) const; + QString consumedRegisterVariable(int index) const; + QString consumedAccumulatorVariableIn() const; + + QString changedRegisterVariable() const; + QQmlJSRegisterContent registerType(int index) const; + QQmlJSRegisterContent lookupType(int lookupIndex) const; + bool shouldMoveRegister(int index) const; + + QString m_body; + CodegenState m_state; + + void resetState() { m_state = CodegenState(); } + +private: + void generateExceptionCheck(); + + void generateEqualityOperation( + const QQmlJSRegisterContent &lhsContent, const QString &lhsName, + const QString &function, bool invert) { + generateEqualityOperation( + lhsContent, m_state.accumulatorIn(), lhsName, m_state.accumulatorVariableIn, + function, invert); + } + + void generateEqualityOperation( + const QQmlJSRegisterContent &lhsContent, const QQmlJSRegisterContent &rhsContent, + const QString &lhsName, const QString &rhsName, const QString &function, bool invert); + void generateCompareOperation(int lhs, const QString &cppOperator); + void generateArithmeticOperation(int lhs, const QString &cppOperator); + void generateShiftOperation(int lhs, const QString &cppOperator); + void generateArithmeticOperation( + const QString &lhs, const QString &rhs, const QString &cppOperator); + void generateArithmeticConstOperation(int lhsConst, const QString &cppOperator); + void generateJumpCodeWithTypeConversions(int relativeOffset); + void generateUnaryOperation(const QString &cppOperator); + void generateInPlaceOperation(const QString &cppOperator); + void generateMoveOutVar(const QString &outVar); + void generateTypeLookup(int index); + void generateVariantEqualityComparison( + const QQmlJSRegisterContent &nonStorable, const QString ®isterName, bool invert); + void generateVariantEqualityComparison( + const QQmlJSRegisterContent &storableContent, const QString &typedRegisterName, + const QString &varRegisterName, bool invert); + void generateArrayInitializer(int argc, int argv); + void generateWriteBack(int registerIndex); + void rejectIfNonQObjectOut(const QString &error); + void rejectIfBadArray(); + + + QString eqIntExpression(int lhsConst); + QString argumentsList(int argc, int argv, QString *outVar); + QString castTargetName(const QQmlJSScope::ConstPtr &type) const; + + bool inlineStringMethod(const QString &name, int base, int argc, int argv); + bool inlineTranslateMethod(const QString &name, int argc, int argv); + bool inlineMathMethod(const QString &name, int argc, int argv); + bool inlineConsoleMethod(const QString &name, int argc, int argv); + bool inlineArrayMethod(const QString &name, int base, int argc, int argv); + + void generate_GetLookupHelper(int index); + + QString resolveValueTypeContentPointer( + const QQmlJSScope::ConstPtr &required, const QQmlJSRegisterContent &actual, + const QString &variable, const QString &errorMessage); + QString resolveQObjectPointer( + const QQmlJSScope::ConstPtr &required, const QQmlJSRegisterContent &actual, + const QString &variable, const QString &errorMessage); + bool generateContentPointerCheck( + const QQmlJSScope::ConstPtr &required, const QQmlJSRegisterContent &actual, + const QString &variable, const QString &errorMessage); + + // map from instruction offset to sequential label number + QHash<int, QString> m_labels; + + const QV4::Compiler::Context *m_context = nullptr; + + bool m_skipUntilNextLabel = false; + + QStringList m_includes; + + struct RegisterVariablesKey + { + QString internalName; + int registerIndex = -1; + int lookupIndex = QQmlJSRegisterContent::InvalidLookupIndex; + + private: + friend size_t qHash(const RegisterVariablesKey &key, size_t seed = 0) noexcept + { + return qHashMulti(seed, key.internalName, key.registerIndex, key.lookupIndex); + } + + friend bool operator==( + const RegisterVariablesKey &lhs, const RegisterVariablesKey &rhs) noexcept + { + return lhs.registerIndex == rhs.registerIndex + && lhs.lookupIndex == rhs.lookupIndex + && lhs.internalName == rhs.internalName; + } + + friend bool operator!=( + const RegisterVariablesKey &lhs, const RegisterVariablesKey &rhs) noexcept + { + return !(lhs == rhs); + } + }; + + struct RegisterVariablesValue + { + QString variableName; + QQmlJSScope::ConstPtr storedType; + int numTracked = 0; + }; + + QHash<RegisterVariablesKey, RegisterVariablesValue> m_registerVariables; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSCODEGENERATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompilepass_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompilepass_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7b9fb53b97eb70165308a6002028257f235044dc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompilepass_p.h @@ -0,0 +1,550 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSCOMPILEPASS_P_H +#define QQMLJSCOMPILEPASS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + + +#include <private/qqmljslogger_p.h> +#include <private/qqmljsregistercontent_p.h> +#include <private/qqmljsscope_p.h> +#include <private/qqmljstyperesolver_p.h> +#include <private/qv4bytecodehandler_p.h> +#include <private/qv4compiler_p.h> +#include <private/qflatmap_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlJSCompilePass : public QV4::Moth::ByteCodeHandler +{ + Q_DISABLE_COPY_MOVE(QQmlJSCompilePass) +public: + enum RegisterShortcuts { + InvalidRegister = -1, + Accumulator = QV4::CallData::Accumulator, + This = QV4::CallData::This, + FirstArgument = QV4::CallData::OffsetCount + }; + + using SourceLocationTable = QV4::Compiler::Context::SourceLocationTable; + + struct VirtualRegister + { + QQmlJSRegisterContent content; + bool canMove = false; + bool affectedBySideEffects = false; + + private: + friend bool operator==(const VirtualRegister &a, const VirtualRegister &b) + { + return a.content == b.content && a.canMove == b.canMove + && a.affectedBySideEffects == b.affectedBySideEffects; + } + }; + + // map from register index to expected type + using VirtualRegisters = QFlatMap<int, VirtualRegister>; + + struct BasicBlock + { + QList<int> jumpOrigins; + QList<int> readRegisters; + QList<QQmlJSScope::ConstPtr> readTypes; + int jumpTarget = -1; + bool jumpIsUnconditional = false; + bool isReturnBlock = false; + bool isThrowBlock = false; + }; + + using BasicBlocks = QFlatMap<int, BasicBlock>; + + struct InstructionAnnotation + { + // Registers explicit read as part of the instruction. + VirtualRegisters readRegisters; + + // Registers that have to be converted for future instructions after a jump. + VirtualRegisters typeConversions; + + QQmlJSRegisterContent changedRegister; + int changedRegisterIndex = InvalidRegister; + bool hasSideEffects = false; + bool isRename = false; + }; + + using InstructionAnnotations = QFlatMap<int, InstructionAnnotation>; + struct BlocksAndAnnotations + { + BasicBlocks basicBlocks; + InstructionAnnotations annotations; + }; + + struct Function + { + QQmlJSScopesById addressableScopes; + QList<QQmlJSRegisterContent> argumentTypes; + QList<QQmlJSRegisterContent> registerTypes; + QQmlJSRegisterContent returnType; + QQmlJSScope::ConstPtr qmlScope; + QByteArray code; + const SourceLocationTable *sourceLocations = nullptr; + bool isSignalHandler = false; + bool isQPropertyBinding = false; + bool isProperty = false; + bool isFullyTyped = false; + }; + + struct ObjectOrArrayDefinition + { + enum { + ArrayClassId = -1, + ArrayConstruct1ArgId = -2, + }; + + int instructionOffset = -1; + int internalClassId = ArrayClassId; + int argc = 0; + int argv = -1; + }; + + struct State + { + VirtualRegisters registers; + VirtualRegisters lookups; + + /*! + \internal + \brief The accumulatorIn is the input register of the current instruction. + + It holds a content, a type that content is acctually stored in, and an enclosing type + of the stored type called the scope. Note that passes after the original type + propagation may change the type of this register to a different type that the original + one can be coerced to. Therefore, when analyzing the same instruction in a later pass, + the type may differ from what was seen or requested ealier. See \l {readAccumulator()}. + The input type may then need to be converted to the expected type. + */ + const QQmlJSRegisterContent &accumulatorIn() const + { + auto it = registers.find(Accumulator); + Q_ASSERT(it != registers.end()); + return it.value().content; + }; + + /*! + \internal + \brief The accumulatorOut is the output register of the current instruction. + */ + const QQmlJSRegisterContent &accumulatorOut() const + { + Q_ASSERT(m_changedRegisterIndex == Accumulator); + return m_changedRegister; + }; + + void setRegister(int registerIndex, QQmlJSRegisterContent content) + { + const int lookupIndex = content.resultLookupIndex(); + if (lookupIndex != QQmlJSRegisterContent::InvalidLookupIndex) + lookups[lookupIndex] = { content, false, false }; + + m_changedRegister = std::move(content); + m_changedRegisterIndex = registerIndex; + } + + void clearChangedRegister() + { + m_changedRegisterIndex = InvalidRegister; + m_changedRegister = QQmlJSRegisterContent(); + } + + int changedRegisterIndex() const { return m_changedRegisterIndex; } + const QQmlJSRegisterContent &changedRegister() const { return m_changedRegister; } + + void addReadRegister(int registerIndex, const QQmlJSRegisterContent ®) + { + Q_ASSERT(isRename() || reg.isConversion()); + const VirtualRegister &source = registers[registerIndex]; + VirtualRegister &target = m_readRegisters[registerIndex]; + target.content = reg; + target.canMove = source.canMove; + target.affectedBySideEffects = source.affectedBySideEffects; + } + + void addReadAccumulator(const QQmlJSRegisterContent ®) + { + addReadRegister(Accumulator, reg); + } + + VirtualRegisters takeReadRegisters() const { return std::move(m_readRegisters); } + void setReadRegisters(VirtualRegisters readReagisters) + { + m_readRegisters = std::move(readReagisters); + } + + QQmlJSRegisterContent readRegister(int registerIndex) const + { + Q_ASSERT(m_readRegisters.contains(registerIndex)); + return m_readRegisters[registerIndex].content; + } + + bool canMoveReadRegister(int registerIndex) const + { + auto it = m_readRegisters.find(registerIndex); + return it != m_readRegisters.end() && it->second.canMove; + } + + bool isRegisterAffectedBySideEffects(int registerIndex) const + { + auto it = m_readRegisters.find(registerIndex); + return it != m_readRegisters.end() && it->second.affectedBySideEffects; + } + + /*! + \internal + \brief The readAccumulator is the register content expected by the current instruction. + + It may differ from the actual input type of the accumulatorIn register and usage of the + value may require a conversion. + */ + QQmlJSRegisterContent readAccumulator() const + { + return readRegister(Accumulator); + } + + bool readsRegister(int registerIndex) const + { + return m_readRegisters.contains(registerIndex); + } + + bool hasSideEffects() const { return m_hasSideEffects; } + + void markSideEffects(bool hasSideEffects) { m_hasSideEffects = hasSideEffects; } + void applySideEffects(bool hasSideEffects) + { + if (!hasSideEffects) + return; + + for (auto it = registers.begin(), end = registers.end(); it != end; ++it) + it.value().affectedBySideEffects = true; + + for (auto it = lookups.begin(), end = lookups.end(); it != end; ++it) + it.value().affectedBySideEffects = true; + } + + void setHasSideEffects(bool hasSideEffects) { + markSideEffects(hasSideEffects); + applySideEffects(hasSideEffects); + } + + bool isRename() const { return m_isRename; } + void setIsRename(bool isRename) { m_isRename = isRename; } + + int renameSourceRegisterIndex() const + { + Q_ASSERT(m_isRename); + Q_ASSERT(m_readRegisters.size() == 1); + return m_readRegisters.begin().key(); + } + + private: + VirtualRegisters m_readRegisters; + QQmlJSRegisterContent m_changedRegister; + int m_changedRegisterIndex = InvalidRegister; + bool m_hasSideEffects = false; + bool m_isRename = false; + }; + + QQmlJSCompilePass(const QV4::Compiler::JSUnitGenerator *jsUnitGenerator, + const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger, + BasicBlocks basicBlocks = {}, InstructionAnnotations annotations = {}) + : m_jsUnitGenerator(jsUnitGenerator) + , m_typeResolver(typeResolver) + , m_logger(logger) + , m_basicBlocks(basicBlocks) + , m_annotations(annotations) + {} + +protected: + const QV4::Compiler::JSUnitGenerator *m_jsUnitGenerator = nullptr; + const QQmlJSTypeResolver *m_typeResolver = nullptr; + QQmlJSLogger *m_logger = nullptr; + + const Function *m_function = nullptr; + BasicBlocks m_basicBlocks; + InstructionAnnotations m_annotations; + QQmlJS::DiagnosticMessage *m_error = nullptr; + + int firstRegisterIndex() const + { + return FirstArgument + m_function->argumentTypes.size(); + } + + bool isArgument(int registerIndex) const + { + return registerIndex >= FirstArgument && registerIndex < firstRegisterIndex(); + } + + QQmlJSRegisterContent argumentType(int registerIndex) const + { + Q_ASSERT(isArgument(registerIndex)); + return m_function->argumentTypes[registerIndex - FirstArgument]; + } + + + State initialState(const Function *function) + { + State state; + for (int i = 0, end = function->argumentTypes.size(); i < end; ++i) { + state.registers[FirstArgument + i].content = function->argumentTypes.at(i); + Q_ASSERT(state.registers[FirstArgument + i].content.isValid()); + } + for (int i = 0, end = function->registerTypes.size(); i != end; ++i) + state.registers[firstRegisterIndex() + i].content = function->registerTypes[i]; + return state; + } + + State nextStateFromAnnotations( + const State &oldState, const InstructionAnnotations &annotations) + { + State newState; + + const auto instruction = annotations.find(currentInstructionOffset()); + newState.registers = oldState.registers; + newState.lookups = oldState.lookups; + + // Usually the initial accumulator type is the output of the previous instruction, but ... + if (oldState.changedRegisterIndex() != InvalidRegister) { + newState.registers[oldState.changedRegisterIndex()].affectedBySideEffects = false; + newState.registers[oldState.changedRegisterIndex()].content + = oldState.changedRegister(); + } + + // Side effects are applied at the end of an instruction: An instruction with side + // effects can still read its registers before the side effects happen. + newState.applySideEffects(oldState.hasSideEffects()); + + if (instruction == annotations.constEnd()) + return newState; + + newState.markSideEffects(instruction->second.hasSideEffects); + newState.setReadRegisters(instruction->second.readRegisters); + newState.setIsRename(instruction->second.isRename); + + for (auto it = instruction->second.typeConversions.begin(), + end = instruction->second.typeConversions.end(); it != end; ++it) { + Q_ASSERT(it.key() != InvalidRegister); + newState.registers[it.key()] = it.value(); + } + + if (instruction->second.changedRegisterIndex != InvalidRegister) { + newState.setRegister(instruction->second.changedRegisterIndex, + instruction->second.changedRegister); + } + + return newState; + } + + QQmlJS::SourceLocation sourceLocation(int instructionOffset) const + { + Q_ASSERT(m_function); + Q_ASSERT(m_function->sourceLocations); + const auto &entries = m_function->sourceLocations->entries; + auto item = std::lower_bound(entries.begin(), entries.end(), instructionOffset, + [](auto entry, uint offset) { return entry.offset < offset; }); + + Q_ASSERT(item != entries.end()); + return item->location; + } + + QQmlJS::SourceLocation currentSourceLocation() const + { + return sourceLocation(currentInstructionOffset()); + } + + void setError(const QString &message, int instructionOffset) + { + Q_ASSERT(m_error); + if (m_error->isValid()) + return; + m_error->message = message; + m_error->loc = sourceLocation(instructionOffset); + } + + void setError(const QString &message) + { + setError(message, currentInstructionOffset()); + } + + static bool instructionManipulatesContext(QV4::Moth::Instr::Type type) + { + using Type = QV4::Moth::Instr::Type; + switch (type) { + case Type::PopContext: + case Type::PopScriptContext: + case Type::CreateCallContext: + case Type::CreateCallContext_Wide: + case Type::PushCatchContext: + case Type::PushCatchContext_Wide: + case Type::PushWithContext: + case Type::PushWithContext_Wide: + case Type::PushBlockContext: + case Type::PushBlockContext_Wide: + case Type::CloneBlockContext: + case Type::CloneBlockContext_Wide: + case Type::PushScriptContext: + case Type::PushScriptContext_Wide: + return true; + default: + break; + } + return false; + } + + // Stub out all the methods so that passes can choose to only implement part of them. + void generate_Add(int) override {} + void generate_As(int) override {} + void generate_BitAnd(int) override {} + void generate_BitAndConst(int) override {} + void generate_BitOr(int) override {} + void generate_BitOrConst(int) override {} + void generate_BitXor(int) override {} + void generate_BitXorConst(int) override {} + void generate_CallGlobalLookup(int, int, int) override {} + void generate_CallName(int, int, int) override {} + void generate_CallPossiblyDirectEval(int, int) override {} + void generate_CallProperty(int, int, int, int) override {} + void generate_CallPropertyLookup(int, int, int, int) override {} + void generate_CallQmlContextPropertyLookup(int, int, int) override {} + void generate_CallValue(int, int, int) override {} + void generate_CallWithReceiver(int, int, int, int) override {} + void generate_CallWithSpread(int, int, int, int) override {} + void generate_CheckException() override {} + void generate_CloneBlockContext() override {} + void generate_CmpEq(int) override {} + void generate_CmpEqInt(int) override {} + void generate_CmpEqNull() override {} + void generate_CmpGe(int) override {} + void generate_CmpGt(int) override {} + void generate_CmpIn(int) override {} + void generate_CmpInstanceOf(int) override {} + void generate_CmpLe(int) override {} + void generate_CmpLt(int) override {} + void generate_CmpNe(int) override {} + void generate_CmpNeInt(int) override {} + void generate_CmpNeNull() override {} + void generate_CmpStrictEqual(int) override {} + void generate_CmpStrictNotEqual(int) override {} + void generate_Construct(int, int, int) override {} + void generate_ConstructWithSpread(int, int, int) override {} + void generate_ConvertThisToObject() override {} + void generate_CreateCallContext() override {} + void generate_CreateClass(int, int, int) override {} + void generate_CreateMappedArgumentsObject() override {} + void generate_CreateRestParameter(int) override {} + void generate_CreateUnmappedArgumentsObject() override {} + void generate_DeadTemporalZoneCheck(int) override {} + void generate_Debug() override {} + void generate_DeclareVar(int, int) override {} + void generate_Decrement() override {} + void generate_DefineArray(int, int) override {} + void generate_DefineObjectLiteral(int, int, int) override {} + void generate_DeleteName(int) override {} + void generate_DeleteProperty(int, int) override {} + void generate_DestructureRestElement() override {} + void generate_Div(int) override {} + void generate_Exp(int) override {} + void generate_GetException() override {} + void generate_GetIterator(int) override {} + void generate_GetLookup(int) override {} + void generate_GetOptionalLookup(int, int) override {} + void generate_GetTemplateObject(int) override {} + void generate_Increment() override {} + void generate_InitializeBlockDeadTemporalZone(int, int) override {} + void generate_IteratorClose() override {} + void generate_IteratorNext(int, int) override {} + void generate_IteratorNextForYieldStar(int, int, int) override {} + void generate_Jump(int) override {} + void generate_JumpFalse(int) override {} + void generate_JumpNoException(int) override {} + void generate_JumpNotUndefined(int) override {} + void generate_JumpTrue(int) override {} + void generate_LoadClosure(int) override {} + void generate_LoadConst(int) override {} + void generate_LoadElement(int) override {} + void generate_LoadFalse() override {} + void generate_LoadGlobalLookup(int) override {} + void generate_LoadImport(int) override {} + void generate_LoadInt(int) override {} + void generate_LoadLocal(int) override {} + void generate_LoadName(int) override {} + void generate_LoadNull() override {} + void generate_LoadOptionalProperty(int, int) override {} + void generate_LoadProperty(int) override {} + void generate_LoadQmlContextPropertyLookup(int) override {} + void generate_LoadReg(int) override {} + void generate_LoadRuntimeString(int) override {} + void generate_LoadScopedLocal(int, int) override {} + void generate_LoadSuperConstructor() override {} + void generate_LoadSuperProperty(int) override {} + void generate_LoadTrue() override {} + void generate_LoadUndefined() override {} + void generate_LoadZero() override {} + void generate_Mod(int) override {} + void generate_MoveConst(int, int) override {} + void generate_MoveReg(int, int) override {} + void generate_MoveRegExp(int, int) override {} + void generate_Mul(int) override {} + void generate_PopContext() override {} + void generate_PopScriptContext() override {} + void generate_PushBlockContext(int) override {} + void generate_PushCatchContext(int, int) override {} + void generate_PushScriptContext(int) override {} + void generate_PushWithContext() override {} + void generate_Resume(int) override {} + void generate_Ret() override {} + void generate_SetException() override {} + void generate_SetLookup(int, int) override {} + void generate_SetUnwindHandler(int) override {} + void generate_Shl(int) override {} + void generate_ShlConst(int) override {} + void generate_Shr(int) override {} + void generate_ShrConst(int) override {} + void generate_StoreElement(int, int) override {} + void generate_StoreLocal(int) override {} + void generate_StoreNameSloppy(int) override {} + void generate_StoreNameStrict(int) override {} + void generate_StoreProperty(int, int) override {} + void generate_StoreReg(int) override {} + void generate_StoreScopedLocal(int, int) override {} + void generate_StoreSuperProperty(int) override {} + void generate_Sub(int) override {} + void generate_TailCall(int, int, int, int) override {} + void generate_ThrowException() override {} + void generate_ThrowOnNullOrUndefined() override {} + void generate_ToObject() override {} + void generate_TypeofName(int) override {} + void generate_TypeofValue() override {} + void generate_UCompl() override {} + void generate_UMinus() override {} + void generate_UNot() override {} + void generate_UPlus() override {} + void generate_UShr(int) override {} + void generate_UShrConst(int) override {} + void generate_UnwindDispatch() override {} + void generate_UnwindToLabel(int, int) override {} + void generate_Yield() override {} + void generate_YieldStar() override {} +}; + +QT_END_NAMESPACE + +#endif // QQMLJSCOMPILEPASS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompiler_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompiler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c7024e9db9e818a358dd03a5512cdd8f164ffdcb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompiler_p.h @@ -0,0 +1,144 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSCOMPILER_P_H +#define QQMLJSCOMPILER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include <QtCore/qstring.h> +#include <QtCore/qlist.h> +#include <QtCore/qloggingcategory.h> + +#include <private/qqmlirbuilder_p.h> +#include <private/qqmljscompilepass_p.h> +#include <private/qqmljscompilerstats_p.h> +#include <private/qqmljsdiagnosticmessage_p.h> +#include <private/qqmljsimporter_p.h> +#include <private/qqmljslogger_p.h> +#include <private/qqmljstyperesolver_p.h> +#include <private/qv4compileddata_p.h> + +#include <functional> + +QT_BEGIN_NAMESPACE + +Q_QMLCOMPILER_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcAotCompiler); + +struct Q_QMLCOMPILER_EXPORT QQmlJSCompileError +{ + QString message; + void print(); + QQmlJSCompileError augment(const QString &contextErrorMessage) const; + void appendDiagnostics(const QString &inputFileName, + const QList<QQmlJS::DiagnosticMessage> &diagnostics); + void appendDiagnostic(const QString &inputFileName, + const QQmlJS::DiagnosticMessage &diagnostic); +}; + +struct Q_QMLCOMPILER_EXPORT QQmlJSAotFunction +{ + QStringList includes; + QString code; + QString signature; + int numArguments = 0; +}; + +class Q_QMLCOMPILER_EXPORT QQmlJSAotCompiler +{ +public: + enum Flag { + NoFlags = 0x0, + ValidateBasicBlocks = 0x1, + }; + Q_DECLARE_FLAGS(Flags, Flag) + + QQmlJSAotCompiler(QQmlJSImporter *importer, const QString &resourcePath, + const QStringList &qmldirFiles, QQmlJSLogger *logger); + + virtual ~QQmlJSAotCompiler() = default; + + virtual void setDocument(const QmlIR::JSCodeGen *codegen, const QmlIR::Document *document); + virtual void setScope(const QmlIR::Object *object, const QmlIR::Object *scope); + virtual std::variant<QQmlJSAotFunction, QQmlJS::DiagnosticMessage> compileBinding( + const QV4::Compiler::Context *context, const QmlIR::Binding &irBinding, + QQmlJS::AST::Node *astNode); + virtual std::variant<QQmlJSAotFunction, QQmlJS::DiagnosticMessage> compileFunction( + const QV4::Compiler::Context *context, const QString &name, QQmlJS::AST::Node *astNode); + + virtual QQmlJSAotFunction globalCode() const; + + Flags m_flags; + +protected: + virtual QQmlJS::DiagnosticMessage diagnose( + const QString &message, QtMsgType type, const QQmlJS::SourceLocation &location) const; + + QQmlJSTypeResolver m_typeResolver; + + const QString m_resourcePath; + const QStringList m_qmldirFiles; + + const QmlIR::Document *m_document = nullptr; + const QmlIR::Object *m_currentObject = nullptr; + const QmlIR::Object *m_currentScope = nullptr; + const QV4::Compiler::JSUnitGenerator *m_unitGenerator = nullptr; + + QQmlJSImporter *m_importer = nullptr; + QQmlJSLogger *m_logger = nullptr; + +private: + QQmlJSAotFunction doCompile(const QV4::Compiler::Context *context, + QQmlJSCompilePass::Function *function, + QQmlJS::DiagnosticMessage *error); + QQmlJSAotFunction doCompileAndRecordAotStats(const QV4::Compiler::Context *context, + QQmlJSCompilePass::Function *function, + QQmlJS::DiagnosticMessage *error, + const QString &name, + QQmlJS::SourceLocation location); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlJSAotCompiler::Flags); + +using QQmlJSAotFunctionMap = QMap<int, QQmlJSAotFunction>; +using QQmlJSSaveFunction + = std::function<bool(const QV4::CompiledData::SaveableUnitPointer &, + const QQmlJSAotFunctionMap &, QString *)>; + +bool Q_QMLCOMPILER_EXPORT qCompileQmlFile(const QString &inputFileName, + QQmlJSSaveFunction saveFunction, + QQmlJSAotCompiler *aotCompiler, QQmlJSCompileError *error, + bool storeSourceLocation = false, + QV4::Compiler::CodegenWarningInterface *interface = + QV4::Compiler::defaultCodegenWarningInterface(), + const QString *fileContents = nullptr); +bool Q_QMLCOMPILER_EXPORT qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName, + QQmlJSSaveFunction saveFunction, + QQmlJSAotCompiler *aotCompiler, QQmlJSCompileError *error, + bool storeSourceLocation = false, + QV4::Compiler::CodegenWarningInterface *interface = + QV4::Compiler::defaultCodegenWarningInterface(), + const QString *fileContents = nullptr); +bool Q_QMLCOMPILER_EXPORT qCompileJSFile(const QString &inputFileName, const QString &inputFileUrl, + QQmlJSSaveFunction saveFunction, + QQmlJSCompileError *error); + +bool Q_QMLCOMPILER_EXPORT qSaveQmlJSUnitAsCpp(const QString &inputFileName, + const QString &outputFileName, + const QV4::CompiledData::SaveableUnitPointer &unit, + const QQmlJSAotFunctionMap &aotFunctions, + QString *errorString); + +QT_END_NAMESPACE + +#endif // QQMLJSCOMPILER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompilerstats_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompilerstats_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0da000da1cd5736ffac5b94a0834470d632be05c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompilerstats_p.h @@ -0,0 +1,95 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSCOMPILERSTATS_P_H +#define QQMLJSCOMPILERSTATS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include <QHash> +#include <QJsonDocument> + +#include <private/qqmljsdiagnosticmessage_p.h> +#include <private/qqmljssourcelocation_p.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { + +struct Q_QMLCOMPILER_EXPORT AotStatsEntry +{ + std::chrono::microseconds codegenDuration; + QString functionName; + QString errorMessage; + int line = 0; + int column = 0; + bool codegenSuccessful = true; + + bool operator<(const AotStatsEntry &) const; +}; + +class Q_QMLCOMPILER_EXPORT AotStats +{ + friend class QQmlJSAotCompilerStats; + +public: + const QHash<QString, QHash<QString, QList<AotStatsEntry>>> &entries() const + { + return m_entries; + } + + void registerFile(const QString &moduleId, const QString &filepath); + void addEntry(const QString &moduleId, const QString &filepath, const AotStatsEntry &entry); + void insert(const AotStats &other); + + static std::optional<QStringList> readAllLines(const QString &path); + bool saveToDisk(const QString &filepath) const; + + static std::optional<AotStats> parseAotstatsFile(const QString &aotstatsPath); + static std::optional<AotStats> aggregateAotstatsList(const QString &aotstatsListPath); + + static AotStats fromJsonDocument(const QJsonDocument &); + QJsonDocument toJsonDocument() const; + +private: + // module Id -> filename -> stats m_entries + QHash<QString, QHash<QString, QList<AotStatsEntry>>> m_entries; +}; + +class Q_QMLCOMPILER_EXPORT QQmlJSAotCompilerStats +{ +public: + static AotStats *instance() { return s_instance.get(); } + + static bool recordAotStats() { return s_recordAotStats; } + static void setRecordAotStats(bool recordAotStats) { s_recordAotStats = recordAotStats; } + + static const QString &moduleId() { return s_moduleId; } + static void setModuleId(QString moduleId) { s_moduleId = moduleId; } + + static void registerFile(const QString &filepath); + static void addEntry(const QString &filepath, const QQmlJS::AotStatsEntry &entry); + +private: + static std::unique_ptr<AotStats> s_instance; + static QString s_moduleId; + static bool s_recordAotStats; +}; + +} // namespace QQmlJS + +QT_END_NAMESPACE + +#endif // QQMLJSCOMPILERSTATS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompilerstatsreporter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompilerstatsreporter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d73642b94b7caecff5db127c07177d4c5b8630d7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscompilerstatsreporter_p.h @@ -0,0 +1,60 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSCOMPILERSTATSREPORTER_P_H +#define QQMLJSCOMPILERSTATSREPORTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <QTextStream> + +#include <qtqmlcompilerexports.h> + +#include <private/qqmljscompilerstats_p.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { + +class Q_QMLCOMPILER_EXPORT AotStatsReporter +{ +public: + AotStatsReporter(const QQmlJS::AotStats &stats, const QStringList &emptyModules, + const QStringList &onlyBytecodeModules); + + QString format() const; + +private: + void formatDetailedStats(QTextStream &) const; + void formatSummary(QTextStream &) const; + QString formatSuccessRate(int codegens, int successes) const; + + const AotStats &m_aotstats; + const QStringList &m_emptyModules; + const QStringList &m_onlyBytecodeModules; + + struct Counters + { + int successes = 0; + int codegens = 0; + }; + + Counters m_totalCounters; + QHash<QString, Counters> m_moduleCounters; + QHash<QString, QHash<QString, Counters>> m_fileCounters; + QList<std::chrono::microseconds> m_successDurations; +}; + +} // namespace QQmlJS + +QT_END_NAMESPACE + +#endif // QQMLJSCOMPILERSTATSREPORTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscontextualtypes_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscontextualtypes_p.h new file mode 100644 index 0000000000000000000000000000000000000000..75ea56698b0f932bdaa4b16dfa77917a130d6f7b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljscontextualtypes_p.h @@ -0,0 +1,114 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSCONTEXTUALTYPES_P_H +#define QQMLJSCONTEXTUALTYPES_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <QtCore/qstring.h> +#include <QtCore/qhash.h> +#include <private/qqmljsscope_p.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +/*! \internal + * Maps type names to types and the compile context of the types. The context can be + * INTERNAL (for c++ and synthetic jsrootgen types) or QML (for qml types). + */ +struct ContextualTypes +{ + enum CompileContext { INTERNAL, QML }; + + ContextualTypes( + CompileContext context, + const QHash<QString, ImportedScope<QQmlJSScope::ConstPtr>> types, + const QQmlJSScope::ConstPtr &arrayType) + : m_types(types) + , m_context(context) + , m_arrayType(arrayType) + {} + + CompileContext context() const { return m_context; } + QQmlJSScope::ConstPtr arrayType() const { return m_arrayType; } + + bool hasType(const QString &name) const { return m_types.contains(name); } + + ImportedScope<QQmlJSScope::ConstPtr> type(const QString &name) const { return m_types[name]; } + QString name(const QQmlJSScope::ConstPtr &type) const { return m_names[type]; } + + void setType(const QString &name, const ImportedScope<QQmlJSScope::ConstPtr> &type) + { + if (!name.startsWith(u'$')) + m_names.insert(type.scope, name); + m_types.insert(name, type); + } + void clearType(const QString &name) + { + auto &scope = m_types[name].scope; + auto it = m_names.constFind(scope); + while (it != m_names.constEnd() && it.key() == scope) + it = m_names.erase(it); + scope = QQmlJSScope::ConstPtr(); + } + + bool isNullType(const QString &name) const + { + const auto it = m_types.constFind(name); + return it != m_types.constEnd() && it->scope.isNull(); + } + + void addTypes(ContextualTypes &&types) + { + Q_ASSERT(types.m_context == m_context); + insertNames(types); + m_types.insert(std::move(types.m_types)); + } + + void addTypes(const ContextualTypes &types) + { + Q_ASSERT(types.m_context == m_context); + insertNames(types); + m_types.insert(types.m_types); + } + + const QHash<QString, ImportedScope<QQmlJSScope::ConstPtr>> &types() const { return m_types; } + const auto &names() const { return m_names; } + + void clearTypes() + { + m_names.clear(); + m_types.clear(); + } + +private: + void insertNames(const ContextualTypes &types) { + for (auto it = types.m_types.constBegin(), end = types.m_types.constEnd(); + it != end; ++it) { + const QString &name = it.key(); + if (!name.startsWith(u'$')) + m_names.insert(it->scope, name); + } + } + + QHash<QString, ImportedScope<QQmlJSScope::ConstPtr>> m_types; + QMultiHash<QQmlJSScope::ConstPtr, QString> m_names; + CompileContext m_context; + + // For resolving sequence types + QQmlJSScope::ConstPtr m_arrayType; +}; +} + +QT_END_NAMESPACE + +#endif // QQMLJSCONTEXTUALTYPES_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsfunctioninitializer_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsfunctioninitializer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4e41c43241ce28589b356b06933234ecccde1cc1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsfunctioninitializer_p.h @@ -0,0 +1,56 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSFUNCTIONINITIALIAZER_P_H +#define QQMLJSFUNCTIONINITIALIAZER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <private/qqmljscompilepass_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLCOMPILER_EXPORT QQmlJSFunctionInitializer +{ + Q_DISABLE_COPY_MOVE(QQmlJSFunctionInitializer) +public: + QQmlJSFunctionInitializer( + const QQmlJSTypeResolver *typeResolver, + const QV4::CompiledData::Location &objectLocation, + const QV4::CompiledData::Location &scopeLocation) + : m_typeResolver(typeResolver) + , m_scopeType(typeResolver->scopeForLocation(scopeLocation)) + , m_objectType(typeResolver->scopeForLocation(objectLocation)) + {} + + QQmlJSCompilePass::Function run( + const QV4::Compiler::Context *context, + const QString &propertyName, QQmlJS::AST::Node *astNode, + const QmlIR::Binding &irBinding, + QQmlJS::DiagnosticMessage *error); + QQmlJSCompilePass::Function run( + const QV4::Compiler::Context *context, + const QString &functionName, QQmlJS::AST::Node *astNode, + QQmlJS::DiagnosticMessage *error); + +private: + void populateSignature( + const QV4::Compiler::Context *context, QQmlJS::AST::FunctionExpression *ast, + QQmlJSCompilePass::Function *function, QQmlJS::DiagnosticMessage *error); + + const QQmlJSTypeResolver *m_typeResolver = nullptr; + const QQmlJSScope::ConstPtr m_scopeType; + const QQmlJSScope::ConstPtr m_objectType; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSFUNCTIONINITIALIZER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsimporter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsimporter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..12676a52da4558c8fd20256998539aa22f24c9a4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsimporter_p.h @@ -0,0 +1,283 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSIMPORTER_P_H +#define QQMLJSIMPORTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include "qqmljscontextualtypes_p.h" +#include "qqmljsscope_p.h" +#include "qqmljsresourcefilemapper_p.h" +#include <QtQml/private/qqmldirparser_p.h> +#include <QtQml/private/qqmljsast_p.h> + +#include <memory> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +class Import +{ +public: + Import() = default; + Import(QString prefix, QString name, QTypeRevision version, bool isFile, bool isDependency); + + bool isValid() const; + + QString prefix() const { return m_prefix; } + QString name() const { return m_name; } + QTypeRevision version() const { return m_version; } + bool isFile() const { return m_isFile; } + bool isDependency() const { return m_isDependency; } + +private: + QString m_prefix; + QString m_name; + QTypeRevision m_version; + bool m_isFile = false; + bool m_isDependency = false; + + friend inline size_t qHash(const Import &key, size_t seed = 0) noexcept + { + return qHashMulti(seed, key.m_prefix, key.m_name, key.m_version, + key.m_isFile, key.m_isDependency); + } + + friend inline bool operator==(const Import &a, const Import &b) + { + return a.m_prefix == b.m_prefix && a.m_name == b.m_name && a.m_version == b.m_version + && a.m_isFile == b.m_isFile && a.m_isDependency == b.m_isDependency; + } +}; +} + +enum QQmlJSImporterFlag { + UseOptionalImports = 0x1, + PreferQmlFilesFromSourceFolder = 0x2 +}; +Q_DECLARE_FLAGS(QQmlJSImporterFlags, QQmlJSImporterFlag) + +class QQmlJSImportVisitor; +class QQmlJSLogger; +class Q_QMLCOMPILER_EXPORT QQmlJSImporter +{ +public: + struct ImportedTypes { + ImportedTypes(QQmlJS::ContextualTypes &&types, QList<QQmlJS::DiagnosticMessage> &&warnings) + : m_types(std::move(types)), m_warnings(std::move(warnings)) + {} + + ImportedTypes(const ImportedTypes &) = default; + ImportedTypes(ImportedTypes &&) = default; + ImportedTypes &operator=(const ImportedTypes &) = default; + ImportedTypes &operator=(ImportedTypes &&) = default; + ~ImportedTypes() = default; + + void clear() + { + m_types.clearTypes(); + m_warnings.clear(); + } + + const QQmlJS::ContextualTypes &contextualTypes() const { return m_types; } + const QList<QQmlJS::DiagnosticMessage> &warnings() const { return m_warnings; }; + + bool isEmpty() const { return m_types.types().isEmpty(); } + + bool hasType(const QString &name) const { return m_types.hasType(name); } + QQmlJS::ImportedScope<QQmlJSScope::ConstPtr> type(const QString &name) const + { + return m_types.type(name); + } + QString name(const QQmlJSScope::ConstPtr &type) const { return m_types.name(type); } + void setType(const QString &name, const QQmlJS::ImportedScope<QQmlJSScope::ConstPtr> &type) + { + m_types.setType(name, type); + } + bool isNullType(const QString &name) const { return m_types.isNullType(name); } + const QHash<QString, QQmlJS::ImportedScope<QQmlJSScope::ConstPtr>> &types() const + { + return m_types.types(); + } + + void add(ImportedTypes &&other) + { + m_types.addTypes(std::move(other.m_types)); + m_warnings.append(std::move(other.m_warnings)); + } + + void addWarnings(QList<QQmlJS::DiagnosticMessage> &&warnings) + { + m_warnings.append(std::move(warnings)); + } + + private: + QQmlJS::ContextualTypes m_types; + QList<QQmlJS::DiagnosticMessage> m_warnings; + }; + + QQmlJSImporter(const QStringList &importPaths, QQmlJSResourceFileMapper *mapper, + QQmlJSImporterFlags flags = QQmlJSImporterFlags{}); + + QQmlJSResourceFileMapper *resourceFileMapper() const { return m_mapper; } + void setResourceFileMapper(QQmlJSResourceFileMapper *mapper) { m_mapper = mapper; } + + QQmlJSResourceFileMapper *metaDataMapper() const { return m_metaDataMapper; } + void setMetaDataMapper(QQmlJSResourceFileMapper *mapper) { m_metaDataMapper = mapper; } + + ImportedTypes importBuiltins(); + QList<QQmlJS::DiagnosticMessage> importQmldirs(const QStringList &qmltypesFiles); + + QQmlJSScope::Ptr importFile(const QString &file); + ImportedTypes importDirectory(const QString &directory, const QString &prefix = QString()); + + // ### qmltc needs this. once re-written, we no longer need to expose this + QHash<QString, QQmlJSScope::Ptr> importedFiles() const { return m_importedFiles; } + + ImportedTypes importModule(const QString &module, const QString &prefix = QString(), + QTypeRevision version = QTypeRevision(), + QStringList *staticModuleList = nullptr); + + ImportedTypes builtinInternalNames(); + + QList<QQmlJS::DiagnosticMessage> takeGlobalWarnings() + { + const auto result = std::move(m_globalWarnings); + m_globalWarnings.clear(); + return result; + } + + QStringList importPaths() const { return m_importPaths; } + void setImportPaths(const QStringList &importPaths); + + void clearCache(); + + QQmlJSScope::ConstPtr jsGlobalObject() const; + + struct ImportVisitorPrerequisites + { + ImportVisitorPrerequisites(QQmlJSScope::Ptr target, QQmlJSLogger *logger, + const QString &implicitImportDirectory = {}, + const QStringList &qmldirFiles = {}) + : m_target(target), + m_logger(logger), + m_implicitImportDirectory(implicitImportDirectory), + m_qmldirFiles(qmldirFiles) + { + Q_ASSERT(target && logger); + } + + QQmlJSScope::Ptr m_target; + QQmlJSLogger *m_logger; + QString m_implicitImportDirectory; + QStringList m_qmldirFiles; + }; + void runImportVisitor(QQmlJS::AST::Node *rootNode, + const ImportVisitorPrerequisites &prerequisites); + + /*! + \internal + When a qml file gets lazily loaded, it will be lexed and parsed and finally be constructed + via an ImportVisitor. By default, this is done via the QQmlJSImportVisitor, but can also be done + via other import visitors like QmltcVisitor, which is used by qmltc to compile a QML file, or + QQmlDomAstCreatorWithQQmlJSScope, which is used to construct the Dom of lazily loaded QML files. + */ + using ImportVisitor = std::function<void(QQmlJS::AST::Node *rootNode, QQmlJSImporter *self, + const ImportVisitorPrerequisites &prerequisites)>; + + void setImportVisitor(ImportVisitor visitor) { m_importVisitor = visitor; } + +private: + friend class QDeferredFactory<QQmlJSScope>; + + struct AvailableTypes + { + AvailableTypes(QQmlJS::ContextualTypes builtins) + : cppNames(std::move(builtins)) + , qmlNames(QQmlJS::ContextualTypes::QML, {}, cppNames.arrayType()) + { + } + + // C++ names used in qmltypes files for non-composite types + QQmlJS::ContextualTypes cppNames; + + // Names the importing component sees, including any prefixes + QQmlJS::ContextualTypes qmlNames; + + // Static modules included here + QStringList staticModules; + + // Warnings produced when importing + QList<QQmlJS::DiagnosticMessage> warnings; + + // Whether a system module has been imported + bool hasSystemModule = false; + }; + + struct Import { + QString name; + bool isStaticModule = false; + bool isSystemModule = false; + + QList<QQmlJSExportedScope> objects; + QHash<QString, QQmlJSExportedScope> scripts; + QList<QQmlDirParser::Import> imports; + QList<QQmlDirParser::Import> dependencies; + + // Warnings produced when importing + QList<QQmlJS::DiagnosticMessage> warnings; + }; + + AvailableTypes builtinImportHelper(); + bool importHelper(const QString &module, AvailableTypes *types, + const QString &prefix = QString(), QTypeRevision version = QTypeRevision(), + bool isDependency = false, bool isFile = false); + void processImport( + const QQmlJS::Import &importDescription, const Import &import, AvailableTypes *types); + void importDependencies( + const Import &import, AvailableTypes *types, const QString &prefix = QString(), + QTypeRevision version = QTypeRevision(), bool isDependency = false); + QQmlDirParser createQmldirParserForFile(const QString &filename, Import *import); + void readQmltypes(const QString &filename, Import *result); + Import readQmldir(const QString &dirname); + Import readDirectory(const QString &directory); + + QQmlJSScope::Ptr localFile2ScopeTree(const QString &filePath); + static void setQualifiedNamesOn(const Import &import); + + QStringList m_importPaths; + + QHash<QPair<QString, QTypeRevision>, QString> m_seenImports; + QHash<QQmlJS::Import, QSharedPointer<AvailableTypes>> m_cachedImportTypes; + QHash<QString, Import> m_seenQmldirFiles; + + QHash<QString, QQmlJSScope::Ptr> m_importedFiles; + QList<QQmlJS::DiagnosticMessage> m_globalWarnings; + std::optional<AvailableTypes> m_builtins; + + QQmlJSResourceFileMapper *m_mapper = nullptr; + QQmlJSResourceFileMapper *m_metaDataMapper = nullptr; + QQmlJSImporterFlags m_flags; + bool useOptionalImports() const { return m_flags.testFlag(UseOptionalImports); }; + bool preferQmlFilesFromSourceFolder() const + { + return m_flags.testFlag(PreferQmlFilesFromSourceFolder); + }; + + ImportVisitor m_importVisitor; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSIMPORTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsimportvisitor_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsimportvisitor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1eb10bc2c89e20279321e7676ec6d460d5632359 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsimportvisitor_p.h @@ -0,0 +1,380 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSIMPORTEDMEMBERSVISITOR_P_H +#define QQMLJSIMPORTEDMEMBERSVISITOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <private/qqmljscontextualtypes_p.h> +#include <qtqmlcompilerexports.h> + +#include "qqmljsannotation_p.h" +#include "qqmljsimporter_p.h" +#include "qqmljslogger_p.h" +#include "qqmljsscope_p.h" +#include "qqmljsscopesbyid_p.h" + +#include <QtCore/qvariant.h> +#include <QtCore/qstack.h> + +#include <private/qqmljsast_p.h> +#include <private/qqmljsdiagnosticmessage_p.h> +#include <private/qv4compileddata_p.h> + +#include <functional> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS::Dom { +class QQmlDomAstCreatorWithQQmlJSScope; +} + +struct QQmlJSResourceFileMapper; +class Q_QMLCOMPILER_EXPORT QQmlJSImportVisitor : public QQmlJS::AST::Visitor +{ +public: + QQmlJSImportVisitor(); + QQmlJSImportVisitor(const QQmlJSScope::Ptr &target, + QQmlJSImporter *importer, QQmlJSLogger *logger, + const QString &implicitImportDirectory, + const QStringList &qmldirFiles = QStringList()); + ~QQmlJSImportVisitor(); + + using QQmlJS::AST::Visitor::endVisit; + using QQmlJS::AST::Visitor::postVisit; + using QQmlJS::AST::Visitor::preVisit; + using QQmlJS::AST::Visitor::visit; + + QQmlJSScope::Ptr result() const { return m_exportedRootScope; } + + const QQmlJSLogger *logger() const { return m_logger; } + QQmlJSLogger *logger() { return m_logger; } + + QQmlJSImporter::ImportedTypes imports() const { return m_rootScopeImports; } + QQmlJSScopesById addressableScopes() const { return m_scopesById; } + QHash<QQmlJS::SourceLocation, QQmlJSMetaSignalHandler> signalHandlers() const + { + return m_signalHandlers; + } + QSet<QQmlJSScope::ConstPtr> literalScopesToCheck() const { return m_literalScopesToCheck; } + QList<QQmlJSScope::ConstPtr> qmlTypes() const { return m_qmlTypes; } + QHash<QV4::CompiledData::Location, QQmlJSScope::ConstPtr> scopesBylocation() const + { + return m_scopesByIrLocation; + } + + static QString implicitImportDirectory( + const QString &localFile, QQmlJSResourceFileMapper *mapper); + + // ### should this be restricted? + QQmlJSImporter *importer() { return m_importer; } + const QQmlJSImporter *importer() const { return m_importer; } + + struct UnfinishedBinding + { + QQmlJSScope::Ptr owner; + std::function<QQmlJSMetaPropertyBinding()> create; + QQmlJSScope::BindingTargetSpecifier specifier = QQmlJSScope::SimplePropertyTarget; + }; + + QStringList seenModuleQualifiers() const { return m_seenModuleQualifiers; } + +protected: + // Linter warnings, we might want to move this at some point + bool visit(QQmlJS::AST::StringLiteral *) override; + + bool visit(QQmlJS::AST::ExpressionStatement *ast) override; + void endVisit(QQmlJS::AST::ExpressionStatement *ast) override; + + bool visit(QQmlJS::AST::UiProgram *) override; + void endVisit(QQmlJS::AST::UiProgram *) override; + bool visit(QQmlJS::AST::UiObjectDefinition *) override; + void endVisit(QQmlJS::AST::UiObjectDefinition *) override; + bool visit(QQmlJS::AST::UiInlineComponent *) override; + void endVisit(QQmlJS::AST::UiInlineComponent *) override; + bool visit(QQmlJS::AST::UiPublicMember *) override; + void endVisit(QQmlJS::AST::UiPublicMember *) override; + bool visit(QQmlJS::AST::UiRequired *required) override; + bool visit(QQmlJS::AST::UiScriptBinding *) override; + void endVisit(QQmlJS::AST::UiScriptBinding *) override; + bool visit(QQmlJS::AST::UiArrayBinding *) override; + void endVisit(QQmlJS::AST::UiArrayBinding *) override; + bool visit(QQmlJS::AST::UiEnumDeclaration *uied) override; + bool visit(QQmlJS::AST::FunctionExpression *fexpr) override; + void endVisit(QQmlJS::AST::FunctionExpression *) override; + bool visit(QQmlJS::AST::UiSourceElement *) override; + bool visit(QQmlJS::AST::FunctionDeclaration *fdecl) override; + void endVisit(QQmlJS::AST::FunctionDeclaration *) override; + bool visit(QQmlJS::AST::ClassExpression *ast) override; + void endVisit(QQmlJS::AST::ClassExpression *) override; + bool visit(QQmlJS::AST::UiImport *import) override; + bool visit(QQmlJS::AST::UiPragma *pragma) override; + bool visit(QQmlJS::AST::ClassDeclaration *ast) override; + void endVisit(QQmlJS::AST::ClassDeclaration *ast) override; + bool visit(QQmlJS::AST::ForStatement *ast) override; + void endVisit(QQmlJS::AST::ForStatement *ast) override; + bool visit(QQmlJS::AST::ForEachStatement *ast) override; + void endVisit(QQmlJS::AST::ForEachStatement *ast) override; + bool visit(QQmlJS::AST::Block *ast) override; + void endVisit(QQmlJS::AST::Block *ast) override; + bool visit(QQmlJS::AST::CaseBlock *ast) override; + void endVisit(QQmlJS::AST::CaseBlock *ast) override; + bool visit(QQmlJS::AST::Catch *ast) override; + void endVisit(QQmlJS::AST::Catch *ast) override; + bool visit(QQmlJS::AST::WithStatement *withStatement) override; + void endVisit(QQmlJS::AST::WithStatement *ast) override; + + bool visit(QQmlJS::AST::VariableDeclarationList *vdl) override; + bool visit(QQmlJS::AST::FormalParameterList *fpl) override; + + bool visit(QQmlJS::AST::UiObjectBinding *uiob) override; + void endVisit(QQmlJS::AST::UiObjectBinding *uiob) override; + + bool visit(QQmlJS::AST::ExportDeclaration *exp) override; + void endVisit(QQmlJS::AST::ExportDeclaration *exp) override; + + bool visit(QQmlJS::AST::ESModule *module) override; + void endVisit(QQmlJS::AST::ESModule *module) override; + + bool visit(QQmlJS::AST::Program *program) override; + void endVisit(QQmlJS::AST::Program *program) override; + + void endVisit(QQmlJS::AST::FieldMemberExpression *) override; + bool visit(QQmlJS::AST::IdentifierExpression *idexp) override; + + bool visit(QQmlJS::AST::PatternElement *) override; + + void throwRecursionDepthError() override; + + QString m_implicitImportDirectory; + QStringList m_qmldirFiles; + QQmlJSScope::Ptr m_currentScope; + const QQmlJSScope::Ptr m_exportedRootScope; + QQmlJSImporter *m_importer = nullptr; + QQmlJSLogger *m_logger = nullptr; + + using RootDocumentNameType = QQmlJSScope::RootDocumentNameType; + using InlineComponentNameType = QQmlJSScope::InlineComponentNameType; + using InlineComponentOrDocumentRootName = QQmlJSScope::RootDocumentNameType; + QQmlJSScope::InlineComponentOrDocumentRootName m_currentRootName = + QQmlJSScope::RootDocumentNameType(); + bool m_nextIsInlineComponent = false; + bool m_rootIsSingleton = false; + QQmlJSScope::Ptr m_savedBindingOuterScope; + QQmlJSScope::ConstPtr m_globalScope; + QQmlJSScopesById m_scopesById; + QQmlJSImporter::ImportedTypes m_rootScopeImports; + QList<QQmlJSScope::ConstPtr> m_qmlTypes; + + // We need to record the locations as IR locations because those contain less data. + // This way we can look up objects by IR location later. + QHash<QV4::CompiledData::Location, QQmlJSScope::ConstPtr> m_scopesByIrLocation; + + // Maps all qmlNames to the source location of their import + QMultiHash<QString, QQmlJS::SourceLocation> m_importTypeLocationMap; + // Maps all static modules to the source location of their import + QMultiHash<QString, QQmlJS::SourceLocation> m_importStaticModuleLocationMap; + // Contains all import source locations (could be extracted from above but that is expensive) + QSet<QQmlJS::SourceLocation> m_importLocations; + // A set of all types that have been used during type resolution + QSet<QString> m_usedTypes; + + QList<UnfinishedBinding> m_bindings; + + // stores JS functions and Script bindings per scope (only the name). mimics + // the content of QmlIR::Object::functionsAndExpressions + QHash<QQmlJSScope::ConstPtr, QList<QString>> m_functionsAndExpressions; + + struct FunctionOrExpressionIdentifier + { + QQmlJSScope::ConstPtr scope; + QString name; + friend bool operator==(const FunctionOrExpressionIdentifier &x, + const FunctionOrExpressionIdentifier &y) + { + return x.scope == y.scope && x.name == y.name; + } + friend bool operator!=(const FunctionOrExpressionIdentifier &x, + const FunctionOrExpressionIdentifier &y) + { + return !(x == y); + } + friend size_t qHash(const FunctionOrExpressionIdentifier &x, size_t seed = 0) + { + return qHashMulti(seed, x.scope, x.name); + } + }; + + // tells whether last-processed UiScriptBinding is truly a script binding + bool m_thisScriptBindingIsJavaScript = false; + QStack<FunctionOrExpressionIdentifier> m_functionStack; + // stores the number of functions inside each function + QHash<FunctionOrExpressionIdentifier, int> m_innerFunctions; + QQmlJSMetaMethod::RelativeFunctionIndex + addFunctionOrExpression(const QQmlJSScope::ConstPtr &scope, const QString &name); + void forgetFunctionExpression(const QString &name); + int synthesizeCompilationUnitRuntimeFunctionIndices(const QQmlJSScope::Ptr &scope, + int count) const; + void populateRuntimeFunctionIndicesForDocument() const; + + void enterEnvironment(QQmlJSScope::ScopeType type, const QString &name, + const QQmlJS::SourceLocation &location); + // Finds an existing scope before attempting to create a new one. Returns \c + // true if the scope already exists and \c false if the new scope is created + bool enterEnvironmentNonUnique(QQmlJSScope::ScopeType type, const QString &name, + const QQmlJS::SourceLocation &location); + void leaveEnvironment(); + + // A set of types that have not been resolved but have been used during the + // AST traversal + QSet<QQmlJSScope::ConstPtr> m_unresolvedTypes; + template<typename ErrorHandler> + bool isTypeResolved(const QQmlJSScope::ConstPtr &type, ErrorHandler handle) + { + if (type->isFullyResolved()) + return true; + + // Note: ignore duplicates, but only after we are certain that the type + // is still unresolved + if (m_unresolvedTypes.contains(type)) + return false; + + m_unresolvedTypes.insert(type); + + handle(type); + return false; + } + bool isTypeResolved(const QQmlJSScope::ConstPtr &type); + + QVector<QQmlJSAnnotation> parseAnnotations(QQmlJS::AST::UiAnnotationList *list); + void setAllBindings(); + void addDefaultProperties(); + void processDefaultProperties(); + void processPropertyBindings(); + void checkRequiredProperties(); + void processPropertyTypes(); + void processMethodTypes(); + void processPropertyBindingObjects(); + void flushPendingSignalParameters(); + + QQmlJSScope::ConstPtr scopeById(const QString &id, const QQmlJSScope::ConstPtr ¤t); + + void breakInheritanceCycles(const QQmlJSScope::Ptr &scope); + void checkDeprecation(const QQmlJSScope::ConstPtr &scope); + void checkGroupedAndAttachedScopes(QQmlJSScope::ConstPtr scope); + bool rootScopeIsValid() const { return m_exportedRootScope->sourceLocation().isValid(); } + + enum class BindingExpressionParseResult { Invalid, Script, Literal, Translation }; + BindingExpressionParseResult parseBindingExpression(const QString &name, + const QQmlJS::AST::Statement *statement); + bool isImportPrefix(QString prefix) const; + + // Used to temporarily store annotations for functions and generators wrapped in UiSourceElements + QVector<QQmlJSAnnotation> m_pendingMethodAnnotations; + + struct PendingPropertyType + { + QQmlJSScope::Ptr scope; + QString name; + QQmlJS::SourceLocation location; + }; + + struct PendingMethodTypeAnnotations + { + QQmlJSScope::Ptr scope; + QString methodName; + // This keeps type annotations' locations in order (parameters then return type). + // If an annotation is not present, it is represented by an invalid source location. + QVarLengthArray<QQmlJS::SourceLocation, 3> locations; + }; + + struct PendingPropertyObjectBinding + { + QQmlJSScope::Ptr scope; + QQmlJSScope::Ptr childScope; + QString name; + QQmlJS::SourceLocation location; + bool onToken; + }; + + struct RequiredProperty + { + QQmlJSScope::Ptr scope; + QString name; + QQmlJS::SourceLocation location; + }; + + /*! + Utility wrapper that adds visibility scope to the data. + + This wrapper becomes useful for binding processing where we need to know + both the property (or signal handler) owner and the scope in which the + binding is executed (the "visibility" scope). + + As visibility scope (and data) does not typically have sufficient + information about a proper source location of that data, the location + also has to be provided to simplify the error reporting. + */ + template<typename T> + struct WithVisibilityScope + { + QQmlJSScope::Ptr visibilityScope; + QQmlJS::SourceLocation dataLocation; + T data; + }; + + QHash<QQmlJSScope::Ptr, QVector<QQmlJSScope::Ptr>> m_pendingDefaultProperties; + QVector<PendingPropertyType> m_pendingPropertyTypes; + QVector<PendingMethodTypeAnnotations> m_pendingMethodTypeAnnotations; + QVector<PendingPropertyObjectBinding> m_pendingPropertyObjectBindings; + QVector<RequiredProperty> m_requiredProperties; + QVector<QQmlJSScope::Ptr> m_objectBindingScopes; + QVector<QQmlJSScope::Ptr> m_objectDefinitionScopes; + + QHash<QQmlJSScope::Ptr, QVector<WithVisibilityScope<QString>>> m_propertyBindings; + + QHash<QQmlJS::SourceLocation, QQmlJSMetaSignalHandler> m_signalHandlers; + QSet<QQmlJSScope::ConstPtr> m_literalScopesToCheck; + QQmlJS::SourceLocation m_pendingSignalHandler; + QStringList m_seenModuleQualifiers; + +private: + void checkSignal( + const QQmlJSScope::ConstPtr &signalScope, const QQmlJS::SourceLocation &location, + const QString &handlerName, const QStringList &handlerParameters); + void importBaseModules(); + void resolveAliases(); + void resolveGroupProperties(); + void handleIdDeclaration(QQmlJS::AST::UiScriptBinding *scriptBinding); + + void visitFunctionExpressionHelper(QQmlJS::AST::FunctionExpression *fexpr); + void processImportWarnings( + const QString &what, const QList<QQmlJS::DiagnosticMessage> &warnings, + const QQmlJS::SourceLocation &srcLocation = QQmlJS::SourceLocation()); + void addImportWithLocation(const QString &name, const QQmlJS::SourceLocation &loc); + void populateCurrentScope(QQmlJSScope::ScopeType type, const QString &name, + const QQmlJS::SourceLocation &location); + void enterRootScope(QQmlJSScope::ScopeType type, const QString &name, + const QQmlJS::SourceLocation &location); + + QList<QQmlJS::DiagnosticMessage> importFromHost( + const QString &path, const QString &prefix, const QQmlJS::SourceLocation &location); + QList<QQmlJS::DiagnosticMessage> importFromQrc( + const QString &path, const QString &prefix, const QQmlJS::SourceLocation &location); + +public: + friend class QQmlJS::Dom::QQmlDomAstCreatorWithQQmlJSScope; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSIMPORTEDMEMBERSVISITOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljslinter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljslinter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f3de9c5b7fd26f0ed7bae46b5ef99392b3c75691 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljslinter_p.h @@ -0,0 +1,148 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QMLJSLINTER_P_H +#define QMLJSLINTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include <QtQmlCompiler/private/qqmljslogger_p.h> +#include <QtQmlCompiler/private/qqmljsimporter_p.h> + +#include <QtQml/private/qqmljssourcelocation_p.h> + +#include <QtCore/qjsonarray.h> +#include <QtCore/qstring.h> +#include <QtCore/qmap.h> +#include <QtCore/qscopedpointer.h> + +#include <vector> +#include <optional> + +QT_BEGIN_NAMESPACE + +class QPluginLoader; +struct QStaticPlugin; + +namespace QQmlSA { +class LintPlugin; +} + +class Q_QMLCOMPILER_EXPORT QQmlJSLinter +{ +public: + QQmlJSLinter(const QStringList &importPaths, + const QStringList &pluginPaths = { QQmlJSLinter::defaultPluginPath() }, + bool useAbsolutePath = false); + + enum LintResult { FailedToOpen, FailedToParse, HasWarnings, LintSuccess }; + enum FixResult { NothingToFix, FixError, FixSuccess }; + + class Q_QMLCOMPILER_EXPORT Plugin + { + Q_DISABLE_COPY(Plugin) + public: + Plugin() = default; + Plugin(Plugin &&plugin) noexcept; + +#if QT_CONFIG(library) + Plugin(QString path); +#endif + Plugin(const QStaticPlugin &plugin); + ~Plugin(); + + const QString &name() const { return m_name; } + const QString &description() const { return m_description; } + const QString &version() const { return m_version; } + const QString &author() const { return m_author; } + const QList<QQmlJS::LoggerCategory> categories() const + { + return m_categories; + } + bool isBuiltin() const { return m_isBuiltin; } + bool isValid() const { return m_isValid; } + bool isInternal() const + { + return m_isInternal; + } + + bool isEnabled() const + { + return m_isEnabled; + } + void setEnabled(bool isEnabled) + { + m_isEnabled = isEnabled; + } + + private: + friend class QQmlJSLinter; + + bool parseMetaData(const QJsonObject &metaData, QString pluginName); + + QString m_name; + QString m_description; + QString m_version; + QString m_author; + + QList<QQmlJS::LoggerCategory> m_categories; + QQmlSA::LintPlugin *m_instance; + std::unique_ptr<QPluginLoader> m_loader; + bool m_isBuiltin = false; + bool m_isInternal = + false; // Internal plugins are those developed and maintained inside the Qt project + bool m_isValid = false; + bool m_isEnabled = true; + }; + + static std::vector<Plugin> loadPlugins(QStringList paths); + static QString defaultPluginPath(); + + LintResult lintFile(const QString &filename, const QString *fileContents, const bool silent, + QJsonArray *json, const QStringList &qmlImportPaths, + const QStringList &qmldirFiles, const QStringList &resourceFiles, + const QList<QQmlJS::LoggerCategory> &categories); + + LintResult lintModule(const QString &uri, const bool silent, QJsonArray *json, + const QStringList &qmlImportPaths, const QStringList &resourceFiles); + + FixResult applyFixes(QString *fixedCode, bool silent); + + const QQmlJSLogger *logger() const { return m_logger.get(); } + + std::vector<Plugin> &plugins() + { + return m_plugins; + } + void setPlugins(std::vector<Plugin> plugins) { m_plugins = std::move(plugins); } + + void setPluginsEnabled(bool enablePlugins) { m_enablePlugins = enablePlugins; } + bool pluginsEnabled() const { return m_enablePlugins; } + + void clearCache() { m_importer.clearCache(); } + +private: + void parseComments(QQmlJSLogger *logger, const QList<QQmlJS::SourceLocation> &comments); + void processMessages(QJsonArray &warnings); + + bool m_useAbsolutePath; + bool m_enablePlugins; + QQmlJSImporter m_importer; + QScopedPointer<QQmlJSLogger> m_logger; + QString m_fileContents; + std::vector<Plugin> m_plugins; +}; + +QT_END_NAMESPACE + +#endif // QMLJSLINTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljslintercodegen_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljslintercodegen_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e7c3fb1d497cf3a74648fa78efd67ac679a851ba --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljslintercodegen_p.h @@ -0,0 +1,72 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSLINTERCODEGEN_P_H +#define QQMLJSLINTERCODEGEN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <QString> +#include <QFile> +#include <QList> + +#include <variant> +#include <memory> +#include <private/qqmljsdiagnosticmessage_p.h> +#include <private/qqmlirbuilder_p.h> +#include <private/qqmljsscope_p.h> +#include <private/qqmljscompiler_p.h> + +#include <QtQmlCompiler/private/qqmljstyperesolver_p.h> +#include <QtQmlCompiler/private/qqmljslogger_p.h> +#include <QtQmlCompiler/private/qqmljscompilepass_p.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlSA { +class PassManager; +}; + +class QQmlJSLinterCodegen : public QQmlJSAotCompiler +{ +public: + QQmlJSLinterCodegen(QQmlJSImporter *importer, const QString &fileName, + const QStringList &qmldirFiles, QQmlJSLogger *logger); + + void setDocument(const QmlIR::JSCodeGen *codegen, const QmlIR::Document *document) override; + std::variant<QQmlJSAotFunction, QQmlJS::DiagnosticMessage> + compileBinding(const QV4::Compiler::Context *context, const QmlIR::Binding &irBinding, + QQmlJS::AST::Node *astNode) override; + std::variant<QQmlJSAotFunction, QQmlJS::DiagnosticMessage> + compileFunction(const QV4::Compiler::Context *context, const QString &name, + QQmlJS::AST::Node *astNode) override; + + void setTypeResolver(QQmlJSTypeResolver typeResolver) + { + m_typeResolver = std::move(typeResolver); + } + + QQmlJSTypeResolver *typeResolver() { return &m_typeResolver; } + + void setPassManager(QQmlSA::PassManager *passManager); + + QQmlSA::PassManager *passManager() { return m_passManager; } + +private: + QQmlSA::PassManager *m_passManager = nullptr; + + bool analyzeFunction(const QV4::Compiler::Context *context, + QQmlJSCompilePass::Function *function, QQmlJS::DiagnosticMessage *error); +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsliteralbindingcheck_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsliteralbindingcheck_p.h new file mode 100644 index 0000000000000000000000000000000000000000..daabba948e38d1a4d264f44aea0e6569e41cbe30 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsliteralbindingcheck_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSLITERALBINDINGCHECK_P_H +#define QQMLJSLITERALBINDINGCHECK_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <QtCore/qglobal.h> +#include <QtQmlCompiler/qqmlsa.h> + +#include <qtqmlcompilerexports.h> +#include "qqmljsvaluetypefromstringcheck_p.h" + +QT_BEGIN_NAMESPACE + +class QQmlJSImportVisitor; +class QQmlJSTypeResolver; + +class Q_QMLCOMPILER_EXPORT LiteralBindingCheckBase : public QQmlSA::PropertyPass +{ +public: + using QQmlSA::PropertyPass::PropertyPass; + + void onBinding(const QQmlSA::Element &element, const QString &propertyName, + const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope, + const QQmlSA::Element &value) override; + +protected: + virtual QQmlJSStructuredTypeError check(const QString &typeName, const QString &value) const = 0; + + QQmlSA::Property getProperty(const QString &propertyName, const QQmlSA::Binding &binding, + const QQmlSA::Element &bindingScope) const; +}; + +class Q_QMLCOMPILER_EXPORT QQmlJSLiteralBindingCheck: public LiteralBindingCheckBase +{ +public: + QQmlJSLiteralBindingCheck(QQmlSA::PassManager *manager); + + void onBinding(const QQmlSA::Element &element, const QString &propertyName, + const QQmlSA::Binding &binding, const QQmlSA::Element &bindingScope, + const QQmlSA::Element &value) override; + +private: + QQmlJSTypeResolver *m_resolver; + +protected: + QQmlJSStructuredTypeError check(const QString &typeName, const QString &value) const override; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSLITERALBINDINGCHECK_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsloadergenerator_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsloadergenerator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fe24a383df321b855c29b258b01ad3d29391ef53 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsloadergenerator_p.h @@ -0,0 +1,33 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSLOADERGENERATOR_P_H +#define QQMLJSLOADERGENERATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include <QtCore/qstring.h> +#include <QtCore/qlist.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +bool Q_QMLCOMPILER_EXPORT qQmlJSGenerateLoader(const QStringList &compiledFiles, + const QString &outputFileName, + const QStringList &resourceFileMappings, + QString *errorString); +QString Q_QMLCOMPILER_EXPORT qQmlJSSymbolNamespaceForPath(const QString &relativePath); + +QT_END_NAMESPACE + +#endif // QQMLJSLOADERGENERATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljslogger_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljslogger_p.h new file mode 100644 index 0000000000000000000000000000000000000000..47d433dab9e584137c0567f4d71f519b39478ee0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljslogger_p.h @@ -0,0 +1,237 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSLOGGER_P_H +#define QQMLJSLOGGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qtqmlcompilerexports.h> + +#include "qcoloroutput_p.h" +#include "qqmljsloggingutils_p.h" + +#include <private/qqmljsdiagnosticmessage_p.h> + +#include <QtCore/qhash.h> +#include <QtCore/qmap.h> +#include <QtCore/qstring.h> +#include <QtCore/qlist.h> +#include <QtCore/qset.h> +#include <QtCore/QLoggingCategory> + +#include <optional> + +QT_BEGIN_NAMESPACE + +/*! + \internal + Used to print the line containing the location of a certain error + */ +class Q_QMLCOMPILER_EXPORT IssueLocationWithContext +{ +public: + /*! + \internal + \param code: The whole text of a translation unit + \param location: The location where an error occurred. + */ + IssueLocationWithContext(QStringView code, const QQmlJS::SourceLocation &location) { + quint32 before = qMax(0, code.lastIndexOf(QLatin1Char('\n'), location.offset)); + + if (before != 0 && before < location.offset) + before++; + + m_beforeText = code.mid(before, location.offset - before); + m_issueText = code.mid(location.offset, location.length); + int after = code.indexOf(QLatin1Char('\n'), location.offset + location.length); + m_afterText = code.mid(location.offset + location.length, + after - (location.offset+location.length)); + } + + // returns start of the line till first character of location + QStringView beforeText() const { return m_beforeText; } + // returns the text at location + QStringView issueText() const { return m_issueText; } + // returns any text after location until the end of the line is reached + QStringView afterText() const { return m_afterText; } + +private: + QStringView m_beforeText; + QStringView m_issueText; + QStringView m_afterText; +}; + +class Q_QMLCOMPILER_EXPORT QQmlJSFixSuggestion +{ +public: + QQmlJSFixSuggestion() = default; + QQmlJSFixSuggestion(const QString &fixDescription, const QQmlJS::SourceLocation &location, + const QString &replacement = QString()); + + QString fixDescription() const { return m_fixDescription; } + QQmlJS::SourceLocation location() const { return m_location; } + QString replacement() const { return m_replacement; } + + void setFilename(const QString &filename) { m_filename = filename; } + QString filename() const { return m_filename; } + + void setHint(const QString &hint) { m_hint = hint; } + QString hint() const { return m_hint; } + + void setAutoApplicable(bool autoApply = true) { m_autoApplicable = autoApply; } + bool isAutoApplicable() const { return m_autoApplicable; } + + bool operator==(const QQmlJSFixSuggestion &) const; + bool operator!=(const QQmlJSFixSuggestion &) const; + +private: + QQmlJS::SourceLocation m_location; + QString m_fixDescription; + QString m_replacement; + QString m_filename; + QString m_hint; + bool m_autoApplicable = false; +}; + +struct Message : public QQmlJS::DiagnosticMessage +{ + // This doesn't need to be an owning-reference since the string is expected to outlive any + // Message object by virtue of coming from a LoggerWarningId. + QAnyStringView id; + std::optional<QQmlJSFixSuggestion> fixSuggestion; +}; + +class Q_QMLCOMPILER_EXPORT QQmlJSLogger +{ + Q_DISABLE_COPY_MOVE(QQmlJSLogger) +public: + QList<QQmlJS::LoggerCategory> categories() const; + static const QList<QQmlJS::LoggerCategory> &defaultCategories(); + + void registerCategory(const QQmlJS::LoggerCategory &category); + + QQmlJSLogger(); + ~QQmlJSLogger() = default; + + bool hasWarnings() const { return !m_warnings.isEmpty(); } + bool hasErrors() const { return !m_errors.isEmpty(); } + + const QList<Message> &infos() const { return m_infos; } + const QList<Message> &warnings() const { return m_warnings; } + const QList<Message> &errors() const { return m_errors; } + + QtMsgType categoryLevel(QQmlJS::LoggerWarningId id) const + { + return m_categoryLevels[id.name().toString()]; + } + void setCategoryLevel(QQmlJS::LoggerWarningId id, QtMsgType level) + { + m_categoryLevels[id.name().toString()] = level; + m_categoryChanged[id.name().toString()] = true; + } + + bool isCategoryIgnored(QQmlJS::LoggerWarningId id) const + { + return m_categoryIgnored[id.name().toString()]; + } + void setCategoryIgnored(QQmlJS::LoggerWarningId id, bool error) + { + m_categoryIgnored[id.name().toString()] = error; + m_categoryChanged[id.name().toString()] = true; + } + + bool isCategoryFatal(QQmlJS::LoggerWarningId id) const + { + return m_categoryFatal[id.name().toString()]; + } + void setCategoryFatal(QQmlJS::LoggerWarningId id, bool error) + { + m_categoryFatal[id.name().toString()] = error; + m_categoryChanged[id.name().toString()] = true; + } + + bool wasCategoryChanged(QQmlJS::LoggerWarningId id) const + { + return m_categoryChanged[id.name().toString()]; + } + + /*! \internal + + Logs \a message with severity deduced from \a category. Prefer using + this function in most cases. + + \sa setCategoryLevel + */ + void log(const QString &message, QQmlJS::LoggerWarningId id, + const QQmlJS::SourceLocation &srcLocation, bool showContext = true, + bool showFileName = true, const std::optional<QQmlJSFixSuggestion> &suggestion = {}, + const QString overrideFileName = QString()) + { + log(message, id, srcLocation, m_categoryLevels[id.name().toString()], showContext, + showFileName, suggestion, overrideFileName); + } + + void processMessages(const QList<QQmlJS::DiagnosticMessage> &messages, + const QQmlJS::LoggerWarningId id); + + void ignoreWarnings(uint32_t line, const QSet<QString> &categories) + { + m_ignoredWarnings[line] = categories; + } + + void setSilent(bool silent) { m_output.setSilent(silent); } + bool isSilent() const { return m_output.isSilent(); } + + void setCode(const QString &code) { m_code = code; } + QString code() const { return m_code; } + + void setFilePath(const QString &filePath) { m_filePath = filePath; } + QString filePath() const { return m_filePath; } + +private: + QMap<QString, QQmlJS::LoggerCategory> m_categories; + + void printContext(const QString &overrideFileName, const QQmlJS::SourceLocation &location); + void printFix(const QQmlJSFixSuggestion &fix); + + void log(const QString &message, QQmlJS::LoggerWarningId id, + const QQmlJS::SourceLocation &srcLocation, QtMsgType type, bool showContext, + bool showFileName, const std::optional<QQmlJSFixSuggestion> &suggestion, + const QString overrideFileName); + + QString m_filePath; + QString m_code; + + QColorOutput m_output; + + QHash<QString, QtMsgType> m_categoryLevels; + QHash<QString, bool> m_categoryIgnored; + + // If true, triggers qFatal on documents with "pragma Strict" + // TODO: Works only for qmlCompiler category so far. + QHash<QString, bool> m_categoryFatal; + + QHash<QString, bool> m_categoryChanged; + + QList<Message> m_infos; + QList<Message> m_warnings; + QList<Message> m_errors; + QHash<uint32_t, QSet<QString>> m_ignoredWarnings; + + // the compiler needs private log() function at the moment + friend class QQmlJSAotCompiler; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSLOGGER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsloggingutils_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsloggingutils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4b06b7b1d657530fb56733da27f7e09b44335eb2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsloggingutils_p.h @@ -0,0 +1,119 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSLOGGINGUTILS_P_H +#define QQMLJSLOGGINGUTILS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> +#include <qtqmlcompilerexports.h> + +#include "qqmljsloggingutils.h" + +QT_BEGIN_NAMESPACE + +class QQmlToolingSettings; +class QCommandLineParser; + +namespace QQmlJS { + +using LoggerWarningId = QQmlSA::LoggerWarningId; + +class LoggerCategoryPrivate; + +class Q_QMLCOMPILER_EXPORT LoggerCategory +{ + Q_DECLARE_PRIVATE(LoggerCategory) + +public: + LoggerCategory(); + LoggerCategory(QString name, QString settingsName, QString description, QtMsgType level, + bool ignored = false, bool isDefault = false); + LoggerCategory(const LoggerCategory &); + LoggerCategory(LoggerCategory &&) noexcept; + LoggerCategory &operator=(const LoggerCategory &); + LoggerCategory &operator=(LoggerCategory &&) noexcept; + ~LoggerCategory(); + + QString name() const; + QString settingsName() const; + QString description() const; + QtMsgType level() const; + bool isIgnored() const; + bool isDefault() const; + + LoggerWarningId id() const; + + void setLevel(QtMsgType); + void setIgnored(bool); + +private: + std::unique_ptr<QQmlJS::LoggerCategoryPrivate> d_ptr; +}; + +class LoggerCategoryPrivate +{ + friend class QT_PREPEND_NAMESPACE(QQmlJS::LoggerCategory); + +public: + LoggerWarningId id() const { return LoggerWarningId(m_name); } + + void setLevel(QtMsgType); + void setIgnored(bool); + + QString name() const; + QString settingsName() const; + QString description() const; + QtMsgType level() const; + bool isIgnored() const; + bool isDefault() const; + bool hasChanged() const; + + static LoggerCategoryPrivate *get(LoggerCategory *); + + friend bool operator==(const LoggerCategoryPrivate &lhs, const LoggerCategoryPrivate &rhs) + { + return operatorEqualsImpl(lhs, rhs); + } + friend bool operator!=(const LoggerCategoryPrivate &lhs, const LoggerCategoryPrivate &rhs) + { + return !operatorEqualsImpl(lhs, rhs); + } + + bool operator==(const LoggerWarningId warningId) const { return warningId.name() == m_name; } + +private: + static bool operatorEqualsImpl(const LoggerCategoryPrivate &, const LoggerCategoryPrivate &); + + QString m_name; + QString m_settingsName; + QString m_description; + QtMsgType m_level = QtDebugMsg; + bool m_ignored = false; + bool m_isDefault = false; // Whether or not the category can be disabled + bool m_changed = false; +}; + +namespace LoggingUtils { +Q_QMLCOMPILER_EXPORT void updateLogLevels(QList<LoggerCategory> &categories, + const QQmlToolingSettings &settings, + QCommandLineParser *parser); + +Q_QMLCOMPILER_EXPORT QString levelToString(const QQmlJS::LoggerCategory &category); +} // namespace LoggingUtils + +} // namespace QQmlJS + +QT_END_NAMESPACE + +#endif // QQMLJSLOGGINGUTILS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsmetatypes_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsmetatypes_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b5cc2bf6f5a6a2fc82f16adab076b729437c389c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsmetatypes_p.h @@ -0,0 +1,891 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSMETATYPES_P_H +#define QQMLJSMETATYPES_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include <QtCore/qstring.h> +#include <QtCore/qstringlist.h> +#include <QtCore/qsharedpointer.h> +#include <QtCore/qvariant.h> +#include <QtCore/qhash.h> + +#include <QtQml/private/qqmljssourcelocation_p.h> +#include <QtQml/private/qqmltranslation_p.h> + +#include "qqmlsaconstants.h" +#include "qqmlsa.h" +#include "qqmljsannotation_p.h" + +// MetaMethod and MetaProperty have both type names and actual QQmlJSScope types. +// When parsing the information from the relevant QML or qmltypes files, we only +// see the names and don't have a complete picture of the types, yet. In a second +// pass we typically fill in the types. The types may have multiple exported names +// and the the name property of MetaProperty and MetaMethod still carries some +// significance regarding which name was chosen to refer to the type. In a third +// pass we may further specify the type if the context provides additional information. +// The parent of an Item, for example, is typically not just a QtObject, but rather +// some other Item with custom properties. + +QT_BEGIN_NAMESPACE + +enum ScriptBindingValueType : unsigned int { + ScriptValue_Unknown, + ScriptValue_Undefined // property int p: undefined +}; + +using QQmlJSMetaMethodType = QQmlSA::MethodType; + +class QQmlJSTypeResolver; +class QQmlJSScope; +class QQmlJSMetaEnum +{ + QStringList m_keys; + QList<int> m_values; // empty if values unknown. + QString m_name; + QString m_alias; + QString m_typeName; + QSharedPointer<const QQmlJSScope> m_type; + bool m_isFlag = false; + bool m_isScoped = false; + bool m_isQml = false; + +public: + QQmlJSMetaEnum() = default; + explicit QQmlJSMetaEnum(QString name) : m_name(std::move(name)) {} + + bool isValid() const { return !m_name.isEmpty(); } + + QString name() const { return m_name; } + void setName(const QString &name) { m_name = name; } + + QString alias() const { return m_alias; } + void setAlias(const QString &alias) { m_alias = alias; } + + bool isFlag() const { return m_isFlag; } + void setIsFlag(bool isFlag) { m_isFlag = isFlag; } + + bool isScoped() const { return m_isScoped; } + void setIsScoped(bool v) { m_isScoped = v; } + + bool isQml() const { return m_isQml; } + void setIsQml(bool v) { m_isQml = v; } + + void addKey(const QString &key) { m_keys.append(key); } + QStringList keys() const { return m_keys; } + + void addValue(int value) { m_values.append(value); } + QList<int> values() const { return m_values; } + + bool hasValues() const { return !m_values.isEmpty(); } + int value(const QString &key) const { return m_values.value(m_keys.indexOf(key)); } + bool hasKey(const QString &key) const { return m_keys.indexOf(key) != -1; } + + QString typeName() const { return m_typeName; } + void setTypeName(const QString &typeName) { m_typeName = typeName; } + + QSharedPointer<const QQmlJSScope> type() const { return m_type; } + void setType(const QSharedPointer<const QQmlJSScope> &type) { m_type = type; } + + friend bool operator==(const QQmlJSMetaEnum &a, const QQmlJSMetaEnum &b) + { + return a.m_keys == b.m_keys + && a.m_values == b.m_values + && a.m_name == b.m_name + && a.m_alias == b.m_alias + && a.m_isFlag == b.m_isFlag + && a.m_type == b.m_type + && a.m_isScoped == b.m_isScoped; + } + + friend bool operator!=(const QQmlJSMetaEnum &a, const QQmlJSMetaEnum &b) + { + return !(a == b); + } + + friend size_t qHash(const QQmlJSMetaEnum &e, size_t seed = 0) + { + return qHashMulti( + seed, e.m_keys, e.m_values, e.m_name, e.m_alias, e.m_isFlag, e.m_type, e.m_isScoped); + } +}; + +class QQmlJSMetaParameter +{ +public: + /*! + \internal + A non-const parameter is passed either by pointer or by value, depending on its access + semantics. For types with reference access semantics, they can be const and will be passed + then as const pointer. Const references are treated like values (i.e. non-const). + */ + enum Constness { + NonConst = 0, + Const, + }; + + QQmlJSMetaParameter(QString name = QString(), QString typeName = QString(), + Constness typeQualifier = NonConst, + QWeakPointer<const QQmlJSScope> type = {}) + : m_name(std::move(name)), + m_typeName(std::move(typeName)), + m_type(type), + m_typeQualifier(typeQualifier) + { + } + + QString name() const { return m_name; } + void setName(const QString &name) { m_name = name; } + QString typeName() const { return m_typeName; } + void setTypeName(const QString &typeName) { m_typeName = typeName; } + QSharedPointer<const QQmlJSScope> type() const { return m_type.toStrongRef(); } + void setType(QWeakPointer<const QQmlJSScope> type) { m_type = type; } + Constness typeQualifier() const { return m_typeQualifier; } + void setTypeQualifier(Constness typeQualifier) { m_typeQualifier = typeQualifier; } + bool isPointer() const { return m_isPointer; } + void setIsPointer(bool isPointer) { m_isPointer = isPointer; } + bool isList() const { return m_isList; } + void setIsList(bool isList) { m_isList = isList; } + + friend bool operator==(const QQmlJSMetaParameter &a, const QQmlJSMetaParameter &b) + { + return a.m_name == b.m_name && a.m_typeName == b.m_typeName + && a.m_type.owner_equal(b.m_type) + && a.m_typeQualifier == b.m_typeQualifier; + } + + friend bool operator!=(const QQmlJSMetaParameter &a, const QQmlJSMetaParameter &b) + { + return !(a == b); + } + + friend size_t qHash(const QQmlJSMetaParameter &e, size_t seed = 0) + { + return qHashMulti(seed, e.m_name, e.m_typeName, e.m_type.owner_hash(), + e.m_typeQualifier); + } + +private: + QString m_name; + QString m_typeName; + QWeakPointer<const QQmlJSScope> m_type; + Constness m_typeQualifier = NonConst; + bool m_isPointer = false; + bool m_isList = false; +}; + +using QQmlJSMetaReturnType = QQmlJSMetaParameter; + +class QQmlJSMetaMethod +{ +public: + enum Access { Private, Protected, Public }; + using MethodType = QQmlJSMetaMethodType; + +public: + /*! \internal + + Represents a relative JavaScript function/expression index within a type + in a QML document. Used as a typed alternative to int with an explicit + invalid state. + */ + enum class RelativeFunctionIndex : int { Invalid = -1 }; + + /*! \internal + + Represents an absolute JavaScript function/expression index pointing + into the QV4::ExecutableCompilationUnit::runtimeFunctions array. Used as + a typed alternative to int with an explicit invalid state. + */ + enum class AbsoluteFunctionIndex : int { Invalid = -1 }; + + QQmlJSMetaMethod() = default; + explicit QQmlJSMetaMethod(QString name, QString returnType = QString()) + : m_name(std::move(name)), + m_returnType(QString(), std::move(returnType)), + m_methodType(MethodType::Method) + {} + + QString methodName() const { return m_name; } + void setMethodName(const QString &name) { m_name = name; } + + QQmlJS::SourceLocation sourceLocation() const { return m_sourceLocation; } + void setSourceLocation(QQmlJS::SourceLocation location) { m_sourceLocation = location; } + + QQmlJSMetaReturnType returnValue() const { return m_returnType; } + void setReturnValue(const QQmlJSMetaReturnType returnValue) { m_returnType = returnValue; } + QString returnTypeName() const { return m_returnType.typeName(); } + void setReturnTypeName(const QString &typeName) { m_returnType.setTypeName(typeName); } + QSharedPointer<const QQmlJSScope> returnType() const { return m_returnType.type(); } + void setReturnType(QWeakPointer<const QQmlJSScope> type) { m_returnType.setType(type); } + + QList<QQmlJSMetaParameter> parameters() const { return m_parameters; } + QPair<QList<QQmlJSMetaParameter>::iterator, QList<QQmlJSMetaParameter>::iterator> + mutableParametersRange() + { + return { m_parameters.begin(), m_parameters.end() }; + } + + QStringList parameterNames() const + { + QStringList names; + for (const auto &p : m_parameters) + names.append(p.name()); + + return names; + } + + void setParameters(const QList<QQmlJSMetaParameter> ¶meters) { m_parameters = parameters; } + + void addParameter(const QQmlJSMetaParameter &p) { m_parameters.append(p); } + + QQmlJSMetaMethodType methodType() const { return m_methodType; } + void setMethodType(MethodType methodType) { m_methodType = methodType; } + + Access access() const { return m_methodAccess; } + + int revision() const { return m_revision; } + void setRevision(int r) { m_revision = r; } + + bool isCloned() const { return m_isCloned; } + void setIsCloned(bool isCloned) { m_isCloned= isCloned; } + + bool isConstructor() const { return m_isConstructor; } + void setIsConstructor(bool isConstructor) { m_isConstructor = isConstructor; } + + bool isJavaScriptFunction() const { return m_isJavaScriptFunction; } + void setIsJavaScriptFunction(bool isJavaScriptFunction) + { + m_isJavaScriptFunction = isJavaScriptFunction; + } + + bool isImplicitQmlPropertyChangeSignal() const { return m_isImplicitQmlPropertyChangeSignal; } + void setIsImplicitQmlPropertyChangeSignal(bool isPropertyChangeSignal) + { + m_isImplicitQmlPropertyChangeSignal = isPropertyChangeSignal; + } + + bool isValid() const { return !m_name.isEmpty(); } + + const QVector<QQmlJSAnnotation>& annotations() const { return m_annotations; } + void setAnnotations(QVector<QQmlJSAnnotation> annotations) { m_annotations = annotations; } + + void setJsFunctionIndex(RelativeFunctionIndex index) + { + Q_ASSERT(!m_isConstructor); + m_relativeFunctionIndex = index; + } + + RelativeFunctionIndex jsFunctionIndex() const + { + Q_ASSERT(!m_isConstructor); + return m_relativeFunctionIndex; + } + + void setConstructorIndex(RelativeFunctionIndex index) + { + Q_ASSERT(m_isConstructor); + m_relativeFunctionIndex = index; + } + + RelativeFunctionIndex constructorIndex() const + { + Q_ASSERT(m_isConstructor); + return m_relativeFunctionIndex; + } + + friend bool operator==(const QQmlJSMetaMethod &a, const QQmlJSMetaMethod &b) + { + return a.m_name == b.m_name && a.m_returnType == b.m_returnType + && a.m_parameters == b.m_parameters && a.m_annotations == b.m_annotations + && a.m_methodType == b.m_methodType && a.m_methodAccess == b.m_methodAccess + && a.m_revision == b.m_revision && a.m_isConstructor == b.m_isConstructor; + } + + friend bool operator!=(const QQmlJSMetaMethod &a, const QQmlJSMetaMethod &b) + { + return !(a == b); + } + + friend size_t qHash(const QQmlJSMetaMethod &method, size_t seed = 0) + { + QtPrivate::QHashCombine combine; + + seed = combine(seed, method.m_name); + seed = combine(seed, method.m_returnType); + seed = combine(seed, method.m_annotations); + seed = combine(seed, method.m_methodType); + seed = combine(seed, method.m_methodAccess); + seed = combine(seed, method.m_revision); + seed = combine(seed, method.m_isConstructor); + + for (const auto &type : method.m_parameters) { + seed = combine(seed, type); + } + + return seed; + } + +private: + QString m_name; + + QQmlJS::SourceLocation m_sourceLocation; + + QQmlJSMetaReturnType m_returnType; + QList<QQmlJSMetaParameter> m_parameters; + QList<QQmlJSAnnotation> m_annotations; + + MethodType m_methodType = MethodType::Signal; + Access m_methodAccess = Public; + int m_revision = 0; + RelativeFunctionIndex m_relativeFunctionIndex = RelativeFunctionIndex::Invalid; + bool m_isCloned = false; + bool m_isConstructor = false; + bool m_isJavaScriptFunction = false; + bool m_isImplicitQmlPropertyChangeSignal = false; +}; + +class QQmlJSMetaProperty +{ + QString m_propertyName; + QString m_typeName; + QString m_read; + QString m_write; + QString m_reset; + QString m_bindable; + QString m_notify; + QString m_privateClass; + QString m_aliasExpr; + QWeakPointer<const QQmlJSScope> m_type; + QQmlJS::SourceLocation m_sourceLocation; + QVector<QQmlJSAnnotation> m_annotations; + bool m_isList = false; + bool m_isWritable = false; + bool m_isPointer = false; + bool m_isFinal = false; + bool m_isConstant = false; + int m_revision = 0; + int m_index = -1; // relative property index within owning QQmlJSScope + +public: + QQmlJSMetaProperty() = default; + + void setPropertyName(const QString &propertyName) { m_propertyName = propertyName; } + QString propertyName() const { return m_propertyName; } + + void setTypeName(const QString &typeName) { m_typeName = typeName; } + QString typeName() const { return m_typeName; } + + void setRead(const QString &read) { m_read = read; } + QString read() const { return m_read; } + + void setWrite(const QString &write) { m_write = write; } + QString write() const { return m_write; } + + void setReset(const QString &reset) { m_reset = reset; } + QString reset() const { return m_reset; } + + void setBindable(const QString &bindable) { m_bindable = bindable; } + QString bindable() const { return m_bindable; } + + void setNotify(const QString ¬ify) { m_notify = notify; } + QString notify() const { return m_notify; } + + void setPrivateClass(const QString &privateClass) { m_privateClass = privateClass; } + QString privateClass() const { return m_privateClass; } + bool isPrivate() const { return !m_privateClass.isEmpty(); } // exists for convenience + + void setType(const QSharedPointer<const QQmlJSScope> &type) { m_type = type; } + QSharedPointer<const QQmlJSScope> type() const { return m_type.toStrongRef(); } + + void setSourceLocation(const QQmlJS::SourceLocation &newSourceLocation) + { m_sourceLocation = newSourceLocation; } + QQmlJS::SourceLocation sourceLocation() const { return m_sourceLocation; } + + void setAnnotations(const QList<QQmlJSAnnotation> &annotation) { m_annotations = annotation; } + const QList<QQmlJSAnnotation> &annotations() const { return m_annotations; } + + void setIsList(bool isList) { m_isList = isList; } + bool isList() const { return m_isList; } + + void setIsWritable(bool isWritable) { m_isWritable = isWritable; } + bool isWritable() const { return m_isWritable; } + + void setIsPointer(bool isPointer) { m_isPointer = isPointer; } + bool isPointer() const { return m_isPointer; } + + void setAliasExpression(const QString &aliasString) { m_aliasExpr = aliasString; } + QString aliasExpression() const { return m_aliasExpr; } + bool isAlias() const { return !m_aliasExpr.isEmpty(); } // exists for convenience + + void setIsFinal(bool isFinal) { m_isFinal = isFinal; } + bool isFinal() const { return m_isFinal; } + + void setIsConstant(bool isConstant) { m_isConstant = isConstant; } + bool isConstant() const { return m_isConstant; } + + void setRevision(int revision) { m_revision = revision; } + int revision() const { return m_revision; } + + void setIndex(int index) { m_index = index; } + int index() const { return m_index; } + + bool isValid() const { return !m_propertyName.isEmpty(); } + + friend bool operator==(const QQmlJSMetaProperty &a, const QQmlJSMetaProperty &b) + { + return a.m_index == b.m_index && a.m_propertyName == b.m_propertyName + && a.m_typeName == b.m_typeName && a.m_bindable == b.m_bindable + && a.m_type.owner_equal(b.m_type) && a.m_isList == b.m_isList + && a.m_isWritable == b.m_isWritable && a.m_isPointer == b.m_isPointer + && a.m_aliasExpr == b.m_aliasExpr && a.m_revision == b.m_revision + && a.m_isFinal == b.m_isFinal; + } + + friend bool operator!=(const QQmlJSMetaProperty &a, const QQmlJSMetaProperty &b) + { + return !(a == b); + } + + friend size_t qHash(const QQmlJSMetaProperty &prop, size_t seed = 0) + { + return qHashMulti(seed, prop.m_propertyName, prop.m_typeName, prop.m_bindable, + prop.m_type.toStrongRef().data(), prop.m_isList, prop.m_isWritable, + prop.m_isPointer, prop.m_aliasExpr, prop.m_revision, prop.m_isFinal, + prop.m_index); + } +}; + +/*! + \class QQmlJSMetaPropertyBinding + + \internal + + Represents a single QML binding of a specific type. Typically, when you + create a new binding, you know all the details of it already, so you should + just set all the data at once. +*/ +class Q_QMLCOMPILER_EXPORT QQmlJSMetaPropertyBinding +{ + using BindingType = QQmlSA::BindingType; + using ScriptBindingKind = QQmlSA::ScriptBindingKind; + + // needs to be kept in sync with the BindingType enum + struct Content { + using Invalid = std::monostate; + struct BoolLiteral { + bool value; + friend bool operator==(BoolLiteral a, BoolLiteral b) { return a.value == b.value; } + friend bool operator!=(BoolLiteral a, BoolLiteral b) { return !(a == b); } + }; + struct NumberLiteral { + QT_WARNING_PUSH + QT_WARNING_DISABLE_CLANG("-Wfloat-equal") + QT_WARNING_DISABLE_GCC("-Wfloat-equal") + friend bool operator==(NumberLiteral a, NumberLiteral b) { return a.value == b.value; } + friend bool operator!=(NumberLiteral a, NumberLiteral b) { return !(a == b); } + QT_WARNING_POP + + double value; // ### TODO: int? + }; + struct StringLiteral { + friend bool operator==(StringLiteral a, StringLiteral b) { return a.value == b.value; } + friend bool operator!=(StringLiteral a, StringLiteral b) { return !(a == b); } + QString value; + }; + struct RegexpLiteral { + friend bool operator==(RegexpLiteral a, RegexpLiteral b) { return a.value == b.value; } + friend bool operator!=(RegexpLiteral a, RegexpLiteral b) { return !(a == b); } + QString value; + }; + struct Null { + friend bool operator==(Null , Null ) { return true; } + friend bool operator!=(Null a, Null b) { return !(a == b); } + }; + struct TranslationString { + friend bool operator==(TranslationString a, TranslationString b) + { + return a.text == b.text && a.comment == b.comment && a.number == b.number && a.context == b.context; + } + friend bool operator!=(TranslationString a, TranslationString b) { return !(a == b); } + QString text; + QString comment; + QString context; + int number; + }; + struct TranslationById { + friend bool operator==(TranslationById a, TranslationById b) + { + return a.id == b.id && a.number == b.number; + } + friend bool operator!=(TranslationById a, TranslationById b) { return !(a == b); } + QString id; + int number; + }; + struct Script { + friend bool operator==(Script a, Script b) + { + return a.index == b.index && a.kind == b.kind; + } + friend bool operator!=(Script a, Script b) { return !(a == b); } + QQmlJSMetaMethod::RelativeFunctionIndex index = + QQmlJSMetaMethod::RelativeFunctionIndex::Invalid; + ScriptBindingKind kind = ScriptBindingKind::Invalid; + ScriptBindingValueType valueType = ScriptBindingValueType::ScriptValue_Unknown; + }; + struct Object { + friend bool operator==(Object a, Object b) { return a.value.owner_equal(b.value) && a.typeName == b.typeName; } + friend bool operator!=(Object a, Object b) { return !(a == b); } + QString typeName; + QWeakPointer<const QQmlJSScope> value; + }; + struct Interceptor { + friend bool operator==(Interceptor a, Interceptor b) + { + return a.value.owner_equal(b.value) && a.typeName == b.typeName; + } + friend bool operator!=(Interceptor a, Interceptor b) { return !(a == b); } + QString typeName; + QWeakPointer<const QQmlJSScope> value; + }; + struct ValueSource { + friend bool operator==(ValueSource a, ValueSource b) + { + return a.value.owner_equal(b.value) && a.typeName == b.typeName; + } + friend bool operator!=(ValueSource a, ValueSource b) { return !(a == b); } + QString typeName; + QWeakPointer<const QQmlJSScope> value; + }; + struct AttachedProperty { + /* + AttachedProperty binding is a grouping for a series of bindings + belonging to the same scope(QQmlJSScope::AttachedPropertyScope). + Thus, the attached property binding itself only exposes the + attaching type object. Such object is unique per the enclosing + scope, so attaching types attached to different QML scopes are + different (think of them as objects in C++ terms). + + An attaching type object, being a QQmlJSScope, has bindings + itself. For instance: + ``` + Type { + Keys.enabled: true + } + ``` + tells us that "Type" has an AttachedProperty binding with + property name "Keys". The attaching object of that binding + (binding.attachingType()) has type "Keys" and a BoolLiteral + binding with property name "enabled". + */ + friend bool operator==(AttachedProperty a, AttachedProperty b) + { + return a.value.owner_equal(b.value); + } + friend bool operator!=(AttachedProperty a, AttachedProperty b) { return !(a == b); } + QWeakPointer<const QQmlJSScope> value; + }; + struct GroupProperty { + /* Given a group property declaration like + anchors.left: root.left + the QQmlJSMetaPropertyBinding will have name "anchors", and a m_bindingContent + of type GroupProperty, with groupScope pointing to the scope introudced by anchors + In that scope, there will be another QQmlJSMetaPropertyBinding, with name "left" and + m_bindingContent Script (for root.left). + There should never be more than one GroupProperty for the same name in the same + scope, though: If the scope also contains anchors.top: root.top that should reuse the + GroupProperty content (and add a top: root.top binding in it). There might however + still be an additional object or script binding ( anchors: {left: foo, right: bar }; + anchors: root.someFunction() ) or another binding to the property in a "derived" + type. + + ### TODO: Obtaining the effective binding result requires some resolving function + */ + QWeakPointer<const QQmlJSScope> groupScope; + friend bool operator==(GroupProperty a, GroupProperty b) { return a.groupScope.owner_equal(b.groupScope); } + friend bool operator!=(GroupProperty a, GroupProperty b) { return !(a == b); } + }; + using type = std::variant<Invalid, BoolLiteral, NumberLiteral, StringLiteral, + RegexpLiteral, Null, TranslationString, + TranslationById, Script, Object, Interceptor, + ValueSource, AttachedProperty, GroupProperty + >; + }; + using BindingContent = Content::type; + + QQmlJS::SourceLocation m_sourceLocation; + QString m_propertyName; // TODO: this is a debug-only information + BindingContent m_bindingContent; + + void ensureSetBindingTypeOnce() + { + Q_ASSERT(bindingType() == BindingType::Invalid); + } + + bool isLiteralBinding() const { return isLiteralBinding(bindingType()); } + + +public: + static bool isLiteralBinding(BindingType type) + { + return type == BindingType::BoolLiteral || type == BindingType::NumberLiteral + || type == BindingType::StringLiteral || type == BindingType::RegExpLiteral + || type == BindingType::Null; // special. we record it as literal + } + + QQmlJSMetaPropertyBinding(); + QQmlJSMetaPropertyBinding(QQmlJS::SourceLocation location) : m_sourceLocation(location) { } + explicit QQmlJSMetaPropertyBinding(QQmlJS::SourceLocation location, const QString &propName) + : m_sourceLocation(location), m_propertyName(propName) + { + } + explicit QQmlJSMetaPropertyBinding(QQmlJS::SourceLocation location, + const QQmlJSMetaProperty &prop) + : QQmlJSMetaPropertyBinding(location, prop.propertyName()) + { + } + + void setPropertyName(const QString &propertyName) { m_propertyName = propertyName; } + QString propertyName() const { return m_propertyName; } + + const QQmlJS::SourceLocation &sourceLocation() const { return m_sourceLocation; } + + BindingType bindingType() const { return BindingType(m_bindingContent.index()); } + + bool isValid() const; + + void setStringLiteral(QAnyStringView value) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::StringLiteral { value.toString() }; + } + + void + setScriptBinding(QQmlJSMetaMethod::RelativeFunctionIndex value, ScriptBindingKind kind, + ScriptBindingValueType valueType = ScriptBindingValueType::ScriptValue_Unknown) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::Script { value, kind, valueType }; + } + + void setGroupBinding(const QSharedPointer<const QQmlJSScope> &groupScope) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::GroupProperty { groupScope }; + } + + void setAttachedBinding(const QSharedPointer<const QQmlJSScope> &attachingScope) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::AttachedProperty { attachingScope }; + } + + void setBoolLiteral(bool value) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::BoolLiteral { value }; + } + + void setNullLiteral() + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::Null {}; + } + + void setNumberLiteral(double value) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::NumberLiteral { value }; + } + + void setRegexpLiteral(QAnyStringView value) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::RegexpLiteral { value.toString() }; + } + + void setTranslation(QStringView text, QStringView comment, QStringView context, int number) + { + ensureSetBindingTypeOnce(); + m_bindingContent = + Content::TranslationString{ text.toString(), comment.toString(), context.toString(), number }; + } + + void setTranslationId(QStringView id, int number) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::TranslationById{ id.toString(), number }; + } + + void setObject(const QString &typeName, const QSharedPointer<const QQmlJSScope> &type) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::Object { typeName, type }; + } + + void setInterceptor(const QString &typeName, const QSharedPointer<const QQmlJSScope> &type) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::Interceptor { typeName, type }; + } + + void setValueSource(const QString &typeName, const QSharedPointer<const QQmlJSScope> &type) + { + ensureSetBindingTypeOnce(); + m_bindingContent = Content::ValueSource { typeName, type }; + } + + // ### TODO: here and below: Introduce an allowConversion parameter, if yes, enable conversions e.g. bool -> number? + bool boolValue() const; + + double numberValue() const; + + QString stringValue() const; + + QString regExpValue() const; + + QQmlTranslation translationDataValue(QString qmlFileNameForContext = QStringLiteral("")) const; + + QSharedPointer<const QQmlJSScope> literalType(const QQmlJSTypeResolver *resolver) const; + + QQmlJSMetaMethod::RelativeFunctionIndex scriptIndex() const + { + if (auto *script = std::get_if<Content::Script>(&m_bindingContent)) + return script->index; + // warn + return QQmlJSMetaMethod::RelativeFunctionIndex::Invalid; + } + + ScriptBindingKind scriptKind() const + { + if (auto *script = std::get_if<Content::Script>(&m_bindingContent)) + return script->kind; + // warn + return ScriptBindingKind::Invalid; + } + + ScriptBindingValueType scriptValueType() const + { + if (auto *script = std::get_if<Content::Script>(&m_bindingContent)) + return script->valueType; + // warn + return ScriptBindingValueType::ScriptValue_Unknown; + } + + QString objectTypeName() const + { + if (auto *object = std::get_if<Content::Object>(&m_bindingContent)) + return object->typeName; + // warn + return {}; + } + QSharedPointer<const QQmlJSScope> objectType() const + { + if (auto *object = std::get_if<Content::Object>(&m_bindingContent)) + return object->value.lock(); + // warn + return {}; + } + + QString interceptorTypeName() const + { + if (auto *interceptor = std::get_if<Content::Interceptor>(&m_bindingContent)) + return interceptor->typeName; + // warn + return {}; + } + QSharedPointer<const QQmlJSScope> interceptorType() const + { + if (auto *interceptor = std::get_if<Content::Interceptor>(&m_bindingContent)) + return interceptor->value.lock(); + // warn + return {}; + } + + QString valueSourceTypeName() const + { + if (auto *valueSource = std::get_if<Content::ValueSource>(&m_bindingContent)) + return valueSource->typeName; + // warn + return {}; + } + QSharedPointer<const QQmlJSScope> valueSourceType() const + { + if (auto *valueSource = std::get_if<Content::ValueSource>(&m_bindingContent)) + return valueSource->value.lock(); + // warn + return {}; + } + + QSharedPointer<const QQmlJSScope> groupType() const + { + if (auto *group = std::get_if<Content::GroupProperty>(&m_bindingContent)) + return group->groupScope.lock(); + // warn + return {}; + } + + QSharedPointer<const QQmlJSScope> attachingType() const + { + if (auto *attached = std::get_if<Content::AttachedProperty>(&m_bindingContent)) + return attached->value.lock(); + // warn + return {}; + } + + bool hasLiteral() const + { + // TODO: Assumption: if the type is literal, we must have one + return isLiteralBinding(); + } + bool hasObject() const { return bindingType() == BindingType::Object; } + bool hasInterceptor() const + { + return bindingType() == BindingType::Interceptor; + } + bool hasValueSource() const + { + return bindingType() == BindingType::ValueSource; + } + + friend bool operator==(const QQmlJSMetaPropertyBinding &a, const QQmlJSMetaPropertyBinding &b) + { + return a.m_propertyName == b.m_propertyName + && a.m_bindingContent == b.m_bindingContent + && a.m_sourceLocation == b.m_sourceLocation; + } + + friend bool operator!=(const QQmlJSMetaPropertyBinding &a, const QQmlJSMetaPropertyBinding &b) + { + return !(a == b); + } + + friend size_t qHash(const QQmlJSMetaPropertyBinding &binding, size_t seed = 0) + { + // we don't need to care about the actual binding content when hashing + return qHashMulti(seed, binding.m_propertyName, binding.m_sourceLocation, + binding.bindingType()); + } +}; + +struct Q_QMLCOMPILER_EXPORT QQmlJSMetaSignalHandler +{ + QStringList signalParameters; + bool isMultiline; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSMETATYPES_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsoptimizations_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsoptimizations_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ae6918a36baafb0998fb537078e9e7716002451d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsoptimizations_p.h @@ -0,0 +1,65 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSOPTIMIZATIONS_P_H +#define QQMLJSOPTIMIZATIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <private/qqmljscompilepass_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLCOMPILER_EXPORT QQmlJSOptimizations : public QQmlJSCompilePass +{ +public: + using Conversions = QSet<int>; + + QQmlJSOptimizations(const QV4::Compiler::JSUnitGenerator *unitGenerator, + const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger, + BasicBlocks basicBlocks, InstructionAnnotations annotations, + QList<ObjectOrArrayDefinition> objectAndArrayDefinitions) + : QQmlJSCompilePass(unitGenerator, typeResolver, logger, basicBlocks, annotations), + m_objectAndArrayDefinitions{ objectAndArrayDefinitions } + { + } + + ~QQmlJSOptimizations() = default; + + BlocksAndAnnotations run(const Function *function, QQmlJS::DiagnosticMessage *error); + +private: + struct RegisterAccess + { + QList<QQmlJSScope::ConstPtr> trackedTypes; + QHash<int, QQmlJSScope::ConstPtr> typeReaders; + QHash<int, Conversions> registerReadersAndConversions; + int trackedRegister; + }; + + QV4::Moth::ByteCodeHandler::Verdict startInstruction(QV4::Moth::Instr::Type) override + { + return ProcessInstruction; + } + void endInstruction(QV4::Moth::Instr::Type) override { } + + void populateBasicBlocks(); + void populateReaderLocations(); + void adjustTypes(); + bool canMove(int instructionOffset, const RegisterAccess &access) const; + + QHash<int, RegisterAccess> m_readerLocations; + QList<ObjectOrArrayDefinition> m_objectAndArrayDefinitions; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSOPTIMIZATIONS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsregistercontent_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsregistercontent_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2ba9964ae934b4e49f9bcacdf48a53fa8eeab371 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsregistercontent_p.h @@ -0,0 +1,292 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSREGISTERCONTENT_P_H +#define QQMLJSREGISTERCONTENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include "qqmljsscope_p.h" +#include <QtCore/qhash.h> +#include <QtCore/qstring.h> + +#include <variant> + +QT_BEGIN_NAMESPACE + +class Q_QMLCOMPILER_EXPORT QQmlJSRegisterContent +{ +public: + enum ContentVariant { + ObjectById, + Singleton, + Script, + MetaType, + + JavaScriptGlobal, + JavaScriptObject, + JavaScriptScopeProperty, + GenericObjectProperty, // Can be JSObject property or QVariantMap + + ScopeProperty, + ScopeMethod, + ScopeAttached, + ScopeModulePrefix, + ExtensionScopeProperty, + ExtensionScopeMethod, + + ObjectProperty, + ObjectMethod, + ObjectEnum, + ObjectAttached, + ObjectModulePrefix, + ExtensionObjectProperty, + ExtensionObjectMethod, + ExtensionObjectEnum, + + MethodReturnValue, + JavaScriptReturnValue, + + ListValue, + ListIterator, + Builtin, + Unknown, + }; + + enum { InvalidLookupIndex = -1 }; + + QQmlJSRegisterContent() = default; + bool isValid() const { return !m_storedType.isNull(); } + + QString descriptiveName() const; + + friend bool operator==(const QQmlJSRegisterContent &a, const QQmlJSRegisterContent &b) + { + return a.m_storedType == b.m_storedType && a.m_variant == b.m_variant + && a.m_scope == b.m_scope && a.m_content == b.m_content; + } + + friend bool operator!=(const QQmlJSRegisterContent &a, const QQmlJSRegisterContent &b) + { + return !(a == b); + } + + bool isType() const { return m_content.index() == Type; } + bool isProperty() const { return m_content.index() == Property; } + bool isEnumeration() const { return m_content.index() == Enum; } + bool isMethod() const { return m_content.index() == Method; } + bool isImportNamespace() const { return m_content.index() == ImportNamespace; } + bool isConversion() const { return m_content.index() == Conversion; } + bool isList() const; + + bool isWritable() const; + + QQmlJSScope::ConstPtr storedType() const { return m_storedType; } + QQmlJSScope::ConstPtr scopeType() const { return m_scope; } + + QQmlJSScope::ConstPtr type() const + { + return std::get<std::pair<QQmlJSScope::ConstPtr, int>>(m_content).first; + } + QQmlJSMetaProperty property() const + { + return std::get<PropertyLookup>(m_content).property; + } + int baseLookupIndex() const + { + return std::get<PropertyLookup>(m_content).baseLookupIndex; + } + int resultLookupIndex() const + { + switch (m_content.index()) { + case Type: + return std::get<std::pair<QQmlJSScope::ConstPtr, int>>(m_content).second; + case Property: + return std::get<PropertyLookup>(m_content).resultLookupIndex; + default: + return InvalidLookupIndex; + } + } + QQmlJSMetaEnum enumeration() const + { + return std::get<std::pair<QQmlJSMetaEnum, QString>>(m_content).first; + } + QString enumMember() const + { + return std::get<std::pair<QQmlJSMetaEnum, QString>>(m_content).second; + } + QList<QQmlJSMetaMethod> method() const { return std::get<QList<QQmlJSMetaMethod>>(m_content); } + uint importNamespace() const { return std::get<uint>(m_content); } + + QQmlJSScope::ConstPtr conversionResult() const + { + return std::get<ConvertedTypes>(m_content).result; + } + + QQmlJSScope::ConstPtr conversionResultScope() const + { + return std::get<ConvertedTypes>(m_content).resultScope; + } + + QList<QQmlJSScope::ConstPtr> conversionOrigins() const + { + return std::get<ConvertedTypes>(m_content).origins; + } + + ContentVariant variant() const { return m_variant; } + + friend size_t qHash(const QQmlJSRegisterContent ®isterContent, size_t seed = 0) + { + seed = qHashMulti(seed, registerContent.m_storedType, registerContent.m_content.index(), + registerContent.m_scope, registerContent.m_variant); + switch (registerContent.m_content.index()) { + case Type: + return qHash(std::get<std::pair<QQmlJSScope::ConstPtr, int>>(registerContent.m_content), + seed); + case Property: + return qHash(std::get<PropertyLookup>(registerContent.m_content), seed); + case Enum: + return qHash(std::get<std::pair<QQmlJSMetaEnum, QString>>(registerContent.m_content), + seed); + case Method: + return qHash(std::get<QList<QQmlJSMetaMethod>>(registerContent.m_content), seed); + case ImportNamespace: + return qHash(std::get<uint>(registerContent.m_content), seed); + case Conversion: + return qHash(std::get<ConvertedTypes>(registerContent.m_content), seed); + } + + Q_UNREACHABLE_RETURN(seed); + } + + static QQmlJSRegisterContent create(const QQmlJSScope::ConstPtr &storedType, + const QQmlJSScope::ConstPtr &type, + int resultLookupIndex, ContentVariant variant, + const QQmlJSScope::ConstPtr &scope = {}); + + static QQmlJSRegisterContent create(const QQmlJSScope::ConstPtr &storedType, + const QQmlJSMetaProperty &property, + int baseLookupIndex, int resultLookupIndex, + ContentVariant variant, + const QQmlJSScope::ConstPtr &scope); + + static QQmlJSRegisterContent create(const QQmlJSScope::ConstPtr &storedType, + const QQmlJSMetaEnum &enumeration, + const QString &enumMember, ContentVariant variant, + const QQmlJSScope::ConstPtr &scope); + + static QQmlJSRegisterContent create(const QQmlJSScope::ConstPtr &storedType, + const QList<QQmlJSMetaMethod> &methods, + ContentVariant variant, + const QQmlJSScope::ConstPtr &scope); + + static QQmlJSRegisterContent create(const QQmlJSScope::ConstPtr &storedType, + uint importNamespaceStringId, ContentVariant variant, + const QQmlJSScope::ConstPtr &scope = {}); + + static QQmlJSRegisterContent create(const QQmlJSScope::ConstPtr &storedType, + const QList<QQmlJSScope::ConstPtr> &origins, + const QQmlJSScope::ConstPtr &conversion, + const QQmlJSScope::ConstPtr &conversionScope, + ContentVariant variant, + const QQmlJSScope::ConstPtr &scope = {}); + + QQmlJSRegisterContent storedIn(const QQmlJSScope::ConstPtr &newStoredType) const + { + QQmlJSRegisterContent result = *this; + result.m_storedType = newStoredType; + return result; + } + + QQmlJSRegisterContent castTo(const QQmlJSScope::ConstPtr &newContainedType) const + { + // This is not a conversion but a run time cast. It may result in null or undefined. + QQmlJSRegisterContent result = *this; + result.m_content = std::make_pair(newContainedType, result.resultLookupIndex()); + return result; + } + +private: + enum ContentKind { Type, Property, Enum, Method, ImportNamespace, Conversion }; + + struct ConvertedTypes + { + QList<QQmlJSScope::ConstPtr> origins; + QQmlJSScope::ConstPtr result; + QQmlJSScope::ConstPtr resultScope; + + friend size_t qHash(const ConvertedTypes &types, size_t seed = 0) + { + return qHashMulti(seed, types.origins, types.result, types.resultScope); + } + + friend bool operator==(const ConvertedTypes &a, const ConvertedTypes &b) + { + return a.origins == b.origins && a.result == b.result && a.resultScope == b.resultScope; + } + + friend bool operator!=(const ConvertedTypes &a, const ConvertedTypes &b) + { + return !(a == b); + } + }; + + struct PropertyLookup + { + QQmlJSMetaProperty property; + int baseLookupIndex = InvalidLookupIndex; + int resultLookupIndex = InvalidLookupIndex; + + friend size_t qHash(const PropertyLookup &property, size_t seed = 0) + { + return qHashMulti( + seed, property.property, property.baseLookupIndex, property.resultLookupIndex); + } + + friend bool operator==(const PropertyLookup &a, const PropertyLookup &b) + { + return a.baseLookupIndex == b.baseLookupIndex + && a.resultLookupIndex == b.resultLookupIndex + && a.property == b.property; + } + + friend bool operator!=(const PropertyLookup &a, const PropertyLookup &b) + { + return !(a == b); + } + }; + + using Content = std::variant< + std::pair<QQmlJSScope::ConstPtr, int>, + PropertyLookup, + std::pair<QQmlJSMetaEnum, QString>, + QList<QQmlJSMetaMethod>, + uint, + ConvertedTypes + >; + + QQmlJSRegisterContent(const QQmlJSScope::ConstPtr &storedType, + const QQmlJSScope::ConstPtr &scope, ContentVariant variant) + : m_storedType(storedType), m_scope(scope), m_variant(variant) + { + } + + QQmlJSScope::ConstPtr m_storedType; + QQmlJSScope::ConstPtr m_scope; + Content m_content; + ContentVariant m_variant = Unknown; + + // TODO: Constant string/number/bool/enumval +}; + +QT_END_NAMESPACE + +#endif // REGISTERCONTENT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsresourcefilemapper_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsresourcefilemapper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b8ab3c2f98fbe48b3daed5f02dc3219d13493d18 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsresourcefilemapper_p.h @@ -0,0 +1,73 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +#ifndef QQMLJSRESOURCEFILEMAPPER_P_H +#define QQMLJSRESOURCEFILEMAPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include <QStringList> +#include <QHash> +#include <QFile> +#include <private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +struct Q_QMLCOMPILER_EXPORT QQmlJSResourceFileMapper +{ + struct Entry + { + QString resourcePath; + QString filePath; + bool isValid() const { return !resourcePath.isEmpty() && !filePath.isEmpty(); } + }; + + enum FilterMode { + File = 0x0, // Default is local (non-directory) file, without recursion + Directory = 0x1, // Directory, either local or resource + Resource = 0x2, // Resource path, either to file or directory + Recurse = 0x4, // Recurse into subdirectories if Directory + }; + Q_DECLARE_FLAGS(FilterFlags, FilterMode); + + struct Filter { + QString path; + QStringList suffixes; + FilterFlags flags; + }; + + static Filter allQmlJSFilter(); + static Filter localFileFilter(const QString &file); + static Filter resourceFileFilter(const QString &file); + static Filter resourceQmlDirectoryFilter(const QString &directory); + + QQmlJSResourceFileMapper(const QStringList &resourceFiles); + + bool isEmpty() const; + bool isFile(const QString &resourcePath) const; + + QList<Entry> filter(const Filter &filter) const; + QStringList filePaths(const Filter &filter) const; + QStringList resourcePaths(const Filter &filter) const; + Entry entry(const Filter &filter) const; + +private: + void populateFromQrcFile(QFile &file); + + QList<Entry> qrcPathToFileSystemPath; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlJSResourceFileMapper::FilterFlags); + +QT_END_NAMESPACE + +#endif // QMLJSRESOURCEFILEMAPPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsscope_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsscope_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c5d911f94782dd6c5d0ae60ad434b8c18223acf8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsscope_p.h @@ -0,0 +1,712 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSSCOPE_P_H +#define QQMLJSSCOPE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include "qqmljsmetatypes_p.h" +#include "qdeferredpointer_p.h" +#include "qqmljsannotation_p.h" +#include "qqmlsaconstants.h" +#include "qqmlsa_p.h" + +#include <QtQml/private/qqmljssourcelocation_p.h> + +#include <QtCore/qfileinfo.h> +#include <QtCore/qhash.h> +#include <QtCore/qset.h> +#include <QtCore/qstring.h> +#include <QtCore/qversionnumber.h> +#include "qqmlsaconstants.h" + +#include <optional> + +QT_BEGIN_NAMESPACE + +class QQmlJSImporter; + +namespace QQmlJS { + +class ConstPtrWrapperIterator +{ +public: + using Ptr = QDeferredSharedPointer<QQmlJSScope>; + using ConstPtr = QDeferredSharedPointer<const QQmlJSScope>; + using iterator_category = std::forward_iterator_tag; + using difference_type = std::ptrdiff_t; + using value_type = ConstPtr; + using pointer = value_type *; + using reference = value_type &; + + ConstPtrWrapperIterator(QList<Ptr>::const_iterator iterator) : m_iterator(iterator) { } + + friend bool operator==(const ConstPtrWrapperIterator &a, const ConstPtrWrapperIterator &b) + { + return a.m_iterator == b.m_iterator; + } + friend bool operator!=(const ConstPtrWrapperIterator &a, const ConstPtrWrapperIterator &b) + { + return a.m_iterator != b.m_iterator; + } + + reference operator*() + { + if (!m_pointer) + m_pointer = *m_iterator; + return m_pointer; + } + pointer operator->() + { + if (!m_pointer) + m_pointer = *m_iterator; + return &m_pointer; + } + + ConstPtrWrapperIterator &operator++() + { + m_iterator++; + m_pointer = {}; + return *this; + } + ConstPtrWrapperIterator operator++(int) + { + auto before = *this; + ++(*this); + return before; + } + +private: + QList<Ptr>::const_iterator m_iterator; + ConstPtr m_pointer; +}; + +class Export { +public: + Export() = default; + Export(QString package, QString type, QTypeRevision version, QTypeRevision revision); + + bool isValid() const; + + QString package() const { return m_package; } + QString type() const { return m_type; } + QTypeRevision version() const { return m_version; } + QTypeRevision revision() const { return m_revision; } + +private: + QString m_package; + QString m_type; + QTypeRevision m_version; + QTypeRevision m_revision; +}; + +template<typename Pointer> +struct ExportedScope { + Pointer scope; + QList<Export> exports; +}; + +template<typename Pointer> +struct ImportedScope { + Pointer scope; + QTypeRevision revision; +}; + +struct ContextualTypes; + +} // namespace QQmlJS + +class Q_QMLCOMPILER_EXPORT QQmlJSScope +{ + friend QQmlSA::Element; + +public: + explicit QQmlJSScope(const QString &internalName); + QQmlJSScope(QQmlJSScope &&) = default; + QQmlJSScope &operator=(QQmlJSScope &&) = default; + + using Ptr = QDeferredSharedPointer<QQmlJSScope>; + using WeakPtr = QDeferredWeakPointer<QQmlJSScope>; + using ConstPtr = QDeferredSharedPointer<const QQmlJSScope>; + using WeakConstPtr = QDeferredWeakPointer<const QQmlJSScope>; + + using AccessSemantics = QQmlSA::AccessSemantics; + using ScopeType = QQmlSA::ScopeType; + + using InlineComponentNameType = QString; + using RootDocumentNameType = std::monostate; // an empty type that has std::hash + /*! + * A Hashable type to differentiate document roots from different inline components. + */ + using InlineComponentOrDocumentRootName = + std::variant<InlineComponentNameType, RootDocumentNameType>; + + enum Flag { + Creatable = 0x1, + Composite = 0x2, + JavaScriptBuiltin = 0x4, + Singleton = 0x8, + Script = 0x10, + CustomParser = 0x20, + Array = 0x40, + InlineComponent = 0x80, + WrappedInImplicitComponent = 0x100, + HasBaseTypeError = 0x200, + ExtensionIsNamespace = 0x400, + IsListProperty = 0x800, + Structured = 0x1000, + ExtensionIsJavaScript = 0x2000, + EnforcesScopedEnums = 0x4000, + }; + Q_DECLARE_FLAGS(Flags, Flag) + Q_FLAGS(Flags); + + using Export = QQmlJS::Export; + template <typename Pointer> + using ImportedScope = QQmlJS::ImportedScope<Pointer>; + template <typename Pointer> + using ExportedScope = QQmlJS::ExportedScope<Pointer>; + + struct JavaScriptIdentifier + { + enum Kind { + Parameter, + FunctionScoped, + LexicalScoped, + Injected + }; + + Kind kind = FunctionScoped; + QQmlJS::SourceLocation location; + std::optional<QString> typeName; + bool isConst = false; + QQmlJSScope::WeakConstPtr scope = {}; + }; + + enum BindingTargetSpecifier { + SimplePropertyTarget, // e.g. `property int p: 42` + ListPropertyTarget, // e.g. `property list<Item> pList: [ Text {} ]` + UnnamedPropertyTarget // default property bindings, where property name is unspecified + }; + + template <typename Key, typename Value> + using QMultiHashRange = QPair<typename QMultiHash<Key, Value>::iterator, + typename QMultiHash<Key, Value>::iterator>; + + static QQmlJSScope::Ptr create() { return QSharedPointer<QQmlJSScope>(new QQmlJSScope); } + static QQmlJSScope::Ptr create(const QString &internalName); + static QQmlJSScope::Ptr clone(const QQmlJSScope::ConstPtr &origin); + + static QQmlJSScope::ConstPtr findCurrentQMLScope(const QQmlJSScope::ConstPtr &scope); + + QQmlJSScope::Ptr parentScope(); + QQmlJSScope::ConstPtr parentScope() const; + static void reparent(const QQmlJSScope::Ptr &parentScope, const QQmlJSScope::Ptr &childScope); + + void insertJSIdentifier(const QString &name, const JavaScriptIdentifier &identifier); + QHash<QString, JavaScriptIdentifier> ownJSIdentifiers() const; + void insertPropertyIdentifier(const QQmlJSMetaProperty &prop); + + ScopeType scopeType() const { return m_scopeType; } + void setScopeType(ScopeType type) { m_scopeType = type; } + + void addOwnMethod(const QQmlJSMetaMethod &method) { m_methods.insert(method.methodName(), method); } + QMultiHashRange<QString, QQmlJSMetaMethod> mutableOwnMethodsRange(const QString &name) + { + return m_methods.equal_range(name); + } + QMultiHash<QString, QQmlJSMetaMethod> ownMethods() const { return m_methods; } + QList<QQmlJSMetaMethod> ownMethods(const QString &name) const { return m_methods.values(name); } + bool hasOwnMethod(const QString &name) const { return m_methods.contains(name); } + + bool hasMethod(const QString &name) const; + QHash<QString, QQmlJSMetaMethod> methods() const; + QList<QQmlJSMetaMethod> methods(const QString &name) const; + QList<QQmlJSMetaMethod> methods(const QString &name, QQmlJSMetaMethodType type) const; + + void addOwnEnumeration(const QQmlJSMetaEnum &enumeration) { m_enumerations.insert(enumeration.name(), enumeration); } + QHash<QString, QQmlJSMetaEnum> ownEnumerations() const { return m_enumerations; } + QQmlJSMetaEnum ownEnumeration(const QString &name) const { return m_enumerations.value(name); } + bool hasOwnEnumeration(const QString &name) const { return m_enumerations.contains(name); } + + bool hasEnumeration(const QString &name) const; + bool hasEnumerationKey(const QString &name) const; + bool hasOwnEnumerationKey(const QString &name) const; + QQmlJSMetaEnum enumeration(const QString &name) const; + QHash<QString, QQmlJSMetaEnum> enumerations() const; + + void setAnnotations(const QList<QQmlJSAnnotation> &annotation) { m_annotations = std::move(annotation); } + const QList<QQmlJSAnnotation> &annotations() const { return m_annotations; } + + QString filePath() const { return m_filePath; } + void setFilePath(const QString &file) { m_filePath = file; } + + // The name the type uses to refer to itself. Either C++ class name or base name of + // QML file. isComposite tells us if this is a C++ or a QML name. + QString internalName() const { return m_internalName; } + void setInternalName(const QString &internalName) { m_internalName = internalName; } + QString augmentedInternalName() const; + + // This returns a more user readable version of internalName / baseTypeName + static QString prettyName(QAnyStringView name); + + bool isComponentRootElement() const; + + void setAliases(const QStringList &aliases) { m_aliases = aliases; } + QStringList aliases() const { return m_aliases; } + + void setInterfaceNames(const QStringList& interfaces) { m_interfaceNames = interfaces; } + QStringList interfaceNames() const { return m_interfaceNames; } + + bool hasInterface(const QString &name) const; + bool hasOwnInterface(const QString &name) const { return m_interfaceNames.contains(name); } + + void setOwnDeferredNames(const QStringList &names) { m_ownDeferredNames = names; } + QStringList ownDeferredNames() const { return m_ownDeferredNames; } + void setOwnImmediateNames(const QStringList &names) { m_ownImmediateNames = names; } + QStringList ownImmediateNames() const { return m_ownImmediateNames; } + + bool isNameDeferred(const QString &name) const; + + // If isComposite(), this is the QML/JS name of the prototype. Otherwise it's the + // relevant base class (in the hierarchy starting from QObject) of a C++ type. + void setBaseTypeName(const QString &baseTypeName); + QString baseTypeName() const; + + QQmlJSScope::ConstPtr baseType() const { return m_baseType.scope; } + QTypeRevision baseTypeRevision() const { return m_baseType.revision; } + + QString moduleName() const; + QString ownModuleName() const { return m_moduleName; } + void setOwnModuleName(const QString &moduleName) { m_moduleName = moduleName; } + + void clearBaseType() { m_baseType = {}; } + void setBaseTypeError(const QString &baseTypeError); + QString baseTypeError() const; + + void addOwnProperty(const QQmlJSMetaProperty &prop) { m_properties.insert(prop.propertyName(), prop); } + QHash<QString, QQmlJSMetaProperty> ownProperties() const { return m_properties; } + QQmlJSMetaProperty ownProperty(const QString &name) const { return m_properties.value(name); } + bool hasOwnProperty(const QString &name) const { return m_properties.contains(name); } + + bool hasProperty(const QString &name) const; + QQmlJSMetaProperty property(const QString &name) const; + QHash<QString, QQmlJSMetaProperty> properties() const; + + void setPropertyLocallyRequired(const QString &name, bool isRequired); + bool isPropertyRequired(const QString &name) const; + bool isPropertyLocallyRequired(const QString &name) const; + + void addOwnPropertyBinding( + const QQmlJSMetaPropertyBinding &binding, + BindingTargetSpecifier specifier = BindingTargetSpecifier::SimplePropertyTarget); + QMultiHash<QString, QQmlJSMetaPropertyBinding> ownPropertyBindings() const; + QPair<QMultiHash<QString, QQmlJSMetaPropertyBinding>::const_iterator, + QMultiHash<QString, QQmlJSMetaPropertyBinding>::const_iterator> + ownPropertyBindings(const QString &name) const; + QList<QQmlJSMetaPropertyBinding> ownPropertyBindingsInQmlIROrder() const; + bool hasOwnPropertyBindings(const QString &name) const; + + bool hasPropertyBindings(const QString &name) const; + QList<QQmlJSMetaPropertyBinding> propertyBindings(const QString &name) const; + + struct AnnotatedScope; // defined later + static AnnotatedScope ownerOfProperty(const QQmlJSScope::ConstPtr &self, const QString &name); + + bool isResolved() const; + bool isFullyResolved() const; + + QString ownDefaultPropertyName() const { return m_defaultPropertyName; } + void setOwnDefaultPropertyName(const QString &name) { m_defaultPropertyName = name; } + QString defaultPropertyName() const; + + QString ownParentPropertyName() const { return m_parentPropertyName; } + void setOwnParentPropertyName(const QString &name) { m_parentPropertyName = name; } + QString parentPropertyName() const; + + QString ownAttachedTypeName() const { return m_attachedTypeName; } + void setOwnAttachedTypeName(const QString &name) { m_attachedTypeName = name; } + QQmlJSScope::ConstPtr ownAttachedType() const { return m_attachedType; } + + QString attachedTypeName() const; + QQmlJSScope::ConstPtr attachedType() const; + + QString extensionTypeName() const { return m_extensionTypeName; } + void setExtensionTypeName(const QString &name) { m_extensionTypeName = name; } + enum ExtensionKind { + NotExtension, + ExtensionType, + ExtensionJavaScript, + ExtensionNamespace, + }; + struct AnnotatedScope + { + QQmlJSScope::ConstPtr scope; + ExtensionKind extensionSpecifier = NotExtension; + }; + AnnotatedScope extensionType() const; + + QString valueTypeName() const { return m_valueTypeName; } + void setValueTypeName(const QString &name) { m_valueTypeName = name; } + QQmlJSScope::ConstPtr valueType() const { return m_valueType; } + QQmlJSScope::ConstPtr listType() const { return m_listType; } + QQmlJSScope::Ptr listType() { return m_listType; } + + void addOwnRuntimeFunctionIndex(QQmlJSMetaMethod::AbsoluteFunctionIndex index); + QQmlJSMetaMethod::AbsoluteFunctionIndex + ownRuntimeFunctionIndex(QQmlJSMetaMethod::RelativeFunctionIndex index) const; + + + /*! + * \internal + * + * Returns true for objects defined from Qml, and false for objects declared from C++. + */ + bool isComposite() const { return m_flags.testFlag(Composite); } + void setIsComposite(bool v) { m_flags.setFlag(Composite, v); } + + /*! + * \internal + * + * Returns true for JavaScript types, false for QML and C++ types. + */ + bool isJavaScriptBuiltin() const { return m_flags.testFlag(JavaScriptBuiltin); } + void setIsJavaScriptBuiltin(bool v) { m_flags.setFlag(JavaScriptBuiltin, v); } + + bool isScript() const { return m_flags.testFlag(Script); } + void setIsScript(bool v) { m_flags.setFlag(Script, v); } + + bool hasCustomParser() const { return m_flags.testFlag(CustomParser); } + void setHasCustomParser(bool v) { m_flags.setFlag(CustomParser, v); } + + bool isArrayScope() const { return m_flags.testFlag(Array); } + void setIsArrayScope(bool v) { m_flags.setFlag(Array, v); } + + bool isInlineComponent() const { return m_flags.testFlag(InlineComponent); } + void setIsInlineComponent(bool v) { m_flags.setFlag(InlineComponent, v); } + + bool isWrappedInImplicitComponent() const { return m_flags.testFlag(WrappedInImplicitComponent); } + void setIsWrappedInImplicitComponent(bool v) { m_flags.setFlag(WrappedInImplicitComponent, v); } + + bool extensionIsJavaScript() const { return m_flags.testFlag(ExtensionIsJavaScript); } + void setExtensionIsJavaScript(bool v) { m_flags.setFlag(ExtensionIsJavaScript, v); } + + bool extensionIsNamespace() const { return m_flags.testFlag(ExtensionIsNamespace); } + void setExtensionIsNamespace(bool v) { m_flags.setFlag(ExtensionIsNamespace, v); } + + bool isListProperty() const { return m_flags.testFlag(IsListProperty); } + void setIsListProperty(bool v) { m_flags.setFlag(IsListProperty, v); } + + bool isSingleton() const { return m_flags.testFlag(Singleton); } + void setIsSingleton(bool v) { m_flags.setFlag(Singleton, v); } + + bool enforcesScopedEnums() const; + void setEnforcesScopedEnumsFlag(bool v) { m_flags.setFlag(EnforcesScopedEnums, v); } + + bool isCreatable() const; + void setCreatableFlag(bool v) { m_flags.setFlag(Creatable, v); } + + bool isStructured() const; + void setStructuredFlag(bool v) { m_flags.setFlag(Structured, v); } + + void setAccessSemantics(AccessSemantics semantics) { m_semantics = semantics; } + AccessSemantics accessSemantics() const { return m_semantics; } + bool isReferenceType() const { return m_semantics == QQmlJSScope::AccessSemantics::Reference; } + bool isValueType() const { return m_semantics == QQmlJSScope::AccessSemantics::Value; } + + std::optional<JavaScriptIdentifier> jsIdentifier(const QString &id) const; + std::optional<JavaScriptIdentifier> ownJSIdentifier(const QString &id) const; + + QQmlJS::ConstPtrWrapperIterator childScopesBegin() const { return m_childScopes.constBegin(); } + QQmlJS::ConstPtrWrapperIterator childScopesEnd() const { return m_childScopes.constEnd(); } + + void setInlineComponentName(const QString &inlineComponentName); + std::optional<QString> inlineComponentName() const; + InlineComponentOrDocumentRootName enclosingInlineComponentName() const; + + QVector<QQmlJSScope::Ptr> childScopes(); + + QVector<QQmlJSScope::ConstPtr> childScopes() const; + + static QTypeRevision resolveTypes( + const Ptr &self, const QQmlJS::ContextualTypes &contextualTypes, + QSet<QString> *usedTypes = nullptr); + static void resolveNonEnumTypes( + const QQmlJSScope::Ptr &self, const QQmlJS::ContextualTypes &contextualTypes, + QSet<QString> *usedTypes = nullptr); + static void resolveEnums( + const QQmlJSScope::Ptr &self, const QQmlJS::ContextualTypes &contextualTypes, + QSet<QString> *usedTypes = nullptr); + static void resolveList( + const QQmlJSScope::Ptr &self, const QQmlJSScope::ConstPtr &arrayType); + static void resolveGroup( + const QQmlJSScope::Ptr &self, const QQmlJSScope::ConstPtr &baseType, + const QQmlJS::ContextualTypes &contextualTypes, + QSet<QString> *usedTypes = nullptr); + + void setSourceLocation(const QQmlJS::SourceLocation &sourceLocation); + QQmlJS::SourceLocation sourceLocation() const; + + static QQmlJSScope::ConstPtr nonCompositeBaseType(const QQmlJSScope::ConstPtr &type); + + static QTypeRevision + nonCompositeBaseRevision(const ImportedScope<QQmlJSScope::ConstPtr> &scope); + + bool isSameType(const QQmlJSScope::ConstPtr &otherScope) const; + bool inherits(const QQmlJSScope::ConstPtr &base) const; + bool canAssign(const QQmlJSScope::ConstPtr &derived) const; + + bool isInCustomParserParent() const; + + + static ImportedScope<QQmlJSScope::ConstPtr> findType(const QString &name, + const QQmlJS::ContextualTypes &contextualTypes, + QSet<QString> *usedTypes = nullptr); + + static QQmlSA::Element createQQmlSAElement(const ConstPtr &); + static QQmlSA::Element createQQmlSAElement(ConstPtr &&); + static const QQmlJSScope::ConstPtr &scope(const QQmlSA::Element &); + static constexpr qsizetype sizeofQQmlSAElement() { return QQmlSA::Element::sizeofElement; } + +private: + /*! \internal + + Minimal information about a QQmlJSMetaPropertyBinding that allows it to + be manipulated similarly to QmlIR::Binding. + */ + template <typename T> + friend class QTypeInfo; // so that we can Q_DECLARE_TYPEINFO QmlIRCompatibilityBindingData + struct QmlIRCompatibilityBindingData + { + QmlIRCompatibilityBindingData() = default; + QmlIRCompatibilityBindingData(const QString &name, quint32 offset) + : propertyName(name), sourceLocationOffset(offset) + { + } + QString propertyName; // bound property name + quint32 sourceLocationOffset = 0; // binding's source location offset + }; + + QQmlJSScope() = default; + QQmlJSScope(const QQmlJSScope &) = default; + QQmlJSScope &operator=(const QQmlJSScope &) = default; + static QTypeRevision resolveType( + const QQmlJSScope::Ptr &self, const QQmlJS::ContextualTypes &contextualTypes, + QSet<QString> *usedTypes); + static void updateChildScope( + const QQmlJSScope::Ptr &childScope, const QQmlJSScope::Ptr &self, + const QQmlJS::ContextualTypes &contextualTypes, QSet<QString> *usedTypes); + + void addOwnPropertyBindingInQmlIROrder(const QQmlJSMetaPropertyBinding &binding, + BindingTargetSpecifier specifier); + bool hasEnforcesScopedEnumsFlag() const { return m_flags & EnforcesScopedEnums; } + bool hasCreatableFlag() const { return m_flags & Creatable; } + bool hasStructuredFlag() const { return m_flags & Structured; } + + QHash<QString, JavaScriptIdentifier> m_jsIdentifiers; + + QMultiHash<QString, QQmlJSMetaMethod> m_methods; + QHash<QString, QQmlJSMetaProperty> m_properties; + QMultiHash<QString, QQmlJSMetaPropertyBinding> m_propertyBindings; + + // a special QmlIR compatibility bindings array, ordered the same way as + // bindings in QmlIR::Object + QList<QmlIRCompatibilityBindingData> m_propertyBindingsArray; + + // same as QmlIR::Object::runtimeFunctionIndices + QList<QQmlJSMetaMethod::AbsoluteFunctionIndex> m_runtimeFunctionIndices; + + QHash<QString, QQmlJSMetaEnum> m_enumerations; + + QVector<QQmlJSAnnotation> m_annotations; + QVector<QQmlJSScope::Ptr> m_childScopes; + QQmlJSScope::WeakPtr m_parentScope; + + QString m_filePath; + QString m_internalName; + QString m_baseTypeNameOrError; + + // We only need the revision for the base type as inheritance is + // the only relation between two types where the revisions matter. + ImportedScope<QQmlJSScope::WeakConstPtr> m_baseType; + + ScopeType m_scopeType = ScopeType::QMLScope; + QStringList m_aliases; + QStringList m_interfaceNames; + QStringList m_ownDeferredNames; + QStringList m_ownImmediateNames; + + QString m_defaultPropertyName; + QString m_parentPropertyName; + /*! \internal + * The attached type name. + * This is an internal name, from a c++ type or a synthetic jsrootgen. + */ + QString m_attachedTypeName; + QStringList m_requiredPropertyNames; + QQmlJSScope::WeakConstPtr m_attachedType; + + /*! \internal + * The Value type name. + * This is an internal name, from a c++ type or a synthetic jsrootgen. + */ + QString m_valueTypeName; + QQmlJSScope::WeakConstPtr m_valueType; + QQmlJSScope::Ptr m_listType; + + /*! + The extension is provided as either a type (QML_{NAMESPACE_}EXTENDED) or as a + namespace (QML_EXTENDED_NAMESPACE). + The bool HasExtensionNamespace helps differentiating both cases, as namespaces + have a more limited lookup capaility. + This is an internal name, from a c++ type or a synthetic jsrootgen. + */ + QString m_extensionTypeName; + QQmlJSScope::WeakConstPtr m_extensionType; + + Flags m_flags = Creatable; // all types are marked as creatable by default. + AccessSemantics m_semantics = AccessSemantics::Reference; + + QQmlJS::SourceLocation m_sourceLocation; + + QString m_moduleName; + + std::optional<QString> m_inlineComponentName; +}; + +inline QQmlJSScope::Ptr QQmlJSScope::parentScope() +{ + return m_parentScope.toStrongRef(); +} + +inline QQmlJSScope::ConstPtr QQmlJSScope::parentScope() const +{ + QT_WARNING_PUSH +#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU < 1400 && Q_CC_GNU >= 1200 + QT_WARNING_DISABLE_GCC("-Wuse-after-free") +#endif + return QQmlJSScope::WeakConstPtr(m_parentScope).toStrongRef(); + QT_WARNING_POP +} + +inline QMultiHash<QString, QQmlJSMetaPropertyBinding> QQmlJSScope::ownPropertyBindings() const +{ + return m_propertyBindings; +} + +inline QPair<QMultiHash<QString, QQmlJSMetaPropertyBinding>::const_iterator, QMultiHash<QString, QQmlJSMetaPropertyBinding>::const_iterator> QQmlJSScope::ownPropertyBindings(const QString &name) const +{ + return m_propertyBindings.equal_range(name); +} + +inline bool QQmlJSScope::hasOwnPropertyBindings(const QString &name) const +{ + return m_propertyBindings.contains(name); +} + +inline QQmlJSMetaMethod::AbsoluteFunctionIndex QQmlJSScope::ownRuntimeFunctionIndex(QQmlJSMetaMethod::RelativeFunctionIndex index) const +{ + const int i = static_cast<int>(index); + Q_ASSERT(i >= 0); + Q_ASSERT(i < int(m_runtimeFunctionIndices.size())); + return m_runtimeFunctionIndices[i]; +} + +inline void QQmlJSScope::setInlineComponentName(const QString &inlineComponentName) +{ + Q_ASSERT(isInlineComponent()); + m_inlineComponentName = inlineComponentName; +} + +inline QVector<QQmlJSScope::Ptr> QQmlJSScope::childScopes() +{ + return m_childScopes; +} + +inline void QQmlJSScope::setSourceLocation(const QQmlJS::SourceLocation &sourceLocation) +{ + m_sourceLocation = sourceLocation; +} + +inline QQmlJS::SourceLocation QQmlJSScope::sourceLocation() const +{ + return m_sourceLocation; +} + +inline QQmlJSScope::ConstPtr QQmlJSScope::nonCompositeBaseType(const ConstPtr &type) +{ + for (QQmlJSScope::ConstPtr base = type; base; base = base->baseType()) { + if (!base->isComposite()) + return base; + } + return {}; +} + +Q_DECLARE_TYPEINFO(QQmlJSScope::QmlIRCompatibilityBindingData, Q_RELOCATABLE_TYPE); + +template<> +class Q_QMLCOMPILER_EXPORT QDeferredFactory<QQmlJSScope> +{ +public: + using TypeReader = std::function<QList<QQmlJS::DiagnosticMessage>( + QQmlJSImporter *importer, const QString &filePath, + const QSharedPointer<QQmlJSScope> &scopeToPopulate)>; + QDeferredFactory() = default; + + QDeferredFactory(QQmlJSImporter *importer, const QString &filePath, + const TypeReader &typeReader = {}); + + bool isValid() const + { + return !m_filePath.isEmpty() && m_importer != nullptr; + } + + QString internalName() const + { + return QFileInfo(m_filePath).baseName(); + } + + QString filePath() const { return m_filePath; } + + QQmlJSImporter* importer() const { return m_importer; } + + void setIsSingleton(bool isSingleton) + { + m_isSingleton = isSingleton; + } + + void setModuleName(const QString &moduleName) { m_moduleName = moduleName; } + +private: + friend class QDeferredSharedPointer<QQmlJSScope>; + friend class QDeferredSharedPointer<const QQmlJSScope>; + friend class QDeferredWeakPointer<QQmlJSScope>; + friend class QDeferredWeakPointer<const QQmlJSScope>; + + // Should only be called when lazy-loading the type in a deferred pointer. + void populate(const QSharedPointer<QQmlJSScope> &scope) const; + + QString m_filePath; + QQmlJSImporter *m_importer = nullptr; + bool m_isSingleton = false; + QString m_moduleName; + TypeReader m_typeReader; +}; + +using QQmlJSExportedScope = QQmlJSScope::ExportedScope<QQmlJSScope::Ptr>; +using QQmlJSImportedScope = QQmlJSScope::ImportedScope<QQmlJSScope::ConstPtr>; + +QT_END_NAMESPACE + +#endif // QQMLJSSCOPE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsscopesbyid_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsscopesbyid_p.h new file mode 100644 index 0000000000000000000000000000000000000000..732d242655ce2af4b2551247194e5846ac2ba04f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsscopesbyid_p.h @@ -0,0 +1,129 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSSCOPESBYID_P_H +#define QQMLJSSCOPESBYID_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + + +#include "qqmljsscope_p.h" + +#include <QtCore/qhash.h> +#include <QtCore/qstring.h> + +QT_BEGIN_NAMESPACE + +enum QQmlJSScopesByIdOption: char { + Default = 0, + AssumeComponentsAreBound = 1, +}; +Q_DECLARE_FLAGS(QQmlJSScopesByIdOptions, QQmlJSScopesByIdOption); + +class QQmlJSScopesById +{ +public: + bool componentsAreBound() const { return m_componentsAreBound; } + void setComponentsAreBound(bool bound) { m_componentsAreBound = bound; } + + void setSignaturesAreEnforced(bool enforced) { m_signaturesAreEnforced = enforced; } + bool signaturesAreEnforced() const { return m_signaturesAreEnforced; } + + void setValueTypesAreAddressable(bool addressable) { m_valueTypesAreAddressable = addressable; } + bool valueTypesAreAddressable() const { return m_valueTypesAreAddressable; } + + QString id(const QQmlJSScope::ConstPtr &scope, const QQmlJSScope::ConstPtr &referrer, + QQmlJSScopesByIdOptions options = Default) const + { + const QQmlJSScope::ConstPtr referrerRoot = componentRoot(referrer); + for (auto it = m_scopesById.begin(), end = m_scopesById.end(); it != end; ++it) { + if (*it == scope && isComponentVisible(componentRoot(*it), referrerRoot, options)) + return it.key(); + } + return QString(); + } + + /*! + \internal + Returns the scope that has id \a id in the component to which \a referrer belongs to. + If no such scope exists, a null scope is returned. + */ + QQmlJSScope::ConstPtr scope(const QString &id, const QQmlJSScope::ConstPtr &referrer, + QQmlJSScopesByIdOptions options = Default) const + { + Q_ASSERT(!id.isEmpty()); + const auto range = m_scopesById.equal_range(id); + if (range.first == range.second) + return QQmlJSScope::ConstPtr(); + const QQmlJSScope::ConstPtr referrerRoot = componentRoot(referrer); + + for (auto it = range.first; it != range.second; ++it) { + if (isComponentVisible(componentRoot(*it), referrerRoot, options)) + return *it; + } + + return QQmlJSScope::ConstPtr(); + } + + void insert(const QString &id, const QQmlJSScope::ConstPtr &scope) + { + Q_ASSERT(!id.isEmpty()); + m_scopesById.insert(id, scope); + } + + void clear() { m_scopesById.clear(); } + + /*! + \internal + Returns \c true if \a id exists anywhere in the current document. + This is still allowed if the other occurrence is in a different (inline) component. + Check the return value of scope to know whether the id has already been assigned + in a givne scope. + */ + bool existsAnywhereInDocument(const QString &id) const { return m_scopesById.contains(id); } + +private: + static QQmlJSScope::ConstPtr componentRoot(const QQmlJSScope::ConstPtr &inner) + { + QQmlJSScope::ConstPtr scope = inner; + while (scope && !scope->isComponentRootElement() && !scope->isInlineComponent()) { + if (QQmlJSScope::ConstPtr parent = scope->parentScope()) + scope = parent; + else + break; + } + return scope; + } + + bool isComponentVisible(const QQmlJSScope::ConstPtr &observed, + const QQmlJSScope::ConstPtr &observer, + QQmlJSScopesByIdOptions options) const + { + if (!m_componentsAreBound && !options.testAnyFlag(AssumeComponentsAreBound)) + return observed == observer; + + for (QQmlJSScope::ConstPtr scope = observer; scope; scope = scope->parentScope()) { + if (scope == observed) + return true; + } + + return false; + } + + QMultiHash<QString, QQmlJSScope::ConstPtr> m_scopesById; + bool m_componentsAreBound = false; + bool m_signaturesAreEnforced = true; + bool m_valueTypesAreAddressable = false; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSSCOPESBYID_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsshadowcheck_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsshadowcheck_p.h new file mode 100644 index 0000000000000000000000000000000000000000..57ab17b8a89c7e7c190cf923facfb9439be42c76 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsshadowcheck_p.h @@ -0,0 +1,70 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSSHADOWCHECK_P_H +#define QQMLJSSHADOWCHECK_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <private/qqmljscompilepass_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLCOMPILER_EXPORT QQmlJSShadowCheck : public QQmlJSCompilePass +{ +public: + QQmlJSShadowCheck(const QV4::Compiler::JSUnitGenerator *jsUnitGenerator, + const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger, + BasicBlocks basicBlocks, InstructionAnnotations annotations) + : QQmlJSCompilePass(jsUnitGenerator, typeResolver, logger, basicBlocks, annotations) + {} + + ~QQmlJSShadowCheck() = default; + + BlocksAndAnnotations run(const Function *function, QQmlJS::DiagnosticMessage *error); + +private: + struct ResettableStore { + QQmlJSRegisterContent accumulatorIn; + int instructionOffset = -1; + }; + + void handleStore(int base, const QString &memberName); + + void generate_LoadProperty(int nameIndex) override; + void generate_GetLookup(int index) override; + void generate_GetOptionalLookup(int index, int offset) override; + void generate_StoreProperty(int nameIndex, int base) override; + void generate_SetLookup(int index, int base) override; + void generate_CallProperty(int nameIndex, int base, int argc, int argv) override; + void generate_CallPropertyLookup(int nameIndex, int base, int argc, int argv) override; + + QV4::Moth::ByteCodeHandler::Verdict startInstruction(QV4::Moth::Instr::Type) override; + void endInstruction(QV4::Moth::Instr::Type) override; + + enum Shadowability { NotShadowable, Shadowable }; + Shadowability checkShadowing( + const QQmlJSRegisterContent &baseType, const QString &propertyName, int baseRegister); + + void checkResettable(const QQmlJSRegisterContent &accumulatorIn, int instructionOffset); + + Shadowability checkBaseType(const QQmlJSRegisterContent &baseType); + + QList<ResettableStore> m_resettableStores; + QList<QQmlJSRegisterContent> m_baseTypes; + QSet<QQmlJSRegisterContent> m_adjustedTypes; + + State m_state; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSSHADOWCHECK_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsstoragegeneralizer_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsstoragegeneralizer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b34e2a14075c3b7f69106ec2b6afa97598dd841a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsstoragegeneralizer_p.h @@ -0,0 +1,40 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSSTORAGEGENERALIZER_P_H +#define QQMLJSSTORAGEGENERALIZER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <private/qqmljscompilepass_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLCOMPILER_EXPORT QQmlJSStorageGeneralizer : public QQmlJSCompilePass +{ +public: + QQmlJSStorageGeneralizer(const QV4::Compiler::JSUnitGenerator *jsUnitGenerator, + const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger, + BasicBlocks basicBlocks, InstructionAnnotations annotations) + : QQmlJSCompilePass(jsUnitGenerator, typeResolver, logger, basicBlocks, annotations) + {} + + BlocksAndAnnotations run(Function *function, QQmlJS::DiagnosticMessage *error); + +protected: + // We don't have to use the byte code here. We only transform the instruction annotations. + Verdict startInstruction(QV4::Moth::Instr::Type) override { return SkipInstruction; } + void endInstruction(QV4::Moth::Instr::Type) override {} +}; + +QT_END_NAMESPACE + +#endif // QQMLJSSTORAGEGENERALIZER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstypedescriptionreader_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstypedescriptionreader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7dbdcadcf9694cf4a21ef5e3a680541c97879e3e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstypedescriptionreader_p.h @@ -0,0 +1,84 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSTYPEDESCRIPTIONREADER_P_H +#define QQMLJSTYPEDESCRIPTIONREADER_P_H + +#include <qtqmlcompilerexports.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include "qqmljsscope_p.h" + +#include <QtQml/private/qqmljsastfwd_p.h> + +// for Q_DECLARE_TR_FUNCTIONS +#include <QtCore/qcoreapplication.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLCOMPILER_EXPORT QQmlJSTypeDescriptionReader +{ + Q_DECLARE_TR_FUNCTIONS(QQmlJSTypeDescriptionReader) +public: + QQmlJSTypeDescriptionReader() = default; + explicit QQmlJSTypeDescriptionReader(QString fileName, QString data) + : m_fileName(std::move(fileName)), m_source(std::move(data)) {} + + bool operator()(QList<QQmlJSExportedScope> *objects, QStringList *dependencies); + + QString errorMessage() const { return m_errorMessage; } + QString warningMessage() const { return m_warningMessage; } + +private: + void readDocument(QQmlJS::AST::UiProgram *ast); + void readModule(QQmlJS::AST::UiObjectDefinition *ast); + void readDependencies(QQmlJS::AST::UiScriptBinding *ast); + void readComponent(QQmlJS::AST::UiObjectDefinition *ast); + void readSignalOrMethod(QQmlJS::AST::UiObjectDefinition *ast, bool isMethod, + const QQmlJSScope::Ptr &scope); + void readProperty(QQmlJS::AST::UiObjectDefinition *ast, const QQmlJSScope::Ptr &scope); + void readEnum(QQmlJS::AST::UiObjectDefinition *ast, const QQmlJSScope::Ptr &scope); + void readParameter(QQmlJS::AST::UiObjectDefinition *ast, QQmlJSMetaMethod *metaMethod); + + QString readStringBinding(QQmlJS::AST::UiScriptBinding *ast); + bool readBoolBinding(QQmlJS::AST::UiScriptBinding *ast); + double readNumericBinding(QQmlJS::AST::UiScriptBinding *ast); + QTypeRevision readNumericVersionBinding(QQmlJS::AST::UiScriptBinding *ast); + int readIntBinding(QQmlJS::AST::UiScriptBinding *ast); + QList<QQmlJSScope::Export> readExports(QQmlJS::AST::UiScriptBinding *ast); + void readAliases(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope); + void readInterfaces(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope); + void checkMetaObjectRevisions( + QQmlJS::AST::UiScriptBinding *ast, QList<QQmlJSScope::Export> *exports); + + QStringList readStringList(QQmlJS::AST::UiScriptBinding *ast); + void readDeferredNames(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope); + void readImmediateNames(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope); + void readEnumValues(QQmlJS::AST::UiScriptBinding *ast, QQmlJSMetaEnum *metaEnum); + + void addError(const QQmlJS::SourceLocation &loc, const QString &message); + void addWarning(const QQmlJS::SourceLocation &loc, const QString &message); + + QQmlJS::AST::ArrayPattern *getArray(QQmlJS::AST::UiScriptBinding *ast); + + QString m_fileName; + QString m_source; + QString m_errorMessage; + QString m_warningMessage; + QList<QQmlJSExportedScope> *m_objects = nullptr; + QStringList *m_dependencies = nullptr; + int m_currentCtorIndex = 0; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSTYPEDESCRIPTIONREADER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstypepropagator_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstypepropagator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e4f30cc13390427740d1135bf322432bbded7993 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstypepropagator_p.h @@ -0,0 +1,274 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSTYPEPROPAGATOR_P_H +#define QQMLJSTYPEPROPAGATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <private/qqmljsast_p.h> +#include <private/qqmljsscope_p.h> +#include <private/qqmljscompilepass_p.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlSA { +class PassManager; +}; + +struct Q_QMLCOMPILER_EXPORT QQmlJSTypePropagator : public QQmlJSCompilePass +{ + QQmlJSTypePropagator(const QV4::Compiler::JSUnitGenerator *unitGenerator, + const QQmlJSTypeResolver *typeResolver, QQmlJSLogger *logger, + BasicBlocks basicBlocks = {}, InstructionAnnotations annotations = {}, + QQmlSA::PassManager *passManager = nullptr); + + BlocksAndAnnotations run(const Function *m_function, QQmlJS::DiagnosticMessage *error); + + void generate_Ret() override; + void generate_Debug() override; + void generate_LoadConst(int index) override; + void generate_LoadZero() override; + void generate_LoadTrue() override; + void generate_LoadFalse() override; + void generate_LoadNull() override; + void generate_LoadUndefined() override; + void generate_LoadInt(int value) override; + void generate_MoveConst(int constIndex, int destTemp) override; + void generate_LoadReg(int reg) override; + void generate_StoreReg(int reg) override; + void generate_MoveReg(int srcReg, int destReg) override; + void generate_LoadImport(int index) override; + void generate_LoadLocal(int index) override; + void generate_StoreLocal(int index) override; + void generate_LoadScopedLocal(int scope, int index) override; + void generate_StoreScopedLocal(int scope, int index) override; + void generate_LoadRuntimeString(int stringId) override; + void generate_MoveRegExp(int regExpId, int destReg) override; + void generate_LoadClosure(int value) override; + void generate_LoadName(int nameIndex) override; + void generate_LoadGlobalLookup(int index) override; + void generate_LoadQmlContextPropertyLookup(int index) override; + void generate_StoreNameCommon(int nameIndex); + void generate_StoreNameSloppy(int nameIndex) override; + void generate_StoreNameStrict(int name) override; + void generate_LoadElement(int base) override; + void generate_StoreElement(int base, int index) override; + void generate_LoadProperty(int nameIndex) override; + void generate_LoadOptionalProperty(int name, int offset) override; + void generate_GetLookup(int index) override; + void generate_GetOptionalLookup(int index, int offset) override; + void generate_StoreProperty(int name, int base) override; + void generate_SetLookup(int index, int base) override; + void generate_LoadSuperProperty(int property) override; + void generate_StoreSuperProperty(int property) override; + void generate_Yield() override; + void generate_YieldStar() override; + void generate_Resume(int) override; + + void generate_CallValue(int name, int argc, int argv) override; + void generate_CallWithReceiver(int name, int thisObject, int argc, int argv) override; + void generate_CallProperty(int name, int base, int argc, int argv) override; + void generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv) override; + void generate_CallName(int name, int argc, int argv) override; + void generate_CallPossiblyDirectEval(int argc, int argv) override; + void generate_CallGlobalLookup(int index, int argc, int argv) override; + void generate_CallQmlContextPropertyLookup(int index, int argc, int argv) override; + void generate_CallWithSpread(int func, int thisObject, int argc, int argv) override; + void generate_TailCall(int func, int thisObject, int argc, int argv) override; + void generate_Construct(int func, int argc, int argv) override; + void generate_ConstructWithSpread(int func, int argc, int argv) override; + void generate_SetUnwindHandler(int offset) override; + void generate_UnwindDispatch() override; + void generate_UnwindToLabel(int level, int offset) override; + void generate_DeadTemporalZoneCheck(int name) override; + void generate_ThrowException() override; + void generate_GetException() override; + void generate_SetException() override; + void generate_CreateCallContext() override; + void generate_PushCatchContext(int index, int name) override; + void generate_PushWithContext() override; + void generate_PushBlockContext(int index) override; + void generate_CloneBlockContext() override; + void generate_PushScriptContext(int index) override; + void generate_PopScriptContext() override; + void generate_PopContext() override; + void generate_GetIterator(int iterator) override; + void generate_IteratorNext(int value, int offset) override; + void generate_IteratorNextForYieldStar(int iterator, int object, int offset) override; + void generate_IteratorClose() override; + void generate_DestructureRestElement() override; + void generate_DeleteProperty(int base, int index) override; + void generate_DeleteName(int name) override; + void generate_TypeofName(int name) override; + void generate_TypeofValue() override; + void generate_DeclareVar(int varName, int isDeletable) override; + void generate_DefineArray(int argc, int args) override; + void generate_DefineObjectLiteral(int internalClassId, int argc, int args) override; + void generate_CreateClass(int classIndex, int heritage, int computedNames) override; + void generate_CreateMappedArgumentsObject() override; + void generate_CreateUnmappedArgumentsObject() override; + void generate_CreateRestParameter(int argIndex) override; + void generate_ConvertThisToObject() override; + void generate_LoadSuperConstructor() override; + void generate_ToObject() override; + void generate_Jump(int offset) override; + void generate_JumpTrue(int offset) override; + void generate_JumpFalse(int offset) override; + void generate_JumpNoException(int offset) override; + void generate_JumpNotUndefined(int offset) override; + void generate_CheckException() override; + void generate_CmpEqNull() override; + void generate_CmpNeNull() override; + void generate_CmpEqInt(int lhsConst) override; + void generate_CmpNeInt(int lhs) override; + void generate_CmpEq(int lhs) override; + void generate_CmpNe(int lhs) override; + void generate_CmpGt(int lhs) override; + void generate_CmpGe(int lhs) override; + void generate_CmpLt(int lhs) override; + void generate_CmpLe(int lhs) override; + void generate_CmpStrictEqual(int lhs) override; + void generate_CmpStrictNotEqual(int lhs) override; + void generate_CmpIn(int lhs) override; + void generate_CmpInstanceOf(int lhs) override; + void generate_As(int lhs) override; + void generate_UNot() override; + void generate_UPlus() override; + void generate_UMinus() override; + void generate_UCompl() override; + void generate_Increment() override; + void generate_Decrement() override; + void generate_Add(int lhs) override; + void generate_BitAnd(int lhs) override; + void generate_BitOr(int lhs) override; + void generate_BitXor(int lhs) override; + void generate_UShr(int lhs) override; + void generate_Shr(int lhs) override; + void generate_Shl(int lhs) override; + void generate_BitAndConst(int rhsConst) override; + void generate_BitOrConst(int rhsConst) override; + void generate_BitXorConst(int rhsConst) override; + void generate_UShrConst(int rhsConst) override; + void generate_ShrConst(int rhs) override; + void generate_ShlConst(int rhs) override; + void generate_Exp(int lhs) override; + void generate_Mul(int lhs) override; + void generate_Div(int lhs) override; + void generate_Mod(int lhs) override; + void generate_Sub(int lhs) override; + void generate_InitializeBlockDeadTemporalZone(int firstReg, int count) override; + void generate_ThrowOnNullOrUndefined() override; + void generate_GetTemplateObject(int index) override; + + bool checkForEnumProblems(const QQmlJSRegisterContent &base, const QString &propertyName); + + Verdict startInstruction(QV4::Moth::Instr::Type instr) override; + void endInstruction(QV4::Moth::Instr::Type instr) override; + +private: + struct ExpectedRegisterState + { + int originatingOffset = 0; + VirtualRegisters registers; + }; + + struct PassState : QQmlJSCompilePass::State + { + InstructionAnnotations annotations; + QSet<int> jumpTargets; + bool skipInstructionsUntilNextJumpTarget = false; + bool needsMorePasses = false; + }; + + void handleUnqualifiedAccess(const QString &name, bool isMethod) const; + void checkDeprecated(QQmlJSScope::ConstPtr scope, const QString &name, bool isMethod) const; + bool isCallingProperty(QQmlJSScope::ConstPtr scope, const QString &name) const; + + enum PropertyResolution { + PropertyMissing, + PropertyTypeUnresolved, + PropertyFullyResolved + }; + + PropertyResolution propertyResolution(QQmlJSScope::ConstPtr scope, const QString &type) const; + QQmlJS::SourceLocation getCurrentSourceLocation() const; + QQmlJS::SourceLocation getCurrentBindingSourceLocation() const; + + void checkConversion(const QQmlJSRegisterContent &from, const QQmlJSRegisterContent &to); + void generateUnaryArithmeticOperation(QQmlJSTypeResolver::UnaryOperator op); + + QQmlJSRegisterContent propagateBinaryOperation(QSOperator::Op op, int lhs); + void generateBinaryArithmeticOperation(QSOperator::Op op, int lhs); + void generateBinaryConstArithmeticOperation(QSOperator::Op op); + + void propagateCall( + const QList<QQmlJSMetaMethod> &methods, int argc, int argv, + const QQmlJSScope::ConstPtr &scope); + bool propagateTranslationMethod(const QList<QQmlJSMetaMethod> &methods, int argc, int argv); + void propagateStringArgCall(int argv); + bool propagateArrayMethod(const QString &name, int argc, int argv, const QQmlJSRegisterContent &valueType); + void propagatePropertyLookup( + const QString &name, int lookupIndex = QQmlJSRegisterContent::InvalidLookupIndex); + void propagateScopeLookupCall(const QString &functionName, int argc, int argv); + void saveRegisterStateForJump(int offset); + bool canConvertFromTo(const QQmlJSRegisterContent &from, const QQmlJSRegisterContent &to); + + QString registerName(int registerIndex) const; + + QQmlJSRegisterContent checkedInputRegister(int reg); + QQmlJSMetaMethod bestMatchForCall(const QList<QQmlJSMetaMethod> &methods, int argc, int argv, + QStringList *errors); + + void setAccumulator(const QQmlJSRegisterContent &content); + void setRegister(int index, const QQmlJSRegisterContent &content); + void mergeRegister(int index, const QQmlJSRegisterContent &a, const QQmlJSRegisterContent &b); + + void addReadRegister(int index, const QQmlJSRegisterContent &convertTo); + void addReadAccumulator(const QQmlJSRegisterContent &convertTo) + { + addReadRegister(Accumulator, convertTo); + } + + void recordEqualsNullType(); + void recordEqualsIntType(); + void recordEqualsType(int lhs); + void recordCompareType(int lhs); + + // helper functions to deal with special cases in generate_ methods + void generate_CallProperty_SCMath(int base, int arcg, int argv); + void generate_CallProperty_SCconsole(int base, int argc, int argv); + void generate_Construct_SCDate(int argc, int argv); + void generate_Construct_SCArray(int argc, int argv); + + // helper functions to perform QQmlSA checks + void generate_ret_SAcheck(); + void generate_LoadQmlContextPropertyLookup_SAcheck(const QString &name); + void generate_StoreNameCommon_SAcheck(const QQmlJSRegisterContent &in, const QString &name); + void propagatePropertyLookup_SAcheck(const QString &propertyName); + void generate_StoreProperty_SAcheck(const QString propertyName, const QQmlJSRegisterContent &callBase); + void generate_callProperty_SAcheck(const QString propertyName, const QQmlJSScope::ConstPtr &baseType); + + + QQmlJSRegisterContent m_returnType; + QQmlSA::PassManager *m_passManager = nullptr; + QQmlJSScope::ConstPtr m_attachedContext; + + // Not part of the state, as the back jumps are the reason for running multiple passes + QMultiHash<int, ExpectedRegisterState> m_jumpOriginRegisterStateByTargetInstructionOffset; + + InstructionAnnotations m_prevStateAnnotations; + PassState m_state; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSTYPEPROPAGATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstypereader_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstypereader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..afa13887c151a60ed6541fc099cbee150b4ff588 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstypereader_p.h @@ -0,0 +1,49 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSTYPEREADER_P_H +#define QQMLJSTYPEREADER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include "qqmljsscope_p.h" +#include "qqmljsimporter_p.h" +#include "qqmljsresourcefilemapper_p.h" + +#include <QtQml/private/qqmljsastfwd_p.h> +#include <QtQml/private/qqmljsdiagnosticmessage_p.h> + +#include <QtCore/qpair.h> +#include <QtCore/qset.h> + +QT_BEGIN_NAMESPACE + +class QQmlJSTypeReader +{ +public: + QQmlJSTypeReader(QQmlJSImporter *importer, const QString &file) + : m_importer(importer) + , m_file(file) + {} + + bool operator()(const QSharedPointer<QQmlJSScope> &scope); + QList<QQmlJS::DiagnosticMessage> errors() const { return m_errors; } + +private: + QQmlJSImporter *m_importer; + QString m_file; + QStringList m_qmldirFiles; + QList<QQmlJS::DiagnosticMessage> m_errors; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSTYPEREADER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstyperesolver_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstyperesolver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c04286a7993a4461d284bebae1508ceb555d3eec --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljstyperesolver_p.h @@ -0,0 +1,344 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSTYPERESOLVER_P_H +#define QQMLJSTYPERESOLVER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <memory> +#include <qtqmlcompilerexports.h> + +#include <private/qqmlirbuilder_p.h> +#include <private/qqmljsast_p.h> +#include "qqmljsimporter_p.h" +#include "qqmljslogger_p.h" +#include "qqmljsregistercontent_p.h" +#include "qqmljsresourcefilemapper_p.h" +#include "qqmljsscope_p.h" +#include "qqmljsscopesbyid_p.h" + +QT_BEGIN_NAMESPACE + +class QQmlJSImportVisitor; +class Q_QMLCOMPILER_EXPORT QQmlJSTypeResolver +{ +public: + enum ParentMode { UseDocumentParent, UseParentProperty }; + enum CloneMode { CloneTypes, DoNotCloneTypes }; + enum ListMode { UseListProperty, UseQObjectList }; + + QQmlJSTypeResolver(QQmlJSImporter *importer); + + // Note: must be called after the construction to read the QML program + void init(QQmlJSImportVisitor *visitor, QQmlJS::AST::Node *program); + + QQmlJSScope::ConstPtr voidType() const { return m_voidType; } + QQmlJSScope::ConstPtr emptyType() const { return m_emptyType; } + QQmlJSScope::ConstPtr nullType() const { return m_nullType; } + QQmlJSScope::ConstPtr realType() const { return m_realType; } + QQmlJSScope::ConstPtr floatType() const { return m_floatType; } + QQmlJSScope::ConstPtr int8Type() const { return m_int8Type; } + QQmlJSScope::ConstPtr uint8Type() const { return m_uint8Type; } + QQmlJSScope::ConstPtr int16Type() const { return m_int16Type; } + QQmlJSScope::ConstPtr uint16Type() const { return m_uint16Type; } + QQmlJSScope::ConstPtr int32Type() const { return m_int32Type; } + QQmlJSScope::ConstPtr uint32Type() const { return m_uint32Type; } + QQmlJSScope::ConstPtr int64Type() const { return m_int64Type; } + QQmlJSScope::ConstPtr uint64Type() const { return m_uint64Type; } + QQmlJSScope::ConstPtr sizeType() const { return m_sizeType; } + QQmlJSScope::ConstPtr boolType() const { return m_boolType; } + QQmlJSScope::ConstPtr stringType() const { return m_stringType; } + QQmlJSScope::ConstPtr stringListType() const { return m_stringListType; } + QQmlJSScope::ConstPtr byteArrayType() const { return m_byteArrayType; } + QQmlJSScope::ConstPtr urlType() const { return m_urlType; } + QQmlJSScope::ConstPtr dateTimeType() const { return m_dateTimeType; } + QQmlJSScope::ConstPtr dateType() const { return m_dateType; } + QQmlJSScope::ConstPtr timeType() const { return m_timeType; } + QQmlJSScope::ConstPtr variantListType() const { return m_variantListType; } + QQmlJSScope::ConstPtr variantMapType() const { return m_variantMapType; } + QQmlJSScope::ConstPtr varType() const { return m_varType; } + QQmlJSScope::ConstPtr jsValueType() const { return m_jsValueType; } + QQmlJSScope::ConstPtr jsPrimitiveType() const { return m_jsPrimitiveType; } + QQmlJSScope::ConstPtr listPropertyType() const { return m_listPropertyType; } + QQmlJSScope::ConstPtr metaObjectType() const { return m_metaObjectType; } + QQmlJSScope::ConstPtr functionType() const { return m_functionType; } + QQmlJSScope::ConstPtr jsGlobalObject() const { return m_jsGlobalObject; } + QQmlJSScope::ConstPtr qObjectType() const { return m_qObjectType; } + QQmlJSScope::ConstPtr qObjectListType() const { return m_qObjectListType; } + QQmlJSScope::ConstPtr arrayPrototype() const { return m_arrayPrototype; } + QQmlJSScope::ConstPtr forInIteratorPtr() const { return m_forInIteratorPtr; } + QQmlJSScope::ConstPtr forOfIteratorPtr() const { return m_forOfIteratorPtr; } + + QQmlJSScope::ConstPtr mathObject() const; + QQmlJSScope::ConstPtr consoleObject() const; + + QQmlJSScope::ConstPtr scopeForLocation(const QV4::CompiledData::Location &location) const; + + bool isPrefix(const QString &name) const + { + return m_imports.hasType(name) && !m_imports.type(name).scope; + } + + const QHash<QString, QQmlJS::ImportedScope<QQmlJSScope::ConstPtr>> &importedTypes() const + { + return m_imports.types(); + } + + const auto &importedNames() const + { + return m_imports.contextualTypes().names(); + } + + QQmlJSScope::ConstPtr typeForName(const QString &name) const + { + return m_imports.type(name).scope; + } + QString nameForType(const QQmlJSScope::ConstPtr &type) const + { + // We want here not the name of the original type. That one may not exist. + // We want the name of the type we've used as replacement since that is + // whatever we do with the type expects. + return m_imports.name(comparableType(type)); + } + + QQmlJSScope::ConstPtr typeFromAST(QQmlJS::AST::Type *type) const; + QQmlJSScope::ConstPtr typeForConst(QV4::ReturnedValue rv) const; + QQmlJSRegisterContent typeForBinaryOperation(QSOperator::Op oper, + const QQmlJSRegisterContent &left, + const QQmlJSRegisterContent &right) const; + + enum class UnaryOperator { Not, Plus, Minus, Increment, Decrement, Complement }; + QQmlJSRegisterContent typeForArithmeticUnaryOperation( + UnaryOperator op, const QQmlJSRegisterContent &operand) const; + + bool isPrimitive(const QQmlJSRegisterContent &type) const; + bool isPrimitive(const QQmlJSScope::ConstPtr &type) const; + + bool isNumeric(const QQmlJSRegisterContent &type) const; + bool isIntegral(const QQmlJSRegisterContent &type) const; + + bool canConvertFromTo(const QQmlJSScope::ConstPtr &from, const QQmlJSScope::ConstPtr &to) const; + bool canConvertFromTo(const QQmlJSRegisterContent &from, const QQmlJSRegisterContent &to) const; + QQmlJSRegisterContent merge(const QQmlJSRegisterContent &a, + const QQmlJSRegisterContent &b) const; + + enum class ComponentIsGeneric { No, Yes }; + QQmlJSScope::ConstPtr + genericType(const QQmlJSScope::ConstPtr &type, + ComponentIsGeneric allowComponent = ComponentIsGeneric::No) const; + + QQmlJSRegisterContent builtinType(const QQmlJSScope::ConstPtr &type) const; + QQmlJSRegisterContent globalType(const QQmlJSScope::ConstPtr &type) const; + QQmlJSRegisterContent scopedType(const QQmlJSScope::ConstPtr &scope, const QString &name, + int lookupIndex = QQmlJSRegisterContent::InvalidLookupIndex, + QQmlJSScopesByIdOptions options = Default) const; + QQmlJSRegisterContent memberType( + const QQmlJSRegisterContent &type, const QString &name, + int lookupIndex = QQmlJSRegisterContent::InvalidLookupIndex) const; + QQmlJSRegisterContent valueType(const QQmlJSRegisterContent &list) const; + QQmlJSRegisterContent returnType( + const QQmlJSScope::ConstPtr &type, QQmlJSRegisterContent::ContentVariant variant, + const QQmlJSScope::ConstPtr &scope) const; + + QQmlJSRegisterContent iteratorPointer( + const QQmlJSRegisterContent &listType, QQmlJS::AST::ForEachType type, + int lookupIndex) const; + + bool registerIsStoredIn(const QQmlJSRegisterContent ®, + const QQmlJSScope::ConstPtr &type) const; + bool registerContains(const QQmlJSRegisterContent ®, + const QQmlJSScope::ConstPtr &type) const; + QQmlJSScope::ConstPtr containedType(const QQmlJSRegisterContent &container) const; + QString containedTypeName(const QQmlJSRegisterContent &container, + bool useFancyName = false) const; + + QQmlJSRegisterContent tracked(const QQmlJSRegisterContent &type) const; + QQmlJSRegisterContent original(const QQmlJSRegisterContent &type) const; + + QQmlJSScope::ConstPtr trackedContainedType(const QQmlJSRegisterContent &container) const; + QQmlJSScope::ConstPtr originalContainedType(const QQmlJSRegisterContent &container) const; + + [[nodiscard]] bool adjustTrackedType( + const QQmlJSScope::ConstPtr &tracked, const QQmlJSScope::ConstPtr &conversion) const; + [[nodiscard]] bool adjustTrackedType( + const QQmlJSScope::ConstPtr &tracked, + const QList<QQmlJSScope::ConstPtr> &conversions) const; + void adjustOriginalType( + const QQmlJSScope::ConstPtr &tracked, const QQmlJSScope::ConstPtr &conversion) const; + void generalizeType(const QQmlJSScope::ConstPtr &type) const; + + void setParentMode(ParentMode mode) { m_parentMode = mode; } + ParentMode parentMode() const { return m_parentMode; } + + void setCloneMode(CloneMode mode) { m_cloneMode = mode; } + bool cloneMode() const { return m_cloneMode; } + + QQmlJSScope::ConstPtr storedType(const QQmlJSScope::ConstPtr &type) const; + QQmlJSScope::ConstPtr originalType(const QQmlJSScope::ConstPtr &type) const; + QQmlJSScope::ConstPtr trackedType(const QQmlJSScope::ConstPtr &type) const; + QQmlJSScope::ConstPtr comparableType(const QQmlJSScope::ConstPtr &type) const; + + const QQmlJSScopesById &objectsById() const { return m_objectsById; } + bool canCallJSFunctions() const { return m_objectsById.signaturesAreEnforced(); } + bool canAddressValueTypes() const { return m_objectsById.valueTypesAreAddressable(); } + + const QHash<QQmlJS::SourceLocation, QQmlJSMetaSignalHandler> &signalHandlers() const + { + return m_signalHandlers; + } + + bool equals(const QQmlJSScope::ConstPtr &a, const QQmlJSScope::ConstPtr &b) const; + + QQmlJSRegisterContent convert( + const QQmlJSRegisterContent &from, const QQmlJSRegisterContent &to) const; + QQmlJSRegisterContent cast( + const QQmlJSRegisterContent &from, const QQmlJSScope::ConstPtr &to) const; + + QQmlJSScope::ConstPtr merge(const QQmlJSScope::ConstPtr &a, + const QQmlJSScope::ConstPtr &b) const; + + bool canHoldUndefined(const QQmlJSRegisterContent &content) const; + bool isOptionalType(const QQmlJSRegisterContent &content) const; + QQmlJSScope::ConstPtr extractNonVoidFromOptionalType( + const QQmlJSRegisterContent &content) const; + + bool isNumeric(const QQmlJSScope::ConstPtr &type) const; + bool isIntegral(const QQmlJSScope::ConstPtr &type) const; + bool isSignedInteger(const QQmlJSScope::ConstPtr &type) const; + bool isUnsignedInteger(const QQmlJSScope::ConstPtr &type) const; + bool isNativeArrayIndex(const QQmlJSScope::ConstPtr &type) const; + + bool canHold(const QQmlJSScope::ConstPtr &container, + const QQmlJSScope::ConstPtr &contained) const; + + bool canPopulate( + const QQmlJSScope::ConstPtr &type, const QQmlJSScope::ConstPtr &argument, + bool *isExtension) const; + + QQmlJSMetaMethod selectConstructor( + const QQmlJSScope::ConstPtr &type, const QQmlJSScope::ConstPtr &argument, + bool *isExtension) const; + + bool areEquivalentLists(const QQmlJSScope::ConstPtr &a, const QQmlJSScope::ConstPtr &b) const; + + bool isTriviallyCopyable(const QQmlJSScope::ConstPtr &type) const; + + bool inherits(const QQmlJSScope::ConstPtr &derived, const QQmlJSScope::ConstPtr &base) const; + QQmlJSLogger *logger() const { return m_logger; } + QStringList seenModuleQualifiers() const { return m_seenModuleQualifiers; } + +protected: + + QQmlJSRegisterContent memberType( + const QQmlJSScope::ConstPtr &type, const QString &name, + int baseLookupIndex, int resultLookupIndex) const; + QQmlJSRegisterContent memberEnumType(const QQmlJSScope::ConstPtr &type, + const QString &name) const; + bool checkEnums(const QQmlJSScope::ConstPtr &scope, const QString &name, + QQmlJSRegisterContent *result, QQmlJSScope::ExtensionKind mode) const; + bool canPrimitivelyConvertFromTo( + const QQmlJSScope::ConstPtr &from, const QQmlJSScope::ConstPtr &to) const; + QQmlJSRegisterContent lengthProperty(bool isWritable, const QQmlJSScope::ConstPtr &scope) const; + QQmlJSRegisterContent transformed( + const QQmlJSRegisterContent &origin, + QQmlJSScope::ConstPtr (QQmlJSTypeResolver::*op)(const QQmlJSScope::ConstPtr &) const) const; + + QQmlJSRegisterContent registerContentForName( + const QString &name, + const QQmlJSScope::ConstPtr &scopeType = QQmlJSScope::ConstPtr(), + bool hasObjectModuelPrefix = false) const; + + + QQmlJSScope::ConstPtr m_voidType; + QQmlJSScope::ConstPtr m_emptyType; + QQmlJSScope::ConstPtr m_nullType; + QQmlJSScope::ConstPtr m_numberPrototype; + QQmlJSScope::ConstPtr m_arrayPrototype; + QQmlJSScope::ConstPtr m_realType; + QQmlJSScope::ConstPtr m_floatType; + QQmlJSScope::ConstPtr m_int8Type; + QQmlJSScope::ConstPtr m_uint8Type; + QQmlJSScope::ConstPtr m_int16Type; + QQmlJSScope::ConstPtr m_uint16Type; + QQmlJSScope::ConstPtr m_int32Type; + QQmlJSScope::ConstPtr m_uint32Type; + QQmlJSScope::ConstPtr m_int64Type; + QQmlJSScope::ConstPtr m_uint64Type; + QQmlJSScope::ConstPtr m_sizeType; + QQmlJSScope::ConstPtr m_boolType; + QQmlJSScope::ConstPtr m_stringType; + QQmlJSScope::ConstPtr m_stringListType; + QQmlJSScope::ConstPtr m_byteArrayType; + QQmlJSScope::ConstPtr m_urlType; + QQmlJSScope::ConstPtr m_dateTimeType; + QQmlJSScope::ConstPtr m_dateType; + QQmlJSScope::ConstPtr m_timeType; + QQmlJSScope::ConstPtr m_variantListType; + QQmlJSScope::ConstPtr m_variantMapType; + QQmlJSScope::ConstPtr m_varType; + QQmlJSScope::ConstPtr m_jsValueType; + QQmlJSScope::ConstPtr m_jsPrimitiveType; + QQmlJSScope::ConstPtr m_listPropertyType; + QQmlJSScope::ConstPtr m_qObjectType; + QQmlJSScope::ConstPtr m_qObjectListType; + QQmlJSScope::ConstPtr m_qQmlScriptStringType; + QQmlJSScope::ConstPtr m_metaObjectType; + QQmlJSScope::ConstPtr m_functionType; + QQmlJSScope::ConstPtr m_jsGlobalObject; + QQmlJSScope::ConstPtr m_forInIteratorPtr; + QQmlJSScope::ConstPtr m_forOfIteratorPtr; + + QQmlJSScopesById m_objectsById; + QHash<QV4::CompiledData::Location, QQmlJSScope::ConstPtr> m_objectsByLocation; + QQmlJSImporter::ImportedTypes m_imports; + QHash<QQmlJS::SourceLocation, QQmlJSMetaSignalHandler> m_signalHandlers; + QStringList m_seenModuleQualifiers; + + ParentMode m_parentMode = UseParentProperty; + CloneMode m_cloneMode = CloneTypes; + QQmlJSLogger *m_logger = nullptr; + + struct TrackedType + { + // The type originally found via type analysis. + QQmlJSScope::ConstPtr original; + + // Any later replacement used to overwrite the contents of the clone. + QQmlJSScope::ConstPtr replacement; + + // A clone of original, used to track the type, + // contents possibly overwritten by replacement. + QQmlJSScope::Ptr clone; + }; + + std::unique_ptr<QHash<QQmlJSScope::ConstPtr, TrackedType>> m_trackedTypes; +}; + +/*! +\internal + +QQmlJSTypeResolver expects to be outlived by its importer and mapper. It crashes when its importer +or mapper gets destructed. Therefore, you can use this struct to extend the lifetime of its +dependencies in case you need to store the resolver as a class member. +QQmlJSTypeResolver also expects to be outlived by the logger used by the importvisitor, while the +importvisitor actually does not and will not outlive the QQmlJSTypeResolver. +*/ +struct QQmlJSTypeResolverDependencies +{ + std::shared_ptr<QQmlJSImporter> importer; + std::shared_ptr<QQmlJSResourceFileMapper> mapper; + std::shared_ptr<QQmlJSLogger> logger; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSTYPERESOLVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsutils_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsutils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ab9a7429a7f064b70f4da0fbbb858fa9de1e4602 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsutils_p.h @@ -0,0 +1,407 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSUTILS_P_H +#define QQMLJSUTILS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include "qqmljslogger_p.h" +#include "qqmljsregistercontent_p.h" +#include "qqmljsresourcefilemapper_p.h" +#include "qqmljsscope_p.h" +#include "qqmljsmetatypes_p.h" + +#include <QtCore/qdir.h> +#include <QtCore/qstack.h> +#include <QtCore/qstring.h> +#include <QtCore/qstringbuilder.h> +#include <QtCore/qstringview.h> + +#include <QtQml/private/qqmlsignalnames_p.h> +#include <private/qduplicatetracker_p.h> + +#include <optional> +#include <functional> +#include <type_traits> +#include <variant> + +QT_BEGIN_NAMESPACE + +namespace detail { +/*! \internal + + Utility method that returns proper value according to the type To. This + version returns From. +*/ +template<typename To, typename From, typename std::enable_if_t<!std::is_pointer_v<To>, int> = 0> +static auto getQQmlJSScopeFromSmartPtr(const From &p) -> From +{ + static_assert(!std::is_pointer_v<From>, "From has to be a smart pointer holding QQmlJSScope"); + return p; +} + +/*! \internal + + Utility method that returns proper value according to the type To. This + version returns From::get(), which is a raw pointer. The returned type + is not necessarily equal to To (e.g. To might be `QQmlJSScope *` while + returned is `const QQmlJSScope *`). +*/ +template<typename To, typename From, typename std::enable_if_t<std::is_pointer_v<To>, int> = 0> +static auto getQQmlJSScopeFromSmartPtr(const From &p) -> decltype(p.get()) +{ + static_assert(!std::is_pointer_v<From>, "From has to be a smart pointer holding QQmlJSScope"); + return p.get(); +} +} + +class QQmlJSTypeResolver; +class QQmlJSScopesById; +struct Q_QMLCOMPILER_EXPORT QQmlJSUtils +{ + /*! \internal + Returns escaped version of \a s. This function is mostly useful for code + generators. + */ + static QString escapeString(QString s) + { + using namespace Qt::StringLiterals; + return s.replace('\\'_L1, "\\\\"_L1) + .replace('"'_L1, "\\\""_L1) + .replace('\n'_L1, "\\n"_L1) + .replace('?'_L1, "\\?"_L1); + } + + /*! \internal + Returns \a s wrapped into a literal macro specified by \a ctor. By + default, returns a QStringLiteral-wrapped literal. This function is + mostly useful for code generators. + + \note This function escapes \a s before wrapping it. + */ + static QString toLiteral(const QString &s, QStringView ctor = u"QStringLiteral") + { + return ctor % u"(\"" % escapeString(s) % u"\")"; + } + + /*! \internal + Returns \a type string conditionally wrapped into \c{const} and \c{&}. + This function is mostly useful for code generators. + */ + static QString constRefify(QString type) + { + if (!type.endsWith(u'*')) + type = u"const " % type % u"&"; + return type; + } + + static std::optional<QQmlJSMetaProperty> + changeHandlerProperty(const QQmlJSScope::ConstPtr &scope, QStringView signalName) + { + if (!signalName.endsWith(QLatin1String("Changed"))) + return {}; + constexpr int length = int(sizeof("Changed") / sizeof(char)) - 1; + signalName.chop(length); + auto p = scope->property(signalName.toString()); + const bool isBindable = !p.bindable().isEmpty(); + const bool canNotify = !p.notify().isEmpty(); + if (p.isValid() && (isBindable || canNotify)) + return p; + return {}; + } + + static std::optional<QQmlJSMetaProperty> + propertyFromChangedHandler(const QQmlJSScope::ConstPtr &scope, QStringView changedHandler) + { + auto signalName = QQmlSignalNames::changedHandlerNameToPropertyName(changedHandler); + if (!signalName) + return {}; + + auto p = scope->property(*signalName); + const bool isBindable = !p.bindable().isEmpty(); + const bool canNotify = !p.notify().isEmpty(); + if (p.isValid() && (isBindable || canNotify)) + return p; + return {}; + } + + static bool hasCompositeBase(const QQmlJSScope::ConstPtr &scope) + { + if (!scope) + return false; + const auto base = scope->baseType(); + if (!base) + return false; + return base->isComposite() && base->scopeType() == QQmlSA::ScopeType::QMLScope; + } + + enum PropertyAccessor { + PropertyAccessor_Read, + PropertyAccessor_Write, + }; + /*! \internal + + Returns \c true if \a p is bindable and property accessor specified by + \a accessor is equal to "default". Returns \c false otherwise. + + \note This function follows BINDABLE-only properties logic (e.g. in moc) + */ + static bool bindablePropertyHasDefaultAccessor(const QQmlJSMetaProperty &p, + PropertyAccessor accessor) + { + if (p.bindable().isEmpty()) + return false; + switch (accessor) { + case PropertyAccessor::PropertyAccessor_Read: + return p.read() == QLatin1String("default"); + case PropertyAccessor::PropertyAccessor_Write: + return p.write() == QLatin1String("default"); + default: + break; + } + return false; + } + + enum ResolvedAliasTarget { + AliasTarget_Invalid, + AliasTarget_Property, + AliasTarget_Object, + }; + struct ResolvedAlias + { + QQmlJSMetaProperty property; + QQmlJSScope::ConstPtr owner; + ResolvedAliasTarget kind = ResolvedAliasTarget::AliasTarget_Invalid; + }; + struct AliasResolutionVisitor + { + std::function<void()> reset = []() {}; + std::function<void(const QQmlJSScope::ConstPtr &)> processResolvedId = + [](const QQmlJSScope::ConstPtr &) {}; + std::function<void(const QQmlJSMetaProperty &, const QQmlJSScope::ConstPtr &)> + processResolvedProperty = + [](const QQmlJSMetaProperty &, const QQmlJSScope::ConstPtr &) {}; + }; + static ResolvedAlias resolveAlias(const QQmlJSTypeResolver *typeResolver, + const QQmlJSMetaProperty &property, + const QQmlJSScope::ConstPtr &owner, + const AliasResolutionVisitor &visitor); + static ResolvedAlias resolveAlias(const QQmlJSScopesById &idScopes, + const QQmlJSMetaProperty &property, + const QQmlJSScope::ConstPtr &owner, + const AliasResolutionVisitor &visitor); + + template<typename QQmlJSScopePtr, typename Action> + static bool searchBaseAndExtensionTypes(QQmlJSScopePtr type, const Action &check) + { + if (!type) + return false; + + using namespace detail; + + // NB: among other things, getQQmlJSScopeFromSmartPtr() also resolves const + // vs non-const pointer issue, so use it's return value as the type + using T = decltype(getQQmlJSScopeFromSmartPtr<QQmlJSScopePtr>( + std::declval<QQmlJSScope::ConstPtr>())); + + const auto checkWrapper = [&](const auto &scope, QQmlJSScope::ExtensionKind mode) { + if constexpr (std::is_invocable<Action, decltype(scope), + QQmlJSScope::ExtensionKind>::value) { + return check(scope, mode); + } else { + static_assert(std::is_invocable<Action, decltype(scope)>::value, + "Inferred type Action has unexpected arguments"); + Q_UNUSED(mode); + return check(scope); + } + }; + + const bool isValueOrSequenceType = [type]() { + switch (type->accessSemantics()) { + case QQmlJSScope::AccessSemantics::Value: + case QQmlJSScope::AccessSemantics::Sequence: + return true; + default: + break; + } + return false; + }(); + + QDuplicateTracker<T> seen; + for (T scope = type; scope && !seen.hasSeen(scope); + scope = getQQmlJSScopeFromSmartPtr<QQmlJSScopePtr>(scope->baseType())) { + QDuplicateTracker<T> seenExtensions; + // Extensions override the types they extend. However, usually base + // types of extensions are ignored. The unusual cases are when we + // have a value or sequence type or when we have the QObject type, in which + // case we also study the extension's base type hierarchy. + const bool isQObject = scope->internalName() == QLatin1String("QObject"); + auto [extensionPtr, extensionKind] = scope->extensionType(); + auto extension = getQQmlJSScopeFromSmartPtr<QQmlJSScopePtr>(extensionPtr); + do { + if (!extension || seenExtensions.hasSeen(extension)) + break; + + if (checkWrapper(extension, extensionKind)) + return true; + extension = getQQmlJSScopeFromSmartPtr<QQmlJSScopePtr>(extension->baseType()); + } while (isValueOrSequenceType || isQObject); + + if (checkWrapper(scope, QQmlJSScope::NotExtension)) + return true; + } + + return false; + } + + template<typename Action> + static void traverseFollowingQmlIrObjectStructure(const QQmlJSScope::Ptr &root, Action act) + { + // We *have* to perform DFS here: QmlIR::Object entries within the + // QmlIR::Document are stored in the order they appear during AST traversal + // (which does DFS) + QStack<QQmlJSScope::Ptr> stack; + stack.push(root); + + while (!stack.isEmpty()) { + QQmlJSScope::Ptr current = stack.pop(); + + act(current); + + auto children = current->childScopes(); + // arrays are special: they are reverse-processed in QmlIRBuilder + if (!current->isArrayScope()) + std::reverse(children.begin(), children.end()); // left-to-right DFS + stack.append(std::move(children)); + } + } + + /*! \internal + + Traverses the base types and extensions of \a scope in the order aligned + with QMetaObjects created at run time for these types and extensions + (except that QQmlVMEMetaObject is ignored). \a start is the starting + type in the hierarchy where \a act is applied. + + \note To call \a act for every type in the hierarchy, use + scope->extensionType().scope as \a start + */ + template<typename Action> + static void traverseFollowingMetaObjectHierarchy(const QQmlJSScope::ConstPtr &scope, + const QQmlJSScope::ConstPtr &start, Action act) + { + // Meta objects are arranged in the following way: + // * static meta objects are chained first + // * dynamic meta objects are added on top - they come from extensions. + // QQmlVMEMetaObject ignored here + // + // Example: + // ``` + // class A : public QObject { + // QML_EXTENDED(Ext) + // }; + // class B : public A { + // QML_EXTENDED(Ext2) + // }; + // ``` + // gives: Ext2 -> Ext -> B -> A -> QObject + // ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ + // ^^^^^^^^^^^ static meta objects + // dynamic meta objects + + using namespace Qt::StringLiterals; + // ignore special extensions + const QLatin1String ignoredExtensionNames[] = { + // QObject extensions: (not related to C++) + "Object"_L1, + "ObjectPrototype"_L1, + }; + + QList<QQmlJSScope::AnnotatedScope> types; + QList<QQmlJSScope::AnnotatedScope> extensions; + const auto collect = [&](const QQmlJSScope::ConstPtr &type, QQmlJSScope::ExtensionKind m) { + if (m == QQmlJSScope::NotExtension) { + types.append(QQmlJSScope::AnnotatedScope { type, m }); + return false; + } + + for (const auto &name : ignoredExtensionNames) { + if (type->internalName() == name) + return false; + } + extensions.append(QQmlJSScope::AnnotatedScope { type, m }); + return false; + }; + searchBaseAndExtensionTypes(scope, collect); + + QList<QQmlJSScope::AnnotatedScope> all; + all.reserve(extensions.size() + types.size()); + // first extensions then types + all.append(std::move(extensions)); + all.append(std::move(types)); + + auto begin = all.cbegin(); + // skip to start + while (begin != all.cend() && !begin->scope->isSameType(start)) + ++begin; + + // iterate over extensions and types starting at a specified point + for (; begin != all.cend(); ++begin) + act(begin->scope, begin->extensionSpecifier); + } + + static std::optional<QQmlJSFixSuggestion> didYouMean(const QString &userInput, + QStringList candidates, + QQmlJS::SourceLocation location); + + static std::variant<QString, QQmlJS::DiagnosticMessage> + sourceDirectoryPath(const QQmlJSImporter *importer, const QString &buildDirectoryPath); + + template <typename Container> + static void deduplicate(Container &container) + { + std::sort(container.begin(), container.end()); + auto erase = std::unique(container.begin(), container.end()); + container.erase(erase, container.end()); + } + + static QStringList cleanPaths(QStringList &&paths) + { + for (QString &path : paths) + path = QDir::cleanPath(path); + return std::move(paths); + } + + static QStringList resourceFilesFromBuildFolders(const QStringList &buildFolders); + static QString qmlSourcePathFromBuildPath(const QQmlJSResourceFileMapper *mapper, + const QString &pathInBuildFolder); + static QString qmlBuildPathFromSourcePath(const QQmlJSResourceFileMapper *mapper, + const QString &pathInBuildFolder); +}; + +bool Q_QMLCOMPILER_EXPORT canStrictlyCompareWithVar( + const QQmlJSTypeResolver *typeResolver, const QQmlJSScope::ConstPtr &lhsType, + const QQmlJSScope::ConstPtr &rhsType); + +bool Q_QMLCOMPILER_EXPORT canCompareWithQObject( + const QQmlJSTypeResolver *typeResolver, const QQmlJSScope::ConstPtr &lhsType, + const QQmlJSScope::ConstPtr &rhsType); + +bool Q_QMLCOMPILER_EXPORT canCompareWithQUrl( + const QQmlJSTypeResolver *typeResolver, const QQmlJSScope::ConstPtr &lhsType, + const QQmlJSScope::ConstPtr &rhsType); + +QT_END_NAMESPACE + +#endif // QQMLJSUTILS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsvaluetypefromstringcheck_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsvaluetypefromstringcheck_p.h new file mode 100644 index 0000000000000000000000000000000000000000..33edc8ed92c65da85ae8599254d183af754f89c0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmljsvaluetypefromstringcheck_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSVALUETYPEFROMSTRINGCHECK_H +#define QQMLJSVALUETYPEFROMSTRINGCHECK_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtCore/qstring.h> + +#include <qtqmlcompilerexports.h> + +QT_BEGIN_NAMESPACE + +struct Q_QMLCOMPILER_EXPORT QQmlJSStructuredTypeError +{ + QString code; + bool constructedFromInvalidString = false; + + bool isValid() const { return !code.isEmpty() || constructedFromInvalidString; } + static QQmlJSStructuredTypeError withInvalidString() { return { QString(), true }; } + static QQmlJSStructuredTypeError withValidString() { return { QString(), false }; } + static QQmlJSStructuredTypeError fromSuggestedString(const QString &enhancedString) + { + return { enhancedString, false }; + } +}; + + +class Q_QMLCOMPILER_EXPORT QQmlJSValueTypeFromStringCheck +{ +public: + static QQmlJSStructuredTypeError hasError(const QString &typeName, const QString &value); +}; + +QT_END_NAMESPACE + +#endif // QQMLJSVALUETYPEFROMSTRINGCHECK_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmlsa_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmlsa_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6b692e68bb1f33c95e3718fd2b96e7d87cbdd794 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmlsa_p.h @@ -0,0 +1,276 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLSA_P_H +#define QQMLSA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include <private/qqmljslogger_p.h> +#include <QtCore/qset.h> +#include "qqmljsmetatypes_p.h" + +#include <map> +#include <unordered_map> +#include <vector> +#include <memory> + +QT_BEGIN_NAMESPACE + +class QQmlJSTypeResolver; +struct QQmlJSTypePropagator; +class QQmlJSImportVisitor; + +namespace QQmlSA { + +class Bindings; +class GenericPassPrivate; +class PassManager; + +enum class AccessSemantics { Reference, Value, None, Sequence }; + +enum class Flag { + Creatable = 0x1, + Composite = 0x2, + Singleton = 0x4, + Script = 0x8, + CustomParser = 0x10, + Array = 0x20, + InlineComponent = 0x40, + WrappedInImplicitComponent = 0x80, + HasBaseTypeError = 0x100, + HasExtensionNamespace = 0x200, + IsListProperty = 0x400, +}; + +struct BindingInfo +{ + QString fullPropertyName; + QQmlSA::Binding binding; + QQmlSA::Element bindingScope; + bool isAttached; +}; + +struct PropertyPassInfo +{ + QStringList properties; + std::shared_ptr<QQmlSA::PropertyPass> pass; + bool allowInheritance = true; +}; + +class BindingsPrivate +{ + friend class QT_PREPEND_NAMESPACE(QQmlJSMetaPropertyBinding); + Q_DECLARE_PUBLIC(QQmlSA::Binding::Bindings) + +public: + explicit BindingsPrivate(QQmlSA::Binding::Bindings *); + BindingsPrivate(QQmlSA::Binding::Bindings *, const BindingsPrivate &); + BindingsPrivate(QQmlSA::Binding::Bindings *, BindingsPrivate &&); + ~BindingsPrivate() = default; + + QMultiHash<QString, Binding>::const_iterator constBegin() const; + QMultiHash<QString, Binding>::const_iterator constEnd() const; + + static QQmlSA::Binding::Bindings + createBindings(const QMultiHash<QString, QQmlJSMetaPropertyBinding> &); + static QQmlSA::Binding::Bindings + createBindings(QPair<QMultiHash<QString, QQmlJSMetaPropertyBinding>::const_iterator, + QMultiHash<QString, QQmlJSMetaPropertyBinding>::const_iterator>); + +private: + QMultiHash<QString, Binding> m_bindings; + QQmlSA::Binding::Bindings *q_ptr; +}; + +class BindingPrivate +{ + friend class QT_PREPEND_NAMESPACE(QQmlJSMetaPropertyBinding); + Q_DECLARE_PUBLIC(Binding) + +public: + explicit BindingPrivate(Binding *); + BindingPrivate(Binding *, const BindingPrivate &); + + static QQmlSA::Binding createBinding(const QQmlJSMetaPropertyBinding &); + static QQmlJSMetaPropertyBinding binding(QQmlSA::Binding &binding); + static const QQmlJSMetaPropertyBinding binding(const QQmlSA::Binding &binding); + +private: + QQmlJSMetaPropertyBinding m_binding; + Binding *q_ptr; +}; + +class MethodPrivate +{ + friend class QT_PREPEND_NAMESPACE(QQmlJSMetaMethod); + Q_DECLARE_PUBLIC(Method) + +public: + explicit MethodPrivate(Method *); + MethodPrivate(Method *, const MethodPrivate &); + + QString methodName() const; + QQmlSA::SourceLocation sourceLocation() const; + MethodType methodType() const; + + static QQmlSA::Method createMethod(const QQmlJSMetaMethod &); + static QQmlJSMetaMethod method(const QQmlSA::Method &); + +private: + QQmlJSMetaMethod m_method; + Method *q_ptr; +}; + +class MethodsPrivate +{ + friend class QT_PREPEND_NAMESPACE(QQmlJSMetaMethod); + Q_DECLARE_PUBLIC(QQmlSA::Method::Methods) + +public: + explicit MethodsPrivate(QQmlSA::Method::Methods *); + MethodsPrivate(QQmlSA::Method::Methods *, const MethodsPrivate &); + MethodsPrivate(QQmlSA::Method::Methods *, MethodsPrivate &&); + ~MethodsPrivate() = default; + + QMultiHash<QString, Method>::const_iterator constBegin() const; + QMultiHash<QString, Method>::const_iterator constEnd() const; + + static QQmlSA::Method::Methods createMethods(const QMultiHash<QString, QQmlJSMetaMethod> &); + +private: + QMultiHash<QString, Method> m_methods; + QQmlSA::Method::Methods *q_ptr; +}; + +class PropertyPrivate +{ + friend class QT_PREPEND_NAMESPACE(QQmlJSMetaProperty); + Q_DECLARE_PUBLIC(QQmlSA::Property) + +public: + explicit PropertyPrivate(Property *); + PropertyPrivate(Property *, const PropertyPrivate &); + PropertyPrivate(Property *, PropertyPrivate &&); + ~PropertyPrivate() = default; + + QString typeName() const; + bool isValid() const; + bool isReadonly() const; + QQmlSA::Element type() const; + + static QQmlJSMetaProperty property(const QQmlSA::Property &property); + static QQmlSA::Property createProperty(const QQmlJSMetaProperty &); + +private: + QQmlJSMetaProperty m_property; + QQmlSA::Property *q_ptr; +}; + +class Q_QMLCOMPILER_EXPORT PassManagerPrivate +{ + friend class QT_PREPEND_NAMESPACE(QQmlJSScope); + +public: + Q_DISABLE_COPY_MOVE(PassManagerPrivate) + + friend class GenericPass; + PassManagerPrivate(QQmlJSImportVisitor *visitor, QQmlJSTypeResolver *resolver) + : m_visitor(visitor), m_typeResolver(resolver) + { + } + + static PassManagerPrivate *get(PassManager *manager) { return manager->d_func(); } + static const PassManagerPrivate *get(const PassManager *manager) { return manager->d_func(); } + static PassManager *createPassManager(QQmlJSImportVisitor *visitor, QQmlJSTypeResolver *resolver) + { + PassManager *result = new PassManager(); + result->d_ptr = std::make_unique<PassManagerPrivate>(visitor, resolver); + return result; + } + static void deletePassManager(PassManager *q) { delete q; } + + void registerElementPass(std::unique_ptr<ElementPass> pass); + bool registerPropertyPass(std::shared_ptr<PropertyPass> pass, QAnyStringView moduleName, + QAnyStringView typeName, + QAnyStringView propertyName = QAnyStringView(), + bool allowInheritance = true); + void analyze(const Element &root); + + bool hasImportedModule(QAnyStringView name) const; + + static QQmlJSImportVisitor *visitor(const QQmlSA::PassManager &); + static QQmlJSTypeResolver *resolver(const QQmlSA::PassManager &); + + + QSet<PropertyPass *> findPropertyUsePasses(const QQmlSA::Element &element, + const QString &propertyName); + + void analyzeWrite(const QQmlSA::Element &element, QString propertyName, + const QQmlSA::Element &value, const QQmlSA::Element &writeScope, + QQmlSA::SourceLocation location); + void analyzeRead(const QQmlSA::Element &element, QString propertyName, + const QQmlSA::Element &readScope, QQmlSA::SourceLocation location); + void analyzeBinding(const QQmlSA::Element &element, const QQmlSA::Element &value, + QQmlSA::SourceLocation location); + + void addBindingSourceLocations(const QQmlSA::Element &element, + const QQmlSA::Element &scope = QQmlSA::Element(), + const QString prefix = QString(), bool isAttached = false); + + std::vector<std::shared_ptr<ElementPass>> m_elementPasses; + std::multimap<QString, PropertyPassInfo> m_propertyPasses; + std::unordered_map<quint32, BindingInfo> m_bindingsByLocation; + QQmlJSImportVisitor *m_visitor; + QQmlJSTypeResolver *m_typeResolver; +}; + +class FixSuggestionPrivate +{ + Q_DECLARE_PUBLIC(FixSuggestion) + friend class QT_PREPEND_NAMESPACE(QQmlJSFixSuggestion); + +public: + explicit FixSuggestionPrivate(FixSuggestion *); + FixSuggestionPrivate(FixSuggestion *, const QString &fixDescription, + const QQmlSA::SourceLocation &location, const QString &replacement); + FixSuggestionPrivate(FixSuggestion *, const FixSuggestionPrivate &); + FixSuggestionPrivate(FixSuggestion *, FixSuggestionPrivate &&); + ~FixSuggestionPrivate() = default; + + QString fixDescription() const; + QQmlSA::SourceLocation location() const; + QString replacement() const; + + void setFileName(const QString &); + QString fileName() const; + + void setHint(const QString &); + QString hint() const; + + void setAutoApplicable(bool autoApplicable = true); + bool isAutoApplicable() const; + + static QQmlJSFixSuggestion &fixSuggestion(QQmlSA::FixSuggestion &); + static const QQmlJSFixSuggestion &fixSuggestion(const QQmlSA::FixSuggestion &); + +private: + QQmlJSFixSuggestion m_fixSuggestion; + QQmlSA::FixSuggestion *q_ptr; +}; + +} // namespace QQmlSA + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmlsasourcelocation_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmlsasourcelocation_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e510675510d9af93dea1f6815328e30110e776b9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qqmlsasourcelocation_p.h @@ -0,0 +1,53 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLSASOURCELOCATION_P_H +#define QQMLSASOURCELOCATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include "qqmlsasourcelocation.h" + +#include <QtQml/private/qqmljssourcelocation_p.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlSA { + +class SourceLocationPrivate +{ +public: + static const QQmlJS::SourceLocation & + sourceLocation(const QQmlSA::SourceLocation &sourceLocation) + { + return reinterpret_cast<const QQmlJS::SourceLocation &>(sourceLocation.m_data); + } + + static QQmlSA::SourceLocation + createQQmlSASourceLocation(const QQmlJS::SourceLocation &jsLocation) + { + QQmlSA::SourceLocation saLocation; + auto &internal = reinterpret_cast<QQmlJS::SourceLocation &>(saLocation.m_data); + internal = jsLocation; + return saLocation; + } + + static constexpr qsizetype sizeOfSourceLocation() + { + return SourceLocation::sizeofSourceLocation; + } +}; + +} // namespace QQmlSA + +QT_END_NAMESPACE + +#endif // QQMLSASOURCELOCATION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qresourcerelocater_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qresourcerelocater_p.h new file mode 100644 index 0000000000000000000000000000000000000000..de36b3635ddadc8610b3a3255a553756c432f2b6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCompiler/6.8.1/QtQmlCompiler/private/qresourcerelocater_p.h @@ -0,0 +1,28 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QRESOURCERELOCATER_P_H +#define QRESOURCERELOCATER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <qtqmlcompilerexports.h> + +#include <QtCore/qstring.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +int Q_QMLCOMPILER_EXPORT qRelocateResourceFile(const QString &input, const QString &output); + +QT_END_NAMESPACE + +#endif // QRESOURCERELOCATER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlcoreglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlcoreglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5017865e194589faa31e3c409ce51c3a0f822da2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlcoreglobal_p.h @@ -0,0 +1,21 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCOREGLOBAL_P_H +#define QQMLCOREGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtQmlCore/qtqmlcoreexports.h> + +#endif // QQMLCOREGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlpermissions_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlpermissions_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b09f23338ee7790c6c24e686bbb8021eb284dd82 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlpermissions_p.h @@ -0,0 +1,117 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPERMISSIONS_P_H +#define QQMLPERMISSIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlglobal_p.h> + +#if QT_CONFIG(permissions) + +#include <QtQml/qqmlregistration.h> + +#include <QtCore/qpermissions.h> +#include <QtCore/qnamespace.h> +#include <QtCore/qproperty.h> +#include <QtCore/qglobal.h> + +#include <QtCore/qcoreapplication.h> + +QT_BEGIN_NAMESPACE + +#define QML_PERMISSION(Permission) \ + Q_OBJECT \ + QML_NAMED_ELEMENT(Permission) \ +public: \ + Q_PROPERTY(Qt::PermissionStatus status READ status NOTIFY statusChanged) \ + Qt::PermissionStatus status() const { return qApp->checkPermission(m_permission); } \ + Q_SIGNAL void statusChanged(); \ + Q_INVOKABLE void request() { \ + const auto previousStatus = status(); \ + qApp->requestPermission(m_permission, this, \ + [this, previousStatus](const QPermission &permission) { \ + if (previousStatus != permission.status()) \ + emit statusChanged(); \ + }); \ + } \ +private: \ + Q##Permission m_permission; \ +public: + +#define QML_PERMISSION_PROPERTY(PropertyType, getterName, setterName) \ + Q_PROPERTY(PropertyType getterName READ getterName WRITE setterName NOTIFY getterName##Changed) \ + PropertyType getterName() const { return m_permission.getterName(); } \ + void setterName(const PropertyType &value) { \ + const auto previousValue = m_permission.getterName(); \ + const auto previousStatus = status(); \ + m_permission.setterName(value); \ + if (m_permission.getterName() != previousValue) { \ + emit getterName##Changed(); \ + if (status() != previousStatus) \ + emit statusChanged(); \ + } \ + } \ + Q_SIGNAL void getterName##Changed(); + + +struct QQmlQLocationPermission : public QObject +{ + QML_PERMISSION(LocationPermission) + QML_ADDED_IN_VERSION(6, 6) + QML_EXTENDED_NAMESPACE(QLocationPermission) + QML_PERMISSION_PROPERTY(QLocationPermission::Availability, availability, setAvailability) + QML_PERMISSION_PROPERTY(QLocationPermission::Accuracy, accuracy, setAccuracy) +}; + +struct QQmlCalendarPermission : public QObject +{ + QML_PERMISSION(CalendarPermission) + QML_ADDED_IN_VERSION(6, 6) + QML_EXTENDED_NAMESPACE(QCalendarPermission) + QML_PERMISSION_PROPERTY(QCalendarPermission::AccessMode, accessMode, setAccessMode) +}; + +struct QQmlContactsPermission : public QObject +{ + QML_PERMISSION(ContactsPermission) + QML_ADDED_IN_VERSION(6, 6) + QML_EXTENDED_NAMESPACE(QContactsPermission) + QML_PERMISSION_PROPERTY(QContactsPermission::AccessMode, accessMode, setAccessMode) +}; + +struct QQmlBluetoothPermission : public QObject +{ + QML_PERMISSION(BluetoothPermission) + QML_ADDED_IN_VERSION(6, 6) + QML_EXTENDED_NAMESPACE(QBluetoothPermission) + QML_PERMISSION_PROPERTY(QBluetoothPermission::CommunicationModes, communicationModes, setCommunicationModes) +}; + +struct QQmlCameraPermission : public QObject +{ + QML_PERMISSION(CameraPermission) + QML_ADDED_IN_VERSION(6, 6) +}; + +struct QQmlMicrophonePermission : public QObject +{ + QML_PERMISSION(MicrophonePermission) + QML_ADDED_IN_VERSION(6, 6) +}; + +QT_END_NAMESPACE + +#endif // QT_CONFIG(permissions) + +#endif // QQMLPERMISSIONS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlsettings_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlsettings_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1e334148fe96c3d8a50b3298bcea1c450d0b17b0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlsettings_p.h @@ -0,0 +1,72 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSETTINGS_P_H +#define QQMLSETTINGS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtCore/qvariant.h> +#include <QtCore/qurl.h> +#include <QtQml/qqml.h> +#include <QtQml/qqmlparserstatus.h> +#include <QtQmlCore/private/qqmlcoreglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlSettingsPrivate; + +class Q_QMLCORE_EXPORT QQmlSettings : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_DECLARE_PRIVATE(QQmlSettings) + QML_NAMED_ELEMENT(Settings) + QML_ADDED_IN_VERSION(6, 5) + + Q_PROPERTY(QString category READ category WRITE setCategory NOTIFY categoryChanged FINAL) + Q_PROPERTY(QUrl location READ location WRITE setLocation NOTIFY locationChanged FINAL) + +public: + explicit QQmlSettings(QObject *parent = nullptr); + ~QQmlSettings() override; + + QString category() const; + void setCategory(const QString &category); + + QUrl location() const; + void setLocation(const QUrl &location); + + Q_INVOKABLE QVariant value(const QString &key, const QVariant &defaultValue = {}) const; + Q_INVOKABLE void setValue(const QString &key, const QVariant &value); + Q_INVOKABLE void sync(); + +Q_SIGNALS: + void categoryChanged(const QString &arg); + void locationChanged(const QUrl &arg); + +protected: + void timerEvent(QTimerEvent *event) override; + + void classBegin() override; + void componentComplete() override; + +private: + QScopedPointer<QQmlSettingsPrivate> d_ptr; + + Q_PRIVATE_SLOT(d_func(), void _q_propertyChanged()) +}; + +QT_END_NAMESPACE + +#endif // QQMLSETTINGS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlstandardpaths_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlstandardpaths_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b451ab33da0205e81f5273867703e05bf0202505 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlstandardpaths_p.h @@ -0,0 +1,52 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSTANDARDPATHS_P_H +#define QQMLSTANDARDPATHS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtCore/qstandardpaths.h> +#include <QtCore/qurl.h> +#include <QtQml/qqml.h> +#include <QtQmlCore/private/qqmlcoreglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlEngine; +class QJSEngine; + +class Q_QMLCORE_EXPORT QQmlStandardPaths : public QObject +{ + Q_OBJECT + QML_SINGLETON + QML_NAMED_ELEMENT(StandardPaths) + QML_ADDED_IN_VERSION(6, 2) + QML_EXTENDED_NAMESPACE(QStandardPaths) + +public: + explicit QQmlStandardPaths(QObject *parent = nullptr); + + Q_INVOKABLE QString displayName(QStandardPaths::StandardLocation type) const; + Q_INVOKABLE QUrl findExecutable(const QString &executableName, const QStringList &paths = QStringList()) const; + Q_INVOKABLE QUrl locate(QStandardPaths::StandardLocation type, const QString &fileName, + QStandardPaths::LocateOptions options = QStandardPaths::LocateFile) const; + Q_INVOKABLE QList<QUrl> locateAll(QStandardPaths::StandardLocation type, const QString &fileName, + QStandardPaths::LocateOptions options = QStandardPaths::LocateFile) const; + Q_INVOKABLE QList<QUrl> standardLocations(QStandardPaths::StandardLocation type) const; + Q_INVOKABLE QUrl writableLocation(QStandardPaths::StandardLocation type) const; +}; + +QT_END_NAMESPACE + +#endif // QQMLSTANDARDPATHS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlsysteminformation_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlsysteminformation_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b07dbc6c710698a74cfcd38e8c38ecb55e180326 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlCore/6.8.1/QtQmlCore/private/qqmlsysteminformation_p.h @@ -0,0 +1,66 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSYSTEMINFORMATION_P_H +#define QQMLSYSTEMINFORMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtQmlCore/private/qqmlcoreglobal_p.h> +#include <QtQml/qqmlregistration.h> + +QT_BEGIN_NAMESPACE +class Q_QMLCORE_EXPORT QQmlSystemInformation : public QObject +{ + Q_OBJECT + QML_SINGLETON + QML_NAMED_ELEMENT(SystemInformation) + QML_ADDED_IN_VERSION(6, 4) + + Q_PROPERTY(int wordSize READ wordSize CONSTANT FINAL) + Q_PROPERTY(QQmlSystemInformation::Endian byteOrder READ byteOrder CONSTANT FINAL) + Q_PROPERTY(QString buildCpuArchitecture READ buildCpuArchitecture CONSTANT FINAL) + Q_PROPERTY(QString currentCpuArchitecture READ currentCpuArchitecture CONSTANT FINAL) + Q_PROPERTY(QString buildAbi READ buildAbi CONSTANT FINAL) + Q_PROPERTY(QString kernelType READ kernelType CONSTANT FINAL) + Q_PROPERTY(QString kernelVersion READ kernelVersion CONSTANT FINAL) + Q_PROPERTY(QString productType READ productType CONSTANT FINAL) + Q_PROPERTY(QString productVersion READ productVersion CONSTANT FINAL) + Q_PROPERTY(QString prettyProductName READ prettyProductName CONSTANT FINAL) + Q_PROPERTY(QString machineHostName READ machineHostName CONSTANT FINAL) + Q_PROPERTY(QByteArray machineUniqueId READ machineUniqueId CONSTANT FINAL) + Q_PROPERTY(QByteArray bootUniqueId READ bootUniqueId CONSTANT FINAL) + +public: + enum class Endian { Big, Little }; + Q_ENUM(Endian) + + explicit QQmlSystemInformation(QObject *parent = nullptr); + + int wordSize() const; + Endian byteOrder() const; + QString buildCpuArchitecture() const; + QString currentCpuArchitecture() const; + QString buildAbi() const; + QString kernelType() const; + QString kernelVersion() const; + QString productType() const; + QString productVersion() const; + QString prettyProductName() const; + QString machineHostName() const; + QByteArray machineUniqueId() const; + QByteArray bootUniqueId() const; +}; +QT_END_NAMESPACE + +#endif // QQMLSYSTEMINFORMATION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugclient_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugclient_p.h new file mode 100644 index 0000000000000000000000000000000000000000..69ac7031a435d57bac040054fc70781f2cd57276 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugclient_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGCLIENT_P_H +#define QQMLDEBUGCLIENT_P_H + +#include <QtCore/qobject.h> +#include <QtCore/private/qglobal_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlDebugConnection; +class QQmlDebugClientPrivate; +class QQmlDebugClient : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(QQmlDebugClient) + Q_DECLARE_PRIVATE(QQmlDebugClient) + +public: + enum State { NotConnected, Unavailable, Enabled }; + + QQmlDebugClient(const QString &name, QQmlDebugConnection *parent); + ~QQmlDebugClient(); + + QString name() const; + float serviceVersion() const; + State state() const; + void sendMessage(const QByteArray &message); + + QQmlDebugConnection *connection() const; + +Q_SIGNALS: + void stateChanged(State state); + +protected: + QQmlDebugClient(QQmlDebugClientPrivate &dd); + +private: + friend class QQmlDebugConnection; + virtual void messageReceived(const QByteArray &message); +}; + +QT_END_NAMESPACE + +#endif // QQMLDEBUGCLIENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugclient_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugclient_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..df608070ca00350a26f6e8aa1433711726476e99 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugclient_p_p.h @@ -0,0 +1,38 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGCLIENT_P_P_H +#define QQMLDEBUGCLIENT_P_P_H + +#include "qqmldebugclient_p.h" + +#include <private/qobject_p.h> +#include <QtCore/qpointer.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlDebugClientPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQmlDebugClient) +public: + QQmlDebugClientPrivate(const QString &name, QQmlDebugConnection *connection); + void addToConnection(); + + QString name; + QPointer<QQmlDebugConnection> connection; +}; + +QT_END_NAMESPACE + +#endif // QQMLDEBUGCLIENT_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugconnection_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugconnection_p.h new file mode 100644 index 0000000000000000000000000000000000000000..852e2951d57f02b01c111cc551b4b98c47606873 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugconnection_p.h @@ -0,0 +1,69 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGCONNECTION_P_H +#define QQMLDEBUGCONNECTION_P_H + +#include <QtCore/qobject.h> +#include <QtNetwork/qabstractsocket.h> +#include <QtCore/private/qglobal_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlDebugClient; +class QQmlDebugConnectionPrivate; +class QQmlDebugConnection : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlDebugConnection) +public: + QQmlDebugConnection(QObject *parent = nullptr); + ~QQmlDebugConnection(); + + void connectToHost(const QString &hostName, quint16 port); + void startLocalServer(const QString &fileName); + + int currentDataStreamVersion() const; + void setMaximumDataStreamVersion(int maximumVersion); + + bool isConnected() const; + bool isConnecting() const; + + void close(); + bool waitForConnected(int msecs = 30000); + + QQmlDebugClient *client(const QString &name) const; + bool addClient(const QString &name, QQmlDebugClient *client); + bool removeClient(const QString &name); + + float serviceVersion(const QString &serviceName) const; + bool sendMessage(const QString &name, const QByteArray &message); + +Q_SIGNALS: + void connected(); + void disconnected(); + void socketError(QAbstractSocket::SocketError socketError); + void socketStateChanged(QAbstractSocket::SocketState socketState); + +private: + void newConnection(); + void socketConnected(); + void socketDisconnected(); + void protocolReadyRead(); + void handshakeTimeout(); +}; + +QT_END_NAMESPACE + +#endif // QQMLDEBUGCONNECTION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugmessageclient_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugmessageclient_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f3c7dd9b7d95c8a8e7608d1499a1d984fc4ad7dc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugmessageclient_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDEBUGMESSAGECLIENT_P_H +#define QQMLDEBUGMESSAGECLIENT_P_H + +#include "qqmldebugclient_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +struct QQmlDebugContextInfo +{ + int line; + QString file; + QString function; + QString category; + qint64 timestamp; +}; + +class QQmlDebugMessageClient : public QQmlDebugClient +{ + Q_OBJECT + +public: + explicit QQmlDebugMessageClient(QQmlDebugConnection *client); + + virtual void messageReceived(const QByteArray &) override; + +Q_SIGNALS: + void message(QtMsgType, const QString &, const QQmlDebugContextInfo &); +}; + +QT_END_NAMESPACE + +#endif // QQMLDEBUGMESSAGECLIENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugtranslationclient_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugtranslationclient_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e6999b5a320766741166b0bd8f97ae667daa86ba --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmldebugtranslationclient_p.h @@ -0,0 +1,41 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQMLDEBUGTRANSLATIONCLIENT_P_H +#define QQMLDEBUGTRANSLATIONCLIENT_P_H + +#include "qqmldebugclient_p.h" + +#include <QtCore/qvector.h> +#include <private/qqmldebugtranslationprotocol_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlDebugTranslationClient : public QQmlDebugClient +{ + Q_OBJECT + +public: + explicit QQmlDebugTranslationClient(QQmlDebugConnection *client); + ~QQmlDebugTranslationClient() = default; + + virtual void messageReceived(const QByteArray &message) override; + bool languageChanged = false; + QVector<QQmlDebugTranslation::TranslationIssue> translationIssues; + QVector<QQmlDebugTranslation::QmlElement> qmlElements; + QVector<QQmlDebugTranslation::QmlState> qmlStates; +}; + +QT_END_NAMESPACE + +#endif // QQMLDEBUGTRANSLATIONCLIENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginecontrolclient_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginecontrolclient_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e04f6cc5cf962aaea25535b040c0bba65507d5ca --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginecontrolclient_p.h @@ -0,0 +1,50 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLENGINECONTROLCLIENT_P_H +#define QQMLENGINECONTROLCLIENT_P_H + +#include "qqmldebugclient_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlEngineControlClientPrivate; +class QQmlEngineControlClient : public QQmlDebugClient +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlEngineControlClient) +public: + QQmlEngineControlClient(QQmlDebugConnection *connection); + + void blockEngine(int engineId); + void releaseEngine(int engineId); + + QList<int> blockedEngines() const; + +Q_SIGNALS: + void engineAboutToBeAdded(int engineId, const QString &name); + void engineAdded(int engineId, const QString &name); + void engineAboutToBeRemoved(int engineId, const QString &name); + void engineRemoved(int engineId, const QString &name); + +protected: + QQmlEngineControlClient(QQmlEngineControlClientPrivate &dd); + +private: + void messageReceived(const QByteArray &) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLENGINECONTROLCLIENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginecontrolclient_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginecontrolclient_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0cc6ed3ec34e45461b13a36026beb21a3847dde2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginecontrolclient_p_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLENGINECONTROLCLIENT_P_P_H +#define QQMLENGINECONTROLCLIENT_P_P_H + +#include "qqmlenginecontrolclient_p.h" +#include "qqmldebugclient_p_p.h" + +#include <QtCore/QHash> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlEngineControlClientPrivate : public QQmlDebugClientPrivate +{ + Q_DECLARE_PUBLIC(QQmlEngineControlClient) +public: + enum MessageType { + EngineAboutToBeAdded, + EngineAdded, + EngineAboutToBeRemoved, + EngineRemoved + }; + + enum CommandType { + StartWaitingEngine, + StopWaitingEngine, + InvalidCommand + }; + + QQmlEngineControlClientPrivate(QQmlDebugConnection *connection); + + void sendCommand(CommandType command, int engineId); + + struct EngineState { + EngineState(CommandType command = InvalidCommand) : releaseCommand(command), blockers(0) {} + CommandType releaseCommand; + int blockers; + }; + + QHash<int, EngineState> blockedEngines; +}; + +QT_END_NAMESPACE + +#endif // QQMLENGINECONTROLCLIENT_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginedebugclient_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginedebugclient_p.h new file mode 100644 index 0000000000000000000000000000000000000000..61544fc01dee2416cd0caa55927a73cd93f4b2fa --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginedebugclient_p.h @@ -0,0 +1,143 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLENGINEDEBUGCLIENT_H +#define QQMLENGINEDEBUGCLIENT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmldebugclient_p.h> +#include <private/qpacket_p.h> + +#include <QtCore/qurl.h> +#include <QtCore/qvariant.h> + +QT_BEGIN_NAMESPACE + +struct QQmlEngineDebugPropertyReference +{ + qint32 objectDebugId = -1; + QString name; + QVariant value; + QString valueTypeName; + QString binding; + bool hasNotifySignal = false; +}; + +struct QQmlEngineDebugFileReference +{ + QUrl url; + qint32 lineNumber = -1; + qint32 columnNumber = -1; +}; + +struct QQmlEngineDebugObjectReference +{ + qint32 debugId = -1; + QString className; + QString idString; + QString name; + QQmlEngineDebugFileReference source; + qint32 contextDebugId = -1; + QList<QQmlEngineDebugPropertyReference> properties; + QList<QQmlEngineDebugObjectReference> children; +}; + +struct QQmlEngineDebugContextReference +{ + qint32 debugId = -1; + QString name; + QList<QQmlEngineDebugObjectReference> objects; + QList<QQmlEngineDebugContextReference> contexts; +}; + +struct QQmlEngineDebugEngineReference +{ + qint32 debugId = -1; + QString name; +}; + +class QQmlEngineDebugClientPrivate; +class QQmlEngineDebugClient : public QQmlDebugClient +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlEngineDebugClient) + +public: + explicit QQmlEngineDebugClient(QQmlDebugConnection *conn); + + qint32 addWatch(const QQmlEngineDebugPropertyReference &, + bool *success); + qint32 addWatch(const QQmlEngineDebugContextReference &, const QString &, + bool *success); + qint32 addWatch(const QQmlEngineDebugObjectReference &, const QString &, + bool *success); + qint32 addWatch(const QQmlEngineDebugObjectReference &, + bool *success); + qint32 addWatch(const QQmlEngineDebugFileReference &, + bool *success); + + void removeWatch(qint32 watch, bool *success); + + qint32 queryAvailableEngines(bool *success); + qint32 queryRootContexts(const QQmlEngineDebugEngineReference &, + bool *success); + qint32 queryObject(const QQmlEngineDebugObjectReference &, + bool *success); + qint32 queryObjectsForLocation(const QString &file, + qint32 lineNumber, qint32 columnNumber, bool *success); + qint32 queryObjectRecursive(const QQmlEngineDebugObjectReference &, + bool *success); + qint32 queryObjectsForLocationRecursive(const QString &file, + qint32 lineNumber, qint32 columnNumber, bool *success); + qint32 queryExpressionResult(qint32 objectDebugId, + const QString &expr, + bool *success); + qint32 queryExpressionResultBC(qint32 objectDebugId, + const QString &expr, + bool *success); + qint32 setBindingForObject(qint32 objectDebugId, const QString &propertyName, + const QVariant &bindingExpression, + bool isLiteralValue, + const QString &source, qint32 line, bool *success); + qint32 resetBindingForObject(qint32 objectDebugId, + const QString &propertyName, bool *success); + qint32 setMethodBody(qint32 objectDebugId, const QString &methodName, + const QString &methodBody, bool *success); + + qint32 getId(); + + void decode(QPacket &ds, QQmlEngineDebugContextReference &); + void decode(QPacket &ds, QQmlEngineDebugObjectReference &, bool simple); + void decode(QPacket &ds, QList<QQmlEngineDebugObjectReference> &o, bool simple); + + QList<QQmlEngineDebugEngineReference> engines() const; + QQmlEngineDebugContextReference rootContext() const; + QQmlEngineDebugObjectReference object() const; + QList<QQmlEngineDebugObjectReference> objects() const; + QVariant resultExpr() const; + bool valid() const; + +Q_SIGNALS: + void newObject(qint32 objectId); + void valueChanged(QByteArray,QVariant); + void result(); + +protected: + void messageReceived(const QByteArray &) override; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QQmlEngineDebugObjectReference) + +#endif // QQMLENGINEDEBUGCLIENT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginedebugclient_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginedebugclient_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c0087d2729841d3c9a7154b27bb3fe504527059c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlenginedebugclient_p_p.h @@ -0,0 +1,40 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLENGINEDEBUGCLIENT_P_P_H +#define QQMLENGINEDEBUGCLIENT_P_P_H + +#include "qqmlenginedebugclient_p.h" +#include "qqmldebugclient_p_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlEngineDebugClientPrivate : public QQmlDebugClientPrivate +{ + Q_DECLARE_PUBLIC(QQmlEngineDebugClient) +public: + QQmlEngineDebugClientPrivate(QQmlDebugConnection *connection); + + qint32 nextId = 0; + bool valid = false; + QList<QQmlEngineDebugEngineReference> engines; + QQmlEngineDebugContextReference rootContext; + QQmlEngineDebugObjectReference object; + QList<QQmlEngineDebugObjectReference> objects; + QVariant exprResult; +}; + +QT_END_NAMESPACE + +#endif // QQMLENGINEDEBUGCLIENT_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlinspectorclient_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlinspectorclient_p.h new file mode 100644 index 0000000000000000000000000000000000000000..668327819f17eaeccdc1213729e7206dc4df93c5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlinspectorclient_p.h @@ -0,0 +1,49 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLINSPECTORCLIENT_P_H +#define QQMLINSPECTORCLIENT_P_H + +#include <private/qqmldebugclient_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlInspectorClientPrivate; +class QQmlInspectorClient : public QQmlDebugClient +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlInspectorClient) + +public: + QQmlInspectorClient(QQmlDebugConnection *connection); + + int setInspectToolEnabled(bool enabled); + int setShowAppOnTop(bool showOnTop); + int setAnimationSpeed(qreal speed); + int select(const QList<int> &objectIds); + int createObject(const QString &qml, int parentId, const QStringList &imports, + const QString &filename); + int moveObject(int childId, int newParentId); + int destroyObject(int objectId); + +Q_SIGNALS: + void responseReceived(int requestId, bool result); + +protected: + void messageReceived(const QByteArray &message) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLINSPECTORCLIENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlinspectorclient_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlinspectorclient_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8d5cee9fa6e149af7e97d04ed3a5ae71f4406760 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlinspectorclient_p_p.h @@ -0,0 +1,33 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLINSPECTORCLIENT_P_P_H +#define QQMLINSPECTORCLIENT_P_P_H + +#include "qqmlinspectorclient_p.h" +#include "qqmldebugclient_p_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlInspectorClientPrivate : public QQmlDebugClientPrivate +{ + Q_DECLARE_PUBLIC(QQmlInspectorClient) +public: + QQmlInspectorClientPrivate(QQmlDebugConnection *connection); + int m_lastRequestId = -1; +}; + +QT_END_NAMESPACE + +#endif // QQMLINSPECTORCLIENT_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlpreviewclient_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlpreviewclient_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6ad23e905c99cd48fce61acd8e5b4feb1c1eb58e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlpreviewclient_p.h @@ -0,0 +1,73 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QQMLPREVIEWCLIENT_P_H +#define QQMLPREVIEWCLIENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmldebugclient_p.h> +#include <private/qqmldebugconnection_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlPreviewClientPrivate; +class QQmlPreviewClient : public QQmlDebugClient +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlPreviewClient) +public: + enum Command { + File, + Load, + Request, + Error, + Rerun, + Directory, + ClearCache, + Zoom, + Fps + }; + + struct FpsInfo { + quint16 numSyncs = 0; + quint16 minSync = std::numeric_limits<quint16>::max(); + quint16 maxSync = 0; + quint16 totalSync = 0; + + quint16 numRenders = 0; + quint16 minRender = std::numeric_limits<quint16>::max(); + quint16 maxRender = 0; + quint16 totalRender = 0; + }; + + QQmlPreviewClient(QQmlDebugConnection *parent); + void messageReceived(const QByteArray &message) override; + + void sendDirectory(const QString &path, const QStringList &entries); + void sendFile(const QString &path, const QByteArray &contents); + void sendError(const QString &path); + + void triggerLoad(const QUrl &url); + void triggerRerun(); + void triggerZoom(float factor); + +Q_SIGNALS: + void request(const QString &path); + void error(const QString &message); + void fps(const FpsInfo &info); +}; + +QT_END_NAMESPACE + +#endif // QQMLPREVIEWCLIENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlpreviewclient_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlpreviewclient_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..aab1262d6fc743867ead3f4a94ecc86a37232df5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlpreviewclient_p_p.h @@ -0,0 +1,34 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPREVIEWCLIENT_P_P_H +#define QQMLPREVIEWCLIENT_P_P_H + +#include "qqmlpreviewclient_p.h" +#include "qqmldebugclient_p_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlPreviewClientPrivate : public QQmlDebugClientPrivate +{ + Q_DECLARE_PUBLIC(QQmlPreviewClient) +public: + QQmlPreviewClientPrivate(QQmlDebugConnection *connection) + : QQmlDebugClientPrivate(QLatin1String("QmlPreview"), connection) + {} +}; + +QT_END_NAMESPACE + +#endif // QQMLPREVIEWCLIENT_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerclient_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerclient_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7853c46e61c84f9c0cc277dfb22db0168c0cc3a5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerclient_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROFILERCLIENT_P_H +#define QQMLPROFILERCLIENT_P_H + +#include "qqmldebugclient_p.h" +#include "qqmlprofilereventlocation_p.h" +#include "qqmlprofilereventreceiver_p.h" +#include "qqmlprofilerclientdefinitions_p.h" + +#include <private/qpacket_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlProfilerClientPrivate; +class QQmlProfilerClient : public QQmlDebugClient +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlProfilerClient) + Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged) + +public: + QQmlProfilerClient(QQmlDebugConnection *connection, QQmlProfilerEventReceiver *eventReceiver, + quint64 features = std::numeric_limits<quint64>::max()); + ~QQmlProfilerClient(); + + bool isRecording() const; + void setRecording(bool); + quint64 recordedFeatures() const; + virtual void messageReceived(const QByteArray &) override; + + void clearEvents(); + void clearAll(); + + void sendRecordingStatus(int engineId = -1); + void setRequestedFeatures(quint64 features); + void setFlushInterval(quint32 flushInterval); + +protected: + QQmlProfilerClient(QQmlProfilerClientPrivate &dd); + void onStateChanged(State status); + +Q_SIGNALS: + void complete(qint64 maximumTime); + void traceFinished(qint64 timestamp, const QList<int> &engineIds); + void traceStarted(qint64 timestamp, const QList<int> &engineIds); + + void recordingChanged(bool arg); + void recordedFeaturesChanged(quint64 features); + + void cleared(); +}; + +QT_END_NAMESPACE + +#endif // QQMLPROFILERCLIENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerclient_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerclient_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5651d355900d0c68b73c7cadf1c51a91d1cdbf45 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerclient_p_p.h @@ -0,0 +1,79 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROFILERCLIENT_P_P_H +#define QQMLPROFILERCLIENT_P_P_H + +#include "qqmldebugclient_p_p.h" +#include "qqmldebugmessageclient_p.h" +#include "qqmlenginecontrolclient_p.h" +#include "qqmlprofilerclient_p.h" +#include "qqmlprofilertypedevent_p.h" +#include "qqmlprofilerclientdefinitions_p.h" + +#include <QtCore/qqueue.h> +#include <QtCore/qstack.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlProfilerClientPrivate : public QQmlDebugClientPrivate { + Q_DECLARE_PUBLIC(QQmlProfilerClient) +public: + QQmlProfilerClientPrivate(QQmlDebugConnection *connection, + QQmlProfilerEventReceiver *eventReceiver) + : QQmlDebugClientPrivate(QLatin1String("CanvasFrameRate"), connection) + , eventReceiver(eventReceiver) + , engineControl(new QQmlEngineControlClient(connection)) + , maximumTime(0) + , recording(false) + , requestedFeatures(0) + , recordedFeatures(0) + , flushInterval(0) + { + } + + ~QQmlProfilerClientPrivate() override; + + void sendRecordingStatus(int engineId); + bool updateFeatures(ProfileFeature feature); + int resolveType(const QQmlProfilerTypedEvent &type); + int resolveStackTop(); + void forwardEvents(const QQmlProfilerEvent &last); + void forwardDebugMessages(qint64 untilTimestamp); + void processCurrentEvent(); + void finalize(); + + QQmlProfilerEventReceiver *eventReceiver; + QScopedPointer<QQmlEngineControlClient> engineControl; + QScopedPointer<QQmlDebugMessageClient> messageClient; + qint64 maximumTime; + bool recording; + quint64 requestedFeatures; + quint64 recordedFeatures; + quint32 flushInterval; + + // Reuse the same event, so that we don't have to constantly reallocate all the data. + QQmlProfilerTypedEvent currentEvent; + QHash<QQmlProfilerEventType, int> eventTypeIds; + QHash<qint64, int> serverTypeIds; + QStack<QQmlProfilerTypedEvent> rangesInProgress; + QQueue<QQmlProfilerEvent> pendingMessages; + QQueue<QQmlProfilerEvent> pendingDebugMessages; + + QList<int> trackedEngines; +}; + +QT_END_NAMESPACE + +#endif // QQMLPROFILERCLIENT_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerclientdefinitions_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerclientdefinitions_p.h new file mode 100644 index 0000000000000000000000000000000000000000..aeb807aa0fd0430b96eb7c39eaeac6d97209d8c1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerclientdefinitions_p.h @@ -0,0 +1,127 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROFILERCLIENTDEFINITIONS_P_H +#define QQMLPROFILERCLIENTDEFINITIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +enum Message { + Event, + RangeStart, + RangeData, + RangeLocation, + RangeEnd, + Complete, // end of transmission + PixmapCacheEvent, + SceneGraphFrame, + MemoryAllocation, + DebugMessage, + + MaximumMessage +}; + +enum EventType { + FramePaint, + Mouse, + Key, + AnimationFrame, + EndTrace, + StartTrace, + + MaximumEventType +}; + +enum RangeType { + Painting, + Compiling, + Creating, + Binding, //running a binding + HandlingSignal, //running a signal handler + Javascript, + + MaximumRangeType +}; + +enum PixmapEventType { + PixmapSizeKnown, + PixmapReferenceCountChanged, + PixmapCacheCountChanged, + PixmapLoadingStarted, + PixmapLoadingFinished, + PixmapLoadingError, + + MaximumPixmapEventType +}; + +enum SceneGraphFrameType { + SceneGraphRendererFrame, // Render Thread + SceneGraphAdaptationLayerFrame, // Render Thread + SceneGraphContextFrame, // Render Thread + SceneGraphRenderLoopFrame, // Render Thread + SceneGraphTexturePrepare, // Render Thread + SceneGraphTextureDeletion, // Render Thread + SceneGraphPolishAndSync, // GUI Thread + SceneGraphWindowsRenderShow, // Unused + SceneGraphWindowsAnimations, // GUI Thread + SceneGraphPolishFrame, // GUI Thread + + MaximumSceneGraphFrameType, + NumRenderThreadFrameTypes = SceneGraphPolishAndSync, + NumGUIThreadFrameTypes = MaximumSceneGraphFrameType - NumRenderThreadFrameTypes +}; + +enum MemoryType { + HeapPage, + LargeItem, + SmallItem +}; + +enum ProfileFeature { + ProfileJavaScript, + ProfileMemory, + ProfilePixmapCache, + ProfileSceneGraph, + ProfileAnimations, + ProfilePainting, + ProfileCompiling, + ProfileCreating, + ProfileBinding, + ProfileHandlingSignal, + ProfileInputEvents, + ProfileDebugMessages, + + MaximumProfileFeature +}; + +enum InputEventType { + InputKeyPress, + InputKeyRelease, + InputKeyUnknown, + + InputMousePress, + InputMouseRelease, + InputMouseMove, + InputMouseDoubleClick, + InputMouseWheel, + InputMouseUnknown, + + MaximumInputEventType +}; + +QT_END_NAMESPACE + +#endif // QQMLPROFILERCLIENTDEFINITIONS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerevent_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerevent_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b4ca54063e577620635c55f46ca0a4282e958e0d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilerevent_p.h @@ -0,0 +1,321 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROFILEREVENT_P_H +#define QQMLPROFILEREVENT_P_H + +#include "qqmlprofilerclientdefinitions_p.h" + +#include <QtCore/qstring.h> +#include <QtCore/qbytearray.h> +#include <QtCore/qvarlengtharray.h> +#include <QtCore/qmetatype.h> + +#include <initializer_list> +#include <limits> +#include <type_traits> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +struct QQmlProfilerEvent { + QQmlProfilerEvent() : + m_timestamp(-1), m_typeIndex(-1), m_dataType(Inline8Bit), m_dataLength(0) + {} + + template<typename Number> + QQmlProfilerEvent(qint64 timestamp, int typeIndex, std::initializer_list<Number> list) + : m_timestamp(timestamp), m_typeIndex(typeIndex) + { + assignNumbers<std::initializer_list<Number>, Number>(list); + } + + QQmlProfilerEvent(qint64 timestamp, int typeIndex, const QString &data) + : m_timestamp(timestamp), m_typeIndex(typeIndex) + { + assignNumbers<QByteArray, qint8>(data.toUtf8()); + } + + template<typename Number> + QQmlProfilerEvent(qint64 timestamp, int typeIndex, const QVector<Number> &data) + : m_timestamp(timestamp), m_typeIndex(typeIndex) + { + assignNumbers<QVector<Number>, Number>(data); + } + + QQmlProfilerEvent(const QQmlProfilerEvent &other) + : m_timestamp(other.m_timestamp), m_typeIndex(other.m_typeIndex), + m_dataType(other.m_dataType), m_dataLength(other.m_dataLength) + { + assignData(other); + } + + QQmlProfilerEvent(QQmlProfilerEvent &&other) + { + memcpy(static_cast<void *>(this), static_cast<const void *>(&other), sizeof(QQmlProfilerEvent)); + other.m_dataType = Inline8Bit; // prevent dtor from deleting the pointer + } + + QQmlProfilerEvent &operator=(const QQmlProfilerEvent &other) + { + if (this != &other) { + clearPointer(); + m_timestamp = other.m_timestamp; + m_typeIndex = other.m_typeIndex; + m_dataType = other.m_dataType; + m_dataLength = other.m_dataLength; + assignData(other); + } + return *this; + } + + QQmlProfilerEvent &operator=(QQmlProfilerEvent &&other) + { + if (this != &other) { + memcpy(static_cast<void *>(this), static_cast<const void *>(&other), sizeof(QQmlProfilerEvent)); + other.m_dataType = Inline8Bit; + } + return *this; + } + + ~QQmlProfilerEvent() + { + clearPointer(); + } + + qint64 timestamp() const { return m_timestamp; } + void setTimestamp(qint64 timestamp) { m_timestamp = timestamp; } + + int typeIndex() const { return m_typeIndex; } + void setTypeIndex(int typeIndex) { m_typeIndex = typeIndex; } + + template<typename Number> + Number number(int i) const + { + // Trailing zeroes can be omitted, for example for SceneGraph events + if (i >= m_dataLength) + return 0; + switch (m_dataType) { + case Inline8Bit: + return m_data.internal8bit[i]; +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Warray-bounds") // Mingw 5.3 gcc doesn't get the type/length logic. + case Inline16Bit: + return m_data.internal16bit[i]; + case Inline32Bit: + return m_data.internal32bit[i]; + case Inline64Bit: + return m_data.internal64bit[i]; +QT_WARNING_POP + case External8Bit: + return static_cast<const qint8 *>(m_data.external)[i]; + case External16Bit: + return static_cast<const qint16 *>(m_data.external)[i]; + case External32Bit: + return static_cast<const qint32 *>(m_data.external)[i]; + case External64Bit: + return static_cast<const qint64 *>(m_data.external)[i]; + default: + return 0; + } + } + + template<typename Number> + void setNumber(int i, Number number) + { + QVarLengthArray<Number> nums = numbers<QVarLengthArray<Number>, Number>(); + int prevSize = nums.size(); + if (i >= prevSize) { + nums.resize(i + 1); + // Fill with zeroes. We don't want to accidentally prevent squeezing. + while (prevSize < i) + nums[prevSize++] = 0; + } + nums[i] = number; + setNumbers<QVarLengthArray<Number>, Number>(nums); + } + + template<typename Container, typename Number> + void setNumbers(const Container &numbers) + { + clearPointer(); + assignNumbers<Container, Number>(numbers); + } + + template<typename Number> + void setNumbers(std::initializer_list<Number> numbers) + { + setNumbers<std::initializer_list<Number>, Number>(numbers); + } + + template<typename Container, typename Number = qint64> + Container numbers() const + { + Container container; + for (int i = 0; i < m_dataLength; ++i) + container.append(number<Number>(i)); + return container; + } + + QString string() const + { + switch (m_dataType) { + case External8Bit: + return QString::fromUtf8(static_cast<const char *>(m_data.external), m_dataLength); + case Inline8Bit: + return QString::fromUtf8(m_data.internalChar, m_dataLength); + default: + Q_UNREACHABLE_RETURN(QString()); + } + } + + void setString(const QString &data) + { + clearPointer(); + assignNumbers<QByteArray, char>(data.toUtf8()); + } + + Message rangeStage() const + { + Q_ASSERT(m_dataType == Inline8Bit); + return static_cast<Message>(m_data.internal8bit[0]); + } + + void setRangeStage(Message stage) + { + clearPointer(); + m_dataType = Inline8Bit; + m_dataLength = 1; + m_data.internal8bit[0] = stage; + } + + bool isValid() const + { + return m_timestamp != -1; + } + +private: + enum Type: quint16 { + External = 1, + Inline8Bit = 8, + External8Bit = Inline8Bit | External, + Inline16Bit = 16, + External16Bit = Inline16Bit | External, + Inline32Bit = 32, + External32Bit = Inline32Bit | External, + Inline64Bit = 64, + External64Bit = Inline64Bit | External + }; + + qint64 m_timestamp; + + static const int s_internalDataLength = 8; + union { + void *external; + char internalChar [s_internalDataLength]; + qint8 internal8bit [s_internalDataLength]; + qint16 internal16bit[s_internalDataLength / 2]; + qint32 internal32bit[s_internalDataLength / 4]; + qint64 internal64bit[s_internalDataLength / 8]; + } m_data; + + qint32 m_typeIndex; + Type m_dataType; + quint16 m_dataLength; + + void assignData(const QQmlProfilerEvent &other) + { + if (m_dataType & External) { + uint length = m_dataLength * (other.m_dataType / 8); + m_data.external = malloc(length); + Q_CHECK_PTR(m_data.external); + memcpy(m_data.external, other.m_data.external, length); + } else { + memcpy(&m_data, &other.m_data, sizeof(m_data)); + } + } + + template<typename Big, typename Small> + bool squeezable(Big source) + { + return static_cast<Small>(source) == source; + } + + template<typename Container, typename Number> + typename std::enable_if<(sizeof(Number) > 1), bool>::type + squeeze(const Container &numbers) + { + typedef typename QIntegerForSize<sizeof(Number) / 2>::Signed Small; + for (Number item : numbers) { + if (!squeezable<Number, Small>(item)) + return false; + } + assignNumbers<Container, Small>(numbers); + return true; + } + + template<typename Container, typename Number> + typename std::enable_if<(sizeof(Number) <= 1), bool>::type + squeeze(const Container &) + { + return false; + } + + template<typename Container, typename Number> + void assignNumbers(const Container &numbers) + { + Number *data; + m_dataLength = squeezable<size_t, quint16>(static_cast<size_t>(numbers.size())) ? + static_cast<quint16>(numbers.size()) : std::numeric_limits<quint16>::max(); + if (m_dataLength > sizeof(m_data) / sizeof(Number)) { + if (squeeze<Container, Number>(numbers)) + return; + m_dataType = static_cast<Type>((sizeof(Number) * 8) | External); + m_data.external = malloc(m_dataLength * sizeof(Number)); + Q_CHECK_PTR(m_data.external); + data = static_cast<Number *>(m_data.external); + } else { + m_dataType = static_cast<Type>(sizeof(Number) * 8); + data = static_cast<Number *>(m_dataType & External ? m_data.external : &m_data); + } + quint16 i = 0; + for (Number item : numbers) { + if (i >= m_dataLength) + break; + data[i++] = item; + } + } + + void clearPointer() + { + if (m_dataType & External) + free(m_data.external); + } + + friend QDataStream &operator>>(QDataStream &stream, QQmlProfilerEvent &event); + friend QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEvent &event); +}; + +bool operator==(const QQmlProfilerEvent &event1, const QQmlProfilerEvent &event2); +bool operator!=(const QQmlProfilerEvent &event1, const QQmlProfilerEvent &event2); + +QDataStream &operator>>(QDataStream &stream, QQmlProfilerEvent &event); +QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEvent &event); + +Q_DECLARE_TYPEINFO(QQmlProfilerEvent, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QQmlProfilerEvent) + +#endif // QQMLPROFILEREVENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilereventlocation_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilereventlocation_p.h new file mode 100644 index 0000000000000000000000000000000000000000..dbe9c067bfc80acf6f682e470ad3666e6909be72 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilereventlocation_p.h @@ -0,0 +1,86 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROFILEREVENTLOCATION_P_H +#define QQMLPROFILEREVENTLOCATION_P_H + +#include <QtCore/qstring.h> +#include <QtCore/qhash.h> +#include <QtCore/qdatastream.h> +#include <QtCore/private/qglobal_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlProfilerEventLocation +{ +public: + QQmlProfilerEventLocation() : m_line(-1),m_column(-1) {} + QQmlProfilerEventLocation(const QString &file, int lineNumber, int columnNumber) : + m_filename(file), m_line(lineNumber), m_column(columnNumber) + {} + + void clear() + { + m_filename.clear(); + m_line = m_column = -1; + } + + bool isValid() const + { + return !m_filename.isEmpty(); + } + + QString filename() const { return m_filename; } + int line() const { return m_line; } + int column() const { return m_column; } + +private: + friend QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventLocation &location); + friend QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventLocation &location); + + QString m_filename; + int m_line; + int m_column; +}; + +inline bool operator==(const QQmlProfilerEventLocation &location1, + const QQmlProfilerEventLocation &location2) +{ + // compare filename last as it's expensive. + return location1.line() == location2.line() && location1.column() == location2.column() + && location1.filename() == location2.filename(); +} + +inline bool operator!=(const QQmlProfilerEventLocation &location1, + const QQmlProfilerEventLocation &location2) +{ + return !(location1 == location2); +} + +inline size_t qHash(const QQmlProfilerEventLocation &location) +{ + return qHash(location.filename()) + ^ ((location.line() & 0xfff) // 12 bits of line number + | ((location.column() << 16) & 0xff0000)); // 8 bits of column + +} + +QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventLocation &location); +QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventLocation &location); + +Q_DECLARE_TYPEINFO(QQmlProfilerEventLocation, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + +#endif // QQMLPROFILEREVENTLOCATION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilereventreceiver_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilereventreceiver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..610d776cc446b5654e663bc7be2f60c10e284bc8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilereventreceiver_p.h @@ -0,0 +1,39 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROFILEREVENTRECEIVER_P_H +#define QQMLPROFILEREVENTRECEIVER_P_H + +#include "qqmlprofilerevent_p.h" +#include "qqmlprofilereventtype_p.h" + +#include <QtCore/qobject.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlProfilerEventReceiver : public QObject +{ + Q_OBJECT +public: + explicit QQmlProfilerEventReceiver(QObject *parent = nullptr) : QObject(parent) {} + ~QQmlProfilerEventReceiver() override; + + virtual int numLoadedEventTypes() const = 0; + virtual void addEventType(const QQmlProfilerEventType &type) = 0; + virtual void addEvent(const QQmlProfilerEvent &event) = 0; +}; + +QT_END_NAMESPACE + +#endif // QQMLPROFILEREVENTRECEIVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilereventtype_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilereventtype_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3f826edbbbc8fb938807b3f2e2c3ce075a983942 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilereventtype_p.h @@ -0,0 +1,89 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROFILEREVENTTYPE_P_H +#define QQMLPROFILEREVENTTYPE_P_H + +#include "qqmlprofilereventlocation_p.h" +#include "qqmlprofilerclientdefinitions_p.h" + +#include <QtCore/qstring.h> +#include <QtCore/qmetatype.h> +#include <QtCore/qhash.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QQmlProfilerEventType { +public: + QQmlProfilerEventType(Message message = MaximumMessage, RangeType rangeType = MaximumRangeType, + int detailType = -1, + const QQmlProfilerEventLocation &location = QQmlProfilerEventLocation(), + const QString &data = QString(), const QString displayName = QString()) : + m_displayName(displayName), m_data(data), m_location(location), m_message(message), + m_rangeType(rangeType), m_detailType(detailType) + {} + + void setDisplayName(const QString &displayName) { m_displayName = displayName; } + void setData(const QString &data) { m_data = data; } + void setLocation(const QQmlProfilerEventLocation &location) { m_location = location; } + + ProfileFeature feature() const; + QString displayName() const { return m_displayName; } + QString data() const { return m_data; } + QQmlProfilerEventLocation location() const { return m_location; } + Message message() const { return m_message; } + RangeType rangeType() const { return m_rangeType; } + int detailType() const { return m_detailType; } + +private: + friend QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventType &type); + friend QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventType &type); + + QString m_displayName; + QString m_data; + QQmlProfilerEventLocation m_location; + Message m_message; + RangeType m_rangeType; + int m_detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType +}; + +QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventType &type); +QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventType &type); + +inline size_t qHash(const QQmlProfilerEventType &type) +{ + return qHash(type.location()) + ^ (((type.message() << 12) & 0xf000) // 4 bits message + | ((type.rangeType() << 24) & 0xf000000) // 4 bits rangeType + | ((static_cast<uint>(type.detailType()) << 28) & 0xf0000000)); // 4 bits detailType +} + +inline bool operator==(const QQmlProfilerEventType &type1, const QQmlProfilerEventType &type2) +{ + return type1.message() == type2.message() && type1.rangeType() == type2.rangeType() + && type1.detailType() == type2.detailType() && type1.location() == type2.location(); +} + +inline bool operator!=(const QQmlProfilerEventType &type1, const QQmlProfilerEventType &type2) +{ + return !(type1 == type2); +} + +Q_DECLARE_TYPEINFO(QQmlProfilerEventType, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QQmlProfilerEventType) + +#endif // QQMLPROFILEREVENTTYPE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilertypedevent_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilertypedevent_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ff77e616b3e780c538c0479b9ba6ad630b177c20 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qqmlprofilertypedevent_p.h @@ -0,0 +1,40 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLPROFILERTYPEDEVENT_P_H +#define QQMLPROFILERTYPEDEVENT_P_H + +#include "qqmlprofilerevent_p.h" +#include "qqmlprofilereventtype_p.h" + +#include <QtCore/qdatastream.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +struct QQmlProfilerTypedEvent +{ + QQmlProfilerEvent event; + QQmlProfilerEventType type; + qint64 serverTypeId = 0; +}; + +QDataStream &operator>>(QDataStream &stream, QQmlProfilerTypedEvent &event); + +Q_DECLARE_TYPEINFO(QQmlProfilerTypedEvent, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QQmlProfilerTypedEvent) + +#endif // QQMLPROFILERTYPEDEVENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qv4debugclient_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qv4debugclient_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d49ff22eb05f95999907b64fc2b9b3ebcdfb1f4d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qv4debugclient_p.h @@ -0,0 +1,85 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4DEBUGCLIENT_P_H +#define QV4DEBUGCLIENT_P_H + +#include "qqmldebugclient_p.h" +#include <QtCore/qjsonvalue.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QV4DebugClientPrivate; +class QV4DebugClient : public QQmlDebugClient +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QV4DebugClient) + +public: + enum StepAction + { + Continue, + In, + Out, + Next + }; + + enum Exception + { + All, + Uncaught + }; + + struct Response + { + QString command; + QJsonValue body; + }; + + QV4DebugClient(QQmlDebugConnection *connection); + + void connect(); + void disconnect(); + + void interrupt(); + void continueDebugging(StepAction stepAction); + void evaluate(const QString &expr, int frame = -1, int context = -1); + void lookup(const QList<int> &handles, bool includeSource = false); + void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false); + void frame(int number = -1); + void scope(int number = -1, int frameNumber = -1); + void scripts(int types = 4, const QList<int> &ids = QList<int>(), bool includeSource = false); + void setBreakpoint(const QString &target, int line = -1, int column = -1, bool enabled = true, + const QString &condition = QString(), int ignoreCount = -1); + void clearBreakpoint(int breakpoint); + void changeBreakpoint(int breakpoint, bool enabled); + void setExceptionBreak(Exception type, bool enabled = false); + void version(); + + Response response() const; + +protected: + void messageReceived(const QByteArray &data) override; + +Q_SIGNALS: + void connected(); + void interrupted(); + void result(); + void failure(); + void stopped(); +}; + +QT_END_NAMESPACE + +#endif // QV4DEBUGCLIENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qv4debugclient_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qv4debugclient_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b676a8d97fdca57da47a3ba913d3b8c10d558d28 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDebug/6.8.1/QtQmlDebug/private/qv4debugclient_p_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4DEBUGCLIENT_P_P_H +#define QV4DEBUGCLIENT_P_P_H + +#include "qv4debugclient_p.h" +#include "qqmldebugclient_p_p.h" + +#include <QtCore/qjsonobject.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QV4DebugClientPrivate : public QQmlDebugClientPrivate +{ + Q_DECLARE_PUBLIC(QV4DebugClient) + +public: + QV4DebugClientPrivate(QQmlDebugConnection *connection); + + void sendMessage(const QByteArray &command, const QJsonObject &args = QJsonObject()); + void flushSendBuffer(); + QByteArray packMessage(const QByteArray &type, const QJsonObject &object); + void onStateChanged(QQmlDebugClient::State state); + + int seq = 0; + QList<QByteArray> sendBuffer; + QByteArray response; +}; + +QT_END_NAMESPACE + +#endif // QV4DEBUGCLIENT_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldom_fwd_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldom_fwd_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d0345fb1113f4188ed0b0c90170e8dbcfe2ef891 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldom_fwd_p.h @@ -0,0 +1,104 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOM_FWD_P_H +#define QQMLDOM_FWD_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "private/qglobal_p.h" + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +class AstComments; +class AttachedInfo; +class Binding; +class Comment; +class CommentedElement; +class ConstantData; +class DomBase; +enum DomCreationOption : char; +class DomEnvironment; +class DomItem; +class DomTop; +class DomUniverse; +class Empty; +class EnumDecl; +class Export; +class ExternalItemInfoBase; +class ExternalItemPairBase; +class ExternalOwningItem; +class FileLocations; +enum FileLocationRegion : int; +class FileWriter; +class GlobalComponent; +class GlobalScope; +class MockObject; +class MockOwner; +class Id; +class Import; +class JsFile; +class JsResource; +class List; +class LoadInfo; +class Map; +class MethodInfo; +class ModuleIndex; +class ModuleScope; +class MutableDomItem; +class ObserversTrie; +class OutWriter; +class OutWriterState; +class OwningItem; +class Path; +class Pragma; +class PropertyDefinition; +class PropertyInfo; +class QQmlDomAstCreator; +class QmlComponent; +class QmlDirectory; +class QmldirFile; +class QmlFile; +class QmlObject; +class QmltypesComponent; +class QmltypesFile; +class Reference; +class RegionComments; +class ScriptExpression; +class Source; +class TestDomItem; +class Version; + +namespace ScriptElements { +class BlockStatement; +class IdentifierExpression; +class Literal; +class ForStatement; +class IfStatement; +class BinaryExpression; +class VariableDeclaration; +class VariableDeclarationEntry; +class GenericScriptElement; +// TODO: add new script classes here, as qqmldomitem_p.h cannot include qqmldomscriptelements_p.h +// without creating circular dependencies +class ReturnStatement; + +} // end namespace ScriptElements + +} // end namespace Dom +} // end namespace QQmlJS +QT_END_NAMESPACE +#endif // QQMLDOM_FWD_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldom_utils_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldom_utils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..21e9078473fd0ba9f62fe6a93c7a3da192b645f1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldom_utils_p.h @@ -0,0 +1,51 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOM_UTILS_P_H +#define QQMLDOM_UTILS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include "qqmldom_fwd_p.h" +#include "qqmldomconstants_p.h" +#include <QtQml/private/qqmljssourcelocation_p.h> +#include <QtCore/qstringlist.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qcborvalue.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(QQmlJSDomImporting); + +template<class... Ts> +struct qOverloadedVisitor : Ts... +{ + using Ts::operator()...; +}; +template<class... Ts> +qOverloadedVisitor(Ts...) -> qOverloadedVisitor<Ts...>; + +namespace QQmlJS { +namespace Dom { + +QString fileLocationRegionName(FileLocationRegion region); +FileLocationRegion fileLocationRegionValue(QStringView region); + +QCborValue sourceLocationToQCborValue(SourceLocation loc); + +} // namespace Dom +}; // namespace QQmlJS + +QT_END_NAMESPACE + +#endif // QQMLDOM_UTILS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomastcreator_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomastcreator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f102d7e257305e945db32d27ac145f371d976b7e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomastcreator_p.h @@ -0,0 +1,755 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMASTCREATOR_P_H +#define QQMLDOMASTCREATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldomelements_p.h" +#include "qqmldomitem_p.h" +#include "qqmldompath_p.h" +#include "qqmldomscriptelements_p.h" + +#include <QtQmlCompiler/private/qqmljsimportvisitor_p.h> + +#include <QtQml/private/qqmljsastvisitor_p.h> +#include <memory> +#include <type_traits> +#include <variant> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +class QQmlDomAstCreator final : public AST::Visitor +{ + Q_DECLARE_TR_FUNCTIONS(QQmlDomAstCreator) + using AST::Visitor::endVisit; + using AST::Visitor::visit; + + static constexpr const auto className = "QmlDomAstCreator"; + + class DomValue + { + public: + template<typename T> + DomValue(const T &obj) : kind(T::kindValue), value(obj) + { + } + DomType kind; + std::variant<QmlObject, MethodInfo, QmlComponent, PropertyDefinition, Binding, EnumDecl, + EnumItem, ConstantData, Id> + value; + }; + + class QmlStackElement + { + public: + Path path; + DomValue item; + FileLocations::Tree fileLocations; + }; + + /*! + \internal + Contains a ScriptElementVariant, that can be used everywhere in the DOM representation, or a + List that should always be inside of something else, e.g., that cannot be the root of the + script element DOM representation. + + Also, it makes sure you do not mistreat a list as a regular script element and vice versa. + + The reason for this is that Lists can get pretty unintuitive, as a List could be a Block of + statements or a list of variable declarations (let i = 3, j = 4, ...) or something completely + different. Instead, always put lists inside named construct (BlockStatement, + VariableDeclaration, ...). + */ + class ScriptStackElement + { + public: + template<typename T> + static ScriptStackElement from(const T &obj) + { + if constexpr (std::is_same_v<T, ScriptElements::ScriptList>) { + ScriptStackElement s{ ScriptElements::ScriptList::kindValue, obj }; + return s; + } else { + ScriptStackElement s{ obj->kind(), ScriptElementVariant::fromElement(obj) }; + return s; + } + Q_UNREACHABLE(); + } + + DomType kind; + using Variant = std::variant<ScriptElementVariant, ScriptElements::ScriptList>; + Variant value; + + ScriptElementVariant takeVariant() + { + Q_ASSERT_X(std::holds_alternative<ScriptElementVariant>(value), "takeVariant", + "Should be a variant, did the parser change?"); + return std::get<ScriptElementVariant>(std::move(value)); + } + + bool isList() const { return std::holds_alternative<ScriptElements::ScriptList>(value); }; + + ScriptElements::ScriptList takeList() + { + Q_ASSERT_X(std::holds_alternative<ScriptElements::ScriptList>(value), "takeList", + "Should be a List, did the parser change?"); + return std::get<ScriptElements::ScriptList>(std::move(value)); + } + + void setSemanticScope(const QQmlJSScope::ConstPtr &scope) + { + if (auto x = std::get_if<ScriptElementVariant>(&value)) { + x->base()->setSemanticScope(scope); + return; + } else if (auto x = std::get_if<ScriptElements::ScriptList>(&value)) { + x->setSemanticScope(scope); + return; + } + Q_UNREACHABLE(); + } + }; + +public: + void enableScriptExpressions(bool enable = true) { m_enableScriptExpressions = enable; } + void enableLoadFileLazily(bool enable = true) { m_loadFileLazily = enable; } + +private: + + MutableDomItem qmlFile; + std::shared_ptr<QmlFile> qmlFilePtr; + QVector<QmlStackElement> nodeStack; + QList<ScriptStackElement> scriptNodeStack; + QVector<int> arrayBindingLevels; + FileLocations::Tree rootMap; + int m_nestedFunctionDepth = 0; + bool m_enableScriptExpressions = false; + bool m_loadFileLazily = false; + + // A Binding inside a UiPublicMember (= a Property definition) will shadow the + // propertydefinition's binding identifiers with its own binding identifiers. Therefore, disable + // bindingIdentifiers for the Binding inside a Property definition by using this flag. + bool m_skipBindingIdentifiers = false; + + void setBindingIdentifiers(const Path &pathFromOwner, const AST::UiQualifiedId *identifiers, + Binding *bindingPtr); + template<typename T> + QmlStackElement ¤tEl(int idx = 0) + { + Q_ASSERT_X(idx < nodeStack.size() && idx >= 0, "currentQmlObjectOrComponentEl", + "Stack does not contain enough elements!"); + int i = nodeStack.size() - idx; + while (i-- > 0) { + DomType k = nodeStack.at(i).item.kind; + if (k == T::kindValue) + return nodeStack[i]; + } + Q_ASSERT_X(false, "currentEl", "Stack does not contan object of type "); + return nodeStack.last(); + } + + template<typename T> + ScriptStackElement ¤tScriptEl(int idx = 0) + { + Q_ASSERT_X(m_enableScriptExpressions, "currentScriptEl", + "Cannot access script elements when they are disabled!"); + + Q_ASSERT_X(idx < scriptNodeStack.size() && idx >= 0, "currentQmlObjectOrComponentEl", + "Stack does not contain enough elements!"); + int i = scriptNodeStack.size() - idx; + while (i-- > 0) { + DomType k = scriptNodeStack.at(i).kind; + if (k == T::element_type::kindValue) + return scriptNodeStack[i]; + } + Q_ASSERT_X(false, "currentEl", "Stack does not contain object of type "); + return scriptNodeStack.last(); + } + + template<typename T> + T ¤t(int idx = 0) + { + return std::get<T>(currentEl<T>(idx).item.value); + } + + index_type currentIndex() { return currentNodeEl().path.last().headIndex(); } + + QmlStackElement ¤tQmlObjectOrComponentEl(int idx = 0); + + QmlStackElement ¤tNodeEl(int i = 0); + ScriptStackElement ¤tScriptNodeEl(int i = 0); + + DomValue ¤tNode(int i = 0); + + void removeCurrentNode(std::optional<DomType> expectedType); + void removeCurrentScriptNode(std::optional<DomType> expectedType); + + void pushEl(const Path &p, const DomValue &it, AST::Node *n) + { + nodeStack.append({ p, it, createMap(it.kind, p, n) }); + } + + FileLocations::Tree createMap(const FileLocations::Tree &base, const Path &p, AST::Node *n); + + FileLocations::Tree createMap(DomType k, const Path &p, AST::Node *n); + + const ScriptElementVariant & + finalizeScriptExpression(const ScriptElementVariant &element, const Path &pathFromOwner, + const FileLocations::Tree &ownerFileLocations); + + void setScriptExpression (const std::shared_ptr<ScriptExpression>& value); + + Path pathOfLastScriptNode() const; + + /*! + \internal + Helper to create string literals from AST nodes. + */ + template<typename AstNodeT> + static std::shared_ptr<ScriptElements::Literal> makeStringLiteral(QStringView value, + AstNodeT *ast) + { + auto myExp = std::make_shared<ScriptElements::Literal>(ast->firstSourceLocation(), + ast->lastSourceLocation()); + myExp->setLiteralValue(value.toString()); + return myExp; + } + + static std::shared_ptr<ScriptElements::Literal> makeStringLiteral(QStringView value, + QQmlJS::SourceLocation loc) + { + auto myExp = std::make_shared<ScriptElements::Literal>(loc); + myExp->setLiteralValue(value.toString()); + return myExp; + } + + /*! + \internal + Helper to create script elements from AST nodes, as the DOM classes should be completely + dependency-free from AST and parser classes. Using the AST classes in qqmldomastcreator is + fine because it needs them for the construction/visit. \sa makeScriptList + */ + template<typename ScriptElementT, typename AstNodeT, + typename Enable = + std::enable_if_t<!std::is_same_v<ScriptElementT, ScriptElements::ScriptList>>> + static decltype(auto) makeScriptElement(AstNodeT *ast) + { + auto myExp = std::make_shared<ScriptElementT>(ast->firstSourceLocation(), + ast->lastSourceLocation()); + return myExp; + } + + /*! + \internal + Helper to create generic script elements from AST nodes. + \sa makeScriptElement + */ + template<typename AstNodeT> + static std::shared_ptr<ScriptElements::GenericScriptElement> + makeGenericScriptElement(AstNodeT *ast, DomType kind) + { + auto myExp = std::make_shared<ScriptElements::GenericScriptElement>( + ast->firstSourceLocation(), ast->lastSourceLocation()); + myExp->setKind(kind); + return myExp; + } + + enum UnaryExpressionKind { Prefix, Postfix }; + std::shared_ptr<ScriptElements::GenericScriptElement> + makeUnaryExpression(AST::Node *expression, QQmlJS::SourceLocation operatorToken, + bool hasExpression, UnaryExpressionKind type); + + static std::shared_ptr<ScriptElements::GenericScriptElement> + makeGenericScriptElement(SourceLocation location, DomType kind) + { + auto myExp = std::make_shared<ScriptElements::GenericScriptElement>(location); + myExp->setKind(kind); + return myExp; + } + + /*! + \internal + Helper to create script lists from AST nodes. + \sa makeScriptElement + */ + template<typename AstNodeT> + static decltype(auto) makeScriptList(AstNodeT *ast) + { + auto myExp = + ScriptElements::ScriptList(ast->firstSourceLocation(), ast->lastSourceLocation()); + return myExp; + } + + template<typename ScriptElementT> + void pushScriptElement(const ScriptElementT &element) + { + Q_ASSERT_X(m_enableScriptExpressions, "pushScriptElement", + "Cannot create script elements when they are disabled!"); + scriptNodeStack.append(ScriptStackElement::from(element)); + } + + void disableScriptElements() + { + m_enableScriptExpressions = false; + scriptNodeStack.clear(); + } + + ScriptElementVariant scriptElementForQualifiedId(AST::UiQualifiedId *expression); + +public: + explicit QQmlDomAstCreator(const MutableDomItem &qmlFile); + + bool visit(AST::UiProgram *program) override; + void endVisit(AST::UiProgram *) override; + + bool visit(AST::UiPragma *el) override; + + bool visit(AST::UiImport *el) override; + + bool visit(AST::UiPublicMember *el) override; + void endVisit(AST::UiPublicMember *el) override; + +private: + ScriptElementVariant prepareBodyForFunction(AST::FunctionExpression *fExpression); + +public: + bool visit(AST::FunctionExpression *el) override; + void endVisit(AST::FunctionExpression *) override; + + bool visit(AST::FunctionDeclaration *el) override; + void endVisit(AST::FunctionDeclaration *) override; + + bool visit(AST::UiSourceElement *el) override; + void endVisit(AST::UiSourceElement *) override; + + void loadAnnotations(AST::UiObjectMember *el) { AST::Node::accept(el->annotations, this); } + + bool visit(AST::UiObjectDefinition *el) override; + void endVisit(AST::UiObjectDefinition *) override; + + bool visit(AST::UiObjectBinding *el) override; + void endVisit(AST::UiObjectBinding *) override; + + bool visit(AST::UiScriptBinding *el) override; + void endVisit(AST::UiScriptBinding *) override; + + bool visit(AST::UiArrayBinding *el) override; + void endVisit(AST::UiArrayBinding *) override; + + bool visit(AST::UiQualifiedId *) override; + + bool visit(AST::UiEnumDeclaration *el) override; + void endVisit(AST::UiEnumDeclaration *) override; + + bool visit(AST::UiEnumMemberList *el) override; + void endVisit(AST::UiEnumMemberList *el) override; + + bool visit(AST::UiInlineComponent *el) override; + void endVisit(AST::UiInlineComponent *) override; + + bool visit(AST::UiRequired *el) override; + + bool visit(AST::UiAnnotation *el) override; + void endVisit(AST::UiAnnotation *) override; + + // for Script elements: + bool visit(AST::BinaryExpression *exp) override; + void endVisit(AST::BinaryExpression *exp) override; + + bool visit(AST::Block *block) override; + void endVisit(AST::Block *) override; + + bool visit(AST::YieldExpression *block) override; + void endVisit(AST::YieldExpression *) override; + + bool visit(AST::ReturnStatement *block) override; + void endVisit(AST::ReturnStatement *) override; + + bool visit(AST::ForStatement *forStatement) override; + void endVisit(AST::ForStatement *forStatement) override; + + bool visit(AST::PatternElement *pe) override; + void endVisit(AST::PatternElement *pe) override; + void endVisitHelper(AST::PatternElement *pe, + const std::shared_ptr<ScriptElements::GenericScriptElement> &element); + + bool visit(AST::IfStatement *) override; + void endVisit(AST::IfStatement *) override; + + bool visit(AST::FieldMemberExpression *) override; + void endVisit(AST::FieldMemberExpression *) override; + + bool visit(AST::ArrayMemberExpression *) override; + void endVisit(AST::ArrayMemberExpression *) override; + + bool visit(AST::CallExpression *) override; + void endVisit(AST::CallExpression *) override; + + bool visit(AST::ArrayPattern *) override; + void endVisit(AST::ArrayPattern *) override; + + bool visit(AST::ObjectPattern *) override; + void endVisit(AST::ObjectPattern *) override; + + bool visit(AST::PatternProperty *) override; + void endVisit(AST::PatternProperty *) override; + + bool visit(AST::VariableStatement *) override; + void endVisit(AST::VariableStatement *) override; + + bool visit(AST::Type *expression) override; + void endVisit(AST::Type *expression) override; + + bool visit(AST::DefaultClause *) override; + void endVisit(AST::DefaultClause *) override; + + bool visit(AST::CaseClause *) override; + void endVisit(AST::CaseClause *) override; + + bool visit(AST::CaseClauses *) override; + void endVisit(AST::CaseClauses *) override; + + bool visit(AST::CaseBlock *) override; + void endVisit(AST::CaseBlock *) override; + + bool visit(AST::SwitchStatement *) override; + void endVisit(AST::SwitchStatement *) override; + + bool visit(AST::WhileStatement *) override; + void endVisit(AST::WhileStatement *) override; + + bool visit(AST::DoWhileStatement *) override; + void endVisit(AST::DoWhileStatement *) override; + + bool visit(AST::ForEachStatement *) override; + void endVisit(AST::ForEachStatement *) override; + + bool visit(AST::ClassExpression *) override; + void endVisit(AST::ClassExpression *) override; + + bool visit(AST::TryStatement *) override; + void endVisit(AST::TryStatement *) override; + + bool visit(AST::Catch *) override; + void endVisit(AST::Catch *) override; + + bool visit(AST::Finally *) override; + void endVisit(AST::Finally *) override; + + bool visit(AST::ThrowStatement *) override; + void endVisit(AST::ThrowStatement *) override; + + bool visit(AST::LabelledStatement *) override; + void endVisit(AST::LabelledStatement *) override; + + bool visit(AST::ContinueStatement *) override; + void endVisit(AST::ContinueStatement *) override; + + bool visit(AST::BreakStatement *) override; + void endVisit(AST::BreakStatement *) override; + + bool visit(AST::Expression *) override; + void endVisit(AST::Expression *) override; + + bool visit(AST::ConditionalExpression *) override; + void endVisit(AST::ConditionalExpression *) override; + + bool visit(AST::UnaryMinusExpression *) override; + void endVisit(AST::UnaryMinusExpression *) override; + + bool visit(AST::UnaryPlusExpression *) override; + void endVisit(AST::UnaryPlusExpression *) override; + + bool visit(AST::TildeExpression *) override; + void endVisit(AST::TildeExpression *) override; + + bool visit(AST::NotExpression *) override; + void endVisit(AST::NotExpression *) override; + + bool visit(AST::TypeOfExpression *) override; + void endVisit(AST::TypeOfExpression *) override; + + bool visit(AST::DeleteExpression *) override; + void endVisit(AST::DeleteExpression *) override; + + bool visit(AST::VoidExpression *) override; + void endVisit(AST::VoidExpression *) override; + + bool visit(AST::PostDecrementExpression *) override; + void endVisit(AST::PostDecrementExpression *) override; + + bool visit(AST::PostIncrementExpression *) override; + void endVisit(AST::PostIncrementExpression *) override; + + bool visit(AST::PreDecrementExpression *) override; + void endVisit(AST::PreDecrementExpression *) override; + + bool visit(AST::PreIncrementExpression *) override; + void endVisit(AST::PreIncrementExpression *) override; + + bool visit(AST::EmptyStatement *) override; + void endVisit(AST::EmptyStatement *) override; + + bool visit(AST::NestedExpression *) override; + void endVisit(AST::NestedExpression *) override; + + bool visit(AST::NewExpression *) override; + void endVisit(AST::NewExpression *) override; + + bool visit(AST::NewMemberExpression *) override; + void endVisit(AST::NewMemberExpression *) override; + + // lists of stuff whose children don't need a qqmljsscope: visitation order can be custom + bool visit(AST::UiParameterList *) override; + bool visit(AST::Elision *elision) override; + + + // lists of stuff whose children need a qqmljsscope: visitation order cannot be custom + void endVisit(AST::StatementList *list) override; + void endVisit(AST::VariableDeclarationList *vdl) override; + void endVisit(AST::ArgumentList *) override; + void endVisit(AST::PatternElementList *) override; + void endVisit(AST::PatternPropertyList *) override; + void endVisit(AST::FormalParameterList *el) override; + void endVisit(AST::TemplateLiteral *) override; + void endVisit(AST::TaggedTemplate *) override; + + + // literals and ids + bool visit(AST::IdentifierExpression *expression) override; + bool visit(AST::NumericLiteral *expression) override; + bool visit(AST::StringLiteral *expression) override; + bool visit(AST::NullExpression *expression) override; + bool visit(AST::TrueLiteral *expression) override; + bool visit(AST::FalseLiteral *expression) override; + bool visit(AST::ComputedPropertyName *expression) override; + bool visit(AST::IdentifierPropertyName *expression) override; + bool visit(AST::NumericLiteralPropertyName *expression) override; + bool visit(AST::StringLiteralPropertyName *expression) override; + bool visit(AST::TypeAnnotation *expression) override; + bool visit(AST::RegExpLiteral *) override; + bool visit(AST::ThisExpression *) override; + bool visit(AST::SuperLiteral *) override; + + void throwRecursionDepthError() override; + + bool stackHasScriptVariant() const + { + return !scriptNodeStack.isEmpty() && !scriptNodeStack.last().isList(); + } + bool stackHasScriptList() const + { + return !scriptNodeStack.isEmpty() && scriptNodeStack.last().isList(); + } + +private: + template<typename T> + void endVisitForLists(T *list, const std::function<int(T *)> &scriptElementsPerEntry = {}); + +public: + friend class QQmlDomAstCreatorWithQQmlJSScope; +}; + +class QQmlDomAstCreatorWithQQmlJSScope : public AST::Visitor +{ +public: + QQmlDomAstCreatorWithQQmlJSScope(const QQmlJSScope::Ptr ¤t, MutableDomItem &qmlFile, + QQmlJSLogger *logger, QQmlJSImporter *importer); + +#define X(name) \ + bool visit(AST::name *) override; \ + void endVisit(AST::name *) override; + QQmlJSASTClassListToVisit +#undef X + + virtual void throwRecursionDepthError() override; + /*! + \internal + Disable the DOM for scriptexpressions, as not yet unimplemented script elements might crash + the construction. + */ + void enableScriptExpressions(bool enable = true) + { + m_enableScriptExpressions = enable; + m_domCreator.enableScriptExpressions(enable); + } + + void enableLoadFileLazily(bool enable = true) + { + m_loadFileLazily = enable; + m_domCreator.enableLoadFileLazily(enable); + } + + QQmlJSImportVisitor &scopeCreator() { return m_scopeCreator; } + +private: + void setScopeInDomAfterEndvisit(); + void setScopeInDomBeforeEndvisit(); + + template<typename U, typename... V> + using IsInList = std::disjunction<std::is_same<U, V>...>; + template<typename U> + using RequiresCustomIteration = + IsInList<U, AST::PatternElementList, AST::PatternPropertyList, AST::FormalParameterList, + AST::VariableDeclarationList, AST::TemplateLiteral>; + + enum VisitorKind : bool { DomCreator, ScopeCreator }; + /*! \internal + \brief Holds the information to reactivate a visitor + This struct tracks a visitor during its inactive phases + and holds the information needed to reactivate the visitor. + */ + struct InactiveVisitorMarker + { + qsizetype count; + AST::Node::Kind nodeKind; + VisitorKind inactiveVisitorKind; + + VisitorKind stillActiveVisitorKind() const + { + return inactiveVisitorKind == DomCreator ? ScopeCreator : DomCreator; + } + }; + + template<typename T> + void customListIteration(T *t) + { + static_assert(RequiresCustomIteration<T>::value); + for (T* it = t; it; it = it->next) { + if constexpr (std::is_same_v<T, AST::PatternElementList>) { + AST::Node::accept(it->elision, this); + AST::Node::accept(it->element, this); + } else if constexpr (std::is_same_v<T, AST::PatternPropertyList>) { + AST::Node::accept(it->property, this); + } else if constexpr (std::is_same_v<T, AST::FormalParameterList>) { + AST::Node::accept(it->element, this); + } else if constexpr (std::is_same_v<T, AST::VariableDeclarationList>) { + AST::Node::accept(it->declaration, this); + } else if constexpr (std::is_same_v<T, AST::ArgumentList>) { + AST::Node::accept(it->expression, this); + } else if constexpr (std::is_same_v<T, AST::PatternElementList>) { + AST::Node::accept(it->elision, this); + AST::Node::accept(it->element, this); + } else if constexpr (std::is_same_v<T, AST::TemplateLiteral>) { + AST::Node::accept(it->expression, this); + } else { + Q_UNREACHABLE(); + } + } + } + + static void initMarkerForActiveVisitor(std::optional<InactiveVisitorMarker> &inactiveVisitorMarker, + AST::Node::Kind nodeKind, bool continueForDom) + { + inactiveVisitorMarker.emplace(); + inactiveVisitorMarker->inactiveVisitorKind = continueForDom ? ScopeCreator : DomCreator; + inactiveVisitorMarker->count = 1; + inactiveVisitorMarker->nodeKind = nodeKind; + }; + + template<typename T> + bool performListIterationIfRequired(T *t) + { + if constexpr (RequiresCustomIteration<T>::value) { + customListIteration(t); + return false; + } + Q_UNUSED(t); + return true; + } + + template<typename T> + bool visitT(T *t) + { + const auto handleVisitResult = [this, t](const bool continueVisit) { + if (m_inactiveVisitorMarker && m_inactiveVisitorMarker->nodeKind == t->kind) + m_inactiveVisitorMarker->count += 1; + + if (continueVisit) + return performListIterationIfRequired(t); + return continueVisit; + }; + + // first case: no marker, both can visit + if (!m_inactiveVisitorMarker) { + bool continueForDom = m_domCreator.visit(t); + bool continueForScope = m_scopeCreator.visit(t); + if (!continueForDom && !continueForScope) + return false; + else if (continueForDom ^ continueForScope) { + initMarkerForActiveVisitor(m_inactiveVisitorMarker, AST::Node::Kind(t->kind), + continueForDom); + return performListIterationIfRequired(t); + } else { + Q_ASSERT(continueForDom && continueForScope); + return performListIterationIfRequired(t); + } + Q_UNREACHABLE(); + } + + // second case: a marker, just one visit + switch (m_inactiveVisitorMarker->stillActiveVisitorKind()) { + case DomCreator: + return handleVisitResult(m_domCreator.visit(t)); + case ScopeCreator: + return handleVisitResult(m_scopeCreator.visit(t)); + }; + Q_UNREACHABLE(); + } + + template<typename T> + void endVisitT(T *t) + { + if (m_inactiveVisitorMarker && m_inactiveVisitorMarker->nodeKind == t->kind) { + m_inactiveVisitorMarker->count -= 1; + if (m_inactiveVisitorMarker->count == 0) + m_inactiveVisitorMarker.reset(); + } + if (m_inactiveVisitorMarker) { + switch (m_inactiveVisitorMarker->stillActiveVisitorKind()) { + case DomCreator: + m_domCreator.endVisit(t); + return; + case ScopeCreator: + m_scopeCreator.endVisit(t); + return; + }; + Q_UNREACHABLE(); + } + + setScopeInDomBeforeEndvisit(); + m_domCreator.endVisit(t); + setScopeInDomAfterEndvisit(); + m_scopeCreator.endVisit(t); + } + + QQmlJSScope::Ptr m_root; + QQmlJSLogger *m_logger = nullptr; + QQmlJSImporter *m_importer = nullptr; + QString m_implicitImportDirectory; + QQmlJSImportVisitor m_scopeCreator; + QQmlDomAstCreator m_domCreator; + + std::optional<InactiveVisitorMarker> m_inactiveVisitorMarker; + bool m_enableScriptExpressions = false; + bool m_loadFileLazily = false; +}; + +} // end namespace Dom +} // end namespace QQmlJS + +QT_END_NAMESPACE +#endif // QQMLDOMASTCREATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomastdumper_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomastdumper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e07f325616c72e0665404b9ad99a53c7a72f65e4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomastdumper_p.h @@ -0,0 +1,56 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMASTDUMPER_P_H +#define QQMLDOMASTDUMPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldomconstants_p.h" +#include "qqmldomstringdumper_p.h" + +#include <QtQml/private/qqmljsglobal_p.h> +#include <QtQml/private/qqmljsastvisitor_p.h> +#include <QtCore/QString> + +QT_BEGIN_NAMESPACE +class QDebug; + +namespace QQmlJS { +namespace Dom { + +inline QStringView noStr(SourceLocation) +{ + return QStringView(); +} + +QMLDOM_EXPORT QString lineDiff(QString s1, QString s2, int nContext); +QMLDOM_EXPORT QString astNodeDiff(AST::Node *n1, AST::Node *n2, int nContext = 3, + AstDumperOptions opt = AstDumperOption::None, int indent = 0, + function_ref<QStringView(SourceLocation)> loc2str1 = noStr, + function_ref<QStringView(SourceLocation)> loc2str2 = noStr); +QMLDOM_EXPORT void astNodeDumper(const Sink &s, AST::Node *n, AstDumperOptions opt = AstDumperOption::None, + int indent = 1, int baseIndent = 0, + function_ref<QStringView(SourceLocation)> loc2str = noStr); +QMLDOM_EXPORT QString astNodeDump(AST::Node *n, AstDumperOptions opt = AstDumperOption::None, + int indent = 1, int baseIndent = 0, + function_ref<QStringView(SourceLocation)> loc2str = noStr); + +QMLDOM_EXPORT QDebug operator<<(QDebug d, AST::Node *n); + +} // namespace Dom +} // namespace AST + +QT_END_NAMESPACE + +#endif // QQMLDOMASTDUMPER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomattachedinfo_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomattachedinfo_p.h new file mode 100644 index 0000000000000000000000000000000000000000..238a21b4552d5c9f03322eca0adbf5ce8c97ed16 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomattachedinfo_p.h @@ -0,0 +1,311 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMLDOMATTACHEDINFO_P_H +#define QMLDOMATTACHEDINFO_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldomitem_p.h" + +#include <memory> +#include <optional> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { +struct AttachedInfoLookupResultBase +{ + Path lookupPath; + Path rootTreePath; + Path foundTreePath; +}; +template<typename TreePtr> +class AttachedInfoLookupResult: public AttachedInfoLookupResultBase +{ +public: + TreePtr foundTree; + + operator bool() { return bool(foundTree); } + template<typename T> + AttachedInfoLookupResult<std::shared_ptr<T>> as() const + { + AttachedInfoLookupResult<std::shared_ptr<T>> res; + res.AttachedInfoLookupResultBase::operator=(*this); + res.foundTree = std::static_pointer_cast<T>(foundTree); + return res; + } +}; + +class QMLDOM_EXPORT AttachedInfo : public OwningItem { + Q_GADGET +public: + enum class PathType { + Relative, + Canonical + }; + Q_ENUM(PathType) + + constexpr static DomType kindValue = DomType::AttachedInfo; + using Ptr = std::shared_ptr<AttachedInfo>; + + DomType kind() const override { return kindValue; } + Path canonicalPath(const DomItem &self) const override { return self.m_ownerPath; } + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + + AttachedInfo::Ptr makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<AttachedInfo>(doCopy(self)); + } + + Ptr parent() const { return m_parent.lock(); } + Path path() const { return m_path; } + void setPath(const Path &p) { m_path = p; } + + AttachedInfo(const Ptr &parent = nullptr, const Path &p = Path()) + : m_path(p), m_parent(parent) + {} + + AttachedInfo(const AttachedInfo &o); + + static Ptr ensure(const Ptr &self, const Path &path, PathType pType = PathType::Relative); + static Ptr find(const Ptr &self, const Path &p, PathType pType = PathType::Relative); + static AttachedInfoLookupResult<Ptr> findAttachedInfo(const DomItem &item, + QStringView treeFieldName); + static Ptr treePtr(const DomItem &item, QStringView fieldName) + { + return findAttachedInfo(item, fieldName).foundTree; + } + + DomItem itemAtPath(const DomItem &self, const Path &p, PathType pType = PathType::Relative) const + { + if (Ptr resPtr = find(self.ownerAs<AttachedInfo>(), p, pType)) { + const Path relative = (pType == PathType::Canonical) ? p.mid(m_path.length()) : p; + Path resPath = self.canonicalPath(); + for (const Path &pEl : relative) { + resPath = resPath.field(Fields::subItems).key(pEl.toString()); + } + return self.copy(resPtr, resPath); + } + return DomItem(); + } + + DomItem infoAtPath(const DomItem &self, const Path &p, PathType pType = PathType::Relative) const + { + return itemAtPath(self, p, pType).field(Fields::infoItem); + } + + MutableDomItem ensureItemAtPath(MutableDomItem &self, const Path &p, + PathType pType = PathType::Relative) + { + if (Ptr resPtr = ensure(self.ownerAs<AttachedInfo>(), p, pType)) { + const Path relative = (pType == PathType::Canonical) ? p.mid(m_path.length()) : p; + Path resPath = self.canonicalPath(); + for (const Path &pEl : relative) { + resPath = resPath.field(Fields::subItems).key(pEl.toString()); + } + return MutableDomItem(self.item().copy(resPtr, resPath)); + } + return MutableDomItem(); + } + + MutableDomItem ensureInfoAtPath(MutableDomItem &self, const Path &p, + PathType pType = PathType::Relative) + { + return ensureItemAtPath(self, p, pType).field(Fields::infoItem); + } + + virtual AttachedInfo::Ptr instantiate( + const AttachedInfo::Ptr &parent, const Path &p = Path()) const = 0; + virtual DomItem infoItem(const DomItem &self) const = 0; + QMap<Path, Ptr> subItems() const { + return m_subItems; + } + void setSubItems(QMap<Path, Ptr> v) { + m_subItems = v; + } +protected: + Path m_path; + std::weak_ptr<AttachedInfo> m_parent; + QMap<Path, Ptr> m_subItems; +}; + +template<typename Info> +class QMLDOM_EXPORT AttachedInfoT final : public AttachedInfo +{ +public: + constexpr static DomType kindValue = DomType::AttachedInfo; + using Ptr = std::shared_ptr<AttachedInfoT>; + using InfoType = Info; + + AttachedInfoT(const Ptr &parent = nullptr, const Path &p = Path()) : AttachedInfo(parent, p) {} + AttachedInfoT(const AttachedInfoT &o): + AttachedInfo(o), + m_info(o.m_info) + { + auto end = o.m_subItems.end(); + auto i = o.m_subItems.begin(); + while (i != end) { + m_subItems.insert(i.key(), Ptr( + new AttachedInfoT(*std::static_pointer_cast<AttachedInfoT>(i.value()).get()))); + } + } + + static Ptr createTree(const Path &p = Path()) { + return Ptr(new AttachedInfoT(nullptr, p)); + } + + static Ptr ensure(const Ptr &self, const Path &path, PathType pType = PathType::Relative) + { + return std::static_pointer_cast<AttachedInfoT>(AttachedInfo::ensure(self, path, pType)); + } + + static Ptr find(const Ptr &self, const Path &p, PathType pType = PathType::Relative) + { + return std::static_pointer_cast<AttachedInfoT>(AttachedInfo::find(self, p, pType)); + } + + static AttachedInfoLookupResult<Ptr> findAttachedInfo(const DomItem &item, + QStringView fieldName) + { + return AttachedInfo::findAttachedInfo(item, fieldName).template as<AttachedInfoT>(); + } + static Ptr treePtr(const DomItem &item, QStringView fieldName) + { + return std::static_pointer_cast<AttachedInfoT>(AttachedInfo::treePtr(item, fieldName)); + } + static bool visitTree( + const Ptr &base, function_ref<bool(const Path &, const Ptr &)> visitor, + const Path &basePath = Path()) { + if (base) { + Path pNow = basePath.path(base->path()); + if (visitor(pNow, base)) { + auto it = base->m_subItems.cbegin(); + auto end = base->m_subItems.cend(); + while (it != end) { + if (!visitTree(std::static_pointer_cast<AttachedInfoT>(it.value()), visitor, pNow)) + return false; + ++it; + } + } else { + return false; + } + } + return true; + } + + AttachedInfo::Ptr instantiate( + const AttachedInfo::Ptr &parent, const Path &p = Path()) const override + { + return Ptr(new AttachedInfoT(std::static_pointer_cast<AttachedInfoT>(parent), p)); + } + + DomItem infoItem(const DomItem &self) const override { return self.wrapField(Fields::infoItem, m_info); } + + Ptr makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<AttachedInfoT>(doCopy(self)); + } + + Ptr parent() const { return std::static_pointer_cast<AttachedInfoT>(AttachedInfo::parent()); } + + const Info &info() const { return m_info; } + Info &info() { return m_info; } + + QString canonicalPathForTesting() const + { + QString result; + for (auto *it = this; it; it = it->parent().get()) { + result.prepend(it->path().toString()); + } + return result; + } + +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &) const override + { + return Ptr(new AttachedInfoT(*this)); + } + +private: + Info m_info; +}; + +class QMLDOM_EXPORT FileLocations { +public: + using Tree = std::shared_ptr<AttachedInfoT<FileLocations>>; + constexpr static DomType kindValue = DomType::FileLocations; + DomType kind() const { return kindValue; } + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const; + + static Tree createTree(const Path &basePath); + static Tree ensure(const Tree &base, const Path &basePath, + AttachedInfo::PathType pType = AttachedInfo::PathType::Relative); + static Tree find(const Tree &self, const Path &p, + AttachedInfo::PathType pType = AttachedInfo::PathType::Relative) + { + return AttachedInfoT<FileLocations>::find(self, p, pType); + } + + // returns the path looked up and the found tree when looking for the info attached to item + static AttachedInfoLookupResult<Tree> findAttachedInfo(const DomItem &item); + static FileLocations::Tree treeOf(const DomItem &); + static const FileLocations *fileLocationsOf(const DomItem &); + + static void updateFullLocation(const Tree &fLoc, SourceLocation loc); + static void addRegion(const Tree &fLoc, FileLocationRegion region, SourceLocation loc); + static QQmlJS::SourceLocation region(const Tree &fLoc, FileLocationRegion region); + +private: + static QMetaEnum regionEnum; + +public: + SourceLocation fullRegion; + QMap<FileLocationRegion, SourceLocation> regions; + QMap<FileLocationRegion, QList<SourceLocation>> preCommentLocations; + QMap<FileLocationRegion, QList<SourceLocation>> postCommentLocations; +}; + +class QMLDOM_EXPORT UpdatedScriptExpression +{ + Q_GADGET +public: + using Tree = std::shared_ptr<AttachedInfoT<UpdatedScriptExpression>>; + constexpr static DomType kindValue = DomType::UpdatedScriptExpression; + DomType kind() const { return kindValue; } + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const; + + static Tree createTree(const Path &basePath); + static Tree ensure(const Tree &base, const Path &basePath, AttachedInfo::PathType pType); + + // returns the path looked up and the found tree when looking for the info attached to item + static AttachedInfoLookupResult<Tree> + findAttachedInfo(const DomItem &item); + // convenience: find FileLocations::Tree attached to the given item + static Tree treePtr(const DomItem &); + // convenience: find FileLocations* attached to the given item (if there is one) + static const UpdatedScriptExpression *exprPtr(const DomItem &); + + static bool visitTree( + const Tree &base, function_ref<bool(const Path &, const Tree &)> visitor, + const Path &basePath = Path()); + + std::shared_ptr<ScriptExpression> expr; +}; + +} // end namespace Dom +} // end namespace QQmlJS + +QT_END_NAMESPACE +#endif // QMLDOMATTACHEDINFO_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomcodeformatter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomcodeformatter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b434f0ae38c864b3ae223237a3a0ee532641ecee --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomcodeformatter_p.h @@ -0,0 +1,275 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMCODEFORMATTER_P_H +#define QQMLDOMCODEFORMATTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldomfunctionref_p.h" +#include "qqmldomscanner_p.h" +#include "qqmldomlinewriter_p.h" + +#include <QtCore/QStack> +#include <QtCore/QList> +#include <QtCore/QSet> +#include <QtCore/QVector> +#include <QtCore/QMetaObject> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +class QMLDOM_EXPORT FormatTextStatus +{ + Q_GADGET +public: + enum class StateType : quint8 { + Invalid = 0, + + TopmostIntro, // The first line in a "topmost" definition. + + TopQml, // root state for qml + TopJs, // root for js + ObjectdefinitionOrJs, // file starts with identifier + + MultilineCommentStart, + MultilineCommentCont, + + ImportStart, // after 'import' + ImportMaybeDotOrVersionOrAs, // after string or identifier + ImportDot, // after . + ImportMaybeAs, // after version + ImportAs, + + PropertyStart, // after 'property' + PropertyModifiers, // after 'default' or readonly + RequiredProperty, // after required + PropertyListOpen, // after 'list' as a type + PropertyName, // after the type + PropertyMaybeInitializer, // after the identifier + ComponentStart, // after component + ComponentName, // after component Name + + TypeAnnotation, // after a : starting a type annotation + TypeParameter, // after a < in a type annotation (starting type parameters) + + EnumStart, // after 'enum' + + SignalStart, // after 'signal' + SignalMaybeArglist, // after identifier + SignalArglistOpen, // after '(' + + FunctionStart, // after 'function' + FunctionArglistOpen, // after '(' starting function argument list + FunctionArglistClosed, // after ')' in argument list, expecting '{' + + BindingOrObjectdefinition, // after an identifier + + BindingAssignment, // after : in a binding + ObjectdefinitionOpen, // after { + + Expression, + ExpressionContinuation, // at the end of the line, when the next line definitely is a + // continuation + ExpressionMaybeContinuation, // at the end of the line, when the next line may be an + // expression + ExpressionOrObjectdefinition, // after a binding starting with an identifier ("x: foo") + ExpressionOrLabel, // when expecting a statement and getting an identifier + + ParenOpen, // opening ( in expression + BracketOpen, // opening [ in expression + ObjectliteralOpen, // opening { in expression + + ObjectliteralAssignment, // after : in object literal + + BracketElementStart, // after starting bracket_open or after ',' in bracket_open + BracketElementMaybeObjectdefinition, // after an identifier in bracket_element_start + + TernaryOp, // The ? : operator + TernaryOpAfterColon, // after the : in a ternary + + JsblockOpen, + + EmptyStatement, // for a ';', will be popped directly + BreakcontinueStatement, // for continue/break, may be followed by identifier + + IfStatement, // After 'if' + MaybeElse, // after the first substatement in an if + ElseClause, // The else line of an if-else construct. + + ConditionOpen, // Start of a condition in 'if', 'while', entered after opening paren + + Substatement, // The first line after a conditional or loop construct. + SubstatementOpen, // The brace that opens a substatement block. + + LabelledStatement, // after a label + + ReturnStatement, // After 'return' + ThrowStatement, // After 'throw' + + StatementWithCondition, // After the 'for', 'while', ... token + StatementWithConditionParenOpen, // While inside the (...) + + TryStatement, // after 'try' + CatchStatement, // after 'catch', nested in try_statement + FinallyStatement, // after 'finally', nested in try_statement + MaybeCatchOrFinally, // after ther closing '}' of try_statement and catch_statement, + // nested in try_statement + + DoStatement, // after 'do' + DoStatementWhileParenOpen, // after '(' in while clause + + SwitchStatement, // After 'switch' token + CaseStart, // after a 'case' or 'default' token + CaseCont // after the colon in a case/default + }; + Q_ENUM(StateType) + + static QString stateToString(StateType type); + + class State + { + public: + quint16 savedIndentDepth = 0; + StateType type = StateType::Invalid; + bool operator==(const State &other) const + { + return type == other.type && savedIndentDepth == other.savedIndentDepth; + } + QString typeStr() const { return FormatTextStatus::stateToString(type); } + }; + + static bool isBracelessState(StateType type) + { + return type == StateType::IfStatement || type == StateType::ElseClause + || type == StateType::Substatement || type == StateType::BindingAssignment + || type == StateType::BindingOrObjectdefinition; + } + + static bool isExpressionEndState(StateType type) + { + return type == StateType::TopmostIntro || type == StateType::TopJs + || type == StateType::ObjectdefinitionOpen || type == StateType::DoStatement + || type == StateType::JsblockOpen || type == StateType::SubstatementOpen + || type == StateType::BracketOpen || type == StateType::ParenOpen + || type == StateType::CaseCont || type == StateType::ObjectliteralOpen; + } + + static FormatTextStatus initialStatus(int baseIndent = 0) + { + return FormatTextStatus { + Scanner::State {}, + QVector<State>({ State { quint16(baseIndent), StateType::TopmostIntro } }), baseIndent + }; + } + + size_t size() const { return states.size(); } + + State state(int belowTop = 0) const; + + void pushState(StateType type, quint16 savedIndentDepth) + { + states.append(State { savedIndentDepth, type }); + } + + State popState() + { + if (states.isEmpty()) { + Q_ASSERT(false); + return State(); + } + State res = states.last(); + states.removeLast(); + return res; + } + + Scanner::State lexerState = {}; + QVector<State> states; + int finalIndent = 0; +}; + +class QMLDOM_EXPORT FormatPartialStatus +{ + Q_GADGET +public: + + using OnEnterCallback = + function_ref<void(FormatTextStatus::StateType newState, int *indentDepth, + int *savedIndentDepth, const FormatPartialStatus &fStatus)>; + + // to determine whether a line was joined, Tokenizer needs a + // newline character at the end, lease ensure that line contains it + FormatPartialStatus() = default; + FormatPartialStatus(const FormatPartialStatus &o) = default; + FormatPartialStatus &operator=(const FormatPartialStatus &o) = default; + FormatPartialStatus(QStringView line, const FormatOptions &options, + const FormatTextStatus &initialStatus) + : line(line), + options(options), + initialStatus(initialStatus), + currentStatus(initialStatus), + currentIndent(0), + tokenIndex(0) + { + Scanner::State startState = initialStatus.lexerState; + currentIndent = initialStatus.finalIndent; + Scanner tokenize; + lineTokens = tokenize(line, startState); + currentStatus.lexerState = tokenize.state(); + } + + void enterState(FormatTextStatus::StateType newState); + void leaveState(bool statementDone); + void turnIntoState(FormatTextStatus::StateType newState); + + const Token &tokenAt(int idx) const; + int tokenCount() const { return lineTokens.size(); } + int column(int index) const; + QStringView tokenText(const Token &token) const; + void handleTokens(); + + bool tryInsideExpression(bool alsoExpression); + bool tryStatement(); + + void defaultOnEnter(FormatTextStatus::StateType newState, int *indentDepth, + int *savedIndentDepth) const; + + int indentLine(); + int indentForNewLineAfter() const; + void recalculateWithIndent(int indent); + + void dump() const; + + QStringView line; + FormatOptions options; + FormatTextStatus initialStatus; + FormatTextStatus currentStatus; + int indentOffset = 0; + int currentIndent = 0; + QList<Token> lineTokens; + int tokenIndex = 0; +}; + +QMLDOM_EXPORT int indentForLineStartingWithToken(const FormatTextStatus &oldStatus, + const FormatOptions &options, + int token = QQmlJSGrammar::T_ERROR); + +QMLDOM_EXPORT FormatPartialStatus formatCodeLine(QStringView line, const FormatOptions &options, + const FormatTextStatus &initialStatus); + +} // namespace Dom +} // namespace QQmlJs +QT_END_NAMESPACE +#endif // QQMLDOMCODEFORMATTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomcomments_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomcomments_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c16e11aa97ded02b9db277a434da4ff904a4cb5a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomcomments_p.h @@ -0,0 +1,363 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMCOMMENTS_P_H +#define QQMLDOMCOMMENTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_fwd_p.h" +#include "qqmldomconstants_p.h" +#include "qqmldomitem_p.h" +#include "qqmldomattachedinfo_p.h" + +#include <QtQml/private/qqmljsast_p.h> +#include <QtQml/private/qqmljsengine_p.h> + +#include <QtCore/QMultiMap> +#include <QtCore/QHash> +#include <QtCore/QStack> +#include <QtCore/QCoreApplication> + +#include <memory> + +QT_BEGIN_NAMESPACE +namespace QQmlJS { +namespace Dom { + +class QMLDOM_EXPORT CommentInfo +{ + Q_DECLARE_TR_FUNCTIONS(CommentInfo) +public: + CommentInfo(QStringView, QQmlJS::SourceLocation loc); + + QStringView preWhitespace() const { return rawComment.mid(0, commentBegin); } + + QStringView comment() const { return rawComment.mid(commentBegin, commentEnd - commentBegin); } + + QStringView commentContent() const + { + return rawComment.mid(commentContentBegin, commentContentEnd - commentContentEnd); + } + + QStringView postWhitespace() const + { + return rawComment.mid(commentEnd, rawComment.size() - commentEnd); + } + + // Comment source location populated during lexing doesn't include start strings // or /* + // Returns the location starting from // or /* + QQmlJS::SourceLocation sourceLocation() const { return commentLocation; } + + quint32 commentBegin = 0; + quint32 commentEnd = 0; + quint32 commentContentBegin = 0; + quint32 commentContentEnd = 0; + QStringView commentStartStr; + QStringView commentEndStr; + bool hasStartNewline = false; + bool hasEndNewline = false; + int nContentNewlines = 0; + QStringView rawComment; + QStringList warnings; + QQmlJS::SourceLocation commentLocation; +}; + +class QMLDOM_EXPORT Comment +{ +public: + constexpr static DomType kindValue = DomType::Comment; + DomType kind() const { return kindValue; } + + enum CommentType {Pre, Post}; + + Comment(const QString &c, const QQmlJS::SourceLocation &loc, int newlinesBefore = 1, + CommentType type = Pre) + : m_comment(c), m_location(loc), m_newlinesBefore(newlinesBefore), m_type(type) + { + } + Comment(QStringView c, const QQmlJS::SourceLocation &loc, int newlinesBefore = 1, + CommentType type = Pre) + : m_comment(c), m_location(loc), m_newlinesBefore(newlinesBefore), m_type(type) + { + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const; + int newlinesBefore() const { return m_newlinesBefore; } + void setNewlinesBefore(int n) { m_newlinesBefore = n; } + QStringView rawComment() const { return m_comment; } + CommentInfo info() const { return CommentInfo(m_comment, m_location); } + void write(OutWriter &lw, SourceLocation *commentLocation = nullptr) const; + + CommentType type() const { return m_type; } + + friend bool operator==(const Comment &c1, const Comment &c2) + { + return c1.m_newlinesBefore == c2.m_newlinesBefore && c1.m_comment == c2.m_comment; + } + friend bool operator!=(const Comment &c1, const Comment &c2) { return !(c1 == c2); } + +private: + QStringView m_comment; + QQmlJS::SourceLocation m_location; + int m_newlinesBefore; + CommentType m_type; +}; + +class QMLDOM_EXPORT CommentedElement +{ +public: + constexpr static DomType kindValue = DomType::CommentedElement; + DomType kind() const { return kindValue; } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const; + void writePre(OutWriter &lw, QList<SourceLocation> *locations = nullptr) const; + void writePost(OutWriter &lw, QList<SourceLocation> *locations = nullptr) const; + + friend bool operator==(const CommentedElement &c1, const CommentedElement &c2) + { + return c1.m_preComments == c2.m_preComments && c1.m_postComments == c2.m_postComments; + } + friend bool operator!=(const CommentedElement &c1, const CommentedElement &c2) + { + return !(c1 == c2); + } + + void addComment(const Comment &comment) + { + if (comment.type() == Comment::CommentType::Pre) + m_preComments.append(comment); + else + m_postComments.append(comment); + } + + const QList<Comment> &preComments() const { return m_preComments;} + const QList<Comment> &postComments() const { return m_postComments;} + +private: + QList<Comment> m_preComments; + QList<Comment> m_postComments; +}; + +class QMLDOM_EXPORT RegionComments +{ +public: + constexpr static DomType kindValue = DomType::RegionComments; + DomType kind() const { return kindValue; } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const; + + friend bool operator==(const RegionComments &c1, const RegionComments &c2) + { + return c1.m_regionComments == c2.m_regionComments; + } + friend bool operator!=(const RegionComments &c1, const RegionComments &c2) + { + return !(c1 == c2); + } + + const QMap<FileLocationRegion, CommentedElement> ®ionComments() const { return m_regionComments;} + Path addComment(const Comment &comment, FileLocationRegion region) + { + if (comment.type() == Comment::CommentType::Pre) + return addPreComment(comment, region); + else + return addPostComment(comment, region); + } + +private: + Path addPreComment(const Comment &comment, FileLocationRegion region) + { + auto &preList = m_regionComments[region].preComments(); + index_type idx = preList.size(); + m_regionComments[region].addComment(comment); + return Path::Field(Fields::regionComments) + .key(fileLocationRegionName(region)) + .field(Fields::preComments) + .index(idx); + } + + Path addPostComment(const Comment &comment, FileLocationRegion region) + { + auto &postList = m_regionComments[region].postComments(); + index_type idx = postList.size(); + m_regionComments[region].addComment(comment); + return Path::Field(Fields::regionComments) + .key(fileLocationRegionName(region)) + .field(Fields::postComments) + .index(idx); + } + + QMap<FileLocationRegion, CommentedElement> m_regionComments; +}; + +class QMLDOM_EXPORT AstComments final : public OwningItem +{ +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &) const override + { + return std::make_shared<AstComments>(*this); + } + +public: + constexpr static DomType kindValue = DomType::AstComments; + DomType kind() const override { return kindValue; } + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + std::shared_ptr<AstComments> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<AstComments>(doCopy(self)); + } + + Path canonicalPath(const DomItem &self) const override { return self.m_ownerPath; } + AstComments(const std::shared_ptr<Engine> &e) : m_engine(e) { } + AstComments(const AstComments &o) + : OwningItem(o), m_engine(o.m_engine), m_commentedElements(o.m_commentedElements) + { + } + + const QHash<AST::Node *, CommentedElement> &commentedElements() const + { + return m_commentedElements; + } + + QHash<AST::Node *, CommentedElement> &commentedElements() + { + return m_commentedElements; + } + + CommentedElement *commentForNode(AST::Node *n) + { + if (m_commentedElements.contains(n)) + return &(m_commentedElements[n]); + return nullptr; + } + QMultiMap<quint32, const QList<Comment> *> allCommentsInNode(AST::Node *n); + +private: + std::shared_ptr<Engine> m_engine; + QHash<AST::Node *, CommentedElement> m_commentedElements; +}; + +class CommentCollector +{ +public: + CommentCollector() = default; + CommentCollector(MutableDomItem item); + void collectComments(); + void collectComments(const std::shared_ptr<Engine> &engine, AST::Node *rootNode, + const std::shared_ptr<AstComments> &astComments); + +private: + MutableDomItem m_rootItem; + FileLocations::Tree m_fileLocations; +}; + +class VisitAll : public AST::Visitor +{ +public: + VisitAll() = default; + + static QSet<int> uiKinds(); + + void throwRecursionDepthError() override { } + + bool visit(AST::UiPublicMember *el) override + { + AST::Node::accept(el->annotations, this); + AST::Node::accept(el->memberType, this); + return true; + } + + bool visit(AST::UiSourceElement *el) override + { + AST::Node::accept(el->annotations, this); + return true; + } + + bool visit(AST::UiObjectDefinition *el) override + { + AST::Node::accept(el->annotations, this); + return true; + } + + bool visit(AST::UiObjectBinding *el) override + { + AST::Node::accept(el->annotations, this); + return true; + } + + bool visit(AST::UiScriptBinding *el) override + { + AST::Node::accept(el->annotations, this); + return true; + } + + bool visit(AST::UiArrayBinding *el) override + { + AST::Node::accept(el->annotations, this); + return true; + } + + bool visit(AST::UiParameterList *el) override + { + AST::Node::accept(el->type, this); + return true; + } + + bool visit(AST::UiQualifiedId *el) override + { + AST::Node::accept(el->next, this); + return true; + } + + bool visit(AST::UiEnumDeclaration *el) override + { + AST::Node::accept(el->annotations, this); + return true; + } + + bool visit(AST::UiInlineComponent *el) override + { + AST::Node::accept(el->annotations, this); + return true; + } + + void endVisit(AST::UiImport *el) override { AST::Node::accept(el->version, this); } + void endVisit(AST::UiPublicMember *el) override { AST::Node::accept(el->parameters, this); } + + void endVisit(AST::UiParameterList *el) override + { + AST::Node::accept(el->next, this); // put other args at the same level as this one... + } + + void endVisit(AST::UiEnumMemberList *el) override + { + AST::Node::accept(el->next, + this); // put other enum members at the same level as this one... + } + + bool visit(AST::TemplateLiteral *el) override + { + AST::Node::accept(el->expression, this); + return true; + } + + void endVisit(AST::Elision *el) override + { + AST::Node::accept(el->next, this); // emit other elisions at the same level + } +}; +} // namespace Dom +} // namespace QQmlJS +QT_END_NAMESPACE + +#endif // QQMLDOMCOMMENTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomcompare_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomcompare_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a679f0483344567f12a9561af4c9b7fe8b653688 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomcompare_p.h @@ -0,0 +1,72 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMLDOMCOMPARE_P_H +#define QMLDOMCOMPARE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldomitem_p.h" + +#include <memory> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +bool domCompare( + const DomItem &i1, const DomItem &i2, function_ref<bool(Path, const DomItem &, const DomItem &)> change, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter = noFilter, + Path p = Path()); + +enum DomCompareStrList { FirstDiff, AllDiffs }; + +QMLDOM_EXPORT QStringList domCompareStrList( + const DomItem &i1, const DomItem &i2, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &) const> filter = noFilter, + DomCompareStrList stopAtFirstDiff = DomCompareStrList::FirstDiff); + +inline QStringList domCompareStrList( + MutableDomItem &i1, const DomItem &i2, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &) const> filter = noFilter, + DomCompareStrList stopAtFirstDiff = DomCompareStrList::FirstDiff) +{ + DomItem ii1 = i1.item(); + return domCompareStrList(ii1, i2, filter, stopAtFirstDiff); +} + +inline QStringList domCompareStrList( + const DomItem &i1, MutableDomItem &i2, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &) const> filter = noFilter, + DomCompareStrList stopAtFirstDiff = DomCompareStrList::FirstDiff) +{ + DomItem ii2 = i2.item(); + return domCompareStrList(i1, ii2, filter, stopAtFirstDiff); +} + +inline QStringList domCompareStrList( + MutableDomItem &i1, MutableDomItem &i2, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &) const> filter = noFilter, + DomCompareStrList stopAtFirstDiff = DomCompareStrList::FirstDiff) +{ + DomItem ii1 = i1.item(); + DomItem ii2 = i2.item(); + return domCompareStrList(ii1, ii2, filter, stopAtFirstDiff); +} + +} // end namespace Dom +} // end namespace QQmlJS + +QT_END_NAMESPACE +#endif // QMLDOMCOMPARE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomconstants_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomconstants_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7b4d675bbd93bb0ea7ebe7b1efab061f62158bc4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomconstants_p.h @@ -0,0 +1,430 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMCONSTANTS_P_H +#define QQMLDOMCONSTANTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" + +#include <QtCore/QObject> +#include <QtCore/QMetaObject> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS{ +namespace Dom { + +Q_NAMESPACE_EXPORT(QMLDOM_EXPORT) + +enum class PathRoot { + Other, + Modules, + Cpp, + Libs, + Top, + Env, + Universe +}; +Q_ENUM_NS(PathRoot) + +enum class PathCurrent { + Other, + Obj, + ObjChain, + ScopeChain, + Component, + Module, + Ids, + Types, + LookupStrict, + LookupDynamic, + Lookup +}; +Q_ENUM_NS(PathCurrent) + +enum class Language { QmlQuick1, QmlQuick2, QmlQuick3, QmlCompiled, QmlAnnotation, Qbs }; +Q_ENUM_NS(Language) + +enum class ResolveOption{ + None=0, + TraceVisit=0x1 // call the function along all elements of the path, not just for the target (the function might be called even if the target is never reached) +}; +Q_ENUM_NS(ResolveOption) +Q_DECLARE_FLAGS(ResolveOptions, ResolveOption) +Q_DECLARE_OPERATORS_FOR_FLAGS(ResolveOptions) + +enum class VisitOption { + None = 0, + VisitSelf = 0x1, // Visit the start item + VisitAdopted = 0x2, // Visit adopted types (but never recurses them) + Recurse = 0x4, // recurse non adopted types + NoPath = 0x8, // does not generate path consistent with visit + Default = VisitOption::VisitSelf | VisitOption::VisitAdopted | VisitOption::Recurse +}; +Q_ENUM_NS(VisitOption) +Q_DECLARE_FLAGS(VisitOptions, VisitOption) +Q_DECLARE_OPERATORS_FOR_FLAGS(VisitOptions) + +enum class LookupOption { + Normal = 0, + Strict = 0x1, + VisitTopClassType = 0x2, // static lookup of class (singleton) or attached type, the default is + // visiting instance methods + SkipFirstScope = 0x4 +}; +Q_ENUM_NS(LookupOption) +Q_DECLARE_FLAGS(LookupOptions, LookupOption) +Q_DECLARE_OPERATORS_FOR_FLAGS(LookupOptions) + +enum class LookupType { PropertyDef, Binding, Property, Method, Type, CppType, Symbol }; +Q_ENUM_NS(LookupType) + +enum class VisitPrototypesOption { + Normal = 0, + SkipFirst = 0x1, + RevisitWarn = 0x2, + ManualProceedToScope = 0x4 +}; +Q_ENUM_NS(VisitPrototypesOption) +Q_DECLARE_FLAGS(VisitPrototypesOptions, VisitPrototypesOption) +Q_DECLARE_OPERATORS_FOR_FLAGS(VisitPrototypesOptions) + +enum class DomKind { Empty, Object, List, Map, Value, ScriptElement }; +Q_ENUM_NS(DomKind) + +enum class DomType { + Empty, // only for default ctor + + ExternalItemInfo, // base class for anything represented by an actual file + ExternalItemPair, // pair of newest version of item, and latest valid update ### REVISIT + // ExternalOwningItems refer to an external path and can be shared between environments + QmlDirectory, // dir e.g. used for implicit import + QmldirFile, // qmldir + JsFile, // file + QmlFile, // file + QmltypesFile, // qmltypes + GlobalScope, // language dependent (currently no difference) + /* enum A { B, C } + * * + EnumItem is marked with * */ + EnumItem, + + // types + EnumDecl, // A in above example + JsResource, // QML file contains QML object, JSFile contains JsResource + QmltypesComponent, // Component inside a qmltypes fles; compared to component it has exported + // meta-object revisions; singleton flag; can export multiple names + QmlComponent, // "normal" QML file based Component; also can represent inline components + GlobalComponent, // component of global object ### REVISIT, try to replace with one of the above + + ModuleAutoExport, // dependent imports to automatically load when a module is imported + ModuleIndex, // index for all the imports of a major version + ModuleScope, // a specific import with full version + ImportScope, // the scope including the types coming from one or more imports + Export, // An exported type + + // header stuff + Import, // wrapped + Pragma, + + // qml elements + Id, + QmlObject, // the Item in Item {}; also used to represent types in qmltype files + ConstantData, // the 2 in "property int i: 2"; can be any generic data in a QML document + SimpleObjectWrap, // internal wrapping to give uniform DOMItem access; ### research more + ScriptExpression, // wraps an AST script expression as a DOMItem + Reference, // reference to another DOMItem; e.g. asking for a type of an object returns a + // Reference + PropertyDefinition, // _just_ the property definition; without the binding, even if it's one + // line + Binding, // the part after the ":" + MethodParameter, + MethodInfo, // container of MethodParameter + Version, // wrapped + Comment, + CommentedElement, // attached to AST if they have pre-/post-comments? + RegionComments, // DomItems have attached RegionComments; can attach comments to fine grained + // "regions" in a DomItem; like the default keyword of a property definition + AstComments, // hash-table from AST node to commented element + FileLocations, // mapping from DomItem to file location ### REVISIT: try to move out of + // hierarchy? + UpdatedScriptExpression, // used in writeOut method when formatting changes ### Revisit: try to + // move out of DOM hierarchy + + // convenience collecting types + PropertyInfo, // not a DOM Item, just a convenience class + + // Moc objects, mainly for testing ### Try to remove them; replace their usage in tests with + // "real" instances + MockObject, + MockOwner, + + // containers + Map, + List, + ListP, + + // supporting objects + LoadInfo, // owning, used inside DomEnvironment ### REVISIT: move out of hierarchy + ErrorMessage, // wrapped + AttachedInfo, // owning + + // Dom top level + DomEnvironment, // a consistent view of modules, types, files, etc. + DomUniverse, // a cache of what can be found in the DomEnvironment, contains the latest valid + // version for every file/type, etc. + latest overall + + // Dom Script elements + // TODO + ScriptElementWrap, // internal wrapping to give uniform access of script elements (e.g. for + // statement lists) + ScriptElementStart, // marker to check if a DomType is a scriptelement or not + ScriptBlockStatement = ScriptElementStart, + ScriptIdentifierExpression, + ScriptLiteral, + ScriptRegExpLiteral, + ScriptForStatement, + ScriptIfStatement, + ScriptPostExpression, + ScriptUnaryExpression, + ScriptBinaryExpression, + ScriptVariableDeclaration, + ScriptVariableDeclarationEntry, + ScriptReturnStatement, + ScriptGenericElement, + ScriptCallExpression, + ScriptFormalParameter, + ScriptArray, + ScriptObject, + ScriptProperty, + ScriptType, + ScriptElision, + ScriptArrayEntry, + ScriptPattern, + ScriptSwitchStatement, + ScriptCaseBlock, + ScriptCaseClause, + ScriptDefaultClause, + ScriptWhileStatement, + ScriptDoWhileStatement, + ScriptForEachStatement, + ScriptTemplateLiteral, + ScriptTemplateStringPart, + ScriptTaggedTemplate, + ScriptTryCatchStatement, + ScriptThrowStatement, + ScriptLabelledStatement, + ScriptBreakStatement, + ScriptContinueStatement, + ScriptConditionalExpression, + ScriptEmptyStatement, + ScriptParenthesizedExpression, + ScriptFunctionExpression, + ScriptYieldExpression, + ScriptNewExpression, + ScriptNewMemberExpression, + ScriptThisExpression, + ScriptSuperLiteral, + + ScriptElementStop, // marker to check if a DomType is a scriptelement or not +}; +Q_ENUM_NS(DomType) + +enum class SimpleWrapOption { None = 0, ValueType = 1 }; +Q_ENUM_NS(SimpleWrapOption) +Q_DECLARE_FLAGS(SimpleWrapOptions, SimpleWrapOption) +Q_DECLARE_OPERATORS_FOR_FLAGS(SimpleWrapOptions) + +enum class BindingValueKind { Object, ScriptExpression, Array, Empty }; +Q_ENUM_NS(BindingValueKind) + +enum class BindingType { Normal, OnBinding }; +Q_ENUM_NS(BindingType) + +enum class ListOptions { + Normal, + Reverse +}; +Q_ENUM_NS(ListOptions) + +enum class EscapeOptions{ + OuterQuotes, + NoOuterQuotes +}; +Q_ENUM_NS(EscapeOptions) + +enum class ErrorLevel{ + Debug = QtMsgType::QtDebugMsg, + Info = QtMsgType::QtInfoMsg, + Warning = QtMsgType::QtWarningMsg, + Error = QtMsgType::QtCriticalMsg, + Fatal = QtMsgType::QtFatalMsg +}; +Q_ENUM_NS(ErrorLevel) + +enum class AstDumperOption { + None=0, + NoLocations=0x1, + NoAnnotations=0x2, + DumpNode=0x4, + SloppyCompare=0x8 +}; +Q_ENUM_NS(AstDumperOption) +Q_DECLARE_FLAGS(AstDumperOptions, AstDumperOption) +Q_DECLARE_OPERATORS_FOR_FLAGS(AstDumperOptions) + +enum class GoTo { + Strict, // never go to an non uniquely defined result + MostLikely // if needed go up to the most likely location between multiple options +}; +Q_ENUM_NS(GoTo) + +enum class AddOption { KeepExisting, Overwrite }; +Q_ENUM_NS(AddOption) + +/*! +\internal +FilterUpOptions decide in which direction the filtering is done. +ReturnInner starts the search at top(), and work its way down to the current +element. +ReturnOuter and ReturnOuterNoSelf starts the search at the current element and +works their way up to to top(). +*/ +enum class FilterUpOptions { ReturnOuter, ReturnOuterNoSelf, ReturnInner }; +Q_ENUM_NS(FilterUpOptions) + +enum class WriteOutCheck { + None = 0x0, + UpdatedDomCompare = 0x1, + UpdatedDomStable = 0x2, + Reparse = 0x4, + ReparseCompare = 0x8, + ReparseStable = 0x10, + DumpOnFailure = 0x20, + All = 0x3F, + Default = Reparse | ReparseCompare | ReparseStable +}; +Q_ENUM_NS(WriteOutCheck) +Q_DECLARE_FLAGS(WriteOutChecks, WriteOutCheck) +Q_DECLARE_OPERATORS_FOR_FLAGS(WriteOutChecks) + +enum class LocalSymbolsType { + None = 0x0, + ObjectType = 0x1, + ValueType = 0x2, + Signal = 0x4, + Method = 0x8, + Attribute = 0x10, + Id = 0x20, + Namespace = 0x40, + Global = 0x80, + MethodParameter = 0x100, + Singleton = 0x200, + AttachedType = 0x400, +}; +Q_ENUM_NS(LocalSymbolsType) +Q_DECLARE_FLAGS(LocalSymbolsTypes, LocalSymbolsType) +Q_DECLARE_OPERATORS_FOR_FLAGS(LocalSymbolsTypes) + +/*! +\internal +The FileLocationRegion allows to map the different FileLocation subregions to their position in +the actual code. For example, \c{ColonTokenRegion} denotes the position of the ':' token in a +binding like `myProperty: something()`, or the ':' token in a pragma like `pragma Hello: World`. + +These are used for formatting in qmlformat and autocompletion in qmlls. + +MainRegion denotes the entire FileLocation region. + +\sa{OutWriter::regionToString}, {FileLocations::regionName} +*/ +enum FileLocationRegion : int { + AsTokenRegion, + BreakKeywordRegion, + DoKeywordRegion, + CaseKeywordRegion, + CatchKeywordRegion, + ColonTokenRegion, + CommaTokenRegion, + ComponentKeywordRegion, + ContinueKeywordRegion, + DefaultKeywordRegion, + EllipsisTokenRegion, + ElseKeywordRegion, + EnumKeywordRegion, + EnumValueRegion, + EqualTokenRegion, + ForKeywordRegion, + FinallyKeywordRegion, + FirstSemicolonTokenRegion, + FunctionKeywordRegion, + IdColonTokenRegion, + IdNameRegion, + IdTokenRegion, + IdentifierRegion, + IfKeywordRegion, + ImportTokenRegion, + ImportUriRegion, + InOfTokenRegion, + LeftBraceRegion, + LeftBracketRegion, + LeftParenthesisRegion, + MainRegion, + NewKeywordRegion, + OperatorTokenRegion, + OnTargetRegion, + OnTokenRegion, + PragmaKeywordRegion, + PragmaValuesRegion, + PropertyKeywordRegion, + QuestionMarkTokenRegion, + ReadonlyKeywordRegion, + RequiredKeywordRegion, + ReturnKeywordRegion, + RightBraceRegion, + RightBracketRegion, + RightParenthesisRegion, + SecondSemicolonRegion, + SemicolonTokenRegion, + SignalKeywordRegion, + SuperKeywordRegion, + StarTokenRegion, + SwitchKeywordRegion, + ThisKeywordRegion, + ThrowKeywordRegion, + TryKeywordRegion, + TypeIdentifierRegion, + TypeModifierRegion, + VersionRegion, + WhileKeywordRegion, + YieldKeywordRegion, +}; +Q_ENUM_NS(FileLocationRegion); + +enum DomCreationOption : char { + None = 0, + WithSemanticAnalysis = 1, + WithScriptExpressions = 2, + WithRecovery = 4 +}; + +Q_DECLARE_FLAGS(DomCreationOptions, DomCreationOption); + +} // end namespace Dom +} // end namespace QQmlJS + +QT_END_NAMESPACE + +#endif // QQMLDOMCONSTANTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomelements_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomelements_p.h new file mode 100644 index 0000000000000000000000000000000000000000..25beca6bad7b4653eceb2859248b6906f2b2d41c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomelements_p.h @@ -0,0 +1,1283 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMELEMENTS_P_H +#define QQMLDOMELEMENTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldomitem_p.h" +#include "qqmldomconstants_p.h" +#include "qqmldomcomments_p.h" +#include "qqmldomlinewriter_p.h" + +#include <QtQml/private/qqmljsast_p.h> +#include <QtQml/private/qqmljsengine_p.h> +#include <QtQml/private/qqmlsignalnames_p.h> + +#include <QtCore/QCborValue> +#include <QtCore/QCborMap> +#include <QtCore/QMutexLocker> +#include <QtCore/QPair> + +#include <memory> +#include <private/qqmljsscope_p.h> + +#include <functional> +#include <limits> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +// namespace for utility methods building specific paths +// using a namespace one can reopen it and add more methods in other places +namespace Paths { +Path moduleIndexPath( + const QString &uri, int majorVersion, const ErrorHandler &errorHandler = nullptr); +Path moduleScopePath( + const QString &uri, Version version, const ErrorHandler &errorHandler = nullptr); +Path moduleScopePath( + const QString &uri, const QString &version, const ErrorHandler &errorHandler = nullptr); +inline Path moduleScopePath( + const QString &uri, const ErrorHandler &errorHandler = nullptr) +{ + return moduleScopePath(uri, QString(), errorHandler); +} +inline Path qmlDirInfoPath(const QString &path) +{ + return Path::Root(PathRoot::Top).field(Fields::qmldirWithPath).key(path); +} +inline Path qmlDirPath(const QString &path) +{ + return qmlDirInfoPath(path).field(Fields::currentItem); +} +inline Path qmldirFileInfoPath(const QString &path) +{ + return Path::Root(PathRoot::Top).field(Fields::qmldirFileWithPath).key(path); +} +inline Path qmldirFilePath(const QString &path) +{ + return qmldirFileInfoPath(path).field(Fields::currentItem); +} +inline Path qmlFileInfoPath(const QString &canonicalFilePath) +{ + return Path::Root(PathRoot::Top).field(Fields::qmlFileWithPath).key(canonicalFilePath); +} +inline Path qmlFilePath(const QString &canonicalFilePath) +{ + return qmlFileInfoPath(canonicalFilePath).field(Fields::currentItem); +} +inline Path qmlFileObjectPath(const QString &canonicalFilePath) +{ + return qmlFilePath(canonicalFilePath) + .field(Fields::components) + .key(QString()) + .index(0) + .field(Fields::objects) + .index(0); +} +inline Path qmltypesFileInfoPath(const QString &path) +{ + return Path::Root(PathRoot::Top).field(Fields::qmltypesFileWithPath).key(path); +} +inline Path qmltypesFilePath(const QString &path) +{ + return qmltypesFileInfoPath(path).field(Fields::currentItem); +} +inline Path jsFileInfoPath(const QString &path) +{ + return Path::Root(PathRoot::Top).field(Fields::jsFileWithPath).key(path); +} +inline Path jsFilePath(const QString &path) +{ + return jsFileInfoPath(path).field(Fields::currentItem); +} +inline Path qmlDirectoryInfoPath(const QString &path) +{ + return Path::Root(PathRoot::Top).field(Fields::qmlDirectoryWithPath).key(path); +} +inline Path qmlDirectoryPath(const QString &path) +{ + return qmlDirectoryInfoPath(path).field(Fields::currentItem); +} +inline Path globalScopeInfoPath(const QString &name) +{ + return Path::Root(PathRoot::Top).field(Fields::globalScopeWithName).key(name); +} +inline Path globalScopePath(const QString &name) +{ + return globalScopeInfoPath(name).field(Fields::currentItem); +} +inline Path lookupCppTypePath(const QString &name) +{ + return Path::Current(PathCurrent::Lookup).field(Fields::cppType).key(name); +} +inline Path lookupPropertyPath(const QString &name) +{ + return Path::Current(PathCurrent::Lookup).field(Fields::propertyDef).key(name); +} +inline Path lookupSymbolPath(const QString &name) +{ + return Path::Current(PathCurrent::Lookup).field(Fields::symbol).key(name); +} +inline Path lookupTypePath(const QString &name) +{ + return Path::Current(PathCurrent::Lookup).field(Fields::type).key(name); +} +inline Path loadInfoPath(const Path &el) +{ + return Path::Root(PathRoot::Env).field(Fields::loadInfo).key(el.toString()); +} +} // end namespace Paths + +class QMLDOM_EXPORT CommentableDomElement : public DomElement +{ +public: + CommentableDomElement(const Path &pathFromOwner = Path()) : DomElement(pathFromOwner) { } + CommentableDomElement(const CommentableDomElement &o) : DomElement(o), m_comments(o.m_comments) + { + } + CommentableDomElement &operator=(const CommentableDomElement &o) = default; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + RegionComments &comments() { return m_comments; } + const RegionComments &comments() const { return m_comments; } + +private: + RegionComments m_comments; +}; + +class QMLDOM_EXPORT Version +{ +public: + constexpr static DomType kindValue = DomType::Version; + constexpr static qint32 Undefined = -1; + constexpr static qint32 Latest = -2; + + Version(qint32 majorVersion = Undefined, qint32 minorVersion = Undefined); + static Version fromString(QStringView v); + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const; + + bool isLatest() const; + bool isValid() const; + QString stringValue() const; + QString majorString() const + { + if (majorVersion >= 0 || majorVersion == Undefined) + return QString::number(majorVersion); + return QString(); + } + QString majorSymbolicString() const + { + if (majorVersion == Version::Latest) + return QLatin1String("Latest"); + if (majorVersion >= 0 || majorVersion == Undefined) + return QString::number(majorVersion); + return QString(); + } + QString minorString() const + { + if (minorVersion >= 0 || minorVersion == Undefined) + return QString::number(minorVersion); + return QString(); + } + int compare(const Version &o) const + { + int c = majorVersion - o.majorVersion; + if (c != 0) + return c; + return minorVersion - o.minorVersion; + } + + qint32 majorVersion; + qint32 minorVersion; +}; +inline bool operator==(const Version &v1, const Version &v2) +{ + return v1.compare(v2) == 0; +} +inline bool operator!=(const Version &v1, const Version &v2) +{ + return v1.compare(v2) != 0; +} +inline bool operator<(const Version &v1, const Version &v2) +{ + return v1.compare(v2) < 0; +} +inline bool operator<=(const Version &v1, const Version &v2) +{ + return v1.compare(v2) <= 0; +} +inline bool operator>(const Version &v1, const Version &v2) +{ + return v1.compare(v2) > 0; +} +inline bool operator>=(const Version &v1, const Version &v2) +{ + return v1.compare(v2) >= 0; +} + +class QMLDOM_EXPORT QmlUri +{ +public: + enum class Kind { Invalid, ModuleUri, DirectoryUrl, RelativePath, AbsolutePath }; + QmlUri() = default; + static QmlUri fromString(const QString &importStr); + static QmlUri fromUriString(const QString &importStr); + static QmlUri fromDirectoryString(const QString &importStr); + bool isValid() const; + bool isDirectory() const; + bool isModule() const; + QString moduleUri() const; + QString localPath() const; + QString absoluteLocalPath(const QString &basePath = QString()) const; + QUrl directoryUrl() const; + QString directoryString() const; + QString toString() const; + Kind kind() const; + + friend bool operator==(const QmlUri &i1, const QmlUri &i2) + { + return i1.m_kind == i2.m_kind && i1.m_value == i2.m_value; + } + friend bool operator!=(const QmlUri &i1, const QmlUri &i2) { return !(i1 == i2); } + +private: + QmlUri(const QUrl &url) : m_kind(Kind::DirectoryUrl), m_value(url) { } + QmlUri(Kind kind, const QString &value) : m_kind(kind), m_value(value) { } + Kind m_kind = Kind::Invalid; + std::variant<QString, QUrl> m_value; +}; + +class QMLDOM_EXPORT Import +{ + Q_DECLARE_TR_FUNCTIONS(Import) +public: + constexpr static DomType kindValue = DomType::Import; + + static Import fromUriString( + const QString &importStr, Version v = Version(), const QString &importId = QString(), + const ErrorHandler &handler = nullptr); + static Import fromFileString( + const QString &importStr, const QString &importId = QString(), + const ErrorHandler &handler = nullptr); + + Import(const QmlUri &uri = QmlUri(), Version version = Version(), + const QString &importId = QString()) + : uri(uri), version(version), importId(importId) + { + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const; + Path importedPath() const + { + if (uri.isDirectory()) { + QString path = uri.absoluteLocalPath(); + if (!path.isEmpty()) { + return Paths::qmlDirPath(path); + } else { + Q_ASSERT_X(false, "Import", "url imports not supported"); + return Paths::qmldirFilePath(uri.directoryString()); + } + } else { + return Paths::moduleScopePath(uri.moduleUri(), version); + } + } + Import baseImport() const { return Import { uri, version }; } + + friend bool operator==(const Import &i1, const Import &i2) + { + return i1.uri == i2.uri && i1.version == i2.version && i1.importId == i2.importId + && i1.comments == i2.comments && i1.implicit == i2.implicit; + } + friend bool operator!=(const Import &i1, const Import &i2) { return !(i1 == i2); } + + void writeOut(const DomItem &self, OutWriter &ow) const; + + static QRegularExpression importRe(); + + QmlUri uri; + Version version; + QString importId; + RegionComments comments; + bool implicit = false; +}; + +class QMLDOM_EXPORT ModuleAutoExport +{ +public: + constexpr static DomType kindValue = DomType::ModuleAutoExport; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const + { + bool cont = true; + cont = cont && self.dvWrapField(visitor, Fields::import, import); + cont = cont && self.dvValueField(visitor, Fields::inheritVersion, inheritVersion); + return cont; + } + + friend bool operator==(const ModuleAutoExport &i1, const ModuleAutoExport &i2) + { + return i1.import == i2.import && i1.inheritVersion == i2.inheritVersion; + } + friend bool operator!=(const ModuleAutoExport &i1, const ModuleAutoExport &i2) + { + return !(i1 == i2); + } + + Import import; + bool inheritVersion = false; +}; + +class QMLDOM_EXPORT Pragma +{ +public: + constexpr static DomType kindValue = DomType::Pragma; + + Pragma(const QString &pragmaName = QString(), const QStringList &pragmaValues = {}) + : name(pragmaName), values{ pragmaValues } + { + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const + { + bool cont = self.dvValueField(visitor, Fields::name, name); + cont = cont && self.dvValueField(visitor, Fields::values, values); + cont = cont && self.dvWrapField(visitor, Fields::comments, comments); + return cont; + } + + void writeOut(const DomItem &self, OutWriter &ow) const; + + QString name; + QStringList values; + RegionComments comments; +}; + +class QMLDOM_EXPORT Id +{ +public: + constexpr static DomType kindValue = DomType::Id; + + Id(const QString &idName = QString(), const Path &referredObject = Path()); + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const; + void updatePathFromOwner(const Path &pathFromOwner); + Path addAnnotation(const Path &selfPathFromOwner, const QmlObject &ann, QmlObject **aPtr = nullptr); + + QString name; + Path referredObjectPath; + RegionComments comments; + QList<QmlObject> annotations; + std::shared_ptr<ScriptExpression> value; +}; + +// TODO: rename? it may contain statements and stuff, not only expressions +// TODO QTBUG-121933 +class QMLDOM_EXPORT ScriptExpression final : public OwningItem +{ + Q_GADGET + Q_DECLARE_TR_FUNCTIONS(ScriptExpression) +public: + enum class ExpressionType { + BindingExpression, + FunctionBody, + ArgInitializer, + ArgumentStructure, + ReturnType, + JSCode, // Used for storing the content of the whole .js file as "one" Expression + ESMCode, // Used for storing the content of the whole ECMAScript module (.mjs) as "one" + // Expression + }; + Q_ENUM(ExpressionType); + constexpr static DomType kindValue = DomType::ScriptExpression; + DomType kind() const override { return kindValue; } + + explicit ScriptExpression( + QStringView code, const std::shared_ptr<QQmlJS::Engine> &engine, AST::Node *ast, + const std::shared_ptr<AstComments> &comments, ExpressionType expressionType, + SourceLocation localOffset = SourceLocation(), int derivedFrom = 0, + QStringView preCode = QStringView(), QStringView postCode = QStringView()); + + ScriptExpression() + : ScriptExpression(QStringView(), std::shared_ptr<QQmlJS::Engine>(), nullptr, + std::shared_ptr<AstComments>(), ExpressionType::BindingExpression, + SourceLocation(), 0) + { + } + + explicit ScriptExpression( + const QString &code, ExpressionType expressionType, int derivedFrom = 0, + const QString &preCode = QString(), const QString &postCode = QString()) + : OwningItem(derivedFrom), m_expressionType(expressionType) + { + setCode(code, preCode, postCode); + } + + ScriptExpression(const ScriptExpression &e); + + std::shared_ptr<ScriptExpression> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<ScriptExpression>(doCopy(self)); + } + + std::shared_ptr<ScriptExpression> copyWithUpdatedCode(const DomItem &self, const QString &code) const; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + + Path canonicalPath(const DomItem &self) const override { return self.m_ownerPath; } + // parsed and created if not available + AST::Node *ast() const { return m_ast; } + // dump of the ast (without locations) + void astDumper(const Sink &s, AstDumperOptions options) const; + QString astRelocatableDump() const; + + // definedSymbols name, value, from + // usedSymbols name, locations + QStringView code() const + { + QMutexLocker l(mutex()); + return m_code; + } + + ExpressionType expressionType() const + { + QMutexLocker l(mutex()); + return m_expressionType; + } + + bool isNull() const + { + QMutexLocker l(mutex()); + return m_code.isNull(); + } + std::shared_ptr<QQmlJS::Engine> engine() const + { + QMutexLocker l(mutex()); + return m_engine; + } + std::shared_ptr<AstComments> astComments() const { return m_astComments; } + void writeOut(const DomItem &self, OutWriter &lw) const override; + SourceLocation globalLocation(const DomItem &self) const; + SourceLocation localOffset() const { return m_localOffset; } + QStringView preCode() const { return m_preCode; } + QStringView postCode() const { return m_postCode; } + void setScriptElement(const ScriptElementVariant &p); + ScriptElementVariant scriptElement() { return m_element; } + +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &) const override + { + return std::make_shared<ScriptExpression>(*this); + } + + std::function<SourceLocation(SourceLocation)> locationToGlobalF(const DomItem &self) const + { + SourceLocation loc = globalLocation(self); + return [loc, this](SourceLocation x) { + return SourceLocation(x.offset - m_localOffset.offset + loc.offset, x.length, + x.startLine - m_localOffset.startLine + loc.startLine, + ((x.startLine == m_localOffset.startLine) ? x.startColumn + - m_localOffset.startColumn + loc.startColumn + : x.startColumn)); + }; + } + + SourceLocation locationToLocal(SourceLocation x) const + { + return SourceLocation( + x.offset - m_localOffset.offset, x.length, x.startLine - m_localOffset.startLine, + ((x.startLine == m_localOffset.startLine) + ? x.startColumn - m_localOffset.startColumn + : x.startColumn)); // are line and column 1 based? then we should + 1 + } + + std::function<SourceLocation(SourceLocation)> locationToLocalF(const DomItem &) const + { + return [this](SourceLocation x) { return locationToLocal(x); }; + } + +private: + enum class ParseMode { + QML, + JS, + ESM, // ECMAScript module + }; + + inline ParseMode resolveParseMode() + { + switch (m_expressionType) { + case ExpressionType::BindingExpression: + // unfortunately there are no documentation explaining this resolution + // this was just moved from the original implementation + return ParseMode::QML; + case ExpressionType::ESMCode: + return ParseMode::ESM; + default: + return ParseMode::JS; + } + } + void setCode(const QString &code, const QString &preCode, const QString &postCode); + [[nodiscard]] AST::Node *parse(ParseMode mode); + + ExpressionType m_expressionType; + QString m_codeStr; + QStringView m_code; + QStringView m_preCode; + QStringView m_postCode; + mutable std::shared_ptr<QQmlJS::Engine> m_engine; + mutable AST::Node *m_ast; + std::shared_ptr<AstComments> m_astComments; + SourceLocation m_localOffset; + ScriptElementVariant m_element; +}; + +class BindingValue; + +class QMLDOM_EXPORT Binding +{ +public: + constexpr static DomType kindValue = DomType::Binding; + + Binding(const QString &m_name = QString()); + Binding(const QString &m_name, std::unique_ptr<BindingValue> value, + BindingType bindingType = BindingType::Normal); + Binding(const QString &m_name, const std::shared_ptr<ScriptExpression> &value, + BindingType bindingType = BindingType::Normal); + Binding(const QString &m_name, const QString &scriptCode, + BindingType bindingType = BindingType::Normal); + Binding(const QString &m_name, const QmlObject &value, + BindingType bindingType = BindingType::Normal); + Binding(const QString &m_name, const QList<QmlObject> &value, + BindingType bindingType = BindingType::Normal); + Binding(const Binding &o); + Binding(Binding &&o) = default; + ~Binding(); + Binding &operator=(const Binding &); + Binding &operator=(Binding &&) = default; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const; + DomItem valueItem(const DomItem &self) const; // ### REVISIT: consider replacing return value with variant + BindingValueKind valueKind() const; + QString name() const { return m_name; } + BindingType bindingType() const { return m_bindingType; } + QmlObject const *objectValue() const; + QList<QmlObject> const *arrayValue() const; + std::shared_ptr<ScriptExpression> scriptExpressionValue() const; + QmlObject *objectValue(); + QList<QmlObject> *arrayValue(); + std::shared_ptr<ScriptExpression> scriptExpressionValue(); + QList<QmlObject> annotations() const { return m_annotations; } + void setAnnotations(const QList<QmlObject> &annotations) { m_annotations = annotations; } + void setValue(std::unique_ptr<BindingValue> &&value) { m_value = std::move(value); } + Path addAnnotation(const Path &selfPathFromOwner, const QmlObject &a, QmlObject **aPtr = nullptr); + const RegionComments &comments() const { return m_comments; } + RegionComments &comments() { return m_comments; } + void updatePathFromOwner(const Path &newPath); + void writeOut(const DomItem &self, OutWriter &lw) const; + void writeOutValue(const DomItem &self, OutWriter &lw) const; + bool isSignalHandler() const + { + QString baseName = m_name.split(QLatin1Char('.')).last(); + return QQmlSignalNames::isHandlerName(baseName); + } + static QString preCodeForName(QStringView n) + { + return QStringLiteral(u"QtObject{\n %1: ").arg(n.split(u'.').last()); + } + static QString postCodeForName(QStringView) { return QStringLiteral(u"\n}\n"); } + QString preCode() const { return preCodeForName(m_name); } + QString postCode() const { return postCodeForName(m_name); } + + ScriptElementVariant bindingIdentifiers() const { return m_bindingIdentifiers; } + void setBindingIdentifiers(const ScriptElementVariant &bindingIdentifiers) { m_bindingIdentifiers = bindingIdentifiers; } + +private: + friend class QQmlDomAstCreator; + BindingType m_bindingType; + QString m_name; + std::unique_ptr<BindingValue> m_value; + QList<QmlObject> m_annotations; + RegionComments m_comments; + ScriptElementVariant m_bindingIdentifiers; +}; + +class QMLDOM_EXPORT AttributeInfo +{ +public: + enum Access { Private, Protected, Public }; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const; + + Path addAnnotation(const Path &selfPathFromOwner, const QmlObject &annotation, + QmlObject **aPtr = nullptr); + void updatePathFromOwner(const Path &newPath); + + QQmlJSScope::ConstPtr semanticScope() const { return m_semanticScope; } + void setSemanticScope(const QQmlJSScope::ConstPtr &scope) { m_semanticScope = scope; } + + QString name; + Access access = Access::Public; + QString typeName; + bool isReadonly = false; + bool isList = false; + QList<QmlObject> annotations; + RegionComments comments; + QQmlJSScope::ConstPtr m_semanticScope; +}; + +struct QMLDOM_EXPORT LocallyResolvedAlias +{ + enum class Status { Invalid, ResolvedProperty, ResolvedObject, Loop, TooDeep }; + bool valid() + { + switch (status) { + case Status::ResolvedProperty: + case Status::ResolvedObject: + return true; + default: + return false; + } + } + DomItem baseObject; + DomItem localPropertyDef; + QString typeName; + QStringList accessedPath; + Status status = Status::Invalid; + int nAliases = 0; +}; + +class QMLDOM_EXPORT PropertyDefinition : public AttributeInfo +{ +public: + constexpr static DomType kindValue = DomType::PropertyDefinition; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const + { + bool cont = AttributeInfo::iterateDirectSubpaths(self, visitor); + cont = cont && self.dvValueField(visitor, Fields::isPointer, isPointer); + cont = cont && self.dvValueField(visitor, Fields::isFinal, isFinal); + cont = cont && self.dvValueField(visitor, Fields::isAlias, isAlias()); + cont = cont && self.dvValueField(visitor, Fields::isDefaultMember, isDefaultMember); + cont = cont && self.dvValueField(visitor, Fields::isRequired, isRequired); + cont = cont && self.dvValueField(visitor, Fields::read, read); + cont = cont && self.dvValueField(visitor, Fields::write, write); + cont = cont && self.dvValueField(visitor, Fields::bindable, bindable); + cont = cont && self.dvValueField(visitor, Fields::notify, notify); + cont = cont && self.dvReferenceField(visitor, Fields::type, typePath()); + if (m_nameIdentifiers) { + cont = cont && self.dvItemField(visitor, Fields::nameIdentifiers, [this, &self]() { + return self.subScriptElementWrapperItem(m_nameIdentifiers); + }); + } + return cont; + } + + Path typePath() const { return Paths::lookupTypePath(typeName); } + + bool isAlias() const { return typeName == u"alias"; } + bool isParametricType() const; + void writeOut(const DomItem &self, OutWriter &lw) const; + ScriptElementVariant nameIdentifiers() const { return m_nameIdentifiers; } + void setNameIdentifiers(const ScriptElementVariant &name) { m_nameIdentifiers = name; } + + QString read; + QString write; + QString bindable; + QString notify; + bool isFinal = false; + bool isPointer = false; + bool isDefaultMember = false; + bool isRequired = false; + ScriptElementVariant m_nameIdentifiers; +}; + +class QMLDOM_EXPORT PropertyInfo +{ +public: + constexpr static DomType kindValue = DomType::PropertyInfo; // used to get the correct kind in ObjectWrapper + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const; + + QList<DomItem> propertyDefs; + QList<DomItem> bindings; +}; + +class QMLDOM_EXPORT MethodParameter +{ +public: + constexpr static DomType kindValue = DomType::MethodParameter; + enum class TypeAnnotationStyle { + Prefix, // a(int x) + Suffix, // a(x : int) + }; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const; + + void writeOut(const DomItem &self, OutWriter &ow) const; + void writeOutSignal(const DomItem &self, OutWriter &ow) const; + + QString name; + QString typeName; + bool isPointer = false; + bool isReadonly = false; + bool isList = false; + bool isRestElement = false; + std::shared_ptr<ScriptExpression> defaultValue; + /*! + \internal + Contains the scriptElement representing this argument, inclusive default value, + deconstruction, etc. + */ + std::shared_ptr<ScriptExpression> value; + QList<QmlObject> annotations; + RegionComments comments; + TypeAnnotationStyle typeAnnotationStyle = TypeAnnotationStyle::Suffix; +}; + +class QMLDOM_EXPORT MethodInfo : public AttributeInfo +{ + Q_GADGET +public: + enum MethodType { Signal, Method }; + Q_ENUM(MethodType) + + constexpr static DomType kindValue = DomType::MethodInfo; + + Path typePath(const DomItem &) const + { + return (typeName.isEmpty() ? Path() : Paths::lookupTypePath(typeName)); + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const; + QString preCode(const DomItem &) const; // ### REVISIT, might be simplified by using different toplevel production rules at usage site + QString postCode(const DomItem &) const; + void writePre(const DomItem &self, OutWriter &ow) const; + void writeOut(const DomItem &self, OutWriter &ow) const; + void setCode(const QString &code) + { + body = std::make_shared<ScriptExpression>( + code, ScriptExpression::ExpressionType::FunctionBody, 0, + QLatin1String("function foo(){\n"), QLatin1String("\n}\n")); + } + MethodInfo() = default; + + // TODO: make private + add getters/setters + QList<MethodParameter> parameters; + MethodType methodType = Method; + std::shared_ptr<ScriptExpression> body; + std::shared_ptr<ScriptExpression> returnType; + bool isConstructor = false; +}; + +class QMLDOM_EXPORT EnumItem +{ +public: + constexpr static DomType kindValue = DomType::EnumItem; + enum class ValueKind : quint8 { + ImplicitValue, + ExplicitValue + }; + EnumItem(const QString &name = QString(), int value = 0, ValueKind valueKind = ValueKind::ImplicitValue) + : m_name(name), m_value(value), m_valueKind(valueKind) + { + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const; + + QString name() const { return m_name; } + double value() const { return m_value; } + RegionComments &comments() { return m_comments; } + const RegionComments &comments() const { return m_comments; } + void writeOut(const DomItem &self, OutWriter &lw) const; + +private: + QString m_name; + double m_value; + ValueKind m_valueKind; + RegionComments m_comments; +}; + +class QMLDOM_EXPORT EnumDecl final : public CommentableDomElement +{ +public: + constexpr static DomType kindValue = DomType::EnumDecl; + DomType kind() const override { return kindValue; } + + EnumDecl(const QString &name = QString(), QList<EnumItem> values = QList<EnumItem>(), + Path pathFromOwner = Path()) + : CommentableDomElement(pathFromOwner), m_name(name), m_values(values) + { + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + + QString name() const { return m_name; } + void setName(const QString &name) { m_name = name; } + const QList<EnumItem> &values() const & { return m_values; } + bool isFlag() const { return m_isFlag; } + void setIsFlag(bool flag) { m_isFlag = flag; } + QString alias() const { return m_alias; } + void setAlias(const QString &aliasName) { m_alias = aliasName; } + void setValues(QList<EnumItem> values) { m_values = values; } + Path addValue(EnumItem value) + { + m_values.append(value); + return Path::Field(Fields::values).index(index_type(m_values.size() - 1)); + } + void updatePathFromOwner(const Path &newP) override; + + const QList<QmlObject> &annotations() const & { return m_annotations; } + void setAnnotations(const QList<QmlObject> &annotations); + Path addAnnotation(const QmlObject &child, QmlObject **cPtr = nullptr); + void writeOut(const DomItem &self, OutWriter &lw) const override; + +private: + QString m_name; + bool m_isFlag = false; + QString m_alias; + QList<EnumItem> m_values; + QList<QmlObject> m_annotations; +}; + +class QMLDOM_EXPORT QmlObject final : public CommentableDomElement +{ + Q_DECLARE_TR_FUNCTIONS(QmlObject) +public: + constexpr static DomType kindValue = DomType::QmlObject; + DomType kind() const override { return kindValue; } + + QmlObject(const Path &pathFromOwner = Path()); + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + bool iterateBaseDirectSubpaths(const DomItem &self, DirectVisitor) const; + QList<QString> fields() const; + QList<QString> fields(const DomItem &) const override { return fields(); } + DomItem field(const DomItem &self, QStringView name) const override; + void updatePathFromOwner(const Path &newPath) override; + QString localDefaultPropertyName() const; + QString defaultPropertyName(const DomItem &self) const; + virtual bool iterateSubOwners(const DomItem &self, function_ref<bool(const DomItem &owner)> visitor) const; + + QString idStr() const { return m_idStr; } + QString name() const { return m_name; } + const QList<Path> &prototypePaths() const & { return m_prototypePaths; } + Path nextScopePath() const { return m_nextScopePath; } + const QMultiMap<QString, PropertyDefinition> &propertyDefs() const & { return m_propertyDefs; } + const QMultiMap<QString, Binding> &bindings() const & { return m_bindings; } + const QMultiMap<QString, MethodInfo> &methods() const & { return m_methods; } + QList<QmlObject> children() const { return m_children; } + QList<QmlObject> annotations() const { return m_annotations; } + + void setIdStr(const QString &id) { m_idStr = id; } + void setName(const QString &name) { m_name = name; } + void setDefaultPropertyName(const QString &name) { m_defaultPropertyName = name; } + void setPrototypePaths(QList<Path> prototypePaths) { m_prototypePaths = prototypePaths; } + Path addPrototypePath(const Path &prototypePath) + { + index_type idx = index_type(m_prototypePaths.indexOf(prototypePath)); + if (idx == -1) { + idx = index_type(m_prototypePaths.size()); + m_prototypePaths.append(prototypePath); + } + return Path::Field(Fields::prototypes).index(idx); + } + void setNextScopePath(const Path &nextScopePath) { m_nextScopePath = nextScopePath; } + void setPropertyDefs(QMultiMap<QString, PropertyDefinition> propertyDefs) + { + m_propertyDefs = propertyDefs; + } + void setBindings(QMultiMap<QString, Binding> bindings) { m_bindings = bindings; } + void setMethods(QMultiMap<QString, MethodInfo> functionDefs) { m_methods = functionDefs; } + void setChildren(const QList<QmlObject> &children) + { + m_children = children; + if (pathFromOwner()) + updatePathFromOwner(pathFromOwner()); + } + void setAnnotations(const QList<QmlObject> &annotations) + { + m_annotations = annotations; + if (pathFromOwner()) + updatePathFromOwner(pathFromOwner()); + } + Path addPropertyDef(const PropertyDefinition &propertyDef, AddOption option, + PropertyDefinition **pDef = nullptr) + { + return insertUpdatableElementInMultiMap(pathFromOwner().field(Fields::propertyDefs), + m_propertyDefs, propertyDef.name, propertyDef, + option, pDef); + } + MutableDomItem addPropertyDef(MutableDomItem &self, const PropertyDefinition &propertyDef, + AddOption option); + + Path addBinding(Binding binding, AddOption option, Binding **bPtr = nullptr) + { + return insertUpdatableElementInMultiMap(pathFromOwner().field(Fields::bindings), m_bindings, + binding.name(), binding, option, bPtr); + } + MutableDomItem addBinding(MutableDomItem &self, Binding binding, AddOption option); + Path addMethod(const MethodInfo &functionDef, AddOption option, MethodInfo **mPtr = nullptr) + { + return insertUpdatableElementInMultiMap(pathFromOwner().field(Fields::methods), m_methods, + functionDef.name, functionDef, option, mPtr); + } + MutableDomItem addMethod(MutableDomItem &self, const MethodInfo &functionDef, AddOption option); + Path addChild(QmlObject child, QmlObject **cPtr = nullptr) + { + return appendUpdatableElementInQList(pathFromOwner().field(Fields::children), m_children, + child, cPtr); + } + MutableDomItem addChild(MutableDomItem &self, QmlObject child) + { + Path p = addChild(child); + return MutableDomItem(self.owner().item(), p); + } + Path addAnnotation(const QmlObject &annotation, QmlObject **aPtr = nullptr) + { + return appendUpdatableElementInQList(pathFromOwner().field(Fields::annotations), + m_annotations, annotation, aPtr); + } + void writeOut(const DomItem &self, OutWriter &ow, const QString &onTarget) const; + void writeOut(const DomItem &self, OutWriter &lw) const override { writeOut(self, lw, QString()); } + + LocallyResolvedAlias resolveAlias(const DomItem &self, + std::shared_ptr<ScriptExpression> accessSequence) const; + LocallyResolvedAlias resolveAlias(const DomItem &self, const QStringList &accessSequence) const; + + QQmlJSScope::ConstPtr semanticScope() const { return m_scope; } + void setSemanticScope(const QQmlJSScope::ConstPtr &scope) { m_scope = scope; } + + ScriptElementVariant nameIdentifiers() const { return m_nameIdentifiers; } + void setNameIdentifiers(const ScriptElementVariant &name) { m_nameIdentifiers = name; } + +private: + friend class QQmlDomAstCreator; + QString m_idStr; + QString m_name; + QList<Path> m_prototypePaths; + Path m_nextScopePath; + QString m_defaultPropertyName; + QMultiMap<QString, PropertyDefinition> m_propertyDefs; + QMultiMap<QString, Binding> m_bindings; + QMultiMap<QString, MethodInfo> m_methods; + QList<QmlObject> m_children; + QList<QmlObject> m_annotations; + QQmlJSScope::ConstPtr m_scope; + ScriptElementVariant m_nameIdentifiers; +}; + +class Export +{ + Q_DECLARE_TR_FUNCTIONS(Export) +public: + constexpr static DomType kindValue = DomType::Export; + static Export fromString( + const Path &source, QStringView exp, const Path &typePath, const ErrorHandler &h); + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const + { + bool cont = true; + cont = cont && self.dvValueField(visitor, Fields::uri, uri); + cont = cont && self.dvValueField(visitor, Fields::typeName, typeName); + cont = cont && self.dvWrapField(visitor, Fields::version, version); + if (typePath) + cont = cont && self.dvReferenceField(visitor, Fields::type, typePath); + cont = cont && self.dvValueField(visitor, Fields::isInternal, isInternal); + cont = cont && self.dvValueField(visitor, Fields::isSingleton, isSingleton); + if (exportSourcePath) + cont = cont && self.dvReferenceField(visitor, Fields::exportSource, exportSourcePath); + return cont; + } + + Path exportSourcePath; + QString uri; + QString typeName; + Version version; + Path typePath; + bool isInternal = false; + bool isSingleton = false; +}; + +class QMLDOM_EXPORT Component : public CommentableDomElement +{ +public: + Component(const QString &name); + Component(const Path &pathFromOwner = Path()); + Component(const Component &o) = default; + Component &operator=(const Component &) = default; + + bool iterateDirectSubpaths(const DomItem &, DirectVisitor) const override; + void updatePathFromOwner(const Path &newPath) override; + DomItem field(const DomItem &self, QStringView name) const override; + + QString name() const { return m_name; } + const QMultiMap<QString, EnumDecl> &enumerations() const & { return m_enumerations; } + const QList<QmlObject> &objects() const & { return m_objects; } + bool isSingleton() const { return m_isSingleton; } + bool isCreatable() const { return m_isCreatable; } + bool isComposite() const { return m_isComposite; } + QString attachedTypeName() const { return m_attachedTypeName; } + Path attachedTypePath(const DomItem &) const { return m_attachedTypePath; } + + void setName(const QString &name) { m_name = name; } + void setEnumerations(QMultiMap<QString, EnumDecl> enumerations) + { + m_enumerations = enumerations; + } + Path addEnumeration(const EnumDecl &enumeration, AddOption option = AddOption::Overwrite, + EnumDecl **ePtr = nullptr) + { + return insertUpdatableElementInMultiMap(pathFromOwner().field(Fields::enumerations), + m_enumerations, enumeration.name(), enumeration, + option, ePtr); + } + void setObjects(const QList<QmlObject> &objects) { m_objects = objects; } + Path addObject(const QmlObject &object, QmlObject **oPtr = nullptr); + void setIsSingleton(bool isSingleton) { m_isSingleton = isSingleton; } + void setIsCreatable(bool isCreatable) { m_isCreatable = isCreatable; } + void setIsComposite(bool isComposite) { m_isComposite = isComposite; } + void setAttachedTypeName(const QString &name) { m_attachedTypeName = name; } + void setAttachedTypePath(const Path &p) { m_attachedTypePath = p; } + +private: + friend class QQmlDomAstCreator; + QString m_name; + QMultiMap<QString, EnumDecl> m_enumerations; + QList<QmlObject> m_objects; + bool m_isSingleton = false; + bool m_isCreatable = true; + bool m_isComposite = true; + QString m_attachedTypeName; + Path m_attachedTypePath; +}; + +class QMLDOM_EXPORT JsResource final : public Component +{ +public: + constexpr static DomType kindValue = DomType::JsResource; + DomType kind() const override { return kindValue; } + + JsResource(const Path &pathFromOwner = Path()) : Component(pathFromOwner) { } + bool iterateDirectSubpaths(const DomItem &, DirectVisitor) const override + { // to do: complete + return true; + } + // globalSymbols defined/exported, required/used +}; + +class QMLDOM_EXPORT QmltypesComponent final : public Component +{ +public: + constexpr static DomType kindValue = DomType::QmltypesComponent; + DomType kind() const override { return kindValue; } + + QmltypesComponent(const Path &pathFromOwner = Path()) : Component(pathFromOwner) { } + bool iterateDirectSubpaths(const DomItem &, DirectVisitor) const override; + const QList<Export> &exports() const & { return m_exports; } + QString fileName() const { return m_fileName; } + void setExports(QList<Export> exports) { m_exports = exports; } + void addExport(const Export &exportedEntry) { m_exports.append(exportedEntry); } + void setFileName(const QString &fileName) { m_fileName = fileName; } + const QList<int> &metaRevisions() const & { return m_metaRevisions; } + void setMetaRevisions(QList<int> metaRevisions) { m_metaRevisions = metaRevisions; } + void setInterfaceNames(const QStringList& interfaces) { m_interfaceNames = interfaces; } + const QStringList &interfaceNames() const & { return m_interfaceNames; } + QString extensionTypeName() const { return m_extensionTypeName; } + void setExtensionTypeName(const QString &name) { m_extensionTypeName = name; } + QString valueTypeName() const { return m_valueTypeName; } + void setValueTypeName(const QString &name) { m_valueTypeName = name; } + bool hasCustomParser() const { return m_hasCustomParser; } + void setHasCustomParser(bool v) { m_hasCustomParser = v; } + bool extensionIsJavaScript() const { return m_extensionIsJavaScript; } + void setExtensionIsJavaScript(bool v) { m_extensionIsJavaScript = v; } + bool extensionIsNamespace() const { return m_extensionIsNamespace; } + void setExtensionIsNamespace(bool v) { m_extensionIsNamespace = v; } + QQmlJSScope::AccessSemantics accessSemantics() const { return m_accessSemantics; } + void setAccessSemantics(QQmlJSScope::AccessSemantics v) { m_accessSemantics = v; } + + void setSemanticScope(const QQmlJSScope::ConstPtr &scope) { m_semanticScope = scope; } + QQmlJSScope::ConstPtr semanticScope() const { return m_semanticScope; } + +private: + QList<Export> m_exports; + QList<int> m_metaRevisions; + QString m_fileName; // remove? + QStringList m_interfaceNames; + bool m_hasCustomParser = false; + bool m_extensionIsJavaScript = false; + bool m_extensionIsNamespace = false; + QString m_valueTypeName; + QString m_extensionTypeName; + QQmlJSScope::AccessSemantics m_accessSemantics = QQmlJSScope::AccessSemantics::None; + QQmlJSScope::ConstPtr m_semanticScope; +}; + +class QMLDOM_EXPORT QmlComponent final : public Component +{ +public: + constexpr static DomType kindValue = DomType::QmlComponent; + DomType kind() const override { return kindValue; } + + QmlComponent(const QString &name = QString()) : Component(name) + { + setIsComposite(true); + setIsCreatable(true); + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + + const QMultiMap<QString, Id> &ids() const & { return m_ids; } + Path nextComponentPath() const { return m_nextComponentPath; } + void setIds(QMultiMap<QString, Id> ids) { m_ids = ids; } + void setNextComponentPath(const Path &p) { m_nextComponentPath = p; } + void updatePathFromOwner(const Path &newPath) override; + Path addId(const Id &id, AddOption option = AddOption::Overwrite, Id **idPtr = nullptr) + { + // warning does nor remove old idStr when overwriting... + return insertUpdatableElementInMultiMap(pathFromOwner().field(Fields::ids), m_ids, id.name, + id, option, idPtr); + } + void writeOut(const DomItem &self, OutWriter &) const override; + QList<QString> subComponentsNames(const DomItem &self) const; + QList<DomItem> subComponents(const DomItem &self) const; + + void setSemanticScope(const QQmlJSScope::ConstPtr &scope) { m_semanticScope = scope; } + QQmlJSScope::ConstPtr semanticScope() const { return m_semanticScope; } + ScriptElementVariant nameIdentifiers() const { return m_nameIdentifiers; } + void setNameIdentifiers(const ScriptElementVariant &name) { m_nameIdentifiers = name; } + +private: + friend class QQmlDomAstCreator; + Path m_nextComponentPath; + QMultiMap<QString, Id> m_ids; + QQmlJSScope::ConstPtr m_semanticScope; + // m_nameIdentifiers contains the name of the component as FieldMemberExpression, and therefore + // only exists in inline components! + ScriptElementVariant m_nameIdentifiers; +}; + +class QMLDOM_EXPORT GlobalComponent final : public Component +{ +public: + constexpr static DomType kindValue = DomType::GlobalComponent; + DomType kind() const override { return kindValue; } + + GlobalComponent(const Path &pathFromOwner = Path()) : Component(pathFromOwner) { } +}; + +static ErrorGroups importErrors = { { DomItem::domErrorGroup, NewErrorGroup("importError") } }; + +class QMLDOM_EXPORT ImportScope +{ + Q_DECLARE_TR_FUNCTIONS(ImportScope) +public: + constexpr static DomType kindValue = DomType::ImportScope; + + ImportScope() = default; + ~ImportScope() = default; + + const QList<Path> &importSourcePaths() const & { return m_importSourcePaths; } + + const QMap<QString, ImportScope> &subImports() const & { return m_subImports; } + + QList<Path> allSources(const DomItem &self) const; + + QSet<QString> importedNames(const DomItem &self) const + { + QSet<QString> res; + const auto sources = allSources(self); + for (const Path &p : sources) { + QSet<QString> ks = self.path(p.field(Fields::exports), self.errorHandler()).keys(); + res += ks; + } + return res; + } + + QList<DomItem> importedItemsWithName(const DomItem &self, const QString &name) const + { + QList<DomItem> res; + const auto sources = allSources(self); + for (const Path &p : sources) { + DomItem source = self.path(p.field(Fields::exports), self.errorHandler()); + DomItem els = source.key(name); + int nEls = els.indexes(); + for (int i = 0; i < nEls; ++i) + res.append(els.index(i)); + if (nEls == 0 && els) { + self.addError(importErrors.warning( + tr("Looking up '%1' expected a list of exports, not %2") + .arg(name, els.toString()))); + } + } + return res; + } + + QList<Export> importedExportsWithName(const DomItem &self, const QString &name) const + { + QList<Export> res; + for (const DomItem &i : importedItemsWithName(self, name)) + if (const Export *e = i.as<Export>()) + res.append(*e); + else + self.addError(importErrors.warning( + tr("Expected Export looking up '%1', not %2").arg(name, i.toString()))); + return res; + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const; + + void addImport(QStringList p, const Path &targetExports) + { + if (!p.isEmpty()) { + const QString current = p.takeFirst(); + m_subImports[current].addImport(std::move(p), targetExports); + } else if (!m_importSourcePaths.contains(targetExports)) { + m_importSourcePaths.append(targetExports); + } + } + +private: + QList<Path> m_importSourcePaths; + QMap<QString, ImportScope> m_subImports; +}; + +class BindingValue +{ +public: + BindingValue(); + BindingValue(const QmlObject &o); + BindingValue(const std::shared_ptr<ScriptExpression> &o); + BindingValue(const QList<QmlObject> &l); + ~BindingValue(); + BindingValue(const BindingValue &o); + BindingValue &operator=(const BindingValue &o); + + DomItem value(const DomItem &binding) const; + void updatePathFromOwner(const Path &newPath); + +private: + friend class Binding; + void clearValue(); + + BindingValueKind kind; + union { + int dummy; + QmlObject object; + std::shared_ptr<ScriptExpression> scriptExpression; + QList<QmlObject> array; + }; +}; + +} // end namespace Dom +} // end namespace QQmlJS +QT_END_NAMESPACE +#endif // QQMLDOMELEMENTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomerrormessage_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomerrormessage_p.h new file mode 100644 index 0000000000000000000000000000000000000000..48419bcb292650094ba580f05ac31ef2e1959615 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomerrormessage_p.h @@ -0,0 +1,221 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef ERRORMESSAGE_H +#define ERRORMESSAGE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldomstringdumper_p.h" +#include "qqmldompath_p.h" + +#include <QtQml/private/qqmljsast_p.h> +#include <QtCore/QCoreApplication> +#include <QtCore/QString> +#include <QtCore/QCborArray> +#include <QtCore/QCborMap> +#include <QtCore/QLoggingCategory> +#include <QtQml/private/qqmljsdiagnosticmessage_p.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(domLog); + +namespace QQmlJS { +namespace Dom { + +QMLDOM_EXPORT ErrorLevel errorLevelFromQtMsgType(QtMsgType msgType); + +class ErrorGroups; +class DomItem; +using std::function; + +#define NewErrorGroup(name) QQmlJS::Dom::ErrorGroup(QT_TRANSLATE_NOOP("ErrorGroup", name)) + +class QMLDOM_EXPORT ErrorGroup { + Q_GADGET + Q_DECLARE_TR_FUNCTIONS(ErrorGroup) +public: + constexpr ErrorGroup(const char *groupId): + m_groupId(groupId) + {} + + + void dump(const Sink &sink) const; + void dumpId(const Sink &sink) const; + + QLatin1String groupId() const; + QString groupName() const; + private: + const char *m_groupId; +}; + +class QMLDOM_EXPORT ErrorGroups{ + Q_GADGET +public: + void dump(const Sink &sink) const; + void dumpId(const Sink &sink) const; + QCborArray toCbor() const; + + [[nodiscard]] ErrorMessage errorMessage( + const Dumper &msg, ErrorLevel level, const Path &element = Path(), + const QString &canonicalFilePath = QString(), SourceLocation location = SourceLocation()) const; + [[nodiscard]] ErrorMessage errorMessage( + const DiagnosticMessage &msg, const Path &element = Path(), + const QString &canonicalFilePath = QString()) const; + + void fatal(const Dumper &msg, const Path &element = Path(), QStringView canonicalFilePath = u"", + SourceLocation location = SourceLocation()) const; + + [[nodiscard]] ErrorMessage debug(const QString &message) const; + [[nodiscard]] ErrorMessage debug(const Dumper &message) const; + [[nodiscard]] ErrorMessage info(const QString &message) const; + [[nodiscard]] ErrorMessage info(const Dumper &message) const; + [[nodiscard]] ErrorMessage warning(const QString &message) const; + [[nodiscard]] ErrorMessage warning(const Dumper &message) const; + [[nodiscard]] ErrorMessage error(const QString &message) const; + [[nodiscard]] ErrorMessage error(const Dumper &message) const; + + static int cmp(const ErrorGroups &g1, const ErrorGroups &g2); + + QVector<ErrorGroup> groups; +}; + +inline bool operator==(const ErrorGroups& lhs, const ErrorGroups& rhs){ return ErrorGroups::cmp(lhs,rhs) == 0; } +inline bool operator!=(const ErrorGroups& lhs, const ErrorGroups& rhs){ return ErrorGroups::cmp(lhs,rhs) != 0; } +inline bool operator< (const ErrorGroups& lhs, const ErrorGroups& rhs){ return ErrorGroups::cmp(lhs,rhs) < 0; } +inline bool operator> (const ErrorGroups& lhs, const ErrorGroups& rhs){ return ErrorGroups::cmp(lhs,rhs) > 0; } +inline bool operator<=(const ErrorGroups& lhs, const ErrorGroups& rhs){ return ErrorGroups::cmp(lhs,rhs) <= 0; } +inline bool operator>=(const ErrorGroups& lhs, const ErrorGroups& rhs){ return ErrorGroups::cmp(lhs,rhs) >= 0; } + +class QMLDOM_EXPORT ErrorMessage { // reuse Some of the other DiagnosticMessages? + Q_GADGET + Q_DECLARE_TR_FUNCTIONS(ErrorMessage) +public: + using Level = ErrorLevel; + // error registry (usage is optional) + static QLatin1String msg(const char *errorId, ErrorMessage &&err); + static QLatin1String msg(QLatin1String errorId, ErrorMessage &&err); + static void visitRegisteredMessages(function_ref<bool (const ErrorMessage &)> visitor); + [[nodiscard]] static ErrorMessage load(QLatin1String errorId); + [[nodiscard]] static ErrorMessage load(const char *errorId); + template<typename... T> + [[nodiscard]] static ErrorMessage load(QLatin1String errorId, T... args){ + ErrorMessage res = load(errorId); + res.message = res.message.arg(args...); + return res; + } + + ErrorMessage( + const QString &message, const ErrorGroups &errorGroups, Level level = Level::Warning, + const Path &path = Path(), const QString &file = QString(), + SourceLocation location = SourceLocation(), QLatin1String errorId = QLatin1String("")); + ErrorMessage( + const ErrorGroups &errorGroups, const DiagnosticMessage &msg, const Path &path = Path(), + const QString &file = QString(), QLatin1String errorId = QLatin1String("")); + + [[nodiscard]] ErrorMessage &withErrorId(QLatin1String errorId); + [[nodiscard]] ErrorMessage &withPath(const Path &); + [[nodiscard]] ErrorMessage &withFile(const QString &); + [[nodiscard]] ErrorMessage &withFile(QStringView); + [[nodiscard]] ErrorMessage &withLocation(SourceLocation); + [[nodiscard]] ErrorMessage &withItem(const DomItem &); + + ErrorMessage handle(const ErrorHandler &errorHandler=nullptr); + + void dump(const Sink &s) const; + QString toString() const; + QCborMap toCbor() const; + friend int compare(const ErrorMessage &msg1, const ErrorMessage &msg2) + { + int c; + c = msg1.location.offset - msg2.location.offset; + if (c != 0) + return c; + c = msg1.location.startLine - msg2.location.startLine; + if (c != 0) + return c; + c = msg1.errorId.compare(msg2.errorId); + if (c != 0) + return c; + if (!msg1.errorId.isEmpty()) + return 0; + c = msg1.message.compare(msg2.message); + if (c != 0) + return c; + c = msg1.file.compare(msg2.file); + if (c != 0) + return c; + c = Path::cmp(msg1.path, msg2.path); + if (c != 0) + return c; + c = int(msg1.level) - int(msg2.level); + if (c != 0) + return c; + c = int(msg1.errorGroups.groups.size() - msg2.errorGroups.groups.size()); + if (c != 0) + return c; + for (qsizetype i = 0; i < msg1.errorGroups.groups.size(); ++i) { + c = msg1.errorGroups.groups[i].groupId().compare(msg2.errorGroups.groups[i].groupId()); + if (c != 0) + return c; + } + c = msg1.location.length - msg2.location.length; + if (c != 0) + return c; + c = msg1.location.startColumn - msg2.location.startColumn; + return c; + } + + QLatin1String errorId; + QString message; + ErrorGroups errorGroups; + Level level; + Path path; + QString file; + SourceLocation location; +}; + +inline bool operator !=(const ErrorMessage &e1, const ErrorMessage &e2) { + return compare(e1, e2) != 0; +} +inline bool operator ==(const ErrorMessage &e1, const ErrorMessage &e2) { + return compare(e1, e2) == 0; +} +inline bool operator<(const ErrorMessage &e1, const ErrorMessage &e2) +{ + return compare(e1, e2) < 0; +} +inline bool operator<=(const ErrorMessage &e1, const ErrorMessage &e2) +{ + return compare(e1, e2) <= 0; +} +inline bool operator>(const ErrorMessage &e1, const ErrorMessage &e2) +{ + return compare(e1, e2) > 0; +} +inline bool operator>=(const ErrorMessage &e1, const ErrorMessage &e2) +{ + return compare(e1, e2) >= 0; +} + +QMLDOM_EXPORT void silentError(const ErrorMessage &); +QMLDOM_EXPORT void errorToQDebug(const ErrorMessage &); + +QMLDOM_EXPORT void defaultErrorHandler(const ErrorMessage &); +QMLDOM_EXPORT void setDefaultErrorHandler(const ErrorHandler &h); + +} // end namespace Dom +} // end namespace QQmlJS +QT_END_NAMESPACE +#endif // ERRORMESSAGE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomexternalitems_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomexternalitems_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d1fd50912d00e109280d42584a9933d87dc05329 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomexternalitems_p.h @@ -0,0 +1,604 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMEXTERNALITEMS_P_H +#define QQMLDOMEXTERNALITEMS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldomitem_p.h" +#include "qqmldomelements_p.h" +#include "qqmldommoduleindex_p.h" +#include "qqmldomcomments_p.h" + +#include <QtQml/private/qqmljsast_p.h> +#include <QtQml/private/qqmljsengine_p.h> +#include <QtQml/private/qqmldirparser_p.h> +#include <QtQmlCompiler/private/qqmljstyperesolver_p.h> +#include <QtCore/QMetaType> +#include <QtCore/qregularexpression.h> + +#include <limits> +#include <memory> + +Q_DECLARE_METATYPE(QQmlDirParser::Plugin) + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +/*! +\internal +\class QQmlJS::Dom::ExternalOwningItem + +\brief A OwningItem that refers to an external resource (file,...) + +Every owning item has a file or directory it refers to. + + +*/ +class QMLDOM_EXPORT ExternalOwningItem: public OwningItem { +public: + ExternalOwningItem( + const QString &filePath, const QDateTime &lastDataUpdateAt, const Path &pathFromTop, + int derivedFrom = 0, const QString &code = QString()); + ExternalOwningItem(const ExternalOwningItem &o) = default; + QString canonicalFilePath(const DomItem &) const override; + QString canonicalFilePath() const; + Path canonicalPath(const DomItem &) const override; + Path canonicalPath() const; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override + { + bool cont = OwningItem::iterateDirectSubpaths(self, visitor); + cont = cont && self.dvValueLazyField(visitor, Fields::canonicalFilePath, [this]() { + return canonicalFilePath(); + }); + cont = cont + && self.dvValueLazyField(visitor, Fields::isValid, [this]() { return isValid(); }); + if (!code().isNull()) + cont = cont + && self.dvValueLazyField(visitor, Fields::code, [this]() { return code(); }); + return cont; + } + + bool iterateSubOwners(const DomItem &self, function_ref<bool(const DomItem &owner)> visitor) override + { + bool cont = OwningItem::iterateSubOwners(self, visitor); + cont = cont && self.field(Fields::components).visitKeys([visitor](const QString &, const DomItem &comps) { + return comps.visitIndexes([visitor](const DomItem &comp) { + return comp.field(Fields::objects).visitIndexes([visitor](const DomItem &qmlObj) { + if (const QmlObject *qmlObjPtr = qmlObj.as<QmlObject>()) + return qmlObjPtr->iterateSubOwners(qmlObj, visitor); + Q_ASSERT(false); + return true; + }); + }); + }); + return cont; + } + + bool isValid() const { + QMutexLocker l(mutex()); + return m_isValid; + } + void setIsValid(bool val) { + QMutexLocker l(mutex()); + m_isValid = val; + } + // null code means invalid + const QString &code() const { return m_code; } + +protected: + QString m_canonicalFilePath; + QString m_code; + Path m_path; + bool m_isValid = false; +}; + +class QMLDOM_EXPORT QmlDirectory final : public ExternalOwningItem +{ +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &) const override + { + return std::make_shared<QmlDirectory>(*this); + } + +public: + constexpr static DomType kindValue = DomType::QmlDirectory; + DomType kind() const override { return kindValue; } + QmlDirectory( + const QString &filePath = QString(), const QStringList &dirList = QStringList(), + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + int derivedFrom = 0); + QmlDirectory(const QmlDirectory &o) = default; + + std::shared_ptr<QmlDirectory> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<QmlDirectory>(doCopy(self)); + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + + const QMultiMap<QString, Export> &exports() const & { return m_exports; } + + const QMultiMap<QString, QString> &qmlFiles() const & { return m_qmlFiles; } + + bool addQmlFilePath(const QString &relativePath); + +private: + QMultiMap<QString, Export> m_exports; + QMultiMap<QString, QString> m_qmlFiles; +}; + +class QMLDOM_EXPORT QmldirFile final : public ExternalOwningItem +{ + Q_DECLARE_TR_FUNCTIONS(QmldirFile) +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &) const override + { + auto copy = std::make_shared<QmldirFile>(*this); + return copy; + } + +public: + constexpr static DomType kindValue = DomType::QmldirFile; + DomType kind() const override { return kindValue; } + + static ErrorGroups myParsingErrors(); + + QmldirFile( + const QString &filePath = QString(), const QString &code = QString(), + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + int derivedFrom = 0) + : ExternalOwningItem(filePath, lastDataUpdateAt, Paths::qmldirFilePath(filePath), + derivedFrom, code) + { + } + QmldirFile(const QmldirFile &o) = default; + + static std::shared_ptr<QmldirFile> fromPathAndCode(const QString &path, const QString &code); + + std::shared_ptr<QmldirFile> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<QmldirFile>(doCopy(self)); + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + + QmlUri uri() const { return m_uri; } + + const QSet<int> &majorVersions() const & { return m_majorVersions; } + + const QMultiMap<QString, Export> &exports() const & { return m_exports; } + + const QList<Import> &imports() const & { return m_imports; } + + const QList<Path> &qmltypesFilePaths() const & { return m_qmltypesFilePaths; } + + QMap<QString, QString> qmlFiles() const; + + bool designerSupported() const { return m_qmldir.designerSupported(); } + + QStringList classNames() const { return m_qmldir.classNames(); } + + QList<ModuleAutoExport> autoExports() const; + void setAutoExports(const QList<ModuleAutoExport> &autoExport); + + void ensureInModuleIndex(const DomItem &self, const QString &uri) const; + +private: + void parse(); + void setFromQmldir(); + + QmlUri m_uri; + QSet<int> m_majorVersions; + QQmlDirParser m_qmldir; + QList<QQmlDirParser::Plugin> m_plugins; + QList<Import> m_imports; + QList<ModuleAutoExport> m_autoExports; + QMultiMap<QString, Export> m_exports; + QList<Path> m_qmltypesFilePaths; +}; + +class QMLDOM_EXPORT JsFile final : public ExternalOwningItem +{ +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &) const override + { + auto copy = std::make_shared<JsFile>(*this); + return copy; + } + +public: + constexpr static DomType kindValue = DomType::JsFile; + DomType kind() const override { return kindValue; } + JsFile(const QString &filePath = QString(), + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + const Path &pathFromTop = Path(), int derivedFrom = 0) + : ExternalOwningItem(filePath, lastDataUpdateAt, pathFromTop, derivedFrom) + { + } + JsFile(const QString &filePath = QString(), const QString &code = QString(), + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + int derivedFrom = 0); + JsFile(const JsFile &o) = default; + + std::shared_ptr<JsFile> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<JsFile>(doCopy(self)); + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const + override; // iterates the *direct* subpaths, returns false if a quick end was requested + + std::shared_ptr<QQmlJS::Engine> engine() const { return m_engine; } + JsResource rootComponent() const { return m_rootComponent; } + void setFileLocationsTree(const FileLocations::Tree &v) { m_fileLocationsTree = std::move(v); } + + static ErrorGroups myParsingErrors(); + + void writeOut(const DomItem &self, OutWriter &lw) const override; + void setExpression(const std::shared_ptr<ScriptExpression> &script) { m_script = script; } + + void initPragmaLibrary() { m_pragmaLibrary = LegacyPragmaLibrary{}; }; + void addFileImport(const QString &jsfile, const QString &module); + void addModuleImport(const QString &uri, const QString &version, const QString &module); + +private: + void writeOutDirectives(OutWriter &lw) const; + + /* + Entities with Legacy prefix are here to support formatting of the discouraged + .import, .pragma directives in .js files. + Taking into account that usage of these directives is discouraged and + the fact that current usecase is limited to the formatting of .js, it's arguably should not + be exposed and kept private. + + LegacyPragma corresponds to the only one existing .pragma library + + LegacyImport is capable of representing the following import statements: + .import T_STRING_LITERAL as T_IDENTIFIER + .import T_IDENTIFIER (. T_IDENTIFIER)* (T_VERSION_NUMBER (. T_VERSION_NUMBER)?)? as T_IDENTIFIER + + LegacyDirectivesCollector is a workaround for collecting those directives. + At the moment of writing .import, .pragma in .js files do not have corresponding + representative AST::Node-s. Collecting of those is happening during the lexing + */ + + struct LegacyPragmaLibrary + { + void writeOut(OutWriter &lw) const; + }; + + struct LegacyImport + { + QString fileName; // file import + QString uri; // module import + QString version; // used for module import + QString asIdentifier; // .import ... as T_Identifier + + void writeOut(OutWriter &lw) const; + }; + + class LegacyDirectivesCollector : public QQmlJS::Directives + { + public: + LegacyDirectivesCollector(JsFile &file) : m_file(file){}; + + void pragmaLibrary() override { m_file.initPragmaLibrary(); }; + void importFile(const QString &jsfile, const QString &module, int, int) override + { + m_file.addFileImport(jsfile, module); + }; + void importModule(const QString &uri, const QString &version, const QString &module, int, + int) override + { + m_file.addModuleImport(uri, version, module); + }; + + private: + JsFile &m_file; + }; + +private: + std::shared_ptr<QQmlJS::Engine> m_engine; + std::optional<LegacyPragmaLibrary> m_pragmaLibrary = std::nullopt; + QList<LegacyImport> m_imports; + std::shared_ptr<ScriptExpression> m_script; + JsResource m_rootComponent; + FileLocations::Tree m_fileLocationsTree; +}; + +class QMLDOM_EXPORT QmlFile final : public ExternalOwningItem +{ +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override; + +public: + constexpr static DomType kindValue = DomType::QmlFile; + DomType kind() const override { return kindValue; } + + enum RecoveryOption { DisableParserRecovery, EnableParserRecovery }; + + QmlFile(const QString &filePath = QString(), const QString &code = QString(), + const QDateTime &lastDataUpdate = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + int derivedFrom = 0, RecoveryOption option = DisableParserRecovery); + static ErrorGroups myParsingErrors(); + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const + override; // iterates the *direct* subpaths, returns false if a quick end was requested + DomItem field(const DomItem &self, QStringView name) const override; + std::shared_ptr<QmlFile> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<QmlFile>(doCopy(self)); + } + void addError(const DomItem &self, ErrorMessage &&msg) override; + + const QMultiMap<QString, QmlComponent> &components() const & + { + return lazyMembers().m_components; + } + void setComponents(const QMultiMap<QString, QmlComponent> &components) + { + lazyMembers().m_components = components; + } + Path addComponent(const QmlComponent &component, AddOption option = AddOption::Overwrite, + QmlComponent **cPtr = nullptr) + { + QStringList nameEls = component.name().split(QChar::fromLatin1('.')); + QString key = nameEls.mid(1).join(QChar::fromLatin1('.')); + return insertUpdatableElementInMultiMap(Path::Field(Fields::components), lazyMembers().m_components, + key, component, option, cPtr); + } + + void writeOut(const DomItem &self, OutWriter &lw) const override; + + AST::UiProgram *ast() const + { + return m_ast; // avoid making it public? would make moving away from it easier + } + const QList<Import> &imports() const & + { + return lazyMembers().m_imports; + } + void setImports(const QList<Import> &imports) { lazyMembers().m_imports = imports; } + Path addImport(const Import &i) + { + auto &members = lazyMembers(); + index_type idx = index_type(members.m_imports.size()); + members.m_imports.append(i); + if (i.uri.isModule()) { + members.m_importScope.addImport((i.importId.isEmpty() + ? QStringList() + : i.importId.split(QChar::fromLatin1('.'))), + i.importedPath()); + } else { + QString path = i.uri.absoluteLocalPath(canonicalFilePath()); + if (!path.isEmpty()) + members.m_importScope.addImport( + (i.importId.isEmpty() ? QStringList() + : i.importId.split(QChar::fromLatin1('.'))), + Paths::qmlDirPath(path)); + } + return Path::Field(Fields::imports).index(idx); + } + std::shared_ptr<QQmlJS::Engine> engine() const { return m_engine; } + RegionComments &comments() { return lazyMembers().m_comments; } + std::shared_ptr<AstComments> astComments() const { return lazyMembers().m_astComments; } + void setAstComments(const std::shared_ptr<AstComments> &comm) { lazyMembers().m_astComments = comm; } + FileLocations::Tree fileLocationsTree() const { return lazyMembers().m_fileLocationsTree; } + void setFileLocationsTree(const FileLocations::Tree &v) { lazyMembers().m_fileLocationsTree = v; } + const QList<Pragma> &pragmas() const & { return lazyMembers().m_pragmas; } + void setPragmas(QList<Pragma> pragmas) { lazyMembers().m_pragmas = pragmas; } + Path addPragma(const Pragma &pragma) + { + auto &members = lazyMembers(); + int idx = members.m_pragmas.size(); + members.m_pragmas.append(pragma); + return Path::Field(Fields::pragmas).index(idx); + } + ImportScope &importScope() { return lazyMembers().m_importScope; } + const ImportScope &importScope() const { return lazyMembers().m_importScope; } + + std::shared_ptr<QQmlJSTypeResolver> typeResolver() const + { + return lazyMembers().m_typeResolver; + } + void setTypeResolverWithDependencies(const std::shared_ptr<QQmlJSTypeResolver> &typeResolver, + const QQmlJSTypeResolverDependencies &dependencies) + { + auto &members = lazyMembers(); + members.m_typeResolver = typeResolver; + members.m_typeResolverDependencies = dependencies; + } + + DomCreationOptions creationOptions() const { return lazyMembers().m_creationOptions; } + + QQmlJSScope::ConstPtr handleForPopulation() const + { + return m_handleForPopulation; + } + + void setHandleForPopulation(const QQmlJSScope::ConstPtr &scope) + { + m_handleForPopulation = scope; + } + + +private: + // The lazy parts of QmlFile are inside of QmlFileLazy. + struct QmlFileLazy + { + QmlFileLazy(FileLocations::Tree fileLocationsTree, AstComments *astComments) + : m_fileLocationsTree(fileLocationsTree), m_astComments(astComments) + { + } + RegionComments m_comments; + QMultiMap<QString, QmlComponent> m_components; + QList<Pragma> m_pragmas; + QList<Import> m_imports; + ImportScope m_importScope; + FileLocations::Tree m_fileLocationsTree; + std::shared_ptr<AstComments> m_astComments; + DomCreationOptions m_creationOptions; + std::shared_ptr<QQmlJSTypeResolver> m_typeResolver; + QQmlJSTypeResolverDependencies m_typeResolverDependencies; + }; + friend class QQmlDomAstCreator; + AST::UiProgram *m_ast; // avoid? would make moving away from it easier + std::shared_ptr<Engine> m_engine; + QQmlJSScope::ConstPtr m_handleForPopulation; + mutable std::optional<QmlFileLazy> m_lazyMembers; + + void ensurePopulated() const + { + if (m_lazyMembers) + return; + + m_lazyMembers.emplace(FileLocations::createTree(canonicalPath()), new AstComments(m_engine)); + + // populate via the QQmlJSScope by accessing the (lazy) pointer + if (m_handleForPopulation.factory()) { + // silence no-discard attribute: + Q_UNUSED(m_handleForPopulation.data()); + } + } + const QmlFileLazy &lazyMembers() const + { + ensurePopulated(); + return *m_lazyMembers; + } + QmlFileLazy &lazyMembers() + { + ensurePopulated(); + return *m_lazyMembers; + } +}; + +class QMLDOM_EXPORT QmltypesFile final : public ExternalOwningItem +{ +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &) const override + { + auto res = std::make_shared<QmltypesFile>(*this); + return res; + } + +public: + constexpr static DomType kindValue = DomType::QmltypesFile; + DomType kind() const override { return kindValue; } + + QmltypesFile( + const QString &filePath = QString(), const QString &code = QString(), + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + int derivedFrom = 0) + : ExternalOwningItem(filePath, lastDataUpdateAt, Paths::qmltypesFilePath(filePath), + derivedFrom, code) + { + } + + QmltypesFile(const QmltypesFile &o) = default; + + void ensureInModuleIndex(const DomItem &self) const; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + std::shared_ptr<QmltypesFile> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<QmltypesFile>(doCopy(self)); + } + + void addImport(const Import i) + { // builder only: not threadsafe... + m_imports.append(i); + } + const QList<Import> &imports() const & { return m_imports; } + const QMultiMap<QString, QmltypesComponent> &components() const & { return m_components; } + void setComponents(QMultiMap<QString, QmltypesComponent> c) { m_components = std::move(c); } + Path addComponent(const QmltypesComponent &comp, AddOption option = AddOption::Overwrite, + QmltypesComponent **cPtr = nullptr) + { + for (const Export &e : comp.exports()) + addExport(e); + return insertUpdatableElementInMultiMap(Path::Field(u"components"), m_components, + comp.name(), comp, option, cPtr); + } + const QMultiMap<QString, Export> &exports() const & { return m_exports; } + void setExports(QMultiMap<QString, Export> e) { m_exports = e; } + Path addExport(const Export &e) + { + index_type i = m_exports.values(e.typeName).size(); + m_exports.insert(e.typeName, e); + addUri(e.uri, e.version.majorVersion); + return canonicalPath().field(Fields::exports).index(i); + } + + const QMap<QString, QSet<int>> &uris() const & { return m_uris; } + void addUri(const QString &uri, int majorVersion) + { + QSet<int> &v = m_uris[uri]; + if (!v.contains(majorVersion)) { + v.insert(majorVersion); + } + } + +private: + QList<Import> m_imports; + QMultiMap<QString, QmltypesComponent> m_components; + QMultiMap<QString, Export> m_exports; + QMap<QString, QSet<int>> m_uris; +}; + +class QMLDOM_EXPORT GlobalScope final : public ExternalOwningItem +{ +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &) const override; + +public: + constexpr static DomType kindValue = DomType::GlobalScope; + DomType kind() const override { return kindValue; } + + GlobalScope( + const QString &filePath = QString(), + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + int derivedFrom = 0) + : ExternalOwningItem(filePath, lastDataUpdateAt, Paths::globalScopePath(filePath), + derivedFrom) + { + setIsValid(true); + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + std::shared_ptr<GlobalScope> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<GlobalScope>(doCopy(self)); + } + QString name() const { return m_name; } + Language language() const { return m_language; } + GlobalComponent rootComponent() const { return m_rootComponent; } + void setName(const QString &name) { m_name = name; } + void setLanguage(Language language) { m_language = language; } + void setRootComponent(const GlobalComponent &ob) + { + m_rootComponent = ob; + m_rootComponent.updatePathFromOwner(Path::Field(Fields::rootComponent)); + } + +private: + QString m_name; + Language m_language; + GlobalComponent m_rootComponent; +}; + +} // end namespace Dom +} // end namespace QQmlJS +QT_END_NAMESPACE +#endif // QQMLDOMEXTERNALITEMS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomfieldfilter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomfieldfilter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..03396c8a0441269d66a3871216b2611602625563 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomfieldfilter_p.h @@ -0,0 +1,69 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMFIELDFILTER_P_H +#define QQMLDOMFIELDFILTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_fwd_p.h" +#include "qqmldom_global.h" +#include "qqmldompath_p.h" + +#include <QtCore/qobject.h> +#include <QtCore/qmap.h> +#include <QtCore/qset.h> +#include <QtQml/private/qqmljsastvisitor_p.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +class QMLDOM_EXPORT FieldFilter +{ + Q_GADGET +public: + QString describeFieldsFilter() const; + bool addFilter(const QString &f); + bool operator()(const DomItem &, const Path &, const DomItem &) const; + bool operator()(const DomItem &, const PathEls::PathComponent &c, const DomItem &) const; + static FieldFilter noFilter(); + static FieldFilter defaultFilter(); + static FieldFilter noLocationFilter(); + static FieldFilter compareFilter(); + static FieldFilter compareNoCommentsFilter(); + void setFiltred(); + const QMultiMap<QString, QString> &fieldFilterAdd() const { return m_fieldFilterAdd; } + QMultiMap<QString, QString> fieldFilterRemove() const { return m_fieldFilterRemove; } + QSet<DomType> filtredTypes; + + FieldFilter(const QMultiMap<QString, QString> &fieldFilterAdd = {}, + const QMultiMap<QString, QString> &fieldFilterRemove = {}) + : m_fieldFilterAdd(fieldFilterAdd), m_fieldFilterRemove(fieldFilterRemove) + { + setFiltred(); + } + +private: + QMultiMap<QString, QString> m_fieldFilterAdd; + QMultiMap<QString, QString> m_fieldFilterRemove; + QSet<DomType> m_filtredTypes; + QSet<size_t> m_filtredFields; + bool m_filtredDefault = true; +}; + +} // end namespace Dom +} // end namespace QQmlJS + +QT_END_NAMESPACE +#endif // QQMLDOMFIELDFILTER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomfilewriter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomfilewriter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c76d97c8d1a3e74c60a83d16f4c3b98e41ce5fc6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomfilewriter_p.h @@ -0,0 +1,65 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMFILEWRITER_P +#define QQMLDOMFILEWRITER_P + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldomfunctionref_p.h" + +#include <QtCore/QFile> +#include <QtCore/QStringList> +#include <QtCore/QCoreApplication> + +QT_BEGIN_NAMESPACE +namespace QQmlJS { +namespace Dom { + +class QMLDOM_EXPORT FileWriter +{ + Q_GADGET + Q_DECLARE_TR_FUNCTIONS(FileWriter) +public: + enum class Status { ShouldWrite, DidWrite, SkippedEqual, SkippedDueToFailure }; + + FileWriter() = default; + + ~FileWriter() + { + if (!silentWarnings) { + for (const QString &w : std::as_const(warnings)) + qWarning() << w; + } + if (shouldRemoveTempFile) + tempFile.remove(); + } + + Status write(const QString &targetFile, function_ref<bool(QTextStream &)> write, int nBk = 2); + + bool shouldRemoveTempFile = false; + bool silentWarnings = false; + Status status = Status::SkippedDueToFailure; + QString targetFile; + QFile tempFile; + QStringList newBkFiles; + QStringList warnings; + +private: + Q_DISABLE_COPY_MOVE(FileWriter) +}; + +} // namespace Dom +} // namespace QQmlJS +QT_END_NAMESPACE +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomfunctionref_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomfunctionref_p.h new file mode 100644 index 0000000000000000000000000000000000000000..75d41a63261e1cefa9b1cb80706bf65279da9087 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomfunctionref_p.h @@ -0,0 +1,60 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMFUNCTIONREF_P_H +#define QQMLDOMFUNCTIONREF_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/private/qglobal_p.h> + +#if !defined(Q_CC_MSVC) || Q_CC_MSVC >= 1930 +#include <QtCore/qxpfunctional.h> + +QT_BEGIN_NAMESPACE +namespace QQmlJS { +namespace Dom { +template <typename T> +using function_ref = qxp::function_ref<T>; +} // namespace Dom +} // namespace QQmlJS +QT_END_NAMESPACE + +#else + +#include <functional> + +QT_BEGIN_NAMESPACE +namespace QQmlJS { +namespace Dom { +namespace _detail { +template <typename T> +struct function_ref_helper { using type = std::function<T>; }; +// std::function doesn't grok the const in <int(int) const>, so remove: +template <typename R, typename...Args> +struct function_ref_helper<R(Args...) const> : function_ref_helper<R(Args...)> {}; +// std::function doesn't grok the noexcept in <int(int) noexcept>, so remove: +template <typename R, typename...Args> +struct function_ref_helper<R(Args...) noexcept> : function_ref_helper<R(Args...)> {}; +// and both together: +template <typename R, typename...Args> +struct function_ref_helper<R(Args...) const noexcept> : function_ref_helper<R(Args...)> {}; +} // namespace _detail +template <typename T> +using function_ref = const typename _detail::function_ref_helper<T>::type &; +} // namespace Dom +} // namespace QQmlJS +QT_END_NAMESPACE + +#endif + +#endif // QQMLDOMFUNCTIONREF_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomindentinglinewriter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomindentinglinewriter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..322048a496333404ced2cd30305e20685ab38852 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomindentinglinewriter_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMINDENTIGLINEWRITER_P +#define QQMLDOMINDENTIGLINEWRITER_P + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldomcodeformatter_p.h" +#include "qqmldomlinewriter_p.h" + +#include <QtQml/private/qqmljssourcelocation_p.h> +#include <QtCore/QAtomicInt> +#include <functional> + +QT_BEGIN_NAMESPACE +namespace QQmlJS { +namespace Dom { + +QMLDOM_EXPORT class IndentingLineWriter : public LineWriter +{ + Q_GADGET +public: + IndentingLineWriter(const SinkF &innerSink, const QString &fileName, + const LineWriterOptions &options = LineWriterOptions(), + const FormatTextStatus &initialStatus = FormatTextStatus::initialStatus(), + int lineNr = 0, int columnNr = 0, int utf16Offset = 0, + QString currentLine = QString()) + : LineWriter(innerSink, fileName, options, lineNr, columnNr, utf16Offset, currentLine), + m_preCachedStatus(initialStatus) + { + } + void reindentAndSplit(const QString &eol, bool eof = false) override; + FormatPartialStatus &fStatus(); + + void lineChanged() override { m_fStatusValid = false; } + void willCommit() override; + bool reindent() const { return m_reindent; } + void setReindent(bool v) { m_reindent = v; } + +private: + Q_DISABLE_COPY_MOVE(IndentingLineWriter) +protected: + FormatTextStatus m_preCachedStatus; + bool m_fStatusValid = false; + FormatPartialStatus m_fStatus; +}; + +} // namespace Dom +} // namespace QQmlJS +QT_END_NAMESPACE +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomitem_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomitem_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e4b8c9926c7eab5e960075682c93e050f184d4a9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomitem_p.h @@ -0,0 +1,2341 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMLDOMITEM_H +#define QMLDOMITEM_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldom_fwd_p.h" +#include "qqmldom_utils_p.h" +#include "qqmldomconstants_p.h" +#include "qqmldomstringdumper_p.h" +#include "qqmldompath_p.h" +#include "qqmldomerrormessage_p.h" +#include "qqmldomfunctionref_p.h" +#include "qqmldomfilewriter_p.h" +#include "qqmldomlinewriter_p.h" +#include "qqmldomfieldfilter_p.h" + +#include <QtCore/QMap> +#include <QtCore/QMultiMap> +#include <QtCore/QSet> +#include <QtCore/QString> +#include <QtCore/QStringView> +#include <QtCore/QDebug> +#include <QtCore/QDateTime> +#include <QtCore/QMutex> +#include <QtCore/QCborValue> +#include <QtCore/QTimeZone> +#include <QtQml/private/qqmljssourcelocation_p.h> +#include <QtQmlCompiler/private/qqmljsscope_p.h> + +#include <memory> +#include <typeinfo> +#include <utility> +#include <type_traits> +#include <variant> +#include <optional> +#include <cstddef> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(writeOutLog); + +namespace QQmlJS { +// we didn't have enough 'O's to properly name everything... +namespace Dom { + +class Path; + +constexpr bool domTypeIsObjWrap(DomType k); +constexpr bool domTypeIsValueWrap(DomType k); +constexpr bool domTypeIsDomElement(DomType); +constexpr bool domTypeIsOwningItem(DomType); +constexpr bool domTypeIsUnattachedOwningItem(DomType); +constexpr bool domTypeIsScriptElement(DomType); +QMLDOM_EXPORT bool domTypeIsExternalItem(DomType k); +QMLDOM_EXPORT bool domTypeIsTopItem(DomType k); +QMLDOM_EXPORT bool domTypeIsContainer(DomType k); +constexpr bool domTypeCanBeInline(DomType k) +{ + switch (k) { + case DomType::Empty: + case DomType::Map: + case DomType::List: + case DomType::ListP: + case DomType::ConstantData: + case DomType::SimpleObjectWrap: + case DomType::ScriptElementWrap: + case DomType::Reference: + return true; + default: + return false; + } +} +QMLDOM_EXPORT bool domTypeIsScope(DomType k); + +QMLDOM_EXPORT QMap<DomType,QString> domTypeToStringMap(); +QMLDOM_EXPORT QString domTypeToString(DomType k); +QMLDOM_EXPORT QMap<DomKind, QString> domKindToStringMap(); +QMLDOM_EXPORT QString domKindToString(DomKind k); + +inline bool noFilter(const DomItem &, const PathEls::PathComponent &, const DomItem &) +{ + return true; +} + +using DirectVisitor = function_ref<bool(const PathEls::PathComponent &, function_ref<DomItem()>)>; +// using DirectVisitor = function_ref<bool(Path, const DomItem &)>; + +namespace { +template<typename T> +struct IsMultiMap : std::false_type +{ +}; + +template<typename Key, typename T> +struct IsMultiMap<QMultiMap<Key, T>> : std::true_type +{ +}; + +template<typename T> +struct IsMap : std::false_type +{ +}; + +template<typename Key, typename T> +struct IsMap<QMap<Key, T>> : std::true_type +{ +}; + +template<typename... Ts> +using void_t = void; + +template<typename T, typename = void> +struct IsDomObject : std::false_type +{ +}; + +template<typename T> +struct IsDomObject<T, void_t<decltype(T::kindValue)>> : std::true_type +{ +}; + +template<typename T, typename = void> +struct IsInlineDom : std::false_type +{ +}; + +template<typename T> +struct IsInlineDom<T, void_t<decltype(T::kindValue)>> + : std::integral_constant<bool, domTypeCanBeInline(T::kindValue)> +{ +}; + +template<typename T> +struct IsInlineDom<T *, void_t<decltype(T::kindValue)>> : std::true_type +{ +}; + +template<typename T> +struct IsInlineDom<std::shared_ptr<T>, void_t<decltype(T::kindValue)>> : std::true_type +{ +}; + +template<typename T> +struct IsSharedPointerToDomObject : std::false_type +{ +}; + +template<typename T> +struct IsSharedPointerToDomObject<std::shared_ptr<T>> : IsDomObject<T> +{ +}; + +template<typename T, typename = void> +struct IsList : std::false_type +{ +}; + +template<typename T> +struct IsList<T, void_t<typename T::value_type>> : std::true_type +{ +}; + +} + +template<typename T> +union SubclassStorage { + int i; + T lp; + + // TODO: these are extremely nasty. What is this int doing in here? + T *data() { return reinterpret_cast<T *>(this); } + const T *data() const { return reinterpret_cast<const T *>(this); } + + SubclassStorage() { } + SubclassStorage(T &&el) { el.moveTo(data()); } + SubclassStorage(const T *el) { el->copyTo(data()); } + SubclassStorage(const SubclassStorage &o) : SubclassStorage(o.data()) { } + SubclassStorage(const SubclassStorage &&o) : SubclassStorage(o.data()) { } + SubclassStorage &operator=(const SubclassStorage &o) + { + data()->~T(); + o.data()->copyTo(data()); + return *this; + } + ~SubclassStorage() { data()->~T(); } +}; + +class QMLDOM_EXPORT DomBase +{ +public: + using FilterT = function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)>; + + virtual ~DomBase() = default; + + DomBase *domBase() { return this; } + const DomBase *domBase() const { return this; } + + // minimal overload set: + virtual DomType kind() const = 0; + virtual DomKind domKind() const; + virtual Path pathFromOwner(const DomItem &self) const = 0; + virtual Path canonicalPath(const DomItem &self) const = 0; + virtual bool + iterateDirectSubpaths(const DomItem &self, + DirectVisitor visitor) const = 0; // iterates the *direct* subpaths, returns + // false if a quick end was requested + + bool iterateDirectSubpathsConst(const DomItem &self, DirectVisitor) + const; // iterates the *direct* subpaths, returns false if a quick end was requested + + virtual DomItem containingObject( + const DomItem &self) const; // the DomItem corresponding to the canonicalSource source + virtual void dump(const DomItem &, const Sink &sink, int indent, FilterT filter) const; + virtual quintptr id() const; + QString typeName() const; + + virtual QList<QString> fields(const DomItem &self) const; + virtual DomItem field(const DomItem &self, QStringView name) const; + + virtual index_type indexes(const DomItem &self) const; + virtual DomItem index(const DomItem &self, index_type index) const; + + virtual QSet<QString> const keys(const DomItem &self) const; + virtual DomItem key(const DomItem &self, const QString &name) const; + + virtual QString canonicalFilePath(const DomItem &self) const; + + virtual void writeOut(const DomItem &self, OutWriter &lw) const; + + virtual QCborValue value() const { + return QCborValue(); + } +}; + +inline DomKind kind2domKind(DomType k) +{ + switch (k) { + case DomType::Empty: + return DomKind::Empty; + case DomType::List: + case DomType::ListP: + return DomKind::List; + case DomType::Map: + return DomKind::Map; + case DomType::ConstantData: + return DomKind::Value; + default: + return DomKind::Object; + } +} + +class QMLDOM_EXPORT Empty final : public DomBase +{ +public: + constexpr static DomType kindValue = DomType::Empty; + DomType kind() const override { return kindValue; } + + Empty *operator->() { return this; } + const Empty *operator->() const { return this; } + Empty &operator*() { return *this; } + const Empty &operator*() const { return *this; } + + Empty(); + quintptr id() const override { return ~quintptr(0); } + Path pathFromOwner(const DomItem &self) const override; + Path canonicalPath(const DomItem &self) const override; + DomItem containingObject(const DomItem &self) const override; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + void dump(const DomItem &, const Sink &s, int indent, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter) + const override; +}; + +class QMLDOM_EXPORT DomElement: public DomBase { +protected: + DomElement& operator=(const DomElement&) = default; +public: + DomElement(const Path &pathFromOwner = Path()); + DomElement(const DomElement &o) = default; + Path pathFromOwner(const DomItem &self) const override; + Path pathFromOwner() const { return m_pathFromOwner; } + Path canonicalPath(const DomItem &self) const override; + DomItem containingObject(const DomItem &self) const override; + virtual void updatePathFromOwner(const Path &newPath); + +private: + Path m_pathFromOwner; +}; + +class QMLDOM_EXPORT Map final : public DomElement +{ +public: + constexpr static DomType kindValue = DomType::Map; + DomType kind() const override { return kindValue; } + + Map *operator->() { return this; } + const Map *operator->() const { return this; } + Map &operator*() { return *this; } + const Map &operator*() const { return *this; } + + using LookupFunction = std::function<DomItem(const DomItem &, QString)>; + using Keys = std::function<QSet<QString>(const DomItem &)>; + Map(const Path &pathFromOwner, const LookupFunction &lookup, + const Keys &keys, const QString &targetType); + quintptr id() const override; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + QSet<QString> const keys(const DomItem &self) const override; + DomItem key(const DomItem &self, const QString &name) const override; + + template<typename T> + static Map fromMultiMapRef(const Path &pathFromOwner, const QMultiMap<QString, T> &mmap); + template<typename T> + static Map fromMultiMap(const Path &pathFromOwner, const QMultiMap<QString, T> &mmap); + template<typename T> + static Map + fromMapRef( + const Path &pathFromOwner, const QMap<QString, T> &mmap, + const std::function<DomItem(const DomItem &, const PathEls::PathComponent &, const T &)> &elWrapper); + + template<typename T> + static Map fromFileRegionMap( + const Path &pathFromOwner, const QMap<FileLocationRegion, T> &map); + template<typename T> + static Map fromFileRegionListMap( + const Path &pathFromOwner, const QMap<FileLocationRegion, QList<T>> &map); + +private: + template<typename MapT> + static QSet<QString> fileRegionKeysFromMap(const MapT &map); + LookupFunction m_lookup; + Keys m_keys; + QString m_targetType; +}; + +class QMLDOM_EXPORT List final : public DomElement +{ +public: + constexpr static DomType kindValue = DomType::List; + DomType kind() const override { return kindValue; } + + List *operator->() { return this; } + const List *operator->() const { return this; } + List &operator*() { return *this; } + const List &operator*() const { return *this; } + + using LookupFunction = std::function<DomItem(const DomItem &, index_type)>; + using Length = std::function<index_type(const DomItem &)>; + using IteratorFunction = + std::function<bool(const DomItem &, function_ref<bool(index_type, function_ref<DomItem()>)>)>; + + List(const Path &pathFromOwner, const LookupFunction &lookup, const Length &length, + const IteratorFunction &iterator, const QString &elType); + quintptr id() const override; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + void + dump(const DomItem &, const Sink &s, int indent, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)>) const override; + index_type indexes(const DomItem &self) const override; + DomItem index(const DomItem &self, index_type index) const override; + + template<typename T> + static List + fromQList(const Path &pathFromOwner, const QList<T> &list, + const std::function<DomItem(const DomItem &, const PathEls::PathComponent &, const T &)> &elWrapper, + ListOptions options = ListOptions::Normal); + template<typename T> + static List + fromQListRef(const Path &pathFromOwner, const QList<T> &list, + const std::function<DomItem(const DomItem &, const PathEls::PathComponent &, const T &)> &elWrapper, + ListOptions options = ListOptions::Normal); + void writeOut(const DomItem &self, OutWriter &ow, bool compact) const; + void writeOut(const DomItem &self, OutWriter &ow) const override { writeOut(self, ow, true); } + +private: + LookupFunction m_lookup; + Length m_length; + IteratorFunction m_iterator; + QString m_elType; +}; + +class QMLDOM_EXPORT ListPBase : public DomElement +{ +public: + constexpr static DomType kindValue = DomType::ListP; + DomType kind() const override { return kindValue; } + + ListPBase(const Path &pathFromOwner, const QList<const void *> &pList, const QString &elType) + : DomElement(pathFromOwner), m_pList(pList), m_elType(elType) + { + } + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor v) const override; + virtual void copyTo(ListPBase *) const { Q_ASSERT(false); }; + virtual void moveTo(ListPBase *) const { Q_ASSERT(false); }; + quintptr id() const override { return quintptr(0); } + index_type indexes(const DomItem &) const override { return index_type(m_pList.size()); } + void writeOut(const DomItem &self, OutWriter &ow, bool compact) const; + void writeOut(const DomItem &self, OutWriter &ow) const override { writeOut(self, ow, true); } + +protected: + QList<const void *> m_pList; + QString m_elType; +}; + +template<typename T> +class ListPT final : public ListPBase +{ +public: + constexpr static DomType kindValue = DomType::ListP; + + ListPT(const Path &pathFromOwner, const QList<T *> &pList, const QString &elType = QString(), + ListOptions options = ListOptions::Normal) + : ListPBase(pathFromOwner, {}, + (elType.isEmpty() ? QLatin1String(typeid(T).name()) : elType)) + { + static_assert(sizeof(ListPBase) == sizeof(ListPT), + "ListPT does not have the same size as ListPBase"); + static_assert(alignof(ListPBase) == alignof(ListPT), + "ListPT does not have the same size as ListPBase"); + m_pList.reserve(pList.size()); + if (options == ListOptions::Normal) { + for (const void *p : pList) + m_pList.append(p); + } else if (options == ListOptions::Reverse) { + for (qsizetype i = pList.size(); i-- != 0;) + // probably writing in reverse and reading sequentially would be better + m_pList.append(pList.at(i)); + } else { + Q_ASSERT(false); + } + } + void copyTo(ListPBase *t) const override { new (t) ListPT(*this); } + void moveTo(ListPBase *t) const override { new (t) ListPT(std::move(*this)); } + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor v) const override; + + DomItem index(const DomItem &self, index_type index) const override; +}; + +class QMLDOM_EXPORT ListP +{ +public: + constexpr static DomType kindValue = DomType::ListP; + template<typename T> + ListP(const Path &pathFromOwner, const QList<T *> &pList, const QString &elType = QString(), + ListOptions options = ListOptions::Normal) + : list(ListPT<T>(pathFromOwner, pList, elType, options)) + { + } + ListP() = delete; + + ListPBase *operator->() { return list.data(); } + const ListPBase *operator->() const { return list.data(); } + ListPBase &operator*() { return *list.data(); } + const ListPBase &operator*() const { return *list.data(); } + +private: + SubclassStorage<ListPBase> list; +}; + +class QMLDOM_EXPORT ConstantData final : public DomElement +{ +public: + constexpr static DomType kindValue = DomType::ConstantData; + DomType kind() const override { return kindValue; } + + enum class Options { + MapIsMap, + FirstMapIsFields + }; + + ConstantData *operator->() { return this; } + const ConstantData *operator->() const { return this; } + ConstantData &operator*() { return *this; } + const ConstantData &operator*() const { return *this; } + + ConstantData(const Path &pathFromOwner, const QCborValue &value, + Options options = Options::MapIsMap); + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + quintptr id() const override; + DomKind domKind() const override; + QCborValue value() const override { return m_value; } + Options options() const { return m_options; } +private: + QCborValue m_value; + Options m_options; +}; + +class QMLDOM_EXPORT SimpleObjectWrapBase : public DomElement +{ +public: + constexpr static DomType kindValue = DomType::SimpleObjectWrap; + DomType kind() const final override { return m_kind; } + + quintptr id() const final override { return m_id; } + DomKind domKind() const final override { return m_domKind; } + + template <typename T> + T const *as() const + { + if (m_options & SimpleWrapOption::ValueType) { + if (m_value.metaType() == QMetaType::fromType<T>()) + return static_cast<const T *>(m_value.constData()); + return nullptr; + } else { + return m_value.value<const T *>(); + } + } + + SimpleObjectWrapBase() = delete; + virtual void copyTo(SimpleObjectWrapBase *) const { Q_ASSERT(false); } + virtual void moveTo(SimpleObjectWrapBase *) const { Q_ASSERT(false); } + bool iterateDirectSubpaths(const DomItem &, DirectVisitor) const override + { + Q_ASSERT(false); + return true; + } + +protected: + friend class TestDomItem; + SimpleObjectWrapBase(const Path &pathFromOwner, const QVariant &value, quintptr idValue, + DomType kind = kindValue, + SimpleWrapOptions options = SimpleWrapOption::None) + : DomElement(pathFromOwner), + m_kind(kind), + m_domKind(kind2domKind(kind)), + m_value(value), + m_id(idValue), + m_options(options) + { + } + + DomType m_kind; + DomKind m_domKind; + QVariant m_value; + quintptr m_id; + SimpleWrapOptions m_options; +}; + +template<typename T> +class SimpleObjectWrapT final : public SimpleObjectWrapBase +{ +public: + constexpr static DomType kindValue = DomType::SimpleObjectWrap; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override + { + return asT()->iterateDirectSubpaths(self, visitor); + } + + void writeOut(const DomItem &self, OutWriter &lw) const override; + + const T *asT() const + { + if constexpr (domTypeIsValueWrap(T::kindValue)) { + if (m_value.metaType() == QMetaType::fromType<T>()) + return static_cast<const T *>(m_value.constData()); + return nullptr; + } else if constexpr (domTypeIsObjWrap(T::kindValue)) { + return m_value.value<const T *>(); + } else { + // need dependent static assert to not unconditially trigger + static_assert(!std::is_same_v<T, T>, "wrapping of unexpected type"); + return nullptr; // necessary to avoid warnings on INTEGRITY + } + } + + void copyTo(SimpleObjectWrapBase *target) const override + { + static_assert(sizeof(SimpleObjectWrapBase) == sizeof(SimpleObjectWrapT), + "Size mismatch in SimpleObjectWrapT"); + static_assert(alignof(SimpleObjectWrapBase) == alignof(SimpleObjectWrapT), + "Size mismatch in SimpleObjectWrapT"); + new (target) SimpleObjectWrapT(*this); + } + + void moveTo(SimpleObjectWrapBase *target) const override + { + static_assert(sizeof(SimpleObjectWrapBase) == sizeof(SimpleObjectWrapT), + "Size mismatch in SimpleObjectWrapT"); + static_assert(alignof(SimpleObjectWrapBase) == alignof(SimpleObjectWrapT), + "Size mismatch in SimpleObjectWrapT"); + new (target) SimpleObjectWrapT(std::move(*this)); + } + + SimpleObjectWrapT(const Path &pathFromOwner, const QVariant &v, + quintptr idValue, SimpleWrapOptions o) + : SimpleObjectWrapBase(pathFromOwner, v, idValue, T::kindValue, o) + { + Q_ASSERT(domTypeIsValueWrap(T::kindValue) == bool(o & SimpleWrapOption::ValueType)); + } +}; + +class QMLDOM_EXPORT SimpleObjectWrap +{ +public: + constexpr static DomType kindValue = DomType::SimpleObjectWrap; + + SimpleObjectWrapBase *operator->() { return wrap.data(); } + const SimpleObjectWrapBase *operator->() const { return wrap.data(); } + SimpleObjectWrapBase &operator*() { return *wrap.data(); } + const SimpleObjectWrapBase &operator*() const { return *wrap.data(); } + + template<typename T> + static SimpleObjectWrap fromObjectRef(const Path &pathFromOwner, T &value) + { + return SimpleObjectWrap(pathFromOwner, value); + } + SimpleObjectWrap() = delete; + +private: + template<typename T> + SimpleObjectWrap(const Path &pathFromOwner, T &value) + { + using BaseT = std::decay_t<T>; + if constexpr (domTypeIsObjWrap(BaseT::kindValue)) { + new (wrap.data()) SimpleObjectWrapT<BaseT>(pathFromOwner, QVariant::fromValue(&value), + quintptr(&value), SimpleWrapOption::None); + } else if constexpr (domTypeIsValueWrap(BaseT::kindValue)) { + new (wrap.data()) SimpleObjectWrapT<BaseT>(pathFromOwner, QVariant::fromValue(value), + quintptr(0), SimpleWrapOption::ValueType); + } else { + qCWarning(domLog) << "Unexpected object to wrap in SimpleObjectWrap: " + << domTypeToString(BaseT::kindValue); + Q_ASSERT_X(false, "SimpleObjectWrap", + "simple wrap of unexpected object"); // allow? (mocks for testing,...) + new (wrap.data()) + SimpleObjectWrapT<BaseT>(pathFromOwner, nullptr, 0, SimpleWrapOption::None); + } + } + SubclassStorage<SimpleObjectWrapBase> wrap; +}; + +class QMLDOM_EXPORT Reference final : public DomElement +{ + Q_GADGET +public: + constexpr static DomType kindValue = DomType::Reference; + DomType kind() const override { return kindValue; } + + Reference *operator->() { return this; } + const Reference *operator->() const { return this; } + Reference &operator*() { return *this; } + const Reference &operator*() const { return *this; } + + bool shouldCache() const; + Reference(const Path &referredObject = Path(), const Path &pathFromOwner = Path(), + const SourceLocation &loc = SourceLocation()); + quintptr id() const override; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + DomItem field(const DomItem &self, QStringView name) const override; + QList<QString> fields(const DomItem &self) const override; + index_type indexes(const DomItem &) const override { return 0; } + DomItem index(const DomItem &, index_type) const override; + QSet<QString> const keys(const DomItem &) const override { return {}; } + DomItem key(const DomItem &, const QString &) const override; + + DomItem get(const DomItem &self, const ErrorHandler &h = nullptr, + QList<Path> *visitedRefs = nullptr) const; + QList<DomItem> getAll(const DomItem &self, const ErrorHandler &h = nullptr, + QList<Path> *visitedRefs = nullptr) const; + + Path referredObjectPath; +}; + +template<typename Info> +class AttachedInfoT; +class FileLocations; + +/*! + \internal + \brief A common base class for all the script elements. + + This marker class allows to use all the script elements as a ScriptElement*, using virtual + dispatch. For now, it does not add any extra functionality, compared to a DomElement, but allows + to forbid DomElement* at the places where only script elements are required. + */ +// TODO: do we need another marker struct like this one to differentiate expressions from +// statements? This would allow to avoid mismatchs between script expressions and script statements, +// using type-safety. +struct ScriptElement : public DomElement +{ + template<typename T> + using PointerType = std::shared_ptr<T>; + + using DomElement::DomElement; + virtual void createFileLocations( + const std::shared_ptr<AttachedInfoT<FileLocations>> &fileLocationOfOwner) = 0; + + QQmlJSScope::ConstPtr semanticScope(); + void setSemanticScope(const QQmlJSScope::ConstPtr &scope); + +private: + QQmlJSScope::ConstPtr m_scope; +}; + +/*! + \internal + \brief Use this to contain any script element. + */ +class ScriptElementVariant +{ +private: + template<typename... T> + using VariantOfPointer = std::variant<ScriptElement::PointerType<T>...>; + + template<typename T, typename Variant> + struct TypeIsInVariant; + + template<typename T, typename... Ts> + struct TypeIsInVariant<T, std::variant<Ts...>> : public std::disjunction<std::is_same<T, Ts>...> + { + }; + +public: + using ScriptElementT = + VariantOfPointer<ScriptElements::BlockStatement, ScriptElements::IdentifierExpression, + ScriptElements::ForStatement, ScriptElements::BinaryExpression, + ScriptElements::VariableDeclarationEntry, ScriptElements::Literal, + ScriptElements::IfStatement, ScriptElements::GenericScriptElement, + ScriptElements::VariableDeclaration, ScriptElements::ReturnStatement>; + + template<typename T> + static ScriptElementVariant fromElement(const T &element) + { + static_assert(TypeIsInVariant<T, ScriptElementT>::value, + "Cannot construct ScriptElementVariant from T, as it is missing from the " + "ScriptElementT."); + ScriptElementVariant p; + p.m_data = element; + return p; + } + + ScriptElement::PointerType<ScriptElement> base() const; + + operator bool() const { return m_data.has_value(); } + + template<typename F> + void visitConst(F &&visitor) const + { + if (m_data) + std::visit(std::forward<F>(visitor), *m_data); + } + + template<typename F> + void visit(F &&visitor) + { + if (m_data) + std::visit(std::forward<F>(visitor), *m_data); + } + std::optional<ScriptElementT> data() { return m_data; } + void setData(const ScriptElementT &data) { m_data = data; } + +private: + std::optional<ScriptElementT> m_data; +}; + +/*! + \internal + + To avoid cluttering the already unwieldy \l ElementT type below with all the types that the + different script elements can have, wrap them in an extra class. It will behave like an internal + Dom structure (e.g. like a List or a Map) and contain a pointer the the script element. + */ +class ScriptElementDomWrapper +{ +public: + ScriptElementDomWrapper(const ScriptElementVariant &element) : m_element(element) { } + + static constexpr DomType kindValue = DomType::ScriptElementWrap; + + DomBase *operator->() { return m_element.base().get(); } + const DomBase *operator->() const { return m_element.base().get(); } + DomBase &operator*() { return *m_element.base(); } + const DomBase &operator*() const { return *m_element.base(); } + + ScriptElementVariant element() const { return m_element; } + +private: + ScriptElementVariant m_element; +}; + +// TODO: create more "groups" to simplify this variant? Maybe into Internal, ScriptExpression, ??? +using ElementT = + std::variant< + ConstantData, + Empty, + List, + ListP, + Map, + Reference, + ScriptElementDomWrapper, + SimpleObjectWrap, + const AstComments *, + const AttachedInfo *, + const DomEnvironment *, + const DomUniverse *, + const EnumDecl *, + const ExternalItemInfoBase *, + const ExternalItemPairBase *, + const GlobalComponent *, + const GlobalScope *, + const JsFile *, + const JsResource *, + const LoadInfo *, + const MockObject *, + const MockOwner *, + const ModuleIndex *, + const ModuleScope *, + const QmlComponent *, + const QmlDirectory *, + const QmlFile *, + const QmlObject *, + const QmldirFile *, + const QmltypesComponent *, + const QmltypesFile *, + const ScriptExpression * + >; + +using TopT = std::variant< + std::monostate, + std::shared_ptr<DomEnvironment>, + std::shared_ptr<DomUniverse>>; + +using OwnerT = std::variant< + std::monostate, + std::shared_ptr<ModuleIndex>, + std::shared_ptr<MockOwner>, + std::shared_ptr<ExternalItemInfoBase>, + std::shared_ptr<ExternalItemPairBase>, + std::shared_ptr<QmlDirectory>, + std::shared_ptr<QmldirFile>, + std::shared_ptr<JsFile>, + std::shared_ptr<QmlFile>, + std::shared_ptr<QmltypesFile>, + std::shared_ptr<GlobalScope>, + std::shared_ptr<ScriptExpression>, + std::shared_ptr<AstComments>, + std::shared_ptr<LoadInfo>, + std::shared_ptr<AttachedInfo>, + std::shared_ptr<DomEnvironment>, + std::shared_ptr<DomUniverse>>; + +inline bool emptyChildrenVisitor(Path, const DomItem &, bool) +{ + return true; +} + +class MutableDomItem; + +class FileToLoad +{ +public: + struct InMemoryContents + { + QString data; + QDateTime date = QDateTime::currentDateTimeUtc(); + }; + + FileToLoad(const std::weak_ptr<DomEnvironment> &environment, const QString &canonicalPath, + const QString &logicalPath, const std::optional<InMemoryContents> &content); + FileToLoad() = default; + + static FileToLoad fromMemory(const std::weak_ptr<DomEnvironment> &environment, + const QString &path, const QString &data); + static FileToLoad fromFileSystem(const std::weak_ptr<DomEnvironment> &environment, + const QString &canonicalPath); + + std::weak_ptr<DomEnvironment> environment() const { return m_environment; } + QString canonicalPath() const { return m_canonicalPath; } + QString logicalPath() const { return m_logicalPath; } + void setCanonicalPath(const QString &canonicalPath) { m_canonicalPath = canonicalPath; } + void setLogicalPath(const QString &logicalPath) { m_logicalPath = logicalPath; } + std::optional<InMemoryContents> content() const { return m_content; } + +private: + std::weak_ptr<DomEnvironment> m_environment; + QString m_canonicalPath; + QString m_logicalPath; + std::optional<InMemoryContents> m_content; +}; + +class QMLDOM_EXPORT DomItem { + Q_DECLARE_TR_FUNCTIONS(DomItem); +public: + using Callback = function<void(const Path &, const DomItem &, const DomItem &)>; + + using InternalKind = DomType; + using Visitor = function_ref<bool(const Path &, const DomItem &)>; + using ChildrenVisitor = function_ref<bool(const Path &, const DomItem &, bool)>; + + static ErrorGroup domErrorGroup; + static ErrorGroups myErrors(); + static ErrorGroups myResolveErrors(); + static DomItem empty; + + enum class CopyOption { EnvConnected, EnvDisconnected }; + + template<typename F> + auto visitEl(F f) const + { + return std::visit(f, this->m_element); + } + + explicit operator bool() const { return m_kind != DomType::Empty; } + InternalKind internalKind() const { + return m_kind; + } + QString internalKindStr() const { return domTypeToString(internalKind()); } + DomKind domKind() const + { + if (m_kind == DomType::ConstantData) + return std::get<ConstantData>(m_element).domKind(); + else + return kind2domKind(m_kind); + } + + Path canonicalPath() const; + + DomItem filterUp(function_ref<bool(DomType k, const DomItem &)> filter, FilterUpOptions options) const; + DomItem containingObject() const; + DomItem container() const; + DomItem owner() const; + DomItem top() const; + DomItem environment() const; + DomItem universe() const; + DomItem containingFile() const; + DomItem containingScriptExpression() const; + DomItem goToFile(const QString &filePath) const; + DomItem goUp(int) const; + DomItem directParent() const; + + DomItem qmlObject(GoTo option = GoTo::Strict, + FilterUpOptions options = FilterUpOptions::ReturnOuter) const; + DomItem fileObject(GoTo option = GoTo::Strict) const; + DomItem rootQmlObject(GoTo option = GoTo::Strict) const; + DomItem globalScope() const; + DomItem component(GoTo option = GoTo::Strict) const; + DomItem scope(FilterUpOptions options = FilterUpOptions::ReturnOuter) const; + QQmlJSScope::ConstPtr nearestSemanticScope() const; + QQmlJSScope::ConstPtr semanticScope() const; + + // convenience getters + DomItem get(const ErrorHandler &h = nullptr, QList<Path> *visitedRefs = nullptr) const; + QList<DomItem> getAll(const ErrorHandler &h = nullptr, QList<Path> *visitedRefs = nullptr) const; + bool isOwningItem() const { return domTypeIsOwningItem(internalKind()); } + bool isExternalItem() const { return domTypeIsExternalItem(internalKind()); } + bool isTopItem() const { return domTypeIsTopItem(internalKind()); } + bool isContainer() const { return domTypeIsContainer(internalKind()); } + bool isScope() const { return domTypeIsScope(internalKind()); } + bool isCanonicalChild(const DomItem &child) const; + bool hasAnnotations() const; + QString name() const { return field(Fields::name).value().toString(); } + DomItem pragmas() const { return field(Fields::pragmas); } + DomItem ids() const { return field(Fields::ids); } + QString idStr() const { return field(Fields::idStr).value().toString(); } + DomItem propertyInfos() const { return field(Fields::propertyInfos); } + PropertyInfo propertyInfoWithName(const QString &name) const; + QSet<QString> propertyInfoNames() const; + DomItem propertyDefs() const { return field(Fields::propertyDefs); } + DomItem bindings() const { return field(Fields::bindings); } + DomItem methods() const { return field(Fields::methods); } + DomItem enumerations() const { return field(Fields::enumerations); } + DomItem children() const { return field(Fields::children); } + DomItem child(index_type i) const { return field(Fields::children).index(i); } + DomItem annotations() const + { + if (hasAnnotations()) + return field(Fields::annotations); + else + return DomItem(); + } + + bool resolve(const Path &path, Visitor visitor, const ErrorHandler &errorHandler, + ResolveOptions options = ResolveOption::None, const Path &fullPath = Path(), + QList<Path> *visitedRefs = nullptr) const; + + DomItem operator[](const Path &path) const; + DomItem operator[](QStringView component) const; + DomItem operator[](const QString &component) const; + DomItem operator[](const char16_t *component) const + { + return (*this)[QStringView(component)]; + } // to avoid clash with stupid builtin ptrdiff_t[DomItem&], coming from C + DomItem operator[](index_type i) const { return index(i); } + DomItem operator[](int i) const { return index(i); } + index_type size() const { return indexes() + keys().size(); } + index_type length() const { return size(); } + + DomItem path(const Path &p, const ErrorHandler &h = &defaultErrorHandler) const; + DomItem path(const QString &p, const ErrorHandler &h = &defaultErrorHandler) const; + DomItem path(QStringView p, const ErrorHandler &h = &defaultErrorHandler) const; + + QList<QString> fields() const; + DomItem field(QStringView name) const; + + index_type indexes() const; + DomItem index(index_type) const; + bool visitIndexes(function_ref<bool(const DomItem &)> visitor) const; + + QSet<QString> keys() const; + QStringList sortedKeys() const; + DomItem key(const QString &name) const; + DomItem key(QStringView name) const { return key(name.toString()); } + bool visitKeys(function_ref<bool(const QString &, const DomItem &)> visitor) const; + + QList<DomItem> values() const; + void writeOutPre(OutWriter &lw) const; + void writeOut(OutWriter &lw) const; + void writeOutPost(OutWriter &lw) const; + bool writeOutForFile(OutWriter &ow, WriteOutChecks extraChecks) const; + bool writeOut(const QString &path, int nBackups = 2, + const LineWriterOptions &opt = LineWriterOptions(), FileWriter *fw = nullptr, + WriteOutChecks extraChecks = WriteOutCheck::Default) const; + + bool visitTree(const Path &basePath, ChildrenVisitor visitor, + VisitOptions options = VisitOption::Default, + ChildrenVisitor openingVisitor = emptyChildrenVisitor, + ChildrenVisitor closingVisitor = emptyChildrenVisitor, + const FieldFilter &filter = FieldFilter::noFilter()) const; + bool visitPrototypeChain(function_ref<bool(const DomItem &)> visitor, + VisitPrototypesOptions options = VisitPrototypesOption::Normal, + const ErrorHandler &h = nullptr, QSet<quintptr> *visited = nullptr, + QList<Path> *visitedRefs = nullptr) const; + bool visitDirectAccessibleScopes(function_ref<bool(const DomItem &)> visitor, + VisitPrototypesOptions options = VisitPrototypesOption::Normal, + const ErrorHandler &h = nullptr, QSet<quintptr> *visited = nullptr, + QList<Path> *visitedRefs = nullptr) const; + bool + visitStaticTypePrototypeChains(function_ref<bool(const DomItem &)> visitor, + VisitPrototypesOptions options = VisitPrototypesOption::Normal, + const ErrorHandler &h = nullptr, QSet<quintptr> *visited = nullptr, + QList<Path> *visitedRefs = nullptr) const; + + bool visitUp(function_ref<bool(const DomItem &)> visitor) const; + bool visitScopeChain( + function_ref<bool(const DomItem &)> visitor, LookupOptions = LookupOption::Normal, + const ErrorHandler &h = nullptr, QSet<quintptr> *visited = nullptr, + QList<Path> *visitedRefs = nullptr) const; + bool visitLocalSymbolsNamed( + const QString &name, function_ref<bool(const DomItem &)> visitor) const; + bool visitLookup1( + const QString &symbolName, function_ref<bool(const DomItem &)> visitor, + LookupOptions = LookupOption::Normal, const ErrorHandler &h = nullptr, + QSet<quintptr> *visited = nullptr, QList<Path> *visitedRefs = nullptr) const; + bool visitLookup( + const QString &symbolName, function_ref<bool(const DomItem &)> visitor, + LookupType type = LookupType::Symbol, LookupOptions = LookupOption::Normal, + const ErrorHandler &errorHandler = nullptr, QSet<quintptr> *visited = nullptr, + QList<Path> *visitedRefs = nullptr) const; + bool visitSubSymbolsNamed( + const QString &name, function_ref<bool(const DomItem &)> visitor) const; + DomItem proceedToScope( + const ErrorHandler &h = nullptr, QList<Path> *visitedRefs = nullptr) const; + QList<DomItem> lookup( + const QString &symbolName, LookupType type = LookupType::Symbol, + LookupOptions = LookupOption::Normal, const ErrorHandler &errorHandler = nullptr) const; + DomItem lookupFirst( + const QString &symbolName, LookupType type = LookupType::Symbol, + LookupOptions = LookupOption::Normal, const ErrorHandler &errorHandler = nullptr) const; + + quintptr id() const; + Path pathFromOwner() const; + QString canonicalFilePath() const; + DomItem fileLocationsTree() const; + DomItem fileLocations() const; + MutableDomItem makeCopy(CopyOption option = CopyOption::EnvConnected) const; + bool commitToBase(const std::shared_ptr<DomEnvironment> &validPtr = nullptr) const; + DomItem refreshed() const { return top().path(canonicalPath()); } + QCborValue value() const; + + void dumpPtr(const Sink &sink) const; + void dump(const Sink &, int indent = 0, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter = + noFilter) const; + FileWriter::Status + dump(const QString &path, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter = noFilter, + int nBackups = 2, int indent = 0, FileWriter *fw = nullptr) const; + QString toString() const; + + // OwnigItem elements + int derivedFrom() const; + int revision() const; + QDateTime createdAt() const; + QDateTime frozenAt() const; + QDateTime lastDataUpdateAt() const; + + void addError(ErrorMessage &&msg) const; + ErrorHandler errorHandler() const; + void clearErrors(const ErrorGroups &groups = ErrorGroups({}), bool iterate = true) const; + // return false if a quick exit was requested + bool iterateErrors( + function_ref<bool (const DomItem &, const ErrorMessage &)> visitor, bool iterate, + Path inPath = Path()) const; + + bool iterateSubOwners(function_ref<bool(const DomItem &owner)> visitor) const; + bool iterateDirectSubpaths(DirectVisitor v) const; + + template<typename T> + DomItem subDataItem(const PathEls::PathComponent &c, const T &value, + ConstantData::Options options = ConstantData::Options::MapIsMap) const; + template<typename T> + DomItem subDataItemField(QStringView f, const T &value, + ConstantData::Options options = ConstantData::Options::MapIsMap) const + { + return subDataItem(PathEls::Field(f), value, options); + } + template<typename T> + DomItem subValueItem(const PathEls::PathComponent &c, const T &value, + ConstantData::Options options = ConstantData::Options::MapIsMap) const; + template<typename T> + bool dvValue(DirectVisitor visitor, const PathEls::PathComponent &c, const T &value, + ConstantData::Options options = ConstantData::Options::MapIsMap) const; + template<typename T> + bool dvValueField(DirectVisitor visitor, QStringView f, const T &value, + ConstantData::Options options = ConstantData::Options::MapIsMap) const + { + return this->dvValue<T>(std::move(visitor), PathEls::Field(f), value, options); + } + template<typename F> + bool dvValueLazy(DirectVisitor visitor, const PathEls::PathComponent &c, F valueF, + ConstantData::Options options = ConstantData::Options::MapIsMap) const; + template<typename F> + bool dvValueLazyField(DirectVisitor visitor, QStringView f, F valueF, + ConstantData::Options options = ConstantData::Options::MapIsMap) const + { + return this->dvValueLazy(std::move(visitor), PathEls::Field(f), valueF, options); + } + DomItem subLocationItem(const PathEls::PathComponent &c, SourceLocation loc) const + { + return this->subDataItem(c, sourceLocationToQCborValue(loc)); + } + // bool dvSubReference(DirectVisitor visitor, const PathEls::PathComponent &c, Path + // referencedObject); + DomItem subReferencesItem(const PathEls::PathComponent &c, const QList<Path> &paths) const; + DomItem subReferenceItem(const PathEls::PathComponent &c, const Path &referencedObject) const; + bool dvReference(DirectVisitor visitor, const PathEls::PathComponent &c, const Path &referencedObject) const + { + return dvItem(std::move(visitor), c, [c, this, referencedObject]() { + return this->subReferenceItem(c, referencedObject); + }); + } + bool dvReferences( + DirectVisitor visitor, const PathEls::PathComponent &c, const QList<Path> &paths) const + { + return dvItem(std::move(visitor), c, [c, this, paths]() { + return this->subReferencesItem(c, paths); + }); + } + bool dvReferenceField(DirectVisitor visitor, QStringView f, const Path &referencedObject) const + { + return dvReference(std::move(visitor), PathEls::Field(f), referencedObject); + } + bool dvReferencesField(DirectVisitor visitor, QStringView f, const QList<Path> &paths) const + { + return dvReferences(std::move(visitor), PathEls::Field(f), paths); + } + bool dvItem(DirectVisitor visitor, const PathEls::PathComponent &c, function_ref<DomItem()> it) const + { + return visitor(c, it); + } + bool dvItemField(DirectVisitor visitor, QStringView f, function_ref<DomItem()> it) const + { + return dvItem(std::move(visitor), PathEls::Field(f), it); + } + DomItem subListItem(const List &list) const; + DomItem subMapItem(const Map &map) const; + DomItem subObjectWrapItem(SimpleObjectWrap obj) const + { + return DomItem(m_top, m_owner, m_ownerPath, obj); + } + + DomItem subScriptElementWrapperItem(const ScriptElementVariant &obj) const + { + Q_ASSERT(obj); + return DomItem(m_top, m_owner, m_ownerPath, ScriptElementDomWrapper(obj)); + } + + template<typename Owner> + DomItem subOwnerItem(const PathEls::PathComponent &c, Owner o) const + { + if constexpr (domTypeIsUnattachedOwningItem(Owner::element_type::kindValue)) + return DomItem(m_top, o, canonicalPath().appendComponent(c), o.get()); + else + return DomItem(m_top, o, Path(), o.get()); + } + template<typename T> + DomItem wrap(const PathEls::PathComponent &c, const T &obj) const; + template<typename T> + DomItem wrapField(QStringView f, const T &obj) const + { + return wrap<T>(PathEls::Field(f), obj); + } + template<typename T> + bool dvWrap(DirectVisitor visitor, const PathEls::PathComponent &c, T &obj) const; + template<typename T> + bool dvWrapField(DirectVisitor visitor, QStringView f, T &obj) const + { + return dvWrap<T>(std::move(visitor), PathEls::Field(f), obj); + } + + DomItem() = default; + DomItem(const std::shared_ptr<DomEnvironment> &); + DomItem(const std::shared_ptr<DomUniverse> &); + + // TODO move to DomEnvironment? + static DomItem fromCode(const QString &code, DomType fileType = DomType::QmlFile); + + // --- start of potentially dangerous stuff, make private? --- + + std::shared_ptr<DomTop> topPtr() const; + std::shared_ptr<OwningItem> owningItemPtr() const; + + // keep the DomItem around to ensure that it doesn't get deleted + template<typename T, typename std::enable_if<std::is_base_of_v<DomBase, T>, bool>::type = true> + T const *as() const + { + if (m_kind == T::kindValue) { + if constexpr (domTypeIsObjWrap(T::kindValue) || domTypeIsValueWrap(T::kindValue)) + return std::get<SimpleObjectWrap>(m_element)->as<T>(); + else + return static_cast<T const *>(base()); + } + return nullptr; + } + + template<typename T, typename std::enable_if<!std::is_base_of_v<DomBase, T>, bool>::type = true> + T const *as() const + { + if (m_kind == T::kindValue) { + Q_ASSERT(domTypeIsObjWrap(m_kind) || domTypeIsValueWrap(m_kind)); + return std::get<SimpleObjectWrap>(m_element)->as<T>(); + } + return nullptr; + } + + template<typename T> + std::shared_ptr<T> ownerAs() const; + + template<typename Owner, typename T> + DomItem copy(const Owner &owner, const Path &ownerPath, const T &base) const + { + Q_ASSERT(!std::holds_alternative<std::monostate>(m_top)); + static_assert(IsInlineDom<std::decay_t<T>>::value, "Expected an inline item or pointer"); + return DomItem(m_top, owner, ownerPath, base); + } + + template<typename Owner> + DomItem copy(const Owner &owner, const Path &ownerPath) const + { + Q_ASSERT(!std::holds_alternative<std::monostate>(m_top)); + return DomItem(m_top, owner, ownerPath, owner.get()); + } + + template<typename T> + DomItem copy(const T &base) const + { + Q_ASSERT(!std::holds_alternative<std::monostate>(m_top)); + using BaseT = std::decay_t<T>; + static_assert(!std::is_same_v<BaseT, ElementT>, + "variant not supported, pass in the stored types"); + static_assert(IsInlineDom<BaseT>::value || std::is_same_v<BaseT, std::monostate>, + "expected either a pointer or an inline item"); + + if constexpr (IsSharedPointerToDomObject<BaseT>::value) + return DomItem(m_top, base, Path(), base.get()); + else if constexpr (IsInlineDom<BaseT>::value) + return DomItem(m_top, m_owner, m_ownerPath, base); + + Q_UNREACHABLE_RETURN(DomItem(m_top, m_owner, m_ownerPath, nullptr)); + } + +private: + enum class WriteOutCheckResult { Success, Failed }; + WriteOutCheckResult performWriteOutChecks(const DomItem &, const DomItem &, OutWriter &, WriteOutChecks) const; + const DomBase *base() const; + + template<typename Env, typename Owner> + DomItem(Env, Owner, Path, std::nullptr_t) : DomItem() + { + } + + template<typename Env, typename Owner, typename T, + typename = std::enable_if_t<IsInlineDom<std::decay_t<T>>::value>> + DomItem(Env env, Owner owner, const Path &ownerPath, const T &el) + : m_top(env), m_owner(owner), m_ownerPath(ownerPath), m_element(el) + { + using BaseT = std::decay_t<T>; + if constexpr (std::is_pointer_v<BaseT>) { + if (!el || el->kind() == DomType::Empty) { // avoid null ptr, and allow only a + // single kind of Empty + m_kind = DomType::Empty; + m_top = std::monostate(); + m_owner = std::monostate(); + m_ownerPath = Path(); + m_element = Empty(); + } else { + using DomT = std::remove_pointer_t<BaseT>; + m_element = el; + m_kind = DomT::kindValue; + } + } else { + static_assert(!std::is_same_v<BaseT, ElementT>, + "variant not supported, pass in the internal type"); + m_kind = el->kind(); + } + } + friend class DomBase; + friend class DomElement; + friend class Map; + friend class List; + friend class QmlObject; + friend class DomUniverse; + friend class DomEnvironment; + friend class ExternalItemInfoBase; + friend class ConstantData; + friend class MutableDomItem; + friend class ScriptExpression; + friend class AstComments; + friend class AttachedInfo; + friend class TestDomItem; + friend QMLDOM_EXPORT bool operator==(const DomItem &, const DomItem &); + DomType m_kind = DomType::Empty; + TopT m_top; + OwnerT m_owner; + Path m_ownerPath; + ElementT m_element = Empty(); +}; + +QMLDOM_EXPORT bool operator==(const DomItem &o1, const DomItem &o2); + +inline bool operator!=(const DomItem &o1, const DomItem &o2) +{ + return !(o1 == o2); +} + +template<typename T> +static DomItem keyMultiMapHelper(const DomItem &self, const QString &key, + const QMultiMap<QString, T> &mmap) +{ + auto it = mmap.find(key); + auto end = mmap.cend(); + if (it == end) + return DomItem(); + else { + // special case single element (++it == end || it.key() != key)? + QList<const T *> values; + while (it != end && it.key() == key) + values.append(&(*it++)); + ListP ll(self.pathFromOwner().appendComponent(PathEls::Key(key)), values, QString(), + ListOptions::Reverse); + return self.copy(ll); + } +} + +template<typename T> +Map Map::fromMultiMapRef(const Path &pathFromOwner, const QMultiMap<QString, T> &mmap) +{ + return Map( + pathFromOwner, + [&mmap](const DomItem &self, const QString &key) { + return keyMultiMapHelper(self, key, mmap); + }, + [&mmap](const DomItem &) { return QSet<QString>(mmap.keyBegin(), mmap.keyEnd()); }, + QLatin1String(typeid(T).name())); +} + +template<typename T> +Map Map::fromMapRef( + const Path &pathFromOwner, const QMap<QString, T> &map, + const std::function<DomItem(const DomItem &, const PathEls::PathComponent &, const T &)> &elWrapper) +{ + return Map( + pathFromOwner, + [&map, elWrapper](const DomItem &self, const QString &key) { + const auto it = map.constFind(key); + if (it == map.constEnd()) + return DomItem(); + return elWrapper(self, PathEls::Key(key), it.value()); + }, + [&map](const DomItem &) { return QSet<QString>(map.keyBegin(), map.keyEnd()); }, + QLatin1String(typeid(T).name())); +} + +template<typename MapT> +QSet<QString> Map::fileRegionKeysFromMap(const MapT &map) +{ + QSet<QString> keys; + std::transform(map.keyBegin(), map.keyEnd(), std::inserter(keys, keys.begin()), fileLocationRegionName); + return keys; +} + +template<typename T> +Map Map::fromFileRegionMap(const Path &pathFromOwner, const QMap<FileLocationRegion, T> &map) +{ + auto result = Map( + pathFromOwner, + [&map](const DomItem &mapItem, const QString &key) -> DomItem { + auto it = map.constFind(fileLocationRegionValue(key)); + if (it == map.constEnd()) + return {}; + + return mapItem.wrap(PathEls::Key(key), *it); + }, + [&map](const DomItem &) { return fileRegionKeysFromMap(map); }, + QString::fromLatin1(typeid(T).name())); + return result; +} + +template<typename T> +Map Map::fromFileRegionListMap(const Path &pathFromOwner, + const QMap<FileLocationRegion, QList<T>> &map) +{ + using namespace Qt::StringLiterals; + auto result = Map( + pathFromOwner, + [&map](const DomItem &mapItem, const QString &key) -> DomItem { + const QList<SourceLocation> locations = map.value(fileLocationRegionValue(key)); + if (locations.empty()) + return {}; + + auto list = List::fromQList<SourceLocation>( + mapItem.pathFromOwner(), locations, + [](const DomItem &self, const PathEls::PathComponent &path, + const SourceLocation &location) { + return self.subLocationItem(path, location); + }); + return mapItem.subListItem(list); + }, + [&map](const DomItem &) { return fileRegionKeysFromMap(map); }, + u"QList<%1>"_s.arg(QString::fromLatin1(typeid(T).name()))); + return result; +} + +template<typename T> +List List::fromQList( + const Path &pathFromOwner, const QList<T> &list, + const std::function<DomItem(const DomItem &, const PathEls::PathComponent &, const T &)> &elWrapper, + ListOptions options) +{ + index_type len = list.size(); + if (options == ListOptions::Reverse) { + return List( + pathFromOwner, + [list, elWrapper](const DomItem &self, index_type i) mutable { + if (i < 0 || i >= list.size()) + return DomItem(); + return elWrapper(self, PathEls::Index(i), list[list.size() - i - 1]); + }, + [len](const DomItem &) { return len; }, nullptr, QLatin1String(typeid(T).name())); + } else { + return List( + pathFromOwner, + [list, elWrapper](const DomItem &self, index_type i) mutable { + if (i < 0 || i >= list.size()) + return DomItem(); + return elWrapper(self, PathEls::Index(i), list[i]); + }, + [len](const DomItem &) { return len; }, nullptr, QLatin1String(typeid(T).name())); + } +} + +template<typename T> +List List::fromQListRef( + const Path &pathFromOwner, const QList<T> &list, + const std::function<DomItem(const DomItem &, const PathEls::PathComponent &, const T &)> &elWrapper, + ListOptions options) +{ + if (options == ListOptions::Reverse) { + return List( + pathFromOwner, + [&list, elWrapper](const DomItem &self, index_type i) { + if (i < 0 || i >= list.size()) + return DomItem(); + return elWrapper(self, PathEls::Index(i), list[list.size() - i - 1]); + }, + [&list](const DomItem &) { return list.size(); }, nullptr, + QLatin1String(typeid(T).name())); + } else { + return List( + pathFromOwner, + [&list, elWrapper](const DomItem &self, index_type i) { + if (i < 0 || i >= list.size()) + return DomItem(); + return elWrapper(self, PathEls::Index(i), list[i]); + }, + [&list](const DomItem &) { return list.size(); }, nullptr, + QLatin1String(typeid(T).name())); + } +} + +class QMLDOM_EXPORT OwningItem: public DomBase { +protected: + virtual std::shared_ptr<OwningItem> doCopy(const DomItem &self) const = 0; + +public: + OwningItem(const OwningItem &o); + OwningItem(int derivedFrom=0); + OwningItem(int derivedFrom, const QDateTime &lastDataUpdateAt); + OwningItem(const OwningItem &&) = delete; + OwningItem &operator=(const OwningItem &&) = delete; + static int nextRevision(); + + Path canonicalPath(const DomItem &self) const override = 0; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + std::shared_ptr<OwningItem> makeCopy(const DomItem &self) const { return doCopy(self); } + Path pathFromOwner() const { return Path(); } + Path pathFromOwner(const DomItem &) const override final { return Path(); } + DomItem containingObject(const DomItem &self) const override; + int derivedFrom() const; + virtual int revision() const; + + QDateTime createdAt() const; + virtual QDateTime lastDataUpdateAt() const; + virtual void refreshedDataAt(QDateTime tNew); + + // explicit freeze handling needed? + virtual bool frozen() const; + virtual bool freeze(); + QDateTime frozenAt() const; + + virtual void addError(const DomItem &self, ErrorMessage &&msg); + void addErrorLocal(ErrorMessage &&msg); + void clearErrors(const ErrorGroups &groups = ErrorGroups({})); + // return false if a quick exit was requested + bool iterateErrors( + const DomItem &self, + function_ref<bool(const DomItem &source, const ErrorMessage &msg)> visitor, + const Path &inPath = Path()); + QMultiMap<Path, ErrorMessage> localErrors() const { + QMutexLocker l(mutex()); + return m_errors; + } + + virtual bool iterateSubOwners(const DomItem &self, function_ref<bool(const DomItem &owner)> visitor); + + QBasicMutex *mutex() const { return &m_mutex; } +private: + mutable QBasicMutex m_mutex; + int m_derivedFrom; + int m_revision; + QDateTime m_createdAt; + QDateTime m_lastDataUpdateAt; + QDateTime m_frozenAt; + QMultiMap<Path, ErrorMessage> m_errors; + QMap<ErrorMessage, quint32> m_errorsCounts; +}; + +template<typename T> +std::shared_ptr<T> DomItem::ownerAs() const +{ + if constexpr (domTypeIsOwningItem(T::kindValue)) { + if (!std::holds_alternative<std::monostate>(m_owner)) { + if constexpr (T::kindValue == DomType::AttachedInfo) { + if (std::holds_alternative<std::shared_ptr<AttachedInfo>>(m_owner)) + return std::static_pointer_cast<T>( + std::get<std::shared_ptr<AttachedInfo>>(m_owner)); + } else if constexpr (T::kindValue == DomType::ExternalItemInfo) { + if (std::holds_alternative<std::shared_ptr<ExternalItemInfoBase>>(m_owner)) + return std::static_pointer_cast<T>( + std::get<std::shared_ptr<ExternalItemInfoBase>>(m_owner)); + } else if constexpr (T::kindValue == DomType::ExternalItemPair) { + if (std::holds_alternative<std::shared_ptr<ExternalItemPairBase>>(m_owner)) + return std::static_pointer_cast<T>( + std::get<std::shared_ptr<ExternalItemPairBase>>(m_owner)); + } else { + if (std::holds_alternative<std::shared_ptr<T>>(m_owner)) { + return std::get<std::shared_ptr<T>>(m_owner); + } + } + } + } else { + Q_ASSERT_X(false, "DomItem::ownerAs", "unexpected non owning value in ownerAs"); + } + return std::shared_ptr<T> {}; +} + +template<int I> +struct rank : rank<I - 1> +{ + static_assert(I > 0, ""); +}; +template<> +struct rank<0> +{ +}; + +template<typename T> +auto writeOutWrap(const T &t, const DomItem &self, OutWriter &lw, rank<1>) + -> decltype(t.writeOut(self, lw)) +{ + t.writeOut(self, lw); +} + +template<typename T> +auto writeOutWrap(const T &, const DomItem &, OutWriter &, rank<0>) -> void +{ + qCWarning(writeOutLog) << "Ignoring writeout to wrapped object not supporting it (" + << typeid(T).name(); +} +template<typename T> +auto writeOutWrap(const T &t, const DomItem &self, OutWriter &lw) -> void +{ + writeOutWrap(t, self, lw, rank<1>()); +} + +template<typename T> +void SimpleObjectWrapT<T>::writeOut(const DomItem &self, OutWriter &lw) const +{ + writeOutWrap<T>(*asT(), self, lw); +} + +QMLDOM_EXPORT QDebug operator<<(QDebug debug, const DomItem &c); + +class QMLDOM_EXPORT MutableDomItem { +public: + using CopyOption = DomItem::CopyOption; + + explicit operator bool() const + { + return bool(m_owner); + } // this is weaker than item(), but normally correct + DomType internalKind() { return item().internalKind(); } + QString internalKindStr() { return domTypeToString(internalKind()); } + DomKind domKind() { return kind2domKind(internalKind()); } + + Path canonicalPath() const { return m_owner.canonicalPath().path(m_pathFromOwner); } + MutableDomItem containingObject() + { + if (m_pathFromOwner) + return MutableDomItem(m_owner, m_pathFromOwner.split().pathToSource); + else { + DomItem cObj = m_owner.containingObject(); + return MutableDomItem(cObj.owner(), (domTypeIsOwningItem(cObj.internalKind()) ? Path() :cObj.pathFromOwner())); + } + } + + MutableDomItem container() + { + if (m_pathFromOwner) + return MutableDomItem(m_owner, m_pathFromOwner.dropTail()); + else { + return MutableDomItem(item().container()); + } + } + + MutableDomItem qmlObject(GoTo option = GoTo::Strict, + FilterUpOptions fOptions = FilterUpOptions::ReturnOuter) + { + return MutableDomItem(item().qmlObject(option, fOptions)); + } + MutableDomItem fileObject(GoTo option = GoTo::Strict) + { + return MutableDomItem(item().fileObject(option)); + } + MutableDomItem rootQmlObject(GoTo option = GoTo::Strict) + { + return MutableDomItem(item().rootQmlObject(option)); + } + MutableDomItem globalScope() { return MutableDomItem(item().globalScope()); } + MutableDomItem scope() { return MutableDomItem(item().scope()); } + + MutableDomItem component(GoTo option = GoTo::Strict) + { + return MutableDomItem { item().component(option) }; + } + MutableDomItem owner() { return MutableDomItem(m_owner); } + MutableDomItem top() { return MutableDomItem(item().top()); } + MutableDomItem environment() { return MutableDomItem(item().environment()); } + MutableDomItem universe() { return MutableDomItem(item().universe()); } + Path pathFromOwner() { return m_pathFromOwner; } + MutableDomItem operator[](const Path &path) { return MutableDomItem(item()[path]); } + MutableDomItem operator[](QStringView component) { return MutableDomItem(item()[component]); } + MutableDomItem operator[](const QString &component) + { + return MutableDomItem(item()[component]); + } + MutableDomItem operator[](const char16_t *component) + { + // to avoid clash with stupid builtin ptrdiff_t[MutableDomItem&], coming from C + return MutableDomItem(item()[QStringView(component)]); + } + MutableDomItem operator[](index_type i) { return MutableDomItem(item().index(i)); } + + MutableDomItem path(const Path &p) { return MutableDomItem(item().path(p)); } + MutableDomItem path(const QString &p) { return path(Path::fromString(p)); } + MutableDomItem path(QStringView p) { return path(Path::fromString(p)); } + + QList<QString> const fields() { return item().fields(); } + MutableDomItem field(QStringView name) { return MutableDomItem(item().field(name)); } + index_type indexes() { return item().indexes(); } + MutableDomItem index(index_type i) { return MutableDomItem(item().index(i)); } + + QSet<QString> const keys() { return item().keys(); } + MutableDomItem key(const QString &name) { return MutableDomItem(item().key(name)); } + MutableDomItem key(QStringView name) { return key(name.toString()); } + + void + dump(const Sink &s, int indent = 0, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter = noFilter) + { + item().dump(s, indent, filter); + } + FileWriter::Status + dump(const QString &path, + function_ref<bool(const DomItem &, const PathEls::PathComponent &, const DomItem &)> filter = noFilter, + int nBackups = 2, int indent = 0, FileWriter *fw = nullptr) + { + return item().dump(path, filter, nBackups, indent, fw); + } + void writeOut(OutWriter &lw) { return item().writeOut(lw); } + bool writeOut(const QString &path, int nBackups = 2, + const LineWriterOptions &opt = LineWriterOptions(), FileWriter *fw = nullptr) + { + return item().writeOut(path, nBackups, opt, fw); + } + + MutableDomItem fileLocations() { return MutableDomItem(item().fileLocations()); } + MutableDomItem makeCopy(CopyOption option = CopyOption::EnvConnected) + { + return item().makeCopy(option); + } + bool commitToBase(const std::shared_ptr<DomEnvironment> &validEnvPtr = nullptr) + { + return item().commitToBase(validEnvPtr); + } + QString canonicalFilePath() const { return item().canonicalFilePath(); } + + MutableDomItem refreshed() { return MutableDomItem(item().refreshed()); } + + QCborValue value() { return item().value(); } + + QString toString() { return item().toString(); } + + // convenience getters + QString name() { return item().name(); } + MutableDomItem pragmas() { return item().pragmas(); } + MutableDomItem ids() { return MutableDomItem::item().ids(); } + QString idStr() { return item().idStr(); } + MutableDomItem propertyDefs() { return MutableDomItem(item().propertyDefs()); } + MutableDomItem bindings() { return MutableDomItem(item().bindings()); } + MutableDomItem methods() { return MutableDomItem(item().methods()); } + MutableDomItem children() { return MutableDomItem(item().children()); } + MutableDomItem child(index_type i) { return MutableDomItem(item().child(i)); } + MutableDomItem annotations() { return MutableDomItem(item().annotations()); } + + // // OwnigItem elements + int derivedFrom() { return m_owner.derivedFrom(); } + int revision() { return m_owner.revision(); } + QDateTime createdAt() { return m_owner.createdAt(); } + QDateTime frozenAt() { return m_owner.frozenAt(); } + QDateTime lastDataUpdateAt() { return m_owner.lastDataUpdateAt(); } + + void addError(ErrorMessage &&msg) { item().addError(std::move(msg)); } + ErrorHandler errorHandler(); + + // convenience setters + MutableDomItem addPrototypePath(const Path &prototypePath); + MutableDomItem setNextScopePath(const Path &nextScopePath); + MutableDomItem setPropertyDefs(QMultiMap<QString, PropertyDefinition> propertyDefs); + MutableDomItem setBindings(QMultiMap<QString, Binding> bindings); + MutableDomItem setMethods(QMultiMap<QString, MethodInfo> functionDefs); + MutableDomItem setChildren(const QList<QmlObject> &children); + MutableDomItem setAnnotations(const QList<QmlObject> &annotations); + MutableDomItem setScript(const std::shared_ptr<ScriptExpression> &exp); + MutableDomItem setCode(const QString &code); + MutableDomItem addPropertyDef(const PropertyDefinition &propertyDef, + AddOption option = AddOption::Overwrite); + MutableDomItem addBinding(Binding binding, AddOption option = AddOption::Overwrite); + MutableDomItem addMethod( + const MethodInfo &functionDef, AddOption option = AddOption::Overwrite); + MutableDomItem addChild(QmlObject child); + MutableDomItem addAnnotation(QmlObject child); + MutableDomItem addPreComment(const Comment &comment, FileLocationRegion region); + MutableDomItem addPostComment(const Comment &comment, FileLocationRegion region); + QQmlJSScope::ConstPtr semanticScope(); + void setSemanticScope(const QQmlJSScope::ConstPtr &scope); + + MutableDomItem() = default; + MutableDomItem(const DomItem &owner, const Path &pathFromOwner): + m_owner(owner), m_pathFromOwner(pathFromOwner) + {} + MutableDomItem(const DomItem &item): + m_owner(item.owner()), m_pathFromOwner(item.pathFromOwner()) + {} + + std::shared_ptr<DomTop> topPtr() { return m_owner.topPtr(); } + std::shared_ptr<OwningItem> owningItemPtr() { return m_owner.owningItemPtr(); } + + template<typename T> + T const *as() + { + return item().as<T>(); + } + + template <typename T> + T *mutableAs() { + Q_ASSERT(!m_owner || !m_owner.owningItemPtr()->frozen()); + + DomItem self = item(); + if (self.m_kind != T::kindValue) + return nullptr; + + const T *t = nullptr; + if constexpr (domTypeIsObjWrap(T::kindValue) || domTypeIsValueWrap(T::kindValue)) + t = static_cast<const SimpleObjectWrapBase *>(self.base())->as<T>(); + else if constexpr (std::is_base_of<DomBase, T>::value) + t = static_cast<const T *>(self.base()); + else + Q_UNREACHABLE_RETURN(nullptr); + + // Nasty. But since ElementT has to store the const pointers, we allow it in this one place. + return const_cast<T *>(t); + } + + template<typename T> + std::shared_ptr<T> ownerAs() const + { + return m_owner.ownerAs<T>(); + } + // it is dangerous to assume it stays valid when updates are preformed... + DomItem item() const { return m_owner.path(m_pathFromOwner); } + + friend bool operator==(const MutableDomItem &o1, const MutableDomItem &o2) + { + return o1.m_owner == o2.m_owner && o1.m_pathFromOwner == o2.m_pathFromOwner; + } + friend bool operator!=(const MutableDomItem &o1, const MutableDomItem &o2) + { + return !(o1 == o2); + } + +private: + DomItem m_owner; + Path m_pathFromOwner; +}; + +QMLDOM_EXPORT QDebug operator<<(QDebug debug, const MutableDomItem &c); + +template<typename K, typename T> +Path insertUpdatableElementInMultiMap(const Path &mapPathFromOwner, QMultiMap<K, T> &mmap, K key, + const T &value, AddOption option = AddOption::KeepExisting, + T **valuePtr = nullptr) +{ + if (option == AddOption::Overwrite) { + auto it = mmap.find(key); + if (it != mmap.end()) { + T &v = *it; + v = value; + if (++it != mmap.end() && it.key() == key) { + qWarning() << " requested overwrite of " << key + << " that contains aleready multiple entries in" << mapPathFromOwner; + } + Path newPath = mapPathFromOwner.key(key).index(0); + v.updatePathFromOwner(newPath); + if (valuePtr) + *valuePtr = &v; + return newPath; + } + } + mmap.insert(key, value); + auto it = mmap.find(key); + auto it2 = it; + int nVal = 0; + while (it2 != mmap.end() && it2.key() == key) { + ++nVal; + ++it2; + } + Path newPath = mapPathFromOwner.key(key).index(nVal-1); + T &v = *it; + v.updatePathFromOwner(newPath); + if (valuePtr) + *valuePtr = &v; + return newPath; +} + +template<typename T> +Path appendUpdatableElementInQList(const Path &listPathFromOwner, QList<T> &list, const T &value, + T **vPtr = nullptr) +{ + int idx = list.size(); + list.append(value); + Path newPath = listPathFromOwner.index(idx); + T &targetV = list[idx]; + targetV.updatePathFromOwner(newPath); + if (vPtr) + *vPtr = &targetV; + return newPath; +} + +template <typename T, typename K = QString> +void updatePathFromOwnerMultiMap(QMultiMap<K, T> &mmap, const Path &newPath) +{ + auto it = mmap.begin(); + auto end = mmap.end(); + index_type i = 0; + K name; + QList<T*> els; + while (it != end) { + if (i > 0 && name != it.key()) { + Path pName = newPath.key(QString(name)); + for (T *el : els) + el->updatePathFromOwner(pName.index(--i)); + els.clear(); + els.append(&(*it)); + name = it.key(); + i = 1; + } else { + els.append(&(*it)); + name = it.key(); + ++i; + } + ++it; + } + Path pName = newPath.key(name); + for (T *el : els) + el->updatePathFromOwner(pName.index(--i)); +} + +template <typename T> +void updatePathFromOwnerQList(QList<T> &list, const Path &newPath) +{ + auto it = list.begin(); + auto end = list.end(); + index_type i = 0; + while (it != end) + (it++)->updatePathFromOwner(newPath.index(i++)); +} + +constexpr bool domTypeIsObjWrap(DomType k) +{ + switch (k) { + case DomType::Binding: + case DomType::EnumItem: + case DomType::ErrorMessage: + case DomType::Export: + case DomType::Id: + case DomType::Import: + case DomType::ImportScope: + case DomType::MethodInfo: + case DomType::MethodParameter: + case DomType::ModuleAutoExport: + case DomType::Pragma: + case DomType::PropertyDefinition: + case DomType::Version: + case DomType::Comment: + case DomType::CommentedElement: + case DomType::RegionComments: + case DomType::FileLocations: + case DomType::UpdatedScriptExpression: + return true; + default: + return false; + } +} + +constexpr bool domTypeIsValueWrap(DomType k) +{ + switch (k) { + case DomType::PropertyInfo: + return true; + default: + return false; + } +} + +constexpr bool domTypeIsDomElement(DomType k) +{ + switch (k) { + case DomType::ModuleScope: + case DomType::QmlObject: + case DomType::ConstantData: + case DomType::SimpleObjectWrap: + case DomType::Reference: + case DomType::Map: + case DomType::List: + case DomType::ListP: + case DomType::EnumDecl: + case DomType::JsResource: + case DomType::QmltypesComponent: + case DomType::QmlComponent: + case DomType::GlobalComponent: + case DomType::MockObject: + return true; + default: + return false; + } +} + +constexpr bool domTypeIsOwningItem(DomType k) +{ + switch (k) { + case DomType::ModuleIndex: + + case DomType::MockOwner: + + case DomType::ExternalItemInfo: + case DomType::ExternalItemPair: + + case DomType::QmlDirectory: + case DomType::QmldirFile: + case DomType::JsFile: + case DomType::QmlFile: + case DomType::QmltypesFile: + case DomType::GlobalScope: + + case DomType::ScriptExpression: + case DomType::AstComments: + + case DomType::LoadInfo: + case DomType::AttachedInfo: + + case DomType::DomEnvironment: + case DomType::DomUniverse: + return true; + default: + return false; + } +} + +constexpr bool domTypeIsUnattachedOwningItem(DomType k) +{ + switch (k) { + case DomType::ScriptExpression: + case DomType::AstComments: + case DomType::AttachedInfo: + return true; + default: + return false; + } +} + +constexpr bool domTypeIsScriptElement(DomType k) +{ + return DomType::ScriptElementStart <= k && k <= DomType::ScriptElementStop; +} + +template<typename T> +DomItem DomItem::subValueItem(const PathEls::PathComponent &c, const T &value, + ConstantData::Options options) const +{ + using BaseT = std::remove_cv_t<std::remove_reference_t<T>>; + if constexpr ( + std::is_base_of_v< + QCborValue, + BaseT> || std::is_base_of_v<QCborArray, BaseT> || std::is_base_of_v<QCborMap, BaseT>) { + return DomItem(m_top, m_owner, m_ownerPath, + ConstantData(pathFromOwner().appendComponent(c), value, options)); + } else if constexpr (std::is_same_v<DomItem, BaseT>) { + Q_UNUSED(options); + return value; + } else if constexpr (IsList<T>::value && !std::is_convertible_v<BaseT, QStringView>) { + return subListItem(List::fromQList<typename BaseT::value_type>( + pathFromOwner().appendComponent(c), value, + [options](const DomItem &list, const PathEls::PathComponent &p, + const typename T::value_type &v) { return list.subValueItem(p, v, options); })); + } else if constexpr (IsSharedPointerToDomObject<BaseT>::value) { + Q_UNUSED(options); + return subOwnerItem(c, value); + } else { + return subDataItem(c, value, options); + } +} + +template<typename T> +DomItem DomItem::subDataItem(const PathEls::PathComponent &c, const T &value, + ConstantData::Options options) const +{ + using BaseT = std::remove_cv_t<std::remove_reference_t<T>>; + if constexpr (std::is_same_v<BaseT, ConstantData>) { + return this->copy(value); + } else if constexpr (std::is_base_of_v<QCborValue, BaseT>) { + return DomItem(m_top, m_owner, m_ownerPath, + ConstantData(pathFromOwner().appendComponent(c), value, options)); + } else { + return DomItem( + m_top, m_owner, m_ownerPath, + ConstantData(pathFromOwner().appendComponent(c), QCborValue(value), options)); + } +} + +template<typename T> +bool DomItem::dvValue(DirectVisitor visitor, const PathEls::PathComponent &c, const T &value, + ConstantData::Options options) const +{ + auto lazyWrap = [this, &c, &value, options]() { + return this->subValueItem<T>(c, value, options); + }; + return visitor(c, lazyWrap); +} + +template<typename F> +bool DomItem::dvValueLazy(DirectVisitor visitor, const PathEls::PathComponent &c, F valueF, + ConstantData::Options options) const +{ + auto lazyWrap = [this, &c, &valueF, options]() { + return this->subValueItem<decltype(valueF())>(c, valueF(), options); + }; + return visitor(c, lazyWrap); +} + +template<typename T> +DomItem DomItem::wrap(const PathEls::PathComponent &c, const T &obj) const +{ + using BaseT = std::decay_t<T>; + if constexpr (std::is_same_v<QString, BaseT> || std::is_arithmetic_v<BaseT>) { + return this->subDataItem(c, QCborValue(obj)); + } else if constexpr (std::is_same_v<SourceLocation, BaseT>) { + return this->subLocationItem(c, obj); + } else if constexpr (std::is_same_v<BaseT, Reference>) { + Q_ASSERT_X(false, "DomItem::wrap", + "wrapping a reference object, probably an error (wrap the target path instead)"); + return this->copy(obj); + } else if constexpr (std::is_same_v<BaseT, ConstantData>) { + return this->subDataItem(c, obj); + } else if constexpr (std::is_same_v<BaseT, Map>) { + return this->subMapItem(obj); + } else if constexpr (std::is_same_v<BaseT, List>) { + return this->subListItem(obj); + } else if constexpr (std::is_base_of_v<ListPBase, BaseT>) { + return this->subListItem(obj); + } else if constexpr (std::is_same_v<BaseT, SimpleObjectWrap>) { + return this->subObjectWrapItem(obj); + } else if constexpr (IsDomObject<BaseT>::value) { + if constexpr (domTypeIsObjWrap(BaseT::kindValue) || domTypeIsValueWrap(BaseT::kindValue)) { + return this->subObjectWrapItem( + SimpleObjectWrap::fromObjectRef(this->pathFromOwner().appendComponent(c), obj)); + } else if constexpr (domTypeIsDomElement(BaseT::kindValue)) { + return this->copy(&obj); + } else { + qCWarning(domLog) << "Unhandled object of type " << domTypeToString(BaseT::kindValue) + << " in DomItem::wrap, not using a shared_ptr for an " + << "OwningItem, or unexpected wrapped object?"; + return DomItem(); + } + } else if constexpr (IsSharedPointerToDomObject<BaseT>::value) { + if constexpr (domTypeIsOwningItem(BaseT::element_type::kindValue)) { + return this->subOwnerItem(c, obj); + } else { + Q_ASSERT_X(false, "DomItem::wrap", "shared_ptr with non owning item"); + return DomItem(); + } + } else if constexpr (IsMultiMap<BaseT>::value) { + if constexpr (std::is_same_v<typename BaseT::key_type, QString>) { + return subMapItem(Map::fromMultiMapRef<typename BaseT::mapped_type>( + pathFromOwner().appendComponent(c), obj)); + } else { + Q_ASSERT_X(false, "DomItem::wrap", "non string keys not supported (try .toString()?)"); + } + } else if constexpr (IsMap<BaseT>::value) { + if constexpr (std::is_same_v<typename BaseT::key_type, QString>) { + return subMapItem(Map::fromMapRef<typename BaseT::mapped_type>( + pathFromOwner().appendComponent(c), obj, + [](const DomItem &map, const PathEls::PathComponent &p, + const typename BaseT::mapped_type &el) { return map.wrap(p, el); })); + } else { + Q_ASSERT_X(false, "DomItem::wrap", "non string keys not supported (try .toString()?)"); + } + } else if constexpr (IsList<BaseT>::value) { + if constexpr (IsDomObject<typename BaseT::value_type>::value) { + return subListItem(List::fromQListRef<typename BaseT::value_type>( + pathFromOwner().appendComponent(c), obj, + [](const DomItem &list, const PathEls::PathComponent &p, + const typename BaseT::value_type &el) { return list.wrap(p, el); })); + } else { + Q_ASSERT_X(false, "DomItem::wrap", "Unsupported list type T"); + return DomItem(); + } + } else { + qCWarning(domLog) << "Cannot wrap " << typeid(BaseT).name(); + Q_ASSERT_X(false, "DomItem::wrap", "Do not know how to wrap type T"); + return DomItem(); + } +} + +template<typename T> +bool DomItem::dvWrap(DirectVisitor visitor, const PathEls::PathComponent &c, T &obj) const +{ + auto lazyWrap = [this, &c, &obj]() { return this->wrap<T>(c, obj); }; + return visitor(c, lazyWrap); +} + +template<typename T> +bool ListPT<T>::iterateDirectSubpaths(const DomItem &self, DirectVisitor v) const +{ + index_type len = index_type(m_pList.size()); + for (index_type i = 0; i < len; ++i) { + if (!v(PathEls::Index(i), [this, &self, i] { return this->index(self, i); })) + return false; + } + return true; +} + +template<typename T> +DomItem ListPT<T>::index(const DomItem &self, index_type index) const +{ + if (index >= 0 && index < m_pList.size()) + return self.wrap(PathEls::Index(index), *static_cast<const T *>(m_pList.value(index))); + return DomItem(); +} + +// allow inlining of DomBase +inline DomKind DomBase::domKind() const +{ + return kind2domKind(kind()); +} + +inline bool DomBase::iterateDirectSubpathsConst(const DomItem &self, DirectVisitor visitor) const +{ + Q_ASSERT(self.base() == this); + return self.iterateDirectSubpaths(std::move(visitor)); +} + +inline DomItem DomBase::containingObject(const DomItem &self) const +{ + Path path = pathFromOwner(self); + DomItem base = self.owner(); + if (!path) { + path = canonicalPath(self); + base = self; + } + Source source = path.split(); + return base.path(source.pathToSource); +} + +inline quintptr DomBase::id() const +{ + return quintptr(this); +} + +inline QString DomBase::typeName() const +{ + return domTypeToString(kind()); +} + +inline QList<QString> DomBase::fields(const DomItem &self) const +{ + QList<QString> res; + self.iterateDirectSubpaths([&res](const PathEls::PathComponent &c, function_ref<DomItem()>) { + if (c.kind() == Path::Kind::Field) + res.append(c.name()); + return true; + }); + return res; +} + +inline DomItem DomBase::field(const DomItem &self, QStringView name) const +{ + DomItem res; + self.iterateDirectSubpaths( + [&res, name](const PathEls::PathComponent &c, function_ref<DomItem()> obj) { + if (c.kind() == Path::Kind::Field && c.checkName(name)) { + res = obj(); + return false; + } + return true; + }); + return res; +} + +inline index_type DomBase::indexes(const DomItem &self) const +{ + index_type res = 0; + self.iterateDirectSubpaths([&res](const PathEls::PathComponent &c, function_ref<DomItem()>) { + if (c.kind() == Path::Kind::Index) { + index_type i = c.index() + 1; + if (res < i) + res = i; + } + return true; + }); + return res; +} + +inline DomItem DomBase::index(const DomItem &self, qint64 index) const +{ + DomItem res; + self.iterateDirectSubpaths( + [&res, index](const PathEls::PathComponent &c, function_ref<DomItem()> obj) { + if (c.kind() == Path::Kind::Index && c.index() == index) { + res = obj(); + return false; + } + return true; + }); + return res; +} + +inline QSet<QString> const DomBase::keys(const DomItem &self) const +{ + QSet<QString> res; + self.iterateDirectSubpaths([&res](const PathEls::PathComponent &c, function_ref<DomItem()>) { + if (c.kind() == Path::Kind::Key) + res.insert(c.name()); + return true; + }); + return res; +} + +inline DomItem DomBase::key(const DomItem &self, const QString &name) const +{ + DomItem res; + self.iterateDirectSubpaths( + [&res, name](const PathEls::PathComponent &c, function_ref<DomItem()> obj) { + if (c.kind() == Path::Kind::Key && c.checkName(name)) { + res = obj(); + return false; + } + return true; + }); + return res; +} + +inline DomItem DomItem::subListItem(const List &list) const +{ + return DomItem(m_top, m_owner, m_ownerPath, list); +} + +inline DomItem DomItem::subMapItem(const Map &map) const +{ + return DomItem(m_top, m_owner, m_ownerPath, map); +} + +} // end namespace Dom +} // end namespace QQmlJS + +QT_END_NAMESPACE +#endif // QMLDOMITEM_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomlinewriter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomlinewriter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..8deca09ae8bf7d3da74d04da66e60454f33e553a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomlinewriter_p.h @@ -0,0 +1,225 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMLINEWRITER_P +#define QQMLDOMLINEWRITER_P + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldomstringdumper_p.h" + +#include <QtQml/private/qqmljssourcelocation_p.h> +#include <QtCore/QObject> +#include <QtCore/QAtomicInt> +#include <QtCore/QMap> +#include <functional> + +QT_BEGIN_NAMESPACE +namespace QQmlJS { +namespace Dom { + +class IndentInfo +{ +public: + QStringView string; + QStringView trailingString; + int nNewlines = 0; + int column = 0; + + IndentInfo(QStringView line, int tabSize, int initialColumn = 0) + { + string = line; + int fixup = 0; + if (initialColumn < 0) // we do not want % of negative numbers + fixup = (-initialColumn + tabSize - 1) / tabSize * tabSize; + column = initialColumn + fixup; + const QChar tab = QLatin1Char('\t'); + int iStart = 0; + int len = line.size(); + for (int i = 0; i < len; i++) { + if (line[i] == tab) + column = ((column / tabSize) + 1) * tabSize; + else if (line[i] == QLatin1Char('\n') + || (line[i] == QLatin1Char('\r') + && (i + 1 == len || line[i + 1] != QLatin1Char('\n')))) { + iStart = i + 1; + ++nNewlines; + column = 0; + } else if (!line[i].isLowSurrogate()) + column++; + } + column -= fixup; + trailingString = line.mid(iStart); + } +}; + +class QMLDOM_EXPORT FormatOptions +{ +public: + int tabSize = 4; + int indentSize = 4; + bool useTabs = false; +}; + +class QMLDOM_EXPORT LineWriterOptions +{ + Q_GADGET +public: + enum class LineEndings { Unix, Windows, OldMacOs }; + Q_ENUM(LineEndings) + enum class TrailingSpace { Preserve, Remove }; + Q_ENUM(TrailingSpace) + enum class Update { None = 0, Expressions = 0x1, Locations = 0x2, All = 0x3, Default = All }; + Q_ENUM(Update) + Q_DECLARE_FLAGS(Updates, Update) + enum class AttributesSequence { Normalize, Preserve }; + Q_ENUM(AttributesSequence) + + int maxLineLength = -1; + int strongMaxLineExtra = 20; + int minContentLength = 10; +#if defined (Q_OS_WIN) + LineEndings lineEndings = LineEndings::Windows; +#else + LineEndings lineEndings = LineEndings::Unix; +#endif + TrailingSpace codeTrailingSpace = TrailingSpace::Remove; + TrailingSpace commentTrailingSpace = TrailingSpace::Remove; + TrailingSpace stringTrailingSpace = TrailingSpace::Preserve; + FormatOptions formatOptions; + Updates updateOptions = Update::Default; + AttributesSequence attributesSequence = AttributesSequence::Normalize; + bool objectsSpacing = false; + bool functionsSpacing = false; +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(LineWriterOptions::Updates) + +using PendingSourceLocationId = int; +using PendingSourceLocationIdAtomic = QAtomicInt; +class LineWriter; + +class QMLDOM_EXPORT PendingSourceLocation +{ + Q_GADGET +public: + quint32 utf16Start() const; + quint32 utf16End() const; + void changeAtOffset(quint32 offset, qint32 change, qint32 colChange, qint32 lineChange); + void commit(); + PendingSourceLocationId id; + SourceLocation value; + SourceLocation *toUpdate = nullptr; + std::function<void(SourceLocation)> updater = nullptr; + bool open = true; +}; + +class QMLDOM_EXPORT LineWriter +{ + Q_GADGET +public: + enum class TextAddType { + Normal, + Extra, + Newline, + NewlineSplit, + NewlineExtra, + PartialCommit, + Eof + }; + + LineWriter(const SinkF &innerSink, const QString &fileName, + const LineWriterOptions &options = LineWriterOptions(), int lineNr = 0, + int columnNr = 0, int utf16Offset = 0, const QString ¤tLine = QString()); + std::function<void(QStringView)> sink() + { + return [this](QStringView s) { this->write(s); }; + } + + virtual ~LineWriter() { } + + QList<SinkF> innerSinks() { return m_innerSinks; } + void addInnerSink(const SinkF &s) { m_innerSinks.append(s); } + LineWriter &ensureNewline(int nNewlines = 1, TextAddType t = TextAddType::Extra); + LineWriter &ensureSpace(TextAddType t = TextAddType::Extra); + LineWriter &ensureSpace(QStringView space, TextAddType t = TextAddType::Extra); + + LineWriter &newline() + { + write(u"\n"); + return *this; + } + LineWriter &space() + { + write(u" "); + return *this; + } + LineWriter &write(QStringView v, TextAddType tType = TextAddType::Normal); + LineWriter &write(QStringView v, SourceLocation *toUpdate) + { + auto pLoc = startSourceLocation(toUpdate); + write(v); + endSourceLocation(pLoc); + return *this; + } + void commitLine(const QString &eol, TextAddType t = TextAddType::Normal, int untilChar = -1); + void flush(); + void eof(bool ensureNewline = true); + SourceLocation committedLocation() const; + PendingSourceLocationId startSourceLocation(SourceLocation *); + PendingSourceLocationId startSourceLocation(std::function<void(SourceLocation)>); + void endSourceLocation(PendingSourceLocationId); + quint32 counter() const { return m_counter; } + int addTextAddCallback(std::function<bool(LineWriter &, TextAddType)> callback); + bool removeTextAddCallback(int i) { return m_textAddCallbacks.remove(i); } + int addNewlinesAutospacerCallback(int nLines); + void handleTrailingSpace(LineWriterOptions::TrailingSpace s); + void setLineIndent(int indentAmount); + QString fileName() const { return m_fileName; } + const QString ¤tLine() const { return m_currentLine; } + const LineWriterOptions &options() const { return m_options; } + virtual void lineChanged() { } + virtual void reindentAndSplit(const QString &eol, bool eof = false); + virtual void willCommit() { } + +private: + Q_DISABLE_COPY_MOVE(LineWriter) +protected: + void changeAtOffset(quint32 offset, qint32 change, qint32 colChange, qint32 lineChange); + QString eolToWrite() const; + SourceLocation currentSourceLocation() const; + int column(int localIndex); + void textAddCallback(TextAddType t); + + QList<SinkF> m_innerSinks; + QString m_fileName; + int m_lineNr = 0; + int m_columnNr = 0; // columnNr (starts at 0) of committed data + int m_lineUtf16Offset = 0; // utf16 offset since last newline (what is typically stores as + // SourceLocation::startColumn + int m_currentColumnNr = 0; // current columnNr (starts at 0) + int m_utf16Offset = 0; // utf16 offset since start for committed data + QString m_currentLine; + LineWriterOptions m_options; + PendingSourceLocationIdAtomic m_lastSourceLocationId; + QMap<PendingSourceLocationId, PendingSourceLocation> m_pendingSourceLocations; + QAtomicInt m_lastCallbackId; + QMap<int, std::function<bool(LineWriter &, TextAddType)>> m_textAddCallbacks; + quint32 m_counter = 0; + quint32 m_committedEmptyLines = 0x7FFFFFFF; + bool m_reindent = true; +}; + +} // namespace Dom +} // namespace QQmlJS +QT_END_NAMESPACE +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldommock_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldommock_p.h new file mode 100644 index 0000000000000000000000000000000000000000..af9b1dccadd5493758ef60d7d003e1010174f5aa --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldommock_p.h @@ -0,0 +1,113 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMMOCK_P_H +#define QQMLDOMMOCK_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldomitem_p.h" +#include "qqmldomconstants_p.h" +#include "qqmldomelements_p.h" +#include "qqmldomcomments_p.h" + +#include <QtQml/private/qqmljsast_p.h> +#include <QtQml/private/qqmljsengine_p.h> + +#include <QtCore/QCborValue> +#include <QtCore/QCborMap> +#include <QtCore/QMutexLocker> +#include <QtCore/QPair> + +#include <functional> +#include <limits> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +// mainly for debugging purposes +class MockObject final : public CommentableDomElement +{ +public: + constexpr static DomType kindValue = DomType::MockObject; + DomType kind() const override { return kindValue; } + + MockObject(const Path &pathFromOwner = Path(), QMap<QString, MockObject> subObjects = {}, + QMap<QString, QCborValue> subValues = {}) + : CommentableDomElement(pathFromOwner), subObjects(subObjects), subValues(subValues) + { + } + + MockObject copy() const; + std::pair<QString, MockObject> asStringPair() const; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + + QMap<QString, MockObject> subObjects; + QMap<QString, QCborValue> subValues; +}; + +// mainly for debugging purposes +class MockOwner final : public OwningItem +{ +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override; + +public: + constexpr static DomType kindValue = DomType::MockOwner; + DomType kind() const override { return kindValue; } + + MockOwner(const Path &pathFromTop = Path(), int derivedFrom = 0, + QMap<QString, MockObject> subObjects = {}, QMap<QString, QCborValue> subValues = {}, + QMap<QString, QMap<QString, MockObject>> subMaps = {}, + QMap<QString, QMultiMap<QString, MockObject>> subMultiMaps = {}, + QMap<QString, QList<MockObject>> subLists = {}) + : OwningItem(derivedFrom), + pathFromTop(pathFromTop), + subObjects(subObjects), + subValues(subValues), + subMaps(subMaps), + subMultiMaps(subMultiMaps), + subLists(subLists) + { + } + + MockOwner(const Path &pathFromTop, int derivedFrom, QDateTime dataRefreshedAt, + QMap<QString, MockObject> subObjects = {}, QMap<QString, QCborValue> subValues = {}) + : OwningItem(derivedFrom, dataRefreshedAt), + pathFromTop(pathFromTop), + subObjects(subObjects), + subValues(subValues) + { + } + + MockOwner(const MockOwner &o); + + std::shared_ptr<MockOwner> makeCopy(const DomItem &self) const; + Path canonicalPath(const DomItem &self) const override; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + + Path pathFromTop; + QMap<QString, MockObject> subObjects; + QMap<QString, QCborValue> subValues; + QMap<QString, QMap<QString, MockObject>> subMaps; + QMap<QString, QMultiMap<QString, MockObject>> subMultiMaps; + QMap<QString, QList<MockObject>> subLists; +}; + +} // end namespace Dom +} // end namespace QQmlJS +QT_END_NAMESPACE +#endif // QQMLDOMELEMENTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldommoduleindex_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldommoduleindex_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f119ce436af4e0f85d070bf4ff7de73ae822f9ba --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldommoduleindex_p.h @@ -0,0 +1,141 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMMODULEINDEX_P_H +#define QQMLDOMMODULEINDEX_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldomelements_p.h" + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +class QMLDOM_EXPORT ModuleScope final : public DomBase +{ +public: + constexpr static DomType kindValue = DomType::ModuleScope; + DomType kind() const override { return kindValue; } + + ModuleScope(const QString &uri = QString(), const Version &version = Version()) + : uri(uri), version(version) + { + } + + Path pathFromOwner() const + { + return Path::Field(Fields::moduleScope) + .key(version.isValid() ? QString::number(version.minorVersion) : QString()); + } + Path pathFromOwner(const DomItem &) const override { return pathFromOwner(); } + Path canonicalPath(const DomItem &self) const override + { + return self.owner().canonicalPath().path(pathFromOwner()); + } + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + + QString uri; + Version version; +}; + +class QMLDOM_EXPORT ModuleIndex final : public OwningItem +{ + Q_DECLARE_TR_FUNCTIONS(ModuleIndex); + +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override; + +public: + enum class Status { NotLoaded, Loading, Loaded }; + constexpr static DomType kindValue = DomType::ModuleIndex; + DomType kind() const override { return kindValue; } + + ModuleIndex( + const QString &uri, int majorVersion, int derivedFrom = 0, + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC)) + : OwningItem(derivedFrom, lastDataUpdateAt), m_uri(uri), m_majorVersion(majorVersion) + { + } + + ModuleIndex(const ModuleIndex &o); + + ~ModuleIndex(); + + std::shared_ptr<ModuleIndex> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<ModuleIndex>(doCopy(self)); + } + + Path canonicalPath(const DomItem &) const override + { + return Paths::moduleIndexPath(uri(), majorVersion()); + } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + + QSet<QString> exportNames(const DomItem &self) const; + + QList<DomItem> exportsWithNameAndMinorVersion(const DomItem &self, const QString &name, + int minorVersion) const; + + QString uri() const { return m_uri; } + int majorVersion() const { return m_majorVersion; } + QList<Path> sources() const; + + QList<int> minorVersions() const + { + QMutexLocker l(mutex()); + return m_moduleScope.keys(); + } + ModuleScope *ensureMinorVersion(int minorVersion); + void mergeWith(const std::shared_ptr<ModuleIndex> &o); + void addQmltypeFilePath(const Path &p) + { + QMutexLocker l(mutex()); + if (!m_qmltypesFilesPaths.contains(p)) + m_qmltypesFilesPaths.append(p); + } + + QList<Path> qmldirsToLoad(const DomItem &self); + QList<Path> qmltypesFilesPaths() const + { + QMutexLocker l(mutex()); + return m_qmltypesFilesPaths; + } + QList<Path> qmldirPaths() const + { + QMutexLocker l(mutex()); + return m_qmldirPaths; + } + QList<Path> directoryPaths() const + { + QMutexLocker l(mutex()); + return m_directoryPaths; + } + QList<DomItem> autoExports(const DomItem &self) const; + +private: + QString m_uri; + int m_majorVersion; + + QList<Path> m_qmltypesFilesPaths; + QList<Path> m_qmldirPaths; + QList<Path> m_directoryPaths; + QMap<int, ModuleScope *> m_moduleScope; +}; + +} // end namespace Dom +} // end namespace QQmlJS +QT_END_NAMESPACE +#endif // QQMLDOMMODULEINDEX_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomoutwriter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomoutwriter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3df4d8455b6f4c56aefb2f34af0b5cd847b2761e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomoutwriter_p.h @@ -0,0 +1,164 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMLDOMOUTWRITER_P_H +#define QMLDOMOUTWRITER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldom_fwd_p.h" +#include "qqmldomattachedinfo_p.h" +#include "qqmldomlinewriter_p.h" + +#include <QtCore/QLoggingCategory> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +class QMLDOM_EXPORT OutWriterState +{ +public: + OutWriterState(const Path &itPath, const DomItem &it, const FileLocations::Tree &fLoc); + + void closeState(OutWriter &); + + Path itemCanonicalPath; + DomItem item; + PendingSourceLocationId fullRegionId; + FileLocations::Tree currentMap; + QMap<FileLocationRegion, PendingSourceLocationId> pendingRegions; + QMap<FileLocationRegion, CommentedElement> pendingComments; +}; + +class QMLDOM_EXPORT OutWriter +{ +public: + int indent = 0; + int indenterId = -1; + bool indentNextlines = false; + bool skipComments = false; + LineWriter &lineWriter; + Path currentPath; + FileLocations::Tree topLocation; + QString writtenStr; + UpdatedScriptExpression::Tree reformattedScriptExpressions; + QList<OutWriterState> states; + + explicit OutWriter(LineWriter &lw) + : lineWriter(lw), + topLocation(FileLocations::createTree(Path())), + reformattedScriptExpressions(UpdatedScriptExpression::createTree(Path())) + { + lineWriter.addInnerSink([this](QStringView s) { writtenStr.append(s); }); + indenterId = + lineWriter.addTextAddCallback([this](LineWriter &, LineWriter::TextAddType tt) { + if (indentNextlines && tt == LineWriter::TextAddType::Normal + && QStringView(lineWriter.currentLine()).trimmed().isEmpty()) + lineWriter.setLineIndent(indent); + return true; + }); + } + + OutWriterState &state(int i = 0); + + int increaseIndent(int level = 1) + { + int oldIndent = indent; + indent += lineWriter.options().formatOptions.indentSize * level; + return oldIndent; + } + int decreaseIndent(int level = 1, int expectedIndent = -1) + { + indent -= lineWriter.options().formatOptions.indentSize * level; + Q_ASSERT(expectedIndent < 0 || expectedIndent == indent); + return indent; + } + + void itemStart(const DomItem &it); + void itemEnd(const DomItem &it); + void regionStart(FileLocationRegion region); + void regionEnd(FileLocationRegion regino); + + quint32 counter() const { return lineWriter.counter(); } + OutWriter &writeRegion(FileLocationRegion region, QStringView toWrite); + OutWriter &writeRegion(FileLocationRegion region); + OutWriter &ensureNewline(int nNewlines = 1) + { + lineWriter.ensureNewline(nNewlines); + return *this; + } + OutWriter &ensureSpace() + { + lineWriter.ensureSpace(); + return *this; + } + OutWriter &ensureSpace(QStringView space) + { + lineWriter.ensureSpace(space); + return *this; + } + OutWriter &newline() + { + lineWriter.newline(); + return *this; + } + OutWriter &space() + { + lineWriter.space(); + return *this; + } + OutWriter &write(QStringView v, LineWriter::TextAddType t = LineWriter::TextAddType::Normal) + { + lineWriter.write(v, t); + return *this; + } + OutWriter &write(QStringView v, SourceLocation *toUpdate) + { + lineWriter.write(v, toUpdate); + return *this; + } + void flush() { lineWriter.flush(); } + void eof(bool ensureNewline = true) { lineWriter.eof(ensureNewline); } + int addNewlinesAutospacerCallback(int nLines) + { + return lineWriter.addNewlinesAutospacerCallback(nLines); + } + int addTextAddCallback(std::function<bool(LineWriter &, LineWriter::TextAddType)> callback) + { + return lineWriter.addTextAddCallback(callback); + } + bool removeTextAddCallback(int i) { return lineWriter.removeTextAddCallback(i); } + void addReformattedScriptExpression(const Path &p, const std::shared_ptr<ScriptExpression> &exp) + { + if (auto updExp = UpdatedScriptExpression::ensure(reformattedScriptExpressions, p, + AttachedInfo::PathType::Canonical)) { + updExp->info().expr = exp; + } + } + DomItem restoreWrittenFileItem(const DomItem &fileItem); + +private: + DomItem writtenQmlFileItem(const DomItem &fileItem, const Path &filePath); + DomItem writtenJsFileItem(const DomItem &fileItem, const Path &filePath); + static void logScriptExprUpdateSkipped( + const DomItem &exprItem, const Path &exprPath, + const std::shared_ptr<ScriptExpression> &formattedExpr); +}; + +} // end namespace Dom +} // end namespace QQmlJS + +QT_END_NAMESPACE +#endif // QMLDOMOUTWRITER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldompath_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldompath_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d61840eb1ef8aff99c8f93e9c3e2d9d6ea78f969 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldompath_p.h @@ -0,0 +1,772 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMLDOM_PATH_H +#define QMLDOM_PATH_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldomconstants_p.h" +#include "qqmldomstringdumper_p.h" +#include "qqmldom_global.h" + +#include <QtCore/QCoreApplication> +#include <QtCore/QMetaEnum> +#include <QtCore/QString> +#include <QtCore/QStringView> +#include <QtCore/QStringList> +#include <QtCore/QVector> +#include <QtCore/QDebug> + +#include <functional> +#include <iterator> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +class ErrorGroups; +class ErrorMessage; +class DomItem; +class Path; + +using ErrorHandler = std::function<void(const ErrorMessage &)> ; + +using index_type = qint64; + +namespace PathEls { + +enum class Kind{ + Empty, + Field, + Index, + Key, + Root, + Current, + Any, + Filter +}; + +class TestPaths; +class Empty; +class Field; +class Index; +class Key; +class Root; +class Current; +class Any; +class Filter; + +class Base { +public: + QStringView stringView() const { return QStringView(); } + index_type index(index_type defaultValue = -1) const { return defaultValue; } + bool hasSquareBrackets() const { return false; } + +protected: + void dump(const Sink &sink, const QString &name, bool hasSquareBrackets) const; +}; + +class Empty final : public Base +{ +public: + Empty() = default; + QString name() const { return QString(); } + bool checkName(QStringView s) const { return s.isEmpty(); } + void dump(const Sink &sink) const { Base::dump(sink, name(), hasSquareBrackets()); } +}; + +class Field final : public Base +{ +public: + Field() = default; + Field(QStringView n): fieldName(n) {} + QString name() const { return fieldName.toString(); } + bool checkName(QStringView s) const { return s == fieldName; } + QStringView stringView() const { return fieldName; } + void dump(const Sink &sink) const { sink(fieldName); } + + QStringView fieldName; +}; + +class Index final : public Base +{ +public: + Index() = default; + Index(index_type i): indexValue(i) {} + QString name() const { return QString::number(indexValue); } + bool checkName(QStringView s) const { return s == name(); } + index_type index(index_type = -1) const { return indexValue; } + void dump(const Sink &sink) const { Base::dump(sink, name(), hasSquareBrackets()); } + bool hasSquareBrackets() const { return true; } + + index_type indexValue = -1; +}; + +class Key final : public Base +{ +public: + Key() = default; + Key(const QString &n) : keyValue(n) { } + QString name() const { return keyValue; } + bool checkName(QStringView s) const { return s == keyValue; } + QStringView stringView() const { return keyValue; } + void dump(const Sink &sink) const { + sink(u"["); + sinkEscaped(sink, keyValue); + sink(u"]"); + } + bool hasSquareBrackets() const { return true; } + + QString keyValue; +}; + +class Root final : public Base +{ +public: + Root() = default; + Root(PathRoot r): contextKind(r), contextName() {} + Root(QStringView n) { + QMetaEnum metaEnum = QMetaEnum::fromType<PathRoot>(); + contextKind = PathRoot::Other; + for (int i = 0; i < metaEnum.keyCount(); ++ i) + if (n.compare(QString::fromUtf8(metaEnum.key(i)), Qt::CaseInsensitive) == 0) + contextKind = PathRoot(metaEnum.value(i)); + if (contextKind == PathRoot::Other) + contextName = n; + } + QString name() const { + switch (contextKind) { + case PathRoot::Modules: + return QStringLiteral(u"$modules"); + case PathRoot::Cpp: + return QStringLiteral(u"$cpp"); + case PathRoot::Libs: + return QStringLiteral(u"$libs"); + case PathRoot::Top: + return QStringLiteral(u"$top"); + case PathRoot::Env: + return QStringLiteral(u"$env"); + case PathRoot::Universe: + return QStringLiteral(u"$universe"); + case PathRoot::Other: + return QString::fromUtf8("$").append(contextName.toString()); + } + Q_ASSERT(false && "Unexpected contextKind in name"); + return QString(); + } + bool checkName(QStringView s) const { + if (contextKind != PathRoot::Other) + return s.compare(name(), Qt::CaseInsensitive) == 0; + return s.startsWith(QChar::fromLatin1('$')) && s.mid(1) == contextName; + } + QStringView stringView() const { return contextName; } + void dump(const Sink &sink) const { sink(name()); } + + PathRoot contextKind = PathRoot::Other; + QStringView contextName; +}; + +class Current final : public Base +{ +public: + Current() = default; + Current(PathCurrent c): contextKind(c) {} + Current(QStringView n) { + QMetaEnum metaEnum = QMetaEnum::fromType<PathCurrent>(); + contextKind = PathCurrent::Other; + for (int i = 0; i < metaEnum.keyCount(); ++ i) + if (n.compare(QString::fromUtf8(metaEnum.key(i)), Qt::CaseInsensitive) == 0) + contextKind = PathCurrent(metaEnum.value(i)); + if (contextKind == PathCurrent::Other) + contextName = n; + } + QString name() const { + switch (contextKind) { + case PathCurrent::Other: + return QString::fromUtf8("@").append(contextName.toString()); + case PathCurrent::Obj: + return QStringLiteral(u"@obj"); + case PathCurrent::ObjChain: + return QStringLiteral(u"@objChain"); + case PathCurrent::ScopeChain: + return QStringLiteral(u"@scopeChain"); + case PathCurrent::Component: + return QStringLiteral(u"@component"); + case PathCurrent::Module: + return QStringLiteral(u"@module"); + case PathCurrent::Ids: + return QStringLiteral(u"@ids"); + case PathCurrent::Types: + return QStringLiteral(u"@types"); + case PathCurrent::LookupStrict: + return QStringLiteral(u"@lookupStrict"); + case PathCurrent::LookupDynamic: + return QStringLiteral(u"@lookupDynamic"); + case PathCurrent::Lookup: + return QStringLiteral(u"@lookup"); + } + Q_ASSERT(false && "Unexpected contextKind in Current::name"); + return QString(); + } + bool checkName(QStringView s) const { + if (contextKind != PathCurrent::Other) + return s.compare(name(), Qt::CaseInsensitive) == 0; + return s.startsWith(QChar::fromLatin1('@')) && s.mid(1) == contextName; + } + QStringView stringView() const { return contextName; } + void dump(const Sink &sink) const { Base::dump(sink, name(), hasSquareBrackets()); } + + PathCurrent contextKind = PathCurrent::Other; + QStringView contextName; +}; + +class Any final : public Base +{ +public: + Any() = default; + QString name() const { return QLatin1String("*"); } + bool checkName(QStringView s) const { return s == u"*"; } + void dump(const Sink &sink) const { Base::dump(sink, name(), hasSquareBrackets()); } + bool hasSquareBrackets() const { return true; } +}; + +class QMLDOM_EXPORT Filter final : public Base +{ +public: + Filter() = default; + Filter(const std::function<bool(const DomItem &)> &f, + QStringView filterDescription = u"<native code filter>"); + QString name() const; + bool checkName(QStringView s) const; + QStringView stringView() const { return filterDescription; } + void dump(const Sink &sink) const { Base::dump(sink, name(), hasSquareBrackets()); } + bool hasSquareBrackets() const { return true; } + + std::function<bool(const DomItem &)> filterFunction; + QStringView filterDescription; +}; + +class QMLDOM_EXPORT PathComponent { +public: + PathComponent() = default; + PathComponent(const PathComponent &) = default; + PathComponent(PathComponent &&) = default; + PathComponent &operator=(const PathComponent &) = default; + PathComponent &operator=(PathComponent &&) = default; + ~PathComponent() = default; + + Kind kind() const { return Kind(m_data.index()); } + + QString name() const + { + return std::visit([](auto &&d) { return d.name(); }, m_data); + } + + bool checkName(QStringView s) const + { + return std::visit([s](auto &&d) { return d.checkName(s); }, m_data); + } + + QStringView stringView() const + { + return std::visit([](auto &&d) { return d.stringView(); }, m_data); + } + + index_type index(index_type defaultValue=-1) const + { + return std::visit([defaultValue](auto &&d) { return d.index(defaultValue); }, m_data); + } + + void dump(const Sink &sink) const + { + return std::visit([sink](auto &&d) { return d.dump(sink); }, m_data); + } + + bool hasSquareBrackets() const + { + return std::visit([](auto &&d) { return d.hasSquareBrackets(); }, m_data); + } + + const Empty *asEmpty() const { return std::get_if<Empty>(&m_data); } + const Field *asField() const { return std::get_if<Field>(&m_data); } + const Index *asIndex() const { return std::get_if<Index>(&m_data); } + const Key *asKey() const { return std::get_if<Key>(&m_data); } + const Root *asRoot() const { return std::get_if<Root>(&m_data); } + const Current *asCurrent() const { return std::get_if<Current>(&m_data); } + const Any *asAny() const { return std::get_if<Any>(&m_data); } + const Filter *asFilter() const { return std::get_if<Filter>(&m_data); } + + static int cmp(const PathComponent &p1, const PathComponent &p2); + + PathComponent(Empty &&o): m_data(std::move(o)) {} + PathComponent(Field &&o): m_data(std::move(o)) {} + PathComponent(Index &&o): m_data(std::move(o)) {} + PathComponent(Key &&o): m_data(std::move(o)) {} + PathComponent(Root &&o): m_data(std::move(o)) {} + PathComponent(Current &&o): m_data(std::move(o)) {} + PathComponent(Any &&o): m_data(std::move(o)) {} + PathComponent(Filter &&o): m_data(std::move(o)) {} + +private: + friend class QQmlJS::Dom::Path; + friend class QQmlJS::Dom::PathEls::TestPaths; + + using Variant = std::variant<Empty, Field, Index, Key, Root, Current, Any, Filter>; + + template<typename T, Kind K> + static constexpr bool variantTypeMatches + = std::is_same_v<std::variant_alternative_t<size_t(K), Variant>, T>; + + static_assert(size_t(Kind::Empty) == 0); + static_assert(variantTypeMatches<Empty, Kind::Empty>); + static_assert(variantTypeMatches<Field, Kind::Field>); + static_assert(variantTypeMatches<Key, Kind::Key>); + static_assert(variantTypeMatches<Root, Kind::Root>); + static_assert(variantTypeMatches<Current, Kind::Current>); + static_assert(variantTypeMatches<Any, Kind::Any>); + static_assert(variantTypeMatches<Filter, Kind::Filter>); + static_assert(std::variant_size_v<Variant> == size_t(Kind::Filter) + 1); + + Variant m_data; +}; + +inline bool operator==(const PathComponent& lhs, const PathComponent& rhs){ return PathComponent::cmp(lhs,rhs) == 0; } +inline bool operator!=(const PathComponent& lhs, const PathComponent& rhs){ return PathComponent::cmp(lhs,rhs) != 0; } +inline bool operator< (const PathComponent& lhs, const PathComponent& rhs){ return PathComponent::cmp(lhs,rhs) < 0; } +inline bool operator> (const PathComponent& lhs, const PathComponent& rhs){ return PathComponent::cmp(lhs,rhs) > 0; } +inline bool operator<=(const PathComponent& lhs, const PathComponent& rhs){ return PathComponent::cmp(lhs,rhs) <= 0; } +inline bool operator>=(const PathComponent& lhs, const PathComponent& rhs){ return PathComponent::cmp(lhs,rhs) >= 0; } + +class PathData { +public: + PathData(const QStringList &strData, const QVector<PathComponent> &components) + : strData(strData), components(components) + {} + PathData(const QStringList &strData, const QVector<PathComponent> &components, + const std::shared_ptr<PathData> &parent) + : strData(strData), components(components), parent(parent) + {} + + QStringList strData; + QVector<PathComponent> components; + std::shared_ptr<PathData> parent; +}; + +} // namespace PathEls + +#define QMLDOM_USTRING(s) u##s +#define QMLDOM_FIELD(name) inline constexpr const auto name = QMLDOM_USTRING(#name) +/*! + \internal + In an ideal world, the Fields namespace would be an enum, not strings. + Use FieldType whenever you expect a static String from the Fields namespace instead of an + arbitrary QStringView. + */ +using FieldType = QStringView; +// namespace, so it cam be reopened to add more entries +namespace Fields{ +QMLDOM_FIELD(access); +QMLDOM_FIELD(accessSemantics); +QMLDOM_FIELD(allSources); +QMLDOM_FIELD(alternative); +QMLDOM_FIELD(annotations); +QMLDOM_FIELD(arguments); +QMLDOM_FIELD(astComments); +QMLDOM_FIELD(astRelocatableDump); +QMLDOM_FIELD(attachedType); +QMLDOM_FIELD(attachedTypeName); +QMLDOM_FIELD(autoExports); +QMLDOM_FIELD(base); +QMLDOM_FIELD(binaryExpression); +QMLDOM_FIELD(bindable); +QMLDOM_FIELD(bindingElement); +QMLDOM_FIELD(bindingIdentifiers); +QMLDOM_FIELD(bindingType); +QMLDOM_FIELD(bindings); +QMLDOM_FIELD(block); +QMLDOM_FIELD(body); +QMLDOM_FIELD(callee); +QMLDOM_FIELD(canonicalFilePath); +QMLDOM_FIELD(canonicalPath); +QMLDOM_FIELD(caseBlock); +QMLDOM_FIELD(caseClause); +QMLDOM_FIELD(caseClauses); +QMLDOM_FIELD(catchBlock); +QMLDOM_FIELD(catchParameter); +QMLDOM_FIELD(children); +QMLDOM_FIELD(classNames); +QMLDOM_FIELD(code); +QMLDOM_FIELD(commentedElements); +QMLDOM_FIELD(comments); +QMLDOM_FIELD(components); +QMLDOM_FIELD(condition); +QMLDOM_FIELD(consequence); +QMLDOM_FIELD(contents); +QMLDOM_FIELD(contentsDate); +QMLDOM_FIELD(cppType); +QMLDOM_FIELD(currentExposedAt); +QMLDOM_FIELD(currentIsValid); +QMLDOM_FIELD(currentItem); +QMLDOM_FIELD(currentRevision); +QMLDOM_FIELD(declarations); +QMLDOM_FIELD(defaultClause); +QMLDOM_FIELD(defaultPropertyName); +QMLDOM_FIELD(defaultValue); +QMLDOM_FIELD(designerSupported); +QMLDOM_FIELD(elLocation); +QMLDOM_FIELD(elements); +QMLDOM_FIELD(elementCanonicalPath); +QMLDOM_FIELD(enumerations); +QMLDOM_FIELD(errors); +QMLDOM_FIELD(exportSource); +QMLDOM_FIELD(exports); +QMLDOM_FIELD(expr); +QMLDOM_FIELD(expression); +QMLDOM_FIELD(expressionType); +QMLDOM_FIELD(extensionTypeName); +QMLDOM_FIELD(fileLocationsTree); +QMLDOM_FIELD(fileName); +QMLDOM_FIELD(finallyBlock); +QMLDOM_FIELD(regExpFlags); +QMLDOM_FIELD(forStatement); +QMLDOM_FIELD(fullRegion); +QMLDOM_FIELD(get); +QMLDOM_FIELD(globalScopeName); +QMLDOM_FIELD(globalScopeWithName); +QMLDOM_FIELD(hasCallback); +QMLDOM_FIELD(hasCustomParser); +QMLDOM_FIELD(idStr); +QMLDOM_FIELD(identifier); +QMLDOM_FIELD(ids); +QMLDOM_FIELD(implicit); +QMLDOM_FIELD(import); +QMLDOM_FIELD(importId); +QMLDOM_FIELD(importScope); +QMLDOM_FIELD(importSources); +QMLDOM_FIELD(imported); +QMLDOM_FIELD(imports); +QMLDOM_FIELD(inProgress); +QMLDOM_FIELD(infoItem); +QMLDOM_FIELD(inheritVersion); +QMLDOM_FIELD(initializer); +QMLDOM_FIELD(interfaceNames); +QMLDOM_FIELD(isAlias); +QMLDOM_FIELD(isComposite); +QMLDOM_FIELD(isConstructor); +QMLDOM_FIELD(isCreatable); +QMLDOM_FIELD(isDefaultMember); +QMLDOM_FIELD(isFinal); +QMLDOM_FIELD(isInternal); +QMLDOM_FIELD(isLatest); +QMLDOM_FIELD(isList); +QMLDOM_FIELD(isPointer); +QMLDOM_FIELD(isReadonly); +QMLDOM_FIELD(isRequired); +QMLDOM_FIELD(isSignalHandler); +QMLDOM_FIELD(isSingleton); +QMLDOM_FIELD(isValid); +QMLDOM_FIELD(jsFileWithPath); +QMLDOM_FIELD(kind); +QMLDOM_FIELD(lastRevision); +QMLDOM_FIELD(label); +QMLDOM_FIELD(lastValidRevision); +QMLDOM_FIELD(left); +QMLDOM_FIELD(loadInfo); +QMLDOM_FIELD(loadOptions); +QMLDOM_FIELD(loadPaths); +QMLDOM_FIELD(loadsWithWork); +QMLDOM_FIELD(localOffset); +QMLDOM_FIELD(location); +QMLDOM_FIELD(logicalPath); +QMLDOM_FIELD(majorVersion); +QMLDOM_FIELD(metaRevisions); +QMLDOM_FIELD(methodType); +QMLDOM_FIELD(methods); +QMLDOM_FIELD(minorVersion); +QMLDOM_FIELD(moduleIndex); +QMLDOM_FIELD(moduleIndexWithUri); +QMLDOM_FIELD(moduleScope); +QMLDOM_FIELD(moreCaseClauses); +QMLDOM_FIELD(nAllLoadedCallbacks); +QMLDOM_FIELD(nCallbacks); +QMLDOM_FIELD(nLoaded); +QMLDOM_FIELD(nNotdone); +QMLDOM_FIELD(name); +QMLDOM_FIELD(nameIdentifiers); +QMLDOM_FIELD(newlinesBefore); +QMLDOM_FIELD(nextComponent); +QMLDOM_FIELD(nextScope); +QMLDOM_FIELD(notify); +QMLDOM_FIELD(objects); +QMLDOM_FIELD(onAttachedObject); +QMLDOM_FIELD(operation); +QMLDOM_FIELD(options); +QMLDOM_FIELD(parameters); +QMLDOM_FIELD(parent); +QMLDOM_FIELD(parentObject); +QMLDOM_FIELD(path); +QMLDOM_FIELD(regExpPattern); +QMLDOM_FIELD(plugins); +QMLDOM_FIELD(postCode); +QMLDOM_FIELD(postCommentLocations); +QMLDOM_FIELD(postComments); +QMLDOM_FIELD(pragma); +QMLDOM_FIELD(pragmas); +QMLDOM_FIELD(preCode); +QMLDOM_FIELD(preCommentLocations); +QMLDOM_FIELD(preComments); +QMLDOM_FIELD(properties); +QMLDOM_FIELD(propertyDef); +QMLDOM_FIELD(propertyDefRef); +QMLDOM_FIELD(propertyDefs); +QMLDOM_FIELD(propertyInfos); +QMLDOM_FIELD(propertyName); +QMLDOM_FIELD(prototypes); +QMLDOM_FIELD(qmlDirectoryWithPath); +QMLDOM_FIELD(qmlFileWithPath); +QMLDOM_FIELD(qmlFiles); +QMLDOM_FIELD(qmldirFileWithPath); +QMLDOM_FIELD(qmldirWithPath); +QMLDOM_FIELD(qmltypesFileWithPath); +QMLDOM_FIELD(qmltypesFiles); +QMLDOM_FIELD(qualifiedImports); +QMLDOM_FIELD(rawComment); +QMLDOM_FIELD(read); +QMLDOM_FIELD(referredObject); +QMLDOM_FIELD(referredObjectPath); +QMLDOM_FIELD(regionComments); +QMLDOM_FIELD(regions); +QMLDOM_FIELD(requestedAt); +QMLDOM_FIELD(requestingUniverse); +QMLDOM_FIELD(returnType); +QMLDOM_FIELD(returnTypeName); +QMLDOM_FIELD(right); +QMLDOM_FIELD(rootComponent); +QMLDOM_FIELD(scopeType); +QMLDOM_FIELD(scriptElement); +QMLDOM_FIELD(sources); +QMLDOM_FIELD(statement); +QMLDOM_FIELD(statements); +QMLDOM_FIELD(status); +QMLDOM_FIELD(stringValue); +QMLDOM_FIELD(subComponents); +QMLDOM_FIELD(subImports); +QMLDOM_FIELD(subItems); +QMLDOM_FIELD(symbol); +QMLDOM_FIELD(symbols); +QMLDOM_FIELD(target); +QMLDOM_FIELD(targetPropertyName); +QMLDOM_FIELD(templateLiteral); +QMLDOM_FIELD(text); +QMLDOM_FIELD(type); +QMLDOM_FIELD(typeArgument); +QMLDOM_FIELD(typeArgumentName); +QMLDOM_FIELD(typeName); +QMLDOM_FIELD(types); +QMLDOM_FIELD(universe); +QMLDOM_FIELD(updatedScriptExpressions); +QMLDOM_FIELD(uri); +QMLDOM_FIELD(uris); +QMLDOM_FIELD(validExposedAt); +QMLDOM_FIELD(validItem); +QMLDOM_FIELD(value); +QMLDOM_FIELD(valueTypeName); +QMLDOM_FIELD(values); +QMLDOM_FIELD(version); +QMLDOM_FIELD(when); +QMLDOM_FIELD(write); +} // namespace Fields + +class Source; +size_t qHash(const Path &, size_t); +class PathIterator; +// Define a iterator for it? +// begin() can basically be itself, end() the empty path (zero length), iteration though dropFront() +class QMLDOM_EXPORT Path{ + Q_GADGET + Q_DECLARE_TR_FUNCTIONS(ErrorGroup); +public: + using Kind = PathEls::Kind; + using Component = PathEls::PathComponent; + static ErrorGroups myErrors(); // use static consts and central registration instead? + + Path() = default; + explicit Path(const PathEls::PathComponent &c) : m_endOffset(0), m_length(0) + { + *this = appendComponent(c); + } + + int length() const { return m_length; } + Path operator[](int i) const; + explicit operator bool() const; + + PathIterator begin() const; + PathIterator end() const; + + PathRoot headRoot() const; + PathCurrent headCurrent() const; + Kind headKind() const; + QString headName() const; + bool checkHeadName(QStringView name) const; + index_type headIndex(index_type defaultValue=-1) const; + std::function<bool(const DomItem &)> headFilter() const; + Path head() const; + Path last() const; + Source split() const; + + void dump(const Sink &sink) const; + QString toString() const; + Path dropFront(int n = 1) const; + Path dropTail(int n = 1) const; + Path mid(int offset, int length) const; + Path mid(int offset) const; + Path appendComponent(const PathEls::PathComponent &c); + + // # Path construction + static Path fromString(const QString &s, const ErrorHandler &errorHandler = nullptr); + static Path fromString(QStringView s, const ErrorHandler &errorHandler = nullptr); + static Path Root(PathRoot r); + static Path Root(QStringView s=u""); + static Path Root(const QString &s); + static Path Index(index_type i); + static Path Field(QStringView s=u""); + static Path Field(const QString &s); + static Path Key(QStringView s=u""); + static Path Key(const QString &s); + static Path Current(PathCurrent c); + static Path Current(QStringView s=u""); + static Path Current(const QString &s); + static Path Empty(); + // add + Path empty() const; + Path field(const QString &name) const; + Path field(QStringView name) const; + Path key(const QString &name) const; + Path key(QStringView name) const; + Path index(index_type i) const; + Path any() const; + Path filter(const std::function<bool(const DomItem &)> &, const QString &) const; + Path filter(const std::function<bool(const DomItem &)> &, + QStringView desc=u"<native code filter>") const; + Path current(PathCurrent s) const; + Path current(const QString &s) const; + Path current(QStringView s=u"") const; + Path path(const Path &toAdd, bool avoidToAddAsBase = false) const; + + Path expandFront() const; + Path expandBack() const; + + Path &operator++(); + Path operator ++(int); + + // iterator traits + using difference_type = long; + using value_type = Path; + using pointer = const Component*; + using reference = const Path&; + using iterator_category = std::forward_iterator_tag; + + static int cmp(const Path &p1, const Path &p2); + +private: + const Component &component(int i) const; + explicit Path(quint16 endOffset, quint16 length, + const std::shared_ptr<PathEls::PathData> &data); + friend class QQmlJS::Dom::PathEls::TestPaths; + friend class FieldFilter; + friend size_t qHash(const Path &, size_t); + + Path noEndOffset() const; + + quint16 m_endOffset = 0; + quint16 m_length = 0; + std::shared_ptr<PathEls::PathData> m_data = {}; +}; + +inline bool operator==(const Path &lhs, const Path &rhs) +{ + return lhs.length() == rhs.length() && Path::cmp(lhs, rhs) == 0; +} +inline bool operator!=(const Path &lhs, const Path &rhs) +{ + return lhs.length() != rhs.length() || Path::cmp(lhs, rhs) != 0; +} +inline bool operator<(const Path &lhs, const Path &rhs) +{ + return Path::cmp(lhs, rhs) < 0; +} +inline bool operator>(const Path &lhs, const Path &rhs) +{ + return Path::cmp(lhs, rhs) > 0; +} +inline bool operator<=(const Path &lhs, const Path &rhs) +{ + return Path::cmp(lhs, rhs) <= 0; +} +inline bool operator>=(const Path &lhs, const Path &rhs) +{ + return Path::cmp(lhs, rhs) >= 0; +} + +class PathIterator { +public: + Path currentEl; + Path operator *() const { return currentEl.head(); } + PathIterator operator ++() { currentEl = currentEl.dropFront(); return *this; } + PathIterator operator ++(int) { PathIterator res{currentEl}; currentEl = currentEl.dropFront(); return res; } + bool operator ==(const PathIterator &o) const { return currentEl == o.currentEl; } + bool operator !=(const PathIterator &o) const { return currentEl != o.currentEl; } +}; + +class Source { +public: + Path pathToSource; + Path pathFromSource; +}; + +inline size_t qHash(const Path &path, size_t seed) +{ + const size_t bufSize = 256; + size_t buf[bufSize]; + size_t *it = &buf[0]; + *it++ = path.length(); + if (path.length()>0) { + int iPath = path.length(); + size_t maxPath = bufSize / 2 - 1; + size_t endPath = (size_t(iPath) > maxPath) ? maxPath - iPath : 0; + while (size_t(iPath) > endPath) { + Path p = path[--iPath]; + Path::Kind k = p.headKind(); + *it++ = size_t(k); + *it++ = qHash(p.component(0).stringView(), seed)^size_t(p.headRoot())^size_t(p.headCurrent()); + } + } + + // TODO: Get rid of the reinterpret_cast. + // Rather hash the path components in a more structured way. + return qHash(QByteArray::fromRawData(reinterpret_cast<char *>(&buf[0]), (it - &buf[0])*sizeof(size_t)), seed); +} + +inline QDebug operator<<(QDebug debug, const Path &p) +{ + debug << p.toString(); + return debug; +} + +} // end namespace Dom +} // end namespace QQmlJS + +QT_END_NAMESPACE + +#endif // QMLDOM_PATH_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomreformatter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomreformatter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d93c18fb986e4e4ed38dcbad2563e1862674d046 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomreformatter_p.h @@ -0,0 +1,221 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMREFORMATTER_P +#define QQMLDOMREFORMATTER_P + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" + +#include "qqmldomoutwriter_p.h" +#include "qqmldom_fwd_p.h" +#include "qqmldomcomments_p.h" + +#include <QtQml/private/qqmljsast_p.h> + +QT_BEGIN_NAMESPACE +namespace QQmlJS { +namespace Dom { + +class ScriptFormatter final : protected AST::JSVisitor +{ +public: + // TODO QTBUG-121988 + ScriptFormatter(OutWriter &lw, const std::shared_ptr<AstComments> &comments, + const std::function<QStringView(SourceLocation)> &loc2Str, AST::Node *node) + : lw(lw), comments(comments), loc2Str(loc2Str) + { + accept(node); + } + +protected: + inline void out(const char *str) { lw.write(QString::fromLatin1(str)); } + inline void out(QStringView str) { lw.write(str); } + inline void out(const SourceLocation &loc) + { + if (loc.length != 0) + out(loc2Str(loc)); + } + inline void newLine(quint32 count = 1) { lw.ensureNewline(count); } + + inline void accept(AST::Node *node) { AST::Node::accept(node, this); } + void lnAcceptIndented(AST::Node *node); + bool acceptBlockOrIndented(AST::Node *ast, bool finishWithSpaceOrNewline = false); + + bool preVisit(AST::Node *n) override; + void postVisit(AST::Node *n) override; + + bool visit(AST::ThisExpression *ast) override; + bool visit(AST::NullExpression *ast) override; + bool visit(AST::TrueLiteral *ast) override; + bool visit(AST::FalseLiteral *ast) override; + bool visit(AST::IdentifierExpression *ast) override; + bool visit(AST::StringLiteral *ast) override; + bool visit(AST::NumericLiteral *ast) override; + bool visit(AST::RegExpLiteral *ast) override; + + bool visit(AST::ArrayPattern *ast) override; + + bool visit(AST::ObjectPattern *ast) override; + + bool visit(AST::PatternElementList *ast) override; + + bool visit(AST::PatternPropertyList *ast) override; + bool visit(AST::PatternProperty *property) override; + + bool visit(AST::NestedExpression *ast) override; + bool visit(AST::IdentifierPropertyName *ast) override; + bool visit(AST::StringLiteralPropertyName *ast) override; + bool visit(AST::NumericLiteralPropertyName *ast) override; + + bool visit(AST::TemplateLiteral *ast) override; + bool visit(AST::ArrayMemberExpression *ast) override; + + bool visit(AST::FieldMemberExpression *ast) override; + + bool visit(AST::NewMemberExpression *ast) override; + + bool visit(AST::NewExpression *ast) override; + + bool visit(AST::CallExpression *ast) override; + + bool visit(AST::PostIncrementExpression *ast) override; + + bool visit(AST::PostDecrementExpression *ast) override; + bool visit(AST::PreIncrementExpression *ast) override; + + bool visit(AST::PreDecrementExpression *ast) override; + + bool visit(AST::DeleteExpression *ast) override; + + bool visit(AST::VoidExpression *ast) override; + bool visit(AST::TypeOfExpression *ast) override; + + bool visit(AST::UnaryPlusExpression *ast) override; + + bool visit(AST::UnaryMinusExpression *ast) override; + + bool visit(AST::TildeExpression *ast) override; + + bool visit(AST::NotExpression *ast) override; + + bool visit(AST::BinaryExpression *ast) override; + + bool visit(AST::ConditionalExpression *ast) override; + + bool visit(AST::Block *ast) override; + + bool visit(AST::VariableStatement *ast) override; + + bool visit(AST::PatternElement *ast) override; + + bool visit(AST::EmptyStatement *ast) override; + + bool visit(AST::IfStatement *ast) override; + bool visit(AST::DoWhileStatement *ast) override; + + bool visit(AST::WhileStatement *ast) override; + + bool visit(AST::ForStatement *ast) override; + + bool visit(AST::ForEachStatement *ast) override; + + bool visit(AST::ContinueStatement *ast) override; + bool visit(AST::BreakStatement *ast) override; + + bool visit(AST::ReturnStatement *ast) override; + bool visit(AST::ThrowStatement *ast) override; + bool visit(AST::WithStatement *ast) override; + + bool visit(AST::SwitchStatement *ast) override; + + bool visit(AST::CaseBlock *ast) override; + + bool visit(AST::CaseClause *ast) override; + + bool visit(AST::DefaultClause *ast) override; + + bool visit(AST::LabelledStatement *ast) override; + + bool visit(AST::TryStatement *ast) override; + + bool visit(AST::Catch *ast) override; + + bool visit(AST::Finally *ast) override; + + bool visit(AST::FunctionDeclaration *ast) override; + + bool visit(AST::FunctionExpression *ast) override; + + bool visit(AST::Elision *ast) override; + + bool visit(AST::ArgumentList *ast) override; + + bool visit(AST::StatementList *ast) override; + + bool visit(AST::VariableDeclarationList *ast) override; + + bool visit(AST::CaseClauses *ast) override; + + bool visit(AST::FormalParameterList *ast) override; + + bool visit(AST::SuperLiteral *) override; + bool visit(AST::ComputedPropertyName *) override; + bool visit(AST::Expression *el) override; + bool visit(AST::ExpressionStatement *el) override; + + bool visit(AST::ClassDeclaration *ast) override; + + bool visit(AST::ImportDeclaration *ast) override; + bool visit(AST::ImportSpecifier *ast) override; + bool visit(AST::NameSpaceImport *ast) override; + bool visit(AST::ImportsList *ast) override; + bool visit(AST::NamedImports *ast) override; + bool visit(AST::ImportClause *ast) override; + + bool visit(AST::ExportDeclaration *ast) override; + bool visit(AST::ExportClause *ast) override; + bool visit(AST::ExportSpecifier *ast) override; + bool visit(AST::ExportsList *ast) override; + + bool visit(AST::FromClause *ast) override; + + void endVisit(AST::ComputedPropertyName *) override; + + void endVisit(AST::ExportDeclaration *ast) override; + void endVisit(AST::ExportClause *ast) override; + + void endVisit(AST::ImportDeclaration *ast) override; + void endVisit(AST::NamedImports *ast) override; + + void throwRecursionDepthError() override; + +private: + bool addSemicolons() const { return expressionDepth > 0; } + + OutWriter &lw; + std::shared_ptr<AstComments> comments; + std::function<QStringView(SourceLocation)> loc2Str; + QHash<AST::Node *, QList<std::function<void()>>> postOps; + int expressionDepth = 0; +}; + +QMLDOM_EXPORT void reformatAst( + OutWriter &lw, const std::shared_ptr<AstComments> &comments, + const std::function<QStringView(SourceLocation)> &loc2Str, AST::Node *n); + +} // namespace Dom +} // namespace QQmlJS +QT_END_NAMESPACE + +#endif // QQMLDOMREFORMATTER_P diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomscanner_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomscanner_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0327dd2370e9ae0ab34cc45788082b719d6b3190 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomscanner_p.h @@ -0,0 +1,98 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMSCANNER_P_H +#define QQMLDOMSCANNER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldomstringdumper_p.h" + +#include <QStringList> +#include <QStringView> +#include <QtQml/private/qqmljslexer_p.h> +#include <QtQml/private/qqmljsgrammar_p.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +class QMLDOM_EXPORT Token +{ + Q_GADGET +public: + static bool lexKindIsDelimiter(int kind); + static bool lexKindIsJSKeyword(int kind); + static bool lexKindIsIdentifier(int kind); + static bool lexKindIsStringType(int kind); + static bool lexKindIsInvalid(int kind); + static bool lexKindIsQmlReserved(int kind); + static bool lexKindIsComment(int kind); + + inline Token() = default; + inline Token(int o, int l, int lexKind) : offset(o), length(l), lexKind(lexKind) { } + inline int begin() const { return offset; } + inline int end() const { return offset + length; } + void dump(const Sink &s, QStringView line = QStringView()) const; + QString toString(QStringView line = QStringView()) const + { + return dumperToString([line, this](const Sink &s) { this->dump(s, line); }); + } + + static int compare(const Token &t1, const Token &t2) + { + if (int c = t1.offset - t2.offset) + return c; + if (int c = t1.length - t2.length) + return c; + return int(t1.lexKind) - int(t2.lexKind); + } + + int offset = 0; + int length = 0; + int lexKind = QQmlJSGrammar::T_NONE; +}; + +inline int operator==(const Token &t1, const Token &t2) +{ + return Token::compare(t1, t2) == 0; +} +inline int operator!=(const Token &t1, const Token &t2) +{ + return Token::compare(t1, t2) != 0; +} + +class QMLDOM_EXPORT Scanner +{ +public: + struct QMLDOM_EXPORT State + { + Lexer::State state {}; + bool regexpMightFollow = true; + bool isMultiline() const; + bool isMultilineComment() const; + }; + + QList<Token> operator()(QStringView text, const State &startState); + State state() const; + +private: + bool _qmlMode = true; + State _state; +}; + +} // namespace Dom +} // namespace QQmlJS +QT_END_NAMESPACE +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomscriptelements_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomscriptelements_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b0ce7b4a4e291869353aaf41896ebb98c7329bda --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomscriptelements_p.h @@ -0,0 +1,432 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMSCRIPTELEMENTS_P_H +#define QQMLDOMSCRIPTELEMENTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldomitem_p.h" +#include "qqmldomelements_p.h" +#include "qqmldomattachedinfo_p.h" +#include "qqmldompath_p.h" +#include <algorithm> +#include <limits> +#include <type_traits> +#include <utility> +#include <variant> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +namespace ScriptElements { + +template<DomType type> +class ScriptElementBase : public ScriptElement +{ +public: + using BaseT = ScriptElementBase<type>; + static constexpr DomType kindValue = type; + static constexpr DomKind domKindValue = DomKind::ScriptElement; + + ScriptElementBase(QQmlJS::SourceLocation combinedLocation = QQmlJS::SourceLocation{}) + : ScriptElement(), m_locations({ { FileLocationRegion::MainRegion, combinedLocation } }) + { + } + ScriptElementBase(QQmlJS::SourceLocation first, QQmlJS::SourceLocation last) + : ScriptElementBase(combine(first, last)) + { + } + DomType kind() const override { return type; } + DomKind domKind() const override { return domKindValue; } + + void createFileLocations(const FileLocations::Tree &base) override + { + FileLocations::Tree res = + FileLocations::ensure(base, pathFromOwner(), AttachedInfo::PathType::Relative); + for (auto location: m_locations) { + FileLocations::addRegion(res, location.first, location.second); + } + } + + /* + Pretty prints the current DomItem. Currently, for script elements, this is done entirely on + the parser representation (via the AST classes), but it could be moved here if needed. + */ + // void writeOut(const DomItem &self, OutWriter &lw) const override; + + /*! + All of the following overloads are only required for optimization purposes. + The base implementation will work fine, but might be slightly slower. + You can override dump(), fields(), field(), indexes(), index(), keys() or key() if the + performance of the base class becomes problematic. + */ + + // // needed for debug + // void dump(const DomItem &, const Sink &sink, int indent, FilterT filter) const override; + + // // just required for optimization if iterateDirectSubpaths is slow + // QList<QString> fields(const DomItem &self) const override; + // DomItem field(const DomItem &self, QStringView name) const override; + + // index_type indexes(const DomItem &self) const override; + // DomItem index(const DomItem &self, index_type index) const override; + + // QSet<QString> const keys(const DomItem &self) const override; + // DomItem key(const DomItem &self, const QString &name) const override; + + QQmlJS::SourceLocation mainRegionLocation() const + { + Q_ASSERT(m_locations.size() > 0); + Q_ASSERT(m_locations.front().first == FileLocationRegion::MainRegion); + + auto current = m_locations.front(); + return current.second; + } + void setMainRegionLocation(const QQmlJS::SourceLocation &location) + { + Q_ASSERT(m_locations.size() > 0); + Q_ASSERT(m_locations.front().first == FileLocationRegion::MainRegion); + + m_locations.front().second = location; + } + void addLocation(FileLocationRegion region, QQmlJS::SourceLocation location) + { + Q_ASSERT_X(region != FileLocationRegion::MainRegion, "ScriptElementBase::addLocation", + "use the setCombinedLocation instead!"); + m_locations.emplace_back(region, location); + } + +protected: + std::vector<std::pair<FileLocationRegion, QQmlJS::SourceLocation>> m_locations; +}; + +class ScriptList : public ScriptElementBase<DomType::List> +{ +public: + using typename ScriptElementBase<DomType::List>::BaseT; + + using BaseT::BaseT; + + // minimal required overload for this to be wrapped as DomItem: + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override + { + bool cont = + asList(self.pathFromOwner().key(QString())).iterateDirectSubpaths(self, visitor); + return cont; + } + void updatePathFromOwner(const Path &p) override + { + BaseT::updatePathFromOwner(p); + for (int i = 0; i < m_list.size(); ++i) { + Q_ASSERT(m_list[i].base()); + m_list[i].base()->updatePathFromOwner(p.index(i)); + } + } + void createFileLocations(const FileLocations::Tree &base) override + { + BaseT::createFileLocations(base); + + for (int i = 0; i < m_list.size(); ++i) { + Q_ASSERT(m_list[i].base()); + m_list[i].base()->createFileLocations(base); + } + } + + List asList(const Path &path) const + { + auto asList = List::fromQList<ScriptElementVariant>( + path, m_list, + [](const DomItem &list, const PathEls::PathComponent &, const ScriptElementVariant &wrapped) + -> DomItem { return list.subScriptElementWrapperItem(wrapped); }); + + return asList; + } + + void append(const ScriptElementVariant &statement) { m_list.push_back(statement); } + void append(const ScriptList &list) { m_list.append(list.m_list); } + void reverse() { std::reverse(m_list.begin(), m_list.end()); } + void replaceKindForGenericChildren(DomType oldType, DomType newType); + const QList<ScriptElementVariant> &qList() { return std::as_const(m_list); }; + +private: + QList<ScriptElementVariant> m_list; +}; + +class GenericScriptElement : public ScriptElementBase<DomType::ScriptGenericElement> +{ +public: + using BaseT::BaseT; + using VariantT = std::variant<ScriptElementVariant, ScriptList>; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + void updatePathFromOwner(const Path &p) override; + void createFileLocations(const FileLocations::Tree &base) override; + + DomType kind() const override { return m_kind; } + void setKind(DomType kind) { m_kind = kind; } + + decltype(auto) insertChild(QStringView name, VariantT v) + { + return m_children.insert(std::make_pair(name, v)); + } + + ScriptElementVariant elementChild(const QQmlJS::Dom::FieldType &field) + { + auto it = m_children.find(field); + if (it == m_children.end()) + return {}; + if (!std::holds_alternative<ScriptElementVariant>(it->second)) + return {}; + return std::get<ScriptElementVariant>(it->second); + } + + void insertValue(QStringView name, const QCborValue &v) + { + m_values.insert(std::make_pair(name, v)); + } + + QCborValue value() const override + { + auto it = m_values.find(Fields::value); + if (it == m_values.cend()) + return {}; + + return it->second; + } + +private: + /*! + \internal + The DomItem interface will use iterateDirectSubpaths for all kinds of operations on the + GenericScriptElement. Therefore, to avoid bad surprises when using the DomItem interface, use + a sorted map to always iterate the children in the same order. + */ + std::map<QQmlJS::Dom::FieldType, VariantT> m_children; + // value fields + std::map<QQmlJS::Dom::FieldType, QCborValue> m_values; + DomType m_kind = DomType::Empty; +}; + +class BlockStatement : public ScriptElementBase<DomType::ScriptBlockStatement> +{ +public: + using BaseT::BaseT; + + // minimal required overload for this to be wrapped as DomItem: + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + void updatePathFromOwner(const Path &p) override; + void createFileLocations(const FileLocations::Tree &base) override; + + ScriptList statements() const { return m_statements; } + void setStatements(const ScriptList &statements) { m_statements = statements; } + +private: + ScriptList m_statements; +}; + +class IdentifierExpression : public ScriptElementBase<DomType::ScriptIdentifierExpression> +{ +public: + using BaseT::BaseT; + void setName(QStringView name) { m_name = name.toString(); } + QString name() { return m_name; } + + // minimal required overload for this to be wrapped as DomItem: + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + + QCborValue value() const override { return QCborValue(m_name); } + +private: + QString m_name; +}; + +class Literal : public ScriptElementBase<DomType::ScriptLiteral> +{ +public: + using BaseT::BaseT; + + using VariantT = std::variant<QString, double, bool, std::nullptr_t>; + + void setLiteralValue(VariantT value) { m_value = value; } + VariantT literalValue() const { return m_value; } + + // minimal required overload for this to be wrapped as DomItem: + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + + QCborValue value() const override + { + return std::visit([](auto &&e) -> QCborValue { return e; }, m_value); + } + +private: + VariantT m_value; +}; + +// TODO: test this method + implement foreach etc +class ForStatement : public ScriptElementBase<DomType::ScriptForStatement> +{ +public: + using BaseT::BaseT; + + // minimal required overload for this to be wrapped as DomItem: + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + void updatePathFromOwner(const Path &p) override; + void createFileLocations(const FileLocations::Tree &base) override; + + ScriptElementVariant initializer() const { return m_initializer; } + void setInitializer(const ScriptElementVariant &newInitializer) + { + m_initializer = newInitializer; + } + + ScriptElementVariant declarations() const { return m_declarations; } + void setDeclarations(const ScriptElementVariant &newDeclaration) + { + m_declarations = newDeclaration; + } + ScriptElementVariant condition() const { return m_condition; } + void setCondition(const ScriptElementVariant &newCondition) { m_condition = newCondition; } + ScriptElementVariant expression() const { return m_expression; } + void setExpression(const ScriptElementVariant &newExpression) { m_expression = newExpression; } + ScriptElementVariant body() const { return m_body; } + void setBody(const ScriptElementVariant &newBody) { m_body = newBody; } + +private: + ScriptElementVariant m_initializer; + ScriptElementVariant m_declarations; + ScriptElementVariant m_condition; + ScriptElementVariant m_expression; + ScriptElementVariant m_body; +}; + +class IfStatement : public ScriptElementBase<DomType::ScriptIfStatement> +{ +public: + using BaseT::BaseT; + + // minimal required overload for this to be wrapped as DomItem: + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + void updatePathFromOwner(const Path &p) override; + void createFileLocations(const FileLocations::Tree &base) override; + + ScriptElementVariant condition() const { return m_condition; } + void setCondition(const ScriptElementVariant &condition) { m_condition = condition; } + ScriptElementVariant consequence() { return m_consequence; } + void setConsequence(const ScriptElementVariant &consequence) { m_consequence = consequence; } + ScriptElementVariant alternative() { return m_alternative; } + void setAlternative(const ScriptElementVariant &alternative) { m_alternative = alternative; } + +private: + ScriptElementVariant m_condition; + ScriptElementVariant m_consequence; + ScriptElementVariant m_alternative; +}; + +class ReturnStatement : public ScriptElementBase<DomType::ScriptReturnStatement> +{ +public: + using BaseT::BaseT; + + // minimal required overload for this to be wrapped as DomItem: + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + void updatePathFromOwner(const Path &p) override; + void createFileLocations(const FileLocations::Tree &base) override; + + ScriptElementVariant expression() const { return m_expression; } + void setExpression(ScriptElementVariant expression) { m_expression = expression; } + +private: + ScriptElementVariant m_expression; +}; + +class BinaryExpression : public ScriptElementBase<DomType::ScriptBinaryExpression> +{ +public: + using BaseT::BaseT; + + enum Operator : char { + FieldMemberAccess, + ArrayMemberAccess, + TO_BE_IMPLEMENTED = std::numeric_limits<char>::max(), // not required by qmlls + }; + + // minimal required overload for this to be wrapped as DomItem: + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + void updatePathFromOwner(const Path &p) override; + void createFileLocations(const FileLocations::Tree &base) override; + + ScriptElementVariant left() const { return m_left; } + void setLeft(const ScriptElementVariant &newLeft) { m_left = newLeft; } + ScriptElementVariant right() const { return m_right; } + void setRight(const ScriptElementVariant &newRight) { m_right = newRight; } + int op() const { return m_operator; } + void setOp(Operator op) { m_operator = op; } + +private: + ScriptElementVariant m_left; + ScriptElementVariant m_right; + Operator m_operator = TO_BE_IMPLEMENTED; +}; + +class VariableDeclarationEntry : public ScriptElementBase<DomType::ScriptVariableDeclarationEntry> +{ +public: + using BaseT::BaseT; + + enum ScopeType { Var, Let, Const }; + + ScopeType scopeType() const { return m_scopeType; } + void setScopeType(ScopeType scopeType) { m_scopeType = scopeType; } + + ScriptElementVariant identifier() const { return m_identifier; } + void setIdentifier(const ScriptElementVariant &identifier) { m_identifier = identifier; } + + ScriptElementVariant initializer() const { return m_initializer; } + void setInitializer(const ScriptElementVariant &initializer) { m_initializer = initializer; } + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + void updatePathFromOwner(const Path &p) override; + void createFileLocations(const FileLocations::Tree &base) override; + +private: + ScopeType m_scopeType; + ScriptElementVariant m_identifier; + ScriptElementVariant m_initializer; +}; + +class VariableDeclaration : public ScriptElementBase<DomType::ScriptVariableDeclaration> +{ +public: + using BaseT::BaseT; + + // minimal required overload for this to be wrapped as DomItem: + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor visitor) const override; + void updatePathFromOwner(const Path &p) override; + void createFileLocations(const FileLocations::Tree &base) override; + + void setDeclarations(const ScriptList &list) { m_declarations = list; } + ScriptList declarations() { return m_declarations; } + +private: + ScriptList m_declarations; +}; + +} // namespace ScriptElements +} // end namespace Dom +} // end namespace QQmlJS + +QT_END_NAMESPACE + +#endif // QQMLDOMSCRIPTELEMENTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomstringdumper_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomstringdumper_p.h new file mode 100644 index 0000000000000000000000000000000000000000..604e0e183cf47978ab4890b2c10e9bd205ff0fa1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomstringdumper_p.h @@ -0,0 +1,122 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef DUMPER_H +#define DUMPER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldom_global.h" +#include "qqmldomconstants_p.h" +#include "qqmldomfunctionref_p.h" + +#include <QtCore/QString> +#include <QtCore/QStringView> +#include <QtCore/QDebug> + +#include <type_traits> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +using Sink = function_ref<void(QStringView)>; +using SinkF = std::function<void(QStringView)>; +using DumperFunction = std::function<void(const Sink &)>; + +class Dumper{ +public: + DumperFunction dumper; +private: + // We want to avoid the limit of one user conversion: + // after doing (* -> QStringView) we cannot have QStringView -> Dumper, as it + // would be the second user defined conversion. + // For a similar reason we have a template to accept function_ref<void(Sink)> . + // The end result is that void f(Dumper) can be called nicely, and avoid overloads: + // f(u"bla"), f(QLatin1String("bla")), f(QString()), f([](const Sink &s){...}),... + template <typename T> + using if_compatible_dumper = typename + std::enable_if<std::is_convertible<T, DumperFunction>::value, bool>::type; + + template<typename T> + using if_string_view_convertible = typename + std::enable_if<std::is_convertible_v<T, QStringView>, bool>::type; + +public: + Dumper(QStringView s): + dumper([s](const Sink &sink){ sink(s); }) {} + + Dumper(std::nullptr_t): Dumper(QStringView(nullptr)) {} + + template <typename Stringy, if_string_view_convertible<Stringy> = true> + Dumper(Stringy string): + Dumper(QStringView(string)) {} + + template <typename U, if_compatible_dumper<U> = true> + Dumper(U f): dumper(std::move(f)) {} + + void operator()(const Sink &s) const { dumper(s); } +}; + +template <typename T> +void sinkInt(const Sink &s, T i) { + const int BUFSIZE = 42; // safe up to 128 bits + QChar buf[BUFSIZE]; + int ibuf = BUFSIZE; + buf[--ibuf] = QChar(0); + bool neg = false; + if (i < 0) + neg=true; + int digit = i % 10; + i = i / 10; + if constexpr (std::is_signed_v<T>) { + if (neg) { // we change the sign here because -numeric_limits<T>::min() == numeric_limits<T>::min() + i = -i; + digit = - digit; + } + } + buf[--ibuf] = QChar::fromLatin1('0' + digit); + while (i > 0 && ibuf > 0) { + digit = i % 10; + buf[--ibuf] = QChar::fromLatin1('0' + digit); + i = i / 10; + } + if (neg && ibuf > 0) + buf[--ibuf] = QChar::fromLatin1('-'); + s(QStringView(&buf[ibuf], BUFSIZE - ibuf -1)); +} + +QMLDOM_EXPORT QString dumperToString(const Dumper &writer); + +QMLDOM_EXPORT void sinkEscaped(const Sink &sink, QStringView s, + EscapeOptions options = EscapeOptions::OuterQuotes); + +inline void devNull(QStringView) {} + +QMLDOM_EXPORT void sinkIndent(const Sink &s, int indent); + +QMLDOM_EXPORT void sinkNewline(const Sink &s, int indent = 0); + +QMLDOM_EXPORT void dumpErrorLevel(const Sink &s, ErrorLevel level); + +QMLDOM_EXPORT void dumperToQDebug(const Dumper &dumper, QDebug debug); + +QMLDOM_EXPORT void dumperToQDebug(const Dumper &dumper, ErrorLevel level = ErrorLevel::Debug); + +QMLDOM_EXPORT QDebug operator<<(QDebug d, const Dumper &dumper); + +} // end namespace Dom +} // end namespace QQmlJS +QT_END_NAMESPACE + +#endif // DUMPER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomtop_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomtop_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b97dbf89094dc78162bd6f9c7dbb24621bac0d33 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomtop_p.h @@ -0,0 +1,1133 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef DOMTOP_H +#define DOMTOP_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmldomitem_p.h" +#include "qqmldomelements_p.h" +#include "qqmldomexternalitems_p.h" + +#include <QtCore/QQueue> +#include <QtCore/QString> +#include <QtCore/QDateTime> + +#include <QtCore/QCborValue> +#include <QtCore/QCborMap> + +#include <memory> +#include <optional> + +QT_BEGIN_NAMESPACE + +using namespace Qt::Literals::StringLiterals; + +namespace QQmlJS { +namespace Dom { + +class QMLDOM_EXPORT ExternalItemPairBase: public OwningItem { // all access should have the lock of the DomUniverse containing this + Q_DECLARE_TR_FUNCTIONS(ExternalItemPairBase); +public: + constexpr static DomType kindValue = DomType::ExternalItemPair; + DomType kind() const final override { return kindValue; } + ExternalItemPairBase( + const QDateTime &validExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + const QDateTime ¤tExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + int derivedFrom = 0, + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC)) + : OwningItem(derivedFrom, lastDataUpdateAt), + validExposedAt(validExposedAt), + currentExposedAt(currentExposedAt) + {} + ExternalItemPairBase(const ExternalItemPairBase &o): + OwningItem(o), validExposedAt(o.validExposedAt), currentExposedAt(o.currentExposedAt) + {} + virtual std::shared_ptr<ExternalOwningItem> validItem() const = 0; + virtual DomItem validItem(const DomItem &self) const = 0; + virtual std::shared_ptr<ExternalOwningItem> currentItem() const = 0; + virtual DomItem currentItem(const DomItem &self) const = 0; + + QString canonicalFilePath(const DomItem &) const final override; + Path canonicalPath(const DomItem &self) const final override; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const final override; + DomItem field(const DomItem &self, QStringView name) const final override + { + return OwningItem::field(self, name); + } + + bool currentIsValid() const; + + std::shared_ptr<ExternalItemPairBase> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<ExternalItemPairBase>(doCopy(self)); + } + + QDateTime lastDataUpdateAt() const final override + { + if (currentItem()) + return currentItem()->lastDataUpdateAt(); + return ExternalItemPairBase::lastDataUpdateAt(); + } + + void refreshedDataAt(QDateTime tNew) final override + { + if (currentItem()) + currentItem()->refreshedDataAt(tNew); + return OwningItem::refreshedDataAt(tNew); + } + + friend class DomUniverse; + + QDateTime validExposedAt; + QDateTime currentExposedAt; +}; + +template<class T> +class QMLDOM_EXPORT ExternalItemPair final : public ExternalItemPairBase +{ // all access should have the lock of the DomUniverse containing this +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &) const override + { + return std::make_shared<ExternalItemPair>(*this); + } + +public: + constexpr static DomType kindValue = DomType::ExternalItemPair; + friend class DomUniverse; + ExternalItemPair( + const std::shared_ptr<T> &valid = {}, const std::shared_ptr<T> ¤t = {}, + const QDateTime &validExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + const QDateTime ¤tExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + int derivedFrom = 0, + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC)) + : ExternalItemPairBase(validExposedAt, currentExposedAt, derivedFrom, lastDataUpdateAt), + valid(valid), + current(current) + {} + ExternalItemPair(const ExternalItemPair &o): + ExternalItemPairBase(o), valid(o.valid), current(o.current) + { + } + std::shared_ptr<ExternalOwningItem> validItem() const override { return valid; } + DomItem validItem(const DomItem &self) const override { return self.copy(valid); } + std::shared_ptr<ExternalOwningItem> currentItem() const override { return current; } + DomItem currentItem(const DomItem &self) const override { return self.copy(current); } + std::shared_ptr<ExternalItemPair> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<ExternalItemPair>(doCopy(self)); + } + + std::shared_ptr<T> valid; + std::shared_ptr<T> current; +}; + +class QMLDOM_EXPORT DomTop: public OwningItem { +public: + DomTop(QMap<QString, OwnerT> extraOwningItems = {}, int derivedFrom = 0) + : OwningItem(derivedFrom), m_extraOwningItems(extraOwningItems) + {} + DomTop(const DomTop &o): + OwningItem(o) + { + QMap<QString, OwnerT> items = o.extraOwningItems(); + { + QMutexLocker l(mutex()); + m_extraOwningItems = items; + } + } + using Callback = DomItem::Callback; + + virtual Path canonicalPath() const = 0; + + Path canonicalPath(const DomItem &) const override; + DomItem containingObject(const DomItem &) const override; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + template<typename T> + void setExtraOwningItem(const QString &fieldName, const std::shared_ptr<T> &item) + { + QMutexLocker l(mutex()); + if (!item) + m_extraOwningItems.remove(fieldName); + else + m_extraOwningItems.insert(fieldName, item); + } + + void clearExtraOwningItems(); + QMap<QString, OwnerT> extraOwningItems() const; + +private: + QMap<QString, OwnerT> m_extraOwningItems; +}; + +class QMLDOM_EXPORT DomUniverse final : public DomTop, + public std::enable_shared_from_this<DomUniverse> +{ + Q_GADGET + Q_DECLARE_TR_FUNCTIONS(DomUniverse); +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override; + +public: + constexpr static DomType kindValue = DomType::DomUniverse; + DomType kind() const override { return kindValue; } + + static ErrorGroups myErrors(); + + DomUniverse(const QString &universeName); + DomUniverse(const DomUniverse &) = delete; + static std::shared_ptr<DomUniverse> guaranteeUniverse(const std::shared_ptr<DomUniverse> &univ); + static DomItem create(const QString &universeName); + + Path canonicalPath() const override; + using DomTop::canonicalPath; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + std::shared_ptr<DomUniverse> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<DomUniverse>(doCopy(self)); + } + + // Helper structure reflecting the change in the map once loading && parsing is completed + // formerItem - DomItem representing value (ExternalItemPair) existing in the map before the + // loading && parsing. Might be empty (if didn't exist / failure) or equal to currentItem + // currentItem - DomItem representing current map value + struct LoadResult + { + DomItem formerItem; + DomItem currentItem; + }; + + LoadResult loadFile(const FileToLoad &file, DomType fileType, + DomCreationOptions creationOptions = {}); + + void removePath(const QString &dir); + + std::shared_ptr<ExternalItemPair<GlobalScope>> globalScopeWithName(const QString &name) const + { + QMutexLocker l(mutex()); + return m_globalScopeWithName.value(name); + } + + std::shared_ptr<ExternalItemPair<GlobalScope>> ensureGlobalScopeWithName(const QString &name) + { + if (auto current = globalScopeWithName(name)) + return current; + auto newScope = std::make_shared<GlobalScope>(name); + auto newValue = std::make_shared<ExternalItemPair<GlobalScope>>( + newScope, newScope); + QMutexLocker l(mutex()); + if (auto current = m_globalScopeWithName.value(name)) + return current; + m_globalScopeWithName.insert(name, newValue); + return newValue; + } + + QSet<QString> globalScopeNames() const + { + QMap<QString, std::shared_ptr<ExternalItemPair<GlobalScope>>> map; + { + QMutexLocker l(mutex()); + map = m_globalScopeWithName; + } + return QSet<QString>(map.keyBegin(), map.keyEnd()); + } + + std::shared_ptr<ExternalItemPair<QmlDirectory>> qmlDirectoryWithPath(const QString &path) const + { + QMutexLocker l(mutex()); + return m_qmlDirectoryWithPath.value(path); + } + QSet<QString> qmlDirectoryPaths() const + { + QMap<QString, std::shared_ptr<ExternalItemPair<QmlDirectory>>> map; + { + QMutexLocker l(mutex()); + map = m_qmlDirectoryWithPath; + } + return QSet<QString>(map.keyBegin(), map.keyEnd()); + } + + std::shared_ptr<ExternalItemPair<QmldirFile>> qmldirFileWithPath(const QString &path) const + { + QMutexLocker l(mutex()); + return m_qmldirFileWithPath.value(path); + } + QSet<QString> qmldirFilePaths() const + { + QMap<QString, std::shared_ptr<ExternalItemPair<QmldirFile>>> map; + { + QMutexLocker l(mutex()); + map = m_qmldirFileWithPath; + } + return QSet<QString>(map.keyBegin(), map.keyEnd()); + } + + std::shared_ptr<ExternalItemPair<QmlFile>> qmlFileWithPath(const QString &path) const + { + QMutexLocker l(mutex()); + return m_qmlFileWithPath.value(path); + } + QSet<QString> qmlFilePaths() const + { + QMap<QString, std::shared_ptr<ExternalItemPair<QmlFile>>> map; + { + QMutexLocker l(mutex()); + map = m_qmlFileWithPath; + } + return QSet<QString>(map.keyBegin(), map.keyEnd()); + } + + std::shared_ptr<ExternalItemPair<JsFile>> jsFileWithPath(const QString &path) const + { + QMutexLocker l(mutex()); + return m_jsFileWithPath.value(path); + } + QSet<QString> jsFilePaths() const + { + QMap<QString, std::shared_ptr<ExternalItemPair<JsFile>>> map; + { + QMutexLocker l(mutex()); + map = m_jsFileWithPath; + } + return QSet<QString>(map.keyBegin(), map.keyEnd()); + } + + std::shared_ptr<ExternalItemPair<QmltypesFile>> qmltypesFileWithPath(const QString &path) const + { + QMutexLocker l(mutex()); + return m_qmltypesFileWithPath.value(path); + } + QSet<QString> qmltypesFilePaths() const + { + QMap<QString, std::shared_ptr<ExternalItemPair<QmltypesFile>>> map; + { + QMutexLocker l(mutex()); + map = m_qmltypesFileWithPath; + } + return QSet<QString>(map.keyBegin(), map.keyEnd()); + } + + QString name() const { + return m_name; + } + +private: + struct ContentWithDate + { + QString content; + QDateTime date; + }; + // contains either Content with the timestamp when it was read or an Error + using ReadResult = std::variant<ContentWithDate, ErrorMessage>; + ReadResult readFileContent(const QString &canonicalPath) const; + + LoadResult load(const ContentWithDate &codeWithDate, const FileToLoad &file, DomType fType, + DomCreationOptions creationOptions = {}); + + // contains either Content to be parsed or LoadResult if loading / parsing is not needed + using PreloadResult = std::variant<ContentWithDate, LoadResult>; + PreloadResult preload(const DomItem &univ, const FileToLoad &file, DomType fType) const; + + std::shared_ptr<QmlFile> parseQmlFile(const QString &code, const FileToLoad &file, + const QDateTime &contentDate, + DomCreationOptions creationOptions); + std::shared_ptr<JsFile> parseJsFile(const QString &code, const FileToLoad &file, + const QDateTime &contentDate); + std::shared_ptr<ExternalItemPairBase> getPathValueOrNull(DomType fType, + const QString &path) const; + std::optional<DomItem> getItemIfMostRecent(const DomItem &univ, DomType fType, + const QString &path) const; + std::optional<DomItem> getItemIfHasSameCode(const DomItem &univ, DomType fType, + const QString &canonicalPath, + const ContentWithDate &codeWithDate) const; + static bool valueHasMostRecentItem(const ExternalItemPairBase *value, + const QDateTime &lastModified); + static bool valueHasSameContent(const ExternalItemPairBase *value, const QString &content); + + // TODO better name / consider proper public get/set + template <typename T> + QMap<QString, std::shared_ptr<ExternalItemPair<T>>> &getMutableRefToMap() + { + Q_ASSERT(!mutex()->tryLock()); + if constexpr (std::is_same_v<T, QmlDirectory>) { + return m_qmlDirectoryWithPath; + } + if constexpr (std::is_same_v<T, QmldirFile>) { + return m_qmldirFileWithPath; + } + if constexpr (std::is_same_v<T, QmlFile>) { + return m_qmlFileWithPath; + } + if constexpr (std::is_same_v<T, JsFile>) { + return m_jsFileWithPath; + } + if constexpr (std::is_same_v<T, QmltypesFile>) { + return m_qmltypesFileWithPath; + } + if constexpr (std::is_same_v<T, GlobalScope>) { + return m_globalScopeWithName; + } + Q_UNREACHABLE(); + } + + // Inserts or updates an entry reflecting ExternalItem in the corresponding map + // Returns a pair of: + // - current ExternalItemPair, current value in the map (might be empty, or equal to curValue) + // - new current ExternalItemPair, value in the map after after the execution of this function + template <typename T> + QPair<std::shared_ptr<ExternalItemPair<T>>, std::shared_ptr<ExternalItemPair<T>>> + insertOrUpdateEntry(std::shared_ptr<T> newItem) + { + std::shared_ptr<ExternalItemPair<T>> curValue; + std::shared_ptr<ExternalItemPair<T>> newCurValue; + QString canonicalPath = newItem->canonicalFilePath(); + QDateTime now = QDateTime::currentDateTimeUtc(); + { + QMutexLocker l(mutex()); + auto &map = getMutableRefToMap<T>(); + auto it = map.find(canonicalPath); + if (it != map.cend() && (*it) && (*it)->current) { + curValue = *it; + if (valueHasSameContent(curValue.get(), newItem->code())) { + // value in the map has same content as newItem, a.k.a. most recent + newCurValue = curValue; + if (newCurValue->current->lastDataUpdateAt() < newItem->lastDataUpdateAt()) { + // update timestamp in the current, as if its content was refreshed by + // NewItem + newCurValue->current->refreshedDataAt(newItem->lastDataUpdateAt()); + } + } else if (curValue->current->lastDataUpdateAt() > newItem->lastDataUpdateAt()) { + // value in the map is more recent than newItem, nothing to update + newCurValue = curValue; + } else { + // perform update with newItem + curValue->current = std::move(newItem); + curValue->currentExposedAt = now; + if (curValue->current->isValid()) { + curValue->valid = curValue->current; + curValue->validExposedAt = std::move(now); + } + newCurValue = curValue; + } + } else { + // not found / invalid, just insert + newCurValue = std::make_shared<ExternalItemPair<T>>( + (newItem->isValid() ? newItem : std::shared_ptr<T>()), newItem, now, now); + map.insert(canonicalPath, newCurValue); + } + } + return qMakePair(curValue, newCurValue); + } + + // Inserts or updates an entry reflecting ExternalItem in the corresponding map + // returns LoadResult reflecting the change made to the map + template <typename T> + LoadResult insertOrUpdateExternalItem(std::shared_ptr<T> extItem) + { + auto change = insertOrUpdateEntry<T>(std::move(extItem)); + DomItem univ(shared_from_this()); + return { univ.copy(change.first), univ.copy(change.second) }; + } + +private: + QString m_name; + QMap<QString, std::shared_ptr<ExternalItemPair<GlobalScope>>> m_globalScopeWithName; + QMap<QString, std::shared_ptr<ExternalItemPair<QmlDirectory>>> m_qmlDirectoryWithPath; + QMap<QString, std::shared_ptr<ExternalItemPair<QmldirFile>>> m_qmldirFileWithPath; + QMap<QString, std::shared_ptr<ExternalItemPair<QmlFile>>> m_qmlFileWithPath; + QMap<QString, std::shared_ptr<ExternalItemPair<JsFile>>> m_jsFileWithPath; + QMap<QString, std::shared_ptr<ExternalItemPair<QmltypesFile>>> m_qmltypesFileWithPath; +}; + +class QMLDOM_EXPORT ExternalItemInfoBase: public OwningItem { + Q_DECLARE_TR_FUNCTIONS(ExternalItemInfoBase); +public: + constexpr static DomType kindValue = DomType::ExternalItemInfo; + DomType kind() const final override { return kindValue; } + ExternalItemInfoBase( + const Path &canonicalPath, + const QDateTime ¤tExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + int derivedFrom = 0, + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC)) + : OwningItem(derivedFrom, lastDataUpdateAt), + m_canonicalPath(canonicalPath), + m_currentExposedAt(currentExposedAt) + {} + ExternalItemInfoBase(const ExternalItemInfoBase &o) = default; + + virtual std::shared_ptr<ExternalOwningItem> currentItem() const = 0; + virtual DomItem currentItem(const DomItem &) const = 0; + + QString canonicalFilePath(const DomItem &) const final override; + Path canonicalPath() const { return m_canonicalPath; } + Path canonicalPath(const DomItem &) const final override { return canonicalPath(); } + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const final override; + DomItem field(const DomItem &self, QStringView name) const final override + { + return OwningItem::field(self, name); + } + + int currentRevision(const DomItem &self) const; + int lastRevision(const DomItem &self) const; + int lastValidRevision(const DomItem &self) const; + + std::shared_ptr<ExternalItemInfoBase> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<ExternalItemInfoBase>(doCopy(self)); + } + + QDateTime lastDataUpdateAt() const final override + { + if (currentItem()) + return currentItem()->lastDataUpdateAt(); + return OwningItem::lastDataUpdateAt(); + } + + void refreshedDataAt(QDateTime tNew) final override + { + if (currentItem()) + currentItem()->refreshedDataAt(tNew); + return OwningItem::refreshedDataAt(tNew); + } + + void ensureLogicalFilePath(const QString &path) { + QMutexLocker l(mutex()); + if (!m_logicalFilePaths.contains(path)) + m_logicalFilePaths.append(path); + } + + QDateTime currentExposedAt() const { + QMutexLocker l(mutex()); // should not be needed, as it should not change... + return m_currentExposedAt; + } + + void setCurrentExposedAt(QDateTime d) { + QMutexLocker l(mutex()); // should not be needed, as it should not change... + m_currentExposedAt = d; + } + + + QStringList logicalFilePaths() const { + QMutexLocker l(mutex()); + return m_logicalFilePaths; + } + + private: + friend class DomEnvironment; + Path m_canonicalPath; + QDateTime m_currentExposedAt; + QStringList m_logicalFilePaths; +}; + +template<typename T> +class ExternalItemInfo final : public ExternalItemInfoBase +{ +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &) const override + { + return std::make_shared<ExternalItemInfo>(*this); + } + +public: + constexpr static DomType kindValue = DomType::ExternalItemInfo; + ExternalItemInfo( + const std::shared_ptr<T> ¤t = std::shared_ptr<T>(), + const QDateTime ¤tExposedAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC), + int derivedFrom = 0, + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC)) + : ExternalItemInfoBase(current->canonicalPath().dropTail(), currentExposedAt, derivedFrom, + lastDataUpdateAt), + current(current) + {} + ExternalItemInfo(const QString &canonicalPath) : current(new T(canonicalPath)) { } + ExternalItemInfo(const ExternalItemInfo &o): + ExternalItemInfoBase(o), current(o.current) + { + } + + std::shared_ptr<ExternalItemInfo> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<ExternalItemInfo>(doCopy(self)); + } + + std::shared_ptr<ExternalOwningItem> currentItem() const override { + return current; + } + DomItem currentItem(const DomItem &self) const override { return self.copy(current); } + + std::shared_ptr<T> current; +}; + +class Dependency +{ // internal, should be cleaned, but nobody should use this... +public: + bool operator==(Dependency const &o) const + { + return uri == o.uri && version.majorVersion == o.version.majorVersion + && version.minorVersion == o.version.minorVersion && filePath == o.filePath; + } + QString uri; // either dotted uri or file:, http: https: uri + Version version; + QString filePath; // for file deps + DomType fileType; +}; + +class QMLDOM_EXPORT LoadInfo final : public OwningItem +{ + Q_DECLARE_TR_FUNCTIONS(LoadInfo); + +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override; + +public: + constexpr static DomType kindValue = DomType::LoadInfo; + DomType kind() const override { return kindValue; } + + enum class Status { + NotStarted, // dependencies non checked yet + Starting, // adding deps + InProgress, // waiting for all deps to be loaded + CallingCallbacks, // calling callbacks + Done // fully loaded + }; + + LoadInfo(const Path &elPath = Path(), Status status = Status::NotStarted, int nLoaded = 0, + int derivedFrom = 0, + const QDateTime &lastDataUpdateAt = QDateTime::fromMSecsSinceEpoch(0, QTimeZone::UTC)) + : OwningItem(derivedFrom, lastDataUpdateAt), + m_elementCanonicalPath(elPath), + m_status(status), + m_nLoaded(nLoaded) + { + } + LoadInfo(const LoadInfo &o) : OwningItem(o), m_elementCanonicalPath(o.elementCanonicalPath()) + { + { + QMutexLocker l(o.mutex()); + m_status = o.m_status; + m_nLoaded = o.m_nLoaded; + m_toDo = o.m_toDo; + m_inProgress = o.m_inProgress; + m_endCallbacks = o.m_endCallbacks; + } + } + + Path canonicalPath(const DomItem &self) const override; + + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + std::shared_ptr<LoadInfo> makeCopy(const DomItem &self) const + { + return std::static_pointer_cast<LoadInfo>(doCopy(self)); + } + void addError(const DomItem &self, ErrorMessage &&msg) override + { + self.path(elementCanonicalPath()).addError(std::move(msg)); + } + + void addEndCallback(const DomItem &self, std::function<void(Path, const DomItem &, const DomItem &)> callback); + + void advanceLoad(const DomItem &self); + void finishedLoadingDep(const DomItem &self, const Dependency &d); + void execEnd(const DomItem &self); + + Status status() const + { + QMutexLocker l(mutex()); + return m_status; + } + + int nLoaded() const + { + QMutexLocker l(mutex()); + return m_nLoaded; + } + + Path elementCanonicalPath() const + { + QMutexLocker l(mutex()); // we should never change this, remove lock? + return m_elementCanonicalPath; + } + + int nNotDone() const + { + QMutexLocker l(mutex()); + return m_toDo.size() + m_inProgress.size(); + } + + QList<Dependency> inProgress() const + { + QMutexLocker l(mutex()); + return m_inProgress; + } + + QList<Dependency> toDo() const + { + QMutexLocker l(mutex()); + return m_toDo; + } + + int nCallbacks() const + { + QMutexLocker l(mutex()); + return m_endCallbacks.size(); + } + +private: + void doAddDependencies(const DomItem &self); + void addDependency(const DomItem &self, const Dependency &dep); + + Path m_elementCanonicalPath; + Status m_status; + int m_nLoaded; + QQueue<Dependency> m_toDo; + QList<Dependency> m_inProgress; + QList<std::function<void(Path, const DomItem &, const DomItem &)>> m_endCallbacks; +}; + +enum class EnvLookup { Normal, NoBase, BaseOnly }; + +enum class Changeable { ReadOnly, Writable }; + +class QMLDOM_EXPORT RefCacheEntry +{ + Q_GADGET +public: + enum class Cached { None, First, All }; + Q_ENUM(Cached) + + static RefCacheEntry forPath(const DomItem &el, const Path &canonicalPath); + static bool addForPath(const DomItem &el, const Path &canonicalPath, const RefCacheEntry &entry, + AddOption addOption = AddOption::KeepExisting); + + Cached cached = Cached::None; + QList<Path> canonicalPaths; +}; + +class QMLDOM_EXPORT DomEnvironment final : public DomTop, + public std::enable_shared_from_this<DomEnvironment> +{ + Q_GADGET + Q_DECLARE_TR_FUNCTIONS(DomEnvironment); +protected: + std::shared_ptr<OwningItem> doCopy(const DomItem &self) const override; + +private: + struct TypeReader + { + std::weak_ptr<DomEnvironment> m_env; + + QList<QQmlJS::DiagnosticMessage> + operator()(QQmlJSImporter *importer, const QString &filePath, + const QSharedPointer<QQmlJSScope> &scopeToPopulate); + }; +public: + enum class Option { + Default = 0x0, + KeepValid = 0x1, // if there is a previous valid version, use that instead of the latest + Exported = 0x2, // the current environment is accessible by multiple threads, one should only modify whole OwningItems, and in general load and do other operations in other (Child) environments + NoReload = 0x4, // never reload something that was already loaded by the parent environment + WeakLoad = 0x8, // load only the names of the available types, not the types (qml files) themselves + SingleThreaded = 0x10, // do all operations in a single thread + NoDependencies = 0x20 // will not load dependencies (useful when editing) + }; + Q_ENUM(Option) + Q_DECLARE_FLAGS(Options, Option); + + static ErrorGroups myErrors(); + constexpr static DomType kindValue = DomType::DomEnvironment; + DomType kind() const override; + + Path canonicalPath() const override; + using DomTop::canonicalPath; + bool iterateDirectSubpaths(const DomItem &self, DirectVisitor) const override; + DomItem field(const DomItem &self, QStringView name) const final override; + + std::shared_ptr<DomEnvironment> makeCopy(const DomItem &self) const; + + void loadFile(const FileToLoad &file, const Callback &callback, + std::optional<DomType> fileType = std::optional<DomType>(), + const ErrorHandler &h = nullptr /* used only in loadPendingDependencies*/); + void loadBuiltins(const Callback &callback = nullptr, const ErrorHandler &h = nullptr); + void loadModuleDependency(const QString &uri, Version v, const Callback &callback = nullptr, + const ErrorHandler & = nullptr); + + void removePath(const QString &path); + + std::shared_ptr<DomUniverse> universe() const; + + QSet<QString> moduleIndexUris(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const; + QSet<int> moduleIndexMajorVersions(const DomItem &self, const QString &uri, + EnvLookup lookup = EnvLookup::Normal) const; + std::shared_ptr<ModuleIndex> moduleIndexWithUri(const DomItem &self, const QString &uri, int majorVersion, + EnvLookup lookup, Changeable changeable, + const ErrorHandler &errorHandler = nullptr); + std::shared_ptr<ModuleIndex> moduleIndexWithUri(const DomItem &self, const QString &uri, int majorVersion, + EnvLookup lookup = EnvLookup::Normal) const; + std::shared_ptr<ExternalItemInfo<QmlDirectory>> + qmlDirectoryWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const; + QSet<QString> qmlDirectoryPaths(const DomItem &self, EnvLookup options = EnvLookup::Normal) const; + std::shared_ptr<ExternalItemInfo<QmldirFile>> + qmldirFileWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const; + QSet<QString> qmldirFilePaths(const DomItem &self, EnvLookup options = EnvLookup::Normal) const; + std::shared_ptr<ExternalItemInfoBase> + qmlDirWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const; + QSet<QString> qmlDirPaths(const DomItem &self, EnvLookup options = EnvLookup::Normal) const; + std::shared_ptr<ExternalItemInfo<QmlFile>> + qmlFileWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const; + QSet<QString> qmlFilePaths(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const; + std::shared_ptr<ExternalItemInfo<JsFile>> + jsFileWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const; + QSet<QString> jsFilePaths(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const; + std::shared_ptr<ExternalItemInfo<QmltypesFile>> + qmltypesFileWithPath(const DomItem &self, const QString &path, EnvLookup options = EnvLookup::Normal) const; + QSet<QString> qmltypesFilePaths(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const; + std::shared_ptr<ExternalItemInfo<GlobalScope>> + globalScopeWithName(const DomItem &self, const QString &name, EnvLookup lookup = EnvLookup::Normal) const; + std::shared_ptr<ExternalItemInfo<GlobalScope>> + ensureGlobalScopeWithName(const DomItem &self, const QString &name, EnvLookup lookup = EnvLookup::Normal); + QSet<QString> globalScopeNames(const DomItem &self, EnvLookup lookup = EnvLookup::Normal) const; + + explicit DomEnvironment(const QStringList &loadPaths, Options options = Option::SingleThreaded, + DomCreationOptions domCreationOptions = None, + const std::shared_ptr<DomUniverse> &universe = nullptr); + explicit DomEnvironment(const std::shared_ptr<DomEnvironment> &parent, + const QStringList &loadPaths, Options options = Option::SingleThreaded, + DomCreationOptions domCreationOptions = None); + DomEnvironment(const DomEnvironment &o) = delete; + static std::shared_ptr<DomEnvironment> + create(const QStringList &loadPaths, Options options = Option::SingleThreaded, + DomCreationOptions creationOptions = DomCreationOption::None, + const DomItem &universe = DomItem::empty); + + // TODO AddOption can easily be removed later. KeepExisting option only used in one + // place which will be removed in https://codereview.qt-project.org/c/qt/qtdeclarative/+/523217 + void addQmlFile(const std::shared_ptr<QmlFile> &file, + AddOption option = AddOption::KeepExisting); + void addQmlDirectory(const std::shared_ptr<QmlDirectory> &file, + AddOption option = AddOption::KeepExisting); + void addQmldirFile(const std::shared_ptr<QmldirFile> &file, + AddOption option = AddOption::KeepExisting); + void addQmltypesFile(const std::shared_ptr<QmltypesFile> &file, + AddOption option = AddOption::KeepExisting); + void addJsFile(const std::shared_ptr<JsFile> &file, AddOption option = AddOption::KeepExisting); + void addGlobalScope(const std::shared_ptr<GlobalScope> &file, + AddOption option = AddOption::KeepExisting); + + bool commitToBase( + const DomItem &self, const std::shared_ptr<DomEnvironment> &validEnv = nullptr); + + void addDependenciesToLoad(const Path &path); + void addLoadInfo( + const DomItem &self, const std::shared_ptr<LoadInfo> &loadInfo); + std::shared_ptr<LoadInfo> loadInfo(const Path &path) const; + QList<Path> loadInfoPaths() const; + QHash<Path, std::shared_ptr<LoadInfo>> loadInfos() const; + void loadPendingDependencies(); + bool finishLoadingDependencies(int waitMSec = 30000); + void addWorkForLoadInfo(const Path &elementCanonicalPath); + + Options options() const; + + std::shared_ptr<DomEnvironment> base() const; + + QStringList loadPaths() const; + QStringList qmldirFiles() const; + + QString globalScopeName() const; + + static QList<Import> defaultImplicitImports(); + QList<Import> implicitImports() const; + + void addAllLoadedCallback(const DomItem &self, Callback c); + + void clearReferenceCache(); + void setLoadPaths(const QStringList &v); + + // Helper structure reflecting the change in the map once loading / fetching is completed + // formerItem - DomItem representing value (ExternalItemInfo) existing in the map before the + // loading && parsing. Might be empty (if didn't exist / failure) or equal to currentItem + // currentItem - DomItem representing current map value + struct LoadResult + { + DomItem formerItem; + DomItem currentItem; + }; + // TODO(QTBUG-121171) + template <typename T> + LoadResult insertOrUpdateExternalItemInfo(const QString &path, std::shared_ptr<T> extItem) + { + // maybe in the next revision this all can be just substituted by the addExternalItem + DomItem env(shared_from_this()); + // try to fetch from the current env. + if (auto curValue = lookup<T>(path, EnvLookup::NoBase)) { + // found in the "initial" env + return { env.copy(curValue), env.copy(curValue) }; + } + std::shared_ptr<ExternalItemInfo<T>> newCurValue; + // try to fetch from the base env + auto valueInBase = lookup<T>(path, EnvLookup::BaseOnly); + if (!valueInBase) { + // Nothing found. Just create an externalItemInfo which will be inserted + newCurValue = std::make_shared<ExternalItemInfo<T>>(std::move(extItem), + QDateTime::currentDateTimeUtc()); + } else { + // prepare updated value as a copy of the value from the Base to be inserted + newCurValue = valueInBase->makeCopy(env); + if (newCurValue->current != extItem) { + newCurValue->current = std::move(extItem); + newCurValue->setCurrentExposedAt(QDateTime::currentDateTimeUtc()); + } + } + // Before inserting new or updated value, check one more time, if ItemInfo is already + // present + // lookup<> can't be used here because of the data-race + { + QMutexLocker l(mutex()); + auto &map = getMutableRefToMap<T>(); + const auto &it = map.find(path); + if (it != map.end()) + return { env.copy(*it), env.copy(*it) }; + // otherwise insert + map.insert(path, newCurValue); + } + return { env.copy(valueInBase), env.copy(newCurValue) }; + } + + template <typename T> + void addExternalItemInfo(const DomItem &newExtItem, const Callback &loadCallback, + const Callback &endCallback) + { + // get either Valid "file" from the ExternalItemPair or the current (wip) "file" + std::shared_ptr<T> newItemPtr; + if (options() & DomEnvironment::Option::KeepValid) + newItemPtr = newExtItem.field(Fields::validItem).ownerAs<T>(); + if (!newItemPtr) + newItemPtr = newExtItem.field(Fields::currentItem).ownerAs<T>(); + Q_ASSERT(newItemPtr && "envCallbackForFile reached without current file"); + + auto loadResult = insertOrUpdateExternalItemInfo(newExtItem.canonicalFilePath(), + std::move(newItemPtr)); + Path p = loadResult.currentItem.canonicalPath(); + { + auto depLoad = qScopeGuard([p, this, endCallback] { + addDependenciesToLoad(p); + // add EndCallback to the queue, which should be called once all dependencies are + // loaded + if (endCallback) { + DomItem env = DomItem(shared_from_this()); + addAllLoadedCallback( + env, [p, endCallback](Path, const DomItem &, const DomItem &env) { + DomItem el = env.path(p); + endCallback(p, el, el); + }); + } + }); + // call loadCallback + if (loadCallback) { + loadCallback(p, loadResult.formerItem, loadResult.currentItem); + } + } + } + void populateFromQmlFile(MutableDomItem &&qmlFile); + DomCreationOptions domCreationOptions() const { return m_domCreationOptions; } + +private: + friend class RefCacheEntry; + + void loadFile(const FileToLoad &file, const Callback &loadCallback, const Callback &endCallback, + std::optional<DomType> fileType = std::optional<DomType>(), + const ErrorHandler &h = nullptr); + + void loadModuleDependency(const DomItem &self, const QString &uri, Version v, + Callback loadCallback = nullptr, Callback endCallback = nullptr, + const ErrorHandler & = nullptr); + + template <typename T> + QSet<QString> getStrings(function_ref<QSet<QString>()> getBase, const QMap<QString, T> &selfMap, + EnvLookup lookup) const; + + template <typename T> + const QMap<QString, std::shared_ptr<ExternalItemInfo<T>>> &getConstRefToMap() const + { + Q_ASSERT(!mutex()->tryLock()); + if constexpr (std::is_same_v<T, GlobalScope>) { + return m_globalScopeWithName; + } + if constexpr (std::is_same_v<T, QmlDirectory>) { + return m_qmlDirectoryWithPath; + } + if constexpr (std::is_same_v<T, QmldirFile>) { + return m_qmldirFileWithPath; + } + if constexpr (std::is_same_v<T, QmlFile>) { + return m_qmlFileWithPath; + } + if constexpr (std::is_same_v<T, JsFile>) { + return m_jsFileWithPath; + } + if constexpr (std::is_same_v<T, QmltypesFile>) { + return m_qmltypesFileWithPath; + } + Q_UNREACHABLE(); + } + + template <typename T> + std::shared_ptr<ExternalItemInfo<T>> lookup(const QString &path, EnvLookup options) const + { + if (options != EnvLookup::BaseOnly) { + QMutexLocker l(mutex()); + const auto &map = getConstRefToMap<T>(); + const auto &it = map.find(path); + if (it != map.end()) + return *it; + } + if (options != EnvLookup::NoBase && m_base) + return m_base->lookup<T>(path, options); + return {}; + } + + template <typename T> + QMap<QString, std::shared_ptr<ExternalItemInfo<T>>> &getMutableRefToMap() + { + Q_ASSERT(!mutex()->tryLock()); + if constexpr (std::is_same_v<T, QmlDirectory>) { + return m_qmlDirectoryWithPath; + } + if constexpr (std::is_same_v<T, QmldirFile>) { + return m_qmldirFileWithPath; + } + if constexpr (std::is_same_v<T, QmlFile>) { + return m_qmlFileWithPath; + } + if constexpr (std::is_same_v<T, JsFile>) { + return m_jsFileWithPath; + } + if constexpr (std::is_same_v<T, QmltypesFile>) { + return m_qmltypesFileWithPath; + } + if constexpr (std::is_same_v<T, GlobalScope>) { + return m_globalScopeWithName; + } + Q_UNREACHABLE(); + } + + template <typename T> + void addExternalItem(std::shared_ptr<T> file, QString key, AddOption option) + { + if (!file) + return; + + auto eInfo = std::make_shared<ExternalItemInfo<T>>(file, QDateTime::currentDateTimeUtc()); + // Lookup helper can't be used here, because it introduces data-race otherwise + // (other modifications might happen between the lookup and the insert) + QMutexLocker l(mutex()); + auto &map = getMutableRefToMap<T>(); + const auto &it = map.find(key); + if (it != map.end() && option == AddOption::KeepExisting) + return; + map.insert(key, eInfo); + } + + using FetchResult = + QPair<std::shared_ptr<ExternalItemInfoBase>, std::shared_ptr<ExternalItemInfoBase>>; + // This function tries to get an Info object about the ExternalItem from the current env + // and depending on the result and options tries to fetch it from the Parent env, + // saving a copy with an updated timestamp + template <typename T> + FetchResult fetchFileFromEnvs(const FileToLoad &file) + { + const auto &path = file.canonicalPath(); + // lookup only in the current env + if (auto value = lookup<T>(path, EnvLookup::NoBase)) { + return qMakePair(value, value); + } + // try to find the file in the base(parent) Env and insert if found + if (options() & Option::NoReload) { + if (auto baseV = lookup<T>(path, EnvLookup::BaseOnly)) { + // Watch out! QTBUG-121171 + // It's possible between the lookup and creation of curVal, baseV && baseV->current + // might have changed + // Prepare a value to be inserted as copy of the value from Base + auto curV = std::make_shared<ExternalItemInfo<T>>( + baseV->current, QDateTime::currentDateTimeUtc(), baseV->revision(), + baseV->lastDataUpdateAt()); + // Lookup one more time if the value was already inserted to the current env + // Lookup can't be used here because of the data-race + { + QMutexLocker l(mutex()); + auto &map = getMutableRefToMap<T>(); + const auto &it = map.find(path); + if (it != map.end()) + return qMakePair(*it, *it); + // otherwise insert + map.insert(path, curV); + } + return qMakePair(baseV, curV); + } + } + return qMakePair(nullptr, nullptr); + } + + Callback getLoadCallbackFor(DomType fileType, const Callback &loadCallback); + + std::shared_ptr<ModuleIndex> lookupModuleInEnv(const QString &uri, int majorVersion) const; + // ModuleLookupResult contains the ModuleIndex pointer, and an indicator whether it was found + // in m_base or in m_moduleIndexWithUri + struct ModuleLookupResult { + enum Origin : bool {FromBase, FromGlobal}; + std::shared_ptr<ModuleIndex> module; + Origin fromBase = FromGlobal; + }; + // helper function used by the moduleIndexWithUri methods + ModuleLookupResult moduleIndexWithUriHelper(const DomItem &self, const QString &uri, int majorVersion, + EnvLookup lookup = EnvLookup::Normal) const; + + const Options m_options; + const std::shared_ptr<DomEnvironment> m_base; + std::shared_ptr<DomEnvironment> m_lastValidBase; + const std::shared_ptr<DomUniverse> m_universe; + QStringList m_loadPaths; // paths for qml + QString m_globalScopeName; + QMap<QString, QMap<int, std::shared_ptr<ModuleIndex>>> m_moduleIndexWithUri; + QMap<QString, std::shared_ptr<ExternalItemInfo<GlobalScope>>> m_globalScopeWithName; + QMap<QString, std::shared_ptr<ExternalItemInfo<QmlDirectory>>> m_qmlDirectoryWithPath; + QMap<QString, std::shared_ptr<ExternalItemInfo<QmldirFile>>> m_qmldirFileWithPath; + QMap<QString, std::shared_ptr<ExternalItemInfo<QmlFile>>> m_qmlFileWithPath; + QMap<QString, std::shared_ptr<ExternalItemInfo<JsFile>>> m_jsFileWithPath; + QMap<QString, std::shared_ptr<ExternalItemInfo<QmltypesFile>>> m_qmltypesFileWithPath; + QQueue<Path> m_loadsWithWork; + QQueue<Path> m_inProgress; + QHash<Path, std::shared_ptr<LoadInfo>> m_loadInfos; + QList<Import> m_implicitImports; + QList<Callback> m_allLoadedCallback; + QHash<Path, RefCacheEntry> m_referenceCache; + DomCreationOptions m_domCreationOptions; + + struct SemanticAnalysis + { + SemanticAnalysis(const QStringList &loadPaths); + void updateLoadPaths(const QStringList &loadPaths); + + std::shared_ptr<QQmlJSResourceFileMapper> m_mapper; + std::shared_ptr<QQmlJSImporter> m_importer; + }; + std::optional<SemanticAnalysis> m_semanticAnalysis; +public: + SemanticAnalysis semanticAnalysis(); +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(DomEnvironment::Options) + +} // end namespace Dom +} // end namespace QQmlJS +QT_END_NAMESPACE +#endif // DOMTOP_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomtypesreader_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomtypesreader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..be1e34782c7ff6f7d40ad13886118d2d644f3ab6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlDom/6.8.1/QtQmlDom/private/qqmldomtypesreader_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDOMTYPESREADER_H +#define QQMLDOMTYPESREADER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include "qqmldomexternalitems_p.h" + +#include <QtQml/private/qqmljsastfwd_p.h> + +// for Q_DECLARE_TR_FUNCTIONS +#include <QtCore/qcoreapplication.h> +#include <private/qqmljsmetatypes_p.h> +#include <private/qqmljsscope_p.h> + +QT_BEGIN_NAMESPACE + +namespace QQmlJS { +namespace Dom { + +class QmltypesReader +{ + Q_DECLARE_TR_FUNCTIONS(TypeDescriptionReader) +public: + explicit QmltypesReader(const DomItem &qmltypesFile) + : m_qmltypesFilePtr(qmltypesFile.ownerAs<QmltypesFile>()), m_qmltypesFile(qmltypesFile) + { + } + + bool parse(); + // static void read +private: + void addError(ErrorMessage &&message); + + void insertProperty(const QQmlJSScope::ConstPtr &jsScope, const QQmlJSMetaProperty &property, + QMap<int, QmlObject> &objs); + void insertSignalOrMethod(const QQmlJSMetaMethod &metaMethod, QMap<int, QmlObject> &objs); + void insertComponent(const QQmlJSScope::ConstPtr &jsScope, + const QList<QQmlJSScope::Export> &exportsList); + EnumDecl enumFromMetaEnum(const QQmlJSMetaEnum &metaEnum); + + std::shared_ptr<QmltypesFile> qmltypesFilePtr() { return m_qmltypesFilePtr; } + DomItem &qmltypesFile() { return m_qmltypesFile; } + ErrorHandler handler() + { + return [this](const ErrorMessage &m) { this->addError(ErrorMessage(m)); }; + } + +private: + std::shared_ptr<QmltypesFile> m_qmltypesFilePtr; + DomItem m_qmltypesFile; + Path m_currentPath; +}; + +} // end namespace Dom +} // end namespace QQmlJS +QT_END_NAMESPACE +#endif // QQMLDOMTYPESREADER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qdochtmlparser_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qdochtmlparser_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ddeeda4530f5bbf464d2471955888334308aff3f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qdochtmlparser_p.h @@ -0,0 +1,43 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QDOCHTMLEXTRACTOR_P_H +#define QDOCHTMLEXTRACTOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQmlDom/private/qqmldomtop_p.h> +#include <QString> + +QT_BEGIN_NAMESPACE + +class HtmlExtractor +{ +public: + enum class ExtractionMode : char { Simplified, Extended }; + + virtual QString extract(const QString &code, const QString &keyword, ExtractionMode mode) = 0; + virtual ~HtmlExtractor() = default; +}; + +class ExtractDocumentation +{ +public: + ExtractDocumentation(QQmlJS::Dom::DomType domType); + QString execute(const QString &code, const QString &keyword, HtmlExtractor::ExtractionMode mode); +private: + std::unique_ptr<HtmlExtractor> m_extractor; +}; + +QT_END_NAMESPACE + +#endif // QDOCHTMLEXTRACTOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qlanguageserver_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qlanguageserver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c6b5a335ddad379a47cd049cb943331fb5dc7d42 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qlanguageserver_p.h @@ -0,0 +1,93 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QLANGUAGESERVER_P_H +#define QLANGUAGESERVER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLanguageServer/private/qlanguageserverspec_p.h> +#include <QtLanguageServer/private/qlanguageserverprotocol_p.h> +#include <QtLanguageServer/private/qlspnotifysignals_p.h> +#include <QtCore/qloggingcategory.h> + +QT_BEGIN_NAMESPACE + +class QLanguageServer; +class QLanguageServerPrivate; +Q_DECLARE_LOGGING_CATEGORY(lspServerLog) + +class QLanguageServerModule : public QObject +{ + Q_OBJECT +public: + QLanguageServerModule(QObject *parent = nullptr) : QObject(parent) { } + virtual QString name() const = 0; + virtual void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) = 0; + virtual void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) = 0; +}; + +class QLanguageServer : public QObject +{ + Q_OBJECT + Q_PROPERTY(RunStatus runStatus READ runStatus NOTIFY runStatusChanged) + Q_PROPERTY(bool isInitialized READ isInitialized) +public: + QLanguageServer(const QJsonRpcTransport::DataHandler &h, QObject *parent = nullptr); + enum class RunStatus { + NotSetup, + SettingUp, + DidSetup, + Initializing, + DidInitialize, // normal state of execution + WaitPending, + Stopping, + Stopped + }; + Q_ENUM(RunStatus) + + QLanguageServerProtocol *protocol(); + void finishSetup(); + void registerHandlers(QLanguageServerProtocol *protocol); + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &serverInfo); + void addServerModule(QLanguageServerModule *serverModule); + QLanguageServerModule *moduleByName(const QString &n) const; + QLspNotifySignals *notifySignals(); + + // API + RunStatus runStatus() const; + bool isInitialized() const; + bool isRequestCanceled(const QJsonRpc::IdType &id) const; + const QLspSpecification::InitializeParams &clientInfo() const; + const QLspSpecification::InitializeResult &serverInfo() const; + +public Q_SLOTS: + void receiveData(const QByteArray &d, bool isEndOfMessage); +Q_SIGNALS: + void runStatusChanged(RunStatus); + void clientInitialized(QLanguageServer *server); + void shutdown(); + void exit(); + void lifecycleError(); + void readNextMessage(); + +private: + void registerMethods(QJsonRpc::TypedRpc &typedRpc); + void executeShutdown(); + Q_DECLARE_PRIVATE(QLanguageServer) +}; + +QT_END_NAMESPACE + +#endif // QLANGUAGESERVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qlspcustomtypes_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qlspcustomtypes_p.h new file mode 100644 index 0000000000000000000000000000000000000000..49f2acadf622530d87f49985264111a16053b3eb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qlspcustomtypes_p.h @@ -0,0 +1,56 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QLSPCUSTOMTYPES_P_H +#define QLSPCUSTOMTYPES_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLanguageServer/private/qlanguageserverspec_p.h> + +QT_BEGIN_NAMESPACE + +namespace QLspSpecification { + +class UriToBuildDirs +{ +public: + QByteArray baseUri = {}; + QList<QByteArray> buildDirs = {}; + + template<typename W> + void walk(W &w) + { + field(w, "baseUri", baseUri); + field(w, "buildDirs", buildDirs); + } +}; + +namespace Notifications { +constexpr auto AddBuildDirsMethod = "$/addBuildDirs"; + +class AddBuildDirsParams +{ +public: + QList<UriToBuildDirs> buildDirsToSet = {}; + + template<typename W> + void walk(W &w) + { + field(w, "buildDirsToSet", buildDirsToSet); + } +}; +} // namespace Notifications +} // namespace QLspSpecification + +QT_END_NAMESPACE + +#endif // QLSPCUSTOMTYPES_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlbasemodule_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlbasemodule_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d5b6c7c63d2b8a6a95ce7035a389113af32149c9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlbasemodule_p.h @@ -0,0 +1,267 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLBASEMODULE_P_H +#define QQMLBASEMODULE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlcodemodel_p.h" +#include "qqmllsutils_p.h" +#include <QtQmlDom/private/qqmldom_utils_p.h> + +#include <QObject> +#include <type_traits> +#include <unordered_map> + +template<typename ParametersT, typename ResponseT> +struct BaseRequest +{ + // allow using Parameters and Response type aliases in the + // implementations of the different requests. + using Parameters = ParametersT; + using Response = ResponseT; + + // The version of the code on which the typedefinition request was made. + // Request is received: mark it with the current version of the textDocument. + // Then, wait for the codemodel to finish creating a snapshot version that is newer or equal to + // the textDocument version at request-received-time. + int m_minVersion; + Parameters m_parameters; + Response m_response; + + bool fillFrom(QmlLsp::OpenDocument doc, const Parameters ¶ms, Response &&response); +}; + +/*! +\internal +\brief This class sends a result or an error when going out of scope. + +It has a helper method \c setErrorFrom that sets an error from variant and optionals. +*/ + +template<typename Result, typename ResponseCallback> +struct ResponseScopeGuard +{ + Q_DISABLE_COPY_MOVE(ResponseScopeGuard) + + std::variant<Result *, QQmlLSUtils::ErrorMessage> m_response; + ResponseCallback &m_callback; + + ResponseScopeGuard(Result &results, ResponseCallback &callback) + : m_response(&results), m_callback(callback) + { + } + + // note: discards the current result or error message, if there is any + void setError(const QQmlLSUtils::ErrorMessage &error) { m_response = error; } + + template<typename... T> + bool setErrorFrom(const std::variant<T...> &variant) + { + static_assert(std::disjunction_v<std::is_same<T, QQmlLSUtils::ErrorMessage>...>, + "ResponseScopeGuard::setErrorFrom was passed a variant that never contains" + " an error message."); + if (auto x = std::get_if<QQmlLSUtils::ErrorMessage>(&variant)) { + setError(*x); + return true; + } + return false; + } + + /*! + \internal + Note: use it as follows: + \badcode + if (scopeGuard.setErrorFrom(xxx)) { + // do early exit + } + // xxx was not an error, continue + \endcode + */ + bool setErrorFrom(const std::optional<QQmlLSUtils::ErrorMessage> &error) + { + if (error) { + setError(*error); + return true; + } + return false; + } + + ~ResponseScopeGuard() + { + std::visit(qOverloadedVisitor{ [this](Result *result) { m_callback.sendResponse(*result); }, + [this](const QQmlLSUtils::ErrorMessage &error) { + m_callback.sendErrorResponse(error.code, + error.message.toUtf8()); + } }, + m_response); + } +}; + +template<typename RequestType> +struct QQmlBaseModule : public QLanguageServerModule +{ + using RequestParameters = typename RequestType::Parameters; + using RequestResponse = typename RequestType::Response; + using RequestPointer = std::unique_ptr<RequestType>; + using RequestPointerArgument = RequestPointer &&; + using BaseT = QQmlBaseModule<RequestType>; + + QQmlBaseModule(QmlLsp::QQmlCodeModel *codeModel); + ~QQmlBaseModule(); + + void requestHandler(const RequestParameters ¶meters, RequestResponse &&response); + decltype(auto) getRequestHandler(); + // processes a request in a different thread. + virtual void process(RequestPointerArgument toBeProcessed) = 0; + std::variant<QList<QQmlLSUtils::ItemLocation>, QQmlLSUtils::ErrorMessage> + itemsForRequest(const RequestPointer &request); + +public Q_SLOTS: + void updatedSnapshot(const QByteArray &uri); + +protected: + QMutex m_pending_mutex; + std::unordered_multimap<QString, RequestPointer> m_pending; + QmlLsp::QQmlCodeModel *m_codeModel; +}; + +template<typename Parameters, typename Response> +bool BaseRequest<Parameters, Response>::fillFrom(QmlLsp::OpenDocument doc, const Parameters ¶ms, + Response &&response) +{ + Q_UNUSED(doc); + m_parameters = params; + m_response = std::move(response); + + if (!doc.textDocument) { + qDebug() << "Cannot find document in qmlls's codemodel, did you open it before accessing " + "it?"; + return false; + } + + { + QMutexLocker l(doc.textDocument->mutex()); + m_minVersion = doc.textDocument->version().value_or(0); + } + return true; +} + +template<typename RequestType> +QQmlBaseModule<RequestType>::QQmlBaseModule(QmlLsp::QQmlCodeModel *codeModel) + : m_codeModel(codeModel) +{ + QObject::connect(m_codeModel, &QmlLsp::QQmlCodeModel::updatedSnapshot, this, + &QQmlBaseModule<RequestType>::updatedSnapshot); +} + +template<typename RequestType> +QQmlBaseModule<RequestType>::~QQmlBaseModule() +{ + QMutexLocker l(&m_pending_mutex); + m_pending.clear(); // empty the m_pending while the mutex is hold +} + +template<typename RequestType> +decltype(auto) QQmlBaseModule<RequestType>::getRequestHandler() +{ + auto handler = [this](const QByteArray &, const RequestParameters ¶meters, + RequestResponse &&response) { + requestHandler(parameters, std::move(response)); + }; + return handler; +} + +template<typename RequestType> +void QQmlBaseModule<RequestType>::requestHandler(const RequestParameters ¶meters, + RequestResponse &&response) +{ + auto req = std::make_unique<RequestType>(); + QmlLsp::OpenDocument doc = m_codeModel->openDocumentByUrl( + QQmlLSUtils::lspUriToQmlUrl(parameters.textDocument.uri)); + + if (!req->fillFrom(doc, parameters, std::move(response))) { + req->m_response.sendErrorResponse(0, "Received invalid request", parameters); + return; + } + const int minVersion = req->m_minVersion; + { + QMutexLocker l(&m_pending_mutex); + m_pending.insert({ QString::fromUtf8(req->m_parameters.textDocument.uri), std::move(req) }); + } + + if (doc.snapshot.docVersion && *doc.snapshot.docVersion >= minVersion) + updatedSnapshot(QQmlLSUtils::lspUriToQmlUrl(parameters.textDocument.uri)); +} + +template<typename RequestType> +void QQmlBaseModule<RequestType>::updatedSnapshot(const QByteArray &url) +{ + QmlLsp::OpenDocumentSnapshot doc = m_codeModel->snapshotByUrl(url); + std::vector<RequestPointer> toCompl; + { + QMutexLocker l(&m_pending_mutex); + for (auto [it, end] = m_pending.equal_range(QString::fromUtf8(url)); it != end;) { + if (auto &[key, value] = *it; + doc.docVersion && value->m_minVersion <= *doc.docVersion) { + toCompl.push_back(std::move(value)); + it = m_pending.erase(it); + } else { + ++it; + } + } + } + for (auto it = toCompl.rbegin(), end = toCompl.rend(); it != end; ++it) { + process(std::move(*it)); + } +} + +template<typename RequestType> +std::variant<QList<QQmlLSUtils::ItemLocation>, QQmlLSUtils::ErrorMessage> +QQmlBaseModule<RequestType>::itemsForRequest(const RequestPointer &request) +{ + + QmlLsp::OpenDocument doc = m_codeModel->openDocumentByUrl( + QQmlLSUtils::lspUriToQmlUrl(request->m_parameters.textDocument.uri)); + + if (!doc.snapshot.validDocVersion || doc.snapshot.validDocVersion != doc.snapshot.docVersion) { + return QQmlLSUtils::ErrorMessage{ 0, + u"Cannot proceed: current QML document is invalid! Fix" + u" all the errors in your QML code and try again."_s }; + } + + QQmlJS::Dom::DomItem file = doc.snapshot.validDoc.fileObject(QQmlJS::Dom::GoTo::MostLikely); + // clear reference cache to resolve latest versions (use a local env instead?) + if (auto envPtr = file.environment().ownerAs<QQmlJS::Dom::DomEnvironment>()) + envPtr->clearReferenceCache(); + if (!file) { + return QQmlLSUtils::ErrorMessage{ + 0, + u"Could not find file %1 in project."_s.arg(doc.snapshot.doc.toString()), + }; + } + + auto itemsFound = QQmlLSUtils::itemsFromTextLocation(file, request->m_parameters.position.line, + request->m_parameters.position.character); + + if (itemsFound.isEmpty()) { + return QQmlLSUtils::ErrorMessage{ + 0, + u"Could not find any items at given text location."_s, + }; + } + return itemsFound; +} + +#endif // QQMLBASEMODULE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlcodemodel_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlcodemodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2d5499b187273ed47b92bdf8bd5fbaa098aad2a2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlcodemodel_p.h @@ -0,0 +1,181 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCODEMODEL_P_H +#define QQMLCODEMODEL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qtextdocument_p.h" + +#include <QObject> +#include <QHash> +#include <QtCore/qfilesystemwatcher.h> +#include <QtCore/private/qfactoryloader_p.h> +#include <QtQmlDom/private/qqmldomitem_p.h> +#include <QtQmlCompiler/private/qqmljsscope_p.h> +#include <QtQmlToolingSettings/private/qqmltoolingsettings_p.h> + +#include <functional> +#include <memory> + +QT_BEGIN_NAMESPACE +class TextSynchronization; +namespace QmlLsp { + +class OpenDocumentSnapshot +{ +public: + enum class DumpOption { + NoCode = 0, + LatestCode = 0x1, + ValidCode = 0x2, + AllCode = LatestCode | ValidCode + }; + Q_DECLARE_FLAGS(DumpOptions, DumpOption) + QStringList searchPath; + QByteArray url; + std::optional<int> docVersion; + QQmlJS::Dom::DomItem doc; + std::optional<int> validDocVersion; + QQmlJS::Dom::DomItem validDoc; + std::optional<int> scopeVersion; + QDateTime scopeDependenciesLoadTime; + bool scopeDependenciesChanged = false; + QQmlJSScope::ConstPtr scope; + QDebug dump(QDebug dbg, DumpOptions dump = DumpOption::NoCode); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(OpenDocumentSnapshot::DumpOptions) + +class OpenDocument +{ +public: + OpenDocumentSnapshot snapshot; + std::shared_ptr<Utils::TextDocument> textDocument; +}; + +struct ToIndex +{ + QString path; + int leftDepth; +}; + +struct RegisteredSemanticTokens +{ + QByteArray resultId = "0"; + QList<int> lastTokens; +}; + +class QQmlCodeModel : public QObject +{ + Q_OBJECT +public: + enum class UrlLookup { Caching, ForceLookup }; + enum class State { Running, Stopping }; + + explicit QQmlCodeModel(QObject *parent = nullptr, QQmlToolingSettings *settings = nullptr); + ~QQmlCodeModel(); + QQmlJS::Dom::DomItem currentEnv() const { return m_currentEnv; }; + QQmlJS::Dom::DomItem validEnv() const { return m_validEnv; }; + OpenDocumentSnapshot snapshotByUrl(const QByteArray &url); + OpenDocument openDocumentByUrl(const QByteArray &url); + + void openNeedUpdate(); + void indexNeedsUpdate(); + void addDirectoriesToIndex(const QStringList &paths, QLanguageServer *server); + void addOpenToUpdate(const QByteArray &); + void removeDirectory(const QString &path); + // void updateDocument(const OpenDocument &doc); + QString url2Path(const QByteArray &url, UrlLookup options = UrlLookup::Caching); + void newOpenFile(const QByteArray &url, int version, const QString &docText); + void newDocForOpenFile(const QByteArray &url, int version, const QString &docText); + void closeOpenFile(const QByteArray &url); + void setRootUrls(const QList<QByteArray> &urls); + QList<QByteArray> rootUrls() const; + void addRootUrls(const QList<QByteArray> &urls); + QStringList buildPathsForRootUrl(const QByteArray &url); + QStringList buildPathsForFileUrl(const QByteArray &url); + void setBuildPathsForRootUrl(QByteArray url, const QStringList &paths); + QStringList importPaths() const { return m_importPaths; }; + void setImportPaths(const QStringList &paths) { m_importPaths = paths; }; + void removeRootUrls(const QList<QByteArray> &urls); + QQmlToolingSettings *settings() const { return m_settings; } + QStringList findFilePathsFromFileNames(const QStringList &fileNames); + static QStringList fileNamesToWatch(const QQmlJS::Dom::DomItem &qmlFile); + void disableCMakeCalls(); + const QFactoryLoader &pluginLoader() const { return m_pluginLoader; } + + RegisteredSemanticTokens ®isteredTokens(); + const RegisteredSemanticTokens ®isteredTokens() const; + QString documentationRootPath() const { return m_documentationRootPath; } + void setDocumentationRootPath(const QString &path); + + QSet<QString> ignoreForWatching() const { return m_ignoreForWatching; } + +Q_SIGNALS: + void updatedSnapshot(const QByteArray &url); + void documentationRootPathChanged(const QString &path); + +private: + void indexDirectory(const QString &path, int depthLeft); + int indexEvalProgress() const; // to be called in the mutex + void indexStart(); // to be called in the mutex + void indexEnd(); // to be called in the mutex + void indexSendProgress(int progress); + bool indexCancelled(); + bool indexSome(); + void addDirectory(const QString &path, int leftDepth); + bool openUpdateSome(); + void openUpdateStart(); + void openUpdateEnd(); + void openUpdate(const QByteArray &); + + static bool callCMakeBuild(const QStringList &buildPaths); + void addFileWatches(const QQmlJS::Dom::DomItem &qmlFile); + enum CMakeStatus { RequiresInitialization, HasCMake, DoesNotHaveCMake }; + void initializeCMakeStatus(const QString &); + + mutable QMutex m_mutex; + State m_state = State::Running; + int m_lastIndexProgress = 0; + int m_nIndexInProgress = 0; + QList<ToIndex> m_toIndex; + int m_indexInProgressCost = 0; + int m_indexDoneCost = 0; + int m_nUpdateInProgress = 0; + QStringList m_importPaths; + QQmlJS::Dom::DomItem m_currentEnv; + QQmlJS::Dom::DomItem m_validEnv; + QByteArray m_lastOpenDocumentUpdated; + QSet<QByteArray> m_openDocumentsToUpdate; + QHash<QByteArray, QStringList> m_buildPathsForRootUrl; + QList<QByteArray> m_rootUrls; + QHash<QByteArray, QString> m_url2path; + QHash<QString, QByteArray> m_path2url; + QHash<QByteArray, OpenDocument> m_openDocuments; + QQmlToolingSettings *m_settings; + QFileSystemWatcher m_cppFileWatcher; + QFactoryLoader m_pluginLoader; + bool m_rebuildRequired = true; // always trigger a rebuild on start + CMakeStatus m_cmakeStatus = RequiresInitialization; + RegisteredSemanticTokens m_tokens; + QString m_documentationRootPath; + QSet<QString> m_ignoreForWatching; +private slots: + void onCppFileChanged(const QString &); +}; + +} // namespace QmlLsp +QT_END_NAMESPACE +#endif // QQMLCODEMODEL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlcompletioncontextstrings_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlcompletioncontextstrings_p.h new file mode 100644 index 0000000000000000000000000000000000000000..79f4d2d530f163fbf77e39fc299599838f7743b8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlcompletioncontextstrings_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLSCOMPLETIONCONTEXTSTRINGS_H +#define QQMLLSCOMPLETIONCONTEXTSTRINGS_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qtconfigmacros.h> +#include <QtCore/qstring.h> +#include <QtCore/qstringview.h> + +QT_BEGIN_NAMESPACE + +// finds the filter string, the base (for fully qualified accesses) and the whole string +// just before pos in code +struct CompletionContextStrings +{ + CompletionContextStrings(QString code, qsizetype pos); + +public: + // line up until pos + QStringView preLine() const + { + return QStringView(m_code).mid(m_lineStart, m_pos - m_lineStart); + } + // the part used to filter the completion (normally actual filtering is left to the client) + QStringView filterChars() const + { + return QStringView(m_code).mid(m_filterStart, m_pos - m_filterStart); + } + // the base part (qualified access) + QStringView base() const + { + return QStringView(m_code).mid(m_baseStart, m_filterStart - m_baseStart); + } + // if we are at line start + bool atLineStart() const { return m_atLineStart; } + + qsizetype offset() const { return m_pos; } + +private: + QString m_code; // the current code + qsizetype m_pos = {}; // current position of the cursor + qsizetype m_filterStart = {}; // start of the characters that are used to filter the suggestions + qsizetype m_lineStart = {}; // start of the current line + qsizetype m_baseStart = {}; // start of the dotted expression that ends at the cursor position + bool m_atLineStart = {}; // if there are only spaces before base +}; + +QT_END_NAMESPACE + +#endif // QQMLLSCOMPLETIONCONTEXTSTRINGS_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlcompletionsupport_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlcompletionsupport_p.h new file mode 100644 index 0000000000000000000000000000000000000000..77c6e070d1604874833a13d2ad67cc776e9df070 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlcompletionsupport_p.h @@ -0,0 +1,61 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCOMPLETIONSUPPORT_P_H +#define QQMLCOMPLETIONSUPPORT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlbasemodule_p.h" +#include "qqmlcodemodel_p.h" + +#include <QtCore/qmutex.h> +#include <QtCore/qhash.h> +#include <QtQmlLS/private/qqmllscompletion_p.h> + +QT_BEGIN_NAMESPACE +struct CompletionRequest + : BaseRequest<QLspSpecification::CompletionParams, + QLspSpecification::LSPPartialResponse< + std::variant<QList<QLspSpecification::CompletionItem>, + QLspSpecification::CompletionList, std::nullptr_t>, + std::variant<QLspSpecification::CompletionList, + QList<QLspSpecification::CompletionItem>>>> +{ + QString code; + + bool fillFrom(QmlLsp::OpenDocument doc, const Parameters ¶ms, Response &&response); + void sendCompletions(const QList<QLspSpecification::CompletionItem> &completions); + QString urlAndPos() const; + QList<QLspSpecification::CompletionItem> + completions(QmlLsp::OpenDocumentSnapshot &doc, const QQmlLSCompletion &completionEngine) const; + QQmlJS::Dom::DomItem patchInvalidFileForParser(const QQmlJS::Dom::DomItem &file, + qsizetype position) const; +}; + +class QmlCompletionSupport : public QQmlBaseModule<CompletionRequest> +{ + Q_OBJECT +public: + QmlCompletionSupport(QmlLsp::QQmlCodeModel *codeModel); + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; + void process(RequestPointerArgument req) override; + + QQmlLSCompletion m_completionEngine; +}; +QT_END_NAMESPACE + +#endif // QMLCOMPLETIONSUPPORT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlfindusagessupport_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlfindusagessupport_p.h new file mode 100644 index 0000000000000000000000000000000000000000..adab39b80a0f60164a7cbdc819fcb6abf1f42f7d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlfindusagessupport_p.h @@ -0,0 +1,47 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMLFINDUSAGESUPPORT_P_H +#define QMLFINDUSAGESUPPORT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlcodemodel_p.h" +#include "qqmlbasemodule_p.h" + +QT_BEGIN_NAMESPACE +struct ReferencesRequest : public BaseRequest<QLspSpecification::ReferenceParams, + QLspSpecification::Responses::ReferenceResponseType> +{ +}; + +class QQmlFindUsagesSupport : public QQmlBaseModule<ReferencesRequest> +{ + Q_OBJECT +public: + QQmlFindUsagesSupport(QmlLsp::QQmlCodeModel *codeModel); + + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; + + void process(RequestPointerArgument request) override; + + void typeDefinitionRequestHandler(const QByteArray &, + const QLspSpecification::TypeDefinitionParams ¶ms, + ReferencesRequest::Response &&response); +}; +QT_END_NAMESPACE + +#endif // QMLFINDUSAGESUPPORT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlformatting_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlformatting_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d4a420e04bef36710e32151d2229b0e1c3091673 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlformatting_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLFORMATTING_P_H +#define QQMLFORMATTING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlbasemodule_p.h" +#include "qqmlcodemodel_p.h" + +QT_BEGIN_NAMESPACE + +struct DocumentFormattingRequest + : public BaseRequest<QLspSpecification::DocumentFormattingParams, + QLspSpecification::Responses::DocumentFormattingResponseType> +{ +}; + +class QQmlDocumentFormatting : public QQmlBaseModule<DocumentFormattingRequest> +{ + Q_OBJECT +public: + QQmlDocumentFormatting(QmlLsp::QQmlCodeModel *codeModel); + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; + void process(RequestPointerArgument req) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLFORMATTING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlgotodefinitionsupport_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlgotodefinitionsupport_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e88f3b966764b2ece30e99ad140f8ac44a52475a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlgotodefinitionsupport_p.h @@ -0,0 +1,49 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLGOTODEFINITIONSUPPORT_P_H +#define QQMLGOTODEFINITIONSUPPORT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlcodemodel_p.h" +#include "qqmlbasemodule_p.h" + +QT_BEGIN_NAMESPACE + +struct DefinitionRequest : public BaseRequest<QLspSpecification::DefinitionParams, + QLspSpecification::Responses::DefinitionResponseType> +{ +}; + +class QmlGoToDefinitionSupport : public QQmlBaseModule<DefinitionRequest> +{ + Q_OBJECT +public: + QmlGoToDefinitionSupport(QmlLsp::QQmlCodeModel *codeModel); + + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; + + void process(RequestPointerArgument request) override; + + void typeDefinitionRequestHandler(const QByteArray &, + const QLspSpecification::DefinitionParams ¶ms, + RequestPointerArgument response); +}; + +QT_END_NAMESPACE + +#endif // QQMLGOTODEFINITIONSUPPORT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlgototypedefinitionsupport_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlgototypedefinitionsupport_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6ebe6267bad606de79dd4de9c0d620b334398bb9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlgototypedefinitionsupport_p.h @@ -0,0 +1,50 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMLGOTOTYPEDEFINITIONSUPPORT_P_H +#define QMLGOTOTYPEDEFINITIONSUPPORT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlcodemodel_p.h" +#include "qqmlbasemodule_p.h" + +QT_BEGIN_NAMESPACE + +struct TypeDefinitionRequest + : public BaseRequest<QLspSpecification::TypeDefinitionParams, + QLspSpecification::Responses::TypeDefinitionResponseType> +{ +}; + +class QmlGoToTypeDefinitionSupport : public QQmlBaseModule<TypeDefinitionRequest> +{ + Q_OBJECT +public: + QmlGoToTypeDefinitionSupport(QmlLsp::QQmlCodeModel *codeModel); + + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; + + void process(RequestPointerArgument request) override; + + void typeDefinitionRequestHandler(const QByteArray &, + const QLspSpecification::TypeDefinitionParams ¶ms, + TypeDefinitionRequest::Response &&response); +}; + +QT_END_NAMESPACE + +#endif // QMLGOTOTYPEDEFINITIONSUPPORT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlhighlightsupport_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlhighlightsupport_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1d57dd39bcdc819b6d5ffc8329876674743f0d07 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlhighlightsupport_p.h @@ -0,0 +1,103 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLHIGHLIGHTSUPPORT_P_H +#define QQMLHIGHLIGHTSUPPORT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlbasemodule_p.h" +#include "qqmlcodemodel_p.h" +#include "qqmlsemantictokens_p.h" + +QT_BEGIN_NAMESPACE + +// We don't need these overrides as we register the request handlers in a single +// module QQmlHighlightSupport. This is an unusual pattern because QQmlBaseModule +// and QLanguageServerModule abstractions are designed to handle a single module +// which has a single request handlers. That is not the case for the semanticTokens +// module which has a one server module but also has three different handlers. +#define HIDE_UNUSED_OVERRIDES \ + private: \ + QString name() const override \ + { \ + return {}; \ + } \ + void setupCapabilities(const QLspSpecification::InitializeParams &, \ + QLspSpecification::InitializeResult &) override \ + { \ + } + +using SemanticTokensRequest = BaseRequest<QLspSpecification::SemanticTokensParams, + QLspSpecification::Responses::SemanticTokensResponseType>; + +using SemanticTokensDeltaRequest = + BaseRequest<QLspSpecification::SemanticTokensDeltaParams, + QLspSpecification::Responses::SemanticTokensDeltaResponseType>; + +using SemanticTokensRangeRequest = + BaseRequest<QLspSpecification::SemanticTokensRangeParams, + QLspSpecification::Responses::SemanticTokensRangeResponseType>; + +class SemanticTokenFullHandler : public QQmlBaseModule<SemanticTokensRequest> +{ +public: + SemanticTokenFullHandler(QmlLsp::QQmlCodeModel *codeModel); + void process(QQmlBaseModule<SemanticTokensRequest>::RequestPointerArgument req) override; + void registerHandlers(QLanguageServer *, QLanguageServerProtocol *) override; + void setHighlightingMode(HighlightingUtils::HighlightingMode mode) { m_mode = mode; } + HIDE_UNUSED_OVERRIDES + HighlightingUtils::HighlightingMode m_mode; +}; + +class SemanticTokenDeltaHandler : public QQmlBaseModule<SemanticTokensDeltaRequest> +{ +public: + SemanticTokenDeltaHandler(QmlLsp::QQmlCodeModel *codeModel); + void process(QQmlBaseModule<SemanticTokensDeltaRequest>::RequestPointerArgument req) override; + void registerHandlers(QLanguageServer *, QLanguageServerProtocol *) override; + void setHighlightingMode(HighlightingUtils::HighlightingMode mode) { m_mode = mode; } + HIDE_UNUSED_OVERRIDES + HighlightingUtils::HighlightingMode m_mode; +}; + +class SemanticTokenRangeHandler : public QQmlBaseModule<SemanticTokensRangeRequest> +{ +public: + SemanticTokenRangeHandler(QmlLsp::QQmlCodeModel *codeModel); + void process(QQmlBaseModule<SemanticTokensRangeRequest>::RequestPointerArgument req) override; + void registerHandlers(QLanguageServer *, QLanguageServerProtocol *) override; + void setHighlightingMode(HighlightingUtils::HighlightingMode mode) { m_mode = mode; } + HIDE_UNUSED_OVERRIDES + HighlightingUtils::HighlightingMode m_mode;; +}; + +class QQmlHighlightSupport : public QLanguageServerModule +{ +public: + QQmlHighlightSupport(QmlLsp::QQmlCodeModel *codeModel); + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; +private: + SemanticTokenFullHandler m_full; + SemanticTokenDeltaHandler m_delta; + SemanticTokenRangeHandler m_range; +}; + +#undef HIDE_UNUSED_OVERRIDES + +QT_END_NAMESPACE + +#endif // QQMLHIGHLIGHTSUPPORT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlhover_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlhover_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a7448e557a3660705177acc1da953d577202ebc2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlhover_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLHOVER_P_H +#define QQMLHOVER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlbasemodule_p.h" +#include "qqmlcodemodel_p.h" + +QT_BEGIN_NAMESPACE + +struct HoverRequest + : public BaseRequest<QLspSpecification::HoverParams, + QLspSpecification::Responses::HoverResponseType> +{ +}; +class HelpManager; +class QQmlHover : public QQmlBaseModule<HoverRequest> +{ + Q_OBJECT +public: + QQmlHover(QmlLsp::QQmlCodeModel *codeModel); + ~QQmlHover() override; + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; + void process(RequestPointerArgument req) override; + +private: + std::unique_ptr<HelpManager> m_helpManager; +}; + +QT_END_NAMESPACE + +#endif // QQMLHOVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllanguageserver_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllanguageserver_p.h new file mode 100644 index 0000000000000000000000000000000000000000..79523c38342ed69108c3a0ef76c7ec30833760e0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllanguageserver_p.h @@ -0,0 +1,83 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLANGUAGESERVER_P_H +#define QQMLLANGUAGESERVER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlcodemodel_p.h" +#include "qqmlfindusagessupport_p.h" +#include "qtextsynchronization_p.h" +#include "qqmllintsuggestions_p.h" +#include "qworkspace_p.h" +#include "qqmlcompletionsupport_p.h" +#include "qqmlgototypedefinitionsupport_p.h" +#include "qqmlformatting_p.h" +#include "qqmlrangeformatting_p.h" +#include "qqmlgotodefinitionsupport_p.h" +#include "qqmlrenamesymbolsupport_p.h" +#include "qqmlhover_p.h" +#include "qqmlhighlightsupport_p.h" + +QT_BEGIN_NAMESPACE + +class QQmlToolingSettings; + +namespace QmlLsp { + +class QQmlLanguageServer : public QLanguageServerModule +{ + Q_OBJECT +public: + QQmlLanguageServer(std::function<void(const QByteArray &)> sendData, + QQmlToolingSettings *settings = nullptr); + + QString name() const final; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) final; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &serverInfo) final; + + int returnValue() const; + + QQmlCodeModel *codeModel(); + QLanguageServer *server(); + TextSynchronization *textSynchronization(); + QmlLintSuggestions *lint(); + WorkspaceHandlers *worspace(); + +public Q_SLOTS: + void exit(); + void errorExit(); + +private: + QQmlCodeModel m_codeModel; + QLanguageServer m_server; + TextSynchronization m_textSynchronization; + QmlLintSuggestions m_lint; + WorkspaceHandlers m_workspace; + QmlCompletionSupport m_completionSupport; + QmlGoToTypeDefinitionSupport m_navigationSupport; + QmlGoToDefinitionSupport m_definitionSupport; + QQmlFindUsagesSupport m_referencesSupport; + QQmlDocumentFormatting m_documentFormatting; + QQmlRenameSymbolSupport m_renameSupport; + QQmlRangeFormatting m_rangeFormatting; + QQmlHover m_hover; + QQmlHighlightSupport m_highlightSupport; + int m_returnValue = 1; +}; + +} // namespace QmlLsp +QT_END_NAMESPACE +#endif // QQMLLANGUAGESERVER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllintsuggestions_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllintsuggestions_p.h new file mode 100644 index 0000000000000000000000000000000000000000..736a8cfef8dc8beebb34ed670b7444e45adb1ab8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllintsuggestions_p.h @@ -0,0 +1,72 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMLLINTSUGGESTIONS_P_H +#define QMLLINTSUGGESTIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlcodemodel_p.h" + +#include <chrono> +#include <optional> + +QT_BEGIN_NAMESPACE +namespace QmlLsp { +struct LastLintUpdate +{ + std::optional<int> version; + std::optional<std::chrono::steady_clock::time_point> invalidUpdatesSince; +}; + +class QmlLintSuggestions : public QLanguageServerModule +{ + Q_OBJECT +public: + QmlLintSuggestions(QLanguageServer *server, QmlLsp::QQmlCodeModel *codeModel); + + QString name() const override { return QLatin1StringView("QmlLint Suggestions"); } +public Q_SLOTS: + void diagnose(const QByteArray &uri); + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; + +private: + struct VersionedDocument + { + std::optional<int> version; + QQmlJS::Dom::DomItem item; + }; + struct TryAgainLater + { + std::chrono::milliseconds time; + }; + struct NoDocumentAvailable + { + }; + + using VersionToDiagnose = std::variant<VersionedDocument, TryAgainLater, NoDocumentAvailable>; + + VersionToDiagnose chooseVersionToDiagnose(const QByteArray &url); + VersionToDiagnose chooseVersionToDiagnoseHelper(const QByteArray &url); + void diagnoseHelper(const QByteArray &uri, const VersionedDocument &document); + + QMutex m_mutex; + QHash<QByteArray, LastLintUpdate> m_lastUpdate; + QLanguageServer *m_server; + QmlLsp::QQmlCodeModel *m_codeModel; +}; +} // namespace QmlLsp +QT_END_NAMESPACE +#endif // QMLLINTSUGGESTIONS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllscompletion_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllscompletion_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5a99fade3df781fc44555fbd0c02fcd8a18fda56 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllscompletion_p.h @@ -0,0 +1,242 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLSCOMPLETION_H +#define QQMLLSCOMPLETION_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlcompletioncontextstrings_p.h" +#include "qqmllsutils_p.h" +#include "qqmllsplugin_p.h" + +#include <QtLanguageServer/private/qlanguageserverspectypes_p.h> +#include <QtQmlDom/private/qqmldomexternalitems_p.h> +#include <QtQmlDom/private/qqmldomtop_p.h> +#include <QtCore/private/qduplicatetracker_p.h> +#include <QtCore/private/qfactoryloader_p.h> +#include <QtCore/qpluginloader.h> +#include <QtCore/qxpfunctional.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(QQmlLSCompletionLog) + + +class QQmlLSCompletion +{ + using DomItem = QQmlJS::Dom::DomItem; +public: + enum class ImportCompletionType { None, Module, Version }; + enum AppendOption { AppendSemicolon, AppendNothing }; + + QQmlLSCompletion(const QFactoryLoader &pluginLoader); + + using CompletionItem = QLspSpecification::CompletionItem; + using BackInsertIterator = std::back_insert_iterator<QList<CompletionItem>>; + QList<CompletionItem> completions(const DomItem ¤tItem, + const CompletionContextStrings &ctx) const; + + static CompletionItem makeSnippet(QUtf8StringView qualifier, QUtf8StringView label, + QUtf8StringView insertText); + + static CompletionItem makeSnippet(QUtf8StringView label, QUtf8StringView insertText); + +private: + struct QQmlLSCompletionPosition + { + DomItem itemAtPosition; + CompletionContextStrings cursorPosition; + qsizetype offset() const { return cursorPosition.offset(); } + }; + + void collectCompletions(const DomItem ¤tItem, const CompletionContextStrings &ctx, + BackInsertIterator result) const; + + bool betweenLocations(QQmlJS::SourceLocation left, const QQmlLSCompletionPosition &positionInfo, + QQmlJS::SourceLocation right) const; + bool afterLocation(QQmlJS::SourceLocation left, + const QQmlLSCompletionPosition &positionInfo) const; + bool beforeLocation(const QQmlLSCompletionPosition &ctx, QQmlJS::SourceLocation right) const; + bool ctxBeforeStatement(const QQmlLSCompletionPosition &positionInfo, + const DomItem &parentForContext, + QQmlJS::Dom::FileLocationRegion firstRegion) const; + bool isCaseOrDefaultBeforeCtx(const DomItem ¤tClause, + const QQmlLSCompletionPosition &positionInfo, + QQmlJS::Dom::FileLocationRegion keywordRegion) const; + DomItem previousCaseOfCaseBlock(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo) const; + + void idsCompletions(const DomItem &component, BackInsertIterator it) const; + + void suggestReachableTypes(const DomItem &context, + QQmlJS::Dom::LocalSymbolsTypes typeCompletionType, + QLspSpecification::CompletionItemKind kind, + BackInsertIterator it) const; + + void suggestJSStatementCompletion(const DomItem ¤tItem, BackInsertIterator it) const; + void suggestCaseAndDefaultStatementCompletion(BackInsertIterator it) const; + void suggestVariableDeclarationStatementCompletion( + BackInsertIterator it, AppendOption option = AppendSemicolon) const; + + void suggestEnumerationsAndEnumerationValues(const QQmlJSScope::ConstPtr &scope, + const QString &enumName, + QDuplicateTracker<QString> &usedNames, + BackInsertIterator result) const; + DomItem ownerOfQualifiedExpression(const DomItem &qualifiedExpression) const; + void suggestJSExpressionCompletion(const DomItem &context, BackInsertIterator it) const; + + void suggestBindingCompletion(const DomItem &itemAtPosition, BackInsertIterator it) const; + + void insideImportCompletionHelper(const DomItem &file, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + + void jsIdentifierCompletion(const QQmlJSScope::ConstPtr &scope, + QDuplicateTracker<QString> *usedNames, BackInsertIterator it) const; + + void methodCompletion(const QQmlJSScope::ConstPtr &scope, QDuplicateTracker<QString> *usedNames, + BackInsertIterator it) const; + void propertyCompletion(const QQmlJSScope::ConstPtr &scope, + QDuplicateTracker<QString> *usedNames, BackInsertIterator it) const; + void enumerationCompletion(const QQmlJSScope::ConstPtr &scope, + QDuplicateTracker<QString> *usedNames, BackInsertIterator it) const; + void enumerationValueCompletionHelper(const QStringList &enumeratorKeys, + BackInsertIterator it) const; + + void enumerationValueCompletion(const QQmlJSScope::ConstPtr &scope, + const QString &enumeratorName, BackInsertIterator it) const; + + static bool cursorInFrontOfItem(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo); + static bool cursorAfterColon(const DomItem ¤tItem, + const QQmlLSCompletionPosition &positionInfo); + void insidePragmaCompletion(QQmlJS::Dom::DomItem currentItem, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideQmlObjectCompletion(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insidePropertyDefinitionCompletion(const DomItem ¤tItem, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideBindingCompletion(const DomItem ¤tItem, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideImportCompletion(const DomItem ¤tItem, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideQmlFileCompletion(const DomItem ¤tItem, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void suggestContinueAndBreakStatementIfNeeded(const DomItem &itemAtPosition, + BackInsertIterator it) const; + void insideScriptLiteralCompletion(const DomItem ¤tItem, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideCallExpression(const DomItem ¤tItem, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideIfStatement(const DomItem ¤tItem, const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideReturnStatement(const DomItem ¤tItem, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideWhileStatement(const DomItem ¤tItem, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideDoWhileStatement(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideForStatementCompletion(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideForEachStatement(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideSwitchStatement(const DomItem &parentForContext, + const QQmlLSCompletionPosition positionInfo, + BackInsertIterator it) const; + void insideCaseClause(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideCaseBlock(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, BackInsertIterator it) const; + void insideDefaultClause(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideBinaryExpressionCompletion(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideScriptPattern(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideVariableDeclarationEntry(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideThrowStatement(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideLabelledStatement(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideContinueStatement(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideBreakStatement(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideConditionalExpression(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideUnaryExpression(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insidePostExpression(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideParenthesizedExpression(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideTemplateLiteral(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideNewExpression(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void insideNewMemberExpression(const DomItem &parentForContext, + const QQmlLSCompletionPosition &positionInfo, + BackInsertIterator it) const; + void signalHandlerCompletion(const QQmlJSScope::ConstPtr &scope, + QDuplicateTracker<QString> *usedNames, + BackInsertIterator it) const; + + void suggestSnippetsForLeftHandSideOfBinding(const DomItem &items, + BackInsertIterator result) const; + + void suggestSnippetsForRightHandSideOfBinding(const DomItem &items, + BackInsertIterator result) const; + +private: + using CompletionFromPluginFunction = void(QQmlLSCompletionPlugin *plugin, + BackInsertIterator result); + void collectFromPlugins(const qxp::function_ref<CompletionFromPluginFunction> f, + BackInsertIterator result) const; + + QStringList m_loadPaths; + + std::vector<std::unique_ptr<QQmlLSCompletionPlugin>> m_plugins; +}; + +QT_END_NAMESPACE + +#endif // QQMLLSCOMPLETION_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllscompletionplugin_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllscompletionplugin_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0940274eb47bf3f3ae84e7497a6996f41b8d5d2c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllscompletionplugin_p.h @@ -0,0 +1,42 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLSCOMPLETIONPLUGIN_H +#define QQMLLSCOMPLETIONPLUGIN_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <iterator> + +#include <QtQmlDom/private/qqmldomelements_p.h> +#include <QtLanguageServer/private/qlanguageserverspectypes_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlLSCompletionPlugin +{ +public: + QQmlLSCompletionPlugin() = default; + virtual ~QQmlLSCompletionPlugin() = default; + + using BackInsertIterator = std::back_insert_iterator<QList<QLspSpecification::CompletionItem>>; + + virtual void suggestSnippetsForLeftHandSideOfBinding(const QQmlJS::Dom::DomItem &items, + BackInsertIterator result) const = 0; + + virtual void suggestSnippetsForRightHandSideOfBinding(const QQmlJS::Dom::DomItem &items, + BackInsertIterator result) const = 0; +}; + +QT_END_NAMESPACE + +#endif // QQMLLSCOMPLETIONPLUGIN_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllshelpplugininterface_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllshelpplugininterface_p.h new file mode 100644 index 0000000000000000000000000000000000000000..760c83beffd6d406cd7a6a81428d3cd5b3289d1b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllshelpplugininterface_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLSHELPPLUGININTERFACE_H +#define QQMLLSHELPPLUGININTERFACE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> +#include <QtCore/qurl.h> +#include <QtCore/qobject.h> +#include <vector> + +QT_BEGIN_NAMESPACE + +class QQmlLSHelpProviderBase +{ +public: + struct DocumentLink + { + QUrl url; + QString title; + }; + +public: + virtual ~QQmlLSHelpProviderBase() = default; + virtual bool registerDocumentation(const QString &documentationFileName) = 0; + [[nodiscard]] virtual QByteArray fileData(const QUrl &url) const = 0; + [[nodiscard]] virtual std::vector<DocumentLink> documentsForIdentifier(const QString &id) const = 0; + [[nodiscard]] virtual std::vector<DocumentLink> + documentsForIdentifier(const QString &id, const QString &filterName) const = 0; + [[nodiscard]] virtual std::vector<DocumentLink> documentsForKeyword(const QString &keyword) const = 0; + [[nodiscard]] virtual std::vector<DocumentLink> + documentsForKeyword(const QString &keyword, const QString &filterName) const = 0; + [[nodiscard]] virtual QStringList registeredNamespaces() const = 0; + [[nodiscard]] virtual QString error() const = 0; +}; + +class QQmlLSHelpPluginInterface +{ +public: + QQmlLSHelpPluginInterface() = default; + virtual ~QQmlLSHelpPluginInterface() = default; + Q_DISABLE_COPY_MOVE(QQmlLSHelpPluginInterface) + + virtual std::unique_ptr<QQmlLSHelpProviderBase> initialize(const QString &collectionFile, + QObject *parent) = 0; +}; + +#define QQmlLSHelpPluginInterface_iid "org.qt-project.Qt.QmlLS.HelpPlugin/1.0" +Q_DECLARE_INTERFACE(QQmlLSHelpPluginInterface, QQmlLSHelpPluginInterface_iid) + +QT_END_NAMESPACE + +#endif // QQMLLSHELPPLUGININTERFACE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllshelputils_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllshelputils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3ccc6ab317a3d1fe951db49871e4f4c130aa1476 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllshelputils_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLSHELPUTILS_P_H +#define QQMLLSHELPUTILS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQmlLS/private/qqmllshelpplugininterface_p.h> +#include <QtQmlLS/private/qqmllsutils_p.h> +#include <QtQmlDom/private/qqmldomtop_p.h> +#include <QtQmlLS/private/qdochtmlparser_p.h> +#include <QtLanguageServer/private/qlanguageserverspectypes_p.h> + +#include <vector> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(QQmlLSHelpUtilsLog); + +using namespace QQmlJS::Dom; + +class HelpManager final +{ +public: + HelpManager(); + void setDocumentationRootPath(const QString &path); + [[nodiscard]] QString documentationRootPath() const; + [[nodiscard]] std::optional<QByteArray> documentationForItem( + const QQmlJS::Dom::DomItem &file, QLspSpecification::Position position); + +private: + [[nodiscard]] std::optional<QByteArray> extractDocumentationForIdentifiers(const QQmlJS::Dom::DomItem &item, + QQmlLSUtils::ExpressionType expr) const; + [[nodiscard]] std::optional<QByteArray> extractDocumentationForDomElements( + const QQmlJS::Dom::DomItem &item) const; + [[nodiscard]] std::optional<QByteArray> extractDocumentation( + const QQmlJS::Dom::DomItem &item) const; + [[nodiscard]] std::optional<QByteArray> tryExtract(ExtractDocumentation &extractor, + const std::vector<QQmlLSHelpProviderBase::DocumentLink> &links, + const QString &name) const; + [[nodiscard]] std::vector<QQmlLSHelpProviderBase::DocumentLink> + collectDocumentationLinks(const QQmlJS::Dom::DomItem &item, const QQmlJSScope::ConstPtr &scope, + const QString &name) const; + void registerDocumentations(const QStringList &docs) const; + std::unique_ptr<QQmlLSHelpProviderBase> m_helpPlugin; + QString m_docRootPath; + QHash<QString, QString> m_cppTypesToQmlTypes; +}; + +QT_END_NAMESPACE + +#endif // QQMLLSHELPUTILS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllsplugin_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllsplugin_p.h new file mode 100644 index 0000000000000000000000000000000000000000..be6365982de4b13ef75aeb437af45205592869e6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllsplugin_p.h @@ -0,0 +1,42 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMLLSPLUGIN_P_H +#define QMLLSPLUGIN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <memory> + +#include <QtCore/qtclasshelpermacros.h> +#include <QtCore/qobject.h> +#include <QtQmlLS/private/qqmllscompletionplugin_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlLSPlugin +{ +public: + QQmlLSPlugin() = default; + virtual ~QQmlLSPlugin() = default; + + Q_DISABLE_COPY_MOVE(QQmlLSPlugin) + + virtual std::unique_ptr<QQmlLSCompletionPlugin> createCompletionPlugin() const = 0; +}; + +#define QmlLSPluginInterface_iid "org.qt-project.Qt.QmlLS.Plugin/1.0" +Q_DECLARE_INTERFACE(QQmlLSPlugin, QmlLSPluginInterface_iid) + +QT_END_NAMESPACE + +#endif // QMLLSPLUGIN_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllsutils_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllsutils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..65e0b0fe4468855ae39b94fb3de71bc9489f15ab --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmllsutils_p.h @@ -0,0 +1,300 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QLANGUAGESERVERUTILS_P_H +#define QLANGUAGESERVERUTILS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLanguageServer/private/qlanguageserverspectypes_p.h> +#include <QtQmlDom/private/qqmldomexternalitems_p.h> +#include <QtQmlDom/private/qqmldomtop_p.h> +#include <algorithm> +#include <optional> +#include <tuple> +#include <variant> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(QQmlLSUtilsLog); + +namespace QQmlLSUtils { + +struct ItemLocation +{ + QQmlJS::Dom::DomItem domItem; + QQmlJS::Dom::FileLocations::Tree fileLocation; +}; + +struct TextPosition +{ + int line; + int character; +}; + +enum IdentifierType : char { + NotAnIdentifier, // when resolving expressions like `Qt.point().x` for example, where + // `Qt.point()` is not an identifier + + JavaScriptIdentifier, + PropertyIdentifier, + PropertyChangedSignalIdentifier, + PropertyChangedHandlerIdentifier, + SignalIdentifier, + SignalHandlerIdentifier, + MethodIdentifier, + LambdaMethodIdentifier, + QmlObjectIdIdentifier, + SingletonIdentifier, + EnumeratorIdentifier, + EnumeratorValueIdentifier, + AttachedTypeIdentifier, + GroupedPropertyIdentifier, + QmlComponentIdentifier, + QualifiedModuleIdentifier, +}; + +struct ErrorMessage +{ + int code; + QString message; +}; + +struct ExpressionType +{ + std::optional<QString> name; + QQmlJSScope::ConstPtr semanticScope; + IdentifierType type = NotAnIdentifier; +}; + +class Location +{ +public: + Location() = default; + Location(const QString &filename, const QQmlJS::SourceLocation &sourceLocation, + const TextPosition &end) + : m_filename(filename), m_sourceLocation(sourceLocation), m_end(end) + { + } + + QString filename() const { return m_filename; } + QQmlJS::SourceLocation sourceLocation() const { return m_sourceLocation; } + TextPosition end() const { return m_end; } + + static Location from(const QString &fileName, const QString &code, quint32 startLine, + quint32 startCharacter, quint32 length); + static Location from(const QString &fileName, const QQmlJS::SourceLocation &sourceLocation, + const QString &code); + static std::optional<Location> tryFrom(const QString &fileName, + const QQmlJS::SourceLocation &sourceLocation, + const QQmlJS::Dom::DomItem &someItem); + + friend bool operator<(const Location &a, const Location &b) + { + return std::make_tuple(a.m_filename, a.m_sourceLocation.begin(), a.m_sourceLocation.end()) + < std::make_tuple(b.m_filename, b.m_sourceLocation.begin(), + b.m_sourceLocation.end()); + } + friend bool operator==(const Location &a, const Location &b) + { + return std::make_tuple(a.m_filename, a.m_sourceLocation.begin(), a.m_sourceLocation.end()) + == std::make_tuple(b.m_filename, b.m_sourceLocation.begin(), + b.m_sourceLocation.end()); + } + +private: + QString m_filename; + QQmlJS::SourceLocation m_sourceLocation; + TextPosition m_end; +}; + +/*! +Represents a rename operation where the file itself needs to be renamed. +\internal +*/ +struct FileRename +{ + QString oldFilename; + QString newFilename; + + friend bool comparesEqual(const FileRename &a, const FileRename &b) noexcept + { + return std::tie(a.oldFilename, a.newFilename) == std::tie(b.oldFilename, b.newFilename); + } + friend Qt::strong_ordering compareThreeWay(const FileRename &a, const FileRename &b) noexcept + { + if (a.oldFilename != b.oldFilename) + return compareThreeWay(a.oldFilename, b.oldFilename); + return compareThreeWay(a.newFilename, b.newFilename); + } + Q_DECLARE_STRONGLY_ORDERED(FileRename); +}; + +struct Edit +{ + Location location; + QString replacement; + + static Edit from(const QString &fileName, const QString &code, quint32 startLine, + quint32 startCharacter, quint32 length, const QString &newName); + + friend bool operator<(const Edit &a, const Edit &b) + { + return std::make_tuple(a.location, a.replacement) + < std::make_tuple(b.location, b.replacement); + } + friend bool operator==(const Edit &a, const Edit &b) + { + return std::make_tuple(a.location, a.replacement) + == std::make_tuple(b.location, b.replacement); + } +}; + +/*! +Represents the locations where some highlighting should take place, like in the "find all +references" feature of the LSP. Those locations are pointing to parts of a Qml file or to a Qml +file name. + +The file names are not reported as usage to the LSP and are currently only needed for the renaming +operation to be able to rename files. + +\internal +*/ +class Usages +{ +public: + void sort(); + bool isEmpty() const; + + friend bool comparesEqual(const Usages &a, const Usages &b) + { + return a.m_usagesInFile == b.m_usagesInFile && a.m_usagesInFilename == b.m_usagesInFilename; + } + Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(Usages) + + Usages() = default; + Usages(const QList<Location> &usageInFile, const QList<QString> &usageInFilename); + + QList<Location> usagesInFile() const { return m_usagesInFile; }; + QList<QString> usagesInFilename() const { return m_usagesInFilename; }; + + void appendUsage(const Location &edit) + { + if (!m_usagesInFile.contains(edit)) + m_usagesInFile.append(edit); + }; + void appendFilenameUsage(const QString &edit) + { + + if (!m_usagesInFilename.contains(edit)) + m_usagesInFilename.append(edit); + }; + +private: + QList<Location> m_usagesInFile; + QList<QString> m_usagesInFilename; +}; + +/*! +Represents the locations where a renaming should take place. Parts of text inside a file can be +renamed and also filename themselves can be renamed. + +\internal +*/ +class RenameUsages +{ +public: + friend bool comparesEqual(const RenameUsages &a, const RenameUsages &b) + { + return std::tie(a.m_renamesInFile, a.m_renamesInFilename) + == std::tie(b.m_renamesInFile, b.m_renamesInFilename); + } + Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(RenameUsages) + + RenameUsages() = default; + RenameUsages(const QList<Edit> &renamesInFile, const QList<FileRename> &renamesInFilename); + + QList<Edit> renameInFile() const { return m_renamesInFile; }; + QList<FileRename> renameInFilename() const { return m_renamesInFilename; }; + + void appendRename(const Edit &edit) { m_renamesInFile.append(edit); }; + void appendRename(const FileRename &edit) { m_renamesInFilename.append(edit); }; + +private: + QList<Edit> m_renamesInFile; + QList<FileRename> m_renamesInFilename; +}; + +/*! + \internal + Choose whether to resolve the owner type or the entire type (the latter is only required to + resolve the types of qualified names and property accesses). + + For properties, methods, enums and co: + * ResolveOwnerType returns the base type of the owner that owns the property, method, enum + and co. For example, resolving "x" in "myRectangle.x" will return the Item as the owner, as + Item is the base type of Rectangle that defines the "x" property. + * ResolveActualTypeForFieldMemberExpression is used to resolve field member expressions, and + might lose some information about the owner. For example, resolving "x" in "myRectangle.x" + will return the JS type for float that was used to define the "x" property. + */ +enum ResolveOptions { + ResolveOwnerType, + ResolveActualTypeForFieldMemberExpression, +}; + +using DomItem = QQmlJS::Dom::DomItem; + +qsizetype textOffsetFrom(const QString &code, int row, int character); +TextPosition textRowAndColumnFrom(const QString &code, qsizetype offset); +QList<ItemLocation> itemsFromTextLocation(const DomItem &file, int line, int character); +DomItem sourceLocationToDomItem(const DomItem &file, const QQmlJS::SourceLocation &location); +QByteArray lspUriToQmlUrl(const QByteArray &uri); +QByteArray qmlUrlToLspUri(const QByteArray &url); +QLspSpecification::Range qmlLocationToLspLocation(Location qmlLocation); +DomItem baseObject(const DomItem &qmlObject); +std::optional<Location> findTypeDefinitionOf(const DomItem &item); +std::optional<Location> findDefinitionOf(const DomItem &item); +Usages findUsagesOf(const DomItem &item); + +std::optional<ErrorMessage> +checkNameForRename(const DomItem &item, const QString &newName, + const std::optional<ExpressionType> &targetType = std::nullopt); +RenameUsages renameUsagesOf(const DomItem &item, const QString &newName, + const std::optional<ExpressionType> &targetType = std::nullopt); +std::optional<ExpressionType> resolveExpressionType(const DomItem &item, ResolveOptions); +bool isValidEcmaScriptIdentifier(QStringView view); + +QPair<QString, QStringList> cmakeBuildCommand(const QString &path); + +bool isFieldMemberExpression(const DomItem &item); +bool isFieldMemberAccess(const DomItem &item); +bool isFieldMemberBase(const DomItem &item); +QStringList fieldMemberExpressionBits(const DomItem &item, const DomItem &stopAtChild = {}); + +QString qualifiersFrom(const DomItem &el); + +QQmlJSScope::ConstPtr findDefiningScopeForProperty(const QQmlJSScope::ConstPtr &referrerScope, + const QString &nameToCheck); +QQmlJSScope::ConstPtr findDefiningScopeForBinding(const QQmlJSScope::ConstPtr &referrerScope, + const QString &nameToCheck); +QQmlJSScope::ConstPtr findDefiningScopeForMethod(const QQmlJSScope::ConstPtr &referrerScope, + const QString &nameToCheck); +QQmlJSScope::ConstPtr findDefiningScopeForEnumeration(const QQmlJSScope::ConstPtr &referrerScope, + const QString &nameToCheck); +QQmlJSScope::ConstPtr findDefiningScopeForEnumerationKey(const QQmlJSScope::ConstPtr &referrerScope, + const QString &nameToCheck); +} // namespace QQmlLSUtils + +QT_END_NAMESPACE + +#endif // QLANGUAGESERVERUTILS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlrangeformatting_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlrangeformatting_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f0ed242dcd427fe6e458b581638f88af4553d209 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlrangeformatting_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLRANGEFORMATTING_P_H +#define QQMLRANGEFORMATTING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlbasemodule_p.h" +#include "qqmlcodemodel_p.h" + +QT_BEGIN_NAMESPACE + +struct RangeFormattingRequest + : public BaseRequest<QLspSpecification::DocumentRangeFormattingParams, + QLspSpecification::Responses::DocumentRangeFormattingResponseType> +{ +}; + +class QQmlRangeFormatting : public QQmlBaseModule<RangeFormattingRequest> +{ + Q_OBJECT +public: + QQmlRangeFormatting(QmlLsp::QQmlCodeModel *codeModel); + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; + void process(RequestPointerArgument req) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLRANGEFORMATTING_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlrenamesymbolsupport_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlrenamesymbolsupport_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4ea43637449e1188446a1b4bf6dc6da217c0d599 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlrenamesymbolsupport_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLRENAMESYMBOLSUPPORT_P_H +#define QQMLRENAMESYMBOLSUPPORT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qlanguageserver_p.h" +#include "qqmlcodemodel_p.h" +#include "qqmlbasemodule_p.h" + +QT_BEGIN_NAMESPACE +struct RenameRequest : public BaseRequest<QLspSpecification::RenameParams, + QLspSpecification::Responses::RenameResponseType> +{ +}; + +class QQmlRenameSymbolSupport : public QQmlBaseModule<RenameRequest> +{ + Q_OBJECT +public: + QQmlRenameSymbolSupport(QmlLsp::QQmlCodeModel *codeModel); + + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; + + void process(RequestPointerArgument request) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLRENAMESYMBOLSUPPORT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlsemantictokens_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlsemantictokens_p.h new file mode 100644 index 0000000000000000000000000000000000000000..51f7be4d343fcb554fc6f9facb346f0e09a72e85 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qqmlsemantictokens_p.h @@ -0,0 +1,225 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSEMANTICTOKENS_P_H +#define QQMLSEMANTICTOKENS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLanguageServer/private/qlanguageserverspec_p.h> +#include <QtQmlDom/private/qqmldomitem_p.h> +#include <QtCore/qlist.h> +#include <QtCore/qmap.h> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(semanticTokens) + +namespace HighlightingUtils { +Q_NAMESPACE + +// Protocol agnostic highlighting kinds +// Use this enum while visiting dom tree to define the highlighting kinds for the semantic tokens +// Then map it to the protocol specific token types and modifiers +// This can be as much as detailed as needed +enum class QmlHighlightKind { + QmlKeyword, // Qml keyword + QmlType, // Qml type name + QmlImportId, // Qml import module name + QmlNamespace, // Qml module namespace, i.e import QtQuick as Namespace + QmlLocalId, // Object id within the same file + QmlExternalId, // Object id defined in another file. [UNUSED FOR NOW] + QmlProperty, // Qml property. For now used for all kind of properties + QmlScopeObjectProperty, // Qml property defined in the current scope + QmlRootObjectProperty, // Qml property defined in the parent scopes + QmlExternalObjectProperty, // Qml property defined in the root object of another file + QmlMethod, + QmlMethodParameter, + QmlSignal, + QmlSignalHandler, + QmlEnumName, // Enum type name + QmlEnumMember, // Enum field names + QmlPragmaName, // Qml pragma name + QmlPragmaValue, // Qml pragma value + QmlTypeModifier, // list<QtObject>, list is the modifier, QtObject is the type + JsImport, // Js imported name + JsGlobalVar, // Js global variable or objects + JsGlobalMethod, // Js global method + JsScopeVar, // Js variable defined in the current scope + JsLabel, // js label + Number, + String, + Comment, + Operator, + Unknown, // Used for the unknown tokens +}; + +enum class QmlHighlightModifier { + None = 0, + QmlPropertyDefinition = 1 << 0, + QmlDefaultProperty = 1 << 1, + QmlRequiredProperty = 1 << 2, + QmlReadonlyProperty = 1 << 3, +}; +Q_DECLARE_FLAGS(QmlHighlightModifiers, QmlHighlightModifier) +Q_DECLARE_OPERATORS_FOR_FLAGS(QmlHighlightModifiers) + +enum class HighlightingMode { Default, QtCHighlighting }; + +// Protocol specific token types +// The values in this enum are converted to relevant strings and sent to the client as server +// capabilities The convention is that the first letter in the enum value is decapitalized and the +// rest is unchanged i.e Namespace -> "namespace" This is handled in enumToByteArray() helper +// function. +enum class SemanticTokenProtocolTypes { + // Subset of the QLspSpefication::SemanticTokenTypes enum + // We register only the token types used in the qml semantic highlighting + Namespace, + Type, + Enum, + Parameter, + Variable, + Property, + EnumMember, + Method, + Keyword, + Comment, + String, + Number, + Regexp, + Operator, + Decorator, + + // Additional token types for the extended semantic highlighting + QmlLocalId, // object id within the same file + QmlExternalId, // object id defined in another file + QmlRootObjectProperty, // qml property defined in the parent scopes + QmlScopeObjectProperty, // qml property defined in the current scope + QmlExternalObjectProperty, // qml property defined in the root object of another file + JsScopeVar, // js variable defined in the current file + JsImportVar, // js import name that is imported in the qml file + JsGlobalVar, // js global variables + QmlStateName, // name of a qml state +}; +Q_ENUM_NS(SemanticTokenProtocolTypes) + +} // namespace HighlightingUtils + +// Represents a semantic highlighting token +// startLine and startColumn are 0-based as in LSP spec. +struct Token +{ + Token() = default; + Token(const QQmlJS::SourceLocation &loc, int tokenType, int tokenModifier = 0) + : offset(loc.offset), + length(loc.length), + startLine(loc.startLine - 1), + startColumn(loc.startColumn - 1), + tokenType(tokenType), + tokenModifier(tokenModifier) + { + } + + inline friend bool operator<(const Token &lhs, const Token &rhs) + { + return lhs.offset < rhs.offset; + } + + inline friend bool operator==(const Token &lhs, const Token &rhs) + { + return lhs.offset == rhs.offset && lhs.length == rhs.length + && lhs.startLine == rhs.startLine && lhs.startColumn == rhs.startColumn + && lhs.tokenType == rhs.tokenType && lhs.tokenModifier == rhs.tokenModifier; + } + + int offset; + int length; + int startLine; + int startColumn; + int tokenType; + int tokenModifier; +}; + +using HighlightsContainer = QMap<int, QT_PREPEND_NAMESPACE(Token)>; + +/*! +\internal +Offsets start from zero. +*/ +struct HighlightsRange +{ + int startOffset; + int endOffset; +}; + +class Highlights +{ +public: + using QmlHighlightKindToLspKind = int (*)(HighlightingUtils::QmlHighlightKind); + Highlights(HighlightingUtils::HighlightingMode mode = HighlightingUtils::HighlightingMode::Default); + void addHighlight(const QQmlJS::SourceLocation &loc, HighlightingUtils::QmlHighlightKind, + HighlightingUtils::QmlHighlightModifiers = + HighlightingUtils::QmlHighlightModifier::None); + HighlightsContainer &highlights() { return m_highlights; } + const HighlightsContainer &highlights() const { return m_highlights; } + +private: + void addHighlightImpl(const QQmlJS::SourceLocation &loc, int tokenType, int tokenModifier = 0); + HighlightsContainer m_highlights; + QmlHighlightKindToLspKind m_mapToProtocol; +}; + +namespace HighlightingUtils +{ + QList<int> encodeSemanticTokens(Highlights &highlights); + QList<QQmlJS::SourceLocation> + sourceLocationsFromMultiLineToken(QStringView code, + const QQmlJS::SourceLocation &tokenLocation); + void addModifier(QLspSpecification::SemanticTokenModifiers modifier, int *baseModifier); + bool rangeOverlapsWithSourceLocation(const QQmlJS::SourceLocation &loc, const HighlightsRange &r); + QList<QLspSpecification::SemanticTokensEdit> computeDiff(const QList<int> &, const QList<int> &); + void updateResultID(QByteArray &resultID); + QList<int> collectTokens(const QQmlJS::Dom::DomItem &item, + const std::optional<HighlightsRange> &range, + HighlightingMode mode = HighlightingMode::Default); +} // namespace HighlightingUtils + +class HighlightingVisitor +{ +public: + HighlightingVisitor(Highlights &highlights, const std::optional<HighlightsRange> &range); + bool operator()(QQmlJS::Dom::Path, const QQmlJS::Dom::DomItem &item, bool); + +private: + void highlightComment(const QQmlJS::Dom::DomItem &item); + void highlightImport(const QQmlJS::Dom::DomItem &item); + void highlightBinding(const QQmlJS::Dom::DomItem &item); + void highlightPragma(const QQmlJS::Dom::DomItem &item); + void highlightEnumItem(const QQmlJS::Dom::DomItem &item); + void highlightEnumDecl(const QQmlJS::Dom::DomItem &item); + void highlightQmlObject(const QQmlJS::Dom::DomItem &item); + void highlightComponent(const QQmlJS::Dom::DomItem &item); + void highlightPropertyDefinition(const QQmlJS::Dom::DomItem &item); + void highlightMethod(const QQmlJS::Dom::DomItem &item); + void highlightScriptLiteral(const QQmlJS::Dom::DomItem &item); + void highlightIdentifier(const QQmlJS::Dom::DomItem &item); + void highlightBySemanticAnalysis(const QQmlJS::Dom::DomItem &item, QQmlJS::SourceLocation loc); + void highlightScriptExpressions(const QQmlJS::Dom::DomItem &item); + +private: + Highlights &m_highlights; + std::optional<HighlightsRange> m_range; +}; + +QT_END_NAMESPACE + +#endif // QQMLSEMANTICTOKENS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextblock_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextblock_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6a34ddde2c47ace6e4cae66bda1d84a19026506d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextblock_p.h @@ -0,0 +1,73 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTBLOCK_P_H +#define QTEXTBLOCK_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> + +namespace Utils { + +class TextDocument; +class TextBlockUserData; + +class TextBlock +{ +public: + bool isValid() const; + + void setBlockNumber(int blockNumber); + int blockNumber() const; + + void setPosition(int position); + int position() const; + + void setLength(int length); + int length() const; + + TextBlock next() const; + TextBlock previous() const; + + int userState() const; + void setUserState(int state); + + bool isVisible() const; + void setVisible(bool visible); + + void setLineCount(int count); + int lineCount() const; + + void setDocument(TextDocument *document); + TextDocument *document() const; + + QString text() const; + + int revision() const; + void setRevision(int rev); + + friend bool operator==(const TextBlock &t1, const TextBlock &t2); + friend bool operator!=(const TextBlock &t1, const TextBlock &t2); + +private: + TextDocument *m_document = nullptr; + int m_revision = 0; + + int m_position = 0; + int m_length = 0; + int m_blockNumber = -1; +}; + +} // namespace Utils + +#endif // TEXTBLOCK_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextcursor_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextcursor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9adea71167e91dc6832fd0ed7950e53950b8198f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextcursor_p.h @@ -0,0 +1,72 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef TEXTCURSOR_H +#define TEXTCURSOR_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> + +namespace Utils { + +class TextDocument; +class TextBlock; + +class TextCursor +{ +public: + enum MoveOperation { + NoMove, + Start, + PreviousCharacter, + End, + NextCharacter, + }; + + enum MoveMode { MoveAnchor, KeepAnchor }; + + enum SelectionType { Document }; + + TextCursor(); + TextCursor(const TextBlock &block); + TextCursor(TextDocument *document); + + bool movePosition(MoveOperation op, MoveMode = MoveAnchor, int n = 1); + int position() const; + void setPosition(int pos, MoveMode mode = MoveAnchor); + QString selectedText() const; + void clearSelection(); + int anchor() const; + TextDocument *document() const; + void insertText(const QString &text); + TextBlock block() const; + int positionInBlock() const; + int blockNumber() const; + + void select(SelectionType selection); + + bool hasSelection() const; + + void removeSelectedText(); + int selectionEnd() const; + + bool isNull() const; + +private: + TextDocument *m_document = nullptr; + int m_position = 0; + int m_anchor = 0; +}; +} // namespace Utils + +#endif // TEXTCURSOR_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextdocument_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextdocument_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f03f5e4efa0345219c256cf00fa6c7a8fa153ed9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextdocument_p.h @@ -0,0 +1,78 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTDOCUMENT_P_H +#define QTEXTDOCUMENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtextblock_p.h" + +#include <QtCore/qchar.h> +#include <QtCore/qvector.h> +#include <QtCore/qscopedpointer.h> +#include <QtCore/qmutex.h> + +#include <optional> + +namespace Utils { + +class TextBlockUserData; + +class TextDocument +{ +public: + TextDocument() = default; + explicit TextDocument(const QString &text); + + TextBlock findBlockByNumber(int blockNumber) const; + TextBlock findBlockByLineNumber(int lineNumber) const; + QChar characterAt(int pos) const; + int characterCount() const; + TextBlock begin() const; + TextBlock firstBlock() const; + TextBlock lastBlock() const; + + std::optional<int> version() const; + void setVersion(std::optional<int>); + + QString toPlainText() const; + void setPlainText(const QString &text); + + bool isModified() const; + void setModified(bool modified); + + void setUndoRedoEnabled(bool enable); + + void clear(); + + void setUserState(int blockNumber, int state); + int userState(int blockNumber) const; + QMutex *mutex() const; + +private: + struct Block + { + TextBlock textBlock; + int userState = -1; + }; + + QVector<Block> m_blocks; + + QString m_content; + bool m_modified = false; + std::optional<int> m_version; + mutable QMutex m_mutex; +}; +} // namespace Utils + +#endif // TEXTDOCUMENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextsynchronization_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextsynchronization_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2ee139ca9af837491d2c0d45c690d212d14d1e68 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qtextsynchronization_p.h @@ -0,0 +1,43 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTEXTSYNCHRONIZATION_P_H +#define QTEXTSYNCHRONIZATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlcodemodel_p.h" +#include "qlanguageserver_p.h" + +QT_BEGIN_NAMESPACE + +class TextSynchronization : public QLanguageServerModule +{ + Q_OBJECT +public: + TextSynchronization(QmlLsp::QQmlCodeModel *codeModel, QObject *parent = nullptr); + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; + +public Q_SLOTS: + void didOpenTextDocument(const QLspSpecification::DidOpenTextDocumentParams ¶ms); + void didDidChangeTextDocument(const QLspSpecification::DidChangeTextDocumentParams ¶ms); + void didCloseTextDocument(const QLspSpecification::DidCloseTextDocumentParams ¶ms); + +private: + QmlLsp::QQmlCodeModel *m_codeModel; +}; + +QT_END_NAMESPACE +#endif // QTEXTSYNCHRONIZATION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qworkspace_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qworkspace_p.h new file mode 100644 index 0000000000000000000000000000000000000000..632ff3aa6b1b98c2fa85a70fdca41198ee8d9aa9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLS/6.8.1/QtQmlLS/private/qworkspace_p.h @@ -0,0 +1,43 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWORKSPACE_P_H +#define QWORKSPACE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlcodemodel_p.h" +#include "qlanguageserver_p.h" + +QT_BEGIN_NAMESPACE + +class WorkspaceHandlers : public QLanguageServerModule +{ + Q_OBJECT +public: + enum class Status { NoIndex, Indexing }; + WorkspaceHandlers(QmlLsp::QQmlCodeModel *codeModel) : m_codeModel(codeModel) { } + QString name() const override; + void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; + void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, + QLspSpecification::InitializeResult &) override; +public Q_SLOTS: + void clientInitialized(QLanguageServer *); + +private: + QmlLsp::QQmlCodeModel *m_codeModel = nullptr; + Status m_status = Status::NoIndex; +}; + +QT_END_NAMESPACE + +#endif // QWORKSPACE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLocalStorage/6.8.1/QtQmlLocalStorage/private/qqmllocalstorage_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLocalStorage/6.8.1/QtQmlLocalStorage/private/qqmllocalstorage_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4bfafdba83b4c77b71e08748345c2428c2cc94e9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLocalStorage/6.8.1/QtQmlLocalStorage/private/qqmllocalstorage_p.h @@ -0,0 +1,42 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLOCALSTORAGE_P_H +#define QQMLLOCALSTORAGE_P_H + +#include "qqmllocalstorageglobal_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtQml/qqml.h> +#include <QtQml/private/qv4engine_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLLOCALSTORAGE_EXPORT QQmlLocalStorage : public QObject +{ + Q_OBJECT + QML_NAMED_ELEMENT(LocalStorage) + QML_ADDED_IN_VERSION(2, 0) + QML_SINGLETON + +public: + QQmlLocalStorage(QObject *parent = nullptr) : QObject(parent) {} + ~QQmlLocalStorage() override = default; + + Q_INVOKABLE void openDatabaseSync(QQmlV4FunctionPtr args); +}; + +QT_END_NAMESPACE + +#endif // QQMLLOCALSTORAGE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlLocalStorage/6.8.1/QtQmlLocalStorage/private/qqmllocalstorageglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlLocalStorage/6.8.1/QtQmlLocalStorage/private/qqmllocalstorageglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0682e2273b4fff4477d901f87e1e12db414d51ec --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlLocalStorage/6.8.1/QtQmlLocalStorage/private/qqmllocalstorageglobal_p.h @@ -0,0 +1,21 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLOCALSTORAGEGLOBAL_P_H +#define QQMLLOCALSTORAGEGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtQmlLocalStorage/qtqmllocalstorageexports.h> + +#endif // QQMLLOCALSTORAGEGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlbind_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlbind_p.h new file mode 100644 index 0000000000000000000000000000000000000000..eb05baab72637b07fbe29c5e4a7ec5bc72da6bdf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlbind_p.h @@ -0,0 +1,93 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLBIND_H +#define QQMLBIND_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQmlMeta/qtqmlmetaexports.h> + +#include <QtQml/qqml.h> +#include <QtCore/qobject.h> + +QT_BEGIN_NAMESPACE + +class QQmlBindPrivate; +class Q_QMLMETA_EXPORT QQmlBind : public QObject, public QQmlPropertyValueSource, public QQmlParserStatus +{ +public: + enum RestorationMode { + RestoreNone = 0x0, + RestoreBinding = 0x1, + RestoreValue = 0x2, + RestoreBindingOrValue = RestoreBinding | RestoreValue + }; + +private: + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlBind) + Q_INTERFACES(QQmlParserStatus) + Q_INTERFACES(QQmlPropertyValueSource) + Q_PROPERTY(QObject *target READ object WRITE setObject) + Q_PROPERTY(QString property READ property WRITE setProperty) + Q_PROPERTY(QVariant value READ value WRITE setValue) + Q_PROPERTY(bool when READ when WRITE setWhen) + Q_PROPERTY(bool delayed READ delayed WRITE setDelayed REVISION(2, 8)) + Q_PROPERTY(RestorationMode restoreMode READ restoreMode WRITE setRestoreMode + NOTIFY restoreModeChanged REVISION(2, 14)) + Q_ENUM(RestorationMode) + QML_NAMED_ELEMENT(Binding) + QML_ADDED_IN_VERSION(2, 0) + Q_CLASSINFO("ImmediatePropertyNames", "objectName,target,property,value,when,delayed,restoreMode"); + +public: + QQmlBind(QObject *parent=nullptr); + ~QQmlBind(); + + bool when() const; + void setWhen(bool); + + QObject *object(); + void setObject(QObject *); + + QString property() const; + void setProperty(const QString &); + + QVariant value() const; + void setValue(const QVariant &); + + bool delayed() const; + void setDelayed(bool); + + RestorationMode restoreMode() const; + void setRestoreMode(RestorationMode); + +Q_SIGNALS: + void restoreModeChanged(); + +protected: + void setTarget(const QQmlProperty &) override; + void classBegin() override; + void componentComplete() override; + +private: + void prepareEval(); + void eval(); + +private Q_SLOTS: + void targetValueChanged(); +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlconnections_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlconnections_p.h new file mode 100644 index 0000000000000000000000000000000000000000..00085b5455eef1152bd12cc4b0a87c93353e843a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlconnections_p.h @@ -0,0 +1,89 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCONNECTIONS_H +#define QQMLCONNECTIONS_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlcustomparser_p.h> + +#include <QtQmlMeta/qtqmlmetaexports.h> +#include <QtQml/qqml.h> + +#include <QtCore/qobject.h> +#include <QtCore/qstring.h> + +QT_BEGIN_NAMESPACE + +class QQmlBoundSignal; +class QQmlContext; +class QQmlConnectionsPrivate; +class Q_QMLMETA_EXPORT QQmlConnections : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlConnections) + + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged REVISION(2, 3)) + Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals) + QML_NAMED_ELEMENT(Connections) + QML_ADDED_IN_VERSION(2, 0) + QML_CUSTOMPARSER + +public: + QQmlConnections(QObject *parent = nullptr); + ~QQmlConnections(); + + QObject *target() const; + void setTarget(QObject *); + + bool isEnabled() const; + void setEnabled(bool enabled); + + bool ignoreUnknownSignals() const; + void setIgnoreUnknownSignals(bool ignore); + +protected: + void classBegin() override; + void componentComplete() override; + +Q_SIGNALS: + void targetChanged(); + Q_REVISION(2, 3) void enabledChanged(); + +private: + void connectSignals(); + void connectSignalsToMethods(); + void connectSignalsToBindings(); +}; + +// TODO: Drop this class as soon as we can +class QQmlConnectionsParser : public QQmlCustomParser +{ +public: + void verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props) override; + void applyBindings(QObject *object, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override; +}; + +// TODO: We won't need Connections to be a custom type anymore once we can drop the +// automatic signal handler inference from undeclared properties. +template<> +inline QQmlCustomParser *qmlCreateCustomParser<QQmlConnections>() +{ + return new QQmlConnectionsParser; +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmllocaleenums_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmllocaleenums_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bce89945d8e2e68b5c24b2baf538942ed33343e4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmllocaleenums_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLOCALEENUMS_H +#define QQMLLOCALEENUMS_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> +#include <private/qqmllocale_p.h> + +#include <QtQmlMeta/qtqmlmetaexports.h> +#include <QtQml/qqml.h> + +QT_REQUIRE_CONFIG(qml_locale); + +QT_BEGIN_NAMESPACE + +// Derive again so that we don't expose QQmlLocale as two different QML types +// as that would be bad style. +struct Q_QMLMETA_EXPORT QQmlLocaleEnums : public QQmlLocale +{ + Q_GADGET +}; + +// Use QML_FOREIGN_NAMESPACE so that we can expose QQmlLocaleEnums as a namespace +// rather than a value type. +namespace QQmlLocaleEnumsForeign +{ +Q_NAMESPACE_EXPORT(Q_QMLMETA_EXPORT) +QML_NAMED_ELEMENT(Locale) +QML_ADDED_IN_VERSION(2, 2) +QML_FOREIGN_NAMESPACE(QQmlLocaleEnums) +}; + +QT_END_NAMESPACE + +#endif // QQMLLOCALEENUMS_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlloggingcategory_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlloggingcategory_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9cb45e693988e70d7edd0b333163e9734cca84bf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlloggingcategory_p.h @@ -0,0 +1,71 @@ +// Copyright (C) 2016 Pelagicore AG +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLOGGINGCATEGORY_P_H +#define QQMLLOGGINGCATEGORY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmlloggingcategorybase_p.h> + +#include <QtQmlMeta/qtqmlmetaexports.h> + +#include <QtQml/qqml.h> +#include <QtQml/qqmlparserstatus.h> + +#include <QtCore/private/qglobal_p.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qobject.h> +#include <QtCore/qstring.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLMETA_EXPORT QQmlLoggingCategory : public QQmlLoggingCategoryBase, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(DefaultLogLevel defaultLogLevel READ defaultLogLevel WRITE setDefaultLogLevel REVISION(2, 12)) + QML_NAMED_ELEMENT(LoggingCategory) + QML_ADDED_IN_VERSION(2, 8) + +public: + enum DefaultLogLevel { + Debug = QtDebugMsg, + Info = QtInfoMsg, + Warning = QtWarningMsg, + Critical = QtCriticalMsg, + Fatal = QtFatalMsg + }; + Q_ENUM(DefaultLogLevel); + + QQmlLoggingCategory(QObject *parent = nullptr); + virtual ~QQmlLoggingCategory(); + + DefaultLogLevel defaultLogLevel() const; + void setDefaultLogLevel(DefaultLogLevel defaultLogLevel); + QString name() const; + void setName(const QString &name); + + void classBegin() override; + void componentComplete() override; + +private: + QByteArray m_name; + DefaultLogLevel m_defaultLogLevel = Debug; + bool m_initialized; +}; + +QT_END_NAMESPACE + +#endif // QQMLLOGGINGCATEGORY_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlmetadependencies_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlmetadependencies_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7374ddea9f3a361d408bf83169f533abd5bd482e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmlmetadependencies_p.h @@ -0,0 +1,30 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLMETADEPENDENCIES_P_H +#define QQMLMETADEPENDENCIES_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQmlMeta/qtqmlmetaexports.h> + +QT_BEGIN_NAMESPACE + +struct QQmlMetaDependencies +{ + // Export the method so that the linker cannot remove it. + static Q_QMLMETA_EXPORT bool collect(); +}; + +QT_END_NAMESPACE + +#endif // QQMLMETADEPENDENCIES_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmltimer_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmltimer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bba8bad18a2e62835a9727a3ca071292104697f2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlMeta/6.8.1/QtQmlMeta/private/qqmltimer_p.h @@ -0,0 +1,85 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTIMER_H +#define QQMLTIMER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlglobal_p.h> + +#include <QtQmlMeta/qtqmlmetaexports.h> +#include <QtQml/qqml.h> +#include <QtCore/qobject.h> + +QT_REQUIRE_CONFIG(qml_animation); + +QT_BEGIN_NAMESPACE + +class QQmlTimerPrivate; +class Q_QMLMETA_EXPORT QQmlTimer : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlTimer) + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged) + Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) + Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged) + Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged) + Q_PROPERTY(QObject *parent READ parent CONSTANT) + Q_CLASSINFO("ParentProperty", "parent") + QML_NAMED_ELEMENT(Timer) + QML_ADDED_IN_VERSION(2, 0) + +public: + QQmlTimer(QObject *parent=nullptr); + + void setInterval(int interval); + int interval() const; + + bool isRunning() const; + void setRunning(bool running); + + bool isRepeating() const; + void setRepeating(bool repeating); + + bool triggeredOnStart() const; + void setTriggeredOnStart(bool triggeredOnStart); + +protected: + void classBegin() override; + void componentComplete() override; + + bool event(QEvent *) override; + +public Q_SLOTS: + void start(); + void stop(); + void restart(); + +Q_SIGNALS: + void triggered(); + void runningChanged(); + void intervalChanged(); + void repeatChanged(); + void triggeredOnStartChanged(); + +private: + void update(); + +private Q_SLOTS: + void ticked(); +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlabstractdelegatecomponent_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlabstractdelegatecomponent_p.h new file mode 100644 index 0000000000000000000000000000000000000000..783d4824454b612cdb4fc09eb2a738da90aefef6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlabstractdelegatecomponent_p.h @@ -0,0 +1,51 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLABSTRACTDELEGATECOMPONENT_P_H +#define QQMLABSTRACTDELEGATECOMPONENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlmodelsglobal_p.h> +#include <private/qqmlcomponentattached_p.h> +#include <qqmlcomponent.h> + +QT_REQUIRE_CONFIG(qml_delegate_model); + +QT_BEGIN_NAMESPACE + +// TODO: consider making QQmlAbstractDelegateComponent public API +class QQmlAdaptorModel; +class Q_QMLMODELS_EXPORT QQmlAbstractDelegateComponent : public QQmlComponent +{ + Q_OBJECT + QML_NAMED_ELEMENT(AbstractDelegateComponent) + QML_ADDED_IN_VERSION(2, 0) + QML_UNCREATABLE("Cannot create instance of abstract class AbstractDelegateComponent.") + +public: + QQmlAbstractDelegateComponent(QObject *parent = nullptr); + ~QQmlAbstractDelegateComponent() override; + + virtual QQmlComponent *delegate(QQmlAdaptorModel *adaptorModel, int row, int column = 0) const = 0; + virtual QString role() const = 0; + +Q_SIGNALS: + void delegateChanged(); + +protected: + QVariant value(QQmlAdaptorModel *adaptorModel,int row, int column, const QString &role) const; +}; + +QT_END_NAMESPACE + +#endif // QQMLABSTRACTDELEGATECOMPONENT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmladaptormodel_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmladaptormodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ee5d4be7ce2e5e9fee7b399e99008f6ff3040776 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmladaptormodel_p.h @@ -0,0 +1,157 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLADAPTORMODEL_P_H +#define QQMLADAPTORMODEL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qabstractitemmodel.h> + +#include <private/qtqmlglobal_p.h> +#include <private/qqmllistaccessor_p.h> +#include <private/qtqmlmodelsglobal_p.h> +#include <private/qqmlguard_p.h> +#include <private/qqmlnullablevalue_p.h> +#include <private/qqmlpropertycache_p.h> + +QT_REQUIRE_CONFIG(qml_delegate_model); + +QT_BEGIN_NAMESPACE + +class QQmlEngine; + +class QQmlDelegateModel; +class QQmlDelegateModelItem; +class QQmlDelegateModelItemMetaType; + +class Q_QMLMODELS_EXPORT QQmlAdaptorModel : public QQmlGuard<QObject> +{ +public: + class Accessors + { + public: + inline Accessors() {} + virtual ~Accessors(); + virtual int rowCount(const QQmlAdaptorModel &) const { return 0; } + virtual int columnCount(const QQmlAdaptorModel &) const { return 0; } + virtual void cleanup(QQmlAdaptorModel &) const {} + + virtual QVariant value(const QQmlAdaptorModel &, int, const QString &) const { + return QVariant(); } + + virtual QQmlDelegateModelItem *createItem( + QQmlAdaptorModel &, + const QQmlRefPointer<QQmlDelegateModelItemMetaType> &, + int, int, int) { return nullptr; } + + virtual bool notify( + const QQmlAdaptorModel &, + const QList<QQmlDelegateModelItem *> &, + int, + int, + const QVector<int> &) const { return false; } + virtual void replaceWatchedRoles( + QQmlAdaptorModel &, + const QList<QByteArray> &, + const QList<QByteArray> &) const {} + virtual QVariant parentModelIndex(const QQmlAdaptorModel &) const { + return QVariant(); } + virtual QVariant modelIndex(const QQmlAdaptorModel &, int) const { + return QVariant(); } + virtual bool canFetchMore(const QQmlAdaptorModel &) const { return false; } + virtual void fetchMore(QQmlAdaptorModel &) const {} + + QScopedPointer<QMetaObject, QScopedPointerPodDeleter> metaObject; + QQmlPropertyCache::ConstPtr propertyCache; + }; + + Accessors *accessors; + QPersistentModelIndex rootIndex; + QQmlListAccessor list; + // we need to ensure that a JS created model does not get gced, but cannot + // arbitrarily set the parent (using QQmlStrongJSQObjectReference) of QObject based models, + // as that causes issues with singletons + QV4::PersistentValue modelStrongReference; + + QTypeRevision modelItemRevision = QTypeRevision::zero(); + + QQmlAdaptorModel(); + ~QQmlAdaptorModel(); + + inline QVariant model() const { return list.list(); } + void setModel(const QVariant &variant); + void invalidateModel(); + + bool isValid() const; + int count() const; + int rowCount() const; + int columnCount() const; + int rowAt(int index) const; + int columnAt(int index) const; + int indexAt(int row, int column) const; + + void useImportVersion(QTypeRevision revision); + + inline bool adaptsAim() const { return qobject_cast<QAbstractItemModel *>(object()); } + inline QAbstractItemModel *aim() { return static_cast<QAbstractItemModel *>(object()); } + inline const QAbstractItemModel *aim() const { return static_cast<const QAbstractItemModel *>(object()); } + + inline QVariant value(int index, const QString &role) const { + return accessors->value(*this, index, role); } + inline QQmlDelegateModelItem *createItem( + const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType, int index) + { + return accessors->createItem(*this, metaType, index, rowAt(index), columnAt(index)); + } + inline bool hasProxyObject() const { + return list.type() == QQmlListAccessor::Instance + || list.type() == QQmlListAccessor::ListProperty + || list.type() == QQmlListAccessor::ObjectList; + } + + inline bool notify( + const QList<QQmlDelegateModelItem *> &items, + int index, + int count, + const QVector<int> &roles) const { + return accessors->notify(*this, items, index, count, roles); } + inline void replaceWatchedRoles( + const QList<QByteArray> &oldRoles, const QList<QByteArray> &newRoles) { + accessors->replaceWatchedRoles(*this, oldRoles, newRoles); } + + inline QVariant modelIndex(int index) const { return accessors->modelIndex(*this, index); } + inline QVariant parentModelIndex() const { return accessors->parentModelIndex(*this); } + inline bool canFetchMore() const { return accessors->canFetchMore(*this); } + inline void fetchMore() { return accessors->fetchMore(*this); } + +private: + static void objectDestroyedImpl(QQmlGuardImpl *); + + Accessors m_nullAccessors; +}; + +class QQmlAdaptorModelProxyInterface +{ +public: + virtual ~QQmlAdaptorModelProxyInterface() {} + + virtual QObject *proxiedObject() = 0; +}; + +#define QQmlAdaptorModelProxyInterface_iid "org.qt-project.Qt.QQmlAdaptorModelProxyInterface" + +Q_DECLARE_INTERFACE(QQmlAdaptorModelProxyInterface, QQmlAdaptorModelProxyInterface_iid) + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmladaptormodelenginedata_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmladaptormodelenginedata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3baa7eccc064ff811ab414fe93d80961217555d9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmladaptormodelenginedata_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QQMLADAPTORMODELENGINEDATA_P_H +#define QQMLADAPTORMODELENGINEDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmldelegatemodel_p_p.h> +#include <private/qmetaobjectbuilder_p.h> +#include <private/qqmlproperty_p.h> + +#include <private/qv4value_p.h> +#include <private/qv4functionobject_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlAdaptorModelEngineData : public QV4::ExecutionEngine::Deletable +{ +public: + QQmlAdaptorModelEngineData(QV4::ExecutionEngine *v4); + + QV4::ExecutionEngine *v4; + QV4::PersistentValue listItemProto; + + static QV4::ReturnedValue get_index(const QV4::FunctionObject *f, const QV4::Value *thisObject, const QV4::Value *, int) + { + QV4::Scope scope(f); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); + if (!o) + RETURN_RESULT(scope.engine->throwTypeError(QStringLiteral("Not a valid DelegateModel object"))); + + RETURN_RESULT(QV4::Encode(o->d()->item->index)); + } + + template <typename T, typename M> static void setModelDataType(QMetaObjectBuilder *builder, M *metaType) + { + builder->setFlags(MetaObjectFlag::DynamicMetaObject); + builder->setClassName(T::staticMetaObject.className()); + builder->setSuperClass(&T::staticMetaObject); + metaType->propertyOffset = T::staticMetaObject.propertyCount(); + metaType->signalOffset = T::staticMetaObject.methodCount(); + } + + static void addProperty(QMetaObjectBuilder *builder, int propertyId, const QByteArray &propertyName, const QByteArray &propertyType) + { + builder->addSignal("__" + QByteArray::number(propertyId) + "()"); + QMetaPropertyBuilder property = builder->addProperty( + propertyName, propertyType, propertyId); + property.setWritable(true); + } + + V4_DEFINE_EXTENSION(QQmlAdaptorModelEngineData, get) +}; + +QT_END_NAMESPACE + +#endif // QQMLADAPTORMODELENGINEDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlchangeset_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlchangeset_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d11271d261881043649d8dd448315f773c191936 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlchangeset_p.h @@ -0,0 +1,128 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLCHANGESET_P_H +#define QQMLCHANGESET_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQmlIntegration/qqmlintegration.h> +#include <QtCore/qdebug.h> +#include <QtCore/qvector.h> +#include <QtQmlModels/private/qtqmlmodelsglobal_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLMODELS_EXPORT QQmlChangeSet +{ + Q_GADGET + QML_ANONYMOUS +public: + struct MoveKey + { + MoveKey() {} + MoveKey(int moveId, int offset) : moveId(moveId), offset(offset) {} + int moveId = -1; + int offset = 0; + }; + + // The storrage for Change (below). This struct is trivial, which it has to be in order to store + // it in a QV4::Heap::Base object. The Change struct doesn't add any storage fields, so it is + // safe to cast ChangeData to/from Change. + struct ChangeData + { + int index; + int count; + int moveId; + int offset; + }; + + struct Change: ChangeData + { + Change() { + index = 0; + count = 0; + moveId = -1; + offset = 0; + } + Change(int index, int count, int moveId = -1, int offset = 0) { + this->index = index; + this->count = count; + this->moveId = moveId; + this->offset = offset; + } + + bool isMove() const { return moveId >= 0; } + + MoveKey moveKey(int index) const { + return MoveKey(moveId, index - Change::index + offset); } + + int start() const { return index; } + int end() const { return index + count; } + }; + + QQmlChangeSet(); + QQmlChangeSet(const QQmlChangeSet &changeSet); + ~QQmlChangeSet(); + + QQmlChangeSet &operator =(const QQmlChangeSet &changeSet); + + const QVector<Change> &removes() const { return m_removes; } + const QVector<Change> &inserts() const { return m_inserts; } + const QVector<Change> &changes() const { return m_changes; } + + void insert(int index, int count); + void remove(int index, int count); + void move(int from, int to, int count, int moveId); + void change(int index, int count); + + void insert(const QVector<Change> &inserts); + void remove(const QVector<Change> &removes, QVector<Change> *inserts = nullptr); + void move(const QVector<Change> &removes, const QVector<Change> &inserts); + void change(const QVector<Change> &changes); + void apply(const QQmlChangeSet &changeSet); + + bool isEmpty() const { return m_removes.empty() && m_inserts.empty() && m_changes.isEmpty(); } + + void clear() + { + m_removes.clear(); + m_inserts.clear(); + m_changes.clear(); + m_difference = 0; + } + + int difference() const { return m_difference; } + +private: + void remove(QVector<Change> *removes, QVector<Change> *inserts); + void change(QVector<Change> *changes); + + QVector<Change> m_removes; + QVector<Change> m_inserts; + QVector<Change> m_changes; + int m_difference; +}; + +Q_DECLARE_TYPEINFO(QQmlChangeSet::Change, Q_PRIMITIVE_TYPE); +Q_DECLARE_TYPEINFO(QQmlChangeSet::MoveKey, Q_PRIMITIVE_TYPE); + +inline size_t qHash(const QQmlChangeSet::MoveKey &key) { return qHash(qMakePair(key.moveId, key.offset)); } +inline bool operator ==(const QQmlChangeSet::MoveKey &l, const QQmlChangeSet::MoveKey &r) { + return l.moveId == r.moveId && l.offset == r.offset; } + +Q_QMLMODELS_EXPORT QDebug operator <<(QDebug debug, const QQmlChangeSet::Change &change); +Q_QMLMODELS_EXPORT QDebug operator <<(QDebug debug, const QQmlChangeSet &change); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldelegatemodel_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldelegatemodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e4097e702ab677a9bf34a7972046c373cc89044b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldelegatemodel_p.h @@ -0,0 +1,235 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDATAMODEL_P_H +#define QQMLDATAMODEL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlmodelsglobal_p.h> +#include <private/qqmllistcompositor_p.h> +#include <private/qqmlobjectmodel_p.h> +#include <private/qqmlincubator_p.h> + +#include <QtCore/qabstractitemmodel.h> +#include <QtCore/qstringlist.h> + +QT_REQUIRE_CONFIG(qml_delegate_model); + +QT_BEGIN_NAMESPACE + +class QQmlChangeSet; +class QQuickPackage; +class QQmlDelegateModelGroup; +class QQmlDelegateModelAttached; +class QQmlDelegateModelPrivate; + + +class Q_QMLMODELS_EXPORT QQmlDelegateModel : public QQmlInstanceModel, public QQmlParserStatus +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlDelegateModel) + + Q_PROPERTY(QVariant model READ model WRITE setModel) + Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) + Q_PROPERTY(QString filterOnGroup READ filterGroup WRITE setFilterGroup NOTIFY filterGroupChanged RESET resetFilterGroup) + Q_PROPERTY(QQmlDelegateModelGroup *items READ items CONSTANT) //TODO : worth renaming? + Q_PROPERTY(QQmlDelegateModelGroup *persistedItems READ persistedItems CONSTANT) + Q_PROPERTY(QQmlListProperty<QQmlDelegateModelGroup> groups READ groups CONSTANT) + Q_PROPERTY(QObject *parts READ parts CONSTANT) + Q_PROPERTY(QVariant rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged) + Q_CLASSINFO("DefaultProperty", "delegate") + QML_NAMED_ELEMENT(DelegateModel) + QML_ADDED_IN_VERSION(2, 1) + QML_ATTACHED(QQmlDelegateModelAttached) + Q_INTERFACES(QQmlParserStatus) + +public: + QQmlDelegateModel(); + QQmlDelegateModel(QQmlContext *, QObject *parent=nullptr); + ~QQmlDelegateModel(); + + void classBegin() override; + void componentComplete() override; + + QVariant model() const; + void setModel(const QVariant &); + + QQmlComponent *delegate() const; + void setDelegate(QQmlComponent *); + + QVariant rootIndex() const; + void setRootIndex(const QVariant &root); + + Q_INVOKABLE QVariant modelIndex(int idx) const; + Q_INVOKABLE QVariant parentModelIndex() const; + + int count() const override; + bool isValid() const override { return delegate() != nullptr; } + QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; + ReleaseFlags release(QObject *object, ReusableFlag reusableFlag = NotReusable) override; + void cancel(int index) override; + QVariant variantValue(int index, const QString &role) override; + void setWatchedRoles(const QList<QByteArray> &roles) override; + QQmlIncubator::Status incubationStatus(int index) override; + + void drainReusableItemsPool(int maxPoolTime) override; + int poolSize() override; + + int indexOf(QObject *object, QObject *objectContext) const override; + + QString filterGroup() const; + void setFilterGroup(const QString &group); + void resetFilterGroup(); + + QQmlDelegateModelGroup *items(); + QQmlDelegateModelGroup *persistedItems(); + QQmlListProperty<QQmlDelegateModelGroup> groups(); + QObject *parts(); + + const QAbstractItemModel *abstractItemModel() const override; + + bool event(QEvent *) override; + + static QQmlDelegateModelAttached *qmlAttachedProperties(QObject *obj); + +Q_SIGNALS: + void filterGroupChanged(); + void defaultGroupsChanged(); + void rootIndexChanged(); + void delegateChanged(); + +private Q_SLOTS: + void _q_itemsChanged(int index, int count, const QVector<int> &roles); + void _q_itemsInserted(int index, int count); + void _q_itemsRemoved(int index, int count); + void _q_itemsMoved(int from, int to, int count); + void _q_modelAboutToBeReset(); + void _q_rowsInserted(const QModelIndex &,int,int); + void _q_columnsInserted(const QModelIndex &, int, int); + void _q_columnsRemoved(const QModelIndex &, int, int); + void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int); + void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end); + void _q_rowsRemoved(const QModelIndex &,int,int); + void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int); + void _q_dataChanged(const QModelIndex&,const QModelIndex&,const QVector<int> &); + void _q_layoutChanged(const QList<QPersistentModelIndex>&, QAbstractItemModel::LayoutChangeHint); + +private: + void handleModelReset(); + bool isDescendantOf(const QPersistentModelIndex &desc, const QList<QPersistentModelIndex> &parents) const; + + Q_DISABLE_COPY(QQmlDelegateModel) +}; + +class QQmlDelegateModelGroupPrivate; +class Q_QMLMODELS_EXPORT QQmlDelegateModelGroup : public QObject +{ + Q_OBJECT + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(bool includeByDefault READ defaultInclude WRITE setDefaultInclude NOTIFY defaultIncludeChanged) + QML_NAMED_ELEMENT(DelegateModelGroup) + QML_ADDED_IN_VERSION(2, 1) +public: + QQmlDelegateModelGroup(QObject *parent = nullptr); + QQmlDelegateModelGroup(const QString &name, QQmlDelegateModel *model, int compositorType, QObject *parent = nullptr); + ~QQmlDelegateModelGroup(); + + QString name() const; + void setName(const QString &name); + + int count() const; + + bool defaultInclude() const; + void setDefaultInclude(bool include); + + Q_INVOKABLE QJSValue get(int index); + +public Q_SLOTS: + void insert(QQmlV4FunctionPtr); + void create(QQmlV4FunctionPtr); + void resolve(QQmlV4FunctionPtr); + void remove(QQmlV4FunctionPtr); + void addGroups(QQmlV4FunctionPtr); + void removeGroups(QQmlV4FunctionPtr); + void setGroups(QQmlV4FunctionPtr); + void move(QQmlV4FunctionPtr); + +Q_SIGNALS: + void countChanged(); + void nameChanged(); + void defaultIncludeChanged(); + void changed(const QJSValue &removed, const QJSValue &inserted); +private: + Q_DECLARE_PRIVATE(QQmlDelegateModelGroup) +}; + +class QQmlDelegateModelItem; +class QQmlDelegateModelAttachedMetaObject; +class QQmlDelegateModelAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlDelegateModel *model READ model CONSTANT FINAL) + Q_PROPERTY(QStringList groups READ groups WRITE setGroups NOTIFY groupsChanged FINAL) + Q_PROPERTY(bool isUnresolved READ isUnresolved NOTIFY unresolvedChanged FINAL) + Q_PROPERTY(bool inPersistedItems READ inPersistedItems WRITE setInPersistedItems NOTIFY groupsChanged FINAL) + Q_PROPERTY(bool inItems READ inItems WRITE setInItems NOTIFY groupsChanged FINAL) + Q_PROPERTY(int persistedItemsIndex READ persistedItemsIndex NOTIFY groupsChanged FINAL) + Q_PROPERTY(int itemsIndex READ itemsIndex NOTIFY groupsChanged FINAL) + +public: + QQmlDelegateModelAttached(QObject *parent); + QQmlDelegateModelAttached(QQmlDelegateModelItem *cacheItem, QObject *parent); + ~QQmlDelegateModelAttached() {} + + void resetCurrentIndex(); + void setCacheItem(QQmlDelegateModelItem *item); + + void setInPersistedItems(bool inPersisted); + bool inPersistedItems() const; + int persistedItemsIndex() const; + + void setInItems(bool inItems); + bool inItems() const; + int itemsIndex() const; + + QQmlDelegateModel *model() const; + + QStringList groups() const; + void setGroups(const QStringList &groups); + + bool isUnresolved() const; + + void emitChanges(); + + void emitUnresolvedChanged() { Q_EMIT unresolvedChanged(); } + +Q_SIGNALS: + void groupsChanged(); + void unresolvedChanged(); + +private: + void setInGroup(QQmlListCompositor::Group group, bool inGroup); + +public: + QQmlDelegateModelItem *m_cacheItem; + int m_previousGroups; + int m_currentIndex[QQmlListCompositor::MaximumGroupCount]; + int m_previousIndex[QQmlListCompositor::MaximumGroupCount]; + + friend class QQmlDelegateModelAttachedMetaObject; +}; + +QT_END_NAMESPACE + +#endif // QQMLDATAMODEL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldelegatemodel_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldelegatemodel_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e7e812767667c60b8f8baaaaae9bc069df48ab34 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldelegatemodel_p_p.h @@ -0,0 +1,450 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDATAMODEL_P_P_H +#define QQMLDATAMODEL_P_P_H + +#include "qqmldelegatemodel_p.h" +#include <private/qv4qobjectwrapper_p.h> + +#include <QtQml/qqmlcontext.h> +#include <QtQml/qqmlincubator.h> + +#include <private/qqmladaptormodel_p.h> +#include <private/qqmlopenmetaobject_p.h> + +#include <QtCore/qloggingcategory.h> +#include <QtCore/qpointer.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_REQUIRE_CONFIG(qml_delegate_model); + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(lcItemViewDelegateRecycling) + +typedef QQmlListCompositor Compositor; + +class QQmlDelegateModelAttachedMetaObject; +class QQmlAbstractDelegateComponent; + +class Q_QMLMODELS_EXPORT QQmlDelegateModelItemMetaType final + : public QQmlRefCounted<QQmlDelegateModelItemMetaType> +{ +public: + QQmlDelegateModelItemMetaType(QV4::ExecutionEngine *engine, QQmlDelegateModel *model, const QStringList &groupNames); + ~QQmlDelegateModelItemMetaType(); + + void initializeMetaObject(); + void initializePrototype(); + + int parseGroups(const QStringList &groupNames) const; + int parseGroups(const QV4::Value &groupNames) const; + + QPointer<QQmlDelegateModel> model; + const int groupCount; + QV4::ExecutionEngine * const v4Engine; + QQmlDelegateModelAttachedMetaObject *metaObject; + const QStringList groupNames; + QV4::PersistentValue modelItemProto; +}; + +class QQmlAdaptorModel; +class QQDMIncubationTask; + +class QQmlDelegateModelItem : public QObject +{ + Q_OBJECT + Q_PROPERTY(int index READ modelIndex NOTIFY modelIndexChanged) + Q_PROPERTY(int row READ modelRow NOTIFY rowChanged REVISION(2, 12)) + Q_PROPERTY(int column READ modelColumn NOTIFY columnChanged REVISION(2, 12)) + Q_PROPERTY(QObject *model READ modelObject CONSTANT) +public: + QQmlDelegateModelItem(const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType, + QQmlAdaptorModel::Accessors *accessor, int modelIndex, + int row, int column); + ~QQmlDelegateModelItem(); + + void referenceObject() { ++objectRef; } + bool releaseObject() + { + Q_ASSERT(objectRef > 0); + return --objectRef == 0 && !(groups & Compositor::PersistedFlag); + } + bool isObjectReferenced() const { return objectRef != 0 || (groups & Compositor::PersistedFlag); } + void childContextObjectDestroyed(QObject *childContextObject); + + bool isReferenced() const { + return scriptRef + || incubationTask + || ((groups & Compositor::UnresolvedFlag) && (groups & Compositor::GroupMask)); + } + + void Dispose(); + + QObject *modelObject() { return this; } + + void destroyObject(); + + static QQmlDelegateModelItem *dataForObject(QObject *object); + + int groupIndex(Compositor::Group group); + + int modelRow() const { return row; } + int modelColumn() const { return column; } + int modelIndex() const { return index; } + virtual void setModelIndex(int idx, int newRow, int newColumn, bool alwaysEmit = false); + + virtual QV4::ReturnedValue get() { return QV4::QObjectWrapper::wrap(v4, this); } + + virtual void setValue(const QString &role, const QVariant &value) { Q_UNUSED(role); Q_UNUSED(value); } + virtual bool resolveIndex(const QQmlAdaptorModel &, int) { return false; } + + static QV4::ReturnedValue get_model(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue get_groups(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue set_groups(const QV4::FunctionObject *, const QV4::Value *thisObject, const QV4::Value *argv, int argc); + static QV4::ReturnedValue get_member(QQmlDelegateModelItem *thisItem, uint flag, const QV4::Value &); + static QV4::ReturnedValue set_member(QQmlDelegateModelItem *thisItem, uint flag, const QV4::Value &arg); + static QV4::ReturnedValue get_index(QQmlDelegateModelItem *thisItem, uint flag, const QV4::Value &arg); + + QV4::ExecutionEngine *v4; + QQmlRefPointer<QQmlDelegateModelItemMetaType> const metaType; + QQmlRefPointer<QQmlContextData> contextData; + QPointer<QObject> object; + QPointer<QQmlDelegateModelAttached> attached; + QQDMIncubationTask *incubationTask; + QQmlComponent *delegate; + int poolTime; + int objectRef; + int scriptRef; + int groups; + int index; + +Q_SIGNALS: + void modelIndexChanged(); + Q_REVISION(2, 12) void rowChanged(); + Q_REVISION(2, 12) void columnChanged(); + +protected: + void objectDestroyed(QObject *); + int row; + int column; +}; + +namespace QV4 { +namespace Heap { +struct QQmlDelegateModelItemObject : Object { + inline void init(QQmlDelegateModelItem *item); + void destroy(); + QQmlDelegateModelItem *item; +}; + +} +} + +struct QQmlDelegateModelItemObject : QV4::Object +{ + V4_OBJECT2(QQmlDelegateModelItemObject, QV4::Object) + V4_NEEDS_DESTROY +}; + +void QV4::Heap::QQmlDelegateModelItemObject::init(QQmlDelegateModelItem *item) +{ + Object::init(); + this->item = item; +} + +class QQmlReusableDelegateModelItemsPool +{ +public: + void insertItem(QQmlDelegateModelItem *modelItem); + QQmlDelegateModelItem *takeItem(const QQmlComponent *delegate, int newIndexHint); + void reuseItem(QQmlDelegateModelItem *item, int newModelIndex); + void drain(int maxPoolTime, std::function<void(QQmlDelegateModelItem *cacheItem)> releaseItem); + int size() { return m_reusableItemsPool.size(); } + +private: + QList<QQmlDelegateModelItem *> m_reusableItemsPool; +}; + +class QQmlDelegateModelPrivate; +class QQDMIncubationTask : public QQmlIncubator +{ +public: + QQDMIncubationTask(QQmlDelegateModelPrivate *l, IncubationMode mode) + : QQmlIncubator(mode) + , incubating(nullptr) + , vdm(l) {} + + void initializeRequiredProperties(QQmlDelegateModelItem *modelItemToIncubate, QObject* object); + void statusChanged(Status) override; + void setInitialState(QObject *) override; + + QQmlDelegateModelItem *incubating = nullptr; + QQmlDelegateModelPrivate *vdm = nullptr; + QQmlRefPointer<QQmlContextData> proxyContext; + QPointer<QObject> proxiedObject = nullptr; // the proxied object might disapear, so we use a QPointer instead of a raw one + int index[QQmlListCompositor::MaximumGroupCount]; +}; + + +class QQmlDelegateModelGroupEmitter +{ +public: + virtual ~QQmlDelegateModelGroupEmitter() {} + virtual void emitModelUpdated(const QQmlChangeSet &changeSet, bool reset) = 0; + virtual void createdPackage(int, QQuickPackage *) {} + virtual void initPackage(int, QQuickPackage *) {} + virtual void destroyingPackage(QQuickPackage *) {} + + QIntrusiveListNode emitterNode; +}; + +typedef QIntrusiveList<QQmlDelegateModelGroupEmitter, &QQmlDelegateModelGroupEmitter::emitterNode> QQmlDelegateModelGroupEmitterList; + +class QQmlDelegateModelGroupPrivate : public QObjectPrivate +{ +public: + Q_DECLARE_PUBLIC(QQmlDelegateModelGroup) + + QQmlDelegateModelGroupPrivate() : group(Compositor::Cache), defaultInclude(false) {} + + static QQmlDelegateModelGroupPrivate *get(QQmlDelegateModelGroup *group) { + return static_cast<QQmlDelegateModelGroupPrivate *>(QObjectPrivate::get(group)); } + + void setModel(QQmlDelegateModel *model, Compositor::Group group); + bool isChangedConnected(); + void emitChanges(QV4::ExecutionEngine *engine); + void emitModelUpdated(bool reset); + + void createdPackage(int index, QQuickPackage *package); + void initPackage(int index, QQuickPackage *package); + void destroyingPackage(QQuickPackage *package); + + bool parseIndex(const QV4::Value &value, int *index, Compositor::Group *group) const; + bool parseGroupArgs( + QQmlV4FunctionPtr args, Compositor::Group *group, int *index, int *count, int *groups) const; + + Compositor::Group group; + QPointer<QQmlDelegateModel> model; + QQmlDelegateModelGroupEmitterList emitters; + QQmlChangeSet changeSet; + QString name; + bool defaultInclude; +}; + +class QQmlDelegateModelParts; + +class QQmlDelegateModelPrivate : public QObjectPrivate, public QQmlDelegateModelGroupEmitter +{ + Q_DECLARE_PUBLIC(QQmlDelegateModel) +public: + QQmlDelegateModelPrivate(QQmlContext *); + ~QQmlDelegateModelPrivate(); + + static QQmlDelegateModelPrivate *get(QQmlDelegateModel *m) { + return static_cast<QQmlDelegateModelPrivate *>(QObjectPrivate::get(m)); + } + + void init(); + void connectModel(QQmlAdaptorModel *model); + void connectToAbstractItemModel(); + void disconnectFromAbstractItemModel(); + + void requestMoreIfNecessary(); + QObject *object(Compositor::Group group, int index, QQmlIncubator::IncubationMode incubationMode); + QQmlDelegateModel::ReleaseFlags release(QObject *object, QQmlInstanceModel::ReusableFlag reusable = QQmlInstanceModel::NotReusable); + QVariant variantValue(Compositor::Group group, int index, const QString &name); + void emitCreatedPackage(QQDMIncubationTask *incubationTask, QQuickPackage *package); + void emitInitPackage(QQDMIncubationTask *incubationTask, QQuickPackage *package); + void emitCreatedItem(QQDMIncubationTask *incubationTask, QObject *item) { + Q_EMIT q_func()->createdItem(incubationTask->index[m_compositorGroup], item); } + void emitInitItem(QQDMIncubationTask *incubationTask, QObject *item) { + Q_EMIT q_func()->initItem(incubationTask->index[m_compositorGroup], item); } + void emitDestroyingPackage(QQuickPackage *package); + void emitDestroyingItem(QObject *item) { Q_EMIT q_func()->destroyingItem(item); } + void addCacheItem(QQmlDelegateModelItem *item, Compositor::iterator it); + void removeCacheItem(QQmlDelegateModelItem *cacheItem); + void destroyCacheItem(QQmlDelegateModelItem *cacheItem); + void updateFilterGroup(); + + void reuseItem(QQmlDelegateModelItem *item, int newModelIndex, int newGroups); + void drainReusableItemsPool(int maxPoolTime); + QQmlComponent *resolveDelegate(int index); + + void addGroups(Compositor::iterator from, int count, Compositor::Group group, int groupFlags); + void removeGroups(Compositor::iterator from, int count, Compositor::Group group, int groupFlags); + void setGroups(Compositor::iterator from, int count, Compositor::Group group, int groupFlags); + + void itemsInserted( + const QVector<Compositor::Insert> &inserts, + QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> *translatedInserts, + QHash<int, QList<QQmlDelegateModelItem *> > *movedItems = nullptr); + void itemsInserted(const QVector<Compositor::Insert> &inserts); + void itemsRemoved( + const QVector<Compositor::Remove> &removes, + QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> *translatedRemoves, + QHash<int, QList<QQmlDelegateModelItem *> > *movedItems = nullptr); + void itemsRemoved(const QVector<Compositor::Remove> &removes); + void itemsMoved( + const QVector<Compositor::Remove> &removes, const QVector<Compositor::Insert> &inserts); + void itemsChanged(const QVector<Compositor::Change> &changes); + void emitChanges(); + void emitModelUpdated(const QQmlChangeSet &changeSet, bool reset) override; + void delegateChanged(bool add = true, bool remove = true); + + enum class InsertionResult { + Success, + Error, + Retry + }; + InsertionResult insert(Compositor::insert_iterator &before, const QV4::Value &object, int groups); + + int adaptorModelCount() const; + + static void group_append(QQmlListProperty<QQmlDelegateModelGroup> *property, QQmlDelegateModelGroup *group); + static qsizetype group_count(QQmlListProperty<QQmlDelegateModelGroup> *property); + static QQmlDelegateModelGroup *group_at(QQmlListProperty<QQmlDelegateModelGroup> *property, qsizetype index); + + void releaseIncubator(QQDMIncubationTask *incubationTask); + void incubatorStatusChanged(QQDMIncubationTask *incubationTask, QQmlIncubator::Status status); + void setInitialState(QQDMIncubationTask *incubationTask, QObject *o); + + QQmlAdaptorModel m_adaptorModel; + QQmlListCompositor m_compositor; + QQmlStrongJSQObjectReference<QQmlComponent> m_delegate; + QQmlAbstractDelegateComponent *m_delegateChooser; + QMetaObject::Connection m_delegateChooserChanged; + QQmlDelegateModelItemMetaType *m_cacheMetaType; + QPointer<QQmlContext> m_context; + QQmlDelegateModelParts *m_parts; + QQmlDelegateModelGroupEmitterList m_pendingParts; + + QList<QQmlDelegateModelItem *> m_cache; + QQmlReusableDelegateModelItemsPool m_reusableItemsPool; + QList<QQDMIncubationTask *> m_finishedIncubating; + QList<QByteArray> m_watchedRoles; + + QString m_filterGroup; + + int m_count; + int m_groupCount; + + QQmlListCompositor::Group m_compositorGroup; + bool m_complete : 1; + bool m_delegateValidated : 1; + bool m_reset : 1; + bool m_transaction : 1; + bool m_incubatorCleanupScheduled : 1; + bool m_waitingToFetchMore : 1; + + union { + struct { + QQmlDelegateModelGroup *m_cacheItems; + QQmlDelegateModelGroup *m_items; + QQmlDelegateModelGroup *m_persistedItems; + }; + QQmlDelegateModelGroup *m_groups[Compositor::MaximumGroupCount]; + }; +}; + +class QQmlPartsModel : public QQmlInstanceModel, public QQmlDelegateModelGroupEmitter +{ + Q_OBJECT + Q_PROPERTY(QString filterOnGroup READ filterGroup WRITE setFilterGroup NOTIFY filterGroupChanged RESET resetFilterGroup FINAL) +public: + QQmlPartsModel(QQmlDelegateModel *model, const QString &part, QObject *parent = nullptr); + ~QQmlPartsModel(); + + QString filterGroup() const; + void setFilterGroup(const QString &group); + void resetFilterGroup(); + void updateFilterGroup(); + void updateFilterGroup(Compositor::Group group, const QQmlChangeSet &changeSet); + + int count() const override; + bool isValid() const override; + QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; + ReleaseFlags release(QObject *item, ReusableFlag reusable = NotReusable) override; + QVariant variantValue(int index, const QString &role) override; + QList<QByteArray> watchedRoles() const { return m_watchedRoles; } + void setWatchedRoles(const QList<QByteArray> &roles) override; + QQmlIncubator::Status incubationStatus(int index) override; + + int indexOf(QObject *item, QObject *objectContext) const override; + + void emitModelUpdated(const QQmlChangeSet &changeSet, bool reset) override; + + void createdPackage(int index, QQuickPackage *package) override; + void initPackage(int index, QQuickPackage *package) override; + void destroyingPackage(QQuickPackage *package) override; + +Q_SIGNALS: + void filterGroupChanged(); + +private: + QQmlDelegateModel *m_model; + QMultiHash<QObject *, QQuickPackage *> m_packaged; + QString m_part; + QString m_filterGroup; + QList<QByteArray> m_watchedRoles; + QVector<int> m_pendingPackageInitializations; // vector holds model indices + Compositor::Group m_compositorGroup; + bool m_inheritGroup; + bool m_modelUpdatePending = true; +}; + +class QMetaPropertyBuilder; + +class QQmlDelegateModelPartsMetaObject : public QQmlOpenMetaObject +{ +public: + QQmlDelegateModelPartsMetaObject(QObject *parent) + : QQmlOpenMetaObject(parent) {} + + void propertyCreated(int, QMetaPropertyBuilder &) override; + QVariant initialValue(int) override; +}; + +class QQmlDelegateModelParts : public QObject +{ +Q_OBJECT +public: + QQmlDelegateModelParts(QQmlDelegateModel *parent); + + QQmlDelegateModel *model; + QList<QQmlPartsModel *> models; +}; + +class QQmlDelegateModelAttachedMetaObject final + : public QAbstractDynamicMetaObject, + public QQmlRefCounted<QQmlDelegateModelAttachedMetaObject> +{ +public: + QQmlDelegateModelAttachedMetaObject( + QQmlDelegateModelItemMetaType *metaType, QMetaObject *metaObject); + ~QQmlDelegateModelAttachedMetaObject(); + + void objectDestroyed(QObject *) override; + int metaCall(QObject *, QMetaObject::Call, int _id, void **) override; + +private: + QQmlDelegateModelItemMetaType * const metaType; + QMetaObject * const metaObject; + const int memberPropertyOffset; + const int indexPropertyOffset; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldmabstractitemmodeldata_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldmabstractitemmodeldata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7e96fc0c235fabde247339d481dccbadc4cbacd5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldmabstractitemmodeldata_p.h @@ -0,0 +1,346 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDMABSTRACTITEMMODELDATA_P_H +#define QQMLDMABSTRACTITEMMODELDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmladaptormodelenginedata_p.h> +#include <private/qqmldelegatemodel_p_p.h> +#include <private/qobject_p.h> + +QT_BEGIN_NAMESPACE + +class VDMAbstractItemModelDataType; +class QQmlDMAbstractItemModelData : public QQmlDelegateModelItem +{ + Q_OBJECT + Q_PROPERTY(bool hasModelChildren READ hasModelChildren CONSTANT) + Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged) + QT_ANONYMOUS_PROPERTY(QVariant READ modelData NOTIFY modelDataChanged FINAL) + +public: + QQmlDMAbstractItemModelData( + const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType, + VDMAbstractItemModelDataType *dataType, + int index, int row, int column); + + int metaCall(QMetaObject::Call call, int id, void **arguments); + bool hasModelChildren() const; + + QV4::ReturnedValue get() override; + void setValue(const QString &role, const QVariant &value) override; + bool resolveIndex(const QQmlAdaptorModel &model, int idx) override; + + static QV4::ReturnedValue get_property( + const QV4::FunctionObject *b, const QV4::Value *thisObject, + const QV4::Value *argv, int argc); + static QV4::ReturnedValue set_property( + const QV4::FunctionObject *b, const QV4::Value *thisObject, + const QV4::Value *argv, int argc); + + static QV4::ReturnedValue get_modelData( + const QV4::FunctionObject *b, const QV4::Value *thisObject, + const QV4::Value *argv, int argc); + static QV4::ReturnedValue set_modelData( + const QV4::FunctionObject *b, const QV4::Value *thisObject, + const QV4::Value *argv, int argc); + + QVariant modelData() const; + void setModelData(const QVariant &modelData); + + const VDMAbstractItemModelDataType *type() const { return m_type; } + +Q_SIGNALS: + void modelDataChanged(); + +private: + QVariant value(int role) const; + void setValue(int role, const QVariant &value); + + VDMAbstractItemModelDataType *m_type; + QVector<QVariant> m_cachedData; +}; + +class VDMAbstractItemModelDataType final + : public QQmlRefCounted<VDMAbstractItemModelDataType> + , public QQmlAdaptorModel::Accessors + , public QAbstractDynamicMetaObject +{ +public: + VDMAbstractItemModelDataType(QQmlAdaptorModel *model) + : model(model) + , propertyOffset(0) + , signalOffset(0) + { + } + + void notifyItem(const QQmlGuard<QQmlDMAbstractItemModelData> &item, const QVector<int> &signalIndexes) const + { + for (const int signalIndex : signalIndexes) { + QMetaObject::activate(item, signalIndex, nullptr); + if (item.isNull()) + return; + } + emit item->modelDataChanged(); + } + + bool notify( + const QQmlAdaptorModel &, + const QList<QQmlDelegateModelItem *> &items, + int index, + int count, + const QVector<int> &roles) const override + { + bool changed = roles.isEmpty() && !watchedRoles.isEmpty(); + if (!changed && !watchedRoles.isEmpty() && watchedRoleIds.isEmpty()) { + QList<int> roleIds; + for (const QByteArray &r : watchedRoles) { + QHash<QByteArray, int>::const_iterator it = roleNames.find(r); + if (it != roleNames.end()) + roleIds << it.value(); + } + const_cast<VDMAbstractItemModelDataType *>(this)->watchedRoleIds = roleIds; + } + + QVector<int> signalIndexes; + for (int i = 0; i < roles.size(); ++i) { + const int role = roles.at(i); + if (!changed && watchedRoleIds.contains(role)) + changed = true; + + int propertyId = propertyRoles.indexOf(role); + if (propertyId != -1) + signalIndexes.append(propertyId + signalOffset); + } + if (roles.isEmpty()) { + const int propertyRolesCount = propertyRoles.size(); + signalIndexes.reserve(propertyRolesCount); + for (int propertyId = 0; propertyId < propertyRolesCount; ++propertyId) + signalIndexes.append(propertyId + signalOffset); + } + + QVarLengthArray<QQmlGuard<QQmlDMAbstractItemModelData>> guardedItems; + for (const auto item : items) { + Q_ASSERT(qobject_cast<QQmlDMAbstractItemModelData *>(item) == item); + guardedItems.append(static_cast<QQmlDMAbstractItemModelData *>(item)); + } + + for (const auto &item : std::as_const(guardedItems)) { + if (item.isNull()) + continue; + + const int idx = item->modelIndex(); + if (idx >= index && idx < index + count) + notifyItem(item, signalIndexes); + } + return changed; + } + + void replaceWatchedRoles( + QQmlAdaptorModel &, + const QList<QByteArray> &oldRoles, + const QList<QByteArray> &newRoles) const override + { + VDMAbstractItemModelDataType *dataType = const_cast<VDMAbstractItemModelDataType *>(this); + + dataType->watchedRoleIds.clear(); + for (const QByteArray &oldRole : oldRoles) + dataType->watchedRoles.removeOne(oldRole); + dataType->watchedRoles += newRoles; + } + + static QV4::ReturnedValue get_hasModelChildren(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) + { + QV4::Scope scope(b); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, thisObject->as<QQmlDelegateModelItemObject>()); + if (!o) + RETURN_RESULT(scope.engine->throwTypeError(QStringLiteral("Not a valid DelegateModel object"))); + + const QQmlAdaptorModel *const model + = static_cast<QQmlDMAbstractItemModelData *>(o->d()->item)->type()->model; + if (o->d()->item->index >= 0) { + if (const QAbstractItemModel *const aim = model->aim()) + RETURN_RESULT(QV4::Encode(aim->hasChildren(aim->index(o->d()->item->index, 0, model->rootIndex)))); + } + RETURN_RESULT(QV4::Encode(false)); + } + + + void initializeConstructor(QQmlAdaptorModelEngineData *const data) + { + QV4::ExecutionEngine *v4 = data->v4; + QV4::Scope scope(v4); + QV4::ScopedObject proto(scope, v4->newObject()); + proto->defineAccessorProperty(QStringLiteral("index"), QQmlAdaptorModelEngineData::get_index, nullptr); + proto->defineAccessorProperty(QStringLiteral("hasModelChildren"), get_hasModelChildren, nullptr); + proto->defineAccessorProperty(QStringLiteral("modelData"), + QQmlDMAbstractItemModelData::get_modelData, + QQmlDMAbstractItemModelData::set_modelData); + QV4::ScopedProperty p(scope); + + typedef QHash<QByteArray, int>::const_iterator iterator; + for (iterator it = roleNames.constBegin(), end = roleNames.constEnd(); it != end; ++it) { + const qsizetype propertyId = propertyRoles.indexOf(it.value()); + const QByteArray &propertyName = it.key(); + + QV4::ScopedString name(scope, v4->newString(QString::fromUtf8(propertyName))); + QV4::ScopedFunctionObject g( + scope, + v4->memoryManager->allocate<QV4::IndexedBuiltinFunction>( + v4, propertyId, QQmlDMAbstractItemModelData::get_property)); + QV4::ScopedFunctionObject s( + scope, + v4->memoryManager->allocate<QV4::IndexedBuiltinFunction>( + v4, propertyId, QQmlDMAbstractItemModelData::set_property)); + p->setGetter(g); + p->setSetter(s); + proto->insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable); + } + prototype.set(v4, proto); + } + + // QAbstractDynamicMetaObject + + void objectDestroyed(QObject *) override + { + release(); + } + + int metaCall(QObject *object, QMetaObject::Call call, int id, void **arguments) override + { + return static_cast<QQmlDMAbstractItemModelData *>(object)->metaCall(call, id, arguments); + } + + int rowCount(const QQmlAdaptorModel &model) const override + { + if (const QAbstractItemModel *aim = model.aim()) + return aim->rowCount(model.rootIndex); + return 0; + } + + int columnCount(const QQmlAdaptorModel &model) const override + { + if (const QAbstractItemModel *aim = model.aim()) + return aim->columnCount(model.rootIndex); + return 0; + } + + void cleanup(QQmlAdaptorModel &) const override + { + release(); + } + + QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override + { + if (!metaObject) { + VDMAbstractItemModelDataType *dataType = const_cast<VDMAbstractItemModelDataType *>(this); + dataType->initializeMetaType(model); + } + + if (const QAbstractItemModel *aim = model.aim()) { + const QModelIndex modelIndex + = aim->index(model.rowAt(index), model.columnAt(index), model.rootIndex); + + const auto it = roleNames.find(role.toUtf8()), end = roleNames.end(); + if (it != roleNames.end()) + return modelIndex.data(*it); + + if (role.isEmpty() || role == QLatin1String("modelData")) { + if (roleNames.size() == 1) + return modelIndex.data(roleNames.begin().value()); + + QVariantMap modelData; + for (auto jt = roleNames.begin(); jt != end; ++jt) + modelData.insert(QString::fromUtf8(jt.key()), modelIndex.data(jt.value())); + return modelData; + } + + if (role == QLatin1String("hasModelChildren")) + return QVariant(aim->hasChildren(modelIndex)); + } + return QVariant(); + } + + QVariant parentModelIndex(const QQmlAdaptorModel &model) const override + { + if (const QAbstractItemModel *aim = model.aim()) + return QVariant::fromValue(aim->parent(model.rootIndex)); + return QVariant(); + } + + QVariant modelIndex(const QQmlAdaptorModel &model, int index) const override + { + if (const QAbstractItemModel *aim = model.aim()) + return QVariant::fromValue(aim->index(model.rowAt(index), model.columnAt(index), + model.rootIndex)); + return QVariant(); + } + + bool canFetchMore(const QQmlAdaptorModel &model) const override + { + if (const QAbstractItemModel *aim = model.aim()) + return aim->canFetchMore(model.rootIndex); + return false; + } + + void fetchMore(QQmlAdaptorModel &model) const override + { + if (QAbstractItemModel *aim = model.aim()) + aim->fetchMore(model.rootIndex); + } + + QQmlDelegateModelItem *createItem( + QQmlAdaptorModel &model, + const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType, + int index, int row, int column) override + { + if (!metaObject) + initializeMetaType(model); + return new QQmlDMAbstractItemModelData(metaType, this, index, row, column); + } + + void initializeMetaType(const QQmlAdaptorModel &model) + { + QMetaObjectBuilder builder; + QQmlAdaptorModelEngineData::setModelDataType<QQmlDMAbstractItemModelData>(&builder, this); + + const QByteArray propertyType = QByteArrayLiteral("QVariant"); + const QAbstractItemModel *aim = model.aim(); + const QHash<int, QByteArray> names = aim ? aim->roleNames() : QHash<int, QByteArray>(); + for (QHash<int, QByteArray>::const_iterator it = names.begin(), cend = names.end(); it != cend; ++it) { + const int propertyId = propertyRoles.size(); + propertyRoles.append(it.key()); + roleNames.insert(it.value(), it.key()); + QQmlAdaptorModelEngineData::addProperty(&builder, propertyId, it.value(), propertyType); + } + + metaObject.reset(builder.toMetaObject()); + *static_cast<QMetaObject *>(this) = *metaObject; + propertyCache = QQmlPropertyCache::createStandalone( + metaObject.data(), model.modelItemRevision); + } + + QV4::PersistentValue prototype; + QList<int> propertyRoles; + QList<int> watchedRoleIds; + QList<QByteArray> watchedRoles; + QHash<QByteArray, int> roleNames; + QQmlAdaptorModel *model; + int propertyOffset; + int signalOffset; +}; + +QT_END_NAMESPACE + +#endif // QQMLDMABSTRACTITEMMODELDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldmlistaccessordata_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldmlistaccessordata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5f9a701edf1af10ded08982a8494f2baec802a2a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldmlistaccessordata_p.h @@ -0,0 +1,293 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDMLISTACCESSORDATA_P_H +#define QQMLDMLISTACCESSORDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmladaptormodelenginedata_p.h> +#include <private/qqmldelegatemodel_p_p.h> +#include <private/qobject_p.h> + +QT_BEGIN_NAMESPACE + +class VDMListDelegateDataType; + +class QQmlDMListAccessorData : public QQmlDelegateModelItem +{ + Q_OBJECT + Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged) + QT_ANONYMOUS_PROPERTY(QVariant READ modelData WRITE setModelData NOTIFY modelDataChanged FINAL) +public: + QQmlDMListAccessorData( + const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType, + VDMListDelegateDataType *dataType, int index, int row, int column, + const QVariant &value); + ~QQmlDMListAccessorData(); + + QVariant modelData() const + { + return cachedData; + } + + void setModelData(const QVariant &data); + + static QV4::ReturnedValue get_modelData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) + { + QV4::ExecutionEngine *v4 = b->engine(); + const QQmlDelegateModelItemObject *o = thisObject->as<QQmlDelegateModelItemObject>(); + if (!o) + return v4->throwTypeError(QStringLiteral("Not a valid DelegateModel object")); + + return v4->fromVariant(static_cast<QQmlDMListAccessorData *>(o->d()->item)->cachedData); + } + + static QV4::ReturnedValue set_modelData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) + { + QV4::ExecutionEngine *v4 = b->engine(); + const QQmlDelegateModelItemObject *o = thisObject->as<QQmlDelegateModelItemObject>(); + if (!o) + return v4->throwTypeError(QStringLiteral("Not a valid DelegateModel object")); + if (!argc) + return v4->throwTypeError(); + + static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData( + QV4::ExecutionEngine::toVariant(argv[0], QMetaType {})); + return QV4::Encode::undefined(); + } + + QV4::ReturnedValue get() override + { + QQmlAdaptorModelEngineData *data = QQmlAdaptorModelEngineData::get(v4); + QV4::Scope scope(v4); + QV4::ScopedObject o(scope, v4->memoryManager->allocate<QQmlDelegateModelItemObject>(this)); + QV4::ScopedObject p(scope, data->listItemProto.value()); + o->setPrototypeOf(p); + ++scriptRef; + return o.asReturnedValue(); + } + + void setValue(const QString &role, const QVariant &value) override; + bool resolveIndex(const QQmlAdaptorModel &model, int idx) override; + +Q_SIGNALS: + void modelDataChanged(); + +private: + friend class VDMListDelegateDataType; + QVariant cachedData; + + // Gets cleaned when the metaobject has processed it. + bool cachedDataClean = false; +}; + + +class VDMListDelegateDataType final + : public QQmlRefCounted<VDMListDelegateDataType> + , public QQmlAdaptorModel::Accessors + , public QAbstractDynamicMetaObject +{ +public: + VDMListDelegateDataType(QQmlAdaptorModel *model) + : model(model) + { + QQmlAdaptorModelEngineData::setModelDataType<QQmlDMListAccessorData>(&builder, this); + metaObject.reset(builder.toMetaObject()); + *static_cast<QMetaObject *>(this) = *metaObject.data(); + } + + void cleanup(QQmlAdaptorModel &) const override + { + release(); + } + + int rowCount(const QQmlAdaptorModel &model) const override + { + return model.list.count(); + } + + int columnCount(const QQmlAdaptorModel &model) const override + { + switch (model.list.type()) { + case QQmlListAccessor::Invalid: + return 0; + case QQmlListAccessor::StringList: + case QQmlListAccessor::UrlList: + case QQmlListAccessor::Integer: + return 1; + default: + break; + } + + // If there are no properties, we can get modelData itself. + return std::max(1, propertyCount() - propertyOffset); + } + + static const QMetaObject *metaObjectFromType(QMetaType type) + { + if (const QMetaObject *metaObject = type.metaObject()) + return metaObject; + + // NB: This acquires the lock on QQmlMetaTypeData. If we had a QQmlEngine here, + // we could use QQmlGadgetPtrWrapper::instance() to avoid this. + if (const QQmlValueType *valueType = QQmlMetaType::valueType(type)) + return valueType->staticMetaObject(); + + return nullptr; + } + + template<typename String> + static QString toQString(const String &string) + { + if constexpr (std::is_same_v<String, QString>) + return string; + else if constexpr (std::is_same_v<String, QByteArray>) + return QString::fromUtf8(string); + else if constexpr (std::is_same_v<String, const char *>) + return QString::fromUtf8(string); + Q_UNREACHABLE_RETURN(QString()); + } + + template<typename String> + static QByteArray toUtf8(const String &string) + { + if constexpr (std::is_same_v<String, QString>) + return string.toUtf8(); + else if constexpr (std::is_same_v<String, QByteArray>) + return string; + else if constexpr (std::is_same_v<String, const char *>) + return QByteArray::fromRawData(string, qstrlen(string)); + Q_UNREACHABLE_RETURN(QByteArray()); + } + + template<typename String> + static QVariant value(const QVariant *row, const String &role) + { + const QMetaType type = row->metaType(); + if (type == QMetaType::fromType<QVariantMap>()) + return row->toMap().value(toQString(role)); + + if (type == QMetaType::fromType<QVariantHash>()) + return row->toHash().value(toQString(role)); + + const QMetaType::TypeFlags typeFlags = type.flags(); + if (typeFlags & QMetaType::PointerToQObject) + return row->value<QObject *>()->property(toUtf8(role)); + + if (const QMetaObject *metaObject = metaObjectFromType(type)) { + const int propertyIndex = metaObject->indexOfProperty(toUtf8(role)); + if (propertyIndex >= 0) + return metaObject->property(propertyIndex).readOnGadget(row->constData()); + } + + return QVariant(); + } + + template<typename String> + void createPropertyIfMissing(const String &string) + { + for (int i = 0, end = propertyCount(); i < end; ++i) { + if (QAnyStringView(property(i).name()) == QAnyStringView(string)) + return; + } + + createProperty(toUtf8(string), nullptr); + } + + void createMissingProperties(const QVariant *row) + { + const QMetaType type = row->metaType(); + if (type == QMetaType::fromType<QVariantMap>()) { + const QVariantMap map = row->toMap(); + for (auto it = map.keyBegin(), end = map.keyEnd(); it != end; ++it) + createPropertyIfMissing(*it); + } else if (type == QMetaType::fromType<QVariantHash>()) { + const QVariantHash map = row->toHash(); + for (auto it = map.keyBegin(), end = map.keyEnd(); it != end; ++it) + createPropertyIfMissing(*it); + } else if (type.flags() & QMetaType::PointerToQObject) { + const QMetaObject *metaObject = row->value<QObject *>()->metaObject(); + for (int i = 0, end = metaObject->propertyCount(); i < end; ++i) + createPropertyIfMissing(metaObject->property(i).name()); + } else if (const QMetaObject *metaObject = metaObjectFromType(type)) { + for (int i = 0, end = metaObject->propertyCount(); i < end; ++i) + createPropertyIfMissing(metaObject->property(i).name()); + } + } + + template<typename String> + static void setValue(QVariant *row, const String &role, const QVariant &value) + { + const QMetaType type = row->metaType(); + if (type == QMetaType::fromType<QVariantMap>()) { + static_cast<QVariantMap *>(row->data())->insert(toQString(role), value); + } else if (type == QMetaType::fromType<QVariantHash>()) { + static_cast<QVariantHash *>(row->data())->insert(toQString(role), value); + } else if (type.flags() & QMetaType::PointerToQObject) { + row->value<QObject *>()->setProperty(toUtf8(role), value); + } else if (const QMetaObject *metaObject = metaObjectFromType(type)) { + const int propertyIndex = metaObject->indexOfProperty(toUtf8(role)); + if (propertyIndex >= 0) + metaObject->property(propertyIndex).writeOnGadget(row->data(), value); + } + } + + QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override + { + const QVariant entry = model.list.at(index); + if (role == QLatin1String("modelData") || role.isEmpty()) + return entry; + + return value(&entry, role); + } + + QQmlDelegateModelItem *createItem( + QQmlAdaptorModel &model, + const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType, + int index, int row, int column) override + { + const QVariant value = (index >= 0 && index < model.list.count()) + ? model.list.at(index) + : QVariant(); + return new QQmlDMListAccessorData(metaType, this, index, row, column, value); + } + + bool notify(const QQmlAdaptorModel &model, const QList<QQmlDelegateModelItem *> &items, int index, int count, const QVector<int> &) const override + { + for (auto modelItem : items) { + const int modelItemIndex = modelItem->index; + if (modelItemIndex < index || modelItemIndex >= index + count) + continue; + + auto listModelItem = static_cast<QQmlDMListAccessorData *>(modelItem); + QVariant updatedModelData = model.list.at(listModelItem->index); + listModelItem->setModelData(updatedModelData); + } + return true; + } + + void emitAllSignals(QQmlDMListAccessorData *accessor) const; + + int metaCall(QObject *object, QMetaObject::Call call, int id, void **arguments) final; + int createProperty(const char *name, const char *) final; + QMetaObject *toDynamicMetaObject(QObject *accessors) final; + + QMetaObjectBuilder builder; + QQmlAdaptorModel *model = nullptr; + int propertyOffset = 0; + int signalOffset = 0; +}; + +QT_END_NAMESPACE + +#endif // QQMLDMLISTACCESSORDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldmobjectdata_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldmobjectdata_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9bfdd14a9ac898f1175991a056fc79acbd606d07 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmldmobjectdata_p.h @@ -0,0 +1,247 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLDMOBJECTDATA_P_H +#define QQMLDMOBJECTDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qqmladaptormodelenginedata_p.h> +#include <private/qqmldelegatemodel_p_p.h> + +#include <private/qobject_p.h> +#include <QtCore/qpointer.h> + +QT_BEGIN_NAMESPACE + +class VDMObjectDelegateDataType; +class QQmlDMObjectData : public QQmlDelegateModelItem, public QQmlAdaptorModelProxyInterface +{ + Q_OBJECT + Q_PROPERTY(QObject *modelData READ modelData NOTIFY modelDataChanged) + QT_ANONYMOUS_PROPERTY(QObject * READ modelData NOTIFY modelDataChanged FINAL) + Q_INTERFACES(QQmlAdaptorModelProxyInterface) +public: + QQmlDMObjectData( + const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType, + VDMObjectDelegateDataType *dataType, + int index, int row, int column, + QObject *object); + + void setModelData(QObject *modelData) + { + if (modelData == object) + return; + + object = modelData; + emit modelDataChanged(); + } + + QObject *modelData() const { return object; } + QObject *proxiedObject() override { return object; } + + QPointer<QObject> object; + +Q_SIGNALS: + void modelDataChanged(); +}; + +class VDMObjectDelegateDataType final + : public QQmlRefCounted<VDMObjectDelegateDataType>, + public QQmlAdaptorModel::Accessors +{ +public: + int propertyOffset; + int signalOffset; + bool shared; + QMetaObjectBuilder builder; + + VDMObjectDelegateDataType() + : propertyOffset(0) + , signalOffset(0) + , shared(true) + { + } + + VDMObjectDelegateDataType(const VDMObjectDelegateDataType &type) + : propertyOffset(type.propertyOffset) + , signalOffset(type.signalOffset) + , shared(false) + , builder(type.metaObject.data(), QMetaObjectBuilder::Properties + | QMetaObjectBuilder::Signals + | QMetaObjectBuilder::SuperClass + | QMetaObjectBuilder::ClassName) + { + builder.setFlags(MetaObjectFlag::DynamicMetaObject); + } + + int rowCount(const QQmlAdaptorModel &model) const override + { + return model.list.count(); + } + + int columnCount(const QQmlAdaptorModel &) const override + { + return 1; + } + + QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override + { + if (QObject *object = model.list.at(index).value<QObject *>()) + return object->property(role.toUtf8()); + return QVariant(); + } + + QQmlDelegateModelItem *createItem( + QQmlAdaptorModel &model, + const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType, + int index, int row, int column) override + { + if (!metaObject) + initializeMetaType(model); + return index >= 0 && index < model.list.count() + ? new QQmlDMObjectData(metaType, this, index, row, column, qvariant_cast<QObject *>(model.list.at(index))) + : nullptr; + } + + void initializeMetaType(QQmlAdaptorModel &model) + { + Q_UNUSED(model); + QQmlAdaptorModelEngineData::setModelDataType<QQmlDMObjectData>(&builder, this); + + metaObject.reset(builder.toMetaObject()); + // Note: ATM we cannot create a shared property cache for this class, since each model + // object can have different properties. And to make those properties available to the + // delegate, QQmlDMObjectData makes use of a QAbstractDynamicMetaObject subclass + // (QQmlDMObjectDataMetaObject), which we cannot represent in a QQmlPropertyCache. + // By not having a shared property cache, revisioned properties in QQmlDelegateModelItem + // will always be available to the delegate, regardless of the import version. + } + + void cleanup(QQmlAdaptorModel &) const override + { + release(); + } + + bool notify(const QQmlAdaptorModel &model, const QList<QQmlDelegateModelItem *> &items, int index, int count, const QVector<int> &) const override + { + for (auto modelItem : items) { + const int modelItemIndex = modelItem->index; + if (modelItemIndex < index || modelItemIndex >= index + count) + continue; + + auto objectModelItem = static_cast<QQmlDMObjectData *>(modelItem); + QObject *updatedModelData = qvariant_cast<QObject *>(model.list.at(objectModelItem->index)); + objectModelItem->setModelData(updatedModelData); + } + return true; + } +}; + +class QQmlDMObjectDataMetaObject : public QAbstractDynamicMetaObject +{ +public: + QQmlDMObjectDataMetaObject(QQmlDMObjectData *data, VDMObjectDelegateDataType *type) + : m_data(data) + , m_type(type) + { + QObjectPrivate *op = QObjectPrivate::get(m_data); + *static_cast<QMetaObject *>(this) = *type->metaObject; + op->metaObject = this; + m_type->addref(); + } + + ~QQmlDMObjectDataMetaObject() + { + m_type->release(); + } + + int metaCall(QObject *o, QMetaObject::Call call, int id, void **arguments) override + { + Q_ASSERT(o == m_data); + Q_UNUSED(o); + + static const int objectPropertyOffset = QObject::staticMetaObject.propertyCount(); + if (id >= m_type->propertyOffset + && (call == QMetaObject::ReadProperty + || call == QMetaObject::WriteProperty + || call == QMetaObject::ResetProperty)) { + if (m_data->object) + QMetaObject::metacall(m_data->object, call, id - m_type->propertyOffset + objectPropertyOffset, arguments); + return -1; + } else if (id >= m_type->signalOffset && call == QMetaObject::InvokeMetaMethod) { + QMetaObject::activate(m_data, this, id - m_type->signalOffset, nullptr); + return -1; + } else { + return m_data->qt_metacall(call, id, arguments); + } + } + + int createProperty(const char *name, const char *) override + { + if (!m_data->object) + return -1; + const QMetaObject *metaObject = m_data->object->metaObject(); + static const int objectPropertyOffset = QObject::staticMetaObject.propertyCount(); + + const int previousPropertyCount = propertyCount() - propertyOffset(); + int propertyIndex = metaObject->indexOfProperty(name); + if (propertyIndex == -1) + return -1; + if (previousPropertyCount + objectPropertyOffset == metaObject->propertyCount()) + return propertyIndex + m_type->propertyOffset - objectPropertyOffset; + + if (m_type->shared) { + VDMObjectDelegateDataType *type = m_type; + m_type = new VDMObjectDelegateDataType(*m_type); + type->release(); + } + + const int previousMethodCount = methodCount(); + int notifierId = previousMethodCount - methodOffset(); + for (int propertyId = previousPropertyCount; propertyId < metaObject->propertyCount() - objectPropertyOffset; ++propertyId) { + QMetaProperty property = metaObject->property(propertyId + objectPropertyOffset); + QMetaPropertyBuilder propertyBuilder; + if (property.hasNotifySignal()) { + m_type->builder.addSignal("__" + QByteArray::number(propertyId) + "()"); + propertyBuilder = m_type->builder.addProperty(property.name(), property.typeName(), notifierId); + ++notifierId; + } else { + propertyBuilder = m_type->builder.addProperty(property.name(), property.typeName()); + } + propertyBuilder.setWritable(property.isWritable()); + propertyBuilder.setResettable(property.isResettable()); + propertyBuilder.setConstant(property.isConstant()); + } + + m_type->metaObject.reset(m_type->builder.toMetaObject()); + *static_cast<QMetaObject *>(this) = *m_type->metaObject; + + notifierId = previousMethodCount; + for (int i = previousPropertyCount; i < metaObject->propertyCount() - objectPropertyOffset; ++i) { + QMetaProperty property = metaObject->property(i + objectPropertyOffset); + if (property.hasNotifySignal()) { + QQmlPropertyPrivate::connect( + m_data->object, property.notifySignalIndex(), m_data, notifierId); + ++notifierId; + } + } + return propertyIndex + m_type->propertyOffset - objectPropertyOffset; + } + + QQmlDMObjectData *m_data; + VDMObjectDelegateDataType *m_type; +}; + +QT_END_NAMESPACE + +#endif // QQMLDMOBJECTDATA_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlinstantiator_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlinstantiator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ffcf3d8a6839514a57de6736b1daee03d8582733 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlinstantiator_p.h @@ -0,0 +1,87 @@ +// Copyright (C) 2016 Research In Motion. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLINSTANTIATOR_P_H +#define QQMLINSTANTIATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqmlcomponent.h> +#include <QtQml/qqmlparserstatus.h> +#include <QtQmlModels/private/qtqmlmodelsglobal_p.h> + +QT_REQUIRE_CONFIG(qml_object_model); + +QT_BEGIN_NAMESPACE + +class QQmlInstantiatorPrivate; +class Q_QMLMODELS_EXPORT QQmlInstantiator : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + + Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) + Q_PROPERTY(bool asynchronous READ isAsync WRITE setAsync NOTIFY asynchronousChanged) + Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) + Q_PROPERTY(QObject *object READ object NOTIFY objectChanged) + Q_CLASSINFO("DefaultProperty", "delegate") + QML_NAMED_ELEMENT(Instantiator) + QML_ADDED_IN_VERSION(2, 1) + +public: + QQmlInstantiator(QObject *parent = nullptr); + ~QQmlInstantiator(); + + bool isActive() const; + void setActive(bool newVal); + + bool isAsync() const; + void setAsync(bool newVal); + + int count() const; + + QQmlComponent* delegate(); + void setDelegate(QQmlComponent* c); + + QVariant model() const; + void setModel(const QVariant &v); + + QObject *object() const; + + Q_INVOKABLE QObject *objectAt(int index) const; + + void classBegin() override; + void componentComplete() override; + +Q_SIGNALS: + void modelChanged(); + void delegateChanged(); + void countChanged(); + void objectChanged(); + void activeChanged(); + void asynchronousChanged(); + + void objectAdded(int index, QObject* object); + void objectRemoved(int index, QObject* object); + +private: + Q_DISABLE_COPY(QQmlInstantiator) + Q_DECLARE_PRIVATE(QQmlInstantiator) + Q_PRIVATE_SLOT(d_func(), void _q_createdItem(int, QObject *)) + Q_PRIVATE_SLOT(d_func(), void _q_modelUpdated(const QQmlChangeSet &, bool)) +}; + +QT_END_NAMESPACE + +#endif // QQMLCREATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlinstantiator_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlinstantiator_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a118e4fb858ff472b4010a1ed921c2e1ab31a087 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlinstantiator_p_p.h @@ -0,0 +1,65 @@ +// Copyright (C) 2016 Research In Motion. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLINSTANTIATOR_P_P_H +#define QQMLINSTANTIATOR_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmlinstantiator_p.h" +#include <QObject> +#include <private/qobject_p.h> +#include <private/qqmlchangeset_p.h> +#include <private/qqmlobjectmodel_p.h> + +#include <QtCore/qpointer.h> + +QT_REQUIRE_CONFIG(qml_object_model); + +QT_BEGIN_NAMESPACE + +class Q_QMLMODELS_EXPORT QQmlInstantiatorPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQmlInstantiator) + +public: + QQmlInstantiatorPrivate(); + + void clear(); + void regenerate(); +#if QT_CONFIG(qml_delegate_model) + void makeModel(); +#endif + void _q_createdItem(int, QObject *); + void _q_modelUpdated(const QQmlChangeSet &, bool); + QObject *modelObject(int index, bool async); + + static QQmlInstantiatorPrivate *get(QQmlInstantiator *instantiator) { return instantiator->d_func(); } + static const QQmlInstantiatorPrivate *get(const QQmlInstantiator *instantiator) { return instantiator->d_func(); } + + bool componentComplete:1; + bool effectiveReset:1; + bool active:1; + bool async:1; +#if QT_CONFIG(qml_delegate_model) + bool ownModel:1; +#endif + int requestedIndex; + QVariant model; + QQmlInstanceModel *instanceModel; + QQmlComponent *delegate; + QVector<QPointer<QObject> > objects; +}; + +QT_END_NAMESPACE + +#endif // QQMLCREATOR_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistaccessor_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistaccessor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9929a8c2a6ae3d69765bf43088da0f779ac9140e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistaccessor_p.h @@ -0,0 +1,61 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLISTACCESSOR_H +#define QQMLLISTACCESSOR_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/QVariant> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QQmlEngine; +class Q_AUTOTEST_EXPORT QQmlListAccessor +{ +public: + QQmlListAccessor(); + ~QQmlListAccessor(); + + QVariant list() const; + void setList(const QVariant &); + + bool isValid() const; + + qsizetype count() const; + QVariant at(qsizetype) const; + void set(qsizetype, const QVariant &); + + enum Type { + Invalid, + StringList, + UrlList, + VariantList, + ObjectList, + ListProperty, + Instance, + Integer, + Sequence, + }; + + Type type() const { return m_type; } + +private: + Type m_type; + QMetaSequence m_metaSequence; + QVariant d; +}; + +QT_END_NAMESPACE + +#endif // QQMLLISTACCESSOR_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistcompositor_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistcompositor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4b1e27c0cab3454ff20c32f841577dc12a4bda57 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistcompositor_p.h @@ -0,0 +1,333 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLISTCOMPOSITOR_P_H +#define QQMLLISTCOMPOSITOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtCore/qvector.h> + +#include <private/qqmlchangeset_p.h> + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +class Q_AUTOTEST_EXPORT QQmlListCompositor +{ +public: + enum { MinimumGroupCount = 3, MaximumGroupCount = 11 }; + + enum Group + { + Cache = 0, + Default = 1, + Persisted = 2 + }; + + enum Flag + { + CacheFlag = 1 << Cache, + DefaultFlag = 1 << Default, + PersistedFlag = 1 << Persisted, + PrependFlag = 0x10000000, + AppendFlag = 0x20000000, + UnresolvedFlag = 0x40000000, + MovedFlag = 0x80000000, + GroupMask = ~(PrependFlag | AppendFlag | UnresolvedFlag | MovedFlag | CacheFlag) + }; + + class Range + { + public: + Range() : next(this), previous(this) {} + Range(Range *next, void *list, int index, int count, uint flags) + : next(next), previous(next->previous), list(list), index(index), count(count), flags(flags) { + next->previous = this; previous->next = this; } + + Range *next; + Range *previous; + void *list = nullptr; + int index = 0; + int count = 0; + uint flags = 0; + + inline int start() const { return index; } + inline int end() const { return index + count; } + + inline int groups() const { return flags & GroupMask; } + + inline bool inGroup() const { return flags & GroupMask; } + inline bool inCache() const { return flags & CacheFlag; } + inline bool inGroup(int group) const { return flags & (1 << group); } + inline bool isUnresolved() const { return flags & UnresolvedFlag; } + + inline bool prepend() const { return flags & PrependFlag; } + inline bool append() const { return flags & AppendFlag; } + }; + + class Q_AUTOTEST_EXPORT iterator + { + public: + inline iterator() = default; + inline iterator(Range *range, int offset, Group group, int groupCount); + + bool operator ==(const iterator &it) const { return range == it.range && offset == it.offset; } + bool operator !=(const iterator &it) const { return range != it.range || offset != it.offset; } + + bool operator ==(Group group) const { return range->flags & (1 << group); } + bool operator !=(Group group) const { return !(range->flags & (1 << group)); } + + Range *&operator *() { return range; } + Range * const &operator *() const { return range; } + Range *operator ->() { return range; } + const Range *operator ->() const { return range; } + + iterator &operator +=(int difference); + + template<typename T> T *list() const { return static_cast<T *>(range->list); } + int modelIndex() const { return range->index + offset; } + + void incrementIndexes(int difference) { incrementIndexes(difference, range->flags); } + void decrementIndexes(int difference) { decrementIndexes(difference, range->flags); } + + inline void incrementIndexes(int difference, uint flags); + inline void decrementIndexes(int difference, uint flags); + + void setGroup(Group g) { group = g; groupFlag = 1 << g; } + + Range *range = nullptr; + int offset = 0; + Group group = Default; + int groupFlag = 0; + int groupCount = 0; + int index[MaximumGroupCount] = { 0 }; + + int cacheIndex() const { + return index[Cache]; + } + + void setCacheIndex(int cacheIndex) { + index[Cache] = cacheIndex; + } + }; + + class Q_AUTOTEST_EXPORT insert_iterator : public iterator + { + public: + inline insert_iterator() {} + inline insert_iterator(const iterator &it) : iterator(it) {} + inline insert_iterator(Range *, int, Group, int); + inline ~insert_iterator() {} + + insert_iterator &operator +=(int difference); + }; + + struct Change + { + inline Change() = default; + inline Change(const iterator &it, int count, uint flags, int moveId = -1); + int count = 0; + uint flags = 0; + int moveId = 0; + int index[MaximumGroupCount] = { 0 }; + + int cacheIndex() const { + return index[Cache]; + } + + void setCacheIndex(int cacheIndex) { + index[Cache] = cacheIndex; + } + + inline bool isMove() const { return moveId >= 0; } + inline bool inCache() const { return flags & CacheFlag; } + inline bool inGroup() const { return flags & GroupMask; } + inline bool inGroup(int group) const { return flags & (CacheFlag << group); } + + inline int groups() const { return flags & GroupMask; } + }; + + struct Insert : public Change + { + Insert() {} + Insert(const iterator &it, int count, uint flags, int moveId = -1) + : Change(it, count, flags, moveId) {} + }; + + struct Remove : public Change + { + Remove() {} + Remove(const iterator &it, int count, uint flags, int moveId = -1) + : Change(it, count, flags, moveId) {} + }; + + QQmlListCompositor(); + ~QQmlListCompositor(); + + int defaultGroups() const { return m_defaultFlags & ~PrependFlag; } + void setDefaultGroups(int groups) { m_defaultFlags = groups | PrependFlag; } + void setDefaultGroup(Group group) { m_defaultFlags |= (1 << group); } + void clearDefaultGroup(Group group) { m_defaultFlags &= ~(1 << group); } + void setRemoveGroups(int groups) { m_removeFlags = PrependFlag | AppendFlag | groups; } + void setGroupCount(int count); + + int count(Group group) const; + iterator find(Group group, int index); + iterator find(Group group, int index) const; + insert_iterator findInsertPosition(Group group, int index); + + const iterator &end() { return m_end; } + + void append(void *list, int index, int count, uint flags, QVector<Insert> *inserts = nullptr); + void insert(Group group, int before, void *list, int index, int count, uint flags, QVector<Insert> *inserts = nullptr); + iterator insert(iterator before, void *list, int index, int count, uint flags, QVector<Insert> *inserts = nullptr); + + void setFlags(Group fromGroup, int from, int count, Group group, int flags, QVector<Insert> *inserts = nullptr); + void setFlags(iterator from, int count, Group group, uint flags, QVector<Insert> *inserts = nullptr); + void setFlags(Group fromGroup, int from, int count, uint flags, QVector<Insert> *inserts = nullptr) { + setFlags(fromGroup, from, count, fromGroup, flags, inserts); } + void setFlags(const iterator from, int count, uint flags, QVector<Insert> *inserts = nullptr) { + setFlags(from, count, from.group, flags, inserts); } + + void clearFlags(Group fromGroup, int from, int count, Group group, uint flags, QVector<Remove> *removals = nullptr); + void clearFlags(iterator from, int count, Group group, uint flags, QVector<Remove> *removals = nullptr); + void clearFlags(Group fromGroup, int from, int count, uint flags, QVector<Remove> *removals = nullptr) { + clearFlags(fromGroup, from, count, fromGroup, flags, removals); } + void clearFlags(const iterator &from, int count, uint flags, QVector<Remove> *removals = nullptr) { + clearFlags(from, count, from.group, flags, removals); } + + bool verifyMoveTo(Group fromGroup, int from, Group toGroup, int to, int count, Group group) const; + + void move( + Group fromGroup, + int from, + Group toGroup, + int to, + int count, + Group group, + QVector<Remove> *removals = nullptr, + QVector<Insert> *inserts = nullptr); + void clear(); + + void listItemsInserted(void *list, int index, int count, QVector<Insert> *inserts); + void listItemsRemoved(void *list, int index, int count, QVector<Remove> *removals); + void listItemsMoved(void *list, int from, int to, int count, QVector<Remove> *removals, QVector<Insert> *inserts); + void listItemsChanged(void *list, int index, int count, QVector<Change> *changes); + + void transition( + Group from, + Group to, + QVector<QQmlChangeSet::Change> *removes, + QVector<QQmlChangeSet::Change> *inserts); + +private: + Range m_ranges; + iterator m_end; + iterator m_cacheIt; + int m_groupCount; + int m_defaultFlags; + int m_removeFlags; + int m_moveId; + + inline Range *insert(Range *before, void *list, int index, int count, uint flags); + inline Range *erase(Range *range); + + struct MovedFlags + { + MovedFlags() {} + MovedFlags(int moveId, uint flags) : moveId(moveId), flags(flags) {} + + int moveId; + uint flags; + }; + + void listItemsRemoved( + QVector<Remove> *translatedRemovals, + void *list, + QVector<QQmlChangeSet::Change> *removals, + QVector<QQmlChangeSet::Change> *insertions = nullptr, + QVector<MovedFlags> *movedFlags = nullptr); + void listItemsInserted( + QVector<Insert> *translatedInsertions, + void *list, + const QVector<QQmlChangeSet::Change> &insertions, + const QVector<MovedFlags> *movedFlags = nullptr); + void listItemsChanged( + QVector<Change> *translatedChanges, + void *list, + const QVector<QQmlChangeSet::Change> &changes); + + friend Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQmlListCompositor &list); +}; + +Q_DECLARE_TYPEINFO(QQmlListCompositor::Change, Q_PRIMITIVE_TYPE); +Q_DECLARE_TYPEINFO(QQmlListCompositor::Remove, Q_PRIMITIVE_TYPE); +Q_DECLARE_TYPEINFO(QQmlListCompositor::Insert, Q_PRIMITIVE_TYPE); + +QT_WARNING_PUSH +// GCC isn't wrong, as groupCount is public in iterator, but we tried Q_ASSUME(), +// right in front of the loops, and it didn't help, so we disable the warning: +QT_WARNING_DISABLE_GCC("-Warray-bounds") +inline QQmlListCompositor::iterator::iterator( + Range *range, int offset, Group group, int groupCount) + : range(range) + , offset(offset) + , group(group) + , groupFlag(1 << group) + , groupCount(groupCount) +{ + for (int i = 0; i < groupCount; ++i) + index[i] = 0; +} + +inline void QQmlListCompositor::iterator::incrementIndexes(int difference, uint flags) +{ + for (int i = 0; i < groupCount; ++i) { + if (flags & (1 << i)) + index[i] += difference; + } +} + +inline void QQmlListCompositor::iterator::decrementIndexes(int difference, uint flags) +{ + for (int i = 0; i < groupCount; ++i) { + if (flags & (1 << i)) + index[i] -= difference; + } +} +QT_WARNING_POP // -Warray-bounds + +inline QQmlListCompositor::insert_iterator::insert_iterator( + Range *range, int offset, Group group, int groupCount) + : iterator(range, offset, group, groupCount) {} + +inline QQmlListCompositor::Change::Change(const iterator &it, int count, uint flags, int moveId) + : count(count), flags(flags), moveId(moveId) +{ + for (int i = 0; i < MaximumGroupCount; ++i) + index[i] = it.index[i]; +} + +Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQmlListCompositor::Group &group); +Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQmlListCompositor::Range &range); +Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQmlListCompositor::iterator &it); +Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQmlListCompositor::Change &change); +Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQmlListCompositor::Remove &remove); +Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQmlListCompositor::Insert &insert); +Q_AUTOTEST_EXPORT QDebug operator <<(QDebug debug, const QQmlListCompositor &list); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistmodel_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistmodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1163482c1bb6ebf39a53aa0f58d174cfa63968b7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistmodel_p.h @@ -0,0 +1,186 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLISTMODEL_H +#define QQMLLISTMODEL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlmodelsglobal_p.h> +#include <private/qqmlcustomparser_p.h> + +#include <QtCore/QObject> +#include <QtCore/QStringList> +#include <QtCore/QHash> +#include <QtCore/QList> +#include <QtCore/QVariant> +#include <QtCore/qabstractitemmodel.h> + +#include <private/qv4engine_p.h> +#include <private/qpodvector_p.h> + +QT_REQUIRE_CONFIG(qml_list_model); + +QT_BEGIN_NAMESPACE + + +class QQmlListModelWorkerAgent; +class ListModel; +class ListLayout; + +namespace QV4 { +struct ModelObject; +} + +class Q_QMLMODELS_EXPORT QQmlListModel : public QAbstractListModel +{ + Q_OBJECT + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(bool dynamicRoles READ dynamicRoles WRITE setDynamicRoles) + Q_PROPERTY(QObject *agent READ agent CONSTANT REVISION(2, 14)) + QML_NAMED_ELEMENT(ListModel) + QML_ADDED_IN_VERSION(2, 0) + QML_CUSTOMPARSER + +public: + QQmlListModel(QObject *parent=nullptr); + ~QQmlListModel(); + + QModelIndex index(int row, int column, const QModelIndex &parent) const override; + int rowCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; + QHash<int,QByteArray> roleNames() const override; + + QVariant data(int index, int role) const; + int count() const; + + Q_INVOKABLE void clear(); + Q_INVOKABLE void remove(QQmlV4FunctionPtr args); + Q_INVOKABLE void append(QQmlV4FunctionPtr args); + Q_INVOKABLE void insert(QQmlV4FunctionPtr args); + Q_INVOKABLE QJSValue get(int index) const; + Q_INVOKABLE void set(int index, const QJSValue &value); + Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value); + Q_INVOKABLE void move(int from, int to, int count); + Q_INVOKABLE void sync(); + + QQmlListModelWorkerAgent *agent(); + + bool dynamicRoles() const { return m_dynamicRoles; } + void setDynamicRoles(bool enableDynamicRoles); + + ListModel *listModel() const { return m_listModel; } + +Q_SIGNALS: + void countChanged(); + +private: + friend class QQmlListModelParser; + friend class QQmlListModelWorkerAgent; + friend class ModelObject; + friend struct QV4::ModelObject; + friend class ModelNodeMetaObject; + friend class ListModel; + friend class ListElement; + friend class DynamicRoleModelNode; + friend class DynamicRoleModelNodeMetaObject; + friend struct StringOrTranslation; + + // Constructs a flat list model for a worker agent + QQmlListModel(QQmlListModel *orig, QQmlListModelWorkerAgent *agent); + QQmlListModel(const QQmlListModel *owner, ListModel *data, QV4::ExecutionEngine *engine, QObject *parent=nullptr); + + QV4::ExecutionEngine *engine() const; + + inline bool canMove(int from, int to, int n) const { return !(from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0); } + + mutable QQmlListModelWorkerAgent *m_agent; + mutable QV4::ExecutionEngine *m_engine; + QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit; + bool m_mainThread; + bool m_primary; + + bool m_dynamicRoles; + + ListLayout *m_layout; + ListModel *m_listModel; + std::unique_ptr<QPropertyNotifier> translationChangeHandler; + + QVector<class DynamicRoleModelNode *> m_modelObjects; + QVector<QString> m_roles; + + struct ElementSync + { + DynamicRoleModelNode *src = nullptr; + DynamicRoleModelNode *target = nullptr; + int srcIndex = -1; + int targetIndex = -1; + QVector<int> changedRoles; + }; + + static bool sync(QQmlListModel *src, QQmlListModel *target); + static QQmlListModel *createWithOwner(QQmlListModel *newOwner); + + void emitItemsChanged(int index, int count, const QVector<int> &roles); + void emitItemsAboutToBeInserted(int index, int count); + void emitItemsInserted(); + + void removeElements(int index, int removeCount); + + void updateTranslations(); +}; + +// ### FIXME +class QQmlListElement : public QObject +{ + Q_OBJECT + QML_NAMED_ELEMENT(ListElement) + QML_ADDED_IN_VERSION(2, 0) +}; + +class QQmlListModelParser : public QQmlCustomParser +{ +public: + enum PropertyType { + Invalid, + Boolean, + Number, + String, + Script + }; + + + QQmlListModelParser() : QQmlCustomParser(QQmlCustomParser::AcceptsSignalHandlers) {} + + void verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override; + void applyBindings(QObject *obj, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override; + +private: + bool verifyProperty(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding); + // returns true if a role was set + bool applyProperty(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding, ListModel *model, int outterElementIndex); + + static bool definesEmptyList(const QString &); + + QString listElementTypeName; +}; + +template<> +inline QQmlCustomParser *qmlCreateCustomParser<QQmlListModel>() +{ + return new QQmlListModelParser; +} + +QT_END_NAMESPACE + +#endif // QQMLLISTMODEL_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistmodel_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistmodel_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..eb044d452a69478bb3fa7ec36721bc609f7eb782 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistmodel_p_p.h @@ -0,0 +1,428 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLLISTMODEL_P_P_H +#define QQMLLISTMODEL_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmllistmodel_p.h" +#include <private/qtqmlmodelsglobal_p.h> +#include <private/qqmlengine_p.h> +#include <private/qqmlopenmetaobject_p.h> +#include <private/qv4qobjectwrapper_p.h> +#include <qqml.h> + +QT_REQUIRE_CONFIG(qml_list_model); + +QT_BEGIN_NAMESPACE + + +class DynamicRoleModelNode; + +class DynamicRoleModelNodeMetaObject : public QQmlOpenMetaObject +{ +public: + DynamicRoleModelNodeMetaObject(DynamicRoleModelNode *object); + ~DynamicRoleModelNodeMetaObject(); + + bool m_enabled; + +protected: + void propertyWrite(int index) override; + void propertyWritten(int index) override; + +private: + DynamicRoleModelNode *m_owner; +}; + +class DynamicRoleModelNode : public QObject +{ + Q_OBJECT +public: + DynamicRoleModelNode(QQmlListModel *owner, int uid); + + static DynamicRoleModelNode *create(const QVariantMap &obj, QQmlListModel *owner); + + void updateValues(const QVariantMap &object, QVector<int> &roles); + + QVariant getValue(const QString &name) const + { + return m_meta->value(name.toUtf8()); + } + + bool setValue(const QByteArray &name, const QVariant &val) + { + return m_meta->setValue(name, val); + } + + void setNodeUpdatesEnabled(bool enable) + { + m_meta->m_enabled = enable; + } + + int getUid() const + { + return m_uid; + } + + static QVector<int> sync(DynamicRoleModelNode *src, DynamicRoleModelNode *target); + +private: + QQmlListModel *m_owner; + int m_uid; + DynamicRoleModelNodeMetaObject *m_meta; + + friend class DynamicRoleModelNodeMetaObject; +}; + +class ModelNodeMetaObject : public QQmlOpenMetaObject +{ +public: + ModelNodeMetaObject(QObject *object, QQmlListModel *model, int elementIndex); + ~ModelNodeMetaObject(); + + QMetaObject *toDynamicMetaObject(QObject *object) override; + + static ModelNodeMetaObject *get(QObject *obj); + + bool m_enabled; + QQmlListModel *m_model; + int m_elementIndex; + + void updateValues(); + void updateValues(const QVector<int> &roles); + + bool initialized() const { return m_initialized; } + +protected: + void propertyWritten(int index) override; + +private: + using QQmlOpenMetaObject::setValue; + + void emitDirectNotifies(const int *changedRoles, int roleCount); + + void initialize(); + bool m_initialized; +}; + +namespace QV4 { + +namespace Heap { + +struct ModelObject : public QObjectWrapper { + void init(QObject *object, QQmlListModel *model) + { + QObjectWrapper::init(object); + m_model = model; + } + + void destroy() + { + m_model.destroy(); + QObjectWrapper::destroy(); + } + + int elementIndex() const { + if (const QObject *o = object()) { + const QObjectPrivate *op = QObjectPrivate::get(o); + return static_cast<ModelNodeMetaObject *>(op->metaObject)->m_elementIndex; + } + return -1; + } + + QV4QPointer<QQmlListModel> m_model; +}; + +} + +struct ModelObject : public QObjectWrapper +{ + V4_OBJECT2(ModelObject, QObjectWrapper) + V4_NEEDS_DESTROY + +protected: + static bool virtualPut(Managed *m, PropertyKey id, const Value& value, Value *receiver); + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup); + static ReturnedValue lookupGetter(Lookup *l, ExecutionEngine *engine, const Value &object); + static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); +}; + +} // namespace QV4 + +class ListLayout +{ +public: + ListLayout() : currentBlock(0), currentBlockOffset(0) {} + ListLayout(const ListLayout *other); + ~ListLayout(); + + class Role + { + public: + + Role() : type(Invalid), blockIndex(-1), blockOffset(-1), index(-1), subLayout(0) {} + explicit Role(const Role *other); + ~Role(); + + // This enum must be kept in sync with the roleTypeNames variable in qqmllistmodel.cpp + enum DataType + { + Invalid = -1, + + String, + Number, + Bool, + List, + QObject, + VariantMap, + DateTime, + Url, + Function, + + MaxDataType + }; + + QString name; + DataType type; + int blockIndex; + int blockOffset; + int index; + ListLayout *subLayout; + }; + + const Role *getRoleOrCreate(const QString &key, const QVariant &data); + const Role &getRoleOrCreate(QV4::String *key, Role::DataType type); + const Role &getRoleOrCreate(const QString &key, Role::DataType type); + + const Role &getExistingRole(int index) const { return *roles.at(index); } + const Role *getExistingRole(const QString &key) const; + const Role *getExistingRole(QV4::String *key) const; + + int roleCount() const { return roles.size(); } + + static void sync(ListLayout *src, ListLayout *target); + +private: + const Role &createRole(const QString &key, Role::DataType type); + + int currentBlock; + int currentBlockOffset; + QVector<Role *> roles; + QStringHash<Role *> roleHash; +}; + +struct StringOrTranslation +{ + ~StringOrTranslation(); + bool isSet() const { return binding || arrayData; } + bool isTranslation() const { return binding && !arrayData; } + void setString(const QString &s); + void setTranslation(const QV4::CompiledData::Binding *binding); + QString toString(const QQmlListModel *owner) const; + QString asString() const; +private: + void clear(); + + union { + char16_t *stringData = nullptr; + const QV4::CompiledData::Binding *binding; + }; + + QTypedArrayData<char16_t> *arrayData = nullptr; + uint stringSize = 0; +}; + +/*! +\internal +*/ +class ListElement +{ +public: + enum ObjectIndestructible { Indestructible = 1, ExplicitlySet = 2 }; + enum { BLOCK_SIZE = 64 - sizeof(int) - sizeof(ListElement *) - sizeof(ModelNodeMetaObject *) }; + + ListElement(); + ListElement(int existingUid); + ~ListElement(); + + static QVector<int> sync(ListElement *src, ListLayout *srcLayout, ListElement *target, ListLayout *targetLayout); + +private: + + void destroy(ListLayout *layout); + + int setVariantProperty(const ListLayout::Role &role, const QVariant &d); + + int setJsProperty(const ListLayout::Role &role, const QV4::Value &d, QV4::ExecutionEngine *eng); + + int setStringProperty(const ListLayout::Role &role, const QString &s); + int setDoubleProperty(const ListLayout::Role &role, double n); + int setBoolProperty(const ListLayout::Role &role, bool b); + int setListProperty(const ListLayout::Role &role, ListModel *m); + int setQObjectProperty(const ListLayout::Role &role, QV4::QObjectWrapper *o); + int setVariantMapProperty(const ListLayout::Role &role, QV4::Object *o); + int setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m); + int setDateTimeProperty(const ListLayout::Role &role, const QDateTime &dt); + int setUrlProperty(const ListLayout::Role &role, const QUrl &url); + int setFunctionProperty(const ListLayout::Role &role, const QJSValue &f); + int setTranslationProperty(const ListLayout::Role &role, const QV4::CompiledData::Binding *b); + + void setStringPropertyFast(const ListLayout::Role &role, const QString &s); + void setDoublePropertyFast(const ListLayout::Role &role, double n); + void setBoolPropertyFast(const ListLayout::Role &role, bool b); + void setQObjectPropertyFast(const ListLayout::Role &role, QV4::QObjectWrapper *o); + void setListPropertyFast(const ListLayout::Role &role, ListModel *m); + void setVariantMapFast(const ListLayout::Role &role, QV4::Object *o); + void setDateTimePropertyFast(const ListLayout::Role &role, const QDateTime &dt); + void setUrlPropertyFast(const ListLayout::Role &role, const QUrl &url); + void setFunctionPropertyFast(const ListLayout::Role &role, const QJSValue &f); + + void clearProperty(const ListLayout::Role &role); + + QVariant getProperty(const ListLayout::Role &role, const QQmlListModel *owner, QV4::ExecutionEngine *eng); + ListModel *getListProperty(const ListLayout::Role &role); + StringOrTranslation *getStringProperty(const ListLayout::Role &role); + QV4::QObjectWrapper *getQObjectProperty(const ListLayout::Role &role); + QV4::PersistentValue *getGuardProperty(const ListLayout::Role &role); + QVariantMap *getVariantMapProperty(const ListLayout::Role &role); + QDateTime *getDateTimeProperty(const ListLayout::Role &role); + QUrl *getUrlProperty(const ListLayout::Role &role); + QJSValue *getFunctionProperty(const ListLayout::Role &role); + + inline char *getPropertyMemory(const ListLayout::Role &role); + + int getUid() const { return uid; } + + ModelNodeMetaObject *objectCache(); + + char data[BLOCK_SIZE]; + ListElement *next; + + int uid; + QObject *m_objectCache; + + friend class ListModel; +}; + +/*! +\internal +*/ +class ListModel +{ +public: + + ListModel(ListLayout *layout, QQmlListModel *modelCache); + ~ListModel() {} + + void destroy(); + + int setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data); + int setExistingProperty(int uid, const QString &key, const QV4::Value &data, QV4::ExecutionEngine *eng); + + QVariant getProperty(int elementIndex, int roleIndex, const QQmlListModel *owner, QV4::ExecutionEngine *eng); + ListModel *getListProperty(int elementIndex, const ListLayout::Role &role); + + void updateTranslations(); + + int roleCount() const + { + return m_layout->roleCount(); + } + + const ListLayout::Role &getExistingRole(int index) const + { + return m_layout->getExistingRole(index); + } + + const ListLayout::Role *getExistingRole(QV4::String *key) const + { + return m_layout->getExistingRole(key); + } + + const ListLayout::Role &getOrCreateListRole(const QString &name) + { + return m_layout->getRoleOrCreate(name, ListLayout::Role::List); + } + + int elementCount() const + { + return elements.count(); + } + + enum class SetElement {WasJustInserted, IsCurrentlyUpdated}; + + void set(int elementIndex, QV4::Object *object, QVector<int> *roles); + void set(int elementIndex, QV4::Object *object, SetElement reason = SetElement::IsCurrentlyUpdated); + + int append(QV4::Object *object); + void insert(int elementIndex, QV4::Object *object); + + Q_REQUIRED_RESULT QVector<std::function<void()>> remove(int index, int count); + + int appendElement(); + void insertElement(int index); + + void move(int from, int to, int n); + + static bool sync(ListModel *src, ListModel *target); + + QObject *getOrCreateModelObject(QQmlListModel *model, int elementIndex); + +private: + QPODVector<ListElement *, 4> elements; + ListLayout *m_layout; + + QQmlListModel *m_modelCache; + + struct ElementSync + { + ListElement *src = nullptr; + ListElement *target = nullptr; + int srcIndex = -1; + int targetIndex = -1; + QVector<int> changedRoles; + }; + + void newElement(int index); + + void updateCacheIndices(int start = 0, int end = -1); + + template<typename ArrayLike> + void setArrayLike(QV4::ScopedObject *o, QV4::String *propertyName, ListElement *e, ArrayLike *a) + { + const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List); + if (r.type == ListLayout::Role::List) { + ListModel *subModel = new ListModel(r.subLayout, nullptr); + + int arrayLength = a->getLength(); + for (int j=0 ; j < arrayLength ; ++j) { + *o = a->get(j); + subModel->append(*o); + } + + e->setListPropertyFast(r, subModel); + } + } + + friend class ListElement; + friend class QQmlListModelWorkerAgent; + friend class QQmlListModelParser; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(ListModel *); + +#endif // QQUICKLISTMODEL_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistmodelworkeragent_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistmodelworkeragent_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4db3c365c0e1fa77564b5809784c24e13d668232 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmllistmodelworkeragent_p.h @@ -0,0 +1,95 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKLISTMODELWORKERAGENT_P_H +#define QQUICKLISTMODELWORKERAGENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qtqmlmodelsglobal_p.h> + +#include <QEvent> +#include <QMutex> +#include <QWaitCondition> +#include <QtQml/qqml.h> + +#include <private/qv4engine_p.h> + +QT_REQUIRE_CONFIG(qml_list_model); + +QT_BEGIN_NAMESPACE + + +class QQmlListModel; + +class QQmlListModelWorkerAgent : public QObject +{ + Q_OBJECT + Q_PROPERTY(int count READ count FINAL) + Q_PROPERTY(QQmlV4ExecutionEnginePtr engine READ engine WRITE setEngine NOTIFY engineChanged FINAL) + QML_ANONYMOUS + QML_ADDED_IN_VERSION(2, 0) + +public: + QQmlListModelWorkerAgent(QQmlListModel *); + ~QQmlListModelWorkerAgent(); + + QV4::ExecutionEngine *engine() const; + void setEngine(QV4::ExecutionEngine *eng); + + Q_INVOKABLE void addref(); + Q_INVOKABLE void release(); + + int count() const; + + Q_INVOKABLE void clear(); + Q_INVOKABLE void remove(QQmlV4FunctionPtr args); + Q_INVOKABLE void append(QQmlV4FunctionPtr args); + Q_INVOKABLE void insert(QQmlV4FunctionPtr args); + Q_INVOKABLE QJSValue get(int index) const; + Q_INVOKABLE void set(int index, const QJSValue &value); + Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value); + Q_INVOKABLE void move(int from, int to, int count); + Q_INVOKABLE void sync(); + + void modelDestroyed(); + +Q_SIGNALS: + void engineChanged(QQmlV4ExecutionEnginePtr engine); + +protected: + bool event(QEvent *) override; + +private: + friend class QQuickWorkerScriptEnginePrivate; + friend class QQmlListModel; + + struct Sync : public QEvent { + Sync(QQmlListModel *l) + : QEvent(QEvent::User) + , list(l) + {} + ~Sync(); + QQmlListModel *list; + }; + + QAtomicInt m_ref; + QQmlListModel *m_orig; + QQmlListModel *m_copy; + QMutex mutex; + QWaitCondition syncDone; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLISTMODELWORKERAGENT_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlmodelindexvaluetype_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlmodelindexvaluetype_p.h new file mode 100644 index 0000000000000000000000000000000000000000..86c7b173807bc1b32a0b7f552d4ddd69f5de847b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlmodelindexvaluetype_p.h @@ -0,0 +1,178 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLMODELINDEXVALUETYPE_P_H +#define QQMLMODELINDEXVALUETYPE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qabstractitemmodel.h> +#include <QtCore/qitemselectionmodel.h> +#include <QtQml/qqml.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +struct QQmlModelIndexValueType +{ + QModelIndex v; + + Q_PROPERTY(int row READ row CONSTANT FINAL) + Q_PROPERTY(int column READ column CONSTANT FINAL) + Q_PROPERTY(QModelIndex parent READ parent FINAL) + Q_PROPERTY(bool valid READ isValid CONSTANT FINAL) + Q_PROPERTY(QAbstractItemModel *model READ model CONSTANT FINAL) + Q_PROPERTY(quint64 internalId READ internalId CONSTANT FINAL) + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED(QQmlModelIndexValueType) + QML_FOREIGN(QModelIndex) + QML_ADDED_IN_VERSION(2, 0) + +public: + Q_INVOKABLE QString toString() const + { return QLatin1String("QModelIndex") + propertiesString(v); } + + Q_REVISION(6, 7) Q_INVOKABLE QVariant data(int role = Qt::DisplayRole) const + { return v.data(role); } + + inline int row() const noexcept { return v.row(); } + inline int column() const noexcept { return v.column(); } + inline QModelIndex parent() const { return v.parent(); } + inline bool isValid() const noexcept { return v.isValid(); } + inline QAbstractItemModel *model() const noexcept + { return const_cast<QAbstractItemModel *>(v.model()); } + quint64 internalId() const { return v.internalId(); } + + static QString propertiesString(const QModelIndex &idx); + + static QPersistentModelIndex toPersistentModelIndex(const QModelIndex &index) + { return QPersistentModelIndex(index); } + + operator QModelIndex() const { return v; } +}; + +struct QQmlPersistentModelIndexValueType +{ + QPersistentModelIndex v; + + Q_PROPERTY(int row READ row FINAL) + Q_PROPERTY(int column READ column FINAL) + Q_PROPERTY(QModelIndex parent READ parent FINAL) + Q_PROPERTY(bool valid READ isValid FINAL) + Q_PROPERTY(QAbstractItemModel *model READ model FINAL) + Q_PROPERTY(quint64 internalId READ internalId FINAL) + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED(QQmlPersistentModelIndexValueType) + QML_FOREIGN(QPersistentModelIndex) + QML_ADDED_IN_VERSION(2, 0) + +public: + Q_INVOKABLE QString toString() const + { return QLatin1String("QPersistentModelIndex") + QQmlModelIndexValueType::propertiesString(v); } + + Q_REVISION(6, 7) Q_INVOKABLE QVariant data(int role = Qt::DisplayRole) const + { return v.data(role); } + + inline int row() const { return v.row(); } + inline int column() const { return v.column(); } + inline QModelIndex parent() const { return v.parent(); } + inline bool isValid() const { return v.isValid(); } + inline QAbstractItemModel *model() const { return const_cast<QAbstractItemModel *>(v.model()); } + inline quint64 internalId() const { return v.internalId(); } + + operator QPersistentModelIndex() const { return v; } +}; + +struct QQmlItemSelectionRangeValueType +{ + QItemSelectionRange v; + + Q_PROPERTY(int top READ top FINAL) + Q_PROPERTY(int left READ left FINAL) + Q_PROPERTY(int bottom READ bottom FINAL) + Q_PROPERTY(int right READ right FINAL) + Q_PROPERTY(int width READ width FINAL) + Q_PROPERTY(int height READ height FINAL) + Q_PROPERTY(QPersistentModelIndex topLeft READ topLeft FINAL) + Q_PROPERTY(QPersistentModelIndex bottomRight READ bottomRight FINAL) + Q_PROPERTY(QModelIndex parent READ parent FINAL) + Q_PROPERTY(bool valid READ isValid FINAL) + Q_PROPERTY(bool empty READ isEmpty FINAL) + Q_PROPERTY(QAbstractItemModel *model READ model FINAL) + Q_GADGET + QML_ANONYMOUS + QML_EXTENDED(QQmlItemSelectionRangeValueType) + QML_FOREIGN(QItemSelectionRange) + QML_ADDED_IN_VERSION(2, 0) + +public: + Q_INVOKABLE QString toString() const; + Q_INVOKABLE inline bool contains(const QModelIndex &index) const + { return v.contains(index); } + Q_INVOKABLE inline bool contains(int row, int column, const QModelIndex &parentIndex) const + { return v.contains(row, column, parentIndex); } + Q_INVOKABLE inline bool intersects(const QItemSelectionRange &other) const + { return v.intersects(other); } + Q_INVOKABLE QItemSelectionRange intersected(const QItemSelectionRange &other) const + { return v.intersected(other); } + + inline int top() const { return v.top(); } + inline int left() const { return v.left(); } + inline int bottom() const { return v.bottom(); } + inline int right() const { return v.right(); } + inline int width() const { return v.width(); } + inline int height() const { return v.height(); } + inline QPersistentModelIndex &topLeft() const { return const_cast<QPersistentModelIndex &>(v.topLeft()); } + inline QPersistentModelIndex &bottomRight() const { return const_cast<QPersistentModelIndex &>(v.bottomRight()); } + inline QModelIndex parent() const { return v.parent(); } + inline QAbstractItemModel *model() const { return const_cast<QAbstractItemModel *>(v.model()); } + inline bool isValid() const { return v.isValid(); } + inline bool isEmpty() const { return v.isEmpty(); } + + operator QItemSelectionRange() const { return v; } +}; + +struct QModelIndexListForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_SEQUENTIAL_CONTAINER(QModelIndex) + QML_FOREIGN(QModelIndexList) + QML_ADDED_IN_VERSION(2, 0) +}; + +struct QModelIndexStdVectorForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_SEQUENTIAL_CONTAINER(QModelIndex) + QML_FOREIGN(std::vector<QModelIndex>) + QML_ADDED_IN_VERSION(2, 0) +}; + +struct QItemSelectionForeign +{ + Q_GADGET + QML_ANONYMOUS + QML_SEQUENTIAL_CONTAINER(QItemSelectionRange) + QML_FOREIGN(QItemSelection) + QML_ADDED_IN_VERSION(2, 0) +}; + +#undef QLISTVALUETYPE_INVOKABLE_API + +QT_END_NAMESPACE + +#endif // QQMLMODELINDEXVALUETYPE_P_H + diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlmodelsmodule_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlmodelsmodule_p.h new file mode 100644 index 0000000000000000000000000000000000000000..16da910c6bcb0d9e23b0e0116ae77a47933a6ce0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlmodelsmodule_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2016 Research In Motion. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLMODELSMODULE_H +#define QQMLMODELSMODULE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqml.h> + +#if QT_CONFIG(itemmodel) +#include <QtCore/qabstractitemmodel.h> +#include <QtCore/qitemselectionmodel.h> +#endif + +#include <private/qtqmlmodelsglobal_p.h> + +QT_BEGIN_NAMESPACE + +#if QT_CONFIG(itemmodel) +struct QItemSelectionModelForeign +{ + Q_GADGET + QML_FOREIGN(QItemSelectionModel) + QML_NAMED_ELEMENT(ItemSelectionModel) + QML_ADDED_IN_VERSION(2, 2) +}; + +struct QAbstractItemModelForeign +{ + Q_GADGET + QML_FOREIGN(QAbstractItemModel) + QML_NAMED_ELEMENT(AbstractItemModel) + QML_ADDED_IN_VERSION(6, 5) + QML_UNCREATABLE("QAbstractItemModel is abstract in C++.") +}; + +struct QAbstractListModelForeign +{ + Q_GADGET + QML_FOREIGN(QAbstractListModel) + QML_NAMED_ELEMENT(AbstractListModel) + QML_ADDED_IN_VERSION(6, 5) + QML_UNCREATABLE("QAbstractListModel is abstract in C++.") +}; +#endif + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlobjectmodel_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlobjectmodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f68ae64137e05aab21a7150c96459696ba5ce7b7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmlobjectmodel_p.h @@ -0,0 +1,157 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLINSTANCEMODEL_P_H +#define QQMLINSTANCEMODEL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtqmlmodelsglobal_p.h> +#include <private/qqmlincubator_p.h> +#include <QtQml/qqml.h> +#include <QtCore/qobject.h> + +QT_REQUIRE_CONFIG(qml_object_model); + +QT_BEGIN_NAMESPACE + +class QObject; +class QQmlChangeSet; +class QAbstractItemModel; + +class Q_QMLMODELS_EXPORT QQmlInstanceModel : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int count READ count NOTIFY countChanged) + QML_ANONYMOUS + QML_ADDED_IN_VERSION(2, 0) + +public: + enum ReusableFlag { + NotReusable, + Reusable + }; + + enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02, Pooled = 0x04 }; + Q_DECLARE_FLAGS(ReleaseFlags, ReleaseFlag) + + virtual int count() const = 0; + virtual bool isValid() const = 0; + virtual QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) = 0; + virtual ReleaseFlags release(QObject *object, ReusableFlag reusableFlag = NotReusable) = 0; + virtual void cancel(int) {} + QString stringValue(int index, const QString &role) { return variantValue(index, role).toString(); } + virtual QVariant variantValue(int, const QString &) = 0; + virtual void setWatchedRoles(const QList<QByteArray> &roles) = 0; + virtual QQmlIncubator::Status incubationStatus(int index) = 0; + + virtual void drainReusableItemsPool(int maxPoolTime) { Q_UNUSED(maxPoolTime); } + virtual int poolSize() { return 0; } + + virtual int indexOf(QObject *object, QObject *objectContext) const = 0; + virtual const QAbstractItemModel *abstractItemModel() const { return nullptr; } + + virtual bool setRequiredProperty(int index, const QString &name, const QVariant &value); + +Q_SIGNALS: + void countChanged(); + void modelUpdated(const QQmlChangeSet &changeSet, bool reset); + void createdItem(int index, QObject *object); + void initItem(int index, QObject *object); + void destroyingItem(QObject *object); + Q_REVISION(2, 15) void itemPooled(int index, QObject *object); + Q_REVISION(2, 15) void itemReused(int index, QObject *object); + +protected: + QQmlInstanceModel(QObjectPrivate &dd, QObject *parent = nullptr) + : QObject(dd, parent) {} + +private: + Q_DISABLE_COPY(QQmlInstanceModel) +}; + +class QQmlObjectModelAttached; +class QQmlObjectModelPrivate; +class Q_QMLMODELS_EXPORT QQmlObjectModel : public QQmlInstanceModel +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQmlObjectModel) + + Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged DESIGNABLE false) + Q_CLASSINFO("DefaultProperty", "children") + QML_NAMED_ELEMENT(ObjectModel) + QML_ADDED_IN_VERSION(2, 1) + QML_ATTACHED(QQmlObjectModelAttached) + +public: + QQmlObjectModel(QObject *parent=nullptr); + ~QQmlObjectModel() {} + + int count() const override; + bool isValid() const override; + QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; + ReleaseFlags release(QObject *object, ReusableFlag reusable = NotReusable) override; + QVariant variantValue(int index, const QString &role) override; + void setWatchedRoles(const QList<QByteArray> &) override {} + QQmlIncubator::Status incubationStatus(int index) override; + + int indexOf(QObject *object, QObject *objectContext) const override; + + QQmlListProperty<QObject> children(); + + static QQmlObjectModelAttached *qmlAttachedProperties(QObject *obj); + + Q_REVISION(2, 3) Q_INVOKABLE QObject *get(int index) const; + Q_REVISION(2, 3) Q_INVOKABLE void append(QObject *object); + Q_REVISION(2, 3) Q_INVOKABLE void insert(int index, QObject *object); + Q_REVISION(2, 3) Q_INVOKABLE void move(int from, int to, int n = 1); + Q_REVISION(2, 3) Q_INVOKABLE void remove(int index, int n = 1); + +public Q_SLOTS: + Q_REVISION(2, 3) void clear(); + +Q_SIGNALS: + void childrenChanged(); + +private: + Q_DISABLE_COPY(QQmlObjectModel) +}; + +class QQmlObjectModelAttached : public QObject +{ + Q_OBJECT + +public: + QQmlObjectModelAttached(QObject *parent) + : QObject(parent), m_index(-1) {} + + Q_PROPERTY(int index READ index NOTIFY indexChanged FINAL) + int index() const { return m_index; } + void setIndex(int idx) { + if (m_index != idx) { + m_index = idx; + Q_EMIT indexChanged(); + } + } + +Q_SIGNALS: + void indexChanged(); + +public: + int m_index; +}; + + +QT_END_NAMESPACE + +#endif // QQMLINSTANCEMODEL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmltableinstancemodel_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmltableinstancemodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..6063d31de09cf12c46820bf2ac2051c6c6732b97 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmltableinstancemodel_p.h @@ -0,0 +1,130 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLTABLEINSTANCEMODEL_P_H +#define QQMLTABLEINSTANCEMODEL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQmlModels/private/qqmldelegatemodel_p.h> +#include <QtQmlModels/private/qqmldelegatemodel_p_p.h> + +#include <QtCore/qpointer.h> + +QT_REQUIRE_CONFIG(qml_table_model); + +QT_BEGIN_NAMESPACE + +class QQmlTableInstanceModel; +class QQmlAbstractDelegateComponent; + +class QQmlTableInstanceModelIncubationTask : public QQDMIncubationTask +{ +public: + QQmlTableInstanceModelIncubationTask( + QQmlTableInstanceModel *tableInstanceModel + , QQmlDelegateModelItem* modelItemToIncubate + , IncubationMode mode) + : QQDMIncubationTask(nullptr, mode) + , modelItemToIncubate(modelItemToIncubate) + , tableInstanceModel(tableInstanceModel) { + clear(); + } + + void statusChanged(Status status) override; + void setInitialState(QObject *object) override; + + QQmlDelegateModelItem *modelItemToIncubate = nullptr; + QQmlTableInstanceModel *tableInstanceModel = nullptr; +}; + +class Q_QMLMODELS_EXPORT QQmlTableInstanceModel : public QQmlInstanceModel +{ + Q_OBJECT + +public: + QQmlTableInstanceModel(QQmlContext *qmlContext, QObject *parent = nullptr); + ~QQmlTableInstanceModel() override; + + void useImportVersion(QTypeRevision version); + + int count() const override { return m_adaptorModel.count(); } + int rows() const { return m_adaptorModel.rowCount(); } + int columns() const { return m_adaptorModel.columnCount(); } + + bool isValid() const override { return true; } + + bool canFetchMore() const { return m_adaptorModel.canFetchMore(); } + void fetchMore() { m_adaptorModel.fetchMore(); } + + QVariant model() const; + void setModel(const QVariant &model); + + QQmlComponent *delegate() const; + void setDelegate(QQmlComponent *); + + const QAbstractItemModel *abstractItemModel() const override; + + QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; + ReleaseFlags release(QObject *object, ReusableFlag reusable = NotReusable) override; + void dispose(QObject *object); + void cancel(int) override; + + void drainReusableItemsPool(int maxPoolTime) override; + int poolSize() override { return m_reusableItemsPool.size(); } + void reuseItem(QQmlDelegateModelItem *item, int newModelIndex); + + QQmlIncubator::Status incubationStatus(int index) override; + + bool setRequiredProperty(int index, const QString &name, const QVariant &value) final; + + QVariant variantValue(int, const QString &) override { Q_UNREACHABLE_RETURN(QVariant()); } + void setWatchedRoles(const QList<QByteArray> &) override { Q_UNREACHABLE(); } + int indexOf(QObject *, QObject *) const override { Q_UNREACHABLE_RETURN(0); } + +private: + enum DestructionMode { + Deferred, + Immediate + }; + + QQmlComponent *resolveDelegate(int index); + + QQmlAdaptorModel m_adaptorModel; + QQmlAbstractDelegateComponent *m_delegateChooser = nullptr; + QQmlComponent *m_delegate = nullptr; + QPointer<QQmlContext> m_qmlContext; + QQmlRefPointer<QQmlDelegateModelItemMetaType> m_metaType; + + QHash<int, QQmlDelegateModelItem *> m_modelItems; + QQmlReusableDelegateModelItemsPool m_reusableItemsPool; + QList<QQmlIncubator *> m_finishedIncubationTasks; + + void incubateModelItem(QQmlDelegateModelItem *modelItem, QQmlIncubator::IncubationMode incubationMode); + void incubatorStatusChanged(QQmlTableInstanceModelIncubationTask *dmIncubationTask, QQmlIncubator::Status status); + void deleteIncubationTaskLater(QQmlIncubator *incubationTask); + void deleteAllFinishedIncubationTasks(); + QQmlDelegateModelItem *resolveModelItem(int index); + void destroyModelItem(QQmlDelegateModelItem *modelItem, DestructionMode mode); + + void dataChangedCallback(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles); + void modelAboutToBeResetCallback(); + + static bool isDoneIncubating(QQmlDelegateModelItem *modelItem); + static void deleteModelItemLater(QQmlDelegateModelItem *modelItem); + + friend class QQmlTableInstanceModelIncubationTask; +}; + +QT_END_NAMESPACE + +#endif // QQMLTABLEINSTANCEMODEL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmltreemodeltotablemodel_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmltreemodeltotablemodel_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..944f94fe5b40b6f968a8ebc6b83c95f2e6851d62 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qqmltreemodeltotablemodel_p_p.h @@ -0,0 +1,183 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQmlTreeModelToTableModel_H +#define QQmlTreeModelToTableModel_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtqmlmodelsglobal_p.h" + +#include <QtCore/qset.h> +#include <QtCore/qpointer.h> +#include <QtCore/qabstractitemmodel.h> +#include <QtCore/qitemselectionmodel.h> + +QT_BEGIN_NAMESPACE + +class QAbstractItemModel; + +class Q_QMLMODELS_EXPORT QQmlTreeModelToTableModel : public QAbstractItemModel +{ + Q_OBJECT + Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelChanged FINAL) + Q_PROPERTY(QModelIndex rootIndex READ rootIndex WRITE setRootIndex RESET resetRootIndex NOTIFY rootIndexChanged FINAL) + + struct TreeItem; + +public: + explicit QQmlTreeModelToTableModel(QObject *parent = nullptr); + + QAbstractItemModel *model() const; + QModelIndex rootIndex() const; + void setRootIndex(const QModelIndex &idx); + void resetRootIndex(); + + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &child) const override; + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + + enum { + DepthRole = Qt::UserRole - 5, + ExpandedRole, + HasChildrenRole, + HasSiblingRole, + ModelIndexRole + }; + + QHash<int, QByteArray> roleNames() const override; + QVariant data(const QModelIndex &, int role) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role) override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; + + void clearModelData(); + + bool isVisible(const QModelIndex &index); + bool childrenVisible(const QModelIndex &index); + + QModelIndex mapToModel(const QModelIndex &index) const; + QModelIndex mapFromModel(const QModelIndex &index) const; + QModelIndex mapToModel(int row) const; + + Q_INVOKABLE QItemSelection selectionForRowRange(const QModelIndex &fromIndex, const QModelIndex &toIndex) const; + + void showModelTopLevelItems(bool doInsertRows = true); + void showModelChildItems(const TreeItem &parent, int start, int end, bool doInsertRows = true, bool doExpandPendingRows = true); + + int itemIndex(const QModelIndex &index) const; + void expandPendingRows(bool doInsertRows = true); + int lastChildIndex(const QModelIndex &index) const; + void removeVisibleRows(int startIndex, int endIndex, bool doRemoveRows = true); + + void dump() const; + bool testConsistency(bool dumpOnFail = false) const; + + using QAbstractItemModel::hasChildren; + +Q_SIGNALS: + void modelChanged(QAbstractItemModel *model); + void rootIndexChanged(); + void expanded(const QModelIndex &index); + void collapsed(const QModelIndex &index); + +public Q_SLOTS: + void expand(const QModelIndex &); + void collapse(const QModelIndex &); + void setModel(QAbstractItemModel *model); + bool isExpanded(const QModelIndex &) const; + bool isExpanded(int row) const; + bool hasChildren(int row) const; + bool hasSiblings(int row) const; + int depthAtRow(int row) const; + void expandRow(int n); + void expandRecursively(int row, int depth); + void collapseRow(int n); + void collapseRecursively(int row); + +private Q_SLOTS: + void modelHasBeenDestroyed(); + void modelHasBeenReset(); + void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles); + void modelLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint); + void modelLayoutChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint); + void modelRowsAboutToBeInserted(const QModelIndex & parent, int start, int end); + void modelRowsAboutToBeMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow); + void modelRowsAboutToBeRemoved(const QModelIndex & parent, int start, int end); + void modelRowsInserted(const QModelIndex & parent, int start, int end); + void modelRowsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow); + void modelRowsRemoved(const QModelIndex & parent, int start, int end); + void modelColumnsAboutToBeInserted(const QModelIndex & parent, int start, int end); + void modelColumnsAboutToBeRemoved(const QModelIndex & parent, int start, int end); + void modelColumnsInserted(const QModelIndex & parent, int start, int end); + void modelColumnsRemoved(const QModelIndex & parent, int start, int end); + +private: + struct TreeItem { + QPersistentModelIndex index; + int depth; + bool expanded; + + explicit TreeItem(const QModelIndex &idx = QModelIndex(), int d = 0, int e = false) + : index(idx), depth(d), expanded(e) + { } + + inline bool operator== (const TreeItem &other) const + { + return this->index == other.index; + } + }; + + struct DataChangedParams { + QModelIndex topLeft; + QModelIndex bottomRight; + QVector<int> roles; + }; + + struct SignalFreezer { + SignalFreezer(QQmlTreeModelToTableModel *parent) : m_parent(parent) { + m_parent->enableSignalAggregation(); + } + ~SignalFreezer() { m_parent->disableSignalAggregation(); } + + private: + QQmlTreeModelToTableModel *m_parent; + }; + + void enableSignalAggregation(); + void disableSignalAggregation(); + bool isAggregatingSignals() const { return m_signalAggregatorStack > 0; } + void queueDataChanged(const QModelIndex &topLeft, + const QModelIndex &bottomRight, + const QVector<int> &roles); + void emitQueuedSignals(); + void connectToModel(); + + QPointer<QAbstractItemModel> m_model = nullptr; + QPersistentModelIndex m_rootIndex; + QList<TreeItem> m_items; + QSet<QPersistentModelIndex> m_expandedItems; + QList<TreeItem> m_itemsToExpand; + mutable int m_lastItemIndex = 0; + bool m_visibleRowsMoved = false; + bool m_modelLayoutChanged = false; + int m_signalAggregatorStack = 0; + QVector<DataChangedParams> m_queuedDataChanged; + std::array<QMetaObject::Connection, 15> m_connections; + int m_column = 0; +}; + +QT_END_NAMESPACE + +#endif // QQmlTreeModelToTableModel_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qquickpackage_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qquickpackage_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3c9ebf9f07e810e9924fb7a792de478467aa255d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qquickpackage_p.h @@ -0,0 +1,67 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKPACKAGE_H +#define QQUICKPACKAGE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qqml.h> +#include <QtQmlModels/private/qtqmlmodelsglobal_p.h> + +QT_REQUIRE_CONFIG(qml_delegate_model); + +QT_BEGIN_NAMESPACE + +class QQuickPackagePrivate; +class QQuickPackageAttached; +class Q_QMLMODELS_EXPORT QQuickPackage : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQuickPackage) + + Q_CLASSINFO("DefaultProperty", "data") + QML_NAMED_ELEMENT(Package) + QML_ADDED_IN_VERSION(2, 0) + QML_ATTACHED(QQuickPackageAttached) + Q_PROPERTY(QQmlListProperty<QObject> data READ data) + +public: + QQuickPackage(QObject *parent=nullptr); + + QQmlListProperty<QObject> data(); + + QObject *part(const QString & = QString()); + bool hasPart(const QString &); + + static QQuickPackageAttached *qmlAttachedProperties(QObject *); +}; + +class QQuickPackageAttached : public QObject +{ +Q_OBJECT +Q_PROPERTY(QString name READ name WRITE setName FINAL) +public: + QQuickPackageAttached(QObject *parent); + virtual ~QQuickPackageAttached(); + + QString name() const; + void setName(const QString &n); + + static QHash<QObject *, QQuickPackageAttached *> attached; +private: + QString _name; +}; + +QT_END_NAMESPACE + +#endif // QQUICKPACKAGE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qtqmlmodels-config_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qtqmlmodels-config_p.h new file mode 100644 index 0000000000000000000000000000000000000000..eb0e17d237d7b152d7b83630e4f8d89ef1d0c653 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qtqmlmodels-config_p.h @@ -0,0 +1,8 @@ +#define QT_FEATURE_qml_object_model 1 + +#define QT_FEATURE_qml_list_model 1 + +#define QT_FEATURE_qml_delegate_model 1 + +#define QT_FEATURE_qml_table_model 1 + diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qtqmlmodelsglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qtqmlmodelsglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7accbf17acc07f5643be053caeaf2460566dd666 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlModels/6.8.1/QtQmlModels/private/qtqmlmodelsglobal_p.h @@ -0,0 +1,25 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTQMLMODELSGLOBAL_P_H +#define QTQMLMODELSGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qtqmlglobal_p.h> +#include <QtQmlModels/qtqmlmodelsglobal.h> +#include <QtQmlModels/private/qtqmlmodels-config_p.h> +#include <QtQmlModels/qtqmlmodelsexports.h> + +#define Q_QMLMODELS_AUTOTEST_EXPORT Q_AUTOTEST_EXPORT + +#endif // QTQMLMODELSGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlnetworkinformation_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlnetworkinformation_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a9a7fdbd2c252f3839658d7ee7f8240ff9f300fa --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlnetworkinformation_p.h @@ -0,0 +1,41 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLNETWORKINFORMATION_P_H +#define QQMLNETWORKINFORMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QQmlEngine> +#include <QJSEngine> + +#include <QtNetwork/qnetworkinformation.h> +#include <qtqmlnetworkexports.h> +#include <QtQml/qqml.h> + +QT_BEGIN_NAMESPACE + +struct Q_QMLNETWORK_EXPORT QQmlNetworkInformation +{ + Q_GADGET + QML_FOREIGN(QNetworkInformation) + QML_NAMED_ELEMENT(NetworkInformation) + QML_ADDED_IN_VERSION(6, 7) + QML_SINGLETON + +public: + static QNetworkInformation *create(QQmlEngine *, QJSEngine *); +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslconfiguration_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslconfiguration_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a529fffbd705bac66d76ab403591add513d1ad6b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslconfiguration_p.h @@ -0,0 +1,109 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSSLCONFIGURATION_P_H +#define QQMLSSLCONFIGURATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qtqmlnetworkexports.h> +#include "qqmlsslkey_p.h" + +#include <QtCore/QByteArray> +#include <QtCore/QMetaType> +#include <QtQml/qqml.h> +#include <QtNetwork/qsslconfiguration.h> +#include <QtNetwork/qsslsocket.h> +#include <QtNetwork/qssl.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLNETWORK_EXPORT QQmlSslConfiguration +{ + Q_GADGET + + Q_PROPERTY(QString ciphers READ ciphers WRITE setCiphers) + Q_PROPERTY(QList<QSsl::SslOption> sslOptions READ sslOptions WRITE setSslOptions) + Q_PROPERTY(QSsl::SslProtocol protocol READ protocol WRITE setProtocol) + Q_PROPERTY(QSslSocket::PeerVerifyMode peerVerifyMode READ peerVerifyMode + WRITE setPeerVerifyMode) + Q_PROPERTY(int peerVerifyDepth READ peerVerifyDepth WRITE setPeerVerifyDepth) + Q_PROPERTY(QByteArray sessionTicket READ sessionTicket WRITE setSessionTicket) + +public: + Q_INVOKABLE void setCertificateFiles(const QStringList &certificateFiles); + Q_INVOKABLE void setPrivateKey(const QQmlSslKey &privateKey); + + QString ciphers() const; + QList<QSsl::SslOption> sslOptions() const; + QSsl::SslProtocol protocol() const; + QSslSocket::PeerVerifyMode peerVerifyMode() const; + int peerVerifyDepth() const; + QByteArray sessionTicket() const; + QSslConfiguration const configuration(); + + void setProtocol(QSsl::SslProtocol protocol); + void setPeerVerifyMode(QSslSocket::PeerVerifyMode mode); + void setPeerVerifyDepth(int depth); + void setCiphers(const QString &ciphers); + void setSslOptions(const QList<QSsl::SslOption> &options); + void setSessionTicket(const QByteArray &sessionTicket); + +private: + inline friend bool operator==(const QQmlSslConfiguration &lval, + const QQmlSslConfiguration &rval) + { + return lval.m_certificateFiles == rval.m_certificateFiles + && lval.m_ciphers == rval.m_ciphers + && lval.m_sslOptions == rval.m_sslOptions + && lval.m_configuration == rval.m_configuration; + } + + inline friend bool operator!=(const QQmlSslConfiguration &lval, + const QQmlSslConfiguration &rval) + { + return !(lval == rval); + } + +protected: + void setSslOptionsList(const QSslConfiguration &configuration); + void setCiphersList(const QSslConfiguration &configuration); + + QStringList m_certificateFiles; + QString m_ciphers; + QList<QSsl::SslOption> m_sslOptions; + QSslConfiguration m_configuration; +}; + +class Q_QMLNETWORK_EXPORT QQmlSslDefaultConfiguration : public QQmlSslConfiguration +{ + Q_GADGET + QML_NAMED_ELEMENT(sslConfiguration) + QML_ADDED_IN_VERSION(6, 7) + +public: + QQmlSslDefaultConfiguration(); +}; + +class Q_QMLNETWORK_EXPORT QQmlSslDefaultDtlsConfiguration : public QQmlSslConfiguration +{ + Q_GADGET + QML_NAMED_ELEMENT(sslDtlsConfiguration) + QML_ADDED_IN_VERSION(6, 7) + +public: + QQmlSslDefaultDtlsConfiguration(); +}; + +QT_END_NAMESPACE + +#endif // QQMLSSLCONFIGURATION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslkey_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslkey_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5661308a7350e1b2a1c310af4092f633abb9e9da --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslkey_p.h @@ -0,0 +1,77 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSSLKEY_P_H +#define QQMLSSLKEY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qtqmlnetworkexports.h> + +#include <QtCore/QByteArray> +#include <QtCore/QMetaType> +#include <QtNetwork/qsslkey.h> +#include <QtNetwork/qssl.h> +#include <QtQml/qqml.h> + +QT_BEGIN_NAMESPACE + +class Q_QMLNETWORK_EXPORT QQmlSslKey +{ + Q_GADGET + QML_NAMED_ELEMENT(sslKey) + QML_ADDED_IN_VERSION(6, 7) + + Q_PROPERTY(QString keyFile READ keyFile + WRITE setKeyFile) + Q_PROPERTY(QSsl::KeyAlgorithm keyAlgorithm READ keyAlgorithm + WRITE setKeyAlgorithm) + Q_PROPERTY(QSsl::EncodingFormat keyFormat READ keyFormat + WRITE setKeyFormat) + Q_PROPERTY(QByteArray keyPassPhrase READ keyPassPhrase + WRITE setKeyPassPhrase) + Q_PROPERTY(QSsl::KeyType keyType READ keyType WRITE setKeyType) + +public: + QSslKey getSslKey() const; + QString keyFile() const { return m_keyFile; } + QSsl::KeyAlgorithm keyAlgorithm() const { return m_keyAlgorithm; } + QSsl::EncodingFormat keyFormat() const { return m_keyFormat; } + QByteArray keyPassPhrase() const { return m_keyPassPhrase; } + QSsl::KeyType keyType() const { return m_keyType; } + + void setKeyFile(const QString &key); + void setKeyAlgorithm(QSsl::KeyAlgorithm value); + void setKeyFormat(QSsl::EncodingFormat value); + void setKeyPassPhrase(const QByteArray &value); + void setKeyType(QSsl::KeyType type); + +private: + inline friend bool operator==(const QQmlSslKey &lvalue, const QQmlSslKey &rvalue) + { + return (lvalue.m_keyFile == rvalue.m_keyFile + && lvalue.m_keyAlgorithm == rvalue.m_keyAlgorithm + && lvalue.m_keyFormat == rvalue.m_keyFormat + && lvalue.m_keyType == rvalue.m_keyType + && lvalue.m_keyPassPhrase == rvalue.m_keyPassPhrase); + } + + QString m_keyFile; + QByteArray m_keyPassPhrase; + QSsl::KeyAlgorithm m_keyAlgorithm = QSsl::Rsa; + QSsl::EncodingFormat m_keyFormat = QSsl::Pem; + QSsl::KeyType m_keyType = QSsl::PrivateKey; +}; + +QT_END_NAMESPACE + +#endif // QQMLSSLKEY_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslnamespace_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslnamespace_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9429666e59aaeed6ad3533ef98e514071452b7d6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslnamespace_p.h @@ -0,0 +1,36 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSSLNAMESPACE_P_H +#define QQMLSSLNAMESPACE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qtqmlnetworkexports.h> + +#include <QtCore/QMetaType> +#include <QtQml/qqml.h> +#include <QtNetwork/QSsl> + +QT_BEGIN_NAMESPACE + +namespace QSslForeignNamespace +{ + Q_NAMESPACE + QML_FOREIGN_NAMESPACE(QSsl) + QML_NAMED_ELEMENT(Ssl) + QML_ADDED_IN_VERSION(6, 7) +}; + +QT_END_NAMESPACE + +#endif // QQMLSSLNAMESPACE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslsocketnamespace_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslsocketnamespace_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0f3af7164629b147a30e429c3dbf7eca7e9fd1ab --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlNetwork/6.8.1/QtQmlNetwork/private/qqmlsslsocketnamespace_p.h @@ -0,0 +1,36 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLSSLSOCKETNAMESPACE_P_H +#define QQMLSSLSOCKETNAMESPACE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qtqmlnetworkexports.h> + +#include <QtCore/QMetaObject> +#include <QtQml/qqml.h> +#include <QtNetwork/qsslsocket.h> + +QT_BEGIN_NAMESPACE + +namespace SslSocketForeignNamespace +{ + Q_NAMESPACE + QML_FOREIGN_NAMESPACE(QSslSocket) + QML_NAMED_ELEMENT(SslSocket) + QML_ADDED_IN_VERSION(6, 7) +}; + +QT_END_NAMESPACE + +#endif // QQMLSSLSOCKETNAMESPACE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlToolingSettings/6.8.1/QtQmlToolingSettings/private/qqmltoolingsettings_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlToolingSettings/6.8.1/QtQmlToolingSettings/private/qqmltoolingsettings_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4b59086ac0077750fb5cfa150c223d89182cc9f3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlToolingSettings/6.8.1/QtQmlToolingSettings/private/qqmltoolingsettings_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLTOOLINGSETTINGS_P_H +#define QQMLTOOLINGSETTINGS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> +#include <QtCore/qhash.h> +#include <QtCore/qvariant.h> + +QT_BEGIN_NAMESPACE + +class QQmlToolingSettings +{ +public: + QQmlToolingSettings(const QString &toolName) : m_toolName(toolName) { } + + void addOption(const QString &name, const QVariant defaultValue = QVariant()); + + bool writeDefaults() const; + bool search(const QString &path); + + QVariant value(QString name) const; + bool isSet(QString name) const; + +private: + QString m_toolName; + QString m_currentSettingsPath; + QHash<QString, QString> m_seenDirectories; + QVariantHash m_values; + + bool read(const QString &settingsFilePath); +}; + +QT_END_NAMESPACE + +#endif // QQMLTOOLINGSETTINGS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlToolingSettings/6.8.1/QtQmlToolingSettings/private/qqmltoolingutils_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlToolingSettings/6.8.1/QtQmlToolingSettings/private/qqmltoolingutils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b700f427b5255b2ca0d729a8e32718462fd732a4 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlToolingSettings/6.8.1/QtQmlToolingSettings/private/qqmltoolingutils_p.h @@ -0,0 +1,37 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLTOOLINGUTILS_P_H +#define QQMLTOOLINGUTILS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qstring.h> +#include <QtCore/qstringlist.h> +#include <QtCore/qcommandlineparser.h> +#include <QtCore/qcommandlineoption.h> + +QT_BEGIN_NAMESPACE + +class QQmlToolingUtils +{ +private: + static void warnForInvalidDirs(const QStringList &dirs, const QString &origin); +public: + static QStringList getAndWarnForInvalidDirsFromEnv(const QString &environmentVariableName); + static QStringList getAndWarnForInvalidDirsFromOption(const QCommandLineParser &parser, + const QCommandLineOption &option); +}; + +QT_END_NAMESPACE + +#endif // QQMLTOOLINGUTILS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qanystringviewutils_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qanystringviewutils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bffbc76749285a77d5ac735ec0c5d56e99945305 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qanystringviewutils_p.h @@ -0,0 +1,187 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QANYSTRINGVIEWUTILS_P_H +#define QANYSTRINGVIEWUTILS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <QtCore/private/qjson_p.h> + +#include <QtCore/qanystringview.h> +#include <QtCore/qcbormap.h> +#include <QtCore/qcborvalue.h> + +QT_BEGIN_NAMESPACE + +namespace QAnyStringViewUtils { + +inline QAnyStringView toStringView(const QCborValue &value) +{ + const QCborContainerPrivate *container = QJsonPrivate::Value::container(value); + if (!container) + return QAnyStringView(); + + const qint64 n = QJsonPrivate::Value::valueHelper(value); + const auto &e = container->elements.at(n); + const auto data = container->byteData(e); + if (!data) + return QAnyStringView(); + if (e.flags & QtCbor::Element::StringIsUtf16) + return data->asStringView(); + if (e.flags & QtCbor::Element::StringIsAscii) + return data->asLatin1(); + return data->asUtf8StringView(); +} + +inline QAnyStringView toStringView(const QCborMap &map, QLatin1StringView key) +{ + return toStringView(map[key]); +} + +// Note: This only works if part is US-ASCII, but there is no type to encode this information! +inline bool endsWith(QAnyStringView whole, QLatin1StringView part) +{ + Q_ASSERT(QtPrivate::isAscii(part)); + return whole.length() >= part.length() && whole.last(part.length()) == part; +} + +// Note: This only works if part is US-ASCII, but there is no type to encode this information! +inline bool startsWith(QAnyStringView whole, QLatin1StringView part) +{ + Q_ASSERT(QtPrivate::isAscii(part)); + return whole.length() >= part.length() && whole.first(part.length()) == part; +} + +inline bool doesContain(QStringView whole, QLatin1Char part) { return whole.contains(part); } +inline bool doesContain(QLatin1StringView whole, QLatin1Char part) { return whole.contains(part); } +inline bool doesContain(QUtf8StringView whole, QLatin1Char part) +{ + return QByteArrayView(whole.data(), whole.size()).contains(part.toLatin1()); +} +inline bool contains(QAnyStringView whole, QLatin1Char part) +{ + return whole.visit([&](auto view) { return doesContain(view, part); }); +} + +inline qsizetype getLastIndexOf(QStringView whole, QLatin1StringView part) +{ + return whole.lastIndexOf(part); +} +inline qsizetype getLastIndexOf(QLatin1StringView whole, QLatin1StringView part) +{ + return whole.lastIndexOf(part); +} +inline qsizetype getLastIndexOf(QUtf8StringView whole, QLatin1StringView part) +{ + return QByteArrayView(whole.data(), whole.size()).lastIndexOf(part); +} +inline qsizetype lastIndexOf(QAnyStringView whole, QLatin1StringView part) +{ + Q_ASSERT(QtPrivate::isAscii(part)); + return whole.visit([&](auto view) { return getLastIndexOf(view, part); }); +} + +inline int toInt(QUtf8StringView view) +{ + return QByteArrayView(view.data(), view.length()).toInt(); +} +inline int toInt(QLatin1StringView view) { return view.toInt(); } +inline int toInt(QStringView view) { return view.toInt(); } + +inline int toInt(QAnyStringView string) +{ + return string.visit([](auto view) { return toInt(view); }); +} + +template<typename StringView> +QAnyStringView doTrimmed(StringView string) +{ + if constexpr (std::is_same_v<StringView, QStringView>) + return string.trimmed(); + if constexpr (std::is_same_v<StringView, QLatin1StringView>) + return string.trimmed(); + if constexpr (std::is_same_v<StringView, QUtf8StringView>) + return QByteArrayView(string.data(), string.length()).trimmed(); +} + + +inline QAnyStringView trimmed(QAnyStringView string) +{ + return string.visit([](auto data) { + return doTrimmed(data); + }); +} + +template<typename StringView, typename Handler> +auto processAsUtf8(StringView string, Handler &&handler) +{ + if constexpr (std::is_same_v<StringView, QStringView>) + return handler(QByteArrayView(string.toUtf8())); + if constexpr (std::is_same_v<StringView, QLatin1StringView>) + return handler(QByteArrayView(string.data(), string.length())); + if constexpr (std::is_same_v<StringView, QUtf8StringView>) + return handler(QByteArrayView(string.data(), string.length())); + if constexpr (std::is_same_v<StringView, QByteArrayView>) + return handler(string); + if constexpr (std::is_same_v<StringView, QByteArray>) + return handler(QByteArrayView(string)); + if constexpr (std::is_same_v<StringView, QAnyStringView>) { + + // Handler is: + // * a reference if an lvalue ref is passed + // * a value otherwise + // We conserve its nature for passing to the lambda below. + // This is necessary because we need to decide on the nature of + // the lambda capture as part of the syntax (prefix '&' or not). + // So we always pass a reference-conserving wrapper as value. + struct Wrapper { Handler handler; }; + + return string.visit([w = Wrapper { std::forward<Handler>(handler) }](auto view) mutable { + static_assert(!(std::is_same_v<decltype(view), QAnyStringView>)); + return processAsUtf8(std::move(view), std::forward<Handler>(w.handler)); + }); + } + Q_UNREACHABLE(); +} + +// Note: This only works if sep is US-ASCII, but there is no type to encode this information! +inline QList<QAnyStringView> split(QAnyStringView source, QLatin1StringView sep) +{ + Q_ASSERT(QtPrivate::isAscii(sep)); + + QList<QAnyStringView> list; + if (source.isEmpty()) { + list.append(source); + return list; + } + + qsizetype start = 0; + qsizetype end = source.length(); + + for (qsizetype current = 0; current < end; ++current) { + if (source.mid(current, sep.length()) == sep) { + list.append(source.mid(start, current - start)); + start = current + sep.length(); + } + } + + if (start < end) + list.append(source.mid(start, end - start)); + + return list; +} + +} + +QT_END_NAMESPACE + +#endif // QANYSTRINGVIEWUTILS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qmetatypesjsonprocessor_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qmetatypesjsonprocessor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..96d3b3568fca60ebce565fd0f3795cb5245e6880 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qmetatypesjsonprocessor_p.h @@ -0,0 +1,301 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef METATYPESJSONPROCESSOR_P_H +#define METATYPESJSONPROCESSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qcbormap.h> +#include <QtCore/qstring.h> +#include <QtCore/qtyperevision.h> +#include <QtCore/qvarlengtharray.h> +#include <QtCore/qvector.h> + +QT_BEGIN_NAMESPACE + +// With all the QAnyStringViews in this file we rely on the Cbor data to stay +// in place if you don't change the Cbor contents. We assume that Cbor data +// is implicitly shared so that merely copying const Cbor objects does not copy +// the contents. + +enum class Access { Public, Protected, Private }; + +struct BaseType +{ + using Container = QVarLengthArray<BaseType, 1>; + + BaseType() = default; + BaseType(const QCborMap &cbor); + + QAnyStringView name; + Access access; +}; + +struct ClassInfo +{ + using Container = std::vector<ClassInfo>; + + ClassInfo() = default; + ClassInfo(const QCborMap &cbor); + + QAnyStringView name; + QAnyStringView value; +}; + +struct Interface +{ + using Container = QVarLengthArray<Interface, 1>; + + Interface() = default; + Interface(const QCborValue &cbor); + + QAnyStringView className; +}; + +struct Property +{ + using Container = std::vector<Property>; + + Property() = default; + Property(const QCborMap &cbor); + + QAnyStringView name; + QAnyStringView type; + + QAnyStringView member; + QAnyStringView read; + QAnyStringView write; + QAnyStringView reset; + QAnyStringView notify; + QAnyStringView bindable; + + QAnyStringView privateClass; + + int index = -1; + + QTypeRevision revision; + + bool isFinal = false; + bool isConstant = false; + bool isRequired = false; +}; + +struct Argument +{ + using Container = std::vector<Argument>; + + Argument() = default; + Argument(const QCborMap &cbor); + + QAnyStringView name; + QAnyStringView type; +}; + +struct Method +{ + using Container = std::vector<Method>; + static constexpr int InvalidIndex = std::numeric_limits<int>::min(); + + Method() = default; + Method(const QCborMap &cbor, bool isConstructor); + + QAnyStringView name; + + Argument::Container arguments; + QAnyStringView returnType; + + int index = InvalidIndex; + + QTypeRevision revision; + + Access access = Access::Public; + + bool isCloned = false; + bool isJavaScriptFunction = false; + bool isConstructor = false; +}; + +struct Enum +{ + using Container = std::vector<Enum>; + + Enum() = default; + Enum(const QCborMap &cbor); + + QAnyStringView name; + QAnyStringView alias; + QAnyStringView type; + + QList<QAnyStringView> values; + + bool isFlag = false; + bool isClass = false; +}; + +struct MetaTypePrivate +{ + Q_DISABLE_COPY_MOVE(MetaTypePrivate) + + enum Kind : quint8 { Object, Gadget, Namespace, Unknown }; + + MetaTypePrivate() = default; + MetaTypePrivate(const QCborMap &cbor, const QString &inputFile); + + const QCborMap cbor; // need to keep this to hold on to the strings + const QString inputFile; + + QAnyStringView className; + QAnyStringView qualifiedClassName; + BaseType::Container superClasses; + ClassInfo::Container classInfos; + Interface::Container ifaces; + + Property::Container properties; + + Method::Container methods; + Method::Container sigs; + Method::Container constructors; + + Enum::Container enums; + + Kind kind = Unknown; + int lineNumber = 0; +}; + +class MetaType +{ +public: + using Kind = MetaTypePrivate::Kind; + + MetaType() = default; + MetaType(const QCborMap &cbor, const QString &inputFile); + + bool isEmpty() const { return d == &s_empty; } + + QString inputFile() const { return d->inputFile; } + int lineNumber() const { return d->lineNumber; } + QAnyStringView className() const { return d->className; } + QAnyStringView qualifiedClassName() const { return d->qualifiedClassName; } + const BaseType::Container &superClasses() const { return d->superClasses; } + const ClassInfo::Container &classInfos() const { return d->classInfos; } + const Interface::Container &ifaces() const { return d->ifaces; } + + const Property::Container &properties() const { return d->properties; } + const Method::Container &methods() const { return d->methods; } + const Method::Container &sigs() const { return d->sigs; } + const Method::Container &constructors() const { return d->constructors; } + + const Enum::Container &enums() const { return d->enums; } + + Kind kind() const { return d->kind; } + +private: + friend bool operator==(const MetaType &a, const MetaType &b) noexcept + { + return a.d == b.d; + } + + friend bool operator!=(const MetaType &a, const MetaType &b) noexcept + { + return !(a == b); + } + + static const MetaTypePrivate s_empty; + const MetaTypePrivate *d = &s_empty; +}; + +struct UsingDeclaration { + QAnyStringView alias; + QAnyStringView original; + + bool isValid() const { return !alias.isEmpty() && !original.isEmpty(); } +private: + friend bool comparesEqual(const UsingDeclaration &a, const UsingDeclaration &b) noexcept + { + return std::tie(a.alias, a.original) == std::tie(b.alias, b.original); + } + + friend Qt::strong_ordering compareThreeWay( + const UsingDeclaration &a, const UsingDeclaration &b) noexcept + { + return a.alias != b.alias + ? compareThreeWay(a.alias, b.alias) + : compareThreeWay(a.original, b.original); + } + Q_DECLARE_STRONGLY_ORDERED(UsingDeclaration); +}; + +class MetaTypesJsonProcessor +{ +public: + static QList<QAnyStringView> namespaces(const MetaType &classDef); + + MetaTypesJsonProcessor(bool privateIncludes) : m_privateIncludes(privateIncludes) {} + + bool processTypes(const QStringList &files); + + bool processForeignTypes(const QString &foreignTypesFile); + bool processForeignTypes(const QStringList &foreignTypesFiles); + + void postProcessTypes(); + void postProcessForeignTypes(); + + QVector<MetaType> types() const { return m_types; } + QVector<MetaType> foreignTypes() const { return m_foreignTypes; } + QList<QAnyStringView> referencedTypes() const { return m_referencedTypes; } + QList<UsingDeclaration> usingDeclarations() const { return m_usingDeclarations; } + QList<QString> includes() const { return m_includes; } + + QString extractRegisteredTypes() const; + +private: + enum RegistrationMode { + NoRegistration, + ObjectRegistration, + GadgetRegistration, + NamespaceRegistration + }; + + struct PreProcessResult { + QList<QAnyStringView> primitiveAliases; + UsingDeclaration usingDeclaration; + QAnyStringView foreignPrimitive; + RegistrationMode mode; + }; + + enum class PopulateMode { No, Yes }; + static PreProcessResult preProcess(const MetaType &classDef, PopulateMode populateMode); + void addRelatedTypes(); + + void sortTypes(QVector<MetaType> &types); + QString resolvedInclude(QAnyStringView include); + void processTypes(const QCborMap &types); + void processForeignTypes(const QCborMap &types); + + bool isPrimitive(QAnyStringView type) const + { + return std::binary_search(m_primitiveTypes.begin(), m_primitiveTypes.end(), type); + } + + QList<QString> m_includes; + QList<QAnyStringView> m_referencedTypes; + QList<QAnyStringView> m_primitiveTypes; + QList<UsingDeclaration> m_usingDeclarations; + QVector<MetaType> m_types; + QVector<MetaType> m_foreignTypes; + bool m_privateIncludes = false; +}; + +QT_END_NAMESPACE + +#endif // METATYPESJSONPROCESSOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmljsstreamwriter_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmljsstreamwriter_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5ad27bef4ab657f24959c9e358ac4029bd8dffed --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmljsstreamwriter_p.h @@ -0,0 +1,69 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLJSSTREAMWRITER_P_H +#define QQMLJSSTREAMWRITER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#include <QtCore/QIODevice> +#include <QtCore/QList> +#include <QtCore/QString> +#include <QtCore/QScopedPointer> +#include <QtCore/QPair> + +QT_BEGIN_NAMESPACE + +class QQmlJSStreamWriter +{ +public: + QQmlJSStreamWriter(QByteArray *array); + + void writeStartDocument(); + void writeEndDocument(); + void writeLibraryImport( + QByteArrayView uri, int majorVersion, int minorVersion, QByteArrayView as = {}); + void writeStartObject(QByteArrayView component); + void writeEndObject(); + void writeScriptBinding(QByteArrayView name, QByteArrayView rhs); + void writeStringBinding(QByteArrayView name, QAnyStringView value); + void writeNumberBinding(QByteArrayView name, qint64 value); + + // TODO: Drop this once we can drop qmlplugindump. It is substantially weird. + void writeEnumObjectLiteralBinding( + QByteArrayView name, const QList<QPair<QAnyStringView, int>> &keyValue); + + // TODO: these would look better with generator functions. + void writeArrayBinding(QByteArrayView name, const QByteArrayList &elements); + void writeStringListBinding(QByteArrayView name, const QList<QAnyStringView> &elements); + + void write(QByteArrayView data); + void writeBooleanBinding(QByteArrayView name, bool value); + +private: + void writeIndent(); + void writePotentialLine(const QByteArray &line); + void flushPotentialLinesWithNewlines(); + + template<typename String, typename ElementHandler> + void doWriteArrayBinding( + QByteArrayView name, const QList<String> &elements, ElementHandler &&handler); + + int m_indentDepth; + QList<QByteArray> m_pendingLines; + int m_pendingLineLength; + bool m_maybeOneline; + QScopedPointer<QIODevice> m_stream; +}; + +QT_END_NAMESPACE + +#endif // QQMLJSSTREAMWRITER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltyperegistrar_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltyperegistrar_p.h new file mode 100644 index 0000000000000000000000000000000000000000..cb0e725fb450d880120cbc30f24a0a2921356e91 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltyperegistrar_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QMLTYPEREGISTRAR_P_H +#define QMLTYPEREGISTRAR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qcbormap.h> +#include <QtCore/qversionnumber.h> + +#include <cstdlib> + +#include "qmetatypesjsonprocessor_p.h" + +QT_BEGIN_NAMESPACE + +class QmlTypeRegistrar +{ + QString m_module; + QString m_targetNamespace; + QTypeRevision m_moduleVersion; + QList<quint8> m_pastMajorVersions; + QList<QString> m_includes; + bool m_followForeignVersioning = false; + QVector<MetaType> m_types; + QVector<MetaType> m_foreignTypes; + QList<QAnyStringView> m_referencedTypes; + QList<UsingDeclaration> m_usingDeclarations; + + MetaType findType(QAnyStringView name) const; + MetaType findTypeForeign(QAnyStringView name) const; + +public: + void write(QTextStream &os, QAnyStringView outFileName) const; + bool generatePluginTypes(const QString &pluginTypesFile, bool generatingJSRoot = false); + void setModuleNameAndNamespace(const QString &module, const QString &targetNamespace); + void setModuleVersions(QTypeRevision moduleVersion, const QList<quint8> &pastMajorVersions, + bool followForeignVersioning); + void setIncludes(const QList<QString> &includes); + void setTypes(const QVector<MetaType> &types, const QVector<MetaType> &foreignTypes); + void setReferencedTypes(const QList<QAnyStringView> &referencedTypes); + void setUsingDeclarations(const QList<UsingDeclaration> &usingDeclarations); + + static bool argumentsFromCommandLineAndFile(QStringList &allArguments, + const QStringList &arguments); + static int runExtract( + const QString &baseName, const QString &nameSpace, + const MetaTypesJsonProcessor &processor); +}; + +QT_END_NAMESPACE +#endif // QMLTYPEREGISTRAR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltyperegistrarconstants_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltyperegistrarconstants_p.h new file mode 100644 index 0000000000000000000000000000000000000000..96169c76a9f2442717ad40ff4eaf6b633edc1568 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltyperegistrarconstants_p.h @@ -0,0 +1,178 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLTYPEREGISTRARCONSTANTS_P_H +#define QQMLTYPEREGISTRARCONSTANTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qlatin1stringview.h> + +QT_BEGIN_NAMESPACE + +namespace Constants { + +// Strings that commonly occur in .qmltypes files. +namespace DotQmltypes { +static constexpr QLatin1StringView S_ACCESS_SEMANTICS { "accessSemantics" }; +static constexpr QLatin1StringView S_ALIAS { "alias" }; +static constexpr QLatin1StringView S_ALIASES { "aliases" }; +static constexpr QLatin1StringView S_ARGUMENTS { "arguments" }; +static constexpr QLatin1StringView S_ATTACHED_TYPE { "attachedType" }; +static constexpr QLatin1StringView S_BINDABLE { "bindable" }; +static constexpr QLatin1StringView S_COMPONENT { "Component" }; +static constexpr QLatin1StringView S_DEFAULT_PROPERTY { "defaultProperty" }; +static constexpr QLatin1StringView S_DEFERRED_NAMES { "deferredNames" }; +static constexpr QLatin1StringView S_ENFORCES_SCOPED_ENUMS { "enforcesScopedEnums" }; +static constexpr QLatin1StringView S_ENUM { "Enum" }; +static constexpr QLatin1StringView S_EXPORTS { "exports" }; +static constexpr QLatin1StringView S_EXPORT_META_OBJECT_REVISIONS { "exportMetaObjectRevisions" }; +static constexpr QLatin1StringView S_EXTENSION { "extension" }; +static constexpr QLatin1StringView S_EXTENSION_IS_JAVA_SCRIPT { "extensionIsJavaScript" }; +static constexpr QLatin1StringView S_EXTENSION_IS_NAMESPACE { "extensionIsNamespace" }; +static constexpr QLatin1StringView S_FILE { "file" }; +static constexpr QLatin1StringView S_HAS_CUSTOM_PARSER { "hasCustomParser" }; +static constexpr QLatin1StringView S_IMMEDIATE_NAMES { "immediateNames" }; +static constexpr QLatin1StringView S_INDEX { "index" }; +static constexpr QLatin1StringView S_INTERFACES { "interfaces" }; +static constexpr QLatin1StringView S_IS_CLONED { "isCloned" }; +static constexpr QLatin1StringView S_IS_CONSTANT { "isConstant" }; +static constexpr QLatin1StringView S_IS_CONSTRUCTOR { "isConstructor" }; +static constexpr QLatin1StringView S_IS_CREATABLE { "isCreatable" }; +static constexpr QLatin1StringView S_IS_FINAL { "isFinal" }; +static constexpr QLatin1StringView S_IS_FLAG { "isFlag" }; +static constexpr QLatin1StringView S_IS_JAVASCRIPT_FUNCTION { "isJavaScriptFunction" }; +static constexpr QLatin1StringView S_IS_JAVASCRIPT_BUILTIN { "isJavaScriptBuiltin" }; +static constexpr QLatin1StringView S_IS_LIST { "isList" }; +static constexpr QLatin1StringView S_IS_POINTER { "isPointer" }; +static constexpr QLatin1StringView S_IS_READONLY { "isReadonly" }; +static constexpr QLatin1StringView S_IS_REQUIRED { "isRequired" }; +static constexpr QLatin1StringView S_IS_SCOPED { "isScoped" }; +static constexpr QLatin1StringView S_IS_SINGLETON { "isSingleton" }; +static constexpr QLatin1StringView S_IS_STRUCTURED { "isStructured" }; +static constexpr QLatin1StringView S_METHOD { "Method" }; +static constexpr QLatin1StringView S_MODULE { "Module" }; +static constexpr QLatin1StringView S_NAME { "name" }; +static constexpr QLatin1StringView S_NONE { "none" }; +static constexpr QLatin1StringView S_NOTIFY { "notify" }; +static constexpr QLatin1StringView S_PARAMETER { "Parameter" }; +static constexpr QLatin1StringView S_PARENT_PROPERTY { "parentProperty" }; +static constexpr QLatin1StringView S_PRIVATE_CLASS { "privateClass" }; +static constexpr QLatin1StringView S_PROPERTY { "Property" }; +static constexpr QLatin1StringView S_PROTOTYPE { "prototype" }; +static constexpr QLatin1StringView S_READ { "read" }; +static constexpr QLatin1StringView S_REFERENCE { "reference" }; +static constexpr QLatin1StringView S_RESET { "reset" }; +static constexpr QLatin1StringView S_REVISION { "revision" }; +static constexpr QLatin1StringView S_SEQUENCE { "sequence" }; +static constexpr QLatin1StringView S_SIGNAL { "Signal" }; +static constexpr QLatin1StringView S_TYPE { "type" }; +static constexpr QLatin1StringView S_VALUE { "value" }; +static constexpr QLatin1StringView S_VALUES { "values" }; +static constexpr QLatin1StringView S_VALUE_TYPE { "valueType" }; +static constexpr QLatin1StringView S_WRITE { "write" }; +} + +// Strings that commonly occur in metatypes.json files. +namespace MetatypesDotJson { +static constexpr QLatin1StringView S_ACCESS { "access" }; +static constexpr QLatin1StringView S_ALIAS { "alias" }; +static constexpr QLatin1StringView S_ANONYMOUS { "anonymous" }; +static constexpr QLatin1StringView S_ARGUMENTS { "arguments" }; +static constexpr QLatin1StringView S_AUTO { "auto" }; +static constexpr QLatin1StringView S_BINDABLE { "bindable" }; +static constexpr QLatin1StringView S_CLASSES { "classes" }; +static constexpr QLatin1StringView S_CLASS_INFOS { "classInfos" }; +static constexpr QLatin1StringView S_CLASS_NAME { "className" }; +static constexpr QLatin1StringView S_CONSTANT { "constant" }; +static constexpr QLatin1StringView S_CONSTRUCT { "construct" }; +static constexpr QLatin1StringView S_CONSTRUCTORS { "constructors" }; +static constexpr QLatin1StringView S_DEFAULT_PROPERTY { "DefaultProperty" }; +static constexpr QLatin1StringView S_DEFERRED_PROPERTY_NAMES { "DeferredPropertyNames" }; +static constexpr QLatin1StringView S_ENUMS { "enums" }; +static constexpr QLatin1StringView S_FALSE { "false" }; +static constexpr QLatin1StringView S_FINAL { "final" }; +static constexpr QLatin1StringView S_GADGET { "gadget" }; +static constexpr QLatin1StringView S_IMMEDIATE_PROPERTY_NAMES { "ImmediatePropertyNames" }; +static constexpr QLatin1StringView S_INDEX { "index" }; +static constexpr QLatin1StringView S_INPUT_FILE { "inputFile" }; +static constexpr QLatin1StringView S_INTERFACES { "interfaces" }; +static constexpr QLatin1StringView S_IS_CLASS { "isClass" }; +static constexpr QLatin1StringView S_IS_CLONED { "isCloned" }; +static constexpr QLatin1StringView S_IS_CONSTRUCTOR { "isConstructor" }; +static constexpr QLatin1StringView S_IS_FLAG { "isFlag" }; +static constexpr QLatin1StringView S_IS_JAVASCRIPT_FUNCTION { "isJavaScriptFunction" }; +static constexpr QLatin1StringView S_LINENUMBER { "lineNumber" }; +static constexpr QLatin1StringView S_MEMBER { "member" }; +static constexpr QLatin1StringView S_METHOD { "method" }; +static constexpr QLatin1StringView S_METHODS { "methods" }; +static constexpr QLatin1StringView S_NAME { "name" }; +static constexpr QLatin1StringView S_NAMESPACE { "namespace" }; +static constexpr QLatin1StringView S_NOTIFY { "notify" }; +static constexpr QLatin1StringView S_OBJECT { "object" }; +static constexpr QLatin1StringView S_PARENT_PROPERTY { "ParentProperty" }; +static constexpr QLatin1StringView S_PRIVATE { "private" }; +static constexpr QLatin1StringView S_PRIVATE_CLASS { "privateClass" }; +static constexpr QLatin1StringView S_PROPERTIES { "properties" }; +static constexpr QLatin1StringView S_PROPERTY { "property" }; +static constexpr QLatin1StringView S_PROTECTED { "protected" }; +static constexpr QLatin1StringView S_PUBLIC { "public" }; +static constexpr QLatin1StringView S_QUALIFIED_CLASS_NAME { "qualifiedClassName" }; +static constexpr QLatin1StringView S_READ { "read" }; + +static constexpr QLatin1StringView S_REGISTER_ENUM_CLASSES_UNSCOPED { + "RegisterEnumClassesUnscoped" +}; + +static constexpr QLatin1StringView S_REQUIRED { "required" }; +static constexpr QLatin1StringView S_RESET { "reset" }; +static constexpr QLatin1StringView S_RETURN_TYPE { "returnType" }; +static constexpr QLatin1StringView S_REVISION { "revision" }; +static constexpr QLatin1StringView S_SIGNALS { "signals" }; +static constexpr QLatin1StringView S_SLOTS { "slots" }; +static constexpr QLatin1StringView S_STRUCTURED { "structured" }; +static constexpr QLatin1StringView S_SUPER_CLASSES { "superClasses" }; +static constexpr QLatin1StringView S_TRUE { "true" }; +static constexpr QLatin1StringView S_TYPE { "type" }; +static constexpr QLatin1StringView S_VALUE { "value" }; +static constexpr QLatin1StringView S_VALUES { "values" }; +static constexpr QLatin1StringView S_WRITE { "write" }; + +// QML-Related Strings that commonly occur in metatypes.json files. +namespace Qml { +static constexpr QLatin1StringView S_ADDED_IN_VERSION { "QML.AddedInVersion" }; +static constexpr QLatin1StringView S_ATTACHED { "QML.Attached" }; +static constexpr QLatin1StringView S_CREATABLE { "QML.Creatable" }; +static constexpr QLatin1StringView S_CREATION_METHOD { "QML.CreationMethod" }; +static constexpr QLatin1StringView S_ELEMENT { "QML.Element" }; +static constexpr QLatin1StringView S_EXTENDED { "QML.Extended" }; +static constexpr QLatin1StringView S_EXTENSION_IS_JAVA_SCRIPT { "QML.ExtensionIsJavaScript" }; +static constexpr QLatin1StringView S_EXTENSION_IS_NAMESPACE { "QML.ExtensionIsNamespace" }; +static constexpr QLatin1StringView S_FOREIGN { "QML.Foreign" }; +static constexpr QLatin1StringView S_FOREIGN_IS_NAMESPACE { "QML.ForeignIsNamespace" }; +static constexpr QLatin1StringView S_HAS_CUSTOM_PARSER { "QML.HasCustomParser" }; +static constexpr QLatin1StringView S_PRIMITIVE_ALIAS { "QML.PrimitiveAlias" }; +static constexpr QLatin1StringView S_REMOVED_IN_VERSION { "QML.RemovedInVersion" }; +static constexpr QLatin1StringView S_ROOT { "QML.Root" }; +static constexpr QLatin1StringView S_SEQUENCE { "QML.Sequence" }; +static constexpr QLatin1StringView S_SINGLETON { "QML.Singleton" }; +static constexpr QLatin1StringView S_UNCREATABLE_REASON { "QML.UncreatableReason" }; +static constexpr QLatin1StringView S_USING { "QML.Using" }; +} // namespace Qml + +} // namespace MetatypesJson + +} + +QT_END_NAMESPACE + +#endif // QQMLTYPEREGISTRARCONSTANTS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltyperegistrarutils_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltyperegistrarutils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7d860c98bc2aecd4224ab46546fe2a03d1f7a5e3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltyperegistrarutils_p.h @@ -0,0 +1,36 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QQMLTYPEREGISTRAR_UTILS_P_H +#define QQMLTYPEREGISTRAR_UTILS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmetatypesjsonprocessor_p.h" + +#include <QtCore/qversionnumber.h> + +QT_BEGIN_NAMESPACE + +QTypeRevision handleInMinorVersion(QTypeRevision revision, int majorVersion); +QAnyStringView interfaceName(const Interface &iface); + +QDebug warning(const MetaType &classDef); +QDebug warning(QAnyStringView fileName, int lineNumber = 0); + +QDebug error(QAnyStringView fileName, int lineNumber = 0); + +int mergeQtConfFiles(const QString &pathToList); + +QT_END_NAMESPACE + +#endif // QQMLTYPEREGISTRAR_UTILS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltypesclassdescription_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltypesclassdescription_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0537cf2f3e1a28e60d7d37b5a48126f12fc2e5d7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltypesclassdescription_p.h @@ -0,0 +1,133 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QMLTYPESCLASSDESCRIPTION_P_H +#define QMLTYPESCLASSDESCRIPTION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qmetatypesjsonprocessor_p.h> + +#include <QtCore/qstring.h> +#include <QtCore/qcbormap.h> +#include <QtCore/qvector.h> +#include <QtCore/qset.h> +#include <QtCore/qversionnumber.h> + +QT_BEGIN_NAMESPACE + +struct FoundType +{ + enum Origin { + Unknown, + OwnTypes, + ForeignTypes, + }; + + FoundType() = default; + FoundType(const MetaType &single, Origin origin); + + MetaType native; + MetaType javaScript; + + Origin nativeOrigin = Unknown; + Origin javaScriptOrigin = Unknown; + + operator bool() const { return !native.isEmpty() || !javaScript.isEmpty(); } + + MetaType select(const MetaType &category, QAnyStringView relation) const; + +}; + +struct QmlTypesClassDescription +{ + // All the string views in this class are based on string data in the JSON they are parsed from. + // You must keep the relevant QCborValues alive while the QmlTypesClassDescription exists. + + MetaType resolvedClass; + QAnyStringView file; + QAnyStringView className; + QList<QAnyStringView> primitiveAliases; + QList<QAnyStringView> elementNames; + QAnyStringView defaultProp; + QAnyStringView parentProp; + QAnyStringView superClass; + QAnyStringView attachedType; + QAnyStringView javaScriptExtensionType; + QAnyStringView nativeExtensionType; + QAnyStringView sequenceValueType; + QAnyStringView accessSemantics; + QList<QTypeRevision> revisions; + QTypeRevision addedInRevision; + QTypeRevision removedInRevision; + bool isCreatable = true; + bool isStructured = false; + bool isSingleton = false; + bool hasCustomParser = false; + bool isRootClass = false; + bool extensionIsJavaScript = false; + bool extensionIsNamespace = false; + bool enforcesScopedEnums = false; + QList<QAnyStringView> implementsInterfaces; + QList<QAnyStringView> deferredNames; + QList<QAnyStringView> immediateNames; + + enum CollectMode { + TopLevel, + SuperClass, + RelatedType + }; + + void collect( + const MetaType &classDef, const QVector<MetaType> &types, + const QVector<MetaType> &foreign, CollectMode mode, QTypeRevision defaultRevision); + FoundType collectRelated( + QAnyStringView related, const QVector<MetaType> &types, + const QVector<MetaType> &foreign, QTypeRevision defaultRevision, + const QList<QAnyStringView> &namespaces); + + static FoundType findType( + const QVector<MetaType> &types, const QVector<MetaType> &foreign, + const QAnyStringView &name, const QList<QAnyStringView> &namespaces); + + void collectLocalAnonymous( + const MetaType &classDef, const QVector<MetaType> &types, + const QVector<MetaType> &foreign, QTypeRevision defaultRevision); + + +private: + void collectSuperClasses( + const MetaType &classDef, const QVector<MetaType> &types, + const QVector<MetaType> &foreign, CollectMode mode, QTypeRevision defaultRevision); + void collectInterfaces(const MetaType &classDef); + + void handleRegisterEnumClassesUnscoped(const MetaType &classDef, QAnyStringView value); +}; + +struct ResolvedTypeAlias +{ + ResolvedTypeAlias(QAnyStringView alias, const QList<UsingDeclaration> &usingDeclarations); + + QAnyStringView type; + bool isList = false; + bool isPointer = false; + bool isConstant = false; + +private: + void handleVoid(); + void handleList(); + void handlePointer(); + void handleConst(); +}; + +QT_END_NAMESPACE +#endif // QMLTYPESCLASSDESCRIPTION_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltypescreator_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltypescreator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d28a884d8a1123094a502710ecc0ea1dece3f5a1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlTypeRegistrar/6.8.1/QtQmlTypeRegistrar/private/qqmltypescreator_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef QMLTYPESCREATOR_P_H +#define QMLTYPESCREATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qqmltypesclassdescription_p.h" +#include "qqmljsstreamwriter_p.h" + +#include <QtCore/qstring.h> +#include <QtCore/qset.h> + +QT_BEGIN_NAMESPACE + +class QmlTypesCreator +{ +public: + QmlTypesCreator() : m_qml(&m_output) {} + + bool generate(const QString &outFileName); + + void setOwnTypes(QVector<MetaType> ownTypes) { m_ownTypes = std::move(ownTypes); } + void setForeignTypes(QVector<MetaType> foreignTypes) { m_foreignTypes = std::move(foreignTypes); } + void setReferencedTypes(QList<QAnyStringView> referencedTypes) { m_referencedTypes = std::move(referencedTypes); } + void setModule(QByteArray module) { m_module = std::move(module); } + void setVersion(QTypeRevision version) { m_version = version; } + void setUsingDeclarations(QList<UsingDeclaration> usingDeclarations) { m_usingDeclarations = std::move(usingDeclarations);} + void setGeneratingJSRoot(bool jsroot) { m_generatingJSRoot = jsroot; } + +private: + void writeComponent(const QmlTypesClassDescription &collector); + void writeClassProperties(const QmlTypesClassDescription &collector); + void writeType(QAnyStringView type); + void writeProperties(const Property::Container &properties); + void writeMethods(const Method::Container &methods, QLatin1StringView type); + void writeEnums(const Enum::Container &enums); + void writeComponents(); + void writeRootMethods(const MetaType &classDef); + + QByteArray m_output; + QQmlJSStreamWriter m_qml; + QVector<MetaType> m_ownTypes; + QVector<MetaType> m_foreignTypes; + QList<QAnyStringView> m_referencedTypes; + QList<UsingDeclaration> m_usingDeclarations; + QByteArray m_module; + QTypeRevision m_version = QTypeRevision::zero(); + bool m_generatingJSRoot = false; +}; + +QT_END_NAMESPACE + +#endif // QMLTYPESCREATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlWorkerScript/6.8.1/QtQmlWorkerScript/private/qquickworkerscript_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlWorkerScript/6.8.1/QtQmlWorkerScript/private/qquickworkerscript_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bc2240ab948701d408f9506e36bad7dfd62eac17 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlWorkerScript/6.8.1/QtQmlWorkerScript/private/qquickworkerscript_p.h @@ -0,0 +1,93 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKWORKERSCRIPT_P_H +#define QQUICKWORKERSCRIPT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qqml.h> + +#include <QtQmlWorkerScript/private/qtqmlworkerscriptglobal_p.h> +#include <QtQml/qqmlparserstatus.h> +#include <QtCore/qthread.h> +#include <QtQml/qjsvalue.h> +#include <QtCore/qurl.h> + +QT_BEGIN_NAMESPACE + + +class QQuickWorkerScript; +class QQuickWorkerScriptEnginePrivate; +class QQuickWorkerScriptEngine : public QThread +{ +Q_OBJECT +public: + QQuickWorkerScriptEngine(QQmlEngine *parent = nullptr); + ~QQuickWorkerScriptEngine(); + + int registerWorkerScript(QQuickWorkerScript *); + void removeWorkerScript(int); + void executeUrl(int, const QUrl &); + void sendMessage(int, const QByteArray &); + +protected: + void run() override; + +private: + QQuickWorkerScriptEnginePrivate *d; +}; + +class Q_QMLWORKERSCRIPT_EXPORT QQuickWorkerScript : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_DISABLE_COPY_MOVE(QQuickWorkerScript) + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(bool ready READ ready NOTIFY readyChanged REVISION(2, 15)) + + QML_NAMED_ELEMENT(WorkerScript); + QML_ADDED_IN_VERSION(2, 0) + + Q_INTERFACES(QQmlParserStatus) +public: + QQuickWorkerScript(QObject *parent = nullptr); + ~QQuickWorkerScript(); + + QUrl source() const; + void setSource(const QUrl &); + + bool ready() const; + +public Q_SLOTS: + void sendMessage(QQmlV4FunctionPtr); + +Q_SIGNALS: + void sourceChanged(); + Q_REVISION(2, 15) void readyChanged(); + void message(const QJSValue &messageObject); + +protected: + void classBegin() override; + void componentComplete() override; + bool event(QEvent *) override; + +private: + QQuickWorkerScriptEngine *engine(); + QQuickWorkerScriptEngine *m_engine; + int m_scriptId; + QUrl m_source; + bool m_componentComplete; +}; + +QT_END_NAMESPACE + +#endif // QQUICKWORKERSCRIPT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlWorkerScript/6.8.1/QtQmlWorkerScript/private/qtqmlworkerscriptglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlWorkerScript/6.8.1/QtQmlWorkerScript/private/qtqmlworkerscriptglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..946e20f4b734877fb2f1f7c10e2bc77fcb2172dd --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlWorkerScript/6.8.1/QtQmlWorkerScript/private/qtqmlworkerscriptglobal_p.h @@ -0,0 +1,24 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTQMLWORKERSCRIPTGLOBAL_P_H +#define QTQMLWORKERSCRIPTGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/private/qtqmlglobal_p.h> +#include <QtQmlWorkerScript/qtqmlworkerscriptglobal.h> +#include <QtQmlWorkerScript/qtqmlworkerscriptexports.h> + +#define Q_QMLWORKERSCRIPT_AUTOTEST_EXPORT Q_AUTOTEST_EXPORT + +#endif // QTQMLWORKERSCRIPTGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlWorkerScript/6.8.1/QtQmlWorkerScript/private/qv4serialize_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlWorkerScript/6.8.1/QtQmlWorkerScript/private/qv4serialize_p.h new file mode 100644 index 0000000000000000000000000000000000000000..28c7b8a7a134a1671632599906d28df928ef4d31 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlWorkerScript/6.8.1/QtQmlWorkerScript/private/qv4serialize_p.h @@ -0,0 +1,40 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QV4SERIALIZE_P_H +#define QV4SERIALIZE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qbytearray.h> +#include <private/qv4value_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +class Serialize { +public: + + static QByteArray serialize(const Value &, ExecutionEngine *); + static ReturnedValue deserialize(const QByteArray &, ExecutionEngine *); + +private: + static void serialize(QByteArray &, const Value &, ExecutionEngine *); + static ReturnedValue deserialize(const char *&, ExecutionEngine *); +}; + +} + +QT_END_NAMESPACE + +#endif // QV8WORKER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlXmlListModel/6.8.1/QtQmlXmlListModel/private/qqmlxmllistmodel_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlXmlListModel/6.8.1/QtQmlXmlListModel/private/qqmlxmllistmodel_p.h new file mode 100644 index 0000000000000000000000000000000000000000..48fc78e28adf24fcaf9beec5e275401ac6491a99 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlXmlListModel/6.8.1/QtQmlXmlListModel/private/qqmlxmllistmodel_p.h @@ -0,0 +1,219 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQMLXMLLISTMODEL_H +#define QQMLXMLLISTMODEL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qflatmap_p.h> +#include <private/qtqmlxmllistmodelglobal_p.h> + +#include <QtQml/qqmllist.h> +#include <QtQml/qqmlparserstatus.h> + +#include <QtQmlIntegration/qqmlintegration.h> + +#include <QtCore/qabstractitemmodel.h> +#include <QtCore/qbytearray.h> +#include <QtCore/qfuture.h> +#include <QtCore/qhash.h> +#include <QtCore/qstringlist.h> +#include <QtCore/qurl.h> + +QT_BEGIN_NAMESPACE + +#if QT_CONFIG(qml_network) +class QNetworkReply; +#endif + +class QXmlStreamReader; +class QQmlContext; +struct QQmlXmlListModelQueryJob +{ + int queryId; + QByteArray data; + QString query; + QStringList roleNames; + QStringList elementNames; + QStringList elementAttributes; + QList<void *> roleQueryErrorId; +}; +struct QQmlXmlListModelQueryResult +{ + Q_GADGET + QML_ANONYMOUS +public: + int queryId; + QList<QFlatMap<int, QString>> data; + QList<QPair<void *, QString>> errors; +}; + +class Q_QMLXMLLISTMODEL_EXPORT QQmlXmlListModelRole : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString elementName READ elementName WRITE setElementName NOTIFY elementNameChanged) + Q_PROPERTY(QString attributeName READ attributeName WRITE setAttributeName NOTIFY + attributeNameChanged) + QML_NAMED_ELEMENT(XmlListModelRole) + +public: + QQmlXmlListModelRole() = default; + ~QQmlXmlListModelRole() = default; + + QString name() const; + void setName(const QString &name); + QString elementName() const; + void setElementName(const QString &name); + QString attributeName() const; + void setAttributeName(const QString &attributeName); + bool isValid() const; + +Q_SIGNALS: + void nameChanged(); + void elementNameChanged(); + void attributeNameChanged(); + +private: + QString m_name; + QString m_elementName; + QString m_attributeName; +}; + +class QQmlXmlListModelQueryExecutor; + +class Q_QMLXMLLISTMODEL_EXPORT QQmlXmlListModel : public QAbstractListModel, + public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged) + Q_PROPERTY(QQmlListProperty<QQmlXmlListModelRole> roles READ roleObjects) + Q_PROPERTY(int count READ count NOTIFY countChanged) + QML_NAMED_ELEMENT(XmlListModel) + Q_CLASSINFO("DefaultProperty", "roles") + +public: + QQmlXmlListModel(QObject *parent = nullptr); + ~QQmlXmlListModel(); + + QModelIndex index(int row, int column, const QModelIndex &parent) const override; + int rowCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role) const override; + QHash<int, QByteArray> roleNames() const override; + + int count() const; + + QUrl source() const; + void setSource(const QUrl &); + + QString query() const; + void setQuery(const QString &); + + QQmlListProperty<QQmlXmlListModelRole> roleObjects(); + + void appendRole(QQmlXmlListModelRole *); + void clearRole(); + + enum Status { Null, Ready, Loading, Error }; + Q_ENUM(Status) + Status status() const; + qreal progress() const; + + Q_INVOKABLE QString errorString() const; + + void classBegin() override; + void componentComplete() override; + +Q_SIGNALS: + void statusChanged(QQmlXmlListModel::Status); + void progressChanged(qreal progress); + void countChanged(); + void sourceChanged(); + void queryChanged(); + +public Q_SLOTS: + void reload(); + +private Q_SLOTS: +#if QT_CONFIG(qml_network) + void requestFinished(); +#endif + void requestProgress(qint64, qint64); + void dataCleared(); + void queryCompleted(const QQmlXmlListModelQueryResult &); + void queryError(void *object, const QString &error); + +private: + Q_DISABLE_COPY(QQmlXmlListModel) + + void notifyQueryStarted(bool remoteSource); + + static void appendRole(QQmlListProperty<QQmlXmlListModelRole> *, QQmlXmlListModelRole *); + static void clearRole(QQmlListProperty<QQmlXmlListModelRole> *); + + void tryExecuteQuery(const QByteArray &data); + + QQmlXmlListModelQueryJob createJob(const QByteArray &data); + int nextQueryId(); + +#if QT_CONFIG(qml_network) + void deleteReply(); + + QNetworkReply *m_reply = nullptr; +#endif + + int m_size = 0; + QUrl m_source; + QString m_query; + QStringList m_roleNames; + QList<int> m_roles; + QList<QQmlXmlListModelRole *> m_roleObjects; + QList<QFlatMap<int, QString>> m_data; + bool m_isComponentComplete = true; + Status m_status = QQmlXmlListModel::Null; + QString m_errorString; + qreal m_progress = 0; + int m_queryId = -1; + int m_nextQueryIdGenerator = -1; + int m_highestRole = Qt::UserRole; + using ResultFutureWatcher = QFutureWatcher<QQmlXmlListModelQueryResult>; + QFlatMap<int, ResultFutureWatcher *> m_watchers; +}; + +class QQmlXmlListModelQueryRunnable : public QRunnable +{ +public: + explicit QQmlXmlListModelQueryRunnable(QQmlXmlListModelQueryJob &&job); + void run() override; + + QFuture<QQmlXmlListModelQueryResult> future() const; + +private: + void doQueryJob(QQmlXmlListModelQueryResult *currentResult); + void processElement(QQmlXmlListModelQueryResult *currentResult, const QString &element, + QXmlStreamReader &reader); + void readSubTree(const QString &prefix, QXmlStreamReader &reader, + QFlatMap<int, QString> &results, QList<QPair<void *, QString>> *errors); + + QQmlXmlListModelQueryJob m_job; + QPromise<QQmlXmlListModelQueryResult> m_promise; +}; + +QT_END_NAMESPACE + +#endif // QQMLXMLLISTMODEL_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQmlXmlListModel/6.8.1/QtQmlXmlListModel/private/qtqmlxmllistmodelglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQmlXmlListModel/6.8.1/QtQmlXmlListModel/private/qtqmlxmllistmodelglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c759d8f2cca8173619c66be58e17623a45cbcdf1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQmlXmlListModel/6.8.1/QtQmlXmlListModel/private/qtqmlxmllistmodelglobal_p.h @@ -0,0 +1,21 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTQMLXMLLISTMODELGLOBAL_P_H +#define QTQMLXMLLISTMODELGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qglobal.h> +#include <QtQmlXmlListModel/qtqmlxmllistmodelexports.h> + +#endif // QTQMLXMLLISTMODELGLOBAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquicktreeview_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquicktreeview_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ddb8b03858edc1c966fee70f1e32e085850595a1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquicktreeview_p.h @@ -0,0 +1,74 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKTREEVIEW_P_H +#define QQUICKTREEVIEW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qabstractitemmodel.h> +#include "qquicktableview_p.h" + +QT_BEGIN_NAMESPACE + +class QQuickTreeViewPrivate; + +class Q_QUICK_EXPORT QQuickTreeView : public QQuickTableView +{ + Q_OBJECT + Q_PROPERTY(QModelIndex rootIndex READ rootIndex WRITE setRootIndex RESET resetRootIndex NOTIFY rootIndexChanged REVISION(6, 6) FINAL) + QML_NAMED_ELEMENT(TreeView) + QML_ADDED_IN_VERSION(6, 3) + +public: + QQuickTreeView(QQuickItem *parent = nullptr); + ~QQuickTreeView() override; + + QModelIndex rootIndex() const; + void setRootIndex(const QModelIndex &index); + void resetRootIndex(); + + Q_INVOKABLE int depth(int row) const; + + Q_INVOKABLE bool isExpanded(int row) const; + Q_INVOKABLE void expand(int row); + Q_INVOKABLE void collapse(int row); + Q_INVOKABLE void toggleExpanded(int row); + + Q_REVISION(6, 4) Q_INVOKABLE void expandRecursively(int row = -1, int depth = -1); + Q_REVISION(6, 4) Q_INVOKABLE void collapseRecursively(int row = -1); + Q_REVISION(6, 4) Q_INVOKABLE void expandToIndex(const QModelIndex &index); + + Q_INVOKABLE QModelIndex modelIndex(const QPoint &cell) const override; + Q_INVOKABLE QPoint cellAtIndex(const QModelIndex &index) const override; + +#if QT_DEPRECATED_SINCE(6, 4) + QT_DEPRECATED_VERSION_X_6_4("Use index(row, column) instead") + Q_REVISION(6, 4) Q_INVOKABLE QModelIndex modelIndex(int row, int column) const override; +#endif + +Q_SIGNALS: + void expanded(int row, int depth); + void collapsed(int row, bool recursively); + Q_REVISION(6, 6) void rootIndexChanged(); + +protected: + void keyPressEvent(QKeyEvent *event) override; + +private: + Q_DISABLE_COPY(QQuickTreeView) + Q_DECLARE_PRIVATE(QQuickTreeView) +}; + +QT_END_NAMESPACE + +#endif // QQUICKTREEVIEW_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquicktreeview_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquicktreeview_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..eec1ffbd1175ffcff543213c20504732acbead69 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquicktreeview_p_p.h @@ -0,0 +1,54 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKTREEVIEW_P_P_H +#define QQUICKTREEVIEW_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquicktreeview_p.h" +#include "qquicktableview_p_p.h" + +#include <QtQmlModels/private/qqmltreemodeltotablemodel_p_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QQuickTreeViewPrivate : public QQuickTableViewPrivate +{ +public: + Q_DECLARE_PUBLIC(QQuickTreeView) + + QQuickTreeViewPrivate(); + ~QQuickTreeViewPrivate() override; + + static inline QQuickTreeViewPrivate *get(QQuickTreeView *q) { return q->d_func(); } + + QVariant modelImpl() const override; + void setModelImpl(const QVariant &newModel) override; + + void initItemCallback(int serializedModelIndex, QObject *object) override; + void itemReusedCallback(int serializedModelIndex, QObject *object) override; + void dataChangedCallback(const QModelIndex &topLeft, + const QModelIndex &bottomRight, + const QVector<int> &roles); + + void updateRequiredProperties(int serializedModelIndex, QObject *object, bool init); + void updateSelection(const QRect &oldSelection, const QRect &newSelection) override; + +public: + QQmlTreeModelToTableModel m_treeModelToTableModel; + QVariant m_assignedModel; +}; + +QT_END_NAMESPACE + +#endif // QQUICKTREEVIEW_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickvalidator_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickvalidator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7d4accef05080a307be0cecda857331f77294240 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickvalidator_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKVALIDATOR_P_H +#define QQUICKVALIDATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> + +#include <QtQml/qqml.h> + +#include <QtGui/qvalidator.h> + +QT_BEGIN_NAMESPACE + +#if QT_CONFIG(validator) +class Q_QUICK_EXPORT QQuickIntValidator : public QIntValidator +{ + Q_OBJECT + Q_PROPERTY(QString locale READ localeName WRITE setLocaleName RESET resetLocaleName NOTIFY localeNameChanged) + QML_NAMED_ELEMENT(IntValidator) + QML_ADDED_IN_VERSION(2, 0) +public: + QQuickIntValidator(QObject *parent = nullptr); + + QString localeName() const; + void setLocaleName(const QString &name); + void resetLocaleName(); + +Q_SIGNALS: + void localeNameChanged(); +}; + +class Q_QUICK_EXPORT QQuickDoubleValidator : public QDoubleValidator +{ + Q_OBJECT + Q_PROPERTY(QString locale READ localeName WRITE setLocaleName RESET resetLocaleName NOTIFY localeNameChanged) + QML_NAMED_ELEMENT(DoubleValidator) + QML_ADDED_IN_VERSION(2, 0) +public: + QQuickDoubleValidator(QObject *parent = nullptr); + + QString localeName() const; + void setLocaleName(const QString &name); + void resetLocaleName(); + +Q_SIGNALS: + void localeNameChanged(); +}; +#endif + +QT_END_NAMESPACE + +#endif // QQUICKVALIDATOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickvaluetypes_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickvaluetypes_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2d51e93fbc8838a0ba4d798ead2201b286fe3766 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickvaluetypes_p.h @@ -0,0 +1,587 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKVALUETYPES_P_H +#define QQUICKVALUETYPES_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qqml.h> +#include <private/qtquickglobal_p.h> +#include <private/qqmlvaluetype_p.h> + +#include <QtGui/QColor> +#include <QtGui/QColorSpace> +#include <QtGui/QVector2D> +#include <QtGui/QVector3D> +#include <QtGui/QVector4D> +#include <QtGui/QQuaternion> +#include <QtGui/QMatrix4x4> +#include <QtGui/QFont> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QQuickColorValueType +{ + QColor v; + Q_PROPERTY(qreal r READ r WRITE setR FINAL) + Q_PROPERTY(qreal g READ g WRITE setG FINAL) + Q_PROPERTY(qreal b READ b WRITE setB FINAL) + Q_PROPERTY(qreal a READ a WRITE setA FINAL) + Q_PROPERTY(qreal hsvHue READ hsvHue WRITE setHsvHue FINAL) + Q_PROPERTY(qreal hsvSaturation READ hsvSaturation WRITE setHsvSaturation FINAL) + Q_PROPERTY(qreal hsvValue READ hsvValue WRITE setHsvValue FINAL) + Q_PROPERTY(qreal hslHue READ hslHue WRITE setHslHue FINAL) + Q_PROPERTY(qreal hslSaturation READ hslSaturation WRITE setHslSaturation FINAL) + Q_PROPERTY(qreal hslLightness READ hslLightness WRITE setHslLightness FINAL) + Q_PROPERTY(bool valid READ isValid FINAL) + Q_GADGET + QML_ADDED_IN_VERSION(2, 0) + QML_FOREIGN(QColor) + QML_VALUE_TYPE(color) + QML_EXTENDED(QQuickColorValueType) + QML_STRUCTURED_VALUE + +public: + static QVariant create(const QJSValue ¶ms); + + Q_INVOKABLE QQuickColorValueType() = default; + Q_INVOKABLE QQuickColorValueType(const QString &string); + Q_INVOKABLE QString toString() const; + + Q_INVOKABLE QVariant alpha(qreal value) const; + Q_INVOKABLE QVariant lighter(qreal factor = 1.5) const; + Q_INVOKABLE QVariant darker(qreal factor = 2.0) const; + Q_INVOKABLE QVariant tint(QVariant factor) const; + + qreal r() const; + qreal g() const; + qreal b() const; + qreal a() const; + qreal hsvHue() const; + qreal hsvSaturation() const; + qreal hsvValue() const; + qreal hslHue() const; + qreal hslSaturation() const; + qreal hslLightness() const; + bool isValid() const; + void setR(qreal); + void setG(qreal); + void setB(qreal); + void setA(qreal); + void setHsvHue(qreal); + void setHsvSaturation(qreal); + void setHsvValue(qreal); + void setHslHue(qreal); + void setHslSaturation(qreal); + void setHslLightness(qreal); + + operator QColor() const { return v; } +}; + +class Q_QUICK_EXPORT QQuickVector2DValueType +{ + QVector2D v; + Q_PROPERTY(qreal x READ x WRITE setX FINAL) + Q_PROPERTY(qreal y READ y WRITE setY FINAL) + Q_GADGET + QML_ADDED_IN_VERSION(2, 0) + QML_FOREIGN(QVector2D) + QML_VALUE_TYPE(vector2d) + QML_EXTENDED(QQuickVector2DValueType) + QML_STRUCTURED_VALUE + +public: + static QVariant create(const QJSValue ¶ms); + + Q_INVOKABLE QQuickVector2DValueType() = default; + Q_INVOKABLE QString toString() const; + + qreal x() const; + qreal y() const; + void setX(qreal); + void setY(qreal); + + Q_INVOKABLE qreal dotProduct(const QVector2D &vec) const; + Q_INVOKABLE QVector2D times(const QVector2D &vec) const; + Q_INVOKABLE QVector2D times(qreal scalar) const; + Q_INVOKABLE QVector2D plus(const QVector2D &vec) const; + Q_INVOKABLE QVector2D minus(const QVector2D &vec) const; + Q_INVOKABLE QVector2D normalized() const; + Q_INVOKABLE qreal length() const; + Q_INVOKABLE QVector3D toVector3d() const; + Q_INVOKABLE QVector4D toVector4d() const; + Q_INVOKABLE bool fuzzyEquals(const QVector2D &vec, qreal epsilon) const; + Q_INVOKABLE bool fuzzyEquals(const QVector2D &vec) const; + + operator QVector2D() const { return v; } +}; + +class Q_QUICK_EXPORT QQuickVector3DValueType +{ + QVector3D v; + Q_PROPERTY(qreal x READ x WRITE setX FINAL) + Q_PROPERTY(qreal y READ y WRITE setY FINAL) + Q_PROPERTY(qreal z READ z WRITE setZ FINAL) + Q_GADGET + QML_ADDED_IN_VERSION(2, 0) + QML_FOREIGN(QVector3D) + QML_VALUE_TYPE(vector3d) + QML_EXTENDED(QQuickVector3DValueType) + QML_STRUCTURED_VALUE + +public: + static QVariant create(const QJSValue ¶ms); + + Q_INVOKABLE QQuickVector3DValueType() = default; + Q_INVOKABLE QString toString() const; + + qreal x() const; + qreal y() const; + qreal z() const; + void setX(qreal); + void setY(qreal); + void setZ(qreal); + + Q_INVOKABLE QVector3D crossProduct(const QVector3D &vec) const; + Q_INVOKABLE qreal dotProduct(const QVector3D &vec) const; + Q_INVOKABLE QVector3D times(const QMatrix4x4 &m) const; + Q_INVOKABLE QVector3D times(const QVector3D &vec) const; + Q_INVOKABLE QVector3D times(qreal scalar) const; + Q_INVOKABLE QVector3D plus(const QVector3D &vec) const; + Q_INVOKABLE QVector3D minus(const QVector3D &vec) const; + Q_INVOKABLE QVector3D normalized() const; + Q_INVOKABLE qreal length() const; + Q_INVOKABLE QVector2D toVector2d() const; + Q_INVOKABLE QVector4D toVector4d() const; + Q_INVOKABLE bool fuzzyEquals(const QVector3D &vec, qreal epsilon) const; + Q_INVOKABLE bool fuzzyEquals(const QVector3D &vec) const; + + operator QVector3D() const { return v; } +}; + +class Q_QUICK_EXPORT QQuickVector4DValueType +{ + QVector4D v; + Q_PROPERTY(qreal x READ x WRITE setX FINAL) + Q_PROPERTY(qreal y READ y WRITE setY FINAL) + Q_PROPERTY(qreal z READ z WRITE setZ FINAL) + Q_PROPERTY(qreal w READ w WRITE setW FINAL) + Q_GADGET + QML_ADDED_IN_VERSION(2, 0) + QML_FOREIGN(QVector4D) + QML_VALUE_TYPE(vector4d) + QML_EXTENDED(QQuickVector4DValueType) + QML_STRUCTURED_VALUE + +public: + static QVariant create(const QJSValue ¶ms); + + Q_INVOKABLE QQuickVector4DValueType() = default; + Q_INVOKABLE QString toString() const; + + qreal x() const; + qreal y() const; + qreal z() const; + qreal w() const; + void setX(qreal); + void setY(qreal); + void setZ(qreal); + void setW(qreal); + + Q_INVOKABLE qreal dotProduct(const QVector4D &vec) const; + Q_INVOKABLE QVector4D times(const QVector4D &vec) const; + Q_INVOKABLE QVector4D times(const QMatrix4x4 &m) const; + Q_INVOKABLE QVector4D times(qreal scalar) const; + Q_INVOKABLE QVector4D plus(const QVector4D &vec) const; + Q_INVOKABLE QVector4D minus(const QVector4D &vec) const; + Q_INVOKABLE QVector4D normalized() const; + Q_INVOKABLE qreal length() const; + Q_INVOKABLE QVector2D toVector2d() const; + Q_INVOKABLE QVector3D toVector3d() const; + Q_INVOKABLE bool fuzzyEquals(const QVector4D &vec, qreal epsilon) const; + Q_INVOKABLE bool fuzzyEquals(const QVector4D &vec) const; + + operator QVector4D() const { return v; } +}; + +class Q_QUICK_EXPORT QQuickQuaternionValueType +{ + QQuaternion v; + Q_PROPERTY(qreal scalar READ scalar WRITE setScalar FINAL) + Q_PROPERTY(qreal x READ x WRITE setX FINAL) + Q_PROPERTY(qreal y READ y WRITE setY FINAL) + Q_PROPERTY(qreal z READ z WRITE setZ FINAL) + Q_GADGET + QML_ADDED_IN_VERSION(2, 0) + QML_FOREIGN(QQuaternion) + QML_VALUE_TYPE(quaternion) + QML_EXTENDED(QQuickQuaternionValueType) + QML_STRUCTURED_VALUE + +public: + static QVariant create(const QJSValue ¶ms); + + Q_INVOKABLE QQuickQuaternionValueType() = default; + Q_INVOKABLE QString toString() const; + + qreal scalar() const; + qreal x() const; + qreal y() const; + qreal z() const; + void setScalar(qreal); + void setX(qreal); + void setY(qreal); + void setZ(qreal); + + Q_INVOKABLE qreal dotProduct(const QQuaternion &q) const; + Q_INVOKABLE QQuaternion times(const QQuaternion &q) const; + Q_INVOKABLE QVector3D times(const QVector3D &vec) const; + Q_INVOKABLE QQuaternion times(qreal factor) const; + Q_INVOKABLE QQuaternion plus(const QQuaternion &q) const; + Q_INVOKABLE QQuaternion minus(const QQuaternion &q) const; + + Q_INVOKABLE QQuaternion normalized() const; + Q_INVOKABLE QQuaternion inverted() const; + Q_INVOKABLE QQuaternion conjugated() const; + Q_INVOKABLE qreal length() const; + + Q_INVOKABLE QVector3D toEulerAngles() const; + Q_INVOKABLE QVector4D toVector4d() const; + + Q_INVOKABLE bool fuzzyEquals(const QQuaternion &q, qreal epsilon) const; + Q_INVOKABLE bool fuzzyEquals(const QQuaternion &q) const; + + operator QQuaternion() const { return v; } +}; + +class Q_QUICK_EXPORT QQuickMatrix4x4ValueType +{ + QMatrix4x4 v; + Q_PROPERTY(qreal m11 READ m11 WRITE setM11 FINAL) + Q_PROPERTY(qreal m12 READ m12 WRITE setM12 FINAL) + Q_PROPERTY(qreal m13 READ m13 WRITE setM13 FINAL) + Q_PROPERTY(qreal m14 READ m14 WRITE setM14 FINAL) + Q_PROPERTY(qreal m21 READ m21 WRITE setM21 FINAL) + Q_PROPERTY(qreal m22 READ m22 WRITE setM22 FINAL) + Q_PROPERTY(qreal m23 READ m23 WRITE setM23 FINAL) + Q_PROPERTY(qreal m24 READ m24 WRITE setM24 FINAL) + Q_PROPERTY(qreal m31 READ m31 WRITE setM31 FINAL) + Q_PROPERTY(qreal m32 READ m32 WRITE setM32 FINAL) + Q_PROPERTY(qreal m33 READ m33 WRITE setM33 FINAL) + Q_PROPERTY(qreal m34 READ m34 WRITE setM34 FINAL) + Q_PROPERTY(qreal m41 READ m41 WRITE setM41 FINAL) + Q_PROPERTY(qreal m42 READ m42 WRITE setM42 FINAL) + Q_PROPERTY(qreal m43 READ m43 WRITE setM43 FINAL) + Q_PROPERTY(qreal m44 READ m44 WRITE setM44 FINAL) + Q_GADGET + QML_ADDED_IN_VERSION(2, 0) + QML_FOREIGN(QMatrix4x4) + QML_VALUE_TYPE(matrix4x4) + QML_EXTENDED(QQuickMatrix4x4ValueType) + QML_STRUCTURED_VALUE + +public: + static QVariant create(const QJSValue ¶ms); + + Q_INVOKABLE QQuickMatrix4x4ValueType() = default; + + qreal m11() const { return v(0, 0); } + qreal m12() const { return v(0, 1); } + qreal m13() const { return v(0, 2); } + qreal m14() const { return v(0, 3); } + qreal m21() const { return v(1, 0); } + qreal m22() const { return v(1, 1); } + qreal m23() const { return v(1, 2); } + qreal m24() const { return v(1, 3); } + qreal m31() const { return v(2, 0); } + qreal m32() const { return v(2, 1); } + qreal m33() const { return v(2, 2); } + qreal m34() const { return v(2, 3); } + qreal m41() const { return v(3, 0); } + qreal m42() const { return v(3, 1); } + qreal m43() const { return v(3, 2); } + qreal m44() const { return v(3, 3); } + + void setM11(qreal value) { v(0, 0) = value; } + void setM12(qreal value) { v(0, 1) = value; } + void setM13(qreal value) { v(0, 2) = value; } + void setM14(qreal value) { v(0, 3) = value; } + void setM21(qreal value) { v(1, 0) = value; } + void setM22(qreal value) { v(1, 1) = value; } + void setM23(qreal value) { v(1, 2) = value; } + void setM24(qreal value) { v(1, 3) = value; } + void setM31(qreal value) { v(2, 0) = value; } + void setM32(qreal value) { v(2, 1) = value; } + void setM33(qreal value) { v(2, 2) = value; } + void setM34(qreal value) { v(2, 3) = value; } + void setM41(qreal value) { v(3, 0) = value; } + void setM42(qreal value) { v(3, 1) = value; } + void setM43(qreal value) { v(3, 2) = value; } + void setM44(qreal value) { v(3, 3) = value; } + + Q_INVOKABLE void translate(const QVector3D &t) { v.translate(t); } + Q_INVOKABLE void rotate(float angle, const QVector3D &axis) { v.rotate(angle, axis); } + Q_INVOKABLE void rotate(const QQuaternion &q) { v.rotate(q); } + Q_INVOKABLE void scale(float s) { v.scale(s); } + Q_INVOKABLE void scale(float sx, float sy, float sz) { v.scale(sx, sy, sz); } + Q_INVOKABLE void scale(const QVector3D &s) { v.scale(s); } + Q_INVOKABLE void lookAt(const QVector3D &eye, const QVector3D ¢er, const QVector3D &up) { v.lookAt(eye, center, up); } + + Q_INVOKABLE QMatrix4x4 times(const QMatrix4x4 &m) const; + Q_INVOKABLE QVector4D times(const QVector4D &vec) const; + Q_INVOKABLE QVector3D times(const QVector3D &vec) const; + Q_INVOKABLE QMatrix4x4 times(qreal factor) const; + Q_INVOKABLE QMatrix4x4 plus(const QMatrix4x4 &m) const; + Q_INVOKABLE QMatrix4x4 minus(const QMatrix4x4 &m) const; + + Q_INVOKABLE QVector4D row(int n) const; + Q_INVOKABLE QVector4D column(int m) const; + + Q_INVOKABLE qreal determinant() const; + Q_INVOKABLE QMatrix4x4 inverted() const; + Q_INVOKABLE QMatrix4x4 transposed() const; + + Q_INVOKABLE QPointF map(const QPointF p) const; + Q_INVOKABLE QRectF mapRect(const QRectF r) const; + + Q_INVOKABLE bool fuzzyEquals(const QMatrix4x4 &m, qreal epsilon) const; + Q_INVOKABLE bool fuzzyEquals(const QMatrix4x4 &m) const; + + operator QMatrix4x4() const { return v; } +}; + +class Q_QUICK_EXPORT QQuickPlanarTransform : public QObject +{ + Q_OBJECT + QML_SINGLETON + QML_NAMED_ELEMENT(PlanarTransform) + QML_ADDED_IN_VERSION(6, 8) + +public: + explicit QQuickPlanarTransform(QObject *parent = nullptr); + + Q_INVOKABLE static QMatrix4x4 identity(); + Q_INVOKABLE static QMatrix4x4 fromAffineMatrix(float scaleX, float shearY, + float shearX, float scaleY, + float translateX, float translateY); + Q_INVOKABLE static QMatrix4x4 fromTranslate(float translateX, float translateY); + Q_INVOKABLE static QMatrix4x4 fromScale(float scaleX, float scaleY, + float originX = 0, float originY = 0); + Q_INVOKABLE static QMatrix4x4 fromRotate(float angle,float originX = 0, float originY = 0); + Q_INVOKABLE static QMatrix4x4 fromShear(float shearX, float shearY, + float originX = 0, float originY = 0); +}; + +namespace QQuickFontEnums +{ +Q_NAMESPACE_EXPORT(Q_QUICK_EXPORT) + +QML_NAMED_ELEMENT(Font) +QML_ADDED_IN_VERSION(2, 0) + +enum FontWeight { Thin = QFont::Thin, + ExtraLight = QFont::ExtraLight, + Light = QFont::Light, + Normal = QFont::Normal, + Medium = QFont::Medium, + DemiBold = QFont::DemiBold, + Bold = QFont::Bold, + ExtraBold = QFont::ExtraBold, + Black = QFont::Black }; +Q_ENUM_NS(FontWeight) +enum Capitalization { MixedCase = QFont::MixedCase, + AllUppercase = QFont::AllUppercase, + AllLowercase = QFont::AllLowercase, + SmallCaps = QFont::SmallCaps, + Capitalize = QFont::Capitalize }; +Q_ENUM_NS(Capitalization) + +enum HintingPreference { + PreferDefaultHinting = QFont::PreferDefaultHinting, + PreferNoHinting = QFont::PreferNoHinting, + PreferVerticalHinting = QFont::PreferVerticalHinting, + PreferFullHinting = QFont::PreferFullHinting +}; +Q_ENUM_NS(HintingPreference) +}; + +class Q_QUICK_EXPORT QQuickFontValueType +{ + QFont v; + Q_GADGET + + Q_PROPERTY(QString family READ family WRITE setFamily FINAL) + Q_PROPERTY(QString styleName READ styleName WRITE setStyleName FINAL) + Q_PROPERTY(bool bold READ bold WRITE setBold FINAL) + Q_PROPERTY(int weight READ weight WRITE setWeight FINAL) + Q_PROPERTY(bool italic READ italic WRITE setItalic FINAL) + Q_PROPERTY(bool underline READ underline WRITE setUnderline FINAL) + Q_PROPERTY(bool overline READ overline WRITE setOverline FINAL) + Q_PROPERTY(bool strikeout READ strikeout WRITE setStrikeout FINAL) + Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize FINAL) + Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize FINAL) + Q_PROPERTY(QQuickFontEnums::Capitalization capitalization READ capitalization WRITE setCapitalization FINAL) + Q_PROPERTY(qreal letterSpacing READ letterSpacing WRITE setLetterSpacing FINAL) + Q_PROPERTY(qreal wordSpacing READ wordSpacing WRITE setWordSpacing FINAL) + Q_PROPERTY(QQuickFontEnums::HintingPreference hintingPreference READ hintingPreference WRITE setHintingPreference FINAL) + Q_PROPERTY(bool kerning READ kerning WRITE setKerning FINAL) + Q_PROPERTY(bool preferShaping READ preferShaping WRITE setPreferShaping FINAL) + Q_PROPERTY(QVariantMap features READ features WRITE setFeatures FINAL) + Q_PROPERTY(QVariantMap variableAxes READ variableAxes WRITE setVariableAxes FINAL) + Q_PROPERTY(bool contextFontMerging READ contextFontMerging WRITE setContextFontMerging FINAL) + Q_PROPERTY(bool preferTypoLineMetrics READ preferTypoLineMetrics WRITE setPreferTypoLineMetrics FINAL) + + QML_VALUE_TYPE(font) + QML_FOREIGN(QFont) + QML_ADDED_IN_VERSION(2, 0) + QML_EXTENDED(QQuickFontValueType) + QML_STRUCTURED_VALUE + +public: + static QVariant create(const QJSValue &value); + + Q_INVOKABLE QQuickFontValueType() = default; + Q_INVOKABLE QString toString() const; + + QString family() const; + void setFamily(const QString &); + + QString styleName() const; + void setStyleName(const QString &); + + bool bold() const; + void setBold(bool b); + + int weight() const; + void setWeight(int); + + bool italic() const; + void setItalic(bool b); + + bool underline() const; + void setUnderline(bool b); + + bool overline() const; + void setOverline(bool b); + + bool strikeout() const; + void setStrikeout(bool b); + + qreal pointSize() const; + void setPointSize(qreal size); + + int pixelSize() const; + void setPixelSize(int size); + + QQuickFontEnums::Capitalization capitalization() const; + void setCapitalization(QQuickFontEnums::Capitalization); + + qreal letterSpacing() const; + void setLetterSpacing(qreal spacing); + + qreal wordSpacing() const; + void setWordSpacing(qreal spacing); + + QQuickFontEnums::HintingPreference hintingPreference() const; + void setHintingPreference(QQuickFontEnums::HintingPreference); + + bool kerning() const; + void setKerning(bool b); + + bool preferShaping() const; + void setPreferShaping(bool b); + + QVariantMap features() const; + void setFeatures(const QVariantMap &features); + + QVariantMap variableAxes() const; + void setVariableAxes(const QVariantMap &variableAxes); + + bool contextFontMerging() const; + void setContextFontMerging(bool b); + + bool preferTypoLineMetrics() const; + void setPreferTypoLineMetrics(bool b); + + operator QFont() const { return v; } +}; + +namespace QQuickColorSpaceEnums +{ +Q_NAMESPACE_EXPORT(Q_QUICK_EXPORT) +QML_NAMED_ELEMENT(ColorSpace) +QML_ADDED_IN_VERSION(2, 15) +Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") + +enum NamedColorSpace { + Unknown = 0, + SRgb, + SRgbLinear, + AdobeRgb, + DisplayP3, + ProPhotoRgb +}; +Q_ENUM_NS(NamedColorSpace) + +enum class Primaries { + Custom = 0, + SRgb, + AdobeRgb, + DciP3D65, + ProPhotoRgb +}; +Q_ENUM_NS(Primaries) +enum class TransferFunction { + Custom = 0, + Linear, + Gamma, + SRgb, + ProPhotoRgb +}; +Q_ENUM_NS(TransferFunction) +} + +class Q_QUICK_EXPORT QQuickColorSpaceValueType +{ + QColorSpace v; + Q_GADGET + + Q_PROPERTY(QQuickColorSpaceEnums::NamedColorSpace namedColorSpace READ namedColorSpace WRITE setNamedColorSpace FINAL) + Q_PROPERTY(QQuickColorSpaceEnums::Primaries primaries READ primaries WRITE setPrimaries FINAL) + Q_PROPERTY(QQuickColorSpaceEnums::TransferFunction transferFunction READ transferFunction WRITE setTransferFunction FINAL) + Q_PROPERTY(float gamma READ gamma WRITE setGamma FINAL) + + QML_ANONYMOUS + QML_FOREIGN(QColorSpace) + QML_ADDED_IN_VERSION(2, 15) + QML_EXTENDED(QQuickColorSpaceValueType) + QML_STRUCTURED_VALUE + +public: + static QVariant create(const QJSValue ¶ms); + + QQuickColorSpaceEnums::NamedColorSpace namedColorSpace() const noexcept; + void setNamedColorSpace(QQuickColorSpaceEnums::NamedColorSpace namedColorSpace); + QQuickColorSpaceEnums::Primaries primaries() const noexcept; + void setPrimaries(QQuickColorSpaceEnums::Primaries primariesId); + QQuickColorSpaceEnums::TransferFunction transferFunction() const noexcept; + void setTransferFunction(QQuickColorSpaceEnums::TransferFunction transferFunction); + float gamma() const noexcept; + void setGamma(float gamma); + + operator QColorSpace() const { return v; } +}; + +QT_END_NAMESPACE + +#endif // QQUICKVALUETYPES_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickview_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickview_p.h new file mode 100644 index 0000000000000000000000000000000000000000..db127c6e6ca6d2a2e76d5f72abbb7ab43d5126dc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickview_p.h @@ -0,0 +1,79 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKVIEW_P_H +#define QQUICKVIEW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquickview.h" + +#include <QtCore/qurl.h> +#include <QtCore/qelapsedtimer.h> +#include <QtCore/qtimer.h> +#include <QtCore/qpointer.h> +#include <QtCore/QWeakPointer> + +#include <QtQml/qqmlengine.h> +#include "qquickwindow_p.h" + +#include "qquickitemchangelistener_p.h" + +QT_BEGIN_NAMESPACE + +class QQmlContext; +class QQmlError; +class QQuickItem; +class QQmlComponent; + +class Q_QUICK_EXPORT QQuickViewPrivate : public QQuickWindowPrivate, + public QQuickItemChangeListener +{ + Q_DECLARE_PUBLIC(QQuickView) +public: + static QQuickViewPrivate* get(QQuickView *view) { return view->d_func(); } + static const QQuickViewPrivate* get(const QQuickView *view) { return view->d_func(); } + + QQuickViewPrivate(); + ~QQuickViewPrivate(); + + enum ExecuteState { Continue, Stop }; + ExecuteState executeHelper(); + void execute(); + void execute(QAnyStringView uri, QAnyStringView typeName); + void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override; + void initResize(); + void updateSize(); + bool setRootObject(QObject *); + + void init(QQmlEngine* e = nullptr); + + QSize rootObjectSize() const; + + QPointer<QQuickItem> root; + + QUrl source; + + QPointer<QQmlEngine> engine; + QQmlComponent *component; + QBasicTimer resizetimer; + + QQuickView::ResizeMode resizeMode; + QSize initialSize; + QElapsedTimer frameTimer; + + QVariantMap initialProperties; +}; + +QT_END_NAMESPACE + +#endif // QQUICKVIEW_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwheelhandler_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwheelhandler_p.h new file mode 100644 index 0000000000000000000000000000000000000000..248f0fa9d83e1c074b6d5d1de5f31ea8eb57ef91 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwheelhandler_p.h @@ -0,0 +1,99 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKWHEELHANDLER_H +#define QQUICKWHEELHANDLER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qevent.h> +#include <QtQuick/qquickitem.h> + +#include "qquicksinglepointhandler_p.h" + +QT_BEGIN_NAMESPACE + +class QQuickWheelEvent; +class QQuickWheelHandlerPrivate; + +class Q_QUICK_EXPORT QQuickWheelHandler : public QQuickSinglePointHandler +{ + Q_OBJECT + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) + Q_PROPERTY(bool invertible READ isInvertible WRITE setInvertible NOTIFY invertibleChanged) + Q_PROPERTY(qreal activeTimeout READ activeTimeout WRITE setActiveTimeout NOTIFY activeTimeoutChanged) + Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) + Q_PROPERTY(qreal rotationScale READ rotationScale WRITE setRotationScale NOTIFY rotationScaleChanged) + Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) + Q_PROPERTY(qreal targetScaleMultiplier READ targetScaleMultiplier WRITE setTargetScaleMultiplier NOTIFY targetScaleMultiplierChanged) + Q_PROPERTY(bool targetTransformAroundCursor READ isTargetTransformAroundCursor WRITE setTargetTransformAroundCursor NOTIFY targetTransformAroundCursorChanged) + Q_PROPERTY(bool blocking READ isBlocking WRITE setBlocking NOTIFY blockingChanged REVISION(6, 3)) + + QML_NAMED_ELEMENT(WheelHandler) + QML_ADDED_IN_VERSION(2, 14) + +public: + explicit QQuickWheelHandler(QQuickItem *parent = nullptr); + + Qt::Orientation orientation() const; + void setOrientation(Qt::Orientation orientation); + + bool isInvertible() const; + void setInvertible(bool invertible); + + qreal activeTimeout() const; + void setActiveTimeout(qreal timeout); + + qreal rotation() const; + void setRotation(qreal rotation); + + qreal rotationScale() const; + void setRotationScale(qreal rotationScale); + + QString property() const; + void setProperty(const QString &name); + + qreal targetScaleMultiplier() const; + void setTargetScaleMultiplier(qreal targetScaleMultiplier); + + bool isTargetTransformAroundCursor() const; + void setTargetTransformAroundCursor(bool ttac); + + bool isBlocking() const; + void setBlocking(bool blocking); + +Q_SIGNALS: + void wheel(QQuickWheelEvent *event); + + void orientationChanged(); + void invertibleChanged(); + void activeTimeoutChanged(); + void rotationChanged(); + void rotationScaleChanged(); + void propertyChanged(); + void targetScaleMultiplierChanged(); + void targetTransformAroundCursorChanged(); + Q_REVISION(6, 3) void blockingChanged(); + +protected: + bool wantsPointerEvent(QPointerEvent *event) override; + void handleEventPoint(QPointerEvent *event, QEventPoint &point) override; + void onTargetChanged(QQuickItem *oldTarget) override; + void onActiveChanged() override; + void timerEvent(QTimerEvent *event) override; + + Q_DECLARE_PRIVATE(QQuickWheelHandler) +}; + +QT_END_NAMESPACE + +#endif // QQUICKWHEELHANDLER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwheelhandler_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwheelhandler_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..944f970ebbf7587131fabf717708a557f089e8f9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwheelhandler_p_p.h @@ -0,0 +1,53 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKWHEELHANDLER_P_P_H +#define QQUICKWHEELHANDLER_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquicksinglepointhandler_p_p.h" +#include "qquickwheelhandler_p.h" +#include <QtCore/qbasictimer.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QQuickWheelHandlerPrivate : public QQuickSinglePointHandlerPrivate +{ + Q_DECLARE_PUBLIC(QQuickWheelHandler) + +public: + static QQuickWheelHandlerPrivate* get(QQuickWheelHandler *q) { return q->d_func(); } + static const QQuickWheelHandlerPrivate* get(const QQuickWheelHandler *q) { return q->d_func(); } + + QQuickWheelHandlerPrivate(); + + QMetaProperty &targetMetaProperty() const; + + QBasicTimer deactivationTimer; + qreal activeTimeout = 0.1; + qreal rotationScale = 1; + qreal rotation = 0; // in units of degrees + qreal targetScaleMultiplier = 1.25992104989487; // qPow(2, 1/3) + QString propertyName; + mutable QMetaProperty metaProperty; + Qt::Orientation orientation = Qt::Vertical; + mutable bool metaPropertyDirty = true; + bool invertible = true; + bool targetTransformAroundCursor = true; + bool blocking = true; + QQuickWheelEvent wheelEvent; +}; + +QT_END_NAMESPACE + +#endif // QQUICKWHEELHANDLER_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindow_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindow_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7b86a9c946e52f06e56b34f655921a204f9f41e7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindow_p.h @@ -0,0 +1,312 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKWINDOW_P_H +#define QQUICKWINDOW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qquickdeliveryagent_p_p.h> +#include <QtQuick/private/qquickevents_p_p.h> +#include <QtQuick/private/qsgcontext_p.h> +#include <QtQuick/private/qquickpaletteproviderprivatebase_p.h> +#include <QtQuick/private/qquickrendertarget_p.h> +#include <QtQuick/private/qquickgraphicsdevice_p.h> +#include <QtQuick/private/qquickgraphicsconfiguration_p.h> +#include <QtQuick/qquickitem.h> +#include <QtQuick/qquickwindow.h> + +#include <QtCore/qthread.h> +#include <QtCore/qmutex.h> +#include <QtCore/qwaitcondition.h> +#include <QtCore/qrunnable.h> +#include <QtCore/qstack.h> + +#include <QtGui/private/qevent_p.h> +#include <QtGui/private/qpointingdevice_p.h> +#include <QtGui/private/qwindow_p.h> +#include <QtGui/qevent.h> +#include <QtGui/qstylehints.h> +#include <QtGui/qguiapplication.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLContext; +class QQuickAnimatorController; +class QQuickDragGrabber; +class QQuickItemPrivate; +class QPointingDevice; +class QQuickRenderControl; +class QQuickWindowIncubationController; +class QQuickWindowPrivate; +class QSGRenderLoop; +class QTouchEvent; +class QRhi; +class QRhiSwapChain; +class QRhiRenderBuffer; +class QRhiRenderPassDescriptor; +class QRhiTexture; + +Q_DECLARE_LOGGING_CATEGORY(lcQuickWindow) + +//Make it easy to identify and customize the root item if needed +class Q_QUICK_EXPORT QQuickRootItem : public QQuickItem +{ + Q_OBJECT + QML_ANONYMOUS + QML_ADDED_IN_VERSION(2, 0) +public: + QQuickRootItem(); + +public Q_SLOTS: + void setWidth(int w) {QQuickItem::setWidth(qreal(w));} + void setHeight(int h) {QQuickItem::setHeight(qreal(h));} +}; + +struct QQuickWindowRenderTarget +{ + enum class ResetFlag { + KeepImplicitBuffers = 0x01 + }; + Q_DECLARE_FLAGS(ResetFlags, ResetFlag) + void reset(QRhi *rhi, ResetFlags flags = {}); + + struct { + QRhiRenderTarget *renderTarget = nullptr; + bool owns = false; + int multiViewCount = 1; + } rt; + struct { + QRhiTexture *texture = nullptr; + QRhiRenderBuffer *renderBuffer = nullptr; + QRhiRenderPassDescriptor *rpDesc = nullptr; + } res; + struct ImplicitBuffers { + QRhiRenderBuffer *depthStencil = nullptr; + QRhiTexture *depthStencilTexture = nullptr; + QRhiTexture *multisampleTexture = nullptr; + void reset(QRhi *rhi); + } implicitBuffers; + struct { + QPaintDevice *paintDevice = nullptr; + bool owns = false; + } sw; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickWindowRenderTarget::ResetFlags) + +class Q_QUICK_EXPORT QQuickWindowPrivate + : public QWindowPrivate + , public QQuickPaletteProviderPrivateBase<QQuickWindow, QQuickWindowPrivate> +{ +public: + Q_DECLARE_PUBLIC(QQuickWindow) + + enum CustomEvents { + FullUpdateRequest = QEvent::User + 1, + TriggerContextCreationFailure = QEvent::User + 2 + }; + + static inline QQuickWindowPrivate *get(QQuickWindow *c) { return c->d_func(); } + static inline const QQuickWindowPrivate *get(const QQuickWindow *c) { return c->d_func(); } + + QQuickWindowPrivate(); + ~QQuickWindowPrivate() override; + + void setPalette(QQuickPalette *p) override; + void updateWindowPalette(); + void updateChildrenPalettes(const QPalette &parentPalette) override; + + void init(QQuickWindow *, QQuickRenderControl *control = nullptr); + + QQuickRootItem *contentItem; + QSet<QQuickItem *> parentlessItems; + QQmlListProperty<QObject> data(); + + // primary delivery agent for the whole scene, used by default for events that arrive in this window; + // but any subscene root can have a QQuickItemPrivate::ExtraData::subsceneDeliveryAgent + QQuickDeliveryAgent *deliveryAgent = nullptr; + QQuickDeliveryAgentPrivate *deliveryAgentPrivate() const + { return deliveryAgent ? static_cast<QQuickDeliveryAgentPrivate *>(QQuickDeliveryAgentPrivate::get(deliveryAgent)) : nullptr; } + +#if QT_CONFIG(cursor) + QQuickItem *cursorItem = nullptr; + QQuickPointerHandler *cursorHandler = nullptr; + void updateCursor(const QPointF &scenePos, QQuickItem *rootItem = nullptr); + QPair<QQuickItem*, QQuickPointerHandler*> findCursorItemAndHandler(QQuickItem *item, const QPointF &scenePos) const; +#endif + + void clearFocusObject() override; + void setFocusToTarget(FocusTarget, Qt::FocusReason) override; + + void dirtyItem(QQuickItem *); + void cleanup(QSGNode *); + + void ensureCustomRenderTarget(); + void setCustomCommandBuffer(QRhiCommandBuffer *cb); + + void polishItems(); + void forcePolish(); + void invalidateFontData(QQuickItem *item); + void syncSceneGraph(); + void renderSceneGraph(); + + bool isRenderable() const; + + bool emitError(QQuickWindow::SceneGraphError error, const QString &msg); + + enum TextureFromNativeTextureFlag { + NativeTextureIsExternalOES = 0x01 + }; + Q_DECLARE_FLAGS(TextureFromNativeTextureFlags, TextureFromNativeTextureFlag) + + QSGTexture *createTextureFromNativeTexture(quint64 nativeObjectHandle, + int nativeLayoutOrState, + uint nativeFormat, + const QSize &size, + QQuickWindow::CreateTextureOptions options, + TextureFromNativeTextureFlags flags = {}) const; + QSGTexture *createTextureFromNativeTexture(quint64 nativeObjectHandle, + int nativeLayoutOrState, + const QSize &size, + QQuickWindow::CreateTextureOptions options, + TextureFromNativeTextureFlags flags = {}) const { + return createTextureFromNativeTexture(nativeObjectHandle, nativeLayoutOrState, 0, size, options, flags); + } + + QQuickItem::UpdatePaintNodeData updatePaintNodeData; + + QQuickItem *dirtyItemList; + QList<QSGNode *> cleanupNodeList; + + QVector<QQuickItem *> itemsToPolish; + + qreal lastReportedItemDevicePixelRatio; + QMetaObject::Connection physicalDpiChangedConnection; + + void updateDirtyNodes(); + void cleanupNodes(); + void cleanupNodesOnShutdown(); + bool updateEffectiveOpacity(QQuickItem *); + void updateEffectiveOpacityRoot(QQuickItem *, qreal); + void updateDirtyNode(QQuickItem *); + + void fireFrameSwapped() { Q_EMIT q_func()->frameSwapped(); } + void fireAboutToStop() { Q_EMIT q_func()->sceneGraphAboutToStop(); } + + bool needsChildWindowStackingOrderUpdate = false; + void updateChildWindowStackingOrder(QQuickItem *item = nullptr); + + int multiViewCount(); + QRhiRenderTarget *activeCustomRhiRenderTarget(); + + QSGRenderContext *context; + QSGRenderer *renderer; + QByteArray visualizationMode; // Default renderer supports "clip", "overdraw", "changes", "batches" and blank. + + QSGRenderLoop *windowManager; + QQuickRenderControl *renderControl; + QScopedPointer<QQuickAnimatorController> animationController; + + QColor clearColor; + + uint persistentGraphics : 1; + uint persistentSceneGraph : 1; + uint inDestructor : 1; + + // Storage for setRenderTarget(QQuickRenderTarget). + // Gets baked into redirect.renderTarget by ensureCustomRenderTarget() when rendering the next frame. + QQuickRenderTarget customRenderTarget; + + struct Redirect { + QRhiCommandBuffer *commandBuffer = nullptr; + QQuickWindowRenderTarget rt; + bool renderTargetDirty = false; + } redirect; + + QQuickGraphicsDevice customDeviceObjects; + + QQuickGraphicsConfiguration graphicsConfig; + + mutable QQuickWindowIncubationController *incubationController; + + static bool defaultAlphaBuffer; + static QQuickWindow::TextRenderType textRenderType; + + // vvv currently in use in Controls 2; TODO remove + static bool dragOverThreshold(qreal d, Qt::Axis axis, const QEventPoint *tp, int startDragThreshold = -1) + { return QQuickDeliveryAgentPrivate::dragOverThreshold(d, axis, *tp, startDragThreshold); } + static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1) + { return QQuickDeliveryAgentPrivate::dragOverThreshold(d, axis, event, startDragThreshold); } + void clearFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason) + { deliveryAgentPrivate()->clearFocusInScope(scope, item, reason); } + // ^^^ currently in use in Controls 2; TODO remove + + // data property + static void data_append(QQmlListProperty<QObject> *, QObject *); + static qsizetype data_count(QQmlListProperty<QObject> *); + static QObject *data_at(QQmlListProperty<QObject> *, qsizetype); + static void data_clear(QQmlListProperty<QObject> *); + static void data_removeLast(QQmlListProperty<QObject> *); + + static void rhiCreationFailureMessage(const QString &backendName, + QString *translatedMessage, + QString *untranslatedMessage); + + static void emitBeforeRenderPassRecording(void *ud); + static void emitAfterRenderPassRecording(void *ud); + + QMutex renderJobMutex; + QList<QRunnable *> beforeSynchronizingJobs; + QList<QRunnable *> afterSynchronizingJobs; + QList<QRunnable *> beforeRenderingJobs; + QList<QRunnable *> afterRenderingJobs; + QList<QRunnable *> afterSwapJobs; + + void runAndClearJobs(QList<QRunnable *> *jobs); + QOpenGLContext *openglContext(); + + QQuickWindow::GraphicsStateInfo rhiStateInfo; + QRhi *rhi = nullptr; + QRhiSwapChain *swapchain = nullptr; + QRhiRenderBuffer *depthStencilForSwapchain = nullptr; + QRhiRenderPassDescriptor *rpDescForSwapchain = nullptr; + uint hasActiveSwapchain : 1; + uint hasRenderableSwapchain : 1; + uint swapchainJustBecameRenderable : 1; + uint updatesEnabled : 1; + bool pendingFontUpdate = false; + bool windowEventDispatch = false; + QPointer<QQuickPalette> windowPaletteRef; + +private: + static void cleanupNodesOnShutdown(QQuickItem *); +}; + +class QQuickWindowQObjectCleanupJob : public QRunnable +{ +public: + QQuickWindowQObjectCleanupJob(QObject *o) : object(o) { } + void run() override { delete object; } + QObject *object; + static void schedule(QQuickWindow *window, QObject *object) { + Q_ASSERT(window); + Q_ASSERT(object); + window->scheduleRenderJob(new QQuickWindowQObjectCleanupJob(object), QQuickWindow::AfterSynchronizingStage); + } +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickWindowPrivate::TextureFromNativeTextureFlags) + +QT_END_NAMESPACE + +#endif // QQUICKWINDOW_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowattached_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowattached_p.h new file mode 100644 index 0000000000000000000000000000000000000000..25cd9bdd38e9d919f81502a45c2be0f4acdb617a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowattached_p.h @@ -0,0 +1,72 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKWINDOW_ATTACHED_P_H +#define QQUICKWINDOW_ATTACHED_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> +#include <qqml.h> +#include <QWindow> + +QT_BEGIN_NAMESPACE + +class QQuickItem; +class QQuickWindow; + +class Q_QUICK_EXPORT QQuickWindowAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QWindow::Visibility visibility READ visibility NOTIFY visibilityChanged FINAL) + Q_PROPERTY(bool active READ isActive NOTIFY activeChanged FINAL) + Q_PROPERTY(QQuickItem* activeFocusItem READ activeFocusItem NOTIFY activeFocusItemChanged FINAL) + Q_PROPERTY(QQuickItem* contentItem READ contentItem NOTIFY contentItemChanged FINAL) + Q_PROPERTY(int width READ width NOTIFY widthChanged FINAL) + Q_PROPERTY(int height READ height NOTIFY heightChanged FINAL) + Q_PROPERTY(QQuickWindow *window READ window NOTIFY windowChanged FINAL) + QML_ANONYMOUS + QML_ADDED_IN_VERSION(2, 0) + +public: + QQuickWindowAttached(QObject* attachee); + + QWindow::Visibility visibility() const; + bool isActive() const; + QQuickItem* activeFocusItem() const; + QQuickItem* contentItem() const; + int width() const; + int height() const; + QQuickWindow *window() const; + +Q_SIGNALS: + + void visibilityChanged(); + void activeChanged(); + void activeFocusItemChanged(); + void contentItemChanged(); + void widthChanged(); + void heightChanged(); + void windowChanged(); + +protected Q_SLOTS: + void windowChange(QQuickWindow*); + +private: + QQuickWindow* m_window; + QQuickItem* m_attachee; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowcontainer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowcontainer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c8f6e8eb41aea597eb65c3d0bf9c380cd67b54a2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowcontainer_p.h @@ -0,0 +1,79 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKWINDOWCONTAINER_P_H +#define QQUICKWINDOWCONTAINER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qtquickglobal_p.h> + +#include <QtCore/private/qobject_p.h> + +#include <QtQuick/private/qquickimplicitsizeitem_p.h> +#include <QtQuick/qquickwindow.h> + +QT_BEGIN_NAMESPACE + +class QQuickWindowContainerPrivate; +class Q_QUICK_EXPORT QQuickWindowContainer : public QQuickImplicitSizeItem +{ + Q_OBJECT + QML_NAMED_ELEMENT(WindowContainer) + Q_PROPERTY(QWindow *window READ containedWindow WRITE setContainedWindow + NOTIFY containedWindowChanged DESIGNABLE false FINAL) + + QML_ADDED_IN_VERSION(6, 7) + +public: + enum ContainerMode { + WindowControlsItem, + ItemControlsWindow + }; + + explicit QQuickWindowContainer(QQuickItem *parent = nullptr, + ContainerMode containerMode = ItemControlsWindow); + ~QQuickWindowContainer(); + + QWindow *containedWindow() const; + void setContainedWindow(QWindow *window); + Q_SIGNAL void containedWindowChanged(QWindow *window); + +protected: + void classBegin() override; + void componentComplete() override; + + void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; + void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &) override; + + void updatePolish() override; + + bool eventFilter(QObject *object, QEvent *event) override; + + QRectF clipRect() const override; + + void releaseResources() override; + +private: + Q_DECLARE_PRIVATE(QQuickWindowContainer) + friend class QQuickWindowQmlImpl; + + void initializeContainedWindow(); + void windowUpdated(); + void syncWindowToItem(); + void parentWindowChanged(QQuickWindow *window); + void windowDestroyed(); +}; + +QT_END_NAMESPACE + +#endif // QQUICKWINDOWCONTAINER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowmodule_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowmodule_p.h new file mode 100644 index 0000000000000000000000000000000000000000..109a27922b8f71d78766e3cabb00ccc6b0c72515 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowmodule_p.h @@ -0,0 +1,103 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKWINDOWMODULE_H +#define QQUICKWINDOWMODULE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> +#include <qquickwindow.h> +#include <qqmlparserstatus.h> +#include <private/qquickwindowattached_p.h> + +QT_BEGIN_NAMESPACE + +class QQuickWindowQmlImplPrivate; + +struct QWindowForeign +{ + Q_GADGET + QML_FOREIGN(QWindow) + QML_ANONYMOUS + QML_ADDED_IN_VERSION(2, 1) +}; + +class Q_QUICK_EXPORT QQuickWindowQmlImpl : public QQuickWindow, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(QWindow::Visibility visibility READ visibility WRITE setVisibility NOTIFY + visibilityChanged) + Q_PROPERTY(QObject *screen READ screen WRITE setScreen NOTIFY screenChanged REVISION(2, 3)) + QML_ATTACHED(QQuickWindowAttached) + QML_NAMED_ELEMENT(Window) + QML_ADDED_IN_VERSION(2, 1) + +public: + QQuickWindowQmlImpl(QWindow *parent = nullptr); + ~QQuickWindowQmlImpl(); + + void setVisible(bool visible); + void setVisibility(QWindow::Visibility visibility); + + QObject *screen() const; + void setScreen(QObject *screen); + + QObject *visualParent() const; + void setVisualParent(QObject *parent); + void visualParentChanged(QObject *) {}; + + void setX(int arg); + int x() const; + void setY(int arg); + int y() const; + void setZ(qreal arg); + qreal z() const; + void zChanged() {}; + + static QQuickWindowAttached *qmlAttachedProperties(QObject *object); + +Q_SIGNALS: + void visibleChanged(bool arg); + void visibilityChanged(QWindow::Visibility visibility); + Q_REVISION(2, 3) void screenChanged(); + + void xChanged(int arg); + void yChanged(int arg); + +protected: + void classBegin() override; + void componentComplete() override; + + bool event(QEvent *) override; + + QQuickWindowQmlImpl(QQuickWindowQmlImplPrivate &dd, QWindow *parent); + +private Q_SLOTS: + Q_REVISION(6, 7) void applyWindowVisibility(); + Q_REVISION(6, 7) void updateTransientParent(); + +private: + bool transientParentVisible(); + void applyVisualParent(); + +private: + Q_DISABLE_COPY(QQuickWindowQmlImpl) + Q_DECLARE_PRIVATE(QQuickWindowQmlImpl) +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowmodule_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowmodule_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..85688f250a2ee54507a3a022603a6b30f33ced1e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qquickwindowmodule_p_p.h @@ -0,0 +1,46 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQUICKWINDOWMODULE_P_P_H +#define QQUICKWINDOWMODULE_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquickwindow_p.h" +#include <QtQml/private/qv4persistent_p.h> +#include "qquickwindowcontainer_p.h" + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QQuickWindowQmlImplPrivate : public QQuickWindowPrivate +{ +public: + QQuickWindowQmlImplPrivate(); + + bool componentComplete = true; + + bool visible = false; + bool visibleExplicitlySet = false; + QQuickWindow::Visibility visibility = QQuickWindow::AutomaticVisibility; + bool visibilityExplicitlySet = false; + + QV4::PersistentValue rootItemMarker; + + QMetaObject::Connection itemParentWindowChangeListener; + + QObject *visualParent = nullptr; + QPointer<QQuickWindowContainer> windowContainer; + qreal z = 0.0; +}; + +QT_END_NAMESPACE + +#endif // QQUICKWINDOWMODULE_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgabstractrenderer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgabstractrenderer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c9f31952afb441d943b9d620d09cc49823439f87 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgabstractrenderer_p.h @@ -0,0 +1,86 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGABSTRACTRENDERER_P_H +#define QSGABSTRACTRENDERER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qtquickglobal_p.h> +#include <QtQuick/qsgnode.h> +#include <QtCore/qobject.h> + +#ifndef GLuint +#define GLuint uint +#endif + +QT_BEGIN_NAMESPACE + +class QSGAbstractRendererPrivate; + +class Q_QUICK_EXPORT QSGAbstractRenderer : public QObject +{ + Q_OBJECT +public: + enum MatrixTransformFlag + { + MatrixTransformFlipY = 0x01 + }; + Q_DECLARE_FLAGS(MatrixTransformFlags, MatrixTransformFlag) + Q_FLAG(MatrixTransformFlags) + + ~QSGAbstractRenderer() override; + + void setRootNode(QSGRootNode *node); + QSGRootNode *rootNode() const; + void setDeviceRect(const QRect &rect); + inline void setDeviceRect(const QSize &size) { setDeviceRect(QRect(QPoint(), size)); } + QRect deviceRect() const; + + void setViewportRect(const QRect &rect); + inline void setViewportRect(const QSize &size) { setViewportRect(QRect(QPoint(), size)); } + QRect viewportRect() const; + + void setProjectionMatrixToRect(const QRectF &rect); + void setProjectionMatrixToRect(const QRectF &rect, MatrixTransformFlags flags); + void setProjectionMatrixToRect(const QRectF &rect, MatrixTransformFlags flags, + bool nativeNDCFlipY); + void setProjectionMatrix(const QMatrix4x4 &matrix, int index = 0); + void setProjectionMatrixWithNativeNDC(const QMatrix4x4 &matrix, int index = 0); + QMatrix4x4 projectionMatrix(int index) const; + QMatrix4x4 projectionMatrixWithNativeNDC(int index) const; + int projectionMatrixCount() const; + int projectionMatrixWithNativeNDCCount() const; + + void setClearColor(const QColor &color); + QColor clearColor() const; + + virtual void renderScene() = 0; + + virtual void prepareSceneInline(); + virtual void renderSceneInline(); + +Q_SIGNALS: + void sceneGraphChanged(); + +protected: + explicit QSGAbstractRenderer(QObject *parent = nullptr); + virtual void nodeChanged(QSGNode *node, QSGNode::DirtyState state) = 0; + +private: + Q_DECLARE_PRIVATE(QSGAbstractRenderer) + friend class QSGRootNode; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgabstractrenderer_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgabstractrenderer_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..78be1a1563819892edff374f3c88ed1c36754bf2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgabstractrenderer_p_p.h @@ -0,0 +1,50 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGABSTRACTRENDERER_P_P_H +#define QSGABSTRACTRENDERER_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsgabstractrenderer_p.h" + +#include "qsgnode.h" +#include <qcolor.h> + +#include <QtCore/private/qobject_p.h> +#include <QtQuick/private/qtquickglobal_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGAbstractRendererPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QSGAbstractRenderer) +public: + static const QSGAbstractRendererPrivate *get(const QSGAbstractRenderer *q) { return q->d_func(); } + + QSGAbstractRendererPrivate(); + void updateProjectionMatrix(); + + QSGRootNode *m_root_node; + QColor m_clear_color; + + QRect m_device_rect; + QRect m_viewport_rect; + + QVarLengthArray<QMatrix4x4, 1> m_projection_matrix; + QVarLengthArray<QMatrix4x4, 1> m_projection_matrix_native_ndc; + uint m_mirrored : 1; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgabstractsoftwarerenderer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgabstractsoftwarerenderer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ded0b29b81c1041576aa36dca0cbcb880e741521 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgabstractsoftwarerenderer_p.h @@ -0,0 +1,79 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGABSTRACTSOFTWARERENDERER_H +#define QSGABSTRACTSOFTWARERENDERER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgrenderer_p.h> + +#include <QtCore/QHash> + +QT_BEGIN_NAMESPACE + +class QSGSimpleRectNode; + +class QSGSoftwareRenderableNode; +class QSGSoftwareRenderableNodeUpdater; + +class Q_QUICK_EXPORT QSGAbstractSoftwareRenderer : public QSGRenderer +{ +public: + QSGAbstractSoftwareRenderer(QSGRenderContext *context); + virtual ~QSGAbstractSoftwareRenderer(); + + QSGSoftwareRenderableNode *renderableNode(QSGNode *node) const; + void addNodeMapping(QSGNode *node, QSGSoftwareRenderableNode *renderableNode); + void appendRenderableNode(QSGSoftwareRenderableNode *node); + + void nodeChanged(QSGNode *node, QSGNode::DirtyState state) override; + + void markDirty(); + +protected: + QRegion renderNodes(QPainter *painter); + void buildRenderList(); + QRegion optimizeRenderList(); + + void setBackgroundColor(const QColor &color); + void setBackgroundRect(const QRect &rect, qreal devicePixelRatio); + QColor backgroundColor(); + QRect backgroundRect(); + // only known after calling optimizeRenderList() + bool isOpaque() const { return m_isOpaque; } + const QVector<QSGSoftwareRenderableNode*> &renderableNodes() const; + +private: + void nodeAdded(QSGNode *node); + void nodeRemoved(QSGNode *node); + void nodeGeometryUpdated(QSGNode *node); + void nodeMaterialUpdated(QSGNode *node); + void nodeMatrixUpdated(QSGNode *node); + void nodeOpacityUpdated(QSGNode *node); + + QHash<QSGNode*, QSGSoftwareRenderableNode*> m_nodes; + QVector<QSGSoftwareRenderableNode*> m_renderableNodes; + + QSGSimpleRectNode *m_background; + + QRegion m_dirtyRegion; + QRegion m_obscuredRegion; + qreal m_devicePixelRatio = 1; + bool m_isOpaque = false; + + QSGSoftwareRenderableNodeUpdater *m_nodeUpdater; +}; + +QT_END_NAMESPACE + +#endif // QSGABSTRACTSOFTWARERENDERER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgadaptationlayer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgadaptationlayer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0a27b1a7fcccdb65d0666585b5fbe9864a887301 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgadaptationlayer_p.h @@ -0,0 +1,559 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGADAPTATIONLAYER_P_H +#define QSGADAPTATIONLAYER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/qsgnode.h> +#include <QtQuick/qsgtexture.h> +#include <QtQuick/qquickpainteditem.h> +#include <QtCore/qobject.h> +#include <QtCore/qrect.h> +#include <QtGui/qbrush.h> +#include <QtGui/qcolor.h> +#include <QtGui/qpainterpath.h> +#include <QtCore/qsharedpointer.h> +#include <QtGui/qglyphrun.h> +#include <QtGui/qpainterpath.h> +#include <QtCore/qurl.h> +#include <private/qfontengine_p.h> +#include <QtGui/private/qdatabuffer_p.h> +#include <private/qdistancefield_p.h> +#include <private/qintrusivelist_p.h> +#include <rhi/qshader.h> + +// ### remove +#include <QtQuick/private/qquicktext_p.h> + +QT_BEGIN_NAMESPACE + +class QSGNode; +class QImage; +class TextureReference; +class QSGDistanceFieldGlyphNode; +class QSGInternalImageNode; +class QSGPainterNode; +class QSGInternalRectangleNode; +class QSGGlyphNode; +class QSGRootNode; +class QSGSpriteNode; +class QSGRenderNode; +class QSGRenderContext; +class QRhiTexture; + +class Q_QUICK_EXPORT QSGNodeVisitorEx +{ +public: + virtual ~QSGNodeVisitorEx(); + + // visit(...) returns true if the children are supposed to be + // visisted and false if they're supposed to be skipped by the visitor. + + virtual bool visit(QSGTransformNode *) = 0; + virtual void endVisit(QSGTransformNode *) = 0; + virtual bool visit(QSGClipNode *) = 0; + virtual void endVisit(QSGClipNode *) = 0; + virtual bool visit(QSGGeometryNode *) = 0; + virtual void endVisit(QSGGeometryNode *) = 0; + virtual bool visit(QSGOpacityNode *) = 0; + virtual void endVisit(QSGOpacityNode *) = 0; + virtual bool visit(QSGInternalImageNode *) = 0; + virtual void endVisit(QSGInternalImageNode *) = 0; + virtual bool visit(QSGPainterNode *) = 0; + virtual void endVisit(QSGPainterNode *) = 0; + virtual bool visit(QSGInternalRectangleNode *) = 0; + virtual void endVisit(QSGInternalRectangleNode *) = 0; + virtual bool visit(QSGGlyphNode *) = 0; + virtual void endVisit(QSGGlyphNode *) = 0; + virtual bool visit(QSGRootNode *) = 0; + virtual void endVisit(QSGRootNode *) = 0; +#if QT_CONFIG(quick_sprite) + virtual bool visit(QSGSpriteNode *) = 0; + virtual void endVisit(QSGSpriteNode *) = 0; +#endif + virtual bool visit(QSGRenderNode *) = 0; + virtual void endVisit(QSGRenderNode *) = 0; + + void visitChildren(QSGNode *node); +}; + + +class Q_QUICK_EXPORT QSGVisitableNode : public QSGGeometryNode +{ +public: + QSGVisitableNode() { setFlag(IsVisitableNode); } + ~QSGVisitableNode() override; + + virtual void accept(QSGNodeVisitorEx *) = 0; +}; + +class Q_QUICK_EXPORT QSGInternalRectangleNode : public QSGVisitableNode +{ +public: + ~QSGInternalRectangleNode() override; + + virtual void setRect(const QRectF &rect) = 0; + virtual void setColor(const QColor &color) = 0; + virtual void setPenColor(const QColor &color) = 0; + virtual void setPenWidth(qreal width) = 0; + virtual void setGradientStops(const QGradientStops &stops) = 0; + virtual void setGradientVertical(bool vertical) = 0; + virtual void setRadius(qreal radius) = 0; + virtual void setTopLeftRadius(qreal radius) = 0; + virtual void setTopRightRadius(qreal radius) = 0; + virtual void setBottomLeftRadius(qreal radius) = 0; + virtual void setBottomRightRadius(qreal radius) = 0; + virtual void setAntialiasing(bool antialiasing) { Q_UNUSED(antialiasing); } + virtual void setAligned(bool aligned) = 0; + + virtual void update() = 0; + + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } +}; + + +class Q_QUICK_EXPORT QSGInternalImageNode : public QSGVisitableNode +{ +public: + ~QSGInternalImageNode() override; + + virtual void setTargetRect(const QRectF &rect) = 0; + virtual void setInnerTargetRect(const QRectF &rect) = 0; + virtual void setInnerSourceRect(const QRectF &rect) = 0; + // The sub-source rect's width and height specify the number of times the inner source rect + // is repeated inside the inner target rect. The x and y specify which (normalized) location + // in the inner source rect maps to the upper-left corner of the inner target rect. + virtual void setSubSourceRect(const QRectF &rect) = 0; + virtual void setTexture(QSGTexture *texture) = 0; + virtual void setAntialiasing(bool antialiasing) { Q_UNUSED(antialiasing); } + virtual void setMirror(bool horizontally, bool vertically) = 0; + virtual void setMipmapFiltering(QSGTexture::Filtering filtering) = 0; + virtual void setFiltering(QSGTexture::Filtering filtering) = 0; + virtual void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) = 0; + virtual void setVerticalWrapMode(QSGTexture::WrapMode wrapMode) = 0; + + virtual void update() = 0; + + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } +}; + +class Q_QUICK_EXPORT QSGPainterNode : public QSGVisitableNode +{ +public: + ~QSGPainterNode() override; + + virtual void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) = 0; + virtual void setSize(const QSize &size) = 0; + virtual void setDirty(const QRect &dirtyRect = QRect()) = 0; + virtual void setOpaquePainting(bool opaque) = 0; + virtual void setLinearFiltering(bool linearFiltering) = 0; + virtual void setMipmapping(bool mipmapping) = 0; + virtual void setSmoothPainting(bool s) = 0; + virtual void setFillColor(const QColor &c) = 0; + virtual void setContentsScale(qreal s) = 0; + virtual void setFastFBOResizing(bool dynamic) = 0; + virtual void setTextureSize(const QSize &size) = 0; + + virtual QImage toImage() const = 0; + virtual void update() = 0; + virtual QSGTexture *texture() const = 0; + + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } +}; + +class Q_QUICK_EXPORT QSGLayer : public QSGDynamicTexture +{ + Q_OBJECT +public: + ~QSGLayer() override; + + enum Format { + RGBA8 = 1, + RGBA16F, + RGBA32F + }; + virtual void setItem(QSGNode *item) = 0; + virtual void setRect(const QRectF &logicalRect) = 0; + virtual void setSize(const QSize &pixelSize) = 0; + virtual void scheduleUpdate() = 0; + virtual QImage toImage() const = 0; + virtual void setLive(bool live) = 0; + virtual void setRecursive(bool recursive) = 0; + virtual void setFormat(Format format) = 0; + virtual void setHasMipmaps(bool mipmap) = 0; + virtual void setDevicePixelRatio(qreal ratio) = 0; + virtual void setMirrorHorizontal(bool mirror) = 0; + virtual void setMirrorVertical(bool mirror) = 0; + virtual void setSamples(int samples) = 0; + Q_SLOT virtual void markDirtyTexture() = 0; + Q_SLOT virtual void invalidated() = 0; + +Q_SIGNALS: + void updateRequested(); + void scheduledUpdateCompleted(); + +protected: + QSGLayer(QSGTexturePrivate &dd); +}; + +#if QT_CONFIG(quick_sprite) + +class Q_QUICK_EXPORT QSGSpriteNode : public QSGVisitableNode +{ +public: + ~QSGSpriteNode() override; + + virtual void setTexture(QSGTexture *texture) = 0; + virtual void setTime(float time) = 0; + virtual void setSourceA(const QPoint &source) = 0; + virtual void setSourceB(const QPoint &source) = 0; + virtual void setSpriteSize(const QSize &size) = 0; + virtual void setSheetSize(const QSize &size) = 0; + virtual void setSize(const QSizeF &size) = 0; + virtual void setFiltering(QSGTexture::Filtering filtering) = 0; + + virtual void update() = 0; + + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } +}; + +#endif + +class Q_QUICK_EXPORT QSGGuiThreadShaderEffectManager : public QObject +{ + Q_OBJECT + +public: + ~QSGGuiThreadShaderEffectManager() override; + + enum Status { + Compiled, + Uncompiled, + Error + }; + + virtual bool hasSeparateSamplerAndTextureObjects() const = 0; + + virtual QString log() const = 0; + virtual Status status() const = 0; + + struct ShaderInfo { + enum Type { + TypeVertex, + TypeFragment, + TypeOther + }; + enum VariableType { + Constant, // cbuffer members or uniforms + Sampler, + Texture // for APIs with separate texture and sampler objects + }; + struct Variable { + VariableType type = Constant; + QByteArray name; + uint offset = 0; // for cbuffer members + uint size = 0; // for cbuffer members + int bindPoint = 0; // for textures/samplers, where applicable + }; + + QString name; // optional, f.ex. the filename, used for debugging purposes only + QShader rhiShader; + Type type; + QVector<Variable> variables; + + // Vertex inputs are not tracked here as QSGGeometry::AttributeSet + // hardwires that anyways so it is up to the shader to provide + // compatible inputs (e.g. compatible with + // QSGGeometry::defaultAttributes_TexturedPoint2D()). + }; + + virtual void prepareShaderCode(ShaderInfo::Type typeHint, const QUrl &src, ShaderInfo *result) = 0; + +Q_SIGNALS: + void shaderCodePrepared(bool ok, ShaderInfo::Type typeHint, const QUrl &src, ShaderInfo *result); + void logAndStatusChanged(); +}; + +#ifndef QT_NO_DEBUG_STREAM +Q_QUICK_EXPORT QDebug operator<<(QDebug debug, const QSGGuiThreadShaderEffectManager::ShaderInfo::Variable &v); +#endif + +class Q_QUICK_EXPORT QSGShaderEffectNode : public QObject, public QSGVisitableNode +{ + Q_OBJECT + +public: + ~QSGShaderEffectNode() override; + + enum DirtyShaderFlag { + DirtyShaders = 0x01, + DirtyShaderConstant = 0x02, + DirtyShaderTexture = 0x04, + DirtyShaderGeometry = 0x08, + DirtyShaderMesh = 0x10, + + DirtyShaderAll = 0xFF + }; + Q_DECLARE_FLAGS(DirtyShaderFlags, DirtyShaderFlag) + + enum CullMode { // must match ShaderEffect + NoCulling, + BackFaceCulling, + FrontFaceCulling + }; + + struct VariableData { + enum SpecialType { None, Unused, Source, SubRect, Opacity, Matrix }; + + QVariant value; + SpecialType specialType; + int propertyIndex = -1; + }; + + struct ShaderData { + ShaderData() {} + bool hasShaderCode = false; + QSGGuiThreadShaderEffectManager::ShaderInfo shaderInfo; + QVector<VariableData> varData; + }; + + struct SyncData { + DirtyShaderFlags dirty; + CullMode cullMode; + bool blending; + struct ShaderSyncData { + const ShaderData *shader; + const QSet<int> *dirtyConstants; + const QSet<int> *dirtyTextures; + }; + ShaderSyncData vertex; + ShaderSyncData fragment; + void *materialTypeCacheKey; + qint8 viewCount; + }; + + // Each ShaderEffect item has one node (render thread) and one manager (gui thread). + + virtual QRectF updateNormalizedTextureSubRect(bool supportsAtlasTextures) = 0; + virtual void syncMaterial(SyncData *syncData) = 0; + + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } + +Q_SIGNALS: + void textureChanged(); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QSGShaderEffectNode::DirtyShaderFlags) + +#ifndef QT_NO_DEBUG_STREAM +Q_QUICK_EXPORT QDebug operator<<(QDebug debug, const QSGShaderEffectNode::VariableData &vd); +#endif + +class Q_QUICK_EXPORT QSGGlyphNode : public QSGVisitableNode +{ +public: + enum AntialiasingMode + { + DefaultAntialiasing = -1, + GrayAntialiasing, + LowQualitySubPixelAntialiasing, + HighQualitySubPixelAntialiasing + }; + + QSGGlyphNode() {} + ~QSGGlyphNode() override; + + virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) = 0; + virtual void setColor(const QColor &color) = 0; + virtual void setStyle(QQuickText::TextStyle style) = 0; + virtual void setStyleColor(const QColor &color) = 0; + virtual QPointF baseLine() const = 0; + + virtual QRectF boundingRect() const { return m_bounding_rect; } + virtual void setBoundingRect(const QRectF &bounds) { m_bounding_rect = bounds; } + + virtual void setPreferredAntialiasingMode(AntialiasingMode) = 0; + virtual void setRenderTypeQuality(int renderTypeQuality) { Q_UNUSED(renderTypeQuality) } + + virtual void update() = 0; + + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } +protected: + QRectF m_bounding_rect; +}; + +class Q_QUICK_EXPORT QSGDistanceFieldGlyphConsumer +{ +public: + virtual ~QSGDistanceFieldGlyphConsumer(); + + virtual void invalidateGlyphs(const QVector<quint32> &glyphs) = 0; + QIntrusiveListNode node; +}; +typedef QIntrusiveList<QSGDistanceFieldGlyphConsumer, &QSGDistanceFieldGlyphConsumer::node> QSGDistanceFieldGlyphConsumerList; + +class Q_QUICK_EXPORT QSGDistanceFieldGlyphCache +{ +public: + QSGDistanceFieldGlyphCache(const QRawFont &font, + int renderTypeQuality); + virtual ~QSGDistanceFieldGlyphCache(); + + struct Metrics { + qreal width; + qreal height; + qreal baselineX; + qreal baselineY; + + bool isNull() const { return width == 0 || height == 0; } + }; + + struct TexCoord { + qreal x = 0; + qreal y = 0; + qreal width = -1; + qreal height = -1; + qreal xMargin = 0; + qreal yMargin = 0; + + TexCoord() {} + + bool isNull() const { return width <= 0 || height <= 0; } + bool isValid() const { return width >= 0 && height >= 0; } + }; + + struct Texture { + QRhiTexture *texture = nullptr; + QSize size; + + bool operator == (const Texture &other) const { + return texture == other.texture; + } + }; + + const QRawFont &referenceFont() const { return m_referenceFont; } + + qreal fontScale(qreal pixelSize) const + { + return pixelSize / baseFontSize(); + } + qreal distanceFieldRadius() const + { + return QT_DISTANCEFIELD_RADIUS(m_doubleGlyphResolution) / qreal(QT_DISTANCEFIELD_SCALE(m_doubleGlyphResolution)); + } + int glyphCount() const { return m_glyphCount; } + bool doubleGlyphResolution() const { return m_doubleGlyphResolution; } + int renderTypeQuality() const { return m_renderTypeQuality; } + + Metrics glyphMetrics(glyph_t glyph, qreal pixelSize); + inline TexCoord glyphTexCoord(glyph_t glyph); + inline const Texture *glyphTexture(glyph_t glyph); + + void populate(const QVector<glyph_t> &glyphs); + void release(const QVector<glyph_t> &glyphs); + + void update(); + + void registerGlyphNode(QSGDistanceFieldGlyphConsumer *node) { m_registeredNodes.insert(node); } + void unregisterGlyphNode(QSGDistanceFieldGlyphConsumer *node) { m_registeredNodes.remove(node); } + + virtual void processPendingGlyphs(); + + virtual bool eightBitFormatIsAlphaSwizzled() const = 0; + virtual bool screenSpaceDerivativesSupported() const = 0; + virtual bool isActive() const; + +protected: + struct GlyphPosition { + glyph_t glyph; + QPointF position; + }; + + struct GlyphData { + Texture *texture = nullptr; + TexCoord texCoord; + QRectF boundingRect; + QPainterPath path; + quint32 ref = 0; + + GlyphData() {} + }; + + virtual void requestGlyphs(const QSet<glyph_t> &glyphs) = 0; + virtual void storeGlyphs(const QList<QDistanceField> &glyphs) = 0; + virtual void referenceGlyphs(const QSet<glyph_t> &glyphs) = 0; + virtual void releaseGlyphs(const QSet<glyph_t> &glyphs) = 0; + + void setGlyphsPosition(const QList<GlyphPosition> &glyphs); + void setGlyphsTexture(const QVector<glyph_t> &glyphs, const Texture &tex); + void markGlyphsToRender(const QVector<glyph_t> &glyphs); + inline void removeGlyph(glyph_t glyph); + + void updateRhiTexture(QRhiTexture *oldTex, QRhiTexture *newTex, const QSize &newTexSize); + + inline bool containsGlyph(glyph_t glyph); + + GlyphData &glyphData(glyph_t glyph); + GlyphData &emptyData(glyph_t glyph); + + int baseFontSize() const; + +#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG) + virtual void saveTexture(QRhiTexture *texture, const QString &nameBase) const = 0; +#endif + + bool m_doubleGlyphResolution; + int m_renderTypeQuality; + +protected: + QRawFont m_referenceFont; + +private: + int m_glyphCount; + QList<Texture> m_textures; + QHash<glyph_t, GlyphData> m_glyphsData; + QDataBuffer<glyph_t> m_pendingGlyphs; + QSet<glyph_t> m_populatingGlyphs; + QSGDistanceFieldGlyphConsumerList m_registeredNodes; + + static Texture s_emptyTexture; +}; + +inline QSGDistanceFieldGlyphCache::TexCoord QSGDistanceFieldGlyphCache::glyphTexCoord(glyph_t glyph) +{ + return glyphData(glyph).texCoord; +} + +inline const QSGDistanceFieldGlyphCache::Texture *QSGDistanceFieldGlyphCache::glyphTexture(glyph_t glyph) +{ + return glyphData(glyph).texture; +} + +inline void QSGDistanceFieldGlyphCache::removeGlyph(glyph_t glyph) +{ + GlyphData &gd = glyphData(glyph); + gd.texCoord = TexCoord(); + gd.texture = &s_emptyTexture; +} + +inline bool QSGDistanceFieldGlyphCache::containsGlyph(glyph_t glyph) +{ + return glyphData(glyph).texCoord.isValid(); +} + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QSGGuiThreadShaderEffectManager::ShaderInfo::Type) + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgareaallocator_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgareaallocator_p.h new file mode 100644 index 0000000000000000000000000000000000000000..635ef330359d124ce31401e406e040a9854eff68 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgareaallocator_p.h @@ -0,0 +1,51 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGAREAALLOCATOR_P_H +#define QSGAREAALLOCATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> +#include <QtCore/qsize.h> + +QT_BEGIN_NAMESPACE + +class QRect; +class QPoint; +struct QSGAreaAllocatorNode; +class Q_QUICK_EXPORT QSGAreaAllocator +{ +public: + QSGAreaAllocator(const QSize &size); + ~QSGAreaAllocator(); + + QRect allocate(const QSize &size); + bool deallocate(const QRect &rect); + bool isEmpty() const { return m_root == nullptr; } + QSize size() const { return m_size; } + + QByteArray serialize(); + const char *deserialize(const char *data, int size); + +private: + bool allocateInNode(const QSize &size, QPoint &result, const QRect ¤tRect, QSGAreaAllocatorNode *node); + bool deallocateInNode(const QPoint &pos, QSGAreaAllocatorNode *node); + void mergeNodeWithNeighbors(QSGAreaAllocatorNode *node); + + QSGAreaAllocatorNode *m_root; + QSize m_size; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbasicglyphnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbasicglyphnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..246153ffddb60e0926be699d6eeaeda203eb8cd3 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbasicglyphnode_p.h @@ -0,0 +1,56 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGBASICGLYPHNODE_P_H +#define QSGBASICGLYPHNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> + +QT_BEGIN_NAMESPACE + +class QSGMaterial; + +class Q_QUICK_EXPORT QSGBasicGlyphNode: public QSGGlyphNode +{ +public: + QSGBasicGlyphNode(); + virtual ~QSGBasicGlyphNode(); + + QPointF baseLine() const override { return m_baseLine; } + void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override; + void setColor(const QColor &color) override; + + void setPreferredAntialiasingMode(AntialiasingMode) override { } + void setStyle(QQuickText::TextStyle) override; + void setStyleColor(const QColor &) override; + + virtual void setMaterialColor(const QColor &color) = 0; + void update() override = 0; + +protected: + QGlyphRun m_glyphs; + QPointF m_position; + QColor m_color; + QQuickText::TextStyle m_style; + QColor m_styleColor; + + QPointF m_baseLine; + QSGMaterial *m_material; + + QSGGeometry m_geometry; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbasicinternalimagenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbasicinternalimagenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..3d487e72bdf21d72f71514b318b6b288c95af92d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbasicinternalimagenode_p.h @@ -0,0 +1,75 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGBASICINTERNALIMAGENODE_P_H +#define QSGBASICINTERNALIMAGENODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGBasicInternalImageNode : public QSGInternalImageNode +{ +public: + QSGBasicInternalImageNode(); + + void setTargetRect(const QRectF &rect) override; + void setInnerTargetRect(const QRectF &rect) override; + void setInnerSourceRect(const QRectF &rect) override; + void setSubSourceRect(const QRectF &rect) override; + void setTexture(QSGTexture *texture) override; + void setAntialiasing(bool antialiasing) override; + void setMirror(bool mirrorHorizontally, bool mirrorVertically) override; + void update() override; + void preprocess() override; + + static QSGGeometry *updateGeometry(const QRectF &targetRect, + const QRectF &innerTargetRect, + const QRectF &sourceRect, + const QRectF &innerSourceRect, + const QRectF &subSourceRect, + QSGGeometry *geometry, + bool mirrorHorizontally = false, + bool mirrorVertically = false, + bool antialiasing = false); + +protected: + virtual void updateMaterialAntialiasing() = 0; + virtual void setMaterialTexture(QSGTexture *texture) = 0; + virtual QSGTexture *materialTexture() const = 0; + virtual bool updateMaterialBlending() = 0; + virtual bool supportsWrap(const QSize &size) const = 0; + + void updateGeometry(); + + QRectF m_targetRect; + QRectF m_innerTargetRect; + QRectF m_innerSourceRect; + QRectF m_subSourceRect; + + uint m_antialiasing : 1; + uint m_mirrorHorizontally : 1; + uint m_mirrorVertically : 1; + uint m_dirtyGeometry : 1; + + QSGGeometry m_geometry; + + QSGDynamicTexture *m_dynamicTexture; + QSize m_dynamicTextureSize; + QRectF m_dynamicTextureSubRect; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbasicinternalrectanglenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbasicinternalrectanglenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..30e6a5317fd4a466fb404782713da83d6e1ca030 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbasicinternalrectanglenode_p.h @@ -0,0 +1,73 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QSGBASICINTERNALRECTANGLENODE_P_H +#define QSGBASICINTERNALRECTANGLENODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGBasicInternalRectangleNode : public QSGInternalRectangleNode +{ +public: + QSGBasicInternalRectangleNode(); + + void setRect(const QRectF &rect) override; + void setColor(const QColor &color) override; + void setPenColor(const QColor &color) override; + void setPenWidth(qreal width) override; + void setGradientStops(const QGradientStops &stops) override; + void setGradientVertical(bool vertical) override; + void setRadius(qreal radius) override; + void setTopLeftRadius(qreal radius) override; + void setTopRightRadius(qreal radius) override; + void setBottomLeftRadius(qreal radius) override; + void setBottomRightRadius(qreal radius) override; + void setAntialiasing(bool antialiasing) override; + void setAligned(bool aligned) override; + void update() override; + +protected: + virtual bool supportsAntialiasing() const { return true; } + virtual void updateMaterialAntialiasing() = 0; + virtual void updateMaterialBlending(QSGNode::DirtyState *state) = 0; + + void updateGeometry(); + void updateGradientTexture(); + + QRectF m_rect; + QGradientStops m_gradient_stops; + QColor m_color; + QColor m_border_color; + float m_radius = 0.0f; + float m_topLeftRadius = -1.0f; + float m_topRightRadius = -1.0f; + float m_bottomLeftRadius = -1.0f; + float m_bottomRightRadius = -1.0f; + float m_pen_width = 0.0f; + + uint m_aligned : 1; + uint m_antialiasing : 1; + uint m_gradient_is_opaque : 1; + uint m_dirty_geometry : 1; + uint m_gradient_is_vertical : 1; + + QSGGeometry m_geometry; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbatchrenderer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbatchrenderer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d7f9605892879a12f9b8826fb3462540253e80d0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgbatchrenderer_p.h @@ -0,0 +1,1028 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> +// Copyright (C) 2016 Robin Burchell <robin.burchell@viroteck.net> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGBATCHRENDERER_P_H +#define QSGBATCHRENDERER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgrenderer_p.h> +#include <private/qsgdefaultrendercontext_p.h> +#include <private/qsgnodeupdater_p.h> +#include <private/qsgrendernode_p.h> +#include <private/qdatabuffer_p.h> +#include <private/qsgtexture_p.h> + +#include <QtCore/QBitArray> +#include <QtCore/QStack> + +#include <rhi/qrhi.h> + +QT_BEGIN_NAMESPACE + +namespace QSGBatchRenderer +{ + +#define QSG_RENDERER_COORD_LIMIT 1000000.0f + +struct Vec; +struct Rect; +struct Buffer; +struct Chunk; +struct Batch; +struct Node; +class Updater; +class Renderer; +class ShaderManager; + +template <typename Type, int PageSize> class AllocatorPage +{ +public: + // The memory used by this allocator + char data[sizeof(Type) * PageSize]; + + // 'blocks' contains a list of free indices which can be allocated. + // The first available index is found in PageSize - available. + int blocks[PageSize]; + + // 'available' is the number of available instances this page has left to allocate. + int available; + + // This is not strictly needed, but useful for sanity checking and anyway + // pretty small.. + QBitArray allocated; + + AllocatorPage() + : available(PageSize) + , allocated(PageSize) + { + for (int i=0; i<PageSize; ++i) + blocks[i] = i; + + // Zero out all new pages. + memset(data, 0, sizeof(data)); + } + + const Type *at(uint index) const + { + return (Type *) &data[index * sizeof(Type)]; + } + + Type *at(uint index) + { + return (Type *) &data[index * sizeof(Type)]; + } +}; + +template <typename Type, int PageSize> class Allocator +{ +public: + Allocator() + { + pages.push_back(new AllocatorPage<Type, PageSize>()); + } + + ~Allocator() + { + qDeleteAll(pages); + } + + Type *allocate() + { + AllocatorPage<Type, PageSize> *p = 0; + for (int i = m_freePage; i < pages.size(); i++) { + if (pages.at(i)->available > 0) { + p = pages.at(i); + m_freePage = i; + break; + } + } + + // we couldn't find a free page from m_freePage to the last page. + // either there is no free pages, or there weren't any in the area we + // scanned: rescanning is expensive, so let's just assume there isn't + // one. when an item is released, we'll reset m_freePage anyway. + if (!p) { + p = new AllocatorPage<Type, PageSize>(); + m_freePage = pages.size(); + pages.push_back(p); + } + uint pos = p->blocks[PageSize - p->available]; + void *mem = p->at(pos); + p->available--; + p->allocated.setBit(pos); + Type *t = (Type*)mem; + return t; + } + + void releaseExplicit(uint pageIndex, uint index) + { + AllocatorPage<Type, PageSize> *page = pages.at(pageIndex); + if (!page->allocated.testBit(index)) + qFatal("Double delete in allocator: page=%d, index=%d", pageIndex , index); + + // Zero this instance as we're done with it. + void *mem = page->at(index); + memset(mem, 0, sizeof(Type)); + + page->allocated[index] = false; + page->available++; + page->blocks[PageSize - page->available] = index; + + // Remove the pages if they are empty and they are the last ones. We need to keep the + // order of pages since we have references to their index, so we can only remove + // from the end. + while (page->available == PageSize && pages.size() > 1 && pages.back() == page) { + pages.pop_back(); + delete page; + page = pages.back(); + } + + // Reset the free page to force a scan for a new free point. + m_freePage = 0; + } + + void release(Type *t) + { + int pageIndex = -1; + for (int i=0; i<pages.size(); ++i) { + AllocatorPage<Type, PageSize> *p = pages.at(i); + if ((Type *) (&p->data[0]) <= t && (Type *) (&p->data[PageSize * sizeof(Type)]) > t) { + pageIndex = i; + break; + } + } + Q_ASSERT(pageIndex >= 0); + + AllocatorPage<Type, PageSize> *page = pages.at(pageIndex); + int index = (quint64(t) - quint64(&page->data[0])) / sizeof(Type); + + releaseExplicit(pageIndex, index); + } + + QVector<AllocatorPage<Type, PageSize> *> pages; + int m_freePage = 0; +}; + + +inline bool hasMaterialWithBlending(QSGGeometryNode *n) +{ + return (n->opaqueMaterial() ? n->opaqueMaterial()->flags() & QSGMaterial::Blending + : n->material()->flags() & QSGMaterial::Blending); +} + +struct Pt { + float x, y; + + void map(const QMatrix4x4 &mat) { + Pt r; + const float *m = mat.constData(); + r.x = x * m[0] + y * m[4] + m[12]; + r.y = x * m[1] + y * m[5] + m[13]; + x = r.x; + y = r.y; + } + + void set(float nx, float ny) { + x = nx; + y = ny; + } +}; + +inline QDebug operator << (QDebug d, const Pt &p) { + d << "Pt(" << p.x << p.y << ")"; + return d; +} + + + +struct Rect { + Pt tl, br; // Top-Left (min) and Bottom-Right (max) + + void operator |= (const Pt &pt) { + if (pt.x < tl.x) + tl.x = pt.x; + if (pt.x > br.x) + br.x = pt.x; + if (pt.y < tl.y) + tl.y = pt.y; + if (pt.y > br.y) + br.y = pt.y; + } + + void operator |= (const Rect &r) { + if (r.tl.x < tl.x) + tl.x = r.tl.x; + if (r.tl.y < tl.y) + tl.y = r.tl.y; + if (r.br.x > br.x) + br.x = r.br.x; + if (r.br.y > br.y) + br.y = r.br.y; + } + + void map(const QMatrix4x4 &m); + + void set(float left, float top, float right, float bottom) { + tl.set(left, top); + br.set(right, bottom); + } + + bool intersects(const Rect &r) { + bool xOverlap = r.tl.x < br.x && r.br.x > tl.x; + bool yOverlap = r.tl.y < br.y && r.br.y > tl.y; + return xOverlap && yOverlap; + } + + bool isOutsideFloatRange() const { + return tl.x < -QSG_RENDERER_COORD_LIMIT + || tl.y < -QSG_RENDERER_COORD_LIMIT + || br.x > QSG_RENDERER_COORD_LIMIT + || br.y > QSG_RENDERER_COORD_LIMIT; + } +}; + +inline QDebug operator << (QDebug d, const Rect &r) { + d << "Rect(" << r.tl.x << r.tl.y << r.br.x << r.br.y << ")"; + return d; +} + +struct Buffer { + quint32 size; + // Data is only valid while preparing the upload. Exception is if we are using the + // broken IBO workaround or we are using a visualization mode. + char *data; + QRhiBuffer *buf; + uint nonDynamicChangeCount; +}; + +struct Element { + Element() + : boundsComputed(false) + , boundsOutsideFloatRange(false) + , translateOnlyToRoot(false) + , removed(false) + , orphaned(false) + , isRenderNode(false) + , isMaterialBlended(false) + { + } + + void setNode(QSGGeometryNode *n) { + node = n; + isMaterialBlended = hasMaterialWithBlending(n); + } + + inline void ensureBoundsValid() { + if (!boundsComputed) + computeBounds(); + } + void computeBounds(); + + QSGGeometryNode *node = nullptr; + Batch *batch = nullptr; + Element *nextInBatch = nullptr; + Node *root = nullptr; + + Rect bounds; // in device coordinates + + int order = 0; + QRhiShaderResourceBindings *srb = nullptr; + QRhiGraphicsPipeline *ps = nullptr; + QRhiGraphicsPipeline *depthPostPassPs = nullptr; + + uint boundsComputed : 1; + uint boundsOutsideFloatRange : 1; + uint translateOnlyToRoot : 1; + uint removed : 1; + uint orphaned : 1; + uint isRenderNode : 1; + uint isMaterialBlended : 1; +}; + +struct RenderNodeElement : public Element { + + RenderNodeElement(QSGRenderNode *rn) + : renderNode(rn) + { + isRenderNode = true; + } + + QSGRenderNode *renderNode; +}; + +struct BatchRootInfo { + BatchRootInfo() {} + QSet<Node *> subRoots; + Node *parentRoot = nullptr; + int lastOrder = -1; + int firstOrder = -1; + int availableOrders = 0; +}; + +struct ClipBatchRootInfo : public BatchRootInfo +{ + QMatrix4x4 matrix; +}; + +struct DrawSet +{ + DrawSet(int v, int z, int i) + : vertices(v) + , zorders(z) + , indices(i) + { + } + DrawSet() {} + int vertices = 0; + int zorders = 0; + int indices = 0; + int indexCount = 0; +}; + +enum BatchCompatibility +{ + BatchBreaksOnCompare, + BatchIsCompatible +}; + +struct ClipState +{ + enum ClipTypeBit + { + NoClip = 0x00, + ScissorClip = 0x01, + StencilClip = 0x02 + }; + Q_DECLARE_FLAGS(ClipType, ClipTypeBit) + + const QSGClipNode *clipList; + ClipType type; + QRhiScissor scissor; + int stencilRef; + + inline void reset(); +}; + +struct StencilClipState +{ + StencilClipState() : drawCalls(1) { } + + bool updateStencilBuffer = false; + QRhiShaderResourceBindings *srb = nullptr; + QRhiBuffer *vbuf = nullptr; + QRhiBuffer *ibuf = nullptr; + QRhiBuffer *ubuf = nullptr; + + struct StencilDrawCall { + int stencilRef; + int vertexCount; + int indexCount; + QRhiCommandBuffer::IndexFormat indexFormat; + quint32 vbufOffset; + quint32 ibufOffset; + quint32 ubufOffset; + }; + QDataBuffer<StencilDrawCall> drawCalls; + + inline void reset(); +}; + +struct Batch +{ + Batch() : drawSets(1) {} + bool geometryWasChanged(QSGGeometryNode *gn); + BatchCompatibility isMaterialCompatible(Element *e) const; + void invalidate(); + void cleanupRemovedElements(); + + bool isTranslateOnlyToRoot() const; + bool isSafeToBatch() const; + + // pseudo-constructor... + void init() { + // Only non-reusable members are reset here. See Renderer::newBatch(). + first = nullptr; + root = nullptr; + vertexCount = 0; + indexCount = 0; + isOpaque = false; + needsUpload = false; + merged = false; + positionAttribute = -1; + uploadedThisFrame = false; + isRenderNode = false; + ubufDataValid = false; + needsPurge = false; + clipState.reset(); + blendConstant = QColor(); + } + + Element *first; + Node *root; + + int positionAttribute; + + int vertexCount; + int indexCount; + + int lastOrderInBatch; + + uint isOpaque : 1; + uint needsUpload : 1; + uint merged : 1; + uint isRenderNode : 1; + uint ubufDataValid : 1; + uint needsPurge : 1; + + mutable uint uploadedThisFrame : 1; // solely for debugging purposes + + Buffer vbo; + Buffer ibo; + QRhiBuffer *ubuf; + ClipState clipState; + StencilClipState stencilClipState; + QColor blendConstant; + + QDataBuffer<DrawSet> drawSets; +}; + +// NOTE: Node is zero-initialized by the Allocator. +struct Node +{ + QSGNode *sgNode; + void *data; + + Node *m_parent; + Node *m_child; + Node *m_next; + Node *m_prev; + + Node *parent() const { return m_parent; } + + void append(Node *child) { + Q_ASSERT(child); + Q_ASSERT(!hasChild(child)); + Q_ASSERT(child->m_parent == nullptr); + Q_ASSERT(child->m_next == nullptr); + Q_ASSERT(child->m_prev == nullptr); + + if (!m_child) { + child->m_next = child; + child->m_prev = child; + m_child = child; + } else { + m_child->m_prev->m_next = child; + child->m_prev = m_child->m_prev; + m_child->m_prev = child; + child->m_next = m_child; + } + child->setParent(this); + } + + void remove(Node *child) { + Q_ASSERT(child); + Q_ASSERT(hasChild(child)); + + // only child.. + if (child->m_next == child) { + m_child = nullptr; + } else { + if (m_child == child) + m_child = child->m_next; + child->m_next->m_prev = child->m_prev; + child->m_prev->m_next = child->m_next; + } + child->m_next = nullptr; + child->m_prev = nullptr; + child->setParent(nullptr); + } + + Node *firstChild() const { return m_child; } + + Node *sibling() const { + Q_ASSERT(m_parent); + return m_next == m_parent->m_child ? nullptr : m_next; + } + + void setParent(Node *p) { + Q_ASSERT(m_parent == nullptr || p == nullptr); + m_parent = p; + } + + bool hasChild(Node *child) const { + Node *n = m_child; + while (n && n != child) + n = n->sibling(); + return n; + } + + + + QSGNode::DirtyState dirtyState; + + uint isOpaque : 1; + uint isBatchRoot : 1; + uint becameBatchRoot : 1; + + inline QSGNode::NodeType type() const { return sgNode->type(); } + + inline Element *element() const { + Q_ASSERT(sgNode->type() == QSGNode::GeometryNodeType); + return (Element *) data; + } + + inline RenderNodeElement *renderNodeElement() const { + Q_ASSERT(sgNode->type() == QSGNode::RenderNodeType); + return (RenderNodeElement *) data; + } + + inline ClipBatchRootInfo *clipInfo() const { + Q_ASSERT(sgNode->type() == QSGNode::ClipNodeType); + return (ClipBatchRootInfo *) data; + } + + inline BatchRootInfo *rootInfo() const { + Q_ASSERT(sgNode->type() == QSGNode::ClipNodeType + || (sgNode->type() == QSGNode::TransformNodeType && isBatchRoot)); + return (BatchRootInfo *) data; + } +}; + +class Updater : public QSGNodeUpdater +{ +public: + Updater(Renderer *r); + + void visitOpacityNode(Node *n); + void visitTransformNode(Node *n); + void visitGeometryNode(Node *n); + void visitClipNode(Node *n); + void updateRootTransforms(Node *n); + void updateRootTransforms(Node *n, Node *root, const QMatrix4x4 &combined); + + void updateStates(QSGNode *n) override; + void visitNode(Node *n); + void registerWithParentRoot(QSGNode *subRoot, QSGNode *parentRoot); + +private: + Renderer *renderer; + + QDataBuffer<Node *> m_roots; + QDataBuffer<QMatrix4x4> m_rootMatrices; + + int m_added; + int m_transformChange; + int m_opacityChange; + + QMatrix4x4 m_identityMatrix; +}; + +struct GraphicsState +{ + bool depthTest = false; + bool depthWrite = false; + QRhiGraphicsPipeline::CompareOp depthFunc = QRhiGraphicsPipeline::Less; + bool blending = false; + QRhiGraphicsPipeline::BlendFactor srcColor = QRhiGraphicsPipeline::One; + QRhiGraphicsPipeline::BlendFactor dstColor = QRhiGraphicsPipeline::OneMinusSrcAlpha; + QRhiGraphicsPipeline::BlendFactor srcAlpha = QRhiGraphicsPipeline::One; + QRhiGraphicsPipeline::BlendFactor dstAlpha = QRhiGraphicsPipeline::OneMinusSrcAlpha; + QRhiGraphicsPipeline::BlendOp opColor = QRhiGraphicsPipeline::Add; + QRhiGraphicsPipeline::BlendOp opAlpha = QRhiGraphicsPipeline::Add; + QRhiGraphicsPipeline::ColorMask colorWrite = QRhiGraphicsPipeline::ColorMask(0xF); + QRhiGraphicsPipeline::CullMode cullMode = QRhiGraphicsPipeline::None; + bool usesScissor = false; + bool stencilTest = false; + int sampleCount = 1; + QSGGeometry::DrawingMode drawMode = QSGGeometry::DrawTriangles; + float lineWidth = 1.0f; + QRhiGraphicsPipeline::PolygonMode polygonMode = QRhiGraphicsPipeline::Fill; + int multiViewCount = 0; +}; + +bool operator==(const GraphicsState &a, const GraphicsState &b) noexcept; +bool operator!=(const GraphicsState &a, const GraphicsState &b) noexcept; +size_t qHash(const GraphicsState &s, size_t seed = 0) noexcept; + +struct ShaderManagerShader; + +struct GraphicsPipelineStateKey +{ + GraphicsState state; + const ShaderManagerShader *sms; + QVector<quint32> renderTargetDescription; + QVector<quint32> srbLayoutDescription; + struct { + size_t renderTargetDescriptionHash; + size_t srbLayoutDescriptionHash; + } extra; + static GraphicsPipelineStateKey create(const GraphicsState &state, + const ShaderManagerShader *sms, + const QRhiRenderPassDescriptor *rpDesc, + const QRhiShaderResourceBindings *srb) + { + const QVector<quint32> rtDesc = rpDesc->serializedFormat(); + const QVector<quint32> srbDesc = srb->serializedLayoutDescription(); + return { state, sms, rtDesc, srbDesc, { qHash(rtDesc), qHash(srbDesc) } }; + } +}; + +bool operator==(const GraphicsPipelineStateKey &a, const GraphicsPipelineStateKey &b) noexcept; +bool operator!=(const GraphicsPipelineStateKey &a, const GraphicsPipelineStateKey &b) noexcept; +size_t qHash(const GraphicsPipelineStateKey &k, size_t seed = 0) noexcept; + +struct ShaderKey +{ + QSGMaterialType *type; + QSGRendererInterface::RenderMode renderMode; + int multiViewCount; +}; + +bool operator==(const ShaderKey &a, const ShaderKey &b) noexcept; +bool operator!=(const ShaderKey &a, const ShaderKey &b) noexcept; +size_t qHash(const ShaderKey &k, size_t seed = 0) noexcept; + +struct ShaderManagerShader +{ + ~ShaderManagerShader() { + delete materialShader; + } + QSGMaterialShader *materialShader = nullptr; + QRhiVertexInputLayout inputLayout; + QVarLengthArray<QRhiShaderStage, 2> stages; + float lastOpacity; +}; + +class ShaderManager : public QObject +{ + Q_OBJECT +public: + using Shader = ShaderManagerShader; + + ShaderManager(QSGDefaultRenderContext *ctx) : context(ctx) { } + ~ShaderManager() { + qDeleteAll(rewrittenShaders); + qDeleteAll(stockShaders); + } + + void clearCachedRendererData(); + + QHash<GraphicsPipelineStateKey, QRhiGraphicsPipeline *> pipelineCache; + + QMultiHash<QVector<quint32>, QRhiShaderResourceBindings *> srbPool; + QVector<quint32> srbLayoutDescSerializeWorkspace; + +public Q_SLOTS: + void invalidated(); + +public: + Shader *prepareMaterial(QSGMaterial *material, + const QSGGeometry *geometry = nullptr, + QSGRendererInterface::RenderMode renderMode = QSGRendererInterface::RenderMode2D, + int multiViewCount = 0); + Shader *prepareMaterialNoRewrite(QSGMaterial *material, + const QSGGeometry *geometry = nullptr, + QSGRendererInterface::RenderMode renderMode = QSGRendererInterface::RenderMode2D, + int multiViewCount = 0); + +private: + QHash<ShaderKey, Shader *> rewrittenShaders; + QHash<ShaderKey, Shader *> stockShaders; + + QSGDefaultRenderContext *context; +}; + +struct RenderPassState +{ + QRhiViewport viewport; + QColor clearColor; + QRhiDepthStencilClearValue dsClear; + bool viewportSet; + bool scissorSet; +}; + +class Visualizer +{ +public: + enum VisualizeMode { + VisualizeNothing, + VisualizeBatches, + VisualizeClipping, + VisualizeChanges, + VisualizeOverdraw + }; + + Visualizer(Renderer *renderer); + virtual ~Visualizer(); + + VisualizeMode mode() const { return m_visualizeMode; } + void setMode(VisualizeMode mode) { m_visualizeMode = mode; } + + virtual void visualizeChangesPrepare(Node *n, uint parentChanges = 0); + virtual void prepareVisualize() = 0; + virtual void visualize() = 0; + + virtual void releaseResources() = 0; + +protected: + Renderer *m_renderer; + VisualizeMode m_visualizeMode; + QHash<Node *, uint> m_visualizeChangeSet; +}; + +class Q_QUICK_EXPORT Renderer : public QSGRenderer +{ +public: + Renderer(QSGDefaultRenderContext *ctx, QSGRendererInterface::RenderMode renderMode = QSGRendererInterface::RenderMode2D); + ~Renderer(); + +protected: + void nodeChanged(QSGNode *node, QSGNode::DirtyState state) override; + void render() override; + void prepareInline() override; + void renderInline() override; + void releaseCachedResources() override; + + struct PreparedRenderBatch { + const Batch *batch; + ShaderManager::Shader *sms; + }; + + struct RenderPassContext { + bool valid = false; + QVarLengthArray<PreparedRenderBatch, 64> opaqueRenderBatches; + QVarLengthArray<PreparedRenderBatch, 64> alphaRenderBatches; + QElapsedTimer timer; + quint64 timeRenderLists; + quint64 timePrepareOpaque; + quint64 timePrepareAlpha; + quint64 timeSorting; + quint64 timeUploadOpaque; + quint64 timeUploadAlpha; + }; + + // update batches and queue and commit rhi resource updates + void prepareRenderPass(RenderPassContext *ctx); + // records the beginPass() + void beginRenderPass(RenderPassContext *ctx); + // records the draw calls, must be preceded by a prepareRenderPass at minimum, + // and also surrounded by begin/endRenderPass unless we are recording inside an + // already started pass. + void recordRenderPass(RenderPassContext *ctx); + // does visualizing if enabled and records the endPass() + void endRenderPass(RenderPassContext *ctx); + +private: + enum RebuildFlag { + BuildRenderListsForTaggedRoots = 0x0001, + BuildRenderLists = 0x0002, + BuildBatches = 0x0004, + FullRebuild = 0xffff + }; + + friend class Updater; + friend class RhiVisualizer; + + void destroyGraphicsResources(); + void map(Buffer *buffer, quint32 byteSize, bool isIndexBuf = false); + void unmap(Buffer *buffer, bool isIndexBuf = false); + + void buildRenderListsFromScratch(); + void buildRenderListsForTaggedRoots(); + void tagSubRoots(Node *node); + void buildRenderLists(QSGNode *node); + + void deleteRemovedElements(); + void cleanupBatches(QDataBuffer<Batch *> *batches); + void prepareOpaqueBatches(); + bool checkOverlap(int first, int last, const Rect &bounds); + void prepareAlphaBatches(); + void invalidateBatchAndOverlappingRenderOrders(Batch *batch); + + void uploadBatch(Batch *b); + void uploadMergedElement(Element *e, int vaOffset, char **vertexData, char **zData, char **indexData, void *iBasePtr, int *indexCount); + + bool ensurePipelineState(Element *e, const ShaderManager::Shader *sms, bool depthPostPass = false); + QRhiTexture *dummyTexture(); + void updateMaterialDynamicData(ShaderManager::Shader *sms, QSGMaterialShader::RenderState &renderState, + QSGMaterial *material, const Batch *batch, Element *e, int ubufOffset, int ubufRegionSize, + char *directUpdatePtr); + void updateMaterialStaticData(ShaderManager::Shader *sms, QSGMaterialShader::RenderState &renderState, + QSGMaterial *material, Batch *batch, bool *gstateChanged); + void checkLineWidth(QSGGeometry *g); + bool prepareRenderMergedBatch(Batch *batch, PreparedRenderBatch *renderBatch); + void renderMergedBatch(PreparedRenderBatch *renderBatch, bool depthPostPass = false); + bool prepareRenderUnmergedBatch(Batch *batch, PreparedRenderBatch *renderBatch); + void renderUnmergedBatch(PreparedRenderBatch *renderBatch, bool depthPostPass = false); + void setGraphicsPipeline(QRhiCommandBuffer *cb, const Batch *batch, Element *e, bool depthPostPass = false); + ClipState::ClipType updateStencilClip(const QSGClipNode *clip); + void updateClip(const QSGClipNode *clipList, const Batch *batch); + void applyClipStateToGraphicsState(); + QRhiGraphicsPipeline *buildStencilPipeline(const Batch *batch, bool firstStencilClipInBatch); + void updateClipState(const QSGClipNode *clipList, Batch *batch); + void enqueueStencilDraw(const Batch *batch); + const QMatrix4x4 &matrixForRoot(Node *node); + void renderRenderNode(Batch *batch); + bool prepareRhiRenderNode(Batch *batch, PreparedRenderBatch *renderBatch); + void renderRhiRenderNode(const Batch *batch); + void setActiveShader(QSGMaterialShader *program, ShaderManager::Shader *shader); + void setActiveRhiShader(QSGMaterialShader *program, ShaderManager::Shader *shader); + + bool changeBatchRoot(Node *node, Node *newRoot); + void registerBatchRoot(Node *childRoot, Node *parentRoot); + void removeBatchRootFromParent(Node *childRoot); + void nodeChangedBatchRoot(Node *node, Node *root); + void turnNodeIntoBatchRoot(Node *node); + void nodeWasTransformed(Node *node, int *vertexCount); + void nodeWasRemoved(Node *node); + void nodeWasAdded(QSGNode *node, Node *shadowParent); + BatchRootInfo *batchRootInfo(Node *node); + void updateLineWidth(QSGGeometry *g); + + inline Batch *newBatch(); + void invalidateAndRecycleBatch(Batch *b); + void releaseElement(Element *e, bool inDestructor = false); + + void setVisualizationMode(const QByteArray &mode) override; + bool hasVisualizationModeWithContinuousUpdate() const override; + + QSGDefaultRenderContext *m_context; + QSGRendererInterface::RenderMode m_renderMode; + QSet<Node *> m_taggedRoots; + QDataBuffer<Element *> m_opaqueRenderList; + QDataBuffer<Element *> m_alphaRenderList; + int m_nextRenderOrder; + bool m_partialRebuild; + QSGNode *m_partialRebuildRoot; + bool m_forceNoDepthBuffer; + + QHash<QSGRenderNode *, RenderNodeElement *> m_renderNodeElements; + QDataBuffer<Batch *> m_opaqueBatches; + QDataBuffer<Batch *> m_alphaBatches; + QHash<QSGNode *, Node *> m_nodes; + + QDataBuffer<Batch *> m_batchPool; + QDataBuffer<Element *> m_elementsToDelete; + QDataBuffer<Element *> m_tmpAlphaElements; + QDataBuffer<Element *> m_tmpOpaqueElements; + + QDataBuffer<QRhiBuffer *> m_vboPool; + QDataBuffer<QRhiBuffer *> m_iboPool; + quint32 m_vboPoolCost; + quint32 m_iboPoolCost; + + uint m_rebuild; + qreal m_zRange; +#if defined(QSGBATCHRENDERER_INVALIDATE_WEDGED_NODES) + int m_renderOrderRebuildLower; + int m_renderOrderRebuildUpper; +#endif + + int m_batchNodeThreshold; + int m_batchVertexThreshold; + int m_srbPoolThreshold; + int m_bufferPoolSizeLimit; + + Visualizer *m_visualizer; + + ShaderManager *m_shaderManager; // per rendercontext, shared + QSGMaterial *m_currentMaterial; + QSGMaterialShader *m_currentProgram; + ShaderManager::Shader *m_currentShader; + ClipState m_currentClipState; + + QDataBuffer<char> m_vertexUploadPool; + QDataBuffer<char> m_indexUploadPool; + + Allocator<Node, 256> m_nodeAllocator; + Allocator<Element, 64> m_elementAllocator; + + RenderPassContext m_mainRenderPassContext; + QRhiResourceUpdateBatch *m_resourceUpdates = nullptr; + uint m_ubufAlignment; + bool m_uint32IndexForRhi; + GraphicsState m_gstate; + RenderPassState m_pstate; + QStack<GraphicsState> m_gstateStack; + QHash<QSGSamplerDescription, QRhiSampler *> m_samplers; + QRhiTexture *m_dummyTexture = nullptr; + + struct StencilClipCommonData { + QRhiGraphicsPipeline *replacePs = nullptr; + QRhiGraphicsPipeline *incrPs = nullptr; + QShader vs; + QShader fs; + QRhiVertexInputLayout inputLayout; + QRhiGraphicsPipeline::Topology topology; + inline void reset(); + } m_stencilClipCommon; + + inline int mergedIndexElemSize() const; + inline bool useDepthBuffer() const; + inline void setStateForDepthPostPass(); +}; + +Batch *Renderer::newBatch() +{ + Batch *b; + int size = m_batchPool.size(); + if (size) { + b = m_batchPool.at(size - 1); + // vbo, ibo, ubuf, stencil-related buffers are reused + m_batchPool.resize(size - 1); + } else { + b = new Batch(); + Q_ASSERT(offsetof(Batch, ibo) == sizeof(Buffer) + offsetof(Batch, vbo)); + memset(&b->vbo, 0, sizeof(Buffer) * 2); // Clear VBO & IBO + b->ubuf = nullptr; + b->stencilClipState.reset(); + } + // initialize (when new batch) or reset (when reusing a batch) the non-reusable fields + b->init(); + return b; +} + +int Renderer::mergedIndexElemSize() const +{ + return m_uint32IndexForRhi ? sizeof(quint32) : sizeof(quint16); +} + +// "use" here means that both depth test and write is wanted (the latter for +// opaque batches only). Therefore neither RenderMode2DNoDepthBuffer nor +// RenderMode3D must result in true. So while RenderMode3D requires a depth +// buffer, this here must say false. In addition, m_forceNoDepthBuffer is a +// dynamic override relevant with QSGRenderNode. +// +bool Renderer::useDepthBuffer() const +{ + return !m_forceNoDepthBuffer && m_renderMode == QSGRendererInterface::RenderMode2D; +} + +void Renderer::setStateForDepthPostPass() +{ + m_gstate.colorWrite = {}; + m_gstate.depthWrite = true; + m_gstate.depthTest = true; + m_gstate.depthFunc = QRhiGraphicsPipeline::Less; +} + +void Renderer::StencilClipCommonData::reset() +{ + delete replacePs; + replacePs = nullptr; + + delete incrPs; + incrPs = nullptr; + + vs = QShader(); + fs = QShader(); +} + +void ClipState::reset() +{ + clipList = nullptr; + type = NoClip; + stencilRef = 0; +} + +void StencilClipState::reset() +{ + updateStencilBuffer = false; + + delete srb; + srb = nullptr; + + delete vbuf; + vbuf = nullptr; + + delete ibuf; + ibuf = nullptr; + + delete ubuf; + ubuf = nullptr; + + drawCalls.reset(); +} + +} + +Q_DECLARE_TYPEINFO(QSGBatchRenderer::GraphicsState, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QSGBatchRenderer::GraphicsPipelineStateKey, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QSGBatchRenderer::RenderPassState, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(QSGBatchRenderer::DrawSet, Q_PRIMITIVE_TYPE); + +QT_END_NAMESPACE + +#endif // QSGBATCHRENDERER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcompressedatlastexture_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcompressedatlastexture_p.h new file mode 100644 index 0000000000000000000000000000000000000000..23c06447a1ec1c0ff9199e35e32e8cb2a9747f77 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcompressedatlastexture_p.h @@ -0,0 +1,79 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCOMPRESSEDATLASTEXTURE_P_H +#define QSGCOMPRESSEDATLASTEXTURE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/QSize> + +#include <QtQuick/QSGTexture> +#include <QtQuick/private/qsgareaallocator_p.h> +#include <QtQuick/private/qsgrhiatlastexture_p.h> + +QT_BEGIN_NAMESPACE + +class QSGCompressedTextureFactory; + +namespace QSGCompressedAtlasTexture { + +class Texture; + +class Atlas : public QSGRhiAtlasTexture::AtlasBase +{ +public: + Atlas(QSGDefaultRenderContext *rc, const QSize &size, uint format); + ~Atlas(); + + bool generateTexture() override; + void enqueueTextureUpload(QSGRhiAtlasTexture::TextureBase *t, + QRhiResourceUpdateBatch *rcub) override; + + Texture *create(QByteArrayView data, const QSize &size); + + uint format() const { return m_format; } + +private: + uint m_format; +}; + +class Texture : public QSGRhiAtlasTexture::TextureBase +{ + Q_OBJECT +public: + Texture(Atlas *atlas, const QRect &textureRect, QByteArrayView data, const QSize &size); + ~Texture(); + + QSize textureSize() const override { return m_size; } + bool hasAlphaChannel() const override; + bool hasMipmaps() const override { return false; } + + QRectF normalizedTextureSubRect() const override { return m_texture_coords_rect; } + + QSGTexture *removedFromAtlas(QRhiResourceUpdateBatch *) const override; + + const QByteArray &data() const { return m_data; } + int sizeInBytes() const { return m_data.size(); } + +private: + QRectF m_texture_coords_rect; + mutable QSGTexture *m_nonatlas_texture; + QByteArray m_data; + QSize m_size; +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcompressedtexture_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcompressedtexture_p.h new file mode 100644 index 0000000000000000000000000000000000000000..716f0493db3f29c4474a7ff0a896ec843be89679 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcompressedtexture_p.h @@ -0,0 +1,82 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCOMPRESSEDTEXTURE_P_H +#define QSGCOMPRESSEDTEXTURE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtexturefiledata_p.h> +#include <private/qsgcontext_p.h> +#include <private/qsgtexture_p.h> +#include <rhi/qrhi.h> +#include <QQuickTextureFactory> +#include <QOpenGLFunctions> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TEXTUREIO); + +class Q_QUICK_EXPORT QSGCompressedTexture : public QSGTexture +{ + Q_OBJECT +public: + QSGCompressedTexture(const QTextureFileData& texData); + virtual ~QSGCompressedTexture(); + + QSize textureSize() const override; + bool hasAlphaChannel() const override; + bool hasMipmaps() const override; + + qint64 comparisonKey() const override; + QRhiTexture *rhiTexture() const override; + void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override; + + QTextureFileData textureData() const; + + struct FormatInfo + { + QRhiTexture::Format rhiFormat; + bool isSRGB; + }; + static FormatInfo formatInfo(quint32 glTextureFormat); + static bool formatIsOpaque(quint32 glTextureFormat); + +protected: + QTextureFileData m_textureData; + QSize m_size; + QRhiTexture *m_texture = nullptr; + bool m_hasAlpha = false; + bool m_uploaded = false; +}; + +namespace QSGOpenGLAtlasTexture { + class Manager; +} + +class Q_QUICK_EXPORT QSGCompressedTextureFactory : public QQuickTextureFactory +{ +public: + QSGCompressedTextureFactory(const QTextureFileData& texData); + QSGTexture *createTexture(QQuickWindow *) const override; + int textureByteCount() const override; + QSize textureSize() const override; + + const QTextureFileData *textureData() const { return &m_textureData; } + +protected: + QTextureFileData m_textureData; +}; + +QT_END_NAMESPACE + +#endif // QSGCOMPRESSEDTEXTURE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcontext_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcontext_p.h new file mode 100644 index 0000000000000000000000000000000000000000..979a897e6e7bc10e57dde35b706272e3253a92aa --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcontext_p.h @@ -0,0 +1,238 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCONTEXT_H +#define QSGCONTEXT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/QObject> +#include <QtCore/qabstractanimation.h> +#include <QtCore/QMutex> + +#include <QtGui/QImage> +#include <QtGui/QSurfaceFormat> + +#include <private/qtquickglobal_p.h> +#include <private/qrawfont_p.h> +#include <private/qfontengine_p.h> + +#include <QtQuick/qsgnode.h> +#include <QtQuick/qsgrendererinterface.h> +#include <QtQuick/qsgtextnode.h> + +#include <QtCore/qpointer.h> + +QT_BEGIN_NAMESPACE + +class QSGContextPrivate; +class QSGInternalRectangleNode; +class QSGInternalImageNode; +class QSGInternalTextNode; +class QSGPainterNode; +class QSGGlyphNode; +class QSGRenderer; +class QSGDistanceFieldGlyphCache; +class QQuickWindow; +class QSGTexture; +class QSGMaterial; +class QSGRenderLoop; +class QSGLayer; +class QQuickTextureFactory; +class QSGCompressedTextureFactory; +class QSGContext; +class QQuickPaintedItem; +class QSGRendererInterface; +class QSGShaderEffectNode; +class QSGGuiThreadShaderEffectManager; +class QSGRectangleNode; +class QSGTextNode; +class QSGImageNode; +class QSGNinePatchNode; +class QSGSpriteNode; +class QSGRenderContext; +class QSGRenderTarget; +class QRhi; +class QRhiRenderTarget; +class QRhiRenderPassDescriptor; +class QRhiCommandBuffer; +class QQuickGraphicsConfiguration; +class QQuickItem; +class QSGCurveGlyphAtlas; + +Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_RENDERLOOP) +Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_COMPILATION) +Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_TEXTURE) +Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_GLYPH) +Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_RENDERER) + +Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_INFO) +Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_RENDERLOOP) + +class Q_QUICK_EXPORT QSGContext : public QObject +{ + Q_OBJECT + +public: + enum AntialiasingMethod { + UndecidedAntialiasing, + VertexAntialiasing, + MsaaAntialiasing + }; + + explicit QSGContext(QObject *parent = nullptr); + ~QSGContext() override; + + virtual void renderContextInitialized(QSGRenderContext *renderContext); + virtual void renderContextInvalidated(QSGRenderContext *renderContext); + virtual QSGRenderContext *createRenderContext() = 0; + + QSGInternalRectangleNode *createInternalRectangleNode(const QRectF &rect, const QColor &c); + virtual QSGInternalRectangleNode *createInternalRectangleNode() = 0; + virtual QSGInternalImageNode *createInternalImageNode(QSGRenderContext *renderContext) = 0; + virtual QSGInternalTextNode *createInternalTextNode(QSGRenderContext *renderContext); + virtual QSGPainterNode *createPainterNode(QQuickPaintedItem *item) = 0; + virtual QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, QSGTextNode::RenderType renderType, int renderTypeQuality) = 0; + virtual QSGLayer *createLayer(QSGRenderContext *renderContext) = 0; + virtual QSGGuiThreadShaderEffectManager *createGuiThreadShaderEffectManager(); + virtual QSGShaderEffectNode *createShaderEffectNode(QSGRenderContext *renderContext); +#if QT_CONFIG(quick_sprite) + virtual QSGSpriteNode *createSpriteNode() = 0; +#endif + virtual QAnimationDriver *createAnimationDriver(QObject *parent); + virtual float vsyncIntervalForAnimationDriver(QAnimationDriver *driver); + virtual bool isVSyncDependent(QAnimationDriver *driver); + + virtual QSize minimumFBOSize() const; + virtual QSurfaceFormat defaultSurfaceFormat() const = 0; + + virtual QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext); + + virtual QSGTextNode *createTextNode(QSGRenderContext *renderContext); + virtual QSGRectangleNode *createRectangleNode() = 0; + virtual QSGImageNode *createImageNode() = 0; + virtual QSGNinePatchNode *createNinePatchNode() = 0; + + static QSGContext *createDefaultContext(); + static QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image); + static QSGRenderLoop *createWindowManager(); + + static void setBackend(const QString &backend); + static QString backend(); +}; + +class Q_QUICK_EXPORT QSGRenderContext : public QObject +{ + Q_OBJECT +public: + enum CreateTextureFlags { + CreateTexture_Alpha = 0x1, + CreateTexture_Atlas = 0x2, + CreateTexture_Mipmap = 0x4 + }; + + QSGRenderContext(QSGContext *context); + ~QSGRenderContext() override; + + QSGContext *sceneGraphContext() const { return m_sg; } + virtual bool isValid() const { return true; } + + struct InitParams { }; + virtual void initialize(const InitParams *params); + virtual void invalidate(); + + using RenderPassCallback = void (*)(void *); + + virtual void prepareSync(qreal devicePixelRatio, + QRhiCommandBuffer *cb, + const QQuickGraphicsConfiguration &config); + + virtual void beginNextFrame(QSGRenderer *renderer, const QSGRenderTarget &renderTarget, + RenderPassCallback mainPassRecordingStart, + RenderPassCallback mainPassRecordingEnd, + void *callbackUserData); + virtual void renderNextFrame(QSGRenderer *renderer) = 0; + virtual void endNextFrame(QSGRenderer *renderer); + + virtual void endSync(); + + virtual void preprocess(); + virtual void invalidateGlyphCaches(); + virtual QSGDistanceFieldGlyphCache *distanceFieldGlyphCache(const QRawFont &font, int renderTypeQuality); + virtual QSGCurveGlyphAtlas *curveGlyphAtlas(const QRawFont &font); + QSGTexture *textureForFactory(QQuickTextureFactory *factory, QQuickWindow *window); + + virtual QSGTexture *createTexture(const QImage &image, uint flags = CreateTexture_Alpha) const = 0; + virtual QSGRenderer *createRenderer(QSGRendererInterface::RenderMode renderMode = QSGRendererInterface::RenderMode2D) = 0; + virtual QSGTexture *compressedTextureForFactory(const QSGCompressedTextureFactory *) const; + + virtual int maxTextureSize() const = 0; + + void unregisterFontengineForCleanup(QFontEngine *engine); + void registerFontengineForCleanup(QFontEngine *engine); + + virtual QRhi *rhi() const; + +Q_SIGNALS: + void initialized(); + void invalidated(); + void releaseCachedResourcesRequested(); + +public Q_SLOTS: + void textureFactoryDestroyed(QObject *o); + +protected: + struct FontKey { + FontKey(const QRawFont &font, int renderTypeQuality); + + QFontEngine::FaceId faceId; + QFont::Style style; + int weight; + int renderTypeQuality; + QString familyName; + QString styleName; + }; + friend bool operator==(const QSGRenderContext::FontKey &f1, const QSGRenderContext::FontKey &f2); + friend size_t qHash(const QSGRenderContext::FontKey &f, size_t seed); + + // Hold m_sg with QPointer in the rare case it gets deleted before us. + QPointer<QSGContext> m_sg; + + QMutex m_mutex; + QHash<QObject *, QSGTexture *> m_textures; + QSet<QSGTexture *> m_texturesToDelete; + QHash<FontKey, QSGDistanceFieldGlyphCache *> m_glyphCaches; + + // References to font engines that are currently in use by native rendering glyph nodes + // and which must be kept alive as long as they are used in the render thread. + QHash<QFontEngine *, int> m_fontEnginesToClean; +}; + +inline bool operator ==(const QSGRenderContext::FontKey &f1, const QSGRenderContext::FontKey &f2) +{ + return f1.faceId == f2.faceId + && f1.style == f2.style + && f1.weight == f2.weight + && f1.renderTypeQuality == f2.renderTypeQuality + && f1.familyName == f2.familyName + && f1.styleName == f2.styleName; +} + +inline size_t qHash(const QSGRenderContext::FontKey &f, size_t seed = 0) +{ + return qHashMulti(seed, f.faceId, f.renderTypeQuality, f.familyName, f.styleName, f.style, f.weight); +} + + +QT_END_NAMESPACE + +#endif // QSGCONTEXT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcontextplugin_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcontextplugin_p.h new file mode 100644 index 0000000000000000000000000000000000000000..aeab65d37f283a9ecd48f7ce3bd6d705dab68c14 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcontextplugin_p.h @@ -0,0 +1,65 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCONTEXTPLUGIN_H +#define QSGCONTEXTPLUGIN_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> +#include <QtQuick/qquickimageprovider.h> +#include <QtCore/qplugin.h> +#include <QtCore/qfactoryinterface.h> + +QT_BEGIN_NAMESPACE + +class QSGContext; + +class QSGRenderLoop; + +struct Q_QUICK_EXPORT QSGContextFactoryInterface : public QFactoryInterface +{ + enum Flag { + SupportsShaderEffectNode = 0x01 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + virtual QSGContext *create(const QString &key) const = 0; + virtual Flags flags(const QString &key) const = 0; + + virtual QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image) = 0; + virtual QSGRenderLoop *createWindowManager() = 0; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QSGContextFactoryInterface::Flags) + +#define QSGContextFactoryInterface_iid \ + "org.qt-project.Qt.QSGContextFactoryInterface" +Q_DECLARE_INTERFACE(QSGContextFactoryInterface, QSGContextFactoryInterface_iid) + +class Q_QUICK_EXPORT QSGContextPlugin : public QObject, public QSGContextFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QSGContextFactoryInterface:QFactoryInterface) +public: + explicit QSGContextPlugin(QObject *parent = nullptr); + virtual ~QSGContextPlugin(); + + QStringList keys() const override = 0; + + QQuickTextureFactory *createTextureFactoryFromImage(const QImage &) override { return nullptr; } + QSGRenderLoop *createWindowManager() override { return nullptr; } +}; + +QT_END_NAMESPACE + +#endif // QSGCONTEXTPLUGIN_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveabstractnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveabstractnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a6af83bdacee9e9bdaf16fa9881a161af65fdc7b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveabstractnode_p.h @@ -0,0 +1,33 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCURVEABSTRACTNODE_P_H +#define QSGCURVEABSTRACTNODE_P_H + +#include <QtGui/qcolor.h> +#include <QtQuick/qsgnode.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QSGCurveAbstractNode : public QSGGeometryNode +{ +public: + virtual void setColor(QColor col) = 0; + virtual void cookGeometry() = 0; + bool isDebugNode = false; +}; + +QT_END_NAMESPACE + +#endif // QSGCURVEABSTRACTNODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvefillnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvefillnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..857b6124835ac757021f2aae8fc0022d9aa64d8a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvefillnode_p.h @@ -0,0 +1,273 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCURVEFILLNODE_P_H +#define QSGCURVEFILLNODE_P_H + +#include <QtGui/qbrush.h> + +#include <QtQuick/qtquickexports.h> +#include <QtQuick/private/qsggradientcache_p.h> +#include <QtQuick/private/qsgtransform_p.h> +#include <QtQuick/qsgnode.h> +#include <QtQuick/qsgtextureprovider.h> + +#include "qsgcurveabstractnode_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QSGTextureProvider; + +class Q_QUICK_EXPORT QSGCurveFillNode : public QObject, public QSGCurveAbstractNode +{ + Q_OBJECT +public: + QSGCurveFillNode(); + + void setColor(QColor col) override + { + m_color = col; + markDirty(DirtyMaterial); + } + + QColor color() const + { + return m_color; + } + + void setFillTextureProvider(QSGTextureProvider *provider) + { + if (provider == m_textureProvider) + return; + + if (m_textureProvider != nullptr) { + disconnect(m_textureProvider, &QSGTextureProvider::textureChanged, + this, &QSGCurveFillNode::handleTextureChanged); + disconnect(m_textureProvider, &QSGTextureProvider::destroyed, + this, &QSGCurveFillNode::handleTextureProviderDestroyed); + } + + m_textureProvider = provider; + markDirty(DirtyMaterial); + + if (m_textureProvider != nullptr) { + connect(m_textureProvider, &QSGTextureProvider::textureChanged, + this, &QSGCurveFillNode::handleTextureChanged); + connect(m_textureProvider, &QSGTextureProvider::destroyed, + this, &QSGCurveFillNode::handleTextureProviderDestroyed); + } + } + + + QSGTextureProvider *fillTextureProvider() const + { + return m_textureProvider; + } + + void setFillGradient(const QSGGradientCache::GradientDesc &fillGradient) + { + m_fillGradient = fillGradient; + markDirty(DirtyMaterial); + } + + const QSGGradientCache::GradientDesc *fillGradient() const + { + return &m_fillGradient; + } + + void setGradientType(QGradient::Type type) + { + m_gradientType = type; + markDirty(DirtyMaterial); + } + + QGradient::Type gradientType() const + { + return m_gradientType; + } + + void setFillTransform(const QSGTransform &transform) + { + m_fillTransform = transform; + markDirty(DirtyMaterial); + } + + const QSGTransform *fillTransform() const + { + return &m_fillTransform; + } + + float debug() const + { + return m_debug; + } + + void setDebug(float newDebug) + { + m_debug = newDebug; + } + + void appendTriangle(const std::array<QVector2D, 3> &v, // triangle vertices + const std::array<QVector2D, 3> &n, // vertex normals + std::function<QVector3D(QVector2D)> uvForPoint + ) + { + QVector3D uv1 = uvForPoint(v[0]); + QVector3D uv2 = uvForPoint(v[1]); + QVector3D uv3 = uvForPoint(v[2]); + + QVector2D duvdx = QVector2D(uvForPoint(v[0] + QVector2D(1, 0))) - QVector2D(uv1); + QVector2D duvdy = QVector2D(uvForPoint(v[0] + QVector2D(0, 1))) - QVector2D(uv1); + + m_uncookedIndexes.append(m_uncookedVertexes.size()); + m_uncookedVertexes.append( { v[0].x(), v[0].y(), + uv1.x(), uv1.y(), uv1.z(), + duvdx.x(), duvdx.y(), + duvdy.x(), duvdy.y(), + n[0].x(), n[0].y() + }); + + m_uncookedIndexes.append(m_uncookedVertexes.size()); + m_uncookedVertexes.append( { v[1].x(), v[1].y(), + uv2.x(), uv2.y(), uv2.z(), + duvdx.x(), duvdx.y(), + duvdy.x(), duvdy.y(), + n[1].x(), n[1].y() + }); + + m_uncookedIndexes.append(m_uncookedVertexes.size()); + m_uncookedVertexes.append( { v[2].x(), v[2].y(), + uv3.x(), uv3.y(), uv3.z(), + duvdx.x(), duvdx.y(), + duvdy.x(), duvdy.y(), + n[2].x(), n[2].y() + }); + } + + void appendTriangle(const QVector2D &v1, + const QVector2D &v2, + const QVector2D &v3, + const QVector3D &uv1, + const QVector3D &uv2, + const QVector3D &uv3, + const QVector2D &n1, + const QVector2D &n2, + const QVector2D &n3, + const QVector2D &duvdx, + const QVector2D &duvdy) + { + m_uncookedIndexes.append(m_uncookedVertexes.size()); + m_uncookedVertexes.append( { v1.x(), v1.y(), + uv1.x(), uv1.y(), uv1.z(), + duvdx.x(), duvdx.y(), + duvdy.x(), duvdy.y(), + n1.x(), n1.y() + }); + + m_uncookedIndexes.append(m_uncookedVertexes.size()); + m_uncookedVertexes.append( { v2.x(), v2.y(), + uv2.x(), uv2.y(), uv2.z(), + duvdx.x(), duvdx.y(), + duvdy.x(), duvdy.y(), + n2.x(), n2.y() + }); + + m_uncookedIndexes.append(m_uncookedVertexes.size()); + m_uncookedVertexes.append( { v3.x(), v3.y(), + uv3.x(), uv3.y(), uv3.z(), + duvdx.x(), duvdx.y(), + duvdy.x(), duvdy.y(), + n3.x(), n3.y() + }); + } + + void appendTriangle(const QVector2D &v1, + const QVector2D &v2, + const QVector2D &v3, + std::function<QVector3D(QVector2D)> uvForPoint) + { + appendTriangle({v1, v2, v3}, {}, uvForPoint); + } + + QVector<quint32> uncookedIndexes() const + { + return m_uncookedIndexes; + } + + void cookGeometry() override; + + void reserve(qsizetype size) + { + m_uncookedIndexes.reserve(size); + m_uncookedVertexes.reserve(size); + } + + void preprocess() override + { + if (m_textureProvider != nullptr) { + if (QSGDynamicTexture *texture = qobject_cast<QSGDynamicTexture *>(m_textureProvider->texture())) + texture->updateTexture(); + } + } + + QVector2D boundsSize() const + { + return m_boundsSize; + } + + void setBoundsSize(const QVector2D &boundsSize) + { + m_boundsSize = boundsSize; + } + +private Q_SLOTS: + void handleTextureChanged() + { + markDirty(DirtyMaterial); + } + + void handleTextureProviderDestroyed() + { + m_textureProvider = nullptr; + markDirty(DirtyMaterial); + } + +private: + struct CurveNodeVertex + { + float x, y, u, v, w; + float dudx, dvdx, dudy, dvdy; // Size of pixel in curve space (must be same for all vertices in triangle) + float nx, ny; // normal vector describing the direction to shift the vertex for AA + }; + + void updateMaterial(); + static const QSGGeometry::AttributeSet &attributes(); + + QScopedPointer<QSGMaterial> m_material; + + QVector<CurveNodeVertex> m_uncookedVertexes; + QVector<quint32> m_uncookedIndexes; + + QSGGradientCache::GradientDesc m_fillGradient; + QSGTextureProvider *m_textureProvider = nullptr; + QVector2D m_boundsSize; + QSGTransform m_fillTransform; + QColor m_color = Qt::white; + QGradient::Type m_gradientType = QGradient::NoGradient; + float m_debug = 0.0f; +}; + +QT_END_NAMESPACE + +#endif // QSGCURVEFILLNODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvefillnode_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvefillnode_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..768ae3856f752a57273711eb8139c7c35628c63a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvefillnode_p_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCURVEFILLNODE_P_P_H +#define QSGCURVEFILLNODE_P_P_H + +#include <QtQuick/qtquickexports.h> +#include <QtQuick/qsgmaterial.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QSGCurveFillNode; +class QSGPlainTexture; +class Q_QUICK_EXPORT QSGCurveFillMaterial : public QSGMaterial +{ +public: + QSGCurveFillMaterial(QSGCurveFillNode *node); + ~QSGCurveFillMaterial() override; + int compare(const QSGMaterial *other) const override; + + QSGCurveFillNode *node() const + { + return m_node; + } + + QSGPlainTexture *dummyTexture() const + { + return m_dummyTexture; + } + + void setDummyTexture(QSGPlainTexture *dummyTexture) + { + m_dummyTexture = dummyTexture; + } + +private: + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; + + QSGCurveFillNode *m_node; + QSGPlainTexture *m_dummyTexture = nullptr; +}; + +QT_END_NAMESPACE + +#endif // QSGCURVEFILLNODE_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveglyphatlas_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveglyphatlas_p.h new file mode 100644 index 0000000000000000000000000000000000000000..93969ab83c95f6dcb9cc7419eac3b9bd275de8d2 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveglyphatlas_p.h @@ -0,0 +1,69 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCURVEGLYPHATLAS_P_H +#define QSGCURVEGLYPHATLAS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qrawfont.h> +#include <QtGui/private/qtextengine_p.h> +#include <QtQuick/qtquickexports.h> + +QT_BEGIN_NAMESPACE + +class QSGCurveFillNode; +class QSGCurveStrokeNode; + +class Q_QUICK_EXPORT QSGCurveGlyphAtlas +{ +public: + QSGCurveGlyphAtlas(const QRawFont &font); + virtual ~QSGCurveGlyphAtlas(); + + void populate(const QList<glyph_t> &glyphs); + void addGlyph(QSGCurveFillNode *node, + glyph_t glyph, + const QPointF &position, + qreal pixelSize) const; + void addStroke(QSGCurveStrokeNode *node, + glyph_t glyph, + const QPointF &position) const; + + qreal fontSize() const + { + return m_font.pixelSize(); + } + +private: + struct Glyph + { + QList<QVector2D> vertices; + QList<QVector3D> uvs; + QList<QVector2D> normals; + QList<QVector2D> duvdx; + QList<QVector2D> duvdy; + + QList<QVector2D> strokeVertices; + QList<QVector2D> strokeUvs; + QList<QVector2D> strokeNormals; + QList<bool> strokeElementIsLine; + }; + + QHash<glyph_t, Glyph> m_glyphs; + QRawFont m_font; +}; + +QT_END_NAMESPACE + + +#endif // QSGCURVEGLYPHATLAS_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveglyphnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveglyphnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..da6816569867102005602f43eb1066ff38a59fb0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveglyphnode_p.h @@ -0,0 +1,68 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCURVEGLYPHNODE_P_H +#define QSGCURVEGLYPHNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qtquickexports.h> +#include <private/qsgadaptationlayer_p.h> +#include <private/qsgbasicglyphnode_p.h> + +QT_BEGIN_NAMESPACE + +class QSGCurveGlyphAtlas; +class QSGCurveFillNode; +class QSGCurveAbstractNode; + +class Q_QUICK_EXPORT QSGCurveGlyphNode : public QSGGlyphNode +{ +public: + QSGCurveGlyphNode(QSGRenderContext *context); + ~QSGCurveGlyphNode(); + void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override; + void update() override; + void preprocess() override; + void setPreferredAntialiasingMode(AntialiasingMode) override; + void updateGeometry(); + void setColor(const QColor &color) override; + void setStyle(QQuickText::TextStyle style) override; + + void setStyleColor(const QColor &color) override; + QPointF baseLine() const override { return m_baseLine; } + +private: + QSGRenderContext *m_context; + QSGGeometry m_geometry; + QColor m_color = Qt::black; + + struct GlyphInfo { + QVector<quint32> indexes; + QVector<QPointF> positions; + }; + + uint m_dirtyGeometry: 1; + qreal m_fontSize = 0.0f; + QGlyphRun m_glyphs; + QQuickText::TextStyle m_style; + QColor m_styleColor; + QPointF m_baseLine; + QPointF m_position; + + QSGCurveFillNode *m_glyphNode = nullptr; + QSGCurveAbstractNode *m_styleNode = nullptr; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveprocessor_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveprocessor_p.h new file mode 100644 index 0000000000000000000000000000000000000000..287267c970e139204e289f3718662cb9195078b6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurveprocessor_p.h @@ -0,0 +1,53 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCURVEPROCESSOR_P_H +#define QSGCURVEPROCESSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/qtquickexports.h> +#include "util/qquadpath_p.h" + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGCurveProcessor +{ +public: + typedef std::function<QVector3D(QVector2D)> uvForPointCallback; + typedef std::function<void(const std::array<QVector2D, 3> &, + const std::array<QVector2D, 3> &, + uvForPointCallback)> addTriangleCallback; + typedef std::function<void(const std::array<QVector2D, 3> &, + const std::array<QVector2D, 3> &, + const std::array<QVector2D, 3> &, + bool)> addStrokeTriangleCallback; + + static void processFill(const QQuadPath &path, + Qt::FillRule fillRule, + addTriangleCallback addTriangle); + static void processStroke(const QQuadPath &strokePath, + float miterLimit, + float penWidth, + Qt::PenJoinStyle joinStyle, + Qt::PenCapStyle capStyle, + addStrokeTriangleCallback addTriangle, + int subdivisions = 3); + static bool solveOverlaps(QQuadPath &path); + static QList<QPair<int, int>> findOverlappingCandidates(const QQuadPath &path); + static bool removeNestedSubpaths(QQuadPath &path); + static bool solveIntersections(QQuadPath &path, bool removeNestedPaths = true); +}; + +QT_END_NAMESPACE + +#endif // QSGCURVEPROCESSOR_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvestrokenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvestrokenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..4d828f61a4d79fc06210a561f9958a6915e34372 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvestrokenode_p.h @@ -0,0 +1,116 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCURVESTROKENODE_P_H +#define QSGCURVESTROKENODE_P_H + +#include <QtQuick/qtquickexports.h> +#include <QtQuick/qsgnode.h> + +#include "qsgcurveabstractnode_p.h" +#include "qsgcurvestrokenode_p_p.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGCurveStrokeNode : public QSGCurveAbstractNode +{ +public: + QSGCurveStrokeNode(); + + void setColor(QColor col) override + { + m_color = col; + } + + QColor color() const + { + return m_color; + } + + void setStrokeWidth(float width) + { + m_strokeWidth = width; + } + + float strokeWidth() const + { + return m_strokeWidth; + } + + void appendTriangle(const std::array<QVector2D, 3> &v, // triangle vertices + const std::array<QVector2D, 3> &p, // curve points + const std::array<QVector2D, 3> &n); // vertex normals + void appendTriangle(const std::array<QVector2D, 3> &v, // triangle vertices + const std::array<QVector2D, 2> &p, // line points + const std::array<QVector2D, 3> &n); // vertex normals + + void cookGeometry() override; + + static const QSGGeometry::AttributeSet &attributes(); + + QVector<quint32> uncookedIndexes() const + { + return m_uncookedIndexes; + } + + float debug() const + { + return m_debug; + } + + void setDebug(float newDebug) + { + m_debug = newDebug; + } + + void setLocalScale(float scale) + { + m_localScale = scale; + } + + float localScale() const + { + return m_localScale; + } + +private: + + struct StrokeVertex + { + float x, y; + float ax, ay; + float bx, by; + float cx, cy; + float nx, ny; //normal vector: direction to move vertext to account for AA + }; + + void updateMaterial(); + + static std::array<QVector2D, 3> curveABC(const std::array<QVector2D, 3> &p); + + QColor m_color; + float m_strokeWidth = 0.0f; + float m_debug = 0.0f; + float m_localScale = 1.0f; + +protected: + QScopedPointer<QSGCurveStrokeMaterial> m_material; + + QVector<StrokeVertex> m_uncookedVertexes; + QVector<quint32> m_uncookedIndexes; +}; + +QT_END_NAMESPACE + +#endif // QSGCURVESTROKENODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvestrokenode_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvestrokenode_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..33aaafc73f8561a94c547de8322252b52b9c2fdf --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgcurvestrokenode_p_p.h @@ -0,0 +1,75 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGCURVESTROKENODE_P_P_H +#define QSGCURVESTROKENODE_P_P_H + +#include <QtQuick/qtquickexports.h> +#include <QtQuick/qsgmaterial.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QSGCurveStrokeNode; +class QSGCurveStrokeMaterial; + +class Q_QUICK_EXPORT QSGCurveStrokeMaterialShader : public QSGMaterialShader +{ +public: + QSGCurveStrokeMaterialShader(int viewCount) + { + setShaderFileName(VertexStage, + QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/shapestroke.vert.qsb"), + viewCount); + setShaderFileName(FragmentStage, + QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/shapestroke.frag.qsb"), + viewCount); + } + + bool updateUniformData(RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; +}; + + +class Q_QUICK_EXPORT QSGCurveStrokeMaterial : public QSGMaterial +{ +public: + QSGCurveStrokeMaterial(QSGCurveStrokeNode *node) + : m_node(node) + { + setFlag(Blending, true); + } + + int compare(const QSGMaterial *other) const override; + + QSGCurveStrokeNode *node() const + { + return m_node; + } + +protected: + QSGMaterialType *type() const override + { + static QSGMaterialType t; + return &t; + } + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override + { + return new QSGCurveStrokeMaterialShader(viewCount()); + } + + QSGCurveStrokeNode *m_node; +}; + +QT_END_NAMESPACE + +#endif // QSGCURVESTROKENODE_P_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultcontext_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultcontext_p.h new file mode 100644 index 0000000000000000000000000000000000000000..983be19c0e4c1a7c297493176c37d5ec240ef264 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultcontext_p.h @@ -0,0 +1,69 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDEFAULTCONTEXT_H +#define QSGDEFAULTCONTEXT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qsgcontext_p.h> +#include <QtQuick/private/qsgdistancefieldglyphnode_p.h> +#include <qsgrendererinterface.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGDefaultContext : public QSGContext, public QSGRendererInterface +{ +public: + QSGDefaultContext(QObject *parent = nullptr); + ~QSGDefaultContext(); + + void renderContextInitialized(QSGRenderContext *renderContext) override; + void renderContextInvalidated(QSGRenderContext *) override; + QSGRenderContext *createRenderContext() override; + QSGInternalRectangleNode *createInternalRectangleNode() override; + QSGInternalImageNode *createInternalImageNode(QSGRenderContext *renderContext) override; + QSGPainterNode *createPainterNode(QQuickPaintedItem *item) override; + QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, QSGTextNode::RenderType renderType, int renderTypeQuality) override; + QSGInternalTextNode *createInternalTextNode(QSGRenderContext *renderContext) override; + QSGLayer *createLayer(QSGRenderContext *renderContext) override; + QSurfaceFormat defaultSurfaceFormat() const override; + QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext) override; + QSGRectangleNode *createRectangleNode() override; + QSGImageNode *createImageNode() override; + QSGNinePatchNode *createNinePatchNode() override; +#if QT_CONFIG(quick_sprite) + QSGSpriteNode *createSpriteNode() override; +#endif + QSGGuiThreadShaderEffectManager *createGuiThreadShaderEffectManager() override; + QSGShaderEffectNode *createShaderEffectNode(QSGRenderContext *renderContext) override; + + void setDistanceFieldEnabled(bool enabled); + bool isDistanceFieldEnabled() const; + + GraphicsApi graphicsApi() const override; + void *getResource(QQuickWindow *window, Resource resource) const override; + ShaderType shaderType() const override; + ShaderCompilationTypes shaderCompilationType() const override; + ShaderSourceTypes shaderSourceType() const override; + +private: + QMutex m_mutex; + QSGContext::AntialiasingMethod m_antialiasingMethod; + bool m_distanceFieldDisabled; + QSGDistanceFieldGlyphNode::AntialiasingMode m_distanceFieldAntialiasing; + bool m_distanceFieldAntialiasingDecided; +}; + +QT_END_NAMESPACE + +#endif // QSGDEFAULTCONTEXT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultglyphnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultglyphnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b9c0e65cc1e06da2caa0466e21b743ee9957ad96 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultglyphnode_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDEFAULTGLYPHNODE_P_H +#define QSGDEFAULTGLYPHNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> +#include <private/qsgbasicglyphnode_p.h> + +QT_BEGIN_NAMESPACE + +class QSGDefaultGlyphNode : public QSGBasicGlyphNode +{ +public: + QSGDefaultGlyphNode(QSGRenderContext *context); + ~QSGDefaultGlyphNode(); + void setMaterialColor(const QColor &color) override; + void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override; + void update() override; + void preprocess() override; + void setPreferredAntialiasingMode(AntialiasingMode) override; + void updateGeometry(); + +private: + enum DefaultGlyphNodeType { + RootGlyphNode, + SubGlyphNode + }; + + void setGlyphNodeType(DefaultGlyphNodeType type) { m_glyphNodeType = type; } + + QSGRenderContext *m_context; + DefaultGlyphNodeType m_glyphNodeType; + QVector<QSGNode *> m_nodesToDelete; + + struct GlyphInfo { + QVector<quint32> indexes; + QVector<QPointF> positions; + }; + + uint m_dirtyGeometry: 1; + + AntialiasingMode m_preferredAntialiasingMode; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultglyphnode_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultglyphnode_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..d2535e2fdd24888b69d40a7c656a53d78693cd43 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultglyphnode_p_p.h @@ -0,0 +1,115 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDEFAULTGLYPHNODE_P_P_H +#define QSGDEFAULTGLYPHNODE_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qcolor.h> +#include <QtQuick/qsgmaterial.h> +#include <QtQuick/qsgtexture.h> +#include <QtQuick/qsggeometry.h> +#include <qshareddata.h> +#include <QtQuick/private/qsgplaintexture_p.h> +#include <QtQuick/private/qsgrhitextureglyphcache_p.h> +#include <qrawfont.h> +#include <qmargins.h> + +QT_BEGIN_NAMESPACE + +class QFontEngine; +class Geometry; +class QSGRenderContext; +class QSGDefaultRenderContext; + +class QSGTextMaskMaterial: public QSGMaterial +{ +public: + QSGTextMaskMaterial(QSGRenderContext *rc, const QVector4D &color, const QRawFont &font, QFontEngine::GlyphFormat glyphFormat = QFontEngine::Format_None); + virtual ~QSGTextMaskMaterial(); + + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; + int compare(const QSGMaterial *other) const override; + + void setColor(const QColor &c) { + const auto rgbC = c.toRgb(); + setColor(QVector4D(rgbC.redF(), rgbC.greenF(), rgbC.blueF(), rgbC.alphaF())); + } + void setColor(const QVector4D &color); + const QVector4D &color() const { return m_color; } + + QSGTexture *texture() const { return m_texture; } + + bool ensureUpToDate(); + + QTextureGlyphCache *glyphCache() const; + QSGRhiTextureGlyphCache *rhiGlyphCache() const; + + void populate(const QPointF &position, + const QVector<quint32> &glyphIndexes, const QVector<QPointF> &glyphPositions, + QSGGeometry *geometry, QRectF *boundingRect, QPointF *baseLine, + const QMargins &margins = QMargins(0, 0, 0, 0)); + +private: + void init(QFontEngine::GlyphFormat glyphFormat); + void updateCache(QFontEngine::GlyphFormat glyphFormat); + + QSGDefaultRenderContext *m_rc; + QSGPlainTexture *m_texture; + QExplicitlySharedDataPointer<QFontEngineGlyphCache> m_glyphCache; + QRawFont m_font; + QFontEngine *m_retainedFontEngine = nullptr; + QRhi *m_rhi; + QVector4D m_color; + QSize m_size; +}; + +class QSGStyledTextMaterial : public QSGTextMaskMaterial +{ +public: + QSGStyledTextMaterial(QSGRenderContext *rc, const QRawFont &font); + virtual ~QSGStyledTextMaterial() { } + + void setStyleShift(const QVector2D &shift) { m_styleShift = shift; } + const QVector2D &styleShift() const { return m_styleShift; } + + void setStyleColor(const QColor &c) { + const auto rgbC = c.toRgb(); + m_styleColor = QVector4D(rgbC.redF(), rgbC.greenF(), rgbC.blueF(), rgbC.alphaF()); + } + void setStyleColor(const QVector4D &color) { m_styleColor = color; } + const QVector4D &styleColor() const { return m_styleColor; } + + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; + int compare(const QSGMaterial *other) const override; + +private: + QVector2D m_styleShift; + QVector4D m_styleColor; +}; + +class QSGOutlinedTextMaterial : public QSGStyledTextMaterial +{ +public: + QSGOutlinedTextMaterial(QSGRenderContext *rc, const QRawFont &font); + ~QSGOutlinedTextMaterial() { } + + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultimagenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultimagenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a1052fc92924396973ff17642879937db5984e58 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultimagenode_p.h @@ -0,0 +1,69 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDEFAULTIMAGENODE_P_H +#define QSGDEFAULTIMAGENODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qtquickglobal_p.h> +#include <QtQuick/qsgimagenode.h> +#include <QtQuick/qsggeometry.h> +#include <QtQuick/qsgtexturematerial.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGDefaultImageNode : public QSGImageNode +{ +public: + QSGDefaultImageNode(); + ~QSGDefaultImageNode(); + + void setRect(const QRectF &rect) override; + QRectF rect() const override; + + void setSourceRect(const QRectF &r) override; + QRectF sourceRect() const override; + + void setTexture(QSGTexture *texture) override; + QSGTexture *texture() const override; + + void setFiltering(QSGTexture::Filtering filtering) override; + QSGTexture::Filtering filtering() const override; + + void setMipmapFiltering(QSGTexture::Filtering filtering) override; + QSGTexture::Filtering mipmapFiltering() const override; + + void setAnisotropyLevel(QSGTexture::AnisotropyLevel level) override; + QSGTexture::AnisotropyLevel anisotropyLevel() const override; + + void setTextureCoordinatesTransform(TextureCoordinatesTransformMode mode) override; + TextureCoordinatesTransformMode textureCoordinatesTransform() const override; + + void setOwnsTexture(bool owns) override; + bool ownsTexture() const override; + +private: + QSGGeometry m_geometry; + QSGOpaqueTextureMaterial m_opaque_material; + QSGTextureMaterial m_material; + QRectF m_rect; + QRectF m_sourceRect; + QSize m_textureSize; + TextureCoordinatesTransformMode m_texCoordMode; + uint m_isAtlasTexture : 1; + uint m_ownsTexture : 1; +}; + +QT_END_NAMESPACE + +#endif // QSGDEFAULTIMAGENODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultinternalimagenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultinternalimagenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..683cf13ea6ebc071d28f4d38f980b502b54eecec --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultinternalimagenode_p.h @@ -0,0 +1,64 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QSGDEFAULTINTERNALIMAGENODE_P_H +#define QSGDEFAULTINTERNALIMAGENODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> +#include <private/qsgbasicinternalimagenode_p.h> +#include <QtQuick/qsgtexturematerial.h> + +QT_BEGIN_NAMESPACE + +class QSGDefaultRenderContext; + +class Q_QUICK_EXPORT QSGSmoothTextureMaterial : public QSGTextureMaterial +{ +public: + QSGSmoothTextureMaterial(); + + void setTexture(QSGTexture *texture); + +protected: + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; +}; + +class Q_QUICK_EXPORT QSGDefaultInternalImageNode : public QSGBasicInternalImageNode +{ +public: + QSGDefaultInternalImageNode(QSGDefaultRenderContext *rc); + + void setMipmapFiltering(QSGTexture::Filtering filtering) override; + void setFiltering(QSGTexture::Filtering filtering) override; + void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) override; + void setVerticalWrapMode(QSGTexture::WrapMode wrapMode) override; + + void updateMaterialAntialiasing() override; + void setMaterialTexture(QSGTexture *texture) override; + QSGTexture *materialTexture() const override; + bool updateMaterialBlending() override; + bool supportsWrap(const QSize &size) const override; + +private: + QSGDefaultRenderContext *m_rc; + QSGOpaqueTextureMaterial m_material; + QSGTextureMaterial m_materialO; + QSGSmoothTextureMaterial m_smoothMaterial; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultinternalrectanglenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultinternalrectanglenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5ee4158bc99b3cc1e1a14c37a0a788f0ffdb1ca6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultinternalrectanglenode_p.h @@ -0,0 +1,54 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#ifndef QSGDEFAULTINTERNALRECTANGLENODE_P_H +#define QSGDEFAULTINTERNALRECTANGLENODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> +#include <private/qsgbasicinternalrectanglenode_p.h> +#include <QtQuick/qsgvertexcolormaterial.h> + +QT_BEGIN_NAMESPACE + +class QSGContext; + +class Q_QUICK_EXPORT QSGSmoothColorMaterial : public QSGMaterial +{ +public: + QSGSmoothColorMaterial(); + + int compare(const QSGMaterial *other) const override; + +protected: + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; +}; + +class Q_QUICK_EXPORT QSGDefaultInternalRectangleNode : public QSGBasicInternalRectangleNode +{ +public: + QSGDefaultInternalRectangleNode(); + +private: + void updateMaterialAntialiasing() override; + void updateMaterialBlending(QSGNode::DirtyState *state) override; + + QSGVertexColorMaterial m_material; + QSGSmoothColorMaterial m_smoothMaterial; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultninepatchnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultninepatchnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..bf55ea2fdf19df7fbaa14f2bf805811824e6c290 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultninepatchnode_p.h @@ -0,0 +1,47 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDEFAULTNINEPATCHNODE_P_H +#define QSGDEFAULTNINEPATCHNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> +#include <QtQuick/qsgninepatchnode.h> +#include <QtQuick/qsggeometry.h> +#include <QtQuick/qsgtexturematerial.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGDefaultNinePatchNode : public QSGNinePatchNode +{ +public: + QSGDefaultNinePatchNode(); + ~QSGDefaultNinePatchNode(); + + void setTexture(QSGTexture *texture) override; + void setBounds(const QRectF &bounds) override; + void setDevicePixelRatio(qreal ratio) override; + void setPadding(qreal left, qreal top, qreal right, qreal bottom) override; + void update() override; + +private: + QRectF m_bounds; + qreal m_devicePixelRatio; + QVector4D m_padding; + QSGGeometry m_geometry; + QSGTextureMaterial m_material; +}; + +QT_END_NAMESPACE + +#endif // QSGDEFAULTNINEPATCHNODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultpainternode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultpainternode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..1f049a33dde621223fb069572667cfece36565b5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultpainternode_p.h @@ -0,0 +1,126 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDEFAULTPAINTERNODE_P_H +#define QSGDEFAULTPAINTERNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> +#include "qsgtexturematerial.h" +#include "qsgplaintexture_p.h" + +#include <QtQuick/qquickpainteditem.h> + +#include <QtGui/qcolor.h> + +QT_BEGIN_NAMESPACE + +class QSGDefaultRenderContext; + +class Q_QUICK_EXPORT QSGPainterTexture : public QSGPlainTexture +{ +public: + QSGPainterTexture(); + + void setDirtyRect(const QRect &rect) { m_dirty_rect = rect; } + + void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override; + +private: + QRect m_dirty_rect; +}; + +class Q_QUICK_EXPORT QSGDefaultPainterNode : public QSGPainterNode +{ +public: + QSGDefaultPainterNode(QQuickPaintedItem *item); + virtual ~QSGDefaultPainterNode(); + + void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) override; + + void setSize(const QSize &size) override; + QSize size() const { return m_size; } + + void setDirty(const QRect &dirtyRect = QRect()) override; + + void setOpaquePainting(bool opaque) override; + bool opaquePainting() const { return m_opaquePainting; } + + void setLinearFiltering(bool linearFiltering) override; + bool linearFiltering() const { return m_linear_filtering; } + + void setMipmapping(bool mipmapping) override; + bool mipmapping() const { return m_mipmapping; } + + void setSmoothPainting(bool s) override; + bool smoothPainting() const { return m_smoothPainting; } + + void setFillColor(const QColor &c) override; + QColor fillColor() const { return m_fillColor; } + + void setContentsScale(qreal s) override; + qreal contentsScale() const { return m_contentsScale; } + + void setFastFBOResizing(bool fastResizing) override; + bool fastFBOResizing() const { return m_fastFBOResizing; } + + void setTextureSize(const QSize &textureSize) override; + QSize textureSize() const { return m_textureSize; } + + QImage toImage() const override; + void update() override; + + void paint(); + + QSGTexture *texture() const override { return m_texture; } + +private: + void updateTexture(); + void updateGeometry(); + void updateRenderTarget(); + + QSGDefaultRenderContext *m_context; + + QQuickPaintedItem::RenderTarget m_preferredRenderTarget; + QQuickPaintedItem::RenderTarget m_actualRenderTarget; + + QQuickPaintedItem *m_item; + + QImage m_image; + + QSGOpaqueTextureMaterial m_material; + QSGTextureMaterial m_materialO; + QSGGeometry m_geometry; + QSGPainterTexture *m_texture; + + QSize m_size; + QSize m_textureSize; + QRect m_dirtyRect; + QColor m_fillColor; + qreal m_contentsScale; + + bool m_dirtyContents : 1; + bool m_opaquePainting : 1; + bool m_linear_filtering : 1; + bool m_mipmapping : 1; + bool m_smoothPainting : 1; + bool m_multisamplingSupported : 1; + bool m_fastFBOResizing : 1; + bool m_dirtyGeometry : 1; + bool m_dirtyRenderTarget : 1; + bool m_dirtyTexture : 1; +}; + +QT_END_NAMESPACE + +#endif // QSGDEFAULTPAINTERNODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultrectanglenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultrectanglenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f2176cb7d32128b777c3beab6c89dbc5d2164121 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultrectanglenode_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDEFAULTRECTANGLENODE_P_H +#define QSGDEFAULTRECTANGLENODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qcolor.h> +#include <QtQuick/qsgrectanglenode.h> +#include <QtQuick/qsgvertexcolormaterial.h> +#include <QtCore/private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QSGDefaultRectangleNode : public QSGRectangleNode +{ +public: + QSGDefaultRectangleNode(); + + void setRect(const QRectF &rect) override; + QRectF rect() const override; + + void setColor(const QColor &color) override; + QColor color() const override; + +private: + QSGVertexColorMaterial m_material; + QSGGeometry m_geometry; + QColor m_color; +}; + +QT_END_NAMESPACE + +#endif // QSGDEFAULTRECTANGLENODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultrendercontext_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultrendercontext_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e5275656ebd1c89c4d6136e4ed03b74ec5a8cf86 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultrendercontext_p.h @@ -0,0 +1,126 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDEFAULTRENDERCONTEXT_H +#define QSGDEFAULTRENDERCONTEXT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qsgcontext_p.h> +#include <rhi/qshader.h> + +QT_BEGIN_NAMESPACE + +class QRhi; +class QRhiCommandBuffer; +class QRhiRenderPassDescriptor; +class QRhiResourceUpdateBatch; +class QRhiTexture; +class QSGMaterialShader; +class QSurface; + +namespace QSGRhiAtlasTexture { + class Manager; +} + +class Q_QUICK_EXPORT QSGDefaultRenderContext : public QSGRenderContext +{ + Q_OBJECT +public: + QSGDefaultRenderContext(QSGContext *context); + + QRhi *rhi() const override { return m_rhi; } + bool isValid() const override { return m_rhi != nullptr; } + + static const int INIT_PARAMS_MAGIC = 0x50E; + struct InitParams : public QSGRenderContext::InitParams { + int sType = INIT_PARAMS_MAGIC; // help discovering broken code passing something else as 'context' + QRhi *rhi = nullptr; + int sampleCount = 1; // 1, 4, 8, ... + // only used as a hint f.ex. in the texture atlas init + QSize initialSurfacePixelSize; + // The first window that will be used with this rc, if available. + // Only a hint, to help picking better values for atlases. + QSurface *maybeSurface = nullptr; + }; + + void initialize(const QSGRenderContext::InitParams *params) override; + void invalidate() override; + + void prepareSync(qreal devicePixelRatio, + QRhiCommandBuffer *cb, + const QQuickGraphicsConfiguration &config) override; + + void beginNextFrame(QSGRenderer *renderer, const QSGRenderTarget &renderTarget, + RenderPassCallback mainPassRecordingStart, + RenderPassCallback mainPassRecordingEnd, + void *callbackUserData) override; + void renderNextFrame(QSGRenderer *renderer) override; + void endNextFrame(QSGRenderer *renderer) override; + + void preprocess() override; + void invalidateGlyphCaches() override; + QSGDistanceFieldGlyphCache *distanceFieldGlyphCache(const QRawFont &font, int renderTypeQuality) override; + QSGCurveGlyphAtlas *curveGlyphAtlas(const QRawFont &font) override; + + QSGTexture *createTexture(const QImage &image, uint flags) const override; + QSGRenderer *createRenderer(QSGRendererInterface::RenderMode renderMode = QSGRendererInterface::RenderMode2D) override; + QSGTexture *compressedTextureForFactory(const QSGCompressedTextureFactory *factory) const override; + + virtual void initializeRhiShader(QSGMaterialShader *shader, QShader::Variant shaderVariant); + + int maxTextureSize() const override { return m_maxTextureSize; } + bool useDepthBufferFor2D() const { return m_useDepthBufferFor2D; } + int msaaSampleCount() const { return m_initParams.sampleCount; } + + QRhiCommandBuffer *currentFrameCommandBuffer() const { + // may be null if not in an active frame, but returning null is valid then + return m_currentFrameCommandBuffer; + } + QRhiRenderPassDescriptor *currentFrameRenderPass() const { + // may be null if not in an active frame, but returning null is valid then + return m_currentFrameRenderPass; + } + + qreal currentDevicePixelRatio() const + { + // Valid starting from QQuickWindow::syncSceneGraph(). This takes the + // redirections, e.g. QQuickWindow::setRenderTarget(), into account. + // This calculation logic matches what the renderer does, so this is + // the same value that gets exposed in RenderState::devicePixelRatio() + // to material shaders. This getter is useful to perform dpr-related + // operations in the sync phase (in updatePaintNode()). + return m_currentDevicePixelRatio; + } + + QRhiResourceUpdateBatch *maybeGlyphCacheResourceUpdates(); + QRhiResourceUpdateBatch *glyphCacheResourceUpdates(); + void deferredReleaseGlyphCacheTexture(QRhiTexture *texture); + void resetGlyphCacheResources(); + +protected: + InitParams m_initParams; + QRhi *m_rhi; + int m_maxTextureSize; + QSGRhiAtlasTexture::Manager *m_rhiAtlasManager; + QRhiCommandBuffer *m_currentFrameCommandBuffer; + QRhiRenderPassDescriptor *m_currentFrameRenderPass; + qreal m_currentDevicePixelRatio; + bool m_useDepthBufferFor2D; + QRhiResourceUpdateBatch *m_glyphCacheResourceUpdates; + QSet<QRhiTexture *> m_pendingGlyphCacheTextures; + QHash<FontKey, QSGCurveGlyphAtlas *> m_curveGlyphAtlases; +}; + +QT_END_NAMESPACE + +#endif // QSGDEFAULTRENDERCONTEXT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultspritenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultspritenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..22d7eeffde1c3f9d9358c898e8bda10dc8e5d064 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdefaultspritenode_p.h @@ -0,0 +1,55 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDEFAULTSPRITENODE_H +#define QSGDEFAULTSPRITENODE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> + +QT_REQUIRE_CONFIG(quick_sprite); + +#include <private/qsgadaptationlayer_p.h> + +QT_BEGIN_NAMESPACE +class QQuickSpriteMaterial; +class QSGDefaultSpriteNode : public QSGSpriteNode +{ +public: + QSGDefaultSpriteNode(); + + void setTexture(QSGTexture *texture) override; + void setTime(float time) override; + void setSourceA(const QPoint &source) override; + void setSourceB(const QPoint &source) override; + void setSpriteSize(const QSize &size) override; + void setSheetSize(const QSize &size) override; + void setSize(const QSizeF &size) override; + void setFiltering(QSGTexture::Filtering filtering) override; + void update() override; +private: + void updateGeometry(); + + QQuickSpriteMaterial *m_material; + QSGGeometry *m_geometry; + bool m_geometryDirty; + QPoint m_sourceA; + QPoint m_sourceB; + QSize m_spriteSize; + QSize m_sheetSize; + QSizeF m_size; +}; + +QT_END_NAMESPACE + +#endif // QSGDEFAULTSPRITENODE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdistancefieldglyphnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdistancefieldglyphnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ba39e6e26be379a438480e218a9f755ff5af0bda --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdistancefieldglyphnode_p.h @@ -0,0 +1,93 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDISTANCEFIELDGLYPHNODE_P_H +#define QSGDISTANCEFIELDGLYPHNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> +#include <QtQuick/qsgtexture.h> + +#include <QtQuick/private/qquicktext_p.h> + +QT_BEGIN_NAMESPACE + +class QSGRenderContext; +class QSGDistanceFieldTextMaterial; + +class QSGDistanceFieldGlyphNode : public QSGGlyphNode, public QSGDistanceFieldGlyphConsumer +{ +public: + QSGDistanceFieldGlyphNode(QSGRenderContext *context); + ~QSGDistanceFieldGlyphNode(); + + QPointF baseLine() const override { return m_baseLine; } + void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override; + void setColor(const QColor &color) override; + + void setPreferredAntialiasingMode(AntialiasingMode mode) override; + void setRenderTypeQuality(int renderTypeQuality) override; + + void setStyle(QQuickText::TextStyle style) override; + void setStyleColor(const QColor &color) override; + + void update() override; + void preprocess() override; + + void invalidateGlyphs(const QVector<quint32> &glyphs) override; + + void updateGeometry(); + +private: + enum DistanceFieldGlyphNodeType { + RootGlyphNode, + SubGlyphNode + }; + + void setGlyphNodeType(DistanceFieldGlyphNodeType type) { m_glyphNodeType = type; } + void updateMaterial(); + + DistanceFieldGlyphNodeType m_glyphNodeType; + QColor m_color; + QPointF m_baseLine; + QSGRenderContext *m_context; + QSGDistanceFieldTextMaterial *m_material; + QPointF m_originalPosition; + QPointF m_position; + QGlyphRun m_glyphs; + QSGDistanceFieldGlyphCache *m_glyph_cache; + QSGGeometry m_geometry; + QQuickText::TextStyle m_style; + QColor m_styleColor; + AntialiasingMode m_antialiasingMode; + QRectF m_boundingRect; + const QSGDistanceFieldGlyphCache::Texture *m_texture; + int m_renderTypeQuality; + + struct GlyphInfo { + QVector<quint32> indexes; + QVector<QPointF> positions; + }; + QSet<quint32> m_allGlyphIndexesLookup; + // m_glyphs holds pointers to the GlyphInfo.indexes and positions arrays, so we need to hold on to them + QHash<const QSGDistanceFieldGlyphCache::Texture *, GlyphInfo> m_glyphsInOtherTextures; + + uint m_dirtyGeometry: 1; + uint m_dirtyMaterial: 1; + + static qint64 m_totalAllocation; // all SG glyph vertices and indices; only for qCDebug metrics +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdistancefieldglyphnode_p_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdistancefieldglyphnode_p_p.h new file mode 100644 index 0000000000000000000000000000000000000000..843d5242c2cf343d348fe43446afc4bf43c26ec1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgdistancefieldglyphnode_p_p.h @@ -0,0 +1,132 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGDISTANCEFIELDGLYPHNODE_P_P_H +#define QSGDISTANCEFIELDGLYPHNODE_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/qsgmaterial.h> +#include <QtQuick/private/qsgplaintexture_p.h> +#include "qsgdistancefieldglyphnode_p.h" +#include "qsgadaptationlayer_p.h" + +QT_BEGIN_NAMESPACE + +class QSGPlainTexture; + +class Q_QUICK_EXPORT QSGDistanceFieldTextMaterial: public QSGMaterial +{ +public: + QSGDistanceFieldTextMaterial(); + ~QSGDistanceFieldTextMaterial(); + + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; + int compare(const QSGMaterial *other) const override; + + virtual void setColor(const QColor &color); + const QVector4D &color() const { return m_color; } + + void setGlyphCache(QSGDistanceFieldGlyphCache *a) { m_glyph_cache = a; } + QSGDistanceFieldGlyphCache *glyphCache() const { return m_glyph_cache; } + + void setTexture(const QSGDistanceFieldGlyphCache::Texture * tex) { m_texture = tex; } + const QSGDistanceFieldGlyphCache::Texture * texture() const { return m_texture; } + + void setFontScale(qreal fontScale) { m_fontScale = fontScale; } + qreal fontScale() const { return m_fontScale; } + + QSize textureSize() const { return m_size; } + + bool updateTextureSize(); + bool updateTextureSizeAndWrapper(); + QSGTexture *wrapperTexture() const { return m_sgTexture; } + +protected: + QSize m_size; + QVector4D m_color; + QSGDistanceFieldGlyphCache *m_glyph_cache; + const QSGDistanceFieldGlyphCache::Texture *m_texture; + qreal m_fontScale; + QSGPlainTexture *m_sgTexture; +}; + +class Q_QUICK_EXPORT QSGDistanceFieldStyledTextMaterial : public QSGDistanceFieldTextMaterial +{ +public: + QSGDistanceFieldStyledTextMaterial(); + ~QSGDistanceFieldStyledTextMaterial(); + + QSGMaterialType *type() const override = 0; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override = 0; + int compare(const QSGMaterial *other) const override; + + void setStyleColor(const QColor &color); + const QVector4D &styleColor() const { return m_styleColor; } + +protected: + QVector4D m_styleColor; +}; + +class Q_QUICK_EXPORT QSGDistanceFieldOutlineTextMaterial : public QSGDistanceFieldStyledTextMaterial +{ +public: + QSGDistanceFieldOutlineTextMaterial(); + ~QSGDistanceFieldOutlineTextMaterial(); + + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; +}; + +class Q_QUICK_EXPORT QSGDistanceFieldShiftedStyleTextMaterial : public QSGDistanceFieldStyledTextMaterial +{ +public: + QSGDistanceFieldShiftedStyleTextMaterial(); + ~QSGDistanceFieldShiftedStyleTextMaterial(); + + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; + int compare(const QSGMaterial *other) const override; + + void setShift(const QPointF &shift) { m_shift = shift; } + const QPointF &shift() const { return m_shift; } + +protected: + QPointF m_shift; +}; + +class Q_QUICK_EXPORT QSGHiQSubPixelDistanceFieldTextMaterial : public QSGDistanceFieldTextMaterial +{ +public: + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; + void setColor(const QColor &color) override { + const auto rgbColor = color.toRgb(); + m_color = QVector4D(rgbColor.redF(), rgbColor.greenF(), rgbColor.blueF(), rgbColor.alphaF()); + } +}; + +class Q_QUICK_EXPORT QSGLoQSubPixelDistanceFieldTextMaterial : public QSGDistanceFieldTextMaterial +{ +public: + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; + void setColor(const QColor &color) override { + const auto rgbColor = color.toRgb(); + m_color = QVector4D(rgbColor.redF(), rgbColor.greenF(), rgbColor.blueF(), rgbColor.alphaF()); + } +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsggeometry_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsggeometry_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b4b46b1e9fd1c39b74159d3925e9273fad09db8f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsggeometry_p.h @@ -0,0 +1,47 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGGEOMETRY_P_H +#define QSGGEOMETRY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsggeometry.h" +#include "private/qglobal_p.h" + +QT_BEGIN_NAMESPACE + +class QSGGeometryData +{ +public: + virtual ~QSGGeometryData() {} + + static inline QSGGeometryData *data(const QSGGeometry *g) { + return g->m_server_data; + } + + static inline void install(const QSGGeometry *g, QSGGeometryData *data) { + Q_ASSERT(!g->m_server_data); + const_cast<QSGGeometry *>(g)->m_server_data = data; + } + + static bool inline hasDirtyVertexData(const QSGGeometry *g) { return g->m_dirty_vertex_data; } + static void inline clearDirtyVertexData(const QSGGeometry *g) { const_cast<QSGGeometry *>(g)->m_dirty_vertex_data = false; } + + static bool inline hasDirtyIndexData(const QSGGeometry *g) { return g->m_dirty_vertex_data; } + static void inline clearDirtyIndexData(const QSGGeometry *g) { const_cast<QSGGeometry *>(g)->m_dirty_index_data = false; } + +}; + +QT_END_NAMESPACE + +#endif // QSGGEOMETRY_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsggradientcache_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsggradientcache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a71c404d6d000e18f454c1e76a3f9b39082484bc --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsggradientcache_p.h @@ -0,0 +1,72 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGGRADIENTCACHE_P_H +#define QSGGRADIENTCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qhash.h> +#include <QtGui/qbrush.h> + +#include <QtQuick/qtquickexports.h> + +QT_BEGIN_NAMESPACE + +class QSGTexture; +class QSGPlainTexture; +class QRhi; + +struct Q_QUICK_EXPORT QSGGradientCacheKey +{ + QSGGradientCacheKey(const QGradientStops &stops, QGradient::Spread spread) + : stops(stops), spread(spread) + { } + QGradientStops stops; + QGradient::Spread spread; + bool operator==(const QSGGradientCacheKey &other) const + { + return spread == other.spread && stops == other.stops; + } +}; + +inline size_t qHash(const QSGGradientCacheKey &v, size_t seed = 0) +{ + size_t h = seed + v.spread; + for (int i = 0; i < 3 && i < v.stops.size(); ++i) + h += v.stops[i].second.rgba(); + return h; +} + +class Q_QUICK_EXPORT QSGGradientCache +{ +public: + struct GradientDesc { // can fully describe a linear/radial/conical gradient + QGradientStops stops; + QGradient::Spread spread = QGradient::PadSpread; + QPointF a; // start (L) or center point (R/C) + QPointF b; // end (L) or focal point (R) + qreal v0; // center radius (R) or start angle (C) + qreal v1; // focal radius (R) + }; + + ~QSGGradientCache(); + static QSGGradientCache *cacheForRhi(QRhi *rhi); + QSGTexture *get(const QSGGradientCacheKey &grad); + +private: + QHash<QSGGradientCacheKey, QSGPlainTexture *> m_textures; +}; + +QT_END_NAMESPACE + +#endif // QSGGRADIENTCACHE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsginternaltextnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsginternaltextnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..611cb907fd503ac14941192dae8fd9def4c6f5e6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsginternaltextnode_p.h @@ -0,0 +1,205 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGINTERNALTEXTNODE_P_H +#define QSGINTERNALTEXTNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsgtextnode.h" +#include "qquicktext_p.h" +#include <qglyphrun.h> + +#include <QtGui/qcolor.h> +#include <QtGui/qtextlayout.h> +#include <QtCore/qvarlengtharray.h> +#include <QtCore/qscopedpointer.h> + +QT_BEGIN_NAMESPACE + +class QSGGlyphNode; +class QTextBlock; +class QColor; +class QTextDocument; +class QSGContext; +class QRawFont; +class QSGInternalRectangleNode; +class QSGClipNode; +class QSGTexture; +class QSGRenderContext; + +class QQuickTextNodeEngine; + +class Q_QUICK_EXPORT QSGInternalTextNode : public QSGTextNode +{ +public: + QSGInternalTextNode(QSGRenderContext *renderContext); + ~QSGInternalTextNode(); + + static bool isComplexRichText(QTextDocument *); + + void setColor(QColor color) override + { + m_color = color; + } + + QColor color() const override + { + return m_color; + } + + void setTextStyle(TextStyle textStyle) override + { + m_textStyle = textStyle; + } + + TextStyle textStyle() override + { + return m_textStyle; + } + + void setStyleColor(QColor styleColor) override + { + m_styleColor = styleColor; + } + + QColor styleColor() const override + { + return m_styleColor; + } + + void setLinkColor(QColor linkColor) override + { + m_linkColor = linkColor; + } + + QColor linkColor() const override + { + return m_linkColor; + } + + void setSelectionColor(QColor selectionColor) override + { + m_selectionColor = selectionColor; + } + + QColor selectionColor() const override + { + return m_selectionColor; + } + + void setSelectionTextColor(QColor selectionTextColor) override + { + m_selectionTextColor = selectionTextColor; + } + + QColor selectionTextColor() const override + { + return m_selectionTextColor; + } + + void setRenderTypeQuality(int renderTypeQuality) override + { + m_renderTypeQuality = renderTypeQuality; + } + int renderTypeQuality() const override + { + return m_renderTypeQuality; + } + + void setRenderType(RenderType renderType) override + { + m_renderType = renderType; + } + + RenderType renderType() const override + { + return m_renderType; + } + + bool containsUnscalableGlyphs() const + { + return m_containsUnscalableGlyphs; + } + + void setFiltering(QSGTexture::Filtering filtering) override + { + m_filtering = filtering; + } + + QSGTexture::Filtering filtering() const override + { + return m_filtering; + } + + void setViewport(const QRectF &viewport) override + { + m_viewport = viewport; + } + + QRectF viewport() const override + { + return m_viewport; + } + + void setCursor(const QRectF &rect, const QColor &color); + void clearCursor(); + + void addRectangleNode(const QRectF &rect, const QColor &color); + virtual void addDecorationNode(const QRectF &rect, const QColor &color); + void addImage(const QRectF &rect, const QImage &image); + void clear() override; + QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color, + QQuickText::TextStyle style = QQuickText::Normal, const QColor &styleColor = QColor(), + QSGNode *parentNode = 0); + + QSGInternalRectangleNode *cursorNode() const { return m_cursorNode; } + QPair<int, int> renderedLineRange() const { return { m_firstLineInViewport, m_firstLinePastViewport }; } + +protected: + void doAddTextLayout(QPointF position, + QTextLayout *textLayout, + int selectionStart, + int selectionEnd, + int lineStart, + int lineCount) override; + + void doAddTextDocument(QPointF position, + QTextDocument *textDocument, + int selectionStart, + int selectionEnd) override; + +private: + QSGInternalRectangleNode *m_cursorNode = nullptr; + QList<QSGTexture *> m_textures; + QSGRenderContext *m_renderContext = nullptr; + RenderType m_renderType = QtRendering; + TextStyle m_textStyle = Normal; + QRectF m_viewport; + QColor m_color = QColor(0, 0, 0); + QColor m_styleColor = QColor(0, 0, 0); + QColor m_linkColor = QColor(0, 0, 255); + QColor m_selectionColor = QColor(0, 0, 128); + QColor m_selectionTextColor = QColor(255, 255, 255); + QSGTexture::Filtering m_filtering = QSGTexture::Nearest; + int m_renderTypeQuality = -1; + int m_firstLineInViewport = -1; + int m_firstLinePastViewport = -1; + bool m_containsUnscalableGlyphs = false; + + friend class QQuickTextEdit; + friend class QQuickTextEditPrivate; +}; + +QT_END_NAMESPACE + +#endif // QSGINTERNALTEXTNODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgmaterialshader_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgmaterialshader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..83753b0700449d593b76e7155d057e6bc79ab922 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgmaterialshader_p.h @@ -0,0 +1,79 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGMATERIALSHADER_P_H +#define QSGMATERIALSHADER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> +#include "qsgmaterialshader.h" +#include "qsgmaterial.h" +#include <rhi/qrhi.h> +#include <rhi/qshader.h> + +QT_BEGIN_NAMESPACE + +class QRhiSampler; + +class Q_QUICK_EXPORT QSGMaterialShaderPrivate +{ +public: + Q_DECLARE_PUBLIC(QSGMaterialShader) + + QSGMaterialShaderPrivate(QSGMaterialShader *q) : q_ptr(q) { } + static QSGMaterialShaderPrivate *get(QSGMaterialShader *s) { return s->d_func(); } + static const QSGMaterialShaderPrivate *get(const QSGMaterialShader *s) { return s->d_func(); } + + void clearCachedRendererData(); + void prepare(QShader::Variant vertexShaderVariant); + + QShader shader(QShader::Stage stage) const { return shaders[stage].shader; } + + static QShader loadShader(const QString &filename); + + QSGMaterialShader *q_ptr; + QHash<QShader::Stage, QString> shaderFileNames; + QSGMaterialShader::Flags flags; + + struct ShaderStageData { + ShaderStageData() { } // so shader.isValid() == false + ShaderStageData(const QShader &shader) : shader(shader) { } + QShader shader; + QShader::Variant shaderVariant = QShader::StandardShader; + QVector<int> vertexInputLocations; // excluding rewriter-inserted ones + int qt_order_attrib_location = -1; // rewriter-inserted + }; + QHash<QShader::Stage, ShaderStageData> shaders; + + static const int MAX_SHADER_RESOURCE_BINDINGS = 32; + + int ubufBinding = -1; + int ubufSize = 0; + QRhiShaderResourceBinding::StageFlags ubufStages; + QRhiShaderResourceBinding::StageFlags combinedImageSamplerBindings[MAX_SHADER_RESOURCE_BINDINGS]; + int combinedImageSamplerCount[MAX_SHADER_RESOURCE_BINDINGS]; + + ShaderStageData *vertexShader = nullptr; + ShaderStageData *fragmentShader = nullptr; + + QByteArray masterUniformData; + + QVarLengthArray<QSGTexture *, 4> textureBindingTable[MAX_SHADER_RESOURCE_BINDINGS]; + QVarLengthArray<QRhiSampler *, 4> samplerBindingTable[MAX_SHADER_RESOURCE_BINDINGS]; +}; + +Q_DECLARE_TYPEINFO(QSGMaterialShaderPrivate::ShaderStageData, Q_RELOCATABLE_TYPE); + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..11d7d152ea1c07c30d5b03f323c96b6f48e6a689 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgnode_p.h @@ -0,0 +1,57 @@ +// Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB) +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGNODE_P_H +#define QSGNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qglobal_p.h> + +#include "qsgnode.h" + +QT_BEGIN_NAMESPACE + +class QSGNodePrivate +{ +public: + QSGNodePrivate() {} + virtual ~QSGNodePrivate() {} + +#ifdef QSG_RUNTIME_DESCRIPTION + static void setDescription(QSGNode *node, const QString &description) { + node->d_ptr->descr= description; + } + static QString description(const QSGNode *node) { + return node->d_ptr->descr; + } + QString descr; +#endif +}; + + +class QSGBasicGeometryNodePrivate : public QSGNodePrivate +{ +public: + QSGBasicGeometryNodePrivate() {} +}; + + +class QSGGeometryNodePrivate: public QSGBasicGeometryNodePrivate +{ +public: + QSGGeometryNodePrivate() {} +}; + +QT_END_NAMESPACE + +#endif // QSGNODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgnodeupdater_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgnodeupdater_p.h new file mode 100644 index 0000000000000000000000000000000000000000..09293c13fbac4f262ca1305879ff5711b56c9eed --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgnodeupdater_p.h @@ -0,0 +1,65 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGNODEUPDATER_P_H +#define QSGNODEUPDATER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> +#include <QtGui/private/qdatabuffer_p.h> + +QT_BEGIN_NAMESPACE + +class QSGNode; +class QSGTransformNode; +class QSGClipNode; +class QSGOpacityNode; +class QSGGeometryNode; +class QMatrix4x4; +class QSGRenderNode; + +class Q_QUICK_EXPORT QSGNodeUpdater +{ +public: + QSGNodeUpdater(); + virtual ~QSGNodeUpdater(); + + virtual void updateStates(QSGNode *n); + virtual bool isNodeBlocked(QSGNode *n, QSGNode *root) const; + +protected: + virtual void enterTransformNode(QSGTransformNode *); + virtual void leaveTransformNode(QSGTransformNode *); + void enterClipNode(QSGClipNode *c); + void leaveClipNode(QSGClipNode *c); + void enterOpacityNode(QSGOpacityNode *o); + void leaveOpacityNode(QSGOpacityNode *o); + void enterGeometryNode(QSGGeometryNode *); + void leaveGeometryNode(QSGGeometryNode *); + void enterRenderNode(QSGRenderNode *); + void leaveRenderNode(QSGRenderNode *); + + void visitNode(QSGNode *n); + void visitChildren(QSGNode *n); + + + QDataBuffer<const QMatrix4x4 *> m_combined_matrix_stack; + QDataBuffer<qreal> m_opacity_stack; + const QSGClipNode *m_current_clip; + + int m_force_update; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgplaintexture_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgplaintexture_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b75814cd3806097f890d56e32efcace02ada6054 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgplaintexture_p.h @@ -0,0 +1,96 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGPLAINTEXTURE_P_H +#define QSGPLAINTEXTURE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qtquickglobal_p.h> +#include <QtQuick/private/qsgtexture_p.h> +#include <QtQuick/private/qquickwindow_p.h> + +QT_BEGIN_NAMESPACE + +class QSGPlainTexturePrivate; + +class Q_QUICK_EXPORT QSGPlainTexture : public QSGTexture +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QSGPlainTexture) +public: + QSGPlainTexture(); + ~QSGPlainTexture() override; + + void setOwnsTexture(bool owns) { m_owns_texture = owns; } + bool ownsTexture() const { return m_owns_texture; } + + void setTextureSize(const QSize &size) { m_texture_size = size; } + QSize textureSize() const override { return m_texture_size; } + + void setHasAlphaChannel(bool alpha) { m_has_alpha = alpha; } + bool hasAlphaChannel() const override { return m_has_alpha; } + + bool hasMipmaps() const override { return mipmapFiltering() != QSGTexture::None; } + + void setImage(const QImage &image); + const QImage &image() { return m_image; } + + qint64 comparisonKey() const override; + + QRhiTexture *rhiTexture() const override; + void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override; + + void setTexture(QRhiTexture *texture); + void setTextureFromNativeTexture(QRhi *rhi, + quint64 nativeObjectHandle, + int nativeLayoutOrState, + uint nativeFormat, + const QSize &size, + QQuickWindow::CreateTextureOptions options, + QQuickWindowPrivate::TextureFromNativeTextureFlags flags); + + static QSGPlainTexture *fromImage(const QImage &image) { + QSGPlainTexture *t = new QSGPlainTexture(); + t->setImage(image); + return t; + } + +protected: + QSGPlainTexture(QSGPlainTexturePrivate &dd); + + QImage m_image; + + QSize m_texture_size; + QRectF m_texture_rect; + QRhiTexture *m_texture; + + uint m_has_alpha : 1; + uint m_dirty_texture : 1; + uint m_dirty_bind_options : 1; // legacy (GL-only) + uint m_owns_texture : 1; + uint m_mipmaps_generated : 1; + uint m_retain_image : 1; + uint m_mipmap_warned : 1; // RHI only +}; + +class QSGPlainTexturePrivate : public QSGTexturePrivate +{ + Q_DECLARE_PUBLIC(QSGPlainTexture) +public: + QSGPlainTexturePrivate(QSGTexture *t) : QSGTexturePrivate(t) { } + QSGTexture::Filtering m_last_mipmap_filter = QSGTexture::None; +}; + +QT_END_NAMESPACE + +#endif // QSGPLAINTEXTURE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrenderer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrenderer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..86d4b1c00d2c32e6594d40b82ff03cf0ba92d230 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrenderer_p.h @@ -0,0 +1,174 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGRENDERER_P_H +#define QSGRENDERER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsgabstractrenderer_p_p.h" +#include "qsgnode.h" +#include "qsgmaterial.h" + +#include <QtQuick/private/qsgcontext_p.h> + +QT_BEGIN_NAMESPACE + +class QSGNodeUpdater; +class QRhiRenderTarget; +class QRhiCommandBuffer; +class QRhiRenderPassDescriptor; +class QRhiResourceUpdateBatch; + +Q_QUICK_EXPORT bool qsg_test_and_clear_fatal_render_error(); +Q_QUICK_EXPORT void qsg_set_fatal_renderer_error(); + +class Q_QUICK_EXPORT QSGRenderTarget +{ +public: + QSGRenderTarget() { } + + QSGRenderTarget(QRhiRenderTarget *rt, + QRhiRenderPassDescriptor *rpDesc, + QRhiCommandBuffer *cb) + : rt(rt), rpDesc(rpDesc), cb(cb) { } + + explicit QSGRenderTarget(QPaintDevice *paintDevice) + : paintDevice(paintDevice) { } + + QRhiRenderTarget *rt = nullptr; + // Store the rp descriptor obj separately, it can (even if often it won't) + // be different from rt->renderPassDescriptor(); e.g. one user is the 2D + // integration in Quick 3D which will use a different, but compatible rp. + QRhiRenderPassDescriptor *rpDesc = nullptr; + QRhiCommandBuffer *cb = nullptr; + + QPaintDevice *paintDevice = nullptr; + + int multiViewCount = 0; +}; + +class Q_QUICK_EXPORT QSGRenderer : public QSGAbstractRenderer +{ +public: + QSGRenderer(QSGRenderContext *context); + virtual ~QSGRenderer(); + + // Accessed by QSGMaterial[Rhi]Shader::RenderState. + QMatrix4x4 currentProjectionMatrix(int index) const { return m_current_projection_matrix[index]; } + QMatrix4x4 currentModelViewMatrix() const { return m_current_model_view_matrix; } + QMatrix4x4 currentCombinedMatrix(int index) const { return m_current_projection_matrix[index] * m_current_model_view_matrix; } + qreal currentOpacity() const { return m_current_opacity; } + qreal determinant() const { return m_current_determinant; } + + void setDevicePixelRatio(qreal ratio) { m_device_pixel_ratio = ratio; } + qreal devicePixelRatio() const { return m_device_pixel_ratio; } + QSGRenderContext *context() const { return m_context; } + + bool isMirrored() const; + void renderScene() override; + void prepareSceneInline() override; + void renderSceneInline() override; + void nodeChanged(QSGNode *node, QSGNode::DirtyState state) override; + + QSGNodeUpdater *nodeUpdater() const; + void setNodeUpdater(QSGNodeUpdater *updater); + inline QSGMaterialShader::RenderState state(QSGMaterialShader::RenderState::DirtyStates dirty) const; + virtual void setVisualizationMode(const QByteArray &) { } + virtual bool hasVisualizationModeWithContinuousUpdate() const { return false; } + virtual void releaseCachedResources() { } + + void clearChangedFlag() { m_changed_emitted = false; } + + // Accessed by QSGMaterialShader::RenderState. + QByteArray *currentUniformData() const { return m_current_uniform_data; } + QRhiResourceUpdateBatch *currentResourceUpdateBatch() const { return m_current_resource_update_batch; } + QRhi *currentRhi() const { return m_rhi; } + + void setRenderTarget(const QSGRenderTarget &rt) { m_rt = rt; } + const QSGRenderTarget &renderTarget() const { return m_rt; } + + void setRenderPassRecordingCallbacks(QSGRenderContext::RenderPassCallback start, + QSGRenderContext::RenderPassCallback end, + void *userData) + { + m_renderPassRecordingCallbacks.start = start; + m_renderPassRecordingCallbacks.end = end; + m_renderPassRecordingCallbacks.userData = userData; + } + +protected: + virtual void render() = 0; + + virtual void prepareInline(); + virtual void renderInline(); + + virtual void preprocess(); + + void addNodesToPreprocess(QSGNode *node); + void removeNodesToPreprocess(QSGNode *node); + + QVarLengthArray<QMatrix4x4, 1> m_current_projection_matrix; // includes adjustment, where applicable, so can be treated as Y up in NDC always + QVarLengthArray<QMatrix4x4, 1> m_current_projection_matrix_native_ndc; // Vulkan has Y down in normalized device coordinates, others Y up... + QMatrix4x4 m_current_model_view_matrix; + qreal m_current_opacity; + qreal m_current_determinant; + qreal m_device_pixel_ratio; + + QSGRenderContext *m_context; + + QByteArray *m_current_uniform_data; + QRhiResourceUpdateBatch *m_current_resource_update_batch; + QRhi *m_rhi; + QSGRenderTarget m_rt; + struct { + QSGRenderContext::RenderPassCallback start = nullptr; + QSGRenderContext::RenderPassCallback end = nullptr; + void *userData = nullptr; + } m_renderPassRecordingCallbacks; + +private: + QSGNodeUpdater *m_node_updater; + + QSet<QSGNode *> m_nodes_to_preprocess; + QSet<QSGNode *> m_nodes_dont_preprocess; + + uint m_changed_emitted : 1; + uint m_is_rendering : 1; + uint m_is_preprocessing : 1; +}; + +QSGMaterialShader::RenderState QSGRenderer::state(QSGMaterialShader::RenderState::DirtyStates dirty) const +{ + QSGMaterialShader::RenderState s; + s.m_dirty = dirty; + s.m_data = this; + return s; +} + + +class Q_QUICK_EXPORT QSGNodeDumper : public QSGNodeVisitor { + +public: + static void dump(QSGNode *n); + + QSGNodeDumper() {} + void visitNode(QSGNode *n) override; + void visitChildren(QSGNode *n) override; + +private: + int m_indent = 0; +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrenderloop_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrenderloop_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ca958db3b38c4d990bf58e81b633d2a1dc9f65cb --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrenderloop_p.h @@ -0,0 +1,127 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGRENDERLOOP_P_H +#define QSGRENDERLOOP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/qimage.h> +#include <QtGui/qsurface.h> +#include <private/qtquickglobal_p.h> +#include <QtCore/qset.h> +#include <QtCore/qobject.h> +#include <QtCore/qcoreevent.h> + +QT_BEGIN_NAMESPACE + +class QQuickWindow; +class QSGContext; +class QSGRenderContext; +class QAnimationDriver; +class QRunnable; + +class Q_QUICK_EXPORT QSGRenderLoop : public QObject +{ + Q_OBJECT + +public: + enum RenderLoopFlags { + SupportsGrabWithoutExpose = 0x01 + }; + + virtual ~QSGRenderLoop(); + + virtual void show(QQuickWindow *window) = 0; + virtual void hide(QQuickWindow *window) = 0; + virtual void resize(QQuickWindow *) {}; + + virtual void windowDestroyed(QQuickWindow *window) = 0; + + virtual void exposureChanged(QQuickWindow *window) = 0; + virtual QImage grab(QQuickWindow *window) = 0; + + virtual void update(QQuickWindow *window) = 0; + virtual void maybeUpdate(QQuickWindow *window) = 0; + virtual void handleUpdateRequest(QQuickWindow *) { } + + virtual QAnimationDriver *animationDriver() const = 0; + + virtual QSGContext *sceneGraphContext() const = 0; + virtual QSGRenderContext *createRenderContext(QSGContext *) const = 0; + + virtual void releaseResources(QQuickWindow *window) = 0; + virtual void postJob(QQuickWindow *window, QRunnable *job); + + void addWindow(QQuickWindow *win) { m_windows.insert(win); } + void removeWindow(QQuickWindow *win) { m_windows.remove(win); } + QSet<QQuickWindow *> windows() const { return m_windows; } + + virtual QSurface::SurfaceType windowSurfaceType() const; + + // ### make this less of a singleton + static QSGRenderLoop *instance(); + static void setInstance(QSGRenderLoop *instance); + + virtual bool interleaveIncubation() const { return false; } + + virtual int flags() const { return 0; } + + static void cleanup(); + + void handleContextCreationFailure(QQuickWindow *window); + +Q_SIGNALS: + void timeToIncubate(); + +private: + static QSGRenderLoop *s_instance; + + QSet<QQuickWindow *> m_windows; +}; + +enum QSGRenderLoopType +{ + BasicRenderLoop, + ThreadedRenderLoop +}; + +enum QSGCustomEvents { + +// Passed from the RL to the RT when a window is removed obscured and +// should be removed from the render loop. +WM_Obscure = QEvent::User + 1, + +// Passed from the RL to RT when GUI has been locked, waiting for sync +// (updatePaintNode()) +WM_RequestSync = QEvent::User + 2, + +// Passed by the RL to the RT to free up maybe release SG and GL contexts +// if no windows are rendering. +WM_TryRelease = QEvent::User + 4, + +// Passed by the RL to the RT when a QQuickWindow::grabWindow() is +// called. +WM_Grab = QEvent::User + 5, + +// Passed by the window when there is a render job to run +WM_PostJob = QEvent::User + 6, + +// When using the QRhi this is sent upon PlatformSurfaceAboutToBeDestroyed from +// the event filter installed on the QQuickWindow. +WM_ReleaseSwapchain = QEvent::User + 7, + +}; + +QT_END_NAMESPACE + +#endif // QSGRENDERLOOP_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrendernode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrendernode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..017bf9f49ee47567c23fed5b4c554029e0bed83a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrendernode_p.h @@ -0,0 +1,41 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGRENDERNODE_P_H +#define QSGRENDERNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qtquickglobal_p.h> +#include <QtQuick/qsgrendernode.h> +#include <QtQuick/private/qsgrenderer_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGRenderNodePrivate +{ +public: + QSGRenderNodePrivate(); + + static QSGRenderNodePrivate *get(QSGRenderNode *node) { return node->d; } + + const QMatrix4x4 *m_matrix; + const QSGClipNode *m_clip_list; + qreal m_opacity; + QSGRenderTarget m_rt; + QVarLengthArray<QMatrix4x4, 1> m_projectionMatrix; + QMatrix4x4 m_localMatrix; // ### Qt 7 m_matrix should not be a pointer +}; + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhiatlastexture_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhiatlastexture_p.h new file mode 100644 index 0000000000000000000000000000000000000000..df9eafc21be9e602de08bdbee688546de4cf3398 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhiatlastexture_p.h @@ -0,0 +1,169 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGRHIATLASTEXTURE_P_H +#define QSGRHIATLASTEXTURE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/QSize> +#include <QtQuick/private/qsgplaintexture_p.h> +#include <QtQuick/private/qsgareaallocator_p.h> +#include <QtGui/QSurface> +#include <rhi/qrhi.h> + +QT_BEGIN_NAMESPACE + +class QSGDefaultRenderContext; + +namespace QSGCompressedAtlasTexture { + class Atlas; +} +class QSGCompressedTextureFactory; + +namespace QSGRhiAtlasTexture +{ + +class Texture; +class TextureBase; +class Atlas; + +class Manager : public QObject +{ + Q_OBJECT + +public: + Manager(QSGDefaultRenderContext *rc, const QSize &surfacePixelSize, QSurface *maybeSurface); + ~Manager(); + + QSGTexture *create(const QImage &image, bool hasAlphaChannel); + QSGTexture *create(const QSGCompressedTextureFactory *factory); + void invalidate(); + +private: + QSGDefaultRenderContext *m_rc; + QRhi *m_rhi; + Atlas *m_atlas = nullptr; + // set of atlases for different compressed formats + QHash<unsigned int, QSGCompressedAtlasTexture::Atlas*> m_atlases; + + QSize m_atlas_size; + int m_atlas_size_limit; +}; + +class AtlasBase : public QObject +{ + Q_OBJECT +public: + AtlasBase(QSGDefaultRenderContext *rc, const QSize &size); + ~AtlasBase(); + + void invalidate(); + void commitTextureOperations(QRhiResourceUpdateBatch *resourceUpdates); + void remove(TextureBase *t); + + QSGDefaultRenderContext *renderContext() const { return m_rc; } + QRhi *rhi() const { return m_rhi; } + QRhiTexture *texture() const { return m_texture; } + QSize size() const { return m_size; } + +protected: + virtual bool generateTexture() = 0; + virtual void enqueueTextureUpload(TextureBase *t, QRhiResourceUpdateBatch *resourceUpdates) = 0; + +protected: + QSGDefaultRenderContext *m_rc; + QRhi *m_rhi; + QSGAreaAllocator m_allocator; + QRhiTexture *m_texture = nullptr; + QSize m_size; + QVector<TextureBase *> m_pending_uploads; + friend class TextureBase; + friend class TextureBasePrivate; + +private: + bool m_allocated = false; +}; + +class Atlas : public AtlasBase +{ +public: + Atlas(QSGDefaultRenderContext *rc, const QSize &size); + ~Atlas(); + + bool generateTexture() override; + void enqueueTextureUpload(TextureBase *t, QRhiResourceUpdateBatch *resourceUpdates) override; + + Texture *create(const QImage &image); + + QRhiTexture::Format format() const { return m_format; } + +private: + QRhiTexture::Format m_format; + int m_atlas_transient_image_threshold = 0; + + uint m_debug_overlay : 1; +}; + +class TextureBase : public QSGTexture +{ + Q_OBJECT +public: + TextureBase(AtlasBase *atlas, const QRect &textureRect); + ~TextureBase(); + + qint64 comparisonKey() const override; + QRhiTexture *rhiTexture() const override; + void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override; + + bool isAtlasTexture() const override { return true; } + QRect atlasSubRect() const { return m_allocated_rect; } + +protected: + QRect m_allocated_rect; + AtlasBase *m_atlas; +}; + +class Texture : public TextureBase +{ + Q_OBJECT +public: + Texture(Atlas *atlas, const QRect &textureRect, const QImage &image); + ~Texture(); + + QSize textureSize() const override { return atlasSubRectWithoutPadding().size(); } + void setHasAlphaChannel(bool alpha) { m_has_alpha = alpha; } + bool hasAlphaChannel() const override { return m_has_alpha; } + bool hasMipmaps() const override { return false; } + + QRectF normalizedTextureSubRect() const override { return m_texture_coords_rect; } + + QRect atlasSubRect() const { return m_allocated_rect; } + QRect atlasSubRectWithoutPadding() const { return m_allocated_rect.adjusted(1, 1, -1, -1); } + + QSGTexture *removedFromAtlas(QRhiResourceUpdateBatch *resourceUpdates) const override; + + void releaseImage() { m_image = QImage(); } + const QImage &image() const { return m_image; } + +private: + QRectF m_texture_coords_rect; + QImage m_image; + mutable QSGPlainTexture *m_nonatlas_texture = nullptr; + bool m_has_alpha; +}; + +} + +QT_END_NAMESPACE + +#endif diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhidistancefieldglyphcache_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhidistancefieldglyphcache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0a1a89e3f21a68df435d939d6f0e9f23c051d0af --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhidistancefieldglyphcache_p.h @@ -0,0 +1,98 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGRHIDISTANCEFIELDGLYPHCACHE_H +#define QSGRHIDISTANCEFIELDGLYPHCACHE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsgadaptationlayer_p.h" +#include <private/qsgareaallocator_p.h> +#include <rhi/qrhi.h> + +QT_BEGIN_NAMESPACE + +class QSGDefaultRenderContext; + +class Q_QUICK_EXPORT QSGRhiDistanceFieldGlyphCache : public QSGDistanceFieldGlyphCache +{ +public: + QSGRhiDistanceFieldGlyphCache(QSGDefaultRenderContext *rc, const QRawFont &font, int renderTypeQuality); + virtual ~QSGRhiDistanceFieldGlyphCache(); + + void requestGlyphs(const QSet<glyph_t> &glyphs) override; + void storeGlyphs(const QList<QDistanceField> &glyphs) override; + void referenceGlyphs(const QSet<glyph_t> &glyphs) override; + void releaseGlyphs(const QSet<glyph_t> &glyphs) override; + + bool useTextureResizeWorkaround() const; + bool createFullSizeTextures() const; + bool isActive() const override; + int maxTextureSize() const; + + void setMaxTextureCount(int max) { m_maxTextureCount = max; } + int maxTextureCount() const { return m_maxTextureCount; } + + void commitResourceUpdates(QRhiResourceUpdateBatch *mergeInto); + + bool eightBitFormatIsAlphaSwizzled() const override; + bool screenSpaceDerivativesSupported() const override; + +#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG) + void saveTexture(QRhiTexture *texture, const QString &nameBase) const override; +#endif + +private: + bool loadPregeneratedCache(const QRawFont &font); + + struct TextureInfo { + QRhiTexture *texture; + QSize size; + QRect allocatedArea; + QDistanceField image; + int padding = -1; + QVarLengthArray<QRhiTextureUploadEntry, 16> uploads; + + TextureInfo(const QRect &preallocRect = QRect()) : texture(nullptr), allocatedArea(preallocRect) { } + }; + + void createTexture(TextureInfo *texInfo, int width, int height, const void *pixels); + void createTexture(TextureInfo *texInfo, int width, int height); + void resizeTexture(TextureInfo *texInfo, int width, int height); + + TextureInfo *textureInfo(int index) + { + for (int i = m_textures.size(); i <= index; ++i) { + if (createFullSizeTextures()) + m_textures.append(QRect(0, 0, maxTextureSize(), maxTextureSize())); + else + m_textures.append(TextureInfo()); + } + + return &m_textures[index]; + } + + QSGDefaultRenderContext *m_rc; + QRhi *m_rhi; + mutable int m_maxTextureSize = 0; + int m_maxTextureCount = 3; + QSGAreaAllocator *m_areaAllocator = nullptr; + QList<TextureInfo> m_textures; + QHash<glyph_t, TextureInfo *> m_glyphsTexture; + QSet<glyph_t> m_unusedGlyphs; + QSet<glyph_t> m_referencedGlyphs; + QSet<QRhiTexture *> m_pendingDispose; +}; + +QT_END_NAMESPACE + +#endif // QSGRHIDISTANCEFIELDGLYPHCACHE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhiinternaltextnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhiinternaltextnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..c985b4edebc4be4d8c77e691b5041653106e492b --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhiinternaltextnode_p.h @@ -0,0 +1,31 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGRHIINTERNALTEXTNODE_P_H +#define QSGRHIINTERNALTEXTNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsginternaltextnode_p.h> + +QT_BEGIN_NAMESPACE + +class QSGRhiInternalTextNode : public QSGInternalTextNode +{ +public: + QSGRhiInternalTextNode(QSGRenderContext *renderContext); + void addDecorationNode(const QRectF &rect, const QColor &color) override; +}; + +QT_END_NAMESPACE + +#endif // QSGRHIINTERNALTEXTNODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhilayer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhilayer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..ce9519284af85c051098f61c553a69b1e3b19de6 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhilayer_p.h @@ -0,0 +1,98 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QSGRHILAYER_P_H +#define QSGRHILAYER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> +#include <private/qsgcontext_p.h> +#include <private/qsgtexture_p.h> +#include <rhi/qrhi.h> + +QT_BEGIN_NAMESPACE + +class QSGDefaultRenderContext; + +class Q_QUICK_EXPORT QSGRhiLayer : public QSGLayer +{ + Q_OBJECT + +public: + QSGRhiLayer(QSGRenderContext *context); + ~QSGRhiLayer(); + + bool updateTexture() override; + + bool hasAlphaChannel() const override; + bool hasMipmaps() const override; + QSize textureSize() const override { return m_pixelSize; } + + qint64 comparisonKey() const override; + QRhiTexture *rhiTexture() const override; + void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override; + + void setItem(QSGNode *item) override; + void setRect(const QRectF &logicalRect) override; + void setSize(const QSize &pixelSize) override; + void setHasMipmaps(bool mipmap) override; + void setFormat(Format format) override; + void setLive(bool live) override; + void setRecursive(bool recursive) override; + void setDevicePixelRatio(qreal ratio) override { m_dpr = ratio; } + void setMirrorHorizontal(bool mirror) override; + void setMirrorVertical(bool mirror) override; + QRectF normalizedTextureSubRect() const override; + void setSamples(int samples) override { m_samples = samples; } + + void scheduleUpdate() override; + QImage toImage() const override; + +public Q_SLOTS: + void markDirtyTexture() override; + void invalidated() override; + +private: + void grab(); + void releaseResources(); + + QSGNode *m_item = nullptr; + QRectF m_logicalRect; + QSize m_pixelSize; + qreal m_dpr = 1; + QRhiTexture::Format m_format = QRhiTexture::RGBA8; + + QSGRenderer *m_renderer = nullptr; + QRhiTexture *m_texture = nullptr; + QRhiRenderBuffer *m_ds = nullptr; + QRhiRenderBuffer *m_msaaColorBuffer = nullptr; + QRhiTexture *m_secondaryTexture = nullptr; + QRhiTextureRenderTarget *m_rt = nullptr; + QRhiRenderPassDescriptor *m_rtRp = nullptr; + + QSGDefaultRenderContext *m_context = nullptr; + QRhi *m_rhi = nullptr; + int m_samples = 0; + + uint m_mipmap : 1; + uint m_live : 1; + uint m_recursive : 1; + uint m_dirtyTexture : 1; + uint m_multisampling : 1; + uint m_grab : 1; + uint m_mirrorHorizontal : 1; + uint m_mirrorVertical : 1; +}; + +QT_END_NAMESPACE + +#endif // QSGRHILAYER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhishadereffectnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhishadereffectnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b23a19f8fef404e858e9d5b2a10a2b2366d69d9e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhishadereffectnode_p.h @@ -0,0 +1,129 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGRHISHADEREFFECTNODE_P_H +#define QSGRHISHADEREFFECTNODE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> +#include <qsgmaterial.h> +#include <QUrl> + +QT_BEGIN_NAMESPACE + +class QSGDefaultRenderContext; +class QSGPlainTexture; +class QSGRhiShaderEffectNode; +class QFileSelector; + +class QSGRhiShaderLinker +{ +public: + void reset(const QShader &vs, const QShader &fs); + + void feedConstants(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices = nullptr); + void feedSamplers(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices = nullptr); + void linkTextureSubRects(); + + void dump(); + + struct Constant { + uint size; + QSGShaderEffectNode::VariableData::SpecialType specialType; + QVariant value; + bool operator==(const Constant &other) const { + return size == other.size && specialType == other.specialType + && (specialType == QSGShaderEffectNode::VariableData::None ? value == other.value : true); + } + }; + + bool m_error; + QShader m_vs; + QShader m_fs; + QHash<uint, Constant> m_constants; // offset -> Constant + QHash<int, QVariant> m_samplers; // binding -> value (source ref) + QHash<QByteArray, int> m_samplerNameMap; // name -> binding + QSet<int> m_subRectBindings; +}; + +QDebug operator<<(QDebug debug, const QSGRhiShaderLinker::Constant &c); + +class QSGRhiShaderEffectMaterial : public QSGMaterial +{ +public: + QSGRhiShaderEffectMaterial(QSGRhiShaderEffectNode *node); + ~QSGRhiShaderEffectMaterial(); + + int compare(const QSGMaterial *other) const override; + QSGMaterialType *type() const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; + + void updateTextureProviders(bool layoutChange); + + bool usesSubRectUniform(int binding) const { return m_linker.m_subRectBindings.contains(binding); } + + static const int MAX_BINDINGS = 32; + + QSGRhiShaderEffectNode *m_node; + QSGMaterialType *m_materialType = nullptr; + void *m_materialTypeCacheKey = nullptr; + QSGRhiShaderLinker m_linker; + QVector<QSGTextureProvider *> m_textureProviders; // [binding] = QSGTextureProvider + bool m_geometryUsesTextureSubRect = false; + QSGShaderEffectNode::CullMode m_cullMode = QSGShaderEffectNode::NoCulling; + bool m_hasCustomVertexShader = false; + bool m_hasCustomFragmentShader = false; + QShader m_vertexShader; + QShader m_fragmentShader; + QSGPlainTexture *m_dummyTexture = nullptr; +}; + +class QSGRhiShaderEffectNode : public QSGShaderEffectNode +{ + Q_OBJECT + +public: + QSGRhiShaderEffectNode(QSGDefaultRenderContext *rc); + + QRectF updateNormalizedTextureSubRect(bool supportsAtlasTextures) override; + void syncMaterial(SyncData *syncData) override; + void preprocess() override; + + static void resetMaterialTypeCache(void *materialTypeCacheKey); + static void garbageCollectMaterialTypeCache(void *materialTypeCacheKey); + +private Q_SLOTS: + void handleTextureChange(); + void handleTextureProviderDestroyed(QObject *object); + +private: + QSGRhiShaderEffectMaterial m_material; +}; + +class QSGRhiGuiThreadShaderEffectManager : public QSGGuiThreadShaderEffectManager +{ +public: + bool hasSeparateSamplerAndTextureObjects() const override; + QString log() const override; + Status status() const override; + void prepareShaderCode(ShaderInfo::Type typeHint, const QUrl &src, ShaderInfo *result) override; + +private: + bool reflect(ShaderInfo *result); + Status m_status = Uncompiled; + QFileSelector *m_fileSelector = nullptr; +}; + +QT_END_NAMESPACE + +#endif // QSGRHISHADEREFFECTNODE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhisupport_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhisupport_p.h new file mode 100644 index 0000000000000000000000000000000000000000..925703245c597b3703c9b42a872ba74735e8953d --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhisupport_p.h @@ -0,0 +1,111 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGRHISUPPORT_P_H +#define QSGRHISUPPORT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsgrenderloop_p.h" +#include "qsgrendererinterface.h" + +#include <rhi/qrhi.h> + +QT_BEGIN_NAMESPACE + +class QSGDefaultRenderContext; +class QOffscreenSurface; +class QQuickGraphicsConfiguration; + +// Opting in/out of QRhi and choosing the default/requested backend is managed +// by this singleton. This is because this information may be needed before +// creating a render loop. A well-written render loop sets up its QRhi and +// related machinery using the helper functions in here. +// +// In addition, the class provides handy conversion and query stuff for the +// renderloop and the QSGRendererInterface implementations. +// +class Q_QUICK_EXPORT QSGRhiSupport +{ +public: + static QSGRhiSupport *instance_internal(); + static QSGRhiSupport *instance(); + static int chooseSampleCount(int samples, QRhi *rhi); + static int chooseSampleCountForWindowWithRhi(QWindow *window, QRhi *rhi); + static QImage grabAndBlockInCurrentFrame(QRhi *rhi, QRhiCommandBuffer *cb, QRhiTexture *src = nullptr); + static void checkEnvQSgInfo(); + +#if QT_CONFIG(opengl) + static QRhiTexture::Format toRhiTextureFormatFromGL(uint format, QRhiTexture::Flags *flags); +#endif + +#if QT_CONFIG(vulkan) + static QRhiTexture::Format toRhiTextureFormatFromVulkan(uint format, QRhiTexture::Flags *flags); +#endif + +#if defined(Q_OS_WIN) + static QRhiTexture::Format toRhiTextureFormatFromDXGI(uint format, QRhiTexture::Flags *flags); +#endif + +#if QT_CONFIG(metal) + static QRhiTexture::Format toRhiTextureFormatFromMetal(uint format, QRhiTexture::Flags *flags); +#endif + + void configure(QSGRendererInterface::GraphicsApi api); + + QRhi::Implementation rhiBackend() const { return m_rhiBackend; } + QString rhiBackendName() const; + QSGRendererInterface::GraphicsApi graphicsApi() const; + + QSurface::SurfaceType windowSurfaceType() const; + + const void *rifResource(QSGRendererInterface::Resource res, + const QSGDefaultRenderContext *rc, + const QQuickWindow *w); + + QOffscreenSurface *maybeCreateOffscreenSurface(QWindow *window); + struct RhiCreateResult { + QRhi *rhi; + bool own; + }; + RhiCreateResult createRhi(QQuickWindow *window, QSurface *offscreenSurface, bool forcePreferSwRenderer = false); + void destroyRhi(QRhi *rhi, const QQuickGraphicsConfiguration &config); + void prepareWindowForRhi(QQuickWindow *window); + + QImage grabOffscreen(QQuickWindow *window); +#ifdef Q_OS_WEBOS + QImage grabOffscreenForProtectedContent(QQuickWindow *window); +#endif + + void applySwapChainFormat(QRhiSwapChain *scWithWindowSet, QQuickWindow *window); + + QRhiTexture::Format toRhiTextureFormat(uint nativeFormat, QRhiTexture::Flags *flags) const; + + bool attemptReinitWithSwRastUponFail() const; + +private: + QSGRhiSupport(); + void applySettings(); + void adjustToPlatformQuirks(); + void preparePipelineCache(QRhi *rhi, QQuickWindow *window); + void finalizePipelineCache(QRhi *rhi, const QQuickGraphicsConfiguration &config); + struct { + bool valid = false; + QSGRendererInterface::GraphicsApi api; + } m_requested; + bool m_settingsApplied = false; + QRhi::Implementation m_rhiBackend = QRhi::Null; +}; + +QT_END_NAMESPACE + +#endif // QSGRHISUPPORT_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhitextureglyphcache_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhitextureglyphcache_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5dcda8a8cc68a220e3303908dd9c5d05f32dcbd7 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhitextureglyphcache_p.h @@ -0,0 +1,67 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGRHITEXTUREGLYPHCACHE_P_H +#define QSGRHITEXTUREGLYPHCACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtextureglyphcache_p.h> +#include <rhi/qrhi.h> + +QT_BEGIN_NAMESPACE + +class QSGDefaultRenderContext; + +class QSGRhiTextureGlyphCache : public QImageTextureGlyphCache +{ +public: + QSGRhiTextureGlyphCache(QSGDefaultRenderContext *rc, + QFontEngine::GlyphFormat format, const QTransform &matrix, + const QColor &color = QColor()); + ~QSGRhiTextureGlyphCache(); + + void createTextureData(int width, int height) override; + void resizeTextureData(int width, int height) override; + void beginFillTexture() override; + void fillTexture(const Coord &c, glyph_t glyph, const QFixedPoint &subPixelPosition) override; + void endFillTexture() override; + int glyphPadding() const override; + int maxTextureWidth() const override; + int maxTextureHeight() const override; + + QRhiTexture *texture() const { return m_texture; } + void commitResourceUpdates(QRhiResourceUpdateBatch *mergeInto); + + // Clamp the default -1 width and height to 0 for compatibility with + // QOpenGLTextureGlyphCache. + int width() const { return qMax(0, m_size.width()); } + int height() const { return qMax(0, m_size.height()); } + + bool eightBitFormatIsAlphaSwizzled() const; + +private: + void prepareGlyphImage(QImage *img); + QRhiTexture *createEmptyTexture(QRhiTexture::Format format); + + QSGDefaultRenderContext *m_rc; + QRhi *m_rhi; + bool m_resizeWithTextureCopy; + QRhiTexture *m_texture = nullptr; + QSize m_size; + bool m_bgra = false; + QVarLengthArray<QRhiTextureUploadEntry, 16> m_uploads; +}; + +QT_END_NAMESPACE + +#endif // QSGRHITEXTUREGLYPHCACHE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhivisualizer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhivisualizer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e001a9904d75576068fa58a5099b5bcad94862a0 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgrhivisualizer_p.h @@ -0,0 +1,201 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> +// Copyright (C) 2016 Robin Burchell <robin.burchell@viroteck.net> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGRHIVISUALIZER_P_H +#define QSGRHIVISUALIZER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsgbatchrenderer_p.h" + +#include <QtCore/qrandom.h> + +QT_BEGIN_NAMESPACE + +namespace QSGBatchRenderer +{ + +class RhiVisualizer : public Visualizer +{ +public: + RhiVisualizer(Renderer *renderer); + ~RhiVisualizer(); + + void prepareVisualize() override; + void visualize() override; + + void releaseResources() override; + + struct DrawCall + { + static const int UBUF_SIZE = 152; // visualization.vert/frag + struct { + char data[UBUF_SIZE]; // matrix, rotation, color, pattern, projection + } uniforms; + struct { + QRhiGraphicsPipeline::Topology topology; + QRhiVertexInputAttribute::Format format; + int count; + int stride; + const void *data; // only when using own vbuf + } vertex; + struct { + QRhiCommandBuffer::IndexFormat format; + int count; + int stride; + const void *data; // only when using own ibuf + } index; + struct { + QRhiBuffer *vbuf; // either same for all draw calls and owned by the *Vis, or points to a Batch.Buffer.vbo.buf + int vbufOffset; + QRhiBuffer *ibuf; // same, but for index + int ibufOffset; + int ubufOffset; + } buf; + }; + +private: + QShader m_vs; + QShader m_fs; + + void recordDrawCalls(const QVector<DrawCall> &drawCalls, + QRhiCommandBuffer *cb, + QRhiShaderResourceBindings *srb, + bool blendOneOne = false); + + class PipelineCache { + public: + QRhiGraphicsPipeline *pipeline(RhiVisualizer *visualizer, + QRhi *rhi, + QRhiShaderResourceBindings *srb, + QRhiRenderPassDescriptor *rpDesc, + QRhiGraphicsPipeline::Topology topology, + QRhiVertexInputAttribute::Format vertexFormat, + quint32 vertexStride, + bool blendOneOne); + void releaseResources(); + private: + struct Pipeline { + QRhiGraphicsPipeline::Topology topology; + QRhiVertexInputAttribute::Format format; + quint32 stride; + QRhiGraphicsPipeline *ps; + }; + QVarLengthArray<Pipeline, 16> pipelines; + }; + + PipelineCache m_pipelines; + + class Fade { + public: + void prepare(RhiVisualizer *visualizer, + QRhi *rhi, QRhiResourceUpdateBatch *u, QRhiRenderPassDescriptor *rpDesc); + void releaseResources(); + void render(QRhiCommandBuffer *cb); + private: + RhiVisualizer *visualizer; + QRhiBuffer *vbuf = nullptr; + QRhiBuffer *ubuf = nullptr; + QRhiGraphicsPipeline *ps = nullptr; + QRhiShaderResourceBindings *srb = nullptr; + } m_fade; + + class ChangeVis { + public: + void prepare(Node *n, RhiVisualizer *visualizer, + QRhi *rhi, QRhiResourceUpdateBatch *u); + void releaseResources(); + void render(QRhiCommandBuffer *cb); + private: + void gather(Node *n); + RhiVisualizer *visualizer; + QVector<DrawCall> drawCalls; + QRhiBuffer *vbuf = nullptr; + QRhiBuffer *ibuf = nullptr; + QRhiBuffer *ubuf = nullptr; + QRhiShaderResourceBindings *srb = nullptr; + } m_changeVis; + + class BatchVis { + public: + void prepare(const QDataBuffer<Batch *> &opaqueBatches, + const QDataBuffer<Batch *> &alphaBatches, + RhiVisualizer *visualizer, + QRhi *rhi, QRhiResourceUpdateBatch *u, + bool forceUintIndex); + void releaseResources(); + void render(QRhiCommandBuffer *cb); + private: + void gather(Batch *b); + RhiVisualizer *visualizer; + bool forceUintIndex; + QVector<DrawCall> drawCalls; + QRhiBuffer *ubuf = nullptr; + QRhiShaderResourceBindings *srb = nullptr; + } m_batchVis; + + class ClipVis { + public: + void prepare(QSGNode *node, RhiVisualizer *visualizer, + QRhi *rhi, QRhiResourceUpdateBatch *u); + void releaseResources(); + void render(QRhiCommandBuffer *cb); + private: + void gather(QSGNode *node); + RhiVisualizer *visualizer; + QVector<DrawCall> drawCalls; + QRhiBuffer *vbuf = nullptr; + QRhiBuffer *ibuf = nullptr; + QRhiBuffer *ubuf = nullptr; + QRhiShaderResourceBindings *srb = nullptr; + } m_clipVis; + + class OverdrawVis { + public: + void prepare(Node *n, RhiVisualizer *visualizer, + QRhi *rhi, QRhiResourceUpdateBatch *u); + void releaseResources(); + void render(QRhiCommandBuffer *cb); + private: + void gather(Node *n); + RhiVisualizer *visualizer; + QVector<DrawCall> drawCalls; + QRhiBuffer *vbuf = nullptr; + QRhiBuffer *ibuf = nullptr; + QRhiBuffer *ubuf = nullptr; + QRhiShaderResourceBindings *srb = nullptr; + float step = 0.0f; + QMatrix4x4 rotation; + struct { + QRhiBuffer *vbuf = nullptr; + QRhiBuffer *ubuf = nullptr; + QRhiShaderResourceBindings *srb = nullptr; + QRhiGraphicsPipeline *ps = nullptr; + } box; + } m_overdrawVis; + + QRandomGenerator m_randomGenerator; + + friend class Fade; + friend class PipelineCache; + friend class ChangeVis; + friend class ClipVis; + friend class OverdrawVis; +}; + +} // namespace QSGBatchRenderer + +QT_END_NAMESPACE + +#endif // QSGRHIVISUALIZER_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareadaptation_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareadaptation_p.h new file mode 100644 index 0000000000000000000000000000000000000000..05f20d3d2da8a0d087e1b48a9d7f9abd923300ed --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareadaptation_p.h @@ -0,0 +1,41 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef PLUGINMAIN_H +#define PLUGINMAIN_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgcontextplugin_p.h> + +QT_BEGIN_NAMESPACE + +class QSGContext; +class QSGRenderLoop; +class QSGSoftwareContext; + +class QSGSoftwareAdaptation : public QSGContextPlugin +{ +public: + QSGSoftwareAdaptation(QObject *parent = nullptr); + + QStringList keys() const override; + QSGContext *create(const QString &key) const override; + QSGContextFactoryInterface::Flags flags(const QString &key) const override; + QSGRenderLoop *createWindowManager() override; +private: + static QSGSoftwareContext *instance; +}; + +QT_END_NAMESPACE + +#endif // PLUGINMAIN_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarecontext_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarecontext_p.h new file mode 100644 index 0000000000000000000000000000000000000000..909274c8435cb5e298471999a510e9f78fcd3f1c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarecontext_p.h @@ -0,0 +1,78 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWARECONTEXT_H +#define QSGSOFTWARECONTEXT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgcontext_p.h> +#include <private/qsgadaptationlayer_p.h> +#include "qsgrendererinterface.h" + +Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_TIME_RENDERLOOP) +Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_TIME_COMPILATION) +Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_TIME_TEXTURE) +Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_TIME_GLYPH) +Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_TIME_RENDERER) +Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_INFO) +Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_RENDERLOOP) + +QT_BEGIN_NAMESPACE + +class QSGSoftwareRenderContext : public QSGRenderContext +{ + Q_OBJECT +public: + QSGSoftwareRenderContext(QSGContext *ctx); + void initializeIfNeeded(); + void invalidate() override; + void renderNextFrame(QSGRenderer *renderer) override; + QSGTexture *createTexture(const QImage &image, uint flags = CreateTexture_Alpha) const override; + QSGRenderer *createRenderer(QSGRendererInterface::RenderMode) override; + int maxTextureSize() const override; + + bool m_initialized; + QPainter *m_activePainter; +}; + +class QSGSoftwareContext : public QSGContext, public QSGRendererInterface +{ + Q_OBJECT +public: + explicit QSGSoftwareContext(QObject *parent = nullptr); + + QSGRenderContext *createRenderContext() override { return new QSGSoftwareRenderContext(this); } + QSGInternalRectangleNode *createInternalRectangleNode() override; + QSGInternalImageNode *createInternalImageNode(QSGRenderContext *renderContext) override; + QSGPainterNode *createPainterNode(QQuickPaintedItem *item) override; + QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, QSGTextNode::RenderType renderType, int renderTypeQuality) override; + QSGLayer *createLayer(QSGRenderContext *renderContext) override; + QSurfaceFormat defaultSurfaceFormat() const override; + QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext) override; + QSGRectangleNode *createRectangleNode() override; + QSGImageNode *createImageNode() override; + QSGNinePatchNode *createNinePatchNode() override; +#if QT_CONFIG(quick_sprite) + QSGSpriteNode *createSpriteNode() override; +#endif + + GraphicsApi graphicsApi() const override; + ShaderType shaderType() const override; + ShaderCompilationTypes shaderCompilationType() const override; + ShaderSourceTypes shaderSourceType() const override; + void *getResource(QQuickWindow *window, Resource resource) const override; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWARECONTEXT_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareglyphnode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareglyphnode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..10abdf26f95913efbad52e6db03aec479af7f808 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareglyphnode_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWAREGLYPHNODE_H +#define QSGSOFTWAREGLYPHNODE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> + +QT_BEGIN_NAMESPACE + +class QSGSoftwareGlyphNode : public QSGGlyphNode +{ +public: + QSGSoftwareGlyphNode(); + + void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override; + void setColor(const QColor &color) override; + void setStyle(QQuickText::TextStyle style) override; + void setStyleColor(const QColor &color) override; + QPointF baseLine() const override; + void setPreferredAntialiasingMode(AntialiasingMode) override; + void update() override; + + void paint(QPainter *painter); + +private: + QPointF m_position; + QGlyphRun m_glyphRun; + QColor m_color; + QSGGeometry m_geometry; + QQuickText::TextStyle m_style; + QColor m_styleColor; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWAREGLYPHNODE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareinternalimagenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareinternalimagenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e156bb21c9110c32a418cf4d1a3a837bed257fe8 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareinternalimagenode_p.h @@ -0,0 +1,115 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWAREINTERNALIMAGENODE_H +#define QSGSOFTWAREINTERNALIMAGENODE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> +#include <private/qsgtexturematerial_p.h> + +#include <QtCore/QPointer> + +QT_BEGIN_NAMESPACE + +namespace QSGSoftwareHelpers { + +typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray; + +struct QTileRules +{ + inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule) + : horizontal(horizontalRule), vertical(verticalRule) {} + inline QTileRules(Qt::TileRule rule = Qt::StretchTile) + : horizontal(rule), vertical(rule) {} + Qt::TileRule horizontal; + Qt::TileRule vertical; +}; + +#ifndef Q_QDOC +// For internal use only. +namespace QDrawBorderPixmap +{ + enum DrawingHint + { + OpaqueTopLeft = 0x0001, + OpaqueTop = 0x0002, + OpaqueTopRight = 0x0004, + OpaqueLeft = 0x0008, + OpaqueCenter = 0x0010, + OpaqueRight = 0x0020, + OpaqueBottomLeft = 0x0040, + OpaqueBottom = 0x0080, + OpaqueBottomRight = 0x0100, + OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight, + OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom, + OpaqueFrame = OpaqueCorners | OpaqueEdges, + OpaqueAll = OpaqueCenter | OpaqueFrame + }; + + Q_DECLARE_FLAGS(DrawingHints, DrawingHint) +} +#endif + +void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, + const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins, + const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints); + +} // QSGSoftwareHelpers namespace + +class QSGSoftwareInternalImageNode : public QSGInternalImageNode +{ +public: + QSGSoftwareInternalImageNode(); + + void setTargetRect(const QRectF &rect) override; + void setInnerTargetRect(const QRectF &rect) override; + void setInnerSourceRect(const QRectF &rect) override; + void setSubSourceRect(const QRectF &rect) override; + void setTexture(QSGTexture *texture) override; + void setMirror(bool mirrorHorizontally, bool mirrorVertically) override; + void setMipmapFiltering(QSGTexture::Filtering filtering) override; + void setFiltering(QSGTexture::Filtering filtering) override; + void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) override; + void setVerticalWrapMode(QSGTexture::WrapMode wrapMode) override; + void update() override; + + void preprocess() override; + + void paint(QPainter *painter); + + QRectF rect() const; + + const QPixmap &pixmap() const; +private: + void updateCachedMirroredPixmap(); + QRectF m_targetRect; + QRectF m_innerTargetRect; + QRectF m_innerSourceRect; + QRectF m_subSourceRect; + + QPointer<QSGTexture> m_texture; + QPixmap m_cachedMirroredPixmap; + + bool m_mirrorHorizontally; + bool m_mirrorVertically; + bool m_textureIsLayer; + bool m_smooth; + bool m_tileHorizontal; + bool m_tileVertical; + bool m_cachedMirroredPixmapIsDirty; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWAREINTERNALIMAGENODE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareinternalrectanglenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareinternalrectanglenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..9bfb6733a8dd512f1cacbbaae72c9900413d08af --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwareinternalrectanglenode_p.h @@ -0,0 +1,78 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWAREINTERNALRECTANGLENODE_H +#define QSGSOFTWAREINTERNALRECTANGLENODE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> + +#include <QPen> +#include <QBrush> +#include <QPixmap> + +QT_BEGIN_NAMESPACE + +class QSGSoftwareInternalRectangleNode : public QSGInternalRectangleNode +{ +public: + QSGSoftwareInternalRectangleNode(); + + void setRect(const QRectF &rect) override; + void setColor(const QColor &color) override; + void setPenColor(const QColor &color) override; + void setPenWidth(qreal width) override; + void setGradientStops(const QGradientStops &stops) override; + void setGradientVertical(bool vertical) override; + void setRadius(qreal radius) override; + void setTopLeftRadius(qreal radius) override; + void setTopRightRadius(qreal radius) override; + void setBottomLeftRadius(qreal radius) override; + void setBottomRightRadius(qreal radius) override; + void setAntialiasing(bool antialiasing) override { Q_UNUSED(antialiasing); } + void setAligned(bool aligned) override; + + void update() override; + + void paint(QPainter *); + + bool isOpaque() const; + QRectF rect() const; +private: + void paintRectangle(QPainter *painter, const QRect &rect); + void paintRectangleIndividualCorners(QPainter *painter, const QRect &rect); + void generateCornerPixmap(); + + QRect m_rect; + QColor m_color; + QColor m_penColor; + qreal m_penWidth; + QGradientStops m_stops; + qreal m_radius; + qreal m_topLeftRadius; + qreal m_topRightRadius; + qreal m_bottomLeftRadius; + qreal m_bottomRightRadius; + QPen m_pen; + QBrush m_brush; + bool m_vertical; + + bool m_cornerPixmapIsDirty; + QPixmap m_cornerPixmap; + + qreal m_devicePixelRatio; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWAREINTERNALRECTANGLENODE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarelayer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarelayer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..88384c8e9542f7e823d196e115b45daa01b794ce --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarelayer_p.h @@ -0,0 +1,86 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWARELAYER_H +#define QSGSOFTWARELAYER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> +#include <private/qsgcontext_p.h> +#include <private/qsgtexture_p.h> + +QT_BEGIN_NAMESPACE + +class QSGSoftwarePixmapRenderer; + +class QSGSoftwareLayer : public QSGLayer +{ + Q_OBJECT +public: + QSGSoftwareLayer(QSGRenderContext *renderContext); + ~QSGSoftwareLayer(); + + const QPixmap &pixmap() const { return m_pixmap; } + + // QSGTexture interface +public: + qint64 comparisonKey() const override; + QSize textureSize() const override; + bool hasAlphaChannel() const override; + bool hasMipmaps() const override; + + // QSGDynamicTexture interface +public: + bool updateTexture() override; + + // QSGLayer interface +public: + void setItem(QSGNode *item) override; + void setRect(const QRectF &rect) override; + void setSize(const QSize &size) override; + void scheduleUpdate() override; + QImage toImage() const override; + void setLive(bool live) override; + void setRecursive(bool recursive) override; + void setFormat(Format) override; + void setHasMipmaps(bool) override; + void setDevicePixelRatio(qreal ratio) override; + void setMirrorHorizontal(bool mirror) override; + void setMirrorVertical(bool mirror) override; + void setSamples(int) override { } + +public Q_SLOTS: + void markDirtyTexture() override; + void invalidated() override; + +private: + void grab(); + + QSGNode *m_item; + QSGRenderContext *m_context; + QSGSoftwarePixmapRenderer *m_renderer; + QRectF m_rect; + QSize m_size; + QPixmap m_pixmap; + qreal m_device_pixel_ratio; + bool m_mirrorHorizontal; + bool m_mirrorVertical; + bool m_live; + bool m_grab; + bool m_recursive; + bool m_dirtyTexture; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWARELAYER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepainternode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepainternode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7318ace9cd8b71dcca9a8311d1dc216af9039d12 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepainternode_p.h @@ -0,0 +1,96 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWAREPAINTERNODE_H +#define QSGSOFTWAREPAINTERNODE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> +#include <QtQuick/qquickpainteditem.h> + +#include <QtGui/QPixmap> + +QT_BEGIN_NAMESPACE + +class QSGSoftwarePainterNode : public QSGPainterNode +{ +public: + QSGSoftwarePainterNode(QQuickPaintedItem *item); + ~QSGSoftwarePainterNode(); + + void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) override; + + void setSize(const QSize &size) override; + QSize size() const { return m_size; } + + void setDirty(const QRect &dirtyRect = QRect()) override; + + void setOpaquePainting(bool opaque) override; + bool opaquePainting() const { return m_opaquePainting; } + + void setLinearFiltering(bool linearFiltering) override; + bool linearFiltering() const { return m_linear_filtering; } + + void setMipmapping(bool mipmapping) override; + bool mipmapping() const { return m_mipmapping; } + + void setSmoothPainting(bool s) override; + bool smoothPainting() const { return m_smoothPainting; } + + void setFillColor(const QColor &c) override; + QColor fillColor() const { return m_fillColor; } + + void setContentsScale(qreal s) override; + qreal contentsScale() const { return m_contentsScale; } + + void setFastFBOResizing(bool dynamic) override; + bool fastFBOResizing() const { return m_fastFBOResizing; } + + QImage toImage() const override; + void update() override; + QSGTexture *texture() const override { return m_texture; } + + void paint(QPainter *painter); + + void paint(); + + void setTextureSize(const QSize &size) override; + QSize textureSize() const { return m_textureSize; } + +private: + + QQuickPaintedItem::RenderTarget m_preferredRenderTarget; + + QQuickPaintedItem *m_item; + + QPixmap m_pixmap; + QSGTexture *m_texture; + + QSize m_size; + bool m_dirtyContents; + QRect m_dirtyRect; + bool m_opaquePainting; + bool m_linear_filtering; + bool m_mipmapping; + bool m_smoothPainting; + bool m_fastFBOResizing; + QColor m_fillColor; + qreal m_contentsScale; + QSize m_textureSize; + + bool m_dirtyGeometry; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWAREPAINTERNODE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepixmaprenderer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepixmaprenderer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b698f43a222620d68bd50cfccadd2a0473b10af1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepixmaprenderer_p.h @@ -0,0 +1,40 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWAREPIXMAPRENDERER_H +#define QSGSOFTWAREPIXMAPRENDERER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsgabstractsoftwarerenderer_p.h" + +QT_BEGIN_NAMESPACE + +class QSGSoftwarePixmapRenderer : public QSGAbstractSoftwareRenderer +{ +public: + QSGSoftwarePixmapRenderer(QSGRenderContext *context); + virtual ~QSGSoftwarePixmapRenderer(); + + void renderScene() final; + void render() final; + + void render(QPaintDevice *target); + void setProjectionRect(const QRect &projectionRect); + +private: + QRect m_projectionRect; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWAREPIXMAPRENDERER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepixmaptexture_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepixmaptexture_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a37eb4225283e3d1ff94b7703291f451aba7ed3f --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepixmaptexture_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWAREPIXMAPTEXTURE_H +#define QSGSOFTWAREPIXMAPTEXTURE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgtexture_p.h> +#include <QtGui/QPixmap> + +QT_BEGIN_NAMESPACE + +class QSGSoftwarePixmapTexture : public QSGTexture +{ + Q_OBJECT + +public: + QSGSoftwarePixmapTexture(const QImage &image, uint flags); + QSGSoftwarePixmapTexture(const QPixmap &pixmap); + + qint64 comparisonKey() const override; + QSize textureSize() const override; + bool hasAlphaChannel() const override; + bool hasMipmaps() const override; + + const QPixmap &pixmap() const { return m_pixmap; } + +private: + QPixmap m_pixmap; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWAREPIXMAPTEXTURE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepublicnodes_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepublicnodes_p.h new file mode 100644 index 0000000000000000000000000000000000000000..42cc63ee65978e687d8f3b0dc0d06c606f215c61 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarepublicnodes_p.h @@ -0,0 +1,115 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWAREPUBLICNODES_H +#define QSGSOFTWAREPUBLICNODES_H + +#include <QtQuick/qsgrectanglenode.h> +#include <QtQuick/qsgimagenode.h> +#include <QtQuick/qsgninepatchnode.h> +#include <QtGui/qpixmap.h> +#include <QtCore/private/qglobal_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QSGSoftwareRectangleNode : public QSGRectangleNode +{ +public: + QSGSoftwareRectangleNode(); + + void setRect(const QRectF &rect) override { m_rect = rect; markDirty(DirtyMaterial); } + QRectF rect() const override { return m_rect; } + + void setColor(const QColor &color) override { m_color = color; markDirty(DirtyMaterial); } + QColor color() const override { return m_color; } + + void paint(QPainter *painter); + +private: + QRectF m_rect; + QColor m_color; +}; + +class QSGSoftwareImageNode : public QSGImageNode +{ +public: + QSGSoftwareImageNode(); + ~QSGSoftwareImageNode(); + + void setRect(const QRectF &rect) override { m_rect = rect; markDirty(DirtyMaterial); } + QRectF rect() const override { return m_rect; } + + void setSourceRect(const QRectF &r) override { m_sourceRect = r; } + QRectF sourceRect() const override { return m_sourceRect; } + + void setTexture(QSGTexture *texture) override; + QSGTexture *texture() const override { return m_texture; } + + void setFiltering(QSGTexture::Filtering filtering) override { m_filtering = filtering; markDirty(DirtyMaterial); } + QSGTexture::Filtering filtering() const override { return m_filtering; } + + void setMipmapFiltering(QSGTexture::Filtering) override { } + QSGTexture::Filtering mipmapFiltering() const override { return QSGTexture::None; } + + void setAnisotropyLevel(QSGTexture::AnisotropyLevel) override { } + QSGTexture::AnisotropyLevel anisotropyLevel() const override { return QSGTexture::AnisotropyNone; } + + void setTextureCoordinatesTransform(TextureCoordinatesTransformMode transformNode) override; + TextureCoordinatesTransformMode textureCoordinatesTransform() const override { return m_transformMode; } + + void setOwnsTexture(bool owns) override { m_owns = owns; } + bool ownsTexture() const override { return m_owns; } + + void paint(QPainter *painter); + +private: + void updateCachedMirroredPixmap(); + + QPixmap m_cachedPixmap; + QSGTexture *m_texture; + QRectF m_rect; + QRectF m_sourceRect; + bool m_owns; + QSGTexture::Filtering m_filtering; + TextureCoordinatesTransformMode m_transformMode; + bool m_cachedMirroredPixmapIsDirty; +}; + +class QSGSoftwareNinePatchNode : public QSGNinePatchNode +{ +public: + QSGSoftwareNinePatchNode(); + + void setTexture(QSGTexture *texture) override; + void setBounds(const QRectF &bounds) override; + void setDevicePixelRatio(qreal ratio) override; + void setPadding(qreal left, qreal top, qreal right, qreal bottom) override; + void update() override; + + void paint(QPainter *painter); + + QRectF bounds() const; + + bool isOpaque() const { return !m_pixmap.hasAlphaChannel(); } + +private: + QPixmap m_pixmap; + QRectF m_bounds; + qreal m_pixelRatio = 1.0; + QMargins m_margins; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWAREPUBLICNODES_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderablenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderablenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..070fbf30fa4cfcc7aa974edc15a5933f5ba053c5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderablenode_p.h @@ -0,0 +1,125 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWARERENDERABLENODE_H +#define QSGSOFTWARERENDERABLENODE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qtquickglobal_p.h> + +#include <QtGui/QRegion> +#include <QtCore/QRect> +#include <QtGui/QTransform> +#include <QtQuick/qsgrectanglenode.h> +#include <QtQuick/qsgimagenode.h> +#include <QtQuick/qsgninepatchnode.h> + +QT_BEGIN_NAMESPACE + +class QSGSimpleRectNode; +class QSGSimpleTextureNode; +class QSGSoftwareInternalImageNode; +class QSGSoftwarePainterNode; +class QSGSoftwareInternalRectangleNode; +class QSGSoftwareGlyphNode; +class QSGSoftwareNinePatchNode; +class QSGSoftwareSpriteNode; +class QSGRenderNode; + +class Q_QUICK_EXPORT QSGSoftwareRenderableNode +{ +public: + enum NodeType { + Invalid = -1, + SimpleRect, + SimpleTexture, + Image, + Painter, + Rectangle, + Glyph, + NinePatch, + SimpleRectangle, + SimpleImage, +#if QT_CONFIG(quick_sprite) + SpriteNode, +#endif + RenderNode + }; + + QSGSoftwareRenderableNode(NodeType type, QSGNode *node); + ~QSGSoftwareRenderableNode(); + + void update(); + + QRegion renderNode(QPainter *painter, bool forceOpaquePainting = false); + QRect boundingRectMin() const { return m_boundingRectMin; } + QRect boundingRectMax() const { return m_boundingRectMax; } + NodeType type() const { return m_nodeType; } + bool isOpaque() const { return m_isOpaque; } + bool isDirty() const { return m_isDirty; } + bool isDirtyRegionEmpty() const; + QSGNode *handle() const { return m_handle.node; } + + void setTransform(const QTransform &transform); + void setClipRegion(const QRegion &clipRegion, bool hasClipRegion = true); + void setOpacity(float opacity); + QTransform transform() const { return m_transform; } + QRegion clipRegion() const { return m_clipRegion; } + float opacity() const { return m_opacity; } + + void markGeometryDirty(); + void markMaterialDirty(); + + void addDirtyRegion(const QRegion &dirtyRegion, bool forceDirty = true); + void subtractDirtyRegion(const QRegion &dirtyRegion); + + QRegion previousDirtyRegion(bool wasRemoved = false) const; + QRegion dirtyRegion() const; + +private: + union RenderableNodeHandle { + QSGNode *node; + QSGSimpleRectNode *simpleRectNode; + QSGSimpleTextureNode *simpleTextureNode; + QSGSoftwareInternalImageNode *imageNode; + QSGSoftwarePainterNode *painterNode; + QSGSoftwareInternalRectangleNode *rectangleNode; + QSGSoftwareGlyphNode *glpyhNode; + QSGSoftwareNinePatchNode *ninePatchNode; + QSGRectangleNode *simpleRectangleNode; + QSGImageNode *simpleImageNode; + QSGSoftwareSpriteNode *spriteNode; + QSGRenderNode *renderNode; + }; + + const NodeType m_nodeType; + RenderableNodeHandle m_handle; + + bool m_isOpaque; + + bool m_isDirty; + QRegion m_dirtyRegion; + QRegion m_previousDirtyRegion; + + QTransform m_transform; + QRegion m_clipRegion; + bool m_hasClipRegion; + float m_opacity; + + QRect m_boundingRectMin; + QRect m_boundingRectMax; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWARERENDERABLENODE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderablenodeupdater_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderablenodeupdater_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5f27e21571c97a8567c78b9d5e35aed9db570cf9 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderablenodeupdater_p.h @@ -0,0 +1,107 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWARERENDERABLENODEUPDATER_H +#define QSGSOFTWARERENDERABLENODEUPDATER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsgsoftwarerenderablenode_p.h" +#include "qsgabstractsoftwarerenderer_p.h" + +#include <private/qsgadaptationlayer_p.h> + +#include <QTransform> +#include <QStack> +#include <QRectF> + +QT_BEGIN_NAMESPACE + +class QSGSoftwareRenderableNodeUpdater : public QSGNodeVisitorEx +{ +public: + QSGSoftwareRenderableNodeUpdater(QSGAbstractSoftwareRenderer *renderer); + virtual ~QSGSoftwareRenderableNodeUpdater(); + + bool visit(QSGTransformNode *) override; + void endVisit(QSGTransformNode *) override; + bool visit(QSGClipNode *) override; + void endVisit(QSGClipNode *) override; + bool visit(QSGGeometryNode *) override; + void endVisit(QSGGeometryNode *) override; + bool visit(QSGOpacityNode *) override; + void endVisit(QSGOpacityNode *) override; + bool visit(QSGInternalImageNode *) override; + void endVisit(QSGInternalImageNode *) override; + bool visit(QSGPainterNode *) override; + void endVisit(QSGPainterNode *) override; + bool visit(QSGInternalRectangleNode *) override; + void endVisit(QSGInternalRectangleNode *) override; + bool visit(QSGGlyphNode *) override; + void endVisit(QSGGlyphNode *) override; + bool visit(QSGRootNode *) override; + void endVisit(QSGRootNode *) override; +#if QT_CONFIG(quick_sprite) + bool visit(QSGSpriteNode *) override; + void endVisit(QSGSpriteNode *) override; +#endif + bool visit(QSGRenderNode *) override; + void endVisit(QSGRenderNode *) override; + + void updateNodes(QSGNode *node, bool isNodeRemoved = false); + +private: + struct NodeState { + float opacity; + QRegion clip; + bool hasClip; + QTransform transform; + QSGNode *parent; + }; + + NodeState currentState(QSGNode *node) const; + + template<class NODE> + bool updateRenderableNode(QSGSoftwareRenderableNode::NodeType type, NODE *node); + + QSGAbstractSoftwareRenderer *m_renderer; + QStack<float> m_opacityState; + QStack<QRegion> m_clipState; + bool m_hasClip; + QStack<QTransform> m_transformState; + QHash<QSGNode*,NodeState> m_stateMap; +}; + +template<class NODE> +bool QSGSoftwareRenderableNodeUpdater::updateRenderableNode(QSGSoftwareRenderableNode::NodeType type, NODE *node) +{ + //Check if we already know about node + auto renderableNode = m_renderer->renderableNode(node); + if (renderableNode == nullptr) { + renderableNode = new QSGSoftwareRenderableNode(type, node); + m_renderer->addNodeMapping(node, renderableNode); + } + + //Update the node + renderableNode->setTransform(m_transformState.top()); + renderableNode->setOpacity(m_opacityState.top()); + renderableNode->setClipRegion(m_clipState.top(), m_hasClip); + + renderableNode->update(); + m_stateMap[node] = currentState(node); + + return true; +} + +QT_END_NAMESPACE + +#endif // QSGSOFTWARERENDERABLENODEUPDATER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderer_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderer_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a1bce0e80252e7a4743ebe0262b0e2d62b1c3018 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderer_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWARERENDERER_H +#define QSGSOFTWARERENDERER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsgabstractsoftwarerenderer_p.h" + +QT_BEGIN_NAMESPACE + +class QPaintDevice; +class QBackingStore; + +class Q_QUICK_EXPORT QSGSoftwareRenderer : public QSGAbstractSoftwareRenderer +{ +public: + QSGSoftwareRenderer(QSGRenderContext *context); + virtual ~QSGSoftwareRenderer(); + + void setCurrentPaintDevice(QPaintDevice *device); + QPaintDevice *currentPaintDevice() const; + void setBackingStore(QBackingStore *backingStore); + QRegion flushRegion() const; + +protected: + void renderScene() final; + void render() final; + +private: + QPaintDevice* m_paintDevice; + QBackingStore* m_backingStore; + QRegion m_flushRegion; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWARERENDERER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderlistbuilder_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderlistbuilder_p.h new file mode 100644 index 0000000000000000000000000000000000000000..619181530826398535b9cd92897d9fcde55f7096 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderlistbuilder_p.h @@ -0,0 +1,62 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWARERENDERLISTBUILDER_H +#define QSGSOFTWARERENDERLISTBUILDER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgadaptationlayer_p.h> + +QT_BEGIN_NAMESPACE + +class QSGAbstractSoftwareRenderer; + +class QSGSoftwareRenderListBuilder : public QSGNodeVisitorEx +{ +public: + QSGSoftwareRenderListBuilder(QSGAbstractSoftwareRenderer *renderer); + + bool visit(QSGTransformNode *) override; + void endVisit(QSGTransformNode *) override; + bool visit(QSGClipNode *) override; + void endVisit(QSGClipNode *) override; + bool visit(QSGGeometryNode *) override; + void endVisit(QSGGeometryNode *) override; + bool visit(QSGOpacityNode *) override; + void endVisit(QSGOpacityNode *) override; + bool visit(QSGInternalImageNode *) override; + void endVisit(QSGInternalImageNode *) override; + bool visit(QSGPainterNode *) override; + void endVisit(QSGPainterNode *) override; + bool visit(QSGInternalRectangleNode *) override; + void endVisit(QSGInternalRectangleNode *) override; + bool visit(QSGGlyphNode *) override; + void endVisit(QSGGlyphNode *) override; + bool visit(QSGRootNode *) override; + void endVisit(QSGRootNode *) override; +#if QT_CONFIG(quick_sprite) + bool visit(QSGSpriteNode *) override; + void endVisit(QSGSpriteNode *) override; +#endif + bool visit(QSGRenderNode *) override; + void endVisit(QSGRenderNode *) override; + +private: + bool addRenderableNode(QSGNode *node); + + QSGAbstractSoftwareRenderer *m_renderer; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWARERENDERLISTBUILDER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderloop_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderloop_p.h new file mode 100644 index 0000000000000000000000000000000000000000..f50eb216c4138ce29e3f0ddc722e933012ff3364 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarerenderloop_p.h @@ -0,0 +1,69 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWARERENDERLOOP_H +#define QSGSOFTWARERENDERLOOP_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgrenderloop_p.h> + +QT_BEGIN_NAMESPACE + +class QBackingStore; + +class QSGSoftwareRenderLoop : public QSGRenderLoop +{ + Q_OBJECT +public: + QSGSoftwareRenderLoop(); + ~QSGSoftwareRenderLoop(); + + void show(QQuickWindow *window) override; + void hide(QQuickWindow *window) override; + + void windowDestroyed(QQuickWindow *window) override; + + void renderWindow(QQuickWindow *window, bool isNewExpose = false); + void exposureChanged(QQuickWindow *window) override; + QImage grab(QQuickWindow *window) override; + + void maybeUpdate(QQuickWindow *window) override; + void update(QQuickWindow *window) override { maybeUpdate(window); } // identical for this implementation. + void handleUpdateRequest(QQuickWindow *) override; + + void releaseResources(QQuickWindow *) override { } + + QSurface::SurfaceType windowSurfaceType() const override; + + QAnimationDriver *animationDriver() const override { return 0; } + + QSGContext *sceneGraphContext() const override; + QSGRenderContext *createRenderContext(QSGContext *) const override { return rc; } + + struct WindowData { + bool updatePending : 1; + bool grabOnly : 1; + }; + + QHash<QQuickWindow *, WindowData> m_windows; + QHash<QQuickWindow *, QBackingStore *> m_backingStores; + + QSGContext *sg; + QSGRenderContext *rc; + + QImage grabContent; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWARERENDERLOOP_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarespritenode_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarespritenode_p.h new file mode 100644 index 0000000000000000000000000000000000000000..a5767981d4943dae74cb162f7d1d2777f2d19177 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarespritenode_p.h @@ -0,0 +1,61 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWARESPRITENODE_H +#define QSGSOFTWARESPRITENODE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> + +QT_REQUIRE_CONFIG(quick_sprite); + +#include <private/qsgadaptationlayer_p.h> + +QT_BEGIN_NAMESPACE + +class QSGSoftwarePixmapTexture; +class QSGSoftwareSpriteNode : public QSGSpriteNode +{ +public: + QSGSoftwareSpriteNode(); + ~QSGSoftwareSpriteNode() override; + + void setTexture(QSGTexture *texture) override; + void setTime(float time) override; + void setSourceA(const QPoint &source) override; + void setSourceB(const QPoint &source) override; + void setSpriteSize(const QSize &size) override; + void setSheetSize(const QSize &size) override; + void setSize(const QSizeF &size) override; + void setFiltering(QSGTexture::Filtering filtering) override; + void update() override; + + void paint(QPainter *painter); + bool isOpaque() const; + QRectF rect() const; + +private: + + QSGSoftwarePixmapTexture *m_texture = nullptr; + float m_time; + QPoint m_sourceA; + QPoint m_sourceB; + QSize m_spriteSize; + QSize m_sheetSize; + QSizeF m_size; + +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWARESPRITENODE_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarethreadedrenderloop_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarethreadedrenderloop_p.h new file mode 100644 index 0000000000000000000000000000000000000000..0544b720da1e5130a28c43cbc66c244785d74c0a --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgsoftwarethreadedrenderloop_p.h @@ -0,0 +1,84 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGSOFTWARETHREADEDRENDERLOOP_H +#define QSGSOFTWARETHREADEDRENDERLOOP_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qsgrenderloop_p.h> + +QT_BEGIN_NAMESPACE + +class QSGSoftwareRenderThread; +class QSGSoftwareContext; + +class QSGSoftwareThreadedRenderLoop : public QSGRenderLoop +{ + Q_OBJECT +public: + QSGSoftwareThreadedRenderLoop(); + ~QSGSoftwareThreadedRenderLoop(); + + void show(QQuickWindow *window) override; + void hide(QQuickWindow *window) override; + void resize(QQuickWindow *window) override; + void windowDestroyed(QQuickWindow *window) override; + void exposureChanged(QQuickWindow *window) override; + QImage grab(QQuickWindow *window) override; + void update(QQuickWindow *window) override; + void maybeUpdate(QQuickWindow *window) override; + void handleUpdateRequest(QQuickWindow *window) override; + QAnimationDriver *animationDriver() const override; + QSGContext *sceneGraphContext() const override; + QSGRenderContext *createRenderContext(QSGContext *) const override; + void releaseResources(QQuickWindow *window) override; + void postJob(QQuickWindow *window, QRunnable *job) override; + QSurface::SurfaceType windowSurfaceType() const override; + bool interleaveIncubation() const override; + int flags() const override; + + bool event(QEvent *e) override; + +public Q_SLOTS: + void onAnimationStarted(); + void onAnimationStopped(); + +private: + struct WindowData { + QQuickWindow *window; + QSGSoftwareRenderThread *thread; + uint updateDuringSync : 1; + uint forceRenderPass : 1; + }; + + WindowData *windowFor(QQuickWindow *window); + + void startOrStopAnimationTimer(); + void handleExposure(QQuickWindow *window); + void handleObscurity(WindowData *w); + void scheduleUpdate(WindowData *w); + void handleResourceRelease(WindowData *w, bool destroying); + void polishAndSync(WindowData *w, bool inExpose); + + QSGSoftwareContext *m_sg; + QAnimationDriver *m_anim; + int animationTimer = 0; + bool lockedForSync = false; + QList<WindowData> m_windows; + + friend class QSGSoftwareRenderThread; +}; + +QT_END_NAMESPACE + +#endif // QSGSOFTWARETHREADEDRENDERLOOP_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtexture_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtexture_p.h new file mode 100644 index 0000000000000000000000000000000000000000..7b77a253442c4b01ff2cac948fc3b05716424f71 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtexture_p.h @@ -0,0 +1,136 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGTEXTURE_P_H +#define QSGTEXTURE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQuick/private/qtquickglobal_p.h> +#include <private/qobject_p.h> +#include "qsgtexture.h" + +QT_BEGIN_NAMESPACE + +struct QSGSamplerDescription +{ + QSGTexture::Filtering filtering = QSGTexture::Nearest; + QSGTexture::Filtering mipmapFiltering = QSGTexture::None; + QSGTexture::WrapMode horizontalWrap = QSGTexture::ClampToEdge; + QSGTexture::WrapMode verticalWrap = QSGTexture::ClampToEdge; + QSGTexture::AnisotropyLevel anisotropylevel = QSGTexture::AnisotropyNone; + + static QSGSamplerDescription fromTexture(QSGTexture *t); +}; + +Q_DECLARE_TYPEINFO(QSGSamplerDescription, Q_RELOCATABLE_TYPE); + +bool operator==(const QSGSamplerDescription &a, const QSGSamplerDescription &b) noexcept; +bool operator!=(const QSGSamplerDescription &a, const QSGSamplerDescription &b) noexcept; +size_t qHash(const QSGSamplerDescription &s, size_t seed = 0) noexcept; + +#if QT_CONFIG(opengl) +class Q_QUICK_EXPORT QSGTexturePlatformOpenGL : public QNativeInterface::QSGOpenGLTexture +{ +public: + QSGTexturePlatformOpenGL(QSGTexture *t) : m_texture(t) { } + QSGTexture *m_texture; + + GLuint nativeTexture() const override; +}; +#endif + +#ifdef Q_OS_WIN +class Q_QUICK_EXPORT QSGTexturePlatformD3D11 : public QNativeInterface::QSGD3D11Texture +{ +public: + QSGTexturePlatformD3D11(QSGTexture *t) : m_texture(t) { } + QSGTexture *m_texture; + + void *nativeTexture() const override; +}; +class Q_QUICK_EXPORT QSGTexturePlatformD3D12 : public QNativeInterface::QSGD3D12Texture +{ +public: + QSGTexturePlatformD3D12(QSGTexture *t) : m_texture(t) { } + QSGTexture *m_texture; + + int nativeResourceState() const override; + void *nativeTexture() const override; +}; +#endif + +#if QT_CONFIG(metal) +class Q_QUICK_EXPORT QSGTexturePlatformMetal : public QNativeInterface::QSGMetalTexture +{ +public: + QSGTexturePlatformMetal(QSGTexture *t) : m_texture(t) { } + QSGTexture *m_texture; + + QT_OBJC_PROTOCOL(MTLTexture) nativeTexture() const override; +}; +#endif + +#if QT_CONFIG(vulkan) +class Q_QUICK_EXPORT QSGTexturePlatformVulkan : public QNativeInterface::QSGVulkanTexture +{ +public: + QSGTexturePlatformVulkan(QSGTexture *t) : m_texture(t) { } + QSGTexture *m_texture; + + VkImage nativeImage() const override; + VkImageLayout nativeImageLayout() const override; +}; +#endif + +class Q_QUICK_EXPORT QSGTexturePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QSGTexture) +public: + QSGTexturePrivate(QSGTexture *t); + static QSGTexturePrivate *get(QSGTexture *t) { return t->d_func(); } + void resetDirtySamplerOptions(); + bool hasDirtySamplerOptions() const; + + uint wrapChanged : 1; + uint filteringChanged : 1; + uint anisotropyChanged : 1; + + uint horizontalWrap : 2; + uint verticalWrap : 2; + uint mipmapMode : 2; + uint filterMode : 2; + uint anisotropyLevel: 3; + + // While we could make QSGTexturePrivate implement all the interfaces, we + // rather choose to use separate objects to avoid clashes in the function + // names and signatures. +#if QT_CONFIG(opengl) + QSGTexturePlatformOpenGL m_openglTextureAccessor; +#endif +#ifdef Q_OS_WIN + QSGTexturePlatformD3D11 m_d3d11TextureAccessor; + QSGTexturePlatformD3D12 m_d3d12TextureAccessor; +#endif +#if QT_CONFIG(metal) + QSGTexturePlatformMetal m_metalTextureAccessor; +#endif +#if QT_CONFIG(vulkan) + QSGTexturePlatformVulkan m_vulkanTextureAccessor; +#endif +}; + +Q_QUICK_EXPORT bool qsg_safeguard_texture(QSGTexture *); + +QT_END_NAMESPACE + +#endif // QSGTEXTURE_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtexturematerial_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtexturematerial_p.h new file mode 100644 index 0000000000000000000000000000000000000000..b1341c283a958046be08a26f9bb34a5e3516c0a5 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtexturematerial_p.h @@ -0,0 +1,42 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef TEXTUREMATERIAL_P_H +#define TEXTUREMATERIAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsgtexturematerial.h" +#include <private/qtquickglobal_p.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGOpaqueTextureMaterialRhiShader : public QSGMaterialShader +{ +public: + QSGOpaqueTextureMaterialRhiShader(int viewCount); + + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; +}; + +class QSGTextureMaterialRhiShader : public QSGOpaqueTextureMaterialRhiShader +{ +public: + QSGTextureMaterialRhiShader(int viewCount); + + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; +}; + +QT_END_NAMESPACE + +#endif // QSGTEXTUREMATERIAL_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtexturereader_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtexturereader_p.h new file mode 100644 index 0000000000000000000000000000000000000000..02770898fc6797f05fe32b1f85c431b448b785a1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtexturereader_p.h @@ -0,0 +1,48 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGTEXTUREREADER_H +#define QSGTEXTUREREADER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QString> +#include <QFileInfo> +#include <private/qglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QIODevice; +class QQuickTextureFactory; +class QTextureFileReader; + +class QSGTextureReader +{ +public: + QSGTextureReader(QIODevice *device, const QString &fileName = QString()); + ~QSGTextureReader(); + + QQuickTextureFactory *read(); + bool isTexture(); + + // TBD access function to params + // TBD ask for identified fmt + + static QList<QByteArray> supportedFileFormats(); + +private: + QTextureFileReader *m_reader = nullptr; +}; + +QT_END_NAMESPACE + +#endif // QSGTEXTUREREADER_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgthreadedrenderloop_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgthreadedrenderloop_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e0890c45bb3bd4eb8e1014303f25f182d7b802a1 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgthreadedrenderloop_p.h @@ -0,0 +1,114 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGTHREADEDRENDERLOOP_P_H +#define QSGTHREADEDRENDERLOOP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/QThread> +#include <QtCore/QElapsedTimer> +#include <private/qsgcontext_p.h> + +#include "qsgrenderloop_p.h" + +QT_BEGIN_NAMESPACE + +class QSGRenderThread; + +class QSGThreadedRenderLoop : public QSGRenderLoop +{ + Q_OBJECT +public: + QSGThreadedRenderLoop(); + ~QSGThreadedRenderLoop(); + + void show(QQuickWindow *) override {} + void hide(QQuickWindow *) override; + void resize(QQuickWindow *window) override; + + void windowDestroyed(QQuickWindow *window) override; + void exposureChanged(QQuickWindow *window) override; + + QImage grab(QQuickWindow *) override; + + void update(QQuickWindow *window) override; + void maybeUpdate(QQuickWindow *window) override; + void handleUpdateRequest(QQuickWindow *window) override; + + QSGContext *sceneGraphContext() const override; + QSGRenderContext *createRenderContext(QSGContext *) const override; + + QAnimationDriver *animationDriver() const override; + + void releaseResources(QQuickWindow *window) override; + + bool event(QEvent *) override; + void postJob(QQuickWindow *window, QRunnable *job) override; + + bool interleaveIncubation() const override; + +public Q_SLOTS: + void animationStarted(); + void animationStopped(); + +private: + struct Window { + QQuickWindow *window; + QSGRenderThread *thread; + QSurfaceFormat actualWindowFormat; + QElapsedTimer timeBetweenPolishAndSyncs; + float psTimeAccumulator; + int psTimeSampleCount; + uint updateDuringSync : 1; + uint forceRenderPass : 1; + uint badVSync : 1; + }; + + friend class QSGRenderThread; + + + Window *windowFor(QQuickWindow *window); + void releaseResources(Window *window, bool inDestructor); + bool checkAndResetForceUpdate(QQuickWindow *window); + + bool anyoneShowing() const; + void initialize(); + + void startOrStopAnimationTimer(); + void postUpdateRequest(Window *w); + void waitForReleaseComplete(); + void polishAndSync(Window *w, bool inExpose = false); + void maybeUpdate(Window *window); + + void handleExposure(QQuickWindow *w); + void handleObscurity(Window *w); + void releaseSwapchain(QQuickWindow *window); + + bool eventFilter(QObject *watched, QEvent *event) override; + + QSGContext *sg; + // Set of contexts that have been created but are now owned by + // a rendering thread yet, as the window has never been exposed. + mutable QSet<QSGRenderContext*> pendingRenderContexts; + QAnimationDriver *m_animation_driver; + QList<Window> m_windows; + + int m_animation_timer; + + bool m_lockedForSync; + bool m_inPolish = false; +}; + +QT_END_NAMESPACE + +#endif // QSGTHREADEDRENDERLOOP_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtransform_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtransform_p.h new file mode 100644 index 0000000000000000000000000000000000000000..da217629000d89b1d7b8e5e926865bef9b888405 --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qsgtransform_p.h @@ -0,0 +1,105 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QSGTRANSFORM_P_H +#define QSGTRANSFORM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <QSharedPointer> +#include <QMatrix4x4> +#include <QtQuick/qtquickexports.h> + +QT_BEGIN_NAMESPACE + +class Q_QUICK_EXPORT QSGTransform +{ +public: + void setMatrix(const QMatrix4x4 &matrix) + { + if (matrix.isIdentity()) + m_matrixPtr.clear(); + else + m_matrixPtr = QSharedPointer<QMatrix4x4>::create(matrix); + m_invertedPtr.clear(); + } + + QMatrix4x4 matrix() const + { + return m_matrixPtr ? *m_matrixPtr : m_identity; + } + + bool isIdentity() const + { + return !m_matrixPtr; + } + + bool operator==(const QMatrix4x4 &other) const + { + return m_matrixPtr ? (other == *m_matrixPtr) : other.isIdentity(); + } + + bool operator!=(const QMatrix4x4 &other) const + { + return !(*this == other); + } + + bool operator==(const QSGTransform &other) const + { + return (m_matrixPtr == other.m_matrixPtr) + || (m_matrixPtr && other.m_matrixPtr && *m_matrixPtr == *other.m_matrixPtr); + } + + bool operator!=(const QSGTransform &other) const + { + return !(*this == other); + } + + int compareTo(const QSGTransform &other) const + { + int diff = 0; + if (m_matrixPtr != other.m_matrixPtr) { + if (m_matrixPtr.isNull()) { + diff = -1; + } else if (other.m_matrixPtr.isNull()) { + diff = 1; + } else { + const float *ptr1 = m_matrixPtr->constData(); + const float *ptr2 = other.m_matrixPtr->constData(); + for (int i = 0; i < 16 && !diff; i++) { + float d = ptr1[i] - ptr2[i]; + if (d != 0) + diff = (d > 0) ? 1 : -1; + } + } + } + return diff; + } + + const float *invertedData() const + { + if (!m_matrixPtr) + return m_identity.constData(); + if (!m_invertedPtr) + m_invertedPtr = QSharedPointer<QMatrix4x4>::create(m_matrixPtr->inverted()); + return m_invertedPtr->constData(); + } + +private: + static QMatrix4x4 m_identity; + QSharedPointer<QMatrix4x4> m_matrixPtr; + mutable QSharedPointer<QMatrix4x4> m_invertedPtr; +}; + +QT_END_NAMESPACE + +#endif // QSGTRANSFORM_P_H diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qtquick-config_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qtquick-config_p.h new file mode 100644 index 0000000000000000000000000000000000000000..e2c39a444687b2e8c7bccc8b2b484e8522ac9b3c --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qtquick-config_p.h @@ -0,0 +1,32 @@ +#define QT_FEATURE_quick_animatedimage 1 + +#define QT_FEATURE_quick_canvas 1 + +#define QT_FEATURE_quick_designer 1 + +#define QT_FEATURE_quick_flipable 1 + +#define QT_FEATURE_quick_gridview 1 + +#define QT_FEATURE_quick_itemview 1 + +#define QT_FEATURE_quick_viewtransitions 1 + +#define QT_FEATURE_quick_listview 1 + +#define QT_FEATURE_quick_tableview 1 + +#define QT_FEATURE_quick_treeview 1 + +#define QT_FEATURE_quick_particles 1 + +#define QT_FEATURE_quick_path 1 + +#define QT_FEATURE_quick_pathview 1 + +#define QT_FEATURE_quick_positioners 1 + +#define QT_FEATURE_quick_repeater 1 + +#define QT_FEATURE_quick_sprite 1 + diff --git a/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qtquickglobal_p.h b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qtquickglobal_p.h new file mode 100644 index 0000000000000000000000000000000000000000..653ce280e013cda88fa32b4746984085d18f1d7e --- /dev/null +++ b/qt/6.8.1/msvc2022_64/include/QtQuick/6.8.1/QtQuick/private/qtquickglobal_p.h @@ -0,0 +1,70 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTQUICKGLOBAL_P_H +#define QTQUICKGLOBAL_P_H + +#include <QtQml/private/qtqmlglobal_p.h> +#include <QtGui/private/qtguiglobal_p.h> +#include <QtQuick/private/qtquick-config_p.h> + +#include <QtCore/qloggingcategory.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qtquickglobal.h" +#include <QtQuick/qtquickexports.h> + +QT_BEGIN_NAMESPACE + +void Q_QUICK_EXPORT qml_register_types_QtQuick(); + +void Q_QUICK_EXPORT QQuick_initializeModule(); + +Q_DECLARE_LOGGING_CATEGORY(lcTouch) +Q_DECLARE_LOGGING_CATEGORY(lcMouse) +Q_DECLARE_LOGGING_CATEGORY(lcFocus) +Q_DECLARE_LOGGING_CATEGORY(lcDirty) + +/* + This is needed for QuickTestUtils. Q_AUTOTEST_EXPORT checks QT_BUILDING_QT + (amongst others) to see if it should export symbols. Until QuickTestUtils + was introduced, this was enough, as there weren't any intermediate test + helper libraries that used a Qt library and were in turn used by tests. + + Taking QQuickItemViewPrivate as an example: previously it was using + Q_AUTOTEST_EXPORT. Since QuickTestUtils is a Qt library (albeit a private + one), QT_BUILDING_QT was true and so Q_AUTOTEST_EXPORT evaluated to an + export. However, QQuickItemViewPrivate was already exported by the Quick + library, so we would get errors like this: + + Qt6Quickd.lib(Qt6Quickd.dll) : error LNK2005: "public: static class + QQuickItemViewPrivate * __cdecl QQuickItemViewPrivate::get(class QQuickItemView *)" + (?get@QQuickItemViewPrivate@@SAPEAV1@PEAVQQuickItemView@@@Z) already defined + in Qt6QuickTestUtilsd.lib(viewtestutils.cpp.obj) + + So, to account for the special case of QuickTestUtils, we need to be more + specific about which part of Qt we're building; instead of checking if we're + building any Qt library at all, check if we're building the Quick library, + and only then export. +*/ +#if defined(QT_BUILD_INTERNAL) && defined(QT_BUILD_QUICK_LIB) && defined(QT_SHARED) +# define Q_QUICK_AUTOTEST_EXPORT Q_DECL_EXPORT +#elif defined(QT_BUILD_INTERNAL) && defined(QT_SHARED) +# define Q_QUICK_AUTOTEST_EXPORT Q_DECL_IMPORT +#else +# define Q_QUICK_AUTOTEST_EXPORT +#endif + +QT_END_NAMESPACE + +#endif // QTQUICKGLOBAL_P_H