Implement std::meta::{data_member_spec,is_data_member_spec}.

This commit is contained in:
Jakub Jelinek
2025-10-18 16:16:47 +02:00
committed by Marek Polacek
parent 4b67ad0feb
commit edb051f3ba
65 changed files with 1111 additions and 122 deletions

View File

@@ -840,6 +840,10 @@ _cpp_destroy_iconv (cpp_reader *pfile)
iconv_close (pfile->char32_cset_desc.cd);
if (pfile->wide_cset_desc.func == convert_using_iconv)
iconv_close (pfile->wide_cset_desc.cd);
if (pfile->reverse_narrow_cset_desc.func == convert_using_iconv)
iconv_close (pfile->narrow_cset_desc.cd);
if (pfile->reverse_utf8_cset_desc.func == convert_using_iconv)
iconv_close (pfile->utf8_cset_desc.cd);
}
}
@@ -2726,6 +2730,110 @@ cpp_interpret_string_notranslate (cpp_reader *pfile, const cpp_string *from,
return retval;
}
/* Convert a string FROM to TO, without handling of any UCNs etc., just
pure character set conversion. If !REVERSE, convert from SOURCE_CHARSET
to execution charset corresponding to TYPE, if REVERSE, convert from the
execution charset corresponding to TYPE to SOURCE_CHARSET. Return false
on error. */
bool
cpp_translate_string (cpp_reader *pfile, const cpp_string *from,
cpp_string *to, enum cpp_ttype type, bool reverse)
{
struct cset_converter cvt = converter_for_type (pfile, type);
struct _cpp_strbuf tbuf;
if (reverse)
{
struct cset_converter *pcvt;
switch (type)
{
default:
pcvt = &pfile->reverse_narrow_cset_desc;
break;
case CPP_UTF8CHAR:
case CPP_UTF8STRING:
pcvt = &pfile->reverse_utf8_cset_desc;
break;
case CPP_CHAR16:
case CPP_STRING16:
case CPP_CHAR32:
case CPP_STRING32:
case CPP_WCHAR:
case CPP_WSTRING:
return false;
}
if (pcvt->func == NULL)
{
*pcvt = init_iconv_desc (pfile, cvt.from, cvt.to);
pcvt->width = cvt.width;
}
cvt = *pcvt;
}
tbuf.asize = MAX (OUTBUF_BLOCK_SIZE, from->len);
tbuf.text = XNEWVEC (uchar, tbuf.asize);
tbuf.len = 0;
if (!APPLY_CONVERSION (cvt, from->text, from->len, &tbuf))
{
XDELETEVEC (tbuf.text);
return false;
}
tbuf.text = XRESIZEVEC (uchar, tbuf.text, tbuf.len);
to->text = tbuf.text;
to->len = tbuf.len;
return true;
}
/* Return true if ID is a valid identifier, false otherwise. Without any
diagnostics. */
bool
cpp_valid_identifier (cpp_reader *pfile, const unsigned char *id)
{
normalize_state nst = INITIAL_NORMALIZE_STATE;
const unsigned char *p = id;
if (*p == '\0')
return false;
const unsigned char *limit
= (const unsigned char *) strchr ((const char *) p, '\0');
static const cppchar_t utf8_signifier = 0xC0;
if (ISIDST (*p))
{
NORMALIZE_STATE_UPDATE_IDNUM (&nst, *p);
++p;
}
while (*p)
{
if (p != id && ISIDNUM (*p))
{
while (ISIDNUM (*p))
++p;
NORMALIZE_STATE_UPDATE_IDNUM (&nst, *(p - 1));
continue;
}
if (CPP_OPTION (pfile, extended_identifiers) && *p >= utf8_signifier)
{
const unsigned char *base = p;
size_t inbytesleft = limit - p;
cppchar_t c;
if (one_utf8_to_cppchar (&p, &inbytesleft, &c))
return false;
switch (ucn_valid_in_identifier (pfile, c, &nst))
{
default:
return false;
case 1:
continue;
case 2:
if (base == id)
return false;
continue;
}
}
return false;
}
return true;
}
/* Return number of source characters in STR. */
static unsigned

View File

@@ -1309,6 +1309,9 @@ extern const char *cpp_interpret_string_ranges (cpp_reader *pfile,
extern bool cpp_interpret_string_notranslate (cpp_reader *,
const cpp_string *, size_t,
cpp_string *, enum cpp_ttype);
extern bool cpp_translate_string (cpp_reader *, const cpp_string *,
cpp_string *, enum cpp_ttype, bool);
extern bool cpp_valid_identifier (cpp_reader *, const unsigned char *);
/* Convert a host character constant to the execution character set. */
extern cppchar_t cpp_host_to_exec_charset (cpp_reader *, cppchar_t);

View File

@@ -543,6 +543,14 @@ struct cpp_reader
wide execution character set. */
struct cset_converter wide_cset_desc;
/* Descriptor for converting from the execution character set to the
source character set. */
struct cset_converter reverse_narrow_cset_desc;
/* Descriptor for converting from the UTF-8 execution character set to the
source character set. */
struct cset_converter reverse_utf8_cset_desc;
/* Date and time text. Calculated together if either is requested. */
const unsigned char *date;
const unsigned char *time;