Skip to content

Commit

Permalink
Prepare headers for rz-bindgen
Browse files Browse the repository at this point in the history
* add some missing /*<types>*/ to rz_core, bin, analysis, cons
* add annotation attributes for rz-bindgen
* fix extern "C" in some headers
* rename RzBuffer functions from length to len
* fix rz_core_analysis_name naming conflict
  • Loading branch information
wingdeans committed Jul 19, 2022
1 parent 35cf52e commit af5d3db
Show file tree
Hide file tree
Showing 20 changed files with 176 additions and 150 deletions.
2 changes: 1 addition & 1 deletion librz/analysis/analysis.c
Expand Up @@ -622,7 +622,7 @@ RZ_API bool rz_analysis_noreturn_at(RzAnalysis *analysis, ut64 addr) {
return false;
}

RZ_API RzList *rz_analysis_noreturn_functions(RzAnalysis *analysis) {
RZ_API RzList /*<char*>*/ *rz_analysis_noreturn_functions(RzAnalysis *analysis) {
rz_return_val_if_fail(analysis, NULL);
// At first we read all noreturn functions from the Types DB
RzList *noretl = rz_type_noreturn_function_names(analysis->typedb);
Expand Down
2 changes: 1 addition & 1 deletion librz/analysis/block.c
Expand Up @@ -889,7 +889,7 @@ static bool automerge_get_predecessors_cb(void *user, const ut64 k, const void *

// Try to find the contiguous predecessors of all given blocks and merge them if possible,
// i.e. if there are no other blocks that have this block as one of their successors
RZ_API void rz_analysis_block_automerge(RzList *blocks) {
RZ_API void rz_analysis_block_automerge(RzList /*<RzAnalysisBlock>*/ *blocks) {
rz_return_if_fail(blocks);
AutomergeCtx ctx = {
.predecessors = ht_up_new0(),
Expand Down
2 changes: 1 addition & 1 deletion librz/analysis/cc.c
Expand Up @@ -223,7 +223,7 @@ RZ_API const char *rz_analysis_cc_func(RzAnalysis *analysis, const char *func_na
return cc ? cc : rz_analysis_cc_default(analysis);
}

RZ_API RzList *rz_analysis_calling_conventions(RzAnalysis *analysis) {
RZ_API RzList /*<char*>*/ *rz_analysis_calling_conventions(RzAnalysis *analysis) {
RzList *ccl = rz_list_new();
SdbKv *kv;
SdbListIter *iter;
Expand Down
2 changes: 1 addition & 1 deletion librz/analysis/class.c
Expand Up @@ -608,7 +608,7 @@ RZ_API void rz_analysis_class_method_fini(RzAnalysisMethod *meth) {
free(meth->real_name);
}

RZ_API void rz_analysis_class_method_recover(RzAnalysis *analysis, RzBinClass *cls, RzList *methods) {
RZ_API void rz_analysis_class_method_recover(RzAnalysis *analysis, RzBinClass *cls, RzList /*<RzBinSymbol>*/ *methods) {
RzListIter *iter_method;
RzBinSymbol *sym;
rz_list_sort(methods, &symbol_method_sort_by_addr);
Expand Down
2 changes: 1 addition & 1 deletion librz/analysis/fcn.c
Expand Up @@ -2542,7 +2542,7 @@ static int typecmp(const void *a, const void *b) {
return !rz_types_equal(t1, t2);
}

RZ_API RZ_OWN RzList /* RzType */ *rz_analysis_types_from_fcn(RzAnalysis *analysis, RzAnalysisFunction *fcn) {
RZ_API RZ_OWN RzList /*<RzType>*/ *rz_analysis_types_from_fcn(RzAnalysis *analysis, RzAnalysisFunction *fcn) {
RzListIter *iter;
RzAnalysisVar *var;
RzList *list = rz_analysis_var_all_list(analysis, fcn);
Expand Down
2 changes: 1 addition & 1 deletion librz/analysis/reflines.c
Expand Up @@ -263,7 +263,7 @@ RZ_API RzList *rz_analysis_reflines_get(RzAnalysis *analysis, ut64 addr, const u
return NULL;
}

RZ_API int rz_analysis_reflines_middle(RzAnalysis *a, RzList * /*<RzAnalysisRefline>*/ list, ut64 addr, int len) {
RZ_API int rz_analysis_reflines_middle(RzAnalysis *a, RzList /*<RzAnalysisRefline>*/ *list, ut64 addr, int len) {
if (a && list) {
RzAnalysisRefline *ref;
RzListIter *iter;
Expand Down
2 changes: 1 addition & 1 deletion librz/analysis/rtti_msvc.c
Expand Up @@ -963,7 +963,7 @@ void str_value_free(HtUPKv *kv) {
free(kv->value);
}

RZ_API void rz_analysis_rtti_msvc_recover_all(RVTableContext *vt_context, RzList *vtables) {
RZ_API void rz_analysis_rtti_msvc_recover_all(RVTableContext *vt_context, RzList /*<RVTableInfo>*/ *vtables) {
RRTTIMSVCAnalContext context;
context.vt_context = vt_context;
rz_pvector_init(&context.vtables, (RzPVectorFree)rz_analysis_vtable_info_free);
Expand Down
2 changes: 1 addition & 1 deletion librz/analysis/vtable.c
Expand Up @@ -216,7 +216,7 @@ RZ_API RVTableInfo *rz_analysis_vtable_parse_at(RVTableContext *context, ut64 ad
return vtable;
}

RZ_API RzList *rz_analysis_vtable_search(RVTableContext *context) {
RZ_API RzList /*<RVTableInfo>*/ *rz_analysis_vtable_search(RVTableContext *context) {
RzAnalysis *analysis = context->analysis;
if (!analysis) {
return NULL;
Expand Down
7 changes: 5 additions & 2 deletions librz/bin/bfile.c
Expand Up @@ -481,8 +481,11 @@ RZ_API RZ_OWN RzList *rz_bin_file_compute_hashes(RzBin *bin, RzBinFile *bf, ut64
return NULL;
}

// Set new hashes to current RzBinInfo, caller should free the returned RzList
RZ_API RzList *rz_bin_file_set_hashes(RzBin *bin, RzList /*<RzBinFileHash*/ *new_hashes) {
/**
* \brief Set \p file_hashes on current RzBinInfo
* \return RzList of previous file_hashes
*/
RZ_API RZ_OWN RzList *rz_bin_file_set_hashes(RzBin *bin, RZ_OWN RzList /*<RzBinFileHash>*/ *new_hashes) {
rz_return_val_if_fail(bin && bin->cur && bin->cur->o && bin->cur->o->info, NULL);
RzBinFile *bf = bin->cur;
RzBinInfo *info = bf->o->info;
Expand Down
4 changes: 2 additions & 2 deletions librz/bin/bobj.c
Expand Up @@ -737,7 +737,7 @@ RZ_API const RzBinInfo *rz_bin_object_get_info(RzBinObject *obj) {
}

/**
* \brief Get list of \p RzBinLib representing the libraries used by the binary object.
* \brief Get list of \p char* representing the libraries used by the binary object.
*/
RZ_API const RzList *rz_bin_object_get_libs(RzBinObject *obj) {
rz_return_val_if_fail(obj, NULL);
Expand Down Expand Up @@ -1033,7 +1033,7 @@ RZ_API ut64 rz_bin_object_v2p(RzBinObject *obj, ut64 vaddr) {
*
* \return On success returns a valid pointer, otherwise NULL
*/
RZ_API RZ_OWN RzBinStrDb *rz_bin_string_database_new(RZ_NULLABLE RzList /*<RzBinString *>*/ *list) {
RZ_API RZ_OWN RzBinStrDb *rz_bin_string_database_new(RZ_NULLABLE RzList /*<RzBinString>*/ *list) {
RzBinStrDb *db = RZ_NEW0(RzBinStrDb);
if (!db) {
RZ_LOG_ERROR("rz_bin: Cannot allocate RzBinStrDb\n");
Expand Down
2 changes: 1 addition & 1 deletion librz/bin/i/private.h
Expand Up @@ -38,7 +38,7 @@ RZ_IPI RzBinFile *rz_bin_file_xtr_load_buffer(RzBin *bin, RzBinXtrPlugin *xtr, c
RZ_IPI RzBinFile *rz_bin_file_new_from_buffer(RzBin *bin, const char *file, RzBuffer *buf, RzBinObjectLoadOptions *opts, int fd, const char *pluginname);

struct rz_bin_string_database_t {
RzList /*<RzBinString*>*/ *list; ///< Contains all the strings in list form
RzList /*<RzBinString>*/ *list; ///< Contains all the strings in list form
HtUP /*<ut64, RzBinString*>*/ *phys; ///< Contains all the strings but mapped by physical address
HtUP /*<ut64, RzBinString*>*/ *virt; ///< Contains all the strings but mapped by virtual address
};
Expand Down
2 changes: 1 addition & 1 deletion librz/cons/hud.c
Expand Up @@ -199,7 +199,7 @@ static void mht_free_kv(HtPPKv *kv) {
// Display a list of entries in the hud, filtered and emphasized based on the user input.

#define HUD_CACHE 0
RZ_API char *rz_cons_hud(RzList *list, const char *prompt) {
RZ_API char *rz_cons_hud(RzList /*<char*>*/ *list, const char *prompt) {
char user_input[HUD_BUF_SIZE + 1];
char *selected_entry = NULL;
RzListIter *iter;
Expand Down

0 comments on commit af5d3db

Please sign in to comment.