Skip to content

Commit 87bcddb

Browse files
kambala-decapitatorwutschel
authored andcommitted
Add libfmt to the project, add xcconfig with library settings, configure C++ settings
1 parent 08404e3 commit 87bcddb

File tree

24 files changed

+14942
-3
lines changed

24 files changed

+14942
-3
lines changed

Config.xcconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
LIBRARY_SEARCH_PATHS[sdk=iphoneos*][arch=arm64] = $(SRCROOT)/libs/fmt/ios-arm64
2+
LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*][arch=arm64] = $(SRCROOT)/libs/fmt/sim-arm64
3+
LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*][arch=x86_64] = $(SRCROOT)/libs/fmt/sim-x86_64
4+
5+
GCC_PREPROCESSOR_DEFINITIONS = FMT_LOCALE FMT_SHARED $(inherited)
6+
HEADER_SEARCH_PATHS = libs/fmt/include
7+
LD_RUNPATH_SEARCH_PATHS[sdk=iphoneos*] = @loader_path/Frameworks
8+
LD_RUNPATH_SEARCH_PATHS[sdk=iphonesimulator*] = $(LIBRARY_SEARCH_PATHS)
9+
OTHER_LDFLAGS = -lfmt $(inherited)

Kodi Remote.xcodeproj/project.pbxproj

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@
263263
1A9786C31683D8E900B4F3F8 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
264264
8ED18E7A16B572D700CA03F4 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
265265
8ED18E7B16B572D700CA03F4 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
266+
ACCBC14627BBB259000A16E1 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
266267
B1FF37DE1709D1EB005473FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
267268
B1FF37DF1709D1ED005473FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
268269
C703692827148CEF0049F9BF /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
@@ -516,6 +517,7 @@
516517
isa = PBXGroup;
517518
children = (
518519
C70F41D02BA4D98E00847C75 /* PrivacyInfo.xcprivacy */,
520+
ACCBC14627BBB259000A16E1 /* Config.xcconfig */,
519521
0F59E2661564796B00184AE8 /* CONTRIBUTING.md */,
520522
0F59E26315646FB800184AE8 /* LICENSE */,
521523
0F8717911564566300AE2D48 /* README.md */,
@@ -1015,6 +1017,8 @@
10151017
ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOL_FRAMEWORKS = UIKit;
10161018
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
10171019
CLANG_ENABLE_MODULES = YES;
1020+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
1021+
CLANG_CXX_LIBRARY = "libc++";
10181022
CLANG_ENABLE_OBJC_ARC = YES;
10191023
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
10201024
CLANG_WARN_BOOL_CONVERSION = YES;
@@ -1048,7 +1052,6 @@
10481052
"$(inherited)",
10491053
);
10501054
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1051-
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
10521055
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
10531056
GCC_WARN_ABOUT_RETURN_TYPE = YES;
10541057
GCC_WARN_UNDECLARED_SELECTOR = YES;
@@ -1073,6 +1076,8 @@
10731076
ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOL_FRAMEWORKS = UIKit;
10741077
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
10751078
CLANG_ENABLE_MODULES = YES;
1079+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
1080+
CLANG_CXX_LIBRARY = "libc++";
10761081
CLANG_ENABLE_OBJC_ARC = YES;
10771082
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
10781083
CLANG_WARN_BOOL_CONVERSION = YES;
@@ -1100,7 +1105,6 @@
11001105
ENABLE_USER_SCRIPT_SANDBOXING = YES;
11011106
GCC_C_LANGUAGE_STANDARD = gnu99;
11021107
GCC_NO_COMMON_BLOCKS = YES;
1103-
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
11041108
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
11051109
GCC_WARN_ABOUT_RETURN_TYPE = YES;
11061110
GCC_WARN_UNDECLARED_SELECTOR = YES;
@@ -1120,6 +1124,7 @@
11201124
};
11211125
0F55491B151D1187007E633F /* Debug */ = {
11221126
isa = XCBuildConfiguration;
1127+
baseConfigurationReference = ACCBC14627BBB259000A16E1 /* Config.xcconfig */;
11231128
buildSettings = {
11241129
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
11251130
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -1128,6 +1133,7 @@
11281133
OTHER_LDFLAGS = (
11291134
"-ObjC",
11301135
"-w",
1136+
"$(inherited)",
11311137
);
11321138
PRODUCT_BUNDLE_IDENTIFIER = "it.joethefox.XBMC-Remote";
11331139
PRODUCT_NAME = "Kodi Remote";
@@ -1138,12 +1144,16 @@
11381144
};
11391145
0F55491C151D1187007E633F /* Release */ = {
11401146
isa = XCBuildConfiguration;
1147+
baseConfigurationReference = ACCBC14627BBB259000A16E1 /* Config.xcconfig */;
11411148
buildSettings = {
11421149
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
11431150
GCC_PRECOMPILE_PREFIX_HEADER = YES;
11441151
GCC_PREFIX_HEADER = "XBMC Remote/Kodi Remote-Prefix.pch";
11451152
INFOPLIST_FILE = "XBMC Remote/Kodi Remote-Info.plist";
1146-
OTHER_LDFLAGS = "-ObjC";
1153+
OTHER_LDFLAGS = (
1154+
"-ObjC",
1155+
"$(inherited)",
1156+
);
11471157
PRODUCT_BUNDLE_IDENTIFIER = "it.joethefox.XBMC-Remote";
11481158
PRODUCT_NAME = "Kodi Remote";
11491159
PROVISIONING_PROFILE_SPECIFIER = "Kodi Remote AppStore";

libs/fmt/include/fmt/args.h

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
// Formatting library for C++ - dynamic format arguments
2+
//
3+
// Copyright (c) 2012 - present, Victor Zverovich
4+
// All rights reserved.
5+
//
6+
// For the license information refer to format.h.
7+
8+
#ifndef FMT_ARGS_H_
9+
#define FMT_ARGS_H_
10+
11+
#include <functional> // std::reference_wrapper
12+
#include <memory> // std::unique_ptr
13+
#include <vector>
14+
15+
#include "core.h"
16+
17+
FMT_BEGIN_NAMESPACE
18+
19+
namespace detail {
20+
21+
template <typename T> struct is_reference_wrapper : std::false_type {};
22+
template <typename T>
23+
struct is_reference_wrapper<std::reference_wrapper<T>> : std::true_type {};
24+
25+
template <typename T> const T& unwrap(const T& v) { return v; }
26+
template <typename T> const T& unwrap(const std::reference_wrapper<T>& v) {
27+
return static_cast<const T&>(v);
28+
}
29+
30+
class dynamic_arg_list {
31+
// Workaround for clang's -Wweak-vtables. Unlike for regular classes, for
32+
// templates it doesn't complain about inability to deduce single translation
33+
// unit for placing vtable. So storage_node_base is made a fake template.
34+
template <typename = void> struct node {
35+
virtual ~node() = default;
36+
std::unique_ptr<node<>> next;
37+
};
38+
39+
template <typename T> struct typed_node : node<> {
40+
T value;
41+
42+
template <typename Arg>
43+
FMT_CONSTEXPR typed_node(const Arg& arg) : value(arg) {}
44+
45+
template <typename Char>
46+
FMT_CONSTEXPR typed_node(const basic_string_view<Char>& arg)
47+
: value(arg.data(), arg.size()) {}
48+
};
49+
50+
std::unique_ptr<node<>> head_;
51+
52+
public:
53+
template <typename T, typename Arg> const T& push(const Arg& arg) {
54+
auto new_node = std::unique_ptr<typed_node<T>>(new typed_node<T>(arg));
55+
auto& value = new_node->value;
56+
new_node->next = std::move(head_);
57+
head_ = std::move(new_node);
58+
return value;
59+
}
60+
};
61+
} // namespace detail
62+
63+
/**
64+
\rst
65+
A dynamic version of `fmt::format_arg_store`.
66+
It's equipped with a storage to potentially temporary objects which lifetimes
67+
could be shorter than the format arguments object.
68+
69+
It can be implicitly converted into `~fmt::basic_format_args` for passing
70+
into type-erased formatting functions such as `~fmt::vformat`.
71+
\endrst
72+
*/
73+
template <typename Context>
74+
class dynamic_format_arg_store
75+
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
76+
// Workaround a GCC template argument substitution bug.
77+
: public basic_format_args<Context>
78+
#endif
79+
{
80+
private:
81+
using char_type = typename Context::char_type;
82+
83+
template <typename T> struct need_copy {
84+
static constexpr detail::type mapped_type =
85+
detail::mapped_type_constant<T, Context>::value;
86+
87+
enum {
88+
value = !(detail::is_reference_wrapper<T>::value ||
89+
std::is_same<T, basic_string_view<char_type>>::value ||
90+
std::is_same<T, detail::std_string_view<char_type>>::value ||
91+
(mapped_type != detail::type::cstring_type &&
92+
mapped_type != detail::type::string_type &&
93+
mapped_type != detail::type::custom_type))
94+
};
95+
};
96+
97+
template <typename T>
98+
using stored_type = conditional_t<detail::is_string<T>::value &&
99+
!has_formatter<T, Context>::value &&
100+
!detail::is_reference_wrapper<T>::value,
101+
std::basic_string<char_type>, T>;
102+
103+
// Storage of basic_format_arg must be contiguous.
104+
std::vector<basic_format_arg<Context>> data_;
105+
std::vector<detail::named_arg_info<char_type>> named_info_;
106+
107+
// Storage of arguments not fitting into basic_format_arg must grow
108+
// without relocation because items in data_ refer to it.
109+
detail::dynamic_arg_list dynamic_args_;
110+
111+
friend class basic_format_args<Context>;
112+
113+
unsigned long long get_types() const {
114+
return detail::is_unpacked_bit | data_.size() |
115+
(named_info_.empty()
116+
? 0ULL
117+
: static_cast<unsigned long long>(detail::has_named_args_bit));
118+
}
119+
120+
const basic_format_arg<Context>* data() const {
121+
return named_info_.empty() ? data_.data() : data_.data() + 1;
122+
}
123+
124+
template <typename T> void emplace_arg(const T& arg) {
125+
data_.emplace_back(detail::make_arg<Context>(arg));
126+
}
127+
128+
template <typename T>
129+
void emplace_arg(const detail::named_arg<char_type, T>& arg) {
130+
if (named_info_.empty()) {
131+
constexpr const detail::named_arg_info<char_type>* zero_ptr{nullptr};
132+
data_.insert(data_.begin(), {zero_ptr, 0});
133+
}
134+
data_.emplace_back(detail::make_arg<Context>(detail::unwrap(arg.value)));
135+
auto pop_one = [](std::vector<basic_format_arg<Context>>* data) {
136+
data->pop_back();
137+
};
138+
std::unique_ptr<std::vector<basic_format_arg<Context>>, decltype(pop_one)>
139+
guard{&data_, pop_one};
140+
named_info_.push_back({arg.name, static_cast<int>(data_.size() - 2u)});
141+
data_[0].value_.named_args = {named_info_.data(), named_info_.size()};
142+
guard.release();
143+
}
144+
145+
public:
146+
constexpr dynamic_format_arg_store() = default;
147+
148+
/**
149+
\rst
150+
Adds an argument into the dynamic store for later passing to a formatting
151+
function.
152+
153+
Note that custom types and string types (but not string views) are copied
154+
into the store dynamically allocating memory if necessary.
155+
156+
**Example**::
157+
158+
fmt::dynamic_format_arg_store<fmt::format_context> store;
159+
store.push_back(42);
160+
store.push_back("abc");
161+
store.push_back(1.5f);
162+
std::string result = fmt::vformat("{} and {} and {}", store);
163+
\endrst
164+
*/
165+
template <typename T> void push_back(const T& arg) {
166+
if (detail::const_check(need_copy<T>::value))
167+
emplace_arg(dynamic_args_.push<stored_type<T>>(arg));
168+
else
169+
emplace_arg(detail::unwrap(arg));
170+
}
171+
172+
/**
173+
\rst
174+
Adds a reference to the argument into the dynamic store for later passing to
175+
a formatting function.
176+
177+
**Example**::
178+
179+
fmt::dynamic_format_arg_store<fmt::format_context> store;
180+
char band[] = "Rolling Stones";
181+
store.push_back(std::cref(band));
182+
band[9] = 'c'; // Changing str affects the output.
183+
std::string result = fmt::vformat("{}", store);
184+
// result == "Rolling Scones"
185+
\endrst
186+
*/
187+
template <typename T> void push_back(std::reference_wrapper<T> arg) {
188+
static_assert(
189+
need_copy<T>::value,
190+
"objects of built-in types and string views are always copied");
191+
emplace_arg(arg.get());
192+
}
193+
194+
/**
195+
Adds named argument into the dynamic store for later passing to a formatting
196+
function. ``std::reference_wrapper`` is supported to avoid copying of the
197+
argument. The name is always copied into the store.
198+
*/
199+
template <typename T>
200+
void push_back(const detail::named_arg<char_type, T>& arg) {
201+
const char_type* arg_name =
202+
dynamic_args_.push<std::basic_string<char_type>>(arg.name).c_str();
203+
if (detail::const_check(need_copy<T>::value)) {
204+
emplace_arg(
205+
fmt::arg(arg_name, dynamic_args_.push<stored_type<T>>(arg.value)));
206+
} else {
207+
emplace_arg(fmt::arg(arg_name, arg.value));
208+
}
209+
}
210+
211+
/** Erase all elements from the store */
212+
void clear() {
213+
data_.clear();
214+
named_info_.clear();
215+
dynamic_args_ = detail::dynamic_arg_list();
216+
}
217+
218+
/**
219+
\rst
220+
Reserves space to store at least *new_cap* arguments including
221+
*new_cap_named* named arguments.
222+
\endrst
223+
*/
224+
void reserve(size_t new_cap, size_t new_cap_named) {
225+
FMT_ASSERT(new_cap >= new_cap_named,
226+
"Set of arguments includes set of named arguments");
227+
data_.reserve(new_cap);
228+
named_info_.reserve(new_cap_named);
229+
}
230+
};
231+
232+
FMT_END_NAMESPACE
233+
234+
#endif // FMT_ARGS_H_

0 commit comments

Comments
 (0)