From 85ddac0558313b5d3fbd9428ae3e9614f16d514d Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Wed, 29 Apr 2020 23:36:48 +0200
Subject: Improved the documentation of the disassembly cache for Python.

---
 plugins/pychrysalide/analysis/binary.c | 23 ++++++++++++++++-------
 src/analysis/binary.c                  |  4 ++--
 src/analysis/binary.h                  |  2 +-
 src/analysis/db/items/bookmark.c       |  2 +-
 src/analysis/db/items/comment.c        |  2 +-
 src/analysis/disass/block.c            |  4 ++--
 src/analysis/routine.c                 |  2 +-
 src/arch/target.c                      |  2 +-
 src/gui/dialogs/gotox.c                |  2 +-
 9 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/plugins/pychrysalide/analysis/binary.c b/plugins/pychrysalide/analysis/binary.c
index 3126a47..acc3ae5 100644
--- a/plugins/pychrysalide/analysis/binary.c
+++ b/plugins/pychrysalide/analysis/binary.c
@@ -71,7 +71,7 @@ static PyObject *py_loaded_binary_get_format(PyObject *, void *);
 static PyObject *py_loaded_binary_get_processor(PyObject *, void *);
 
 /* Fournit le tampon associé au contenu assembleur d'un binaire. */
-static PyObject *py_loaded_binary_get_disassembled_cache(PyObject *, void *);
+static PyObject *py_loaded_binary_get_disassembly_cache(PyObject *, void *);
 
 
 
@@ -476,14 +476,26 @@ static PyObject *py_loaded_binary_get_processor(PyObject *self, void *closure)
 *                                                                             *
 ******************************************************************************/
 
-static PyObject *py_loaded_binary_get_disassembled_cache(PyObject *self, void *closure)
+static PyObject *py_loaded_binary_get_disassembly_cache(PyObject *self, void *closure)
 {
     PyObject *result;                       /* Trouvailles à retourner     */
     GLoadedBinary *binary;                  /* Version native              */
     GBufferCache *cache;                    /* Tampon à récupérer          */
 
+#define LOADED_BINARY_DISASSEMBLY_CACHE_ATTRIB PYTHON_GET_DEF_FULL      \
+(                                                                       \
+    disassembly_cache, py_loaded_binary,                                \
+    "Give access to the disassembly graphical cache, which is a"        \
+    " pychrysalide.glibext.BufferCache instance or None.\n"             \
+    "\n"                                                                \
+    "In graphical mode, the cache is built by default. Otherwise, the"  \
+    " build depends on the *cache* argument provided at the analysis"   \
+    " call (please refer to the pychrysalide.analysis.LoadedContent"    \
+    " interface for more information about this kind of call)."         \
+)
+
     binary = G_LOADED_BINARY(pygobject_get(self));
-    cache = g_loaded_binary_get_disassembled_cache(binary);
+    cache = g_loaded_binary_get_disassembly_cache(binary);
 
     if (cache != NULL)
     {
@@ -537,10 +549,7 @@ PyTypeObject *get_python_loaded_binary_type(void)
             "processor", py_loaded_binary_get_processor, NULL,
             "Handler for the current binary processor.", NULL
         },
-        {
-            "disassembled_cache", py_loaded_binary_get_disassembled_cache, NULL,
-            "Disassembled buffer cache.", NULL
-        },
+        LOADED_BINARY_DISASSEMBLY_CACHE_ATTRIB,
         { NULL }
     };
 
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 0f7b096..bdee11b 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -1236,7 +1236,7 @@ GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *binary)
 *                                                                             *
 ******************************************************************************/
 
-GBufferCache *g_loaded_binary_get_disassembled_cache(const GLoadedBinary *binary)
+GBufferCache *g_loaded_binary_get_disassembly_cache(const GLoadedBinary *binary)
 {
     GBufferCache *result;                   /* Instance à retourner        */
 
@@ -1973,7 +1973,7 @@ static GtkWidget *g_loaded_binary_build_view(GLoadedBinary *binary, unsigned int
             break;
 
         case BVW_BLOCK:
-            cache = g_loaded_binary_get_disassembled_cache(binary);
+            cache = g_loaded_binary_get_disassembly_cache(binary);
             view = g_buffer_view_new(cache, NULL);
             display = gtk_block_display_new(view);
             break;
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 925fbb0..74c5f7f 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -143,7 +143,7 @@ GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *);
 GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *);
 
 /* Fournit le tampon associé au contenu assembleur d'un binaire. */
