Coder Social home page Coder Social logo

austinbrunkhorst / cpp-reflection Goto Github PK

View Code? Open in Web Editor NEW
632.0 49.0 91.0 212 KB

C++ Reflection Parser / Runtime Skeleton

License: MIT License

C++ 93.66% Objective-C 0.20% C 0.40% HTML 2.60% CMake 3.14%
cmake libclang c-plus-plus meta reflection automation build

cpp-reflection's People

Contributors

austinbrunkhorst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpp-reflection's Issues

Get Type with string name Problem.

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!

The examples can not work on Mac OS!

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

The runtime type limit?

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?

Can not set struct as array

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

Documentation issue (CMake)

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 calling add_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).

Examples fail to link

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

can you add some document about cmake rule?

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.

Type Meta Data not work

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

TypeInfo.hpp DecayedType

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).

Can this project to be used as a code generator?

Does this project supposed to:

  1. Parse the C++ source code with full language features via clang? Which means it could parse code with template, macro etc.
  2. Get all the information about all the classes and user defined meta data?
  3. Generate code based on the information with customizable template?

Is this a work-in-progress source?

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.

UrisinePrecompiled.h missing

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 (;.

Conan.io

It looks like much of the dependency setup outlined in your readme could be done automatically by using conan.io.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.