Skip to content

[Feature] Add afterCompile transform hook #702

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

Closed
jtenner opened this issue Jul 2, 2019 · 1 comment
Closed

[Feature] Add afterCompile transform hook #702

jtenner opened this issue Jul 2, 2019 · 1 comment

Comments

@jtenner
Copy link
Contributor

jtenner commented Jul 2, 2019

Use-case is dealing with reflection in my testing library. For example, given the following code snippet:

class Vec3 {
  constructor(
    public x: f64 = 0.0,
    public y: f64 = 0.0,
    public z: f64 = 0.0,
  ) {}
}

I would like to compile a few top-level statements:

// Just using this namespace as an example
Reflection.addClass(idof<Vec3>(), "Vec3");
Reflection.addClassProp(idof<Vec3>(), "x", offsetof<Vec3>("x"), Reflection.F64, 0 /* idof<T>() if reference*/);

I'm ready to do a lot of trial and error to reduce these down to something that looks like this:

Reflection.addClass(4, "Vec3"); // since id is known as a constant

Just need a way to push some statements to be parsed the backlog and this would be relatively easy.

module.exports = {
  afterCompile(parser: Parser): void  { // where do I get the class definition for this parameter?
    parser.managedClasses; // should be useful
  } 
}

Thoughts?

@MaxGraey
Copy link
Member

Should be landed in #892

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

Successfully merging a pull request may close this issue.

3 participants