Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL autocompletion #316

Open
ranocha opened this issue Jul 19, 2021 · 1 comment
Open

REPL autocompletion #316

ranocha opened this issue Jul 19, 2021 · 1 comment
Labels

Comments

@ranocha
Copy link

ranocha commented Jul 19, 2021

We are experimenting with the current master branch of Clang.jl in trixi-framework/P4est.jl#38. I noticed that there is no REPL tab completion for properties and structs defined automatically by Clang.jl (via field_access_method_list in the TOML file). For example, we get the following Julia code in the PR listed above.

struct p4est
    mpicomm::sc_MPI_Comm
    mpisize::Cint
    mpirank::Cint
    mpicomm_owned::Cint
    data_size::Csize_t
    user_pointer::Ptr{Cvoid}
    revision::Clong
    first_local_tree::p4est_topidx_t
    last_local_tree::p4est_topidx_t
    local_num_quadrants::p4est_locidx_t
    global_num_quadrants::p4est_gloidx_t
    global_first_quadrant::Ptr{p4est_gloidx_t}
    global_first_position::Ptr{p4est_quadrant_t}
    connectivity::Ptr{p4est_connectivity_t}
    trees::Ptr{sc_array_t}
    user_data_pool::Ptr{sc_mempool_t}
    quadrant_pool::Ptr{sc_mempool_t}
    inspect::Ptr{p4est_inspect_t}
end

function Base.getproperty(x::Ptr{p4est}, f::Symbol)
    f === :mpicomm && return Ptr{sc_MPI_Comm}(x + 0)
    f === :mpisize && return Ptr{Cint}(x + 4)
    f === :mpirank && return Ptr{Cint}(x + 8)
    f === :mpicomm_owned && return Ptr{Cint}(x + 12)
    f === :data_size && return Ptr{Csize_t}(x + 16)
    f === :user_pointer && return Ptr{Ptr{Cvoid}}(x + 24)
    f === :revision && return Ptr{Clong}(x + 32)
    f === :first_local_tree && return Ptr{p4est_topidx_t}(x + 40)
    f === :last_local_tree && return Ptr{p4est_topidx_t}(x + 44)
    f === :local_num_quadrants && return Ptr{p4est_locidx_t}(x + 48)
    f === :global_num_quadrants && return Ptr{p4est_gloidx_t}(x + 56)
    f === :global_first_quadrant && return Ptr{Ptr{p4est_gloidx_t}}(x + 64)
    f === :global_first_position && return Ptr{Ptr{p4est_quadrant_t}}(x + 72)
    f === :connectivity && return Ptr{Ptr{p4est_connectivity_t}}(x + 80)
    f === :trees && return Ptr{Ptr{sc_array_t}}(x + 88)
    f === :user_data_pool && return Ptr{Ptr{sc_mempool_t}}(x + 96)
    f === :quadrant_pool && return Ptr{Ptr{sc_mempool_t}}(x + 104)
    f === :inspect && return Ptr{Ptr{p4est_inspect_t}}(x + 112)
    return getfield(x, f)
end

However, tab completion in the REPL does not work for Ptr{p4est}, i.e. there is no useful suggestion when typing x. and tab. It would be great to get this kind of REPL tab completion.

@Gnimuc Gnimuc added the good first issue Good for newcomers label Jul 19, 2021
@Gnimuc Gnimuc added this to the release-0.14.0 milestone Jul 19, 2021
@Gnimuc
Copy link
Member

Gnimuc commented Jul 19, 2021

We need to emit Base.propertynames exprs for those Ptr types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants