diff --git a/gen/src/MPIgenerator.jl b/gen/src/MPIgenerator.jl index 11b7bf7c5..fff6d46dc 100644 --- a/gen/src/MPIgenerator.jl +++ b/gen/src/MPIgenerator.jl @@ -12,54 +12,17 @@ module MPIgenerator error("Unknown MPI binary: $(MPIPreferences.binary)") end - @eval Clang.Generators translate(jlty::JuliaCpointer, options=Dict()) = begin - # @show jlty getPointeeType(jlty.ref) getNamedType(getPointeeType(jlty.ref)) propertynames(jlty) - is_jl_funcptr(jlty) && return translate(JuliaPtrCvoid(), options) - jlptree = tojulia(getPointeeType(jlty.ref)) - if get(options, "always_NUL_terminated_string", false) - is_jl_char(jlptree) && return :Cstring - is_jl_wchar(jlptree) && return :Cwstring + @eval Clang.Generators _get_func_arg(cursor::CLFunctionDecl, options, dag) = begin + arg_names, args = invoke(_get_func_arg, NTuple{3,Any}, cursor, options, dag) + + re = r"^type_(.*)_fn" + for (i, (name, arg)) in enumerate(zip(arg_names, args)) + match(re, string(name)) ≡ nothing && continue + arg != :(Ptr{Cvoid}) && continue + args[i] = :($(Symbol(replace(string(name), re => s"MPI_Type_\1_function")))) end - return Expr(:curly, :Ptr, translate(jlptree, options)) - end - rewrite!(dag::ExprDAG) = begin - replace!(get_nodes(dag)) do node - # signature = name(node.cursor) - # @show signature node.cursor - - for a in get_function_args(node.cursor) - startswith(name(a), "type_") || continue - # @show a, typeof(a) - if (ct = Clang.getCursorType(a)) isa CLPointer - # @show translate(tojulia(ct)) - # if Clang.Generators.is_jl_funcptr(tojulia(ct)) - if (pt = Clang.getPointeeType(ct)) isa CLTypedef - dumpobj(a) - repl = "MPI_" * replace(name(a), "type_" => "Type_") - @show repl - # FIXME: how do we replace node function arguments ? - # translate(tojulia(ct)) should replace "Ptr{Cvoid}" => repl - - # the following approach doesn't work since some information is lost during julia code generation - #= - replace!(get_exprs(node)) do ex - out = Expr(ex.head) - for a in ex.args - push!(out.args, a) - end - @show out - out - end - =# - end - # end - end - end - # dump(node) - - node - end + arg_names, args end signatures() = begin @@ -85,9 +48,7 @@ module MPIgenerator ctx = create_context(headers, args, options) - build!(ctx, BUILDSTAGE_NO_PRINTING) - rewrite!(ctx.dag) - build!(ctx, BUILDSTAGE_PRINTING_ONLY) + build!(ctx) # run generator ############################ # custom MPI post-processing diff --git a/src/api/generated_api.jl b/src/api/generated_api.jl index db1efa6b9..245b8279b 100644 --- a/src/api/generated_api.jl +++ b/src/api/generated_api.jl @@ -204,7 +204,7 @@ end $(_doc_external(:MPI_Type_create_keyval)) """ function MPI_Type_create_keyval(type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state) - @mpichk ccall((:MPI_Type_create_keyval, libmpi), Cint, (MPIPtr, MPIPtr, Ptr{Cint}, MPIPtr), type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state) + @mpichk ccall((:MPI_Type_create_keyval, libmpi), Cint, (MPI_Type_copy_attr_function, MPI_Type_delete_attr_function, Ptr{Cint}, MPIPtr), type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state) end """ @@ -5118,7 +5118,7 @@ end $(_doc_external(:PMPI_Type_create_keyval)) """ function PMPI_Type_create_keyval(type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state) - @mpichk ccall((:PMPI_Type_create_keyval, libmpi), Cint, (MPIPtr, MPIPtr, Ptr{Cint}, MPIPtr), type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state) + @mpichk ccall((:PMPI_Type_create_keyval, libmpi), Cint, (MPI_Type_copy_attr_function, MPI_Type_delete_attr_function, Ptr{Cint}, MPIPtr), type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state) end """ @@ -9960,7 +9960,7 @@ end $(_doc_external(:QMPI_Type_create_keyval)) """ function QMPI_Type_create_keyval(context, tool_id, type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state) - @mpichk ccall((:QMPI_Type_create_keyval, libmpi), Cint, (QMPI_Context, Cint, MPIPtr, MPIPtr, Ptr{Cint}, MPIPtr), context, tool_id, type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state) + @mpichk ccall((:QMPI_Type_create_keyval, libmpi), Cint, (QMPI_Context, Cint, MPI_Type_copy_attr_function, MPI_Type_delete_attr_function, Ptr{Cint}, MPIPtr), context, tool_id, type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state) end """