Home > Back-end >  Excuse me somebody know how C IDE implementation 'Reflection' (Reflection)?
Excuse me somebody know how C IDE implementation 'Reflection' (Reflection)?

Time:09-15

You master edition hello
Since I know Java, c # language, reflected the function after
Is hope also supports c + + function, but the Internet ages, are still say c + + without this function,
Really want to have to go to write a class, some specifications, can make to
In fact I also wrote a simple library, can complete the basic requirements

But I always have a problem
Such as BCB, Visual Studio IDE, after we enter the object name
Often there will be a hint, what is the object function of the available hint Windows out
This function is implemented?
Is pure analytical source file, record down what are the variables, the object function is available, like this?

Because I usually do to project need to deal with the often struct structure
Different structure, members of different, different types, is often the need for them to do some UI interface to display
Has been in the pursuit of what method can automatically identify structure, traverse a member variable, the function of automatically generated report
Do people have similar needs and solutions?
Thank you & lt; (_ _) & gt;

CodePudding user response:

Can refer to Qt Meta Object system, (Meta Object),
But need to explicitly "registered" type again,
Also you can refer to the
https://github.com/bytemaster/boost_reflect

boost_reflect

CodePudding user response:

Qt moc only do compile-time reflection (the general called introspection), no runtime reflection (QML is possible. After all, is the runtime interpretive execution js), in addition, the realization of the moc is very awkward, to insert some in the source of macro as a marker positioning, it is also does not have its own compiler and necessity method, reflection is the basis of RTTI, or kung fu in the compiler, the program can look very concise

CodePudding user response:

refer to the second floor early play big play nuclear response:
Qt moc only do compile-time reflection (the general called introspection), there is no runtime reflection (QML is possible. After all, is the runtime interpretive execution js), in addition, the realization of the moc is very awkward, to insert some mess in the source of macro as a marker positioning, it is also does not have its own compiler and necessity method, reflection is the basis of RTTI, or kung fu in the compiler, the program can look very concise

Right, the key is once used metaobj, must moc before compilation, a reflection of the boost slightly better, but it is not good enough, the key is the compiler doesn't support myself,

CodePudding user response:

Reflection is depend on the compilation of the metadata, metadata inappropriate analogy you can imagine similar to c + + template, write a template, the runtime will explain data in accordance with the template,

CodePudding user response:

Metadata as RTTI embedded into an executable program, so you can be accessed at runtime to
  • Related