Skip to content

What is a good strategy to extract information out of ParseCallbacks? #2147

@N3xed

Description

@N3xed

I'd like to extract information from ParseCallbacks so that it can be used later in the build script.

For example:

I have three C macros:

  • VERSION_MAJOR
  • VERSION_MINOR
  • VERSION_PATCH

which all define a number and so get forwarded to ParseCallbacks::int_macro. Now in my implementation of that callback, I want to capture these integers for use later in the build script.

Currently, as I see it, the only option is to use Atomic* or Mutex as the bound on ParseCallbacks specifies UnwindSafe which references to types with interior mutability are not, and the callbacks themselves only get a shared reference to self.
This works but is not pretty and may incur performance penalties for Mutex.

So my questions are:

  • What is the preferred strategy for doing something like that?
    (More so with a less trivial example that requires more complex data e.g. ParseCallbacks::func_macro)
  • Why do these functions not get a mutable reference to self if the callbacks don't need to be Send/Sync?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions