61 using util::removePrefix;
62 using util::removeSuffix;
67 using std::regex_replace;
73 const auto DIAGNOSTICS_DOUBLE_PRECISION = 8;
74 const auto DIAGNOSTICS_FLOAT_PRECISION = 5;
87 extern const string BOTTOM_INDICATOR =
"⟂";
88 extern const string FAILURE_INDICATOR =
"↯";
89 extern const string VOID_INDICATOR =
"void";
90 extern const string FUNCTION_INDICATOR=
"Function";
92 extern const string BOOL_FALSE_STR =
"false";
93 extern const string BOOL_TRUE_STR =
"true";
136 demangleCxx (Literal rawName)
139 UniqueMallocOwner<char> demangled (abi::__cxa_demangle (rawName,
143 return 0==error? demangled.get()
149 #warning "Lumiera was _not_ built with a GCC compatible compiler." 150 #warning "There are good chances this works without problems, but up to now, \ 151 the Lumiera developers lacked the resources to investigate that option; \ 160 return string (rawName);
193 #define TYP_EXP "[\\w<>\\(\\):,\\s]+" 195 static regex commonPrefixes {
"std::" 196 "|(\\w+::)+\\(anonymous namespace\\)::" 203 "|steam::(asset::|mobject::(session::)?|play::)?" 207 , regex::ECMAScript | regex::optimize};
209 static regex stdString {
"(__cxx11::)?basic_string<char, char_traits<char>, allocator<char>\\s*>(\\s+\\B)?" 210 , regex::ECMAScript | regex::optimize};
212 static regex stdAllocator {
"(\\w+<(" TYP_EXP
")), allocator<\\2>\\s*" 213 , regex::ECMAScript | regex::optimize};
215 static regex mapAllocator {
"(map<(" TYP_EXP
"), (" TYP_EXP
")),.+allocator<pair<\\2 const, \\3>\\s*>\\s*" 216 , regex::ECMAScript | regex::optimize};
218 static regex uniquePtr {
"unique_ptr<(\\w+), default_delete<\\1>\\s*" 219 , regex::ECMAScript | regex::optimize};
221 static regex lumieraP {
"P<(\\w+), shared_ptr<\\1>\\s*" 222 , regex::ECMAScript | regex::optimize};
225 auto pos = typeName.begin();
226 auto end = typeName.end();
228 end = regex_replace(pos, pos, end, commonPrefixes,
"");
229 end = regex_replace(pos, pos, end, stdString,
"string");
230 end = regex_replace(pos, pos, end, stdAllocator,
"$1");
231 end = regex_replace(pos, pos, end, mapAllocator,
"$1");
232 end = regex_replace(pos, pos, end, uniquePtr,
"unique_ptr<$1");
233 end = regex_replace(pos, pos, end, lumieraP,
"P<$1");
235 typeName.resize(end - typeName.begin());
264 removeSuffix (typeStr,
" const");
265 removeSuffix (typeStr,
" const *");
266 removeSuffix (typeStr,
"*");
267 removeSuffix (typeStr,
"&");
269 if (isnil (typeStr))
return VOID_INDICATOR;
270 if (
')' == typeStr.back())
return FUNCTION_INDICATOR;
272 auto end = typeStr.end();
273 auto beg = typeStr.begin();
279 else if (
'<' == *end and level>0)
288 if (end == beg)
return VOID_INDICATOR;
290 auto pos = typeStr.rfind(
"::", end-beg);
291 typeStr = (pos==string::npos? typeStr.substr(0, end-beg)
292 : typeStr.substr(pos+2, (end-beg)-pos-2));
307 static regex identifierChars {
"[A-Za-z]\\w*", regex::ECMAScript | regex::optimize};
309 return regex_replace (text, identifierChars,
"$&", std::regex_constants::format_no_copy);
328 using std::noshowbase;
329 using std::ostringstream;
343 ostringstream buffer;
344 buffer.precision (DIAGNOSTICS_DOUBLE_PRECISION);
349 {
return FAILURE_INDICATOR; }
353 showFloat (
float val) noexcept
355 ostringstream buffer;
356 buffer.precision (DIAGNOSTICS_FLOAT_PRECISION);
361 {
return FAILURE_INDICATOR; }
365 showSize (
size_t val) noexcept
367 ostringstream buffer;
372 {
return FAILURE_INDICATOR; }
387 << size_t(addr) % suffix_modulus;
394 ostringstream buffer;
399 {
return FAILURE_INDICATOR; }
inline string literal This is a marker type to indicate that
Capture previous settings of an std::ostream and restore them when leaving scope. ...
Helper to deal with C-MALLOCed memory automatically.
Implementation namespace for support and library code.
Marker types to indicate a literal string and a Symbol.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
RAII helper to capture and restore output stream format settings.
Lumiera error handling (C++ interface).