GMLC-TDC / cheader2json

libclang parser to dump c header info to json
2 stars 0 forks source link

Missing argument names in JSON output for function pointer typedefs #84

Open webfolderio opened 2 days ago

webfolderio commented 2 days ago

The JSON output for function pointer typedefs (like TraceLogCallback) is missing argument names.

Example header:

#ifndef RLAPI
    #define RLAPI
#endif

#include <stdarg.h>

typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args);

RLAPI void SetTraceLogCallback(TraceLogCallback callback);

JSON output:

{
    "kind": "TYPEDEF_DECL",
    "spelling": "TraceLogCallback",
    "type": "void (*)(int, const char *, va_list)",
    "start_line": 7,
    "end_line": 7
}

Expected: JSON should include argument names (logLevel, text, args).

nightlark commented 1 day ago

How would you want the argument names to be included? My initial take is something like this (though it wouldn't handle type names of a nested function pointer that gets taken as an argument):

"arguments": [
    {
        "name": "logLevel",
        "type": "int"
    },
    {
        "name": "text",
        "type": "const char *"
    },
    {
        "name": "args",
        "type": "va_list"
    }
]
webfolderio commented 1 day ago

The suggested JSON format looks good. Thanks for the quick response.