-
Notifications
You must be signed in to change notification settings - Fork 803
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
Better c++ #1965
Better c++ #1965
Conversation
447f6b1
to
1e37258
Compare
27f6336
to
95cfcf9
Compare
That would be better as multiple PRs. It's ok to make a chain of them, just say in the comments who depends on who. |
4420619
to
d622929
Compare
c26698e
to
abb7efb
Compare
abb7efb
to
29b6034
Compare
29b6034
to
8d8f53a
Compare
8bf8cb9
to
2f2cf6a
Compare
That last commit about centralizing GValue got me to realize that since you're writing C++ here and accessing the KvpFrames directly, there's no need for GValues at all, use Edit: Better yet move them to qofinstance. The whole point of the GValue dodge was to provide a generic interface similar to g_object_[sg]et for C code. It doesn't make sense to have a bunch of template <typename T> T
qof_instance_get_path_value(QofInstance* inst, Path path)
{
auto kvp_value{inst->get_slot(path)};
return kvp_value->get<T>();
}
template <typename T> void
qof_instance_set_path_value(QofInstance* inst, Path path, T value)
{
KvpValue kvp_value(value);
inst->kvp_data->set_path(path, kvp_value);
} Then to handle the edit level and marking-dirty in Account.cpp you'd have template <typename T>
set_slot_from_path(Account* acc, Path path, T value)
{
xaccAccountBeginEdit(acc);
qof_instance_set_path_value(QOF_INSTANCE(acc), path, value);
mark_account(acc);
xaccAccountCommitEdit(acc);
} When calling |
0d4725d
to
3e3b714
Compare
Not quite because Edit: alternatively we could return |
The last issue is the |
d8230e3
to
563c974
Compare
if last-num is empty-string, remove the slot. this makes the behaviour consistent with other slots.
e52a405
to
0a6fcb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still want the QofInstance* NULL check in qof_instance_get_path_kvp and get_kvp_gnc_foo_path removed.
You made a typo in your last commit that causes tests to fail.
e146210
to
793c14d
Compare
if the last two are ok I'll tidy up and merge in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite, you went in the opposite direction I had in mind. The null/wrong type check needs to be at the lowest level to protect against some future use that doesn't do it. There's no harm in doing it also nearer the source to make a more usefult tracefile.
2e285c7
to
fbaf27e
Compare
these overloaded functions to kvp slots do not require GValue
which do not require GValue dance small modification of xaccAccountSetLastNum behaviour with empty-string last_num
fbaf27e
to
1085721
Compare
OK, merge when ready. |
to be selectively merged after 5.7.
gnc_account_foreach_descendant
for c++ use.