Skip to content

Stringify on AnyPointer #397

Open
Open
@schreter

Description

@schreter

Now that dynamic reflection landed in capnp-rust (big thanks to David), we can easily Debug-print any capnp struct. However, these structs may contain AnyPointer, which currently doesn't print its own contents (for obvious reasons).

For example, in our project, we use AnyPointer in a generic outer request type to store the inner request. The inner request's structure ID is stored in the generic part and it's used for dispatching the inner request in the server. Now that we have reflection, we can print the contents of the outer and inner request for debugging purposes using our hand-crafted Debug implementation, based on the standard implementation in capnp.

However, I assume, our project is not the only one which uses AnyPointer. So the suggestion is to add a anyptr-debug-print hook to register a method to interpret the AnyPointer as a pointer to something else and/or to print it in the hook itself by dynamically evaluating the current structure containing the AnyPointer in question via the hook. Unfortunately, the formatter currently just gets the access to the pointer, but not to the outer structure, so the print function would require additional parameters for the optional parent dynamic structure and parent's field index which is being evaluated to be able to pass them to the hook to reinterpret the AnyPointer properly.

Opinions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions