FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Simplify tkagg C extension. by anntzer · Pull Request #10936 · matplotlib/matplotlib · GitHub

Repository navigation

Simplify tkagg C extension. - #10936

Merged
tacaswell merged 1 commit into
matplotlib:masterfrom
anntzer:tkc
Jul 15, 2018
Merged

tacaswell merged 1 commit into
matplotlib:masterfrom
anntzer:tkc

Conversation

anntzer commented Apr 1, 2018

Copy link
Copy Markdown
Contributor

PR Summary

(just making it quite a bit shorter...)

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

anntzer added the GUI: tk label Apr 1, 2018
anntzer added this to the v3.0 milestone Apr 1, 2018
Comment thread src/_tkagg.cpp
}
return ( // -1 if any remaining symbols are NULL
return // -1 if any remaining symbols are NULL
((TK_FIND_PHOTO = (Tk_FindPhoto_t)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think it would be clearer if these were a bunch of separate ifs instead of this long chained thing (if every assignment fit on one line, that would also be clearer.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That'll be much simpler to do after #10680 is merged and we later get to remove the old version of the API. Then the only functions we'll have to load are Tk_FindPhoto and Tk_PhotoPutBlock_NoComposite, which also means that the Windows and non-Windows versions will only need to differ by how they call _dfunc.
Not convinced it's worth changing for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just to be clear, the endgame is to just do (e.g.)

void *_dfunc(void *lib_handle, const char *func_name);

int _func_loader(void *lib)
{
    // Fill global function pointers from dynamic lib.
    // Return number of successfully loaded functions.
    #define LOAD_TK(name) tk::name = Tk_##name##_t(_dfunc(lib, "Tk_" #name))
    return bool(LOAD_TK(FindPhoto)) + bool(LOAD_TK(PhotoPutBlock_NoComposite));
    #undef LOAD_TK
}

followed by OS-specific versions of _dfunc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

#10680 is merged now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

But the old API is still around (the simplification will only come after matplotlib.backends.tkagg is completely removed).

Comment thread src/_tkagg.cpp
found_tcl = get_tcl(hMods[i]);
if (found_tcl == -1) {
return 1;
return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What error is set here instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

good catch... fixed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actually no, there is indeed an error being set by _dfunc()

void *_dfunc(void *lib_handle, const char *func_name)
{
    // Load function `func_name` from `lib_handle`.
    // Set Python exception if we can't find `func_name` in `lib_handle`.
    // Returns function pointer or NULL if not present.

    void* func;
    // Reset errors.
    dlerror();
    func = dlsym(lib_handle, func_name);
    if (func == NULL) {
        PyErr_SetString(PyExc_RuntimeError, dlerror());  // here
    }
    return func;
}

(and similarly on Windows).

Left the original version as is.

Comment thread src/_tkagg.cpp
found_tk = get_tk(hMods[i]);
if (found_tk == -1) {
return 1;
return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Or here?

Comment thread src/_tkagg.cpp
// Return 1 if any pointer is NULL, 0 otherwise.
return (
return
((TCL_CREATE_COMMAND = (Tcl_CreateCommand_t)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Same split up here, probably.

tacaswell merged commit 677a3b2 into matplotlib:master Jul 15, 2018
anntzer deleted the tkc branch July 15, 2018 08:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL