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

removal of out_fct_wrap_type #32

Closed
mickjc750 opened this issue Aug 29, 2021 · 7 comments
Closed

removal of out_fct_wrap_type #32

mickjc750 opened this issue Aug 29, 2021 · 7 comments
Labels
enhancement New feature or request resolved-on-develop A changeset fixing this issue has been commiutted to the development branch

Comments

@mickjc750
Copy link

This wrapper exists, as a means of passing a function pointer and a null pointer, from the interface function all the way down to the character output function, which itself is a function pointer based on the output mode. This is needed to provide fctprintf().

A better approach, is to instantiate a variable set (struct) particular to the output mode in the interface function. Then pass this by reference through to the character output function.
This makes the character output function the same format (void (out)(char, void)) as that used by fctprintf().
This removes the need for a double function pointer de-reference per character which is a performance boost.
It also removes the need to pass the 'maxlen' parameter to most of the functions, where for most output modes it is unused.

@eyalroz
Copy link
Owner

eyalroz commented Sep 6, 2021

I don't exactly follow what you're suggesting:

  • out_fct_wrap_type is not exposed in the library interface.
  • As for the double-dereferencing - we do currently have it, but I don't see how your suggestion would remove it: You seem to be suggesting we pass the function pointer through a pointer to a struct containing it.

Please clarify...

@mickjc750
Copy link
Author

Not the function pointer. Only variables specific to the mode of output. It's difficult for me to explain, but I've already done this on an open PR, you can see the changes there.

@eyalroz
Copy link
Owner

eyalroz commented Sep 7, 2021

Oh, now I see your PR.

But - it's a 44-commit PR; that doesn't make sense. I can't use it without spending hours, or days, on merging. To submit a PR, you start from the branch you're PR'ing against, and only apply one or a few changesets to get the effect you wanted.

Anyway, I don't mind using the struct you suggested, which basically a kind of a richer iterator than a raw pointer. I'll try to manually merge that change soon.

@eyalroz
Copy link
Owner

eyalroz commented Sep 7, 2021

Hmm. This is interesting. This actually gives me the idea of doing something a little differentr:

  • Do wrap output functions.
  • Use the wrapper for regular buffer output as well
  • Have the wrapper take care of counting the number of characters printed
  • Don't pass maxlen around at all... perhaps we can even avoid passing idx around entirely.
  • Don't pass idx and maxlen to the output function - because they're supposed to have it.

@eyalroz
Copy link
Owner

eyalroz commented Sep 26, 2021

Well, I was going to work on this, but then other issues came up. Now that there are no open bugs, I believe it might be a good idea to pause, make a release (v5.0 I suppose), then get back to this. What do you think, @mickjc750 ?

@eyalroz eyalroz added the enhancement New feature or request label Sep 26, 2021
@mickjc750
Copy link
Author

I agree, I have some other issues myself at the moment. It's working well enough for now.

@eyalroz
Copy link
Owner

eyalroz commented Jan 22, 2022

@mickjc750 : So, this is happening... expect a PR soon. It will do away with 4 parameters + the return value in lots of functions :-)

eyalroz added a commit that referenced this issue Jan 22, 2022
…entation for all library functions.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 22, 2022
…entation for all library functions.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 22, 2022
…entation for all library functions.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 24, 2022
…entation for all library functions.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 25, 2022
…entation for all library functions.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 25, 2022
…entation for all library functions. Also, this merits a version bump.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 25, 2022
…entation for all library functions. Also, this merits a version bump.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 25, 2022
…entation for all library functions. Also, this merits a version bump.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 26, 2022
…entation for all library functions. Also, this merits a version bump.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 26, 2022
…entation for all library functions. Also, this merits a version bump.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
@eyalroz eyalroz added the resolved-on-develop A changeset fixing this issue has been commiutted to the development branch label Jan 31, 2022
eyalroz added a commit that referenced this issue Jan 31, 2022
…entation for all library functions. Also, this merits a version bump.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 31, 2022
…entation for all library functions. Also, this merits a version bump.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Jan 31, 2022
…entation for all library functions. Also, this merits a version bump.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
eyalroz added a commit that referenced this issue Feb 11, 2022
…entation for all library functions. Also, this merits a version bump.

* Added: An `output_gadget_t` struct
* Added: Named constructor idioms for `output_gadget_t`, instead of the function wrappers we have before: For `putchar_()` output, buffer output, discarding/no output, and arbitrary function output.
* Implementation functions no longer need to maintain and pass around the parameters `buffer`, `maxlen`, `idx` - these are part of the uniform output gadget
* Implementation functions no longer need to increase the position within the output (`idx)`, nor return the increased value to their caller.
* No longer need a dummy buffer of size 1, anywhere.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request resolved-on-develop A changeset fixing this issue has been commiutted to the development branch
Projects
None yet
Development

No branches or pull requests

2 participants