austinbrunkhorst / cpp-reflection Goto Github PK
View Code? Open in Web Editor NEWC++ Reflection Parser / Runtime Skeleton
License: MIT License
C++ Reflection Parser / Runtime Skeleton
License: MIT License
Can you tell me how to build the project?Thanks.
I defined two struct to test.
struct arrStruct
{
int c;
int d;
} Meta(Enable);
struct TestStruct
{
int a;
int b;
struct arrStruct arr[2];
} Meta(Enable);
test code:
void ShowVec(const vector<Field>& valList)
{
for (auto iter = valList.cbegin(); iter != valList.cend(); iter++)
{
Field f = *iter;
Type t = f.GetType();
if (t.IsArray())
{
auto arrayCtor = t.GetArrayConstructor();
auto instance = arrayCtor.Invoke();
auto wrapper = instance.GetArray();
std::cout << "array's size:" << wrapper.Size() << std::endl;
}
if (t.IsClass())
{
std::vector<Field> fields = t.GetFields();
ShowVec(fields);
}
std::cout << "field's name:" << (*iter).GetName() << std::endl;
}
}
when compile:
source\runtime\Impl/FieldSetter.hpp(64): error C3863
Hi @AustinBrunkhorst
When compiling the Examples, everything seems to go fine (both Parser and Runtime compile) but the Serialization.cpp fails to link. This is the output I get. If I look at the files of the Generated folder, all of them but the *.includes one are empty. I think there is something wrong with the meta_parser_build command, like if it was not triggering the Parser. Any ideas?
[ 23%] Built target MetaParser
[ 55%] Built target MetaRuntime
[ 61%] Built target TestModule
[ 62%] Linking CXX executable Serialization
CMakeFiles/Serialization.dir/Serialization.cpp.o: En la función `main':
Serialization.cpp:(.text+0xcb): referencia a `meta_generated::ModuleTestModule::ModuleTestModule(ursine::meta::ReflectionDatabase&)' sin definir
Serialization.cpp:(.text+0xda): referencia a `meta_generated::ModuleTestModule::~ModuleTestModule()' sin definir
collect2: error: ld devolvió el estado de salida 1
make[2]: *** [CMakeFiles/Serialization.dir/build.make:193: Serialization] Error 1
make[1]: *** [CMakeFiles/Makefile2:70: CMakeFiles/Serialization.dir/all] Error 2
I am under linux, using GCC 6.2.0, libclang 3.8.1 and boost 1.6.1
Best,
Arnau
I found the content of generated files is empty!
the compile error is :
Undefined symbols for architecture x86_64:
"meta_generated::ModuleTestModule::ModuleTestModule(ursine::meta::ReflectionDatabase&)", referenced from:
_main in Enums.o
"meta_generated::ModuleTestModule::~ModuleTestModule()", referenced from:
_main in Enums.o
it's a cool library, thanks.
i use the library in my project, i write my cmake file on the basis of example's cmake file.
i generate the vs project, and generate the needed meta files, but these files is empty.
i can't debug this, i don't know where is wrong.
can you add some document about cmake rule?
for example, explain the "meta_parser_prebuild" and "meta_parser_build".
Thanks.
It has tons of problems and bugs, this uploaded version is clearly not working. I had to insert a lot of modifications to make it compile and the Meta attributes is still not working as well.
This header is missing from repo.
Is this file essential to get things up and working or it is safe to remove.
Asking in advance, before I start messing with and things fall to pieces (;.
It looks like much of the dependency setup outlined in your readme could be done automatically by using conan.io.
In Test Projects With MetaProperties.The Code Say:
// you can also use type meta::Type::Get( "SoundEffect" ) based on a string name Type soundEffectType = typeof( SoundEffect );
But,when i Replace the code with:
Type soundEffectType = ursine::meta::Type::Get("SoundEffect");
The soundEffectType Result not Right! SoundEffectType.m_id is 0,and then the program crash with null pointer read!
Does this project supposed to:
template
, macro
etc.meta data
?I have read the section of Type Meta Data, but I can't make it work.
Range is inherit from Object, but there are two pure virtual method:
virtual Type GetType(void) const = 0;
virtual Object *Clone(void) const = 0;
so, I can't got a instance of Range
And I can't find any code in the Parser to handle the annotate attribute of libclang
So, I want to know, is the annotate attribute is ready to be use or some code must be modify before I can use it.
Thank's very much
I test "Serialization" Project ,change the ComplexType struct's ursine::Array<int> arrayValue;
with
std::list<int> arraryValue;
and also change the generate code with type.AddField<ComplexType, std::list<int>>
Then complile and run, the Result of arraryValue is empty.I look at the function SerializeJson(const Variant &instance, bool invokeHook)
,and find that's no std::list serialize function.
So,can you tell me all types, that i can use with runtime?
If I compile this with visual studio 2017 (w/ cmake) it'll give an "Cannot use Argument as an argument" error.
I think this line should be:
typedef typename std::decay<T>::type Decayed;
rather than:
typedef std::decay<T> Decayed;
Because you wanna check if the decayed type of T
is a primitive/enum/class/etc.. and not check if the instantiated template std::decay<T>
is a primitive/enum/class/etc.. (which would always generate the same results: class = true, primitive = false, enum =false).
In README.md you state
Note: this assumes you have created empty files for
${META_GENERATED_HEADER}
and${META_GENERATED_SOURCE}
and added it to the list of sources when callingadd_executable( )
. Otherwise, CMake will complain about the files not existing initially.
The recommended approach is not to create empty files for generated files (especially as you will be tempted to put them in the source directory instead of the build directory). Instead you should set the GENERATED
on the corresponding sources:
set_source_files_properties(
${META_GENERATED_HEADER} ${META_GENERATED_SOURCE}
PROPERTIES
GENERATED ON
)
Furthermore you use a PRE_BUILD
TARGET
add_custom_command
which only works on Visual Studio. Using a non-TARGET
add_custom_command
might be better (and also sets the GENERATED
property automatically).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.