diff --git a/gen/generator.toml b/gen/generator.toml index 9d422b86..d6026f50 100644 --- a/gen/generator.toml +++ b/gen/generator.toml @@ -44,9 +44,9 @@ prologue_file_path = "./prologue.jl" # this is often used for applying custom patches. epilogue_file_path = "" -# node with an id in the `printer_blacklist` will be ignored in the printing passes. +# node with an id in the `printer_denylist` will be ignored in the printing passes. # this is very useful for custom editing. -printer_blacklist = [ +printer_denylist = [ "CINDEX_EXPORTS", "CINDEX_VERSION", "CINDEX_VERSION_STRING", @@ -115,11 +115,11 @@ auto_mutability_with_new = true # when calling this function via `ccall`, passing a `Vector{mutable_type}(undef, n)` to the first # argument will trigger a crash, the reason is mutable structs are not stored inline within a `Vector`, # one should use `Ref{NTuple{n,mutable_type}}()` instead. -# this is not convenient and that's where the `auto_mutability_blacklist` comes in. -auto_mutability_blacklist = [] +# this is not convenient and that's where the `auto_mutability_denylist` comes in. +auto_mutability_denylist = [] -# opposite to `auto_mutability_blacklist` and has a higher priority -auto_mutability_whitelist = [] +# opposite to `auto_mutability_denylist` and has a higher priority +auto_mutability_allowlist = [] # if set to "raw", extract and dump raw c comment; # if set to "doxygen", parse and format doxygen comment. @@ -176,7 +176,7 @@ function_argument_conflict_symbols = [] macro_mode = "basic" # function-like macros in the following list will always be translated. -functionlike_macro_whitelist = [ +functionlike_macro_allowlist = [ "CINDEX_VERSION_ENCODE", ] diff --git a/src/generator/macro.jl b/src/generator/macro.jl index 3efc3420..8653c9e2 100644 --- a/src/generator/macro.jl +++ b/src/generator/macro.jl @@ -195,8 +195,8 @@ is_macro_definition_only(toks::Vector) = length(toks) == 1 && is_identifier(toks is_macro_definition_only(toks::TokenList) = toks.size == 1 && is_identifier(toks[1]) is_macro_definition_only(cursor::CLCursor) = is_macro_definition_only(tokenize(cursor)) -# identifier and keyword blacklist -const MACRO_IDK_BLACKLIST = [ +# identifier and keyword denylist +const MACRO_IDK_DENYLIST = [ C_KEYWORDS_UNSUPPORTED..., "_Pragma", "__attribute__", @@ -214,9 +214,9 @@ Return true if the macro should be ignored. """ function is_macro_unsupported(cursor::CLCursor) for tok in tokenize(cursor) - is_identifier(tok) && tok.text ∈ MACRO_IDK_BLACKLIST && return true - is_keyword(tok) && tok.text ∈ MACRO_IDK_BLACKLIST && return true - is_punctuation(tok) && tok.text ∈ MACRO_IDK_BLACKLIST && return true + is_identifier(tok) && tok.text ∈ MACRO_IDK_DENYLIST && return true + is_keyword(tok) && tok.text ∈ MACRO_IDK_DENYLIST && return true + is_punctuation(tok) && tok.text ∈ MACRO_IDK_DENYLIST && return true end return false end @@ -335,13 +335,13 @@ end function macro_emit!(dag::ExprDAG, node::ExprNode{MacroFunctionLike}, options::Dict) print_comment = get(options, "add_comment_for_skipped_macro", true) mode = get(options, "macro_mode", "basic") - whitelist = get(options, "functionlike_macro_whitelist", String[]) + allowlist = get(options, "functionlike_macro_allowlist", String[]) cursor = node.cursor toks = collect(tokenize(cursor)) tokens = tweak_exprs(dag, toks) id = tokens[1].text - mode != "aggressive" && id ∉ whitelist && return dag + mode != "aggressive" && id ∉ allowlist && return dag lhs_sym = make_symbol_safe(id) diff --git a/src/generator/passes.jl b/src/generator/passes.jl index 2f95b0cb..ce1099af 100644 --- a/src/generator/passes.jl +++ b/src/generator/passes.jl @@ -678,10 +678,10 @@ In this pass, the mutability of those structs which are not necessary to be immu will be reset to `true` according to the following rules: if this type is not used as a field type in any other types - if this type is in the whitelist + if this type is in the allowlist then reset - if this type is in the blacklist + if this type is in the denylist then skip if this type is used as the argument type in some function protos @@ -704,8 +704,8 @@ function (x::TweakMutability)(dag::ExprDAG, options::Dict) general_options = get(options, "general", Dict()) log_options = get(general_options, "log", Dict()) show_info = get(log_options, "TweakMutability_log", x.show_info) - blacklist = get(general_options, "auto_mutability_blacklist", []) - whitelist = get(general_options, "auto_mutability_whitelist", []) + denylist = get(general_options, "auto_mutability_denylist", get(general_options, "auto_mutability_blacklist", [])) + allowlist = get(general_options, "auto_mutability_allowlist", get(general_options, "auto_mutability_whitelist", [])) add_new = get(general_options, "auto_mutability_with_new", true) # collect referenced node ids @@ -731,9 +731,9 @@ function (x::TweakMutability)(dag::ExprDAG, options::Dict) type_name = string(expr.args[2]) apply_reset = false - if type_name ∈ whitelist + if type_name ∈ allowlist apply_reset = true - elseif type_name ∈ blacklist + elseif type_name ∈ denylist apply_reset = false else apply_reset = should_tweak(dag.nodes, i) @@ -832,12 +832,12 @@ function (x::FunctionPrinter)(dag::ExprDAG, options::Dict) general_options = get(options, "general", Dict()) log_options = get(general_options, "log", Dict()) show_info = get(log_options, "FunctionPrinter_log", x.show_info) - blacklist = get(general_options, "printer_blacklist", []) + denylist = get(general_options, "printer_denylist", get(general_options, "printer_blacklist", [])) show_info && @info "[FunctionPrinter]: print to $(x.file)" open(x.file, "w") do io for node in dag.nodes - string(node.id) ∈ blacklist && continue + string(node.id) ∈ denylist && continue node.type isa AbstractFunctionNodeType || continue pretty_print(io, node, general_options) end @@ -859,18 +859,18 @@ function (x::CommonPrinter)(dag::ExprDAG, options::Dict) general_options = get(options, "general", Dict()) log_options = get(general_options, "log", Dict()) show_info = get(log_options, "CommonPrinter_log", x.show_info) - blacklist = get(general_options, "printer_blacklist", []) + denylist = get(general_options, "printer_denylist", get(general_options, "printer_blacklist", [])) show_info && @info "[CommonPrinter]: print to $(x.file)" open(x.file, "w") do io for node in dag.nodes - string(node.id) ∈ blacklist && continue - (node.type isa AbstractMacroNodeType || node.type isa AbstractFunctionNodeType) && continue + string(node.id) ∈ denylist && continue + node.type isa AbstractMacroNodeType && continue pretty_print(io, node, general_options) end # print macros in the bottom of the file for node in dag.nodes - string(node.id) ∈ blacklist && continue + string(node.id) ∈ denylist && continue node.type isa AbstractMacroNodeType || continue pretty_print(io, node, options) end @@ -892,19 +892,19 @@ function (x::GeneralPrinter)(dag::ExprDAG, options::Dict) general_options = get(options, "general", Dict()) log_options = get(general_options, "log", Dict()) show_info = get(log_options, "GeneralPrinter_log", x.show_info) - blacklist = get(general_options, "printer_blacklist", []) + denylist = get(general_options, "printer_denylist", get(general_options, "printer_blacklist", [])) general_options["DAG_ids"] = merge(dag.ids, dag.tags) show_info && @info "[GeneralPrinter]: print to $(x.file)" open(x.file, "a") do io for node in dag.nodes - string(node.id) ∈ blacklist && continue + string(node.id) ∈ denylist && continue node.type isa AbstractMacroNodeType && continue pretty_print(io, node, general_options) end # print macros in the bottom of the file for node in dag.nodes - string(node.id) ∈ blacklist && continue + string(node.id) ∈ denylist && continue node.type isa AbstractMacroNodeType || continue isempty(node.exprs) pretty_print(io, node, options) @@ -928,16 +928,16 @@ function (x::StdPrinter)(dag::ExprDAG, options::Dict) general_options = get(options, "general", Dict()) log_options = get(general_options, "log", Dict()) show_info = get(log_options, "StdPrinter_log", x.show_info) - blacklist = get(general_options, "printer_blacklist", []) + denylist = get(general_options, "printer_denylist", get(general_options, "auto_mutability_blacklist", [])) for node in dag.nodes - string(node.id) ∈ blacklist && continue + string(node.id) ∈ denylist && continue node.type isa AbstractMacroNodeType && continue pretty_print(stdout, node, general_options) end # print macros for node in dag.nodes - string(node.id) ∈ blacklist && continue + string(node.id) ∈ denylist && continue node.type isa AbstractMacroNodeType || continue pretty_print(stdout, node, options) end @@ -1101,4 +1101,4 @@ function collect_nested_tags(dag::ExprDAG) end end nested_tags -end \ No newline at end of file +end