-GBufferCache *g_loaded_binary_get_disassembled_cache(const GLoadedBinary *);
+GBufferCache *g_loaded_binary_get_disassembly_cache(const GLoadedBinary *);
 
 
 /* -------------------- SAUVEGARDE ET RESTAURATION DE PARAMETRES -------------------- */
diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c
index 3cf9f3c..f493559 100644
--- a/src/analysis/db/items/bookmark.c
+++ b/src/analysis/db/items/bookmark.c
@@ -530,7 +530,7 @@ static bool g_db_bookmark_run(GDbBookmark *bookmark, GLoadedBinary *binary, bool
 
     result = false;
 
-    cache = g_loaded_binary_get_disassembled_cache(binary);
+    cache = g_loaded_binary_get_disassembly_cache(binary);
     if (cache == NULL) goto exit;
 
     g_buffer_cache_lock(cache);
diff --git a/src/analysis/db/items/comment.c b/src/analysis/db/items/comment.c
index 241451f..6c1f6d9 100644
--- a/src/analysis/db/items/comment.c
+++ b/src/analysis/db/items/comment.c
@@ -635,7 +635,7 @@ static bool g_db_comment_run(GDbComment *comment, GLoadedBinary *binary, bool ap
 
     result = true;
 
-    cache = g_loaded_binary_get_disassembled_cache(binary);
+    cache = g_loaded_binary_get_disassembly_cache(binary);
 
     cursor = g_binary_cursor_new();
     g_binary_cursor_update(G_BINARY_CURSOR(cursor), &comment->addr);
diff --git a/src/analysis/disass/block.c b/src/analysis/disass/block.c
index c80d464..d314b5a 100644
--- a/src/analysis/disass/block.c
+++ b/src/analysis/disass/block.c
@@ -496,7 +496,7 @@ static GBufferView *g_basic_block_build_view(const GBasicBlock *block, segcnt_li
     end = g_binary_cursor_new();
     g_binary_cursor_update(G_BINARY_CURSOR(end), get_mrange_addr(last_range));
 
-    cache = g_loaded_binary_get_disassembled_cache(block->binary);
+    cache = g_loaded_binary_get_disassembly_cache(block->binary);
 
     result = g_buffer_view_new(cache, highlighted);
 
@@ -637,7 +637,7 @@ static char *g_basic_block_build_tooltip(const GBasicBlock *block)
     string_info = NULL;
 
     proc = g_loaded_binary_get_processor(block->binary);
-    cache = g_loaded_binary_get_disassembled_cache(block->binary);
+    cache = g_loaded_binary_get_disassembly_cache(block->binary);
 
     iter = g_arch_processor_get_iter_from_address(proc, get_mrange_addr(&range));
     if (iter == NULL) goto no_iter;
diff --git a/src/analysis/routine.c b/src/analysis/routine.c
index 240004f..82f30f8 100644
--- a/src/analysis/routine.c
+++ b/src/analysis/routine.c
@@ -1102,7 +1102,7 @@ char *g_binary_routine_build_tooltip(const GBinRoutine *routine, const GLoadedBi
     string_info = NULL;
 
     proc = g_loaded_binary_get_processor(binary);
-    cache = g_loaded_binary_get_disassembled_cache(binary);
+    cache = g_loaded_binary_get_disassembly_cache(binary);
 
     /* Parcours des instructions */
 
diff --git a/src/arch/target.c b/src/arch/target.c
index 7d26be6..65fef30 100644
--- a/src/arch/target.c
+++ b/src/arch/target.c
@@ -427,7 +427,7 @@ static char *g_target_operand_build_tooltip(const GTargetOperand *operand, const
 
                 srange = g_binary_symbol_get_range(operand->symbol);
 
-                cache = g_loaded_binary_get_disassembled_cache(binary);
+                cache = g_loaded_binary_get_disassembly_cache(binary);
 
                 cursor = g_binary_cursor_new();
                 g_binary_cursor_update(G_BINARY_CURSOR(cursor), get_mrange_addr(srange));
diff --git a/src/gui/dialogs/gotox.c b/src/gui/dialogs/gotox.c
index 618eaa0..5ea7c07 100644
--- a/src/gui/dialogs/gotox.c
+++ b/src/gui/dialogs/gotox.c
@@ -390,7 +390,7 @@ static void add_new_location_to_list(GtkTreeStore *store, GLoadedBinary *binary,
 
     /* Détermination de la ligne concernée */
 
-    cache = g_loaded_binary_get_disassembled_cache(binary);
+    cache = g_loaded_binary_get_disassembly_cache(binary);
 
     cursor = g_binary_cursor_new();
     g_binary_cursor_update(G_BINARY_CURSOR(cursor), addr);
-- 
cgit v0.11.2-87-g4458