You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The with_side_effects() should create the constrain that allows user to browse the arguments of a function.
This could be relatively easily achieved by just passing a second argument to a user callback.
Expected feature:
void user_callback(void* data, Arguments* args) {
// here it is possible to inspect/interact with args
}
Such change should be backward-compatible, because same thing
was used by GTK+ extensively:
// old code, most important thing is that gtk_main_quit
// declares no parameters, receives two
// and despite all of this works like a charm.
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
The text was updated successfully, but these errors were encountered:
I'm not familiar enough with GTK to see how they get away with this. Just calling a function/macro with more arguments than it has declared will surely fire error messages from most C compilers.
Or am I misunderstanding you? I would appreciate a more detailed sketch of how this would look.
Ok, I will try to explain this whole C function pointers magic above:
The most important thing is to handle two
function signatures with a one macro. This can be done
with little bit of casting. Take a look at this trivial program:
#include <stdio.h>
It will compile and run on any platform. However, this doesn't mean this
is a C-compilant program, because standard doesn't define
such calls at any point.
After some reconsideration I figured out we might use some other,
more standard C tricks to handle two types with a single macro.
In C11 there is a _Generic macro, which can be useful:
#include <stdio.h>
int main()
{
CALL(funcA);
CALL(funcB);
return 0;
}
I personally like the second approach more sue to standard compliance
and cleaner error messages. If that approach is to be chosen sth like
with_parametrized_side_effects needs to be provided for for
older C versions.
The with_side_effects() should create the constrain that allows user to browse the arguments of a function.
This could be relatively easily achieved by just passing a second argument to a user callback.
Expected feature:
void user_callback(void* data, Arguments* args) {
// here it is possible to inspect/interact with args
}
//using cb
expect(mocked_function, with_side_effect(&user_callback, &unimportant));
Such change should be backward-compatible, because same thing
was used by GTK+ extensively:
// old code, most important thing is that gtk_main_quit
// declares no parameters, receives two
// and despite all of this works like a charm.
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
The text was updated successfully, but these errors were encountered: