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

Default data reflection #169

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Tisten
Copy link
Contributor

@Tisten Tisten commented Nov 4, 2022

Expose default data in the reflection API, solve: #161
The implementation is not "final". Right now there is an internal state which is not thread safe. This is mentioned in the issue above, so please discuss the preferred solution there.

Also includes second iteration of string merging, now doing it when json parsing as well: #14

Christian Nilsendahl added 6 commits October 28, 2022 15:23
Loading multiple type libraries with default data resulted in DL_ERROR_OUT_OF_DEFAULT_VALUE_SLOTS.
Merge remote-tracking branch 'origin/master' into default_data_reflection
Fixed pointer patching of default values
Fixed merging of identical strings when packing json data
@@ -139,63 +140,6 @@ dl_error_t DL_DLL_EXPORT dl_instance_load_inplace( dl_ctx_t dl_ctx,
return DL_ERROR_OK;
}

struct CDLBinStoreContext
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to new private header: "dl_store.h"

@@ -1,6 +1,30 @@
#include "dl_patch_ptr.h"
#include "dl_types.h"

struct dl_patched_ptrs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a plain "undo" of the things mentioned here: https://github.com/wc-duck/datalibrary/pull/158/files#r1000718654

@@ -122,12 +123,27 @@ dl_error_t DL_DLL_EXPORT dl_reflect_get_type_members( dl_ctx_t dl_ctx, dl_typeid
if(members_size < type->member_count)
return DL_ERROR_BUFFER_TOO_SMALL;

if (!dl_ctx->default_data_patched)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the internal state I want to avoid by storing the default data in a persistant memory location instead of reallocating a buffer and moving around the data every time new types are added/loaded, discuss it here #161 (comment)

CArrayStatic<SString, 128>& strings;
};

dl_error_t dl_internal_store_member( dl_ctx_t dl_ctx, const dl_member_desc* member, const uint8_t* instance, CDLBinStoreContext* store_ctx );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being able to use this interface from dl_txt_pack.cpp means dl_patch_ptr doesn't need to handle pointer recording and string merging for storing. It just patches pointers.

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

Successfully merging this pull request may close these issues.

None yet

1 participant