Skip to content

Commit

Permalink
Enable ObjectiveC framework enum and struct parsing (#524)
Browse files Browse the repository at this point in the history
* Properly skip `EnumForwardDecl`s even with attributes

* Split up `create_context`

* Skip ObjectiveC nodes
  • Loading branch information
christiangnrd authored Jan 18, 2025
1 parent 76f5d57 commit 6c3b0ac
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/generator/context.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ function create_context(headers::Vector, args::Vector=String[], options::Dict=Di
@info "Parsing headers..."
parse_headers!(ctx, headers, args)

add_default_passes!(ctx, options, system_dirs, dependent_headers)
end

function add_default_passes!(ctx::AbstractContext, options::Dict, system_dirs::Vector, dependent_headers::Vector)

push!(ctx.passes, CollectTopLevelNode(ctx.trans_units, dependent_headers, system_dirs))
push!(ctx.passes, LinkTypedefToAnonymousTagType())
push!(ctx.passes, LinkTypedefToAnonymousTagType(is_system=true))
Expand Down
17 changes: 17 additions & 0 deletions src/generator/top_level.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,23 @@ function collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::CLEnumDecl, o
return nodes
end

# TODO: Implement full ObjectiveC codegen
function collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::CLObjCClassRef, options)
return nodes
end
function collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::CLObjCProtocolDecl, options)
return nodes
end
function collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::CLObjCProtocolRef, options)
return nodes
end
function collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::CLObjCInterfaceDecl, options)
return nodes
end
function collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::CLObjCCategoryDecl, options)
return nodes
end

# skip macro expansion since the expanded info is already embedded in the AST
collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::CLMacroInstantiation, options) = nodes
collect_top_level_nodes!(nodes::Vector{ExprNode}, cursor::CLMacroExpansion, options) = nodes
Expand Down
2 changes: 1 addition & 1 deletion src/generator/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct EnumDuplicated <: AbstractEnumNodeType end
struct EnumDefault <: AbstractEnumNodeType end

"""
EnumLayout{Attribute} <: AbstractStructNodeType
EnumLayout{Attribute} <: AbstractEnumNodeType
Enum nodes that have special layout.
"""
struct EnumLayout{Attribute} <: AbstractEnumNodeType end
Expand Down

0 comments on commit 6c3b0ac

Please sign in to comment.