attribute for meta information

82 Aufrufe
Direkt zur ersten ungelesenen Nachricht

vova...@gmail.com

ungelesen,
20.09.2013, 12:06:2820.09.13
an std-pr...@isocpp.org
add attribute (like [[meta]] or [[info]]) thet create specialization of class "dynamic trait" for type/func/enum/...

so we can use it like extended type traits

meta<MyEnum>::items[3].name
meta<MyClass>::field[0].name //shift, size, typeid, ....
meta<func>::signature
etc

Jonathan Wakely

ungelesen,
20.09.2013, 12:19:3520.09.13
an std-pr...@isocpp.org, vova...@gmail.com

I think you need to explain this a bit more.

vova...@gmail.com

ungelesen,
20.09.2013, 13:12:4520.09.13
an std-pr...@isocpp.org


Пʼятниця, 20 вересня 2013 р. 17:19:35 UTC+1 користувач Jonathan Wakely написав:
Many tasks require rich meta-information(more than can give typeid). For example for build SQL-queries from struct we need names of fields:
struct person {string name;  int salary} -> SELECT name, salary FROM person
or create table or interact with script or serialization or ...
So we need something like person::meta_info where meta_info is a struct with this information we need. But similar information we need from functions or enums that dont have  operator "::" and C++ do not produce meta information for all types.
My proposal is to introduce attribute [[meta]]:
struct [[meta]] person {string name;  int salary};
this code forces compiler to create "meta" template specialization
template<>
class meta<person> {
    fieldinfo[] fields = { {name="name", type="std::string", shift=0, size=28}, ... } // array of field info structures
    methodinfo[] = {} // array of method info structures
    size_t obj_size = 32;//byte
}

or for function:
int main [[meta]] (char** argc, int argv) {...}
template specialization
template<>
class meta<main> {
    arginfo[] args = { {name="name", type="char**"}, ... } // array of arg info structures
    return_type = ....
    name = "main"
    ....
}

Ville Voutilainen

ungelesen,
20.09.2013, 15:03:0220.09.13
an std-pr...@isocpp.org
On 20 September 2013 20:12, <vova...@gmail.com> wrote:


Пʼятниця, 20 вересня 2013 р. 17:19:35 UTC+1 користувач Jonathan Wakely написав:
On Friday, September 20, 2013 5:06:28 PM UTC+1, vova...@gmail.com wrote:
add attribute (like [[meta]] or [[info]]) thet create specialization of class "dynamic trait" for type/func/enum/...

so we can use it like extended type traits

meta<MyEnum>::items[3].name
meta<MyClass>::field[0].name //shift, size, typeid, ....
meta<func>::signature
etc

I think you need to explain this a bit more.
Many tasks require rich meta-information(more than can give typeid). For example for build SQL-queries from struct we need names of fields:


This is stuff for SG7, the Reflection Study Group. Once that SG gets its forum going, we can start discussing
this sort of proposals.

Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten