diff --git a/gen/generator.toml b/gen/generator.toml index f26da0f1..d377dc63 100644 --- a/gen/generator.toml +++ b/gen/generator.toml @@ -169,6 +169,9 @@ field_access_method_list = [] # prevent the generated symbols from conflicting with the symbols defined and exported in Base. function_argument_conflict_symbols = [] +# if set to true, static functions will be ignored +skip_static_functions = false + # emit constructors for all custom-layout structs like bitfield in the list, # or set to `true` to do so for all such structs add_record_constructors = [] diff --git a/src/generator/Generators.jl b/src/generator/Generators.jl index 0aff527f..998c8c0e 100644 --- a/src/generator/Generators.jl +++ b/src/generator/Generators.jl @@ -15,6 +15,7 @@ using ..Clang: getArgument, getCursorType, getCanonicalType, + getCursorLinkage, getCursorResultType, getElementType, getEnumDeclIntegerType, diff --git a/src/generator/top_level.jl b/src/generator/top_level.jl index fc0ef12d..840bd758 100644 --- a/src/generator/top_level.jl +++ b/src/generator/top_level.jl @@ -12,6 +12,9 @@ function collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::CLCursor, opt end function collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::CLFunctionDecl, options) + skip_static_func = get(options, "skip_static_functions", false) + skip_static_func && getCursorLinkage(cursor) == CXLinkage_Internal && return nodes + func_type = getCursorType(cursor) if kind(func_type) == CXType_FunctionNoProto diff --git a/test/generators.jl b/test/generators.jl index 092620a3..1199c24e 100644 --- a/test/generators.jl +++ b/test/generators.jl @@ -180,3 +180,9 @@ end ctx = create_context([joinpath(@__DIR__, "include/struct-mutual-ref.h")], get_default_args()) @test_logs (:info, "Done!") match_mode = :any build!(ctx) end + +@testset "Issue 455 - skip static functions" begin + options = Dict("general" => Dict{String,Any}("skip_static_functions" => true)) + ctx = create_context([joinpath(@__DIR__, "include/static.h")], get_default_args(), options) + @test_logs (:info, "Done!") match_mode = :any build!(ctx) +end diff --git a/test/include/static.h b/test/include/static.h new file mode 100644 index 00000000..a668793d --- /dev/null +++ b/test/include/static.h @@ -0,0 +1,9 @@ +#ifndef STATIC_H +#define STATIC_H + +static inline int skip_static(void) +{ + return 0; +} + +#endif \ No newline at end of file