View Single Post
Old 06-20-2025, 01:40 PM   #15
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,987
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by hius07 View Post
CalibreSearch can be found as an upvalue in some of the main module methods.
Look for example at
https://github.com/koreader/koreader...ent-2871327027
I got as far as userpatch.getUpValue() before, but apparently I misunderstand it.

I have:
Code:
local userpatch = require("userpatch")

userpatch.registerPatchPluginFunc("calibre", function(Calibre)

    local CalibreSearch, up_idx = userpatch.getUpValue(Calibre.onCalibreSearch, "CalibreSearch")

    print("\ncalibre patch CalibreSearch:")
    print(CalibreSearch)
    
end)
And calibre.koplugin/main.lua contains a reference to CalibreSearch:
Code:
function Calibre:onCalibreSearch()
    CalibreSearch:ShowSearch()
    return true
end
But I just get 'nil' printed in the crash.log.

ADDENDUM

Of all the Calibre methods that reference CalibreSearch, getSearchMenuTable is the only one that gives me that reference from getUpValue:
Code:
userpatch.registerPatchPluginFunc("calibre", function(Calibre)

    local CalibreSearch, up_idx = userpatch. getUpValue(Calibre.getSearchMenuTable, "CalibreSearch")

    print("\ncalibre patch CalibreSearch:")
    print(CalibreSearch)
    
end)
No idea why that one works and the others don't.

Last edited by JimmXinu; 06-20-2025 at 02:29 PM. Reason: Addendum
JimmXinu is offline   Reply With Quote