-
Notifications
You must be signed in to change notification settings - Fork 3k
Add cv-qualifiers to Callback and deprecate combinatorial explody functions #2496
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
Conversation
That's a really nice change, I have few comments to make:
|
+1, these are good points Since a copy involves a simple copy of all the members, is the default Unfortunately the cast is for backwards compatibility, since at some point someone thought |
Yes it is sufficient but in that case drop the copy construction operator (rule of 0 or rule of 3 (five in c++11)).
The question is what we should do in that case ? R call() {
if (!_thunk) {
// never returns
error("LOGIC_ERROR: Call to a not initialized callback!");
}
return _thunk(_obj, &_func);
} So |
The reason for explicitely defining the copy constructor was to make it clear that the Callback class could be copied safely. Tangentally do we expect this to work? Might need the assignment operator: Callback<void()> cb;
void doit();
cb = doit; (Still looking into where null callback is used) |
Well I can't seem to find where the null callback was relied on, I thought it was somewhere in our codebase. I went ahead and moved the null check into the deprecated Interestingly enough, the I'd prefer to keep the copy constructor since it clarifies the class can be safely copied and matches the overloads for |
Looks like it is a bit tricky, since several drivers are relying on uninitialized Callbacks being callable, however this is an easy fix. |
@0xc0170 @sg- Do we recommend any pattern like Otherwise, +1 for the whole PR. |
+1, this should be covered in the guidelines. I like a rule "all or nothing". We already provide "rule of three" or at least partially in our classes, we manage resources, thus inclined to rule "all", for us (c++03) three. If we agree, The changes look good. People happy with jinja2 generated files? |
👍
nope |
Not committing the template files. If something needs to change that often to need auto-generation, I don't think its ready for master :) |
Copy contructor and jinja templates removed, let me know any other feedback. |
@@ -1,3 +1,6 @@ | |||
// Note: This file was autogenerated from main.j2 | |||
// j2 main.j2 > main.h |
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.
This is not true anymore?
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.
Good catch!
LGTM (one comment not valid anymore) |
0c8ec15
to
abd5430
Compare
Should be good to go 👍 |
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 701 Build failed! |
Looks like all the template expansions in the test caused flash to exceed 64K : / After talking with @bridadan (correct me if I'm wrong), will split the test into parts and move to TESTS/mbed_functional, which can house other non-hardware apis. |
/morph test |
At a latter stage maybe we can put all the data members in a non template base class and have function to set and reset them. That way It is also possible to factorize all |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 715 All builds and test passed! |
As the templated tests grew, the resulting binary exceeded a flash size of 64K. This caused the test to incorrectly fail on small devices. Moved and split into the following: TESTS/mbed_functional/callback TESTS/mbed_functional/callback_small TESTS/mbed_functional/callback_big TESTS/mbed_functional/functionpointer
/morph test |
Result: ABORTEDYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 728 Build Prep failed! |
@geky Sorry, making some CI changes. Please hold off on firing more PRs for the moment |
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 741 Test Prep failed! |
Looks like there was bug introduced with the latest version of setuptools, oh joy! I've deployed a workaround that should fix the test prep issue for now until they patch setuptools. /morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 742 Test failed! |
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
Outputmbed Build Number: 745 Test failed! |
@geky Test failures look ok 👍 Just timing issues again from the CI machine being under load |
Ah ok, in that case this pr should be good to go LGTM? |
LGTM ? |
Hi, this broke all mbed Client components. Please revert this. |
we need also this #2656 to be merged asap because it could find this kind of issues.. but I'm wondering why any other CI job's didn't recognize this before it was too late..? |
Our nightly build job identified this issue , it has been failing since yesterday morning after this PR has been merged. |
i think this kind of issues should be identified during PR verification jobs - before merging.. |
mbed-os needs to add mbed-client build jobs to the PR verification queue. |
Will patch or revert. Wasnt aware of this issues as it wasnt linked to the pr until after the merge |
There is no verification job on that catches this. They're missing from the jenkinsfile |
This has failing status so I cant merge 👎 |
From this discussion #2395 and the related issue #2490
The combination of cv-qualifiers with callback overloads results in a large number of overloads to match all possible types that could be passed to the Callback class.
This isn't a big problem for
void (*)(cv T *)
function types, but forvoid (T::*)() cv
types, the method in which cv-qualifiers are associated prevents encoding the cv-qualifiers in theT
type, and requiring a large combination of overloads for all cv-qualifiers.This pr involves several changes:
mbed::callback
function to pass different arguments to Callback with infered type.const
orvolatile
object with the existing convenience functions.Supported overloads:
Should fix: #2490
Replaces: #2395 and #2495
cc @pan-, @0xc0170
Let me know any thoughts/suggestions on this solution you guys have.