Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata to types, unions and enums. #97

Open
wc-duck opened this issue Aug 23, 2018 · 4 comments
Open

Add metadata to types, unions and enums. #97

wc-duck opened this issue Aug 23, 2018 · 4 comments
Labels

Comments

@wc-duck
Copy link
Owner

wc-duck commented Aug 23, 2018

You define your metadata as dl-types and then the metadata of a type as

"metadata" : [ { "range" : { "min" : 1, "max" : 5 } ]

I.e. "range" here would be a dl-type as any other and parsed as such. The instance is then stored in the typelib and accessed via something as:

unsigned int meta_cnt = dl_get_metadata_cnt(ctx, typeid);
for(; i < meta_cnt; ++i)
{
    dl_typeid_t meta_type;
    void* meta_inst = dl_get_metadata(ctx, typeid, i, &out_type_id);

    switch (meta_type)
    {
        /// cast and use!
    }
}
@Tisten
Copy link
Contributor

Tisten commented Oct 14, 2022

Just so you don't happen to start to implement this over the weekend, I will finish this on Monday and create a PR

@wc-duck
Copy link
Owner Author

wc-duck commented Oct 14, 2022

That will not happen... the entire weekend is booked by me and my better half :)

Tisten pushed a commit to Tisten/datalibrary that referenced this issue Oct 17, 2022
@Tisten
Copy link
Contributor

Tisten commented Oct 17, 2022

I hope this can be marked as fixed when the PR is approved.

wc-duck pushed a commit that referenced this issue Nov 2, 2022
* Small fixes (and with incorrect commas)

* Added support for metadata 

#97

* Didn't mean to change all that whitespace

* More whitespace madness

* Compile warning fix

* Gcc fixes

* Fixed memory leaks and operations on uninitialized memory

* Fixed uninitialized data

* PR review fixes

* Review fix from PR #157

* GCC C fix

* Moved metadata access to dl_reflect.h

* Removed WinMerge .bak file

Co-authored-by: Christian Nilsendahl <[email protected]>
@Tisten
Copy link
Contributor

Tisten commented Nov 2, 2022

Feel free to close this now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants