Skip to content

.wrapped wrapper should get access to context data #263

@kristian

Description

@kristian

Sometimes a .wrapped wrapper requires access to context data, e.g. in order to decrypt a payload, one would need the decryption key. Thus the wrapper function should be able to access this (as it's current context) similar to how e.g. formatters are able to access the current context.

I am not deeply familiar with the code generation part, however as far as I can judge, the "this" refrence in the generateWrapper code:

    ctx.pushCode(
      `${wrappedBuf} = ${func}.call(this, ${wrappedBuf}).subarray(0);`,
    );

Doesn't make any sense, as this is the global scope and should be changed to:

    ctx.pushCode(
      `${wrappedBuf} = ${func}.call(${ctx.generateVariable()}, ${wrappedBuf}).subarray(0);`,
    );

As for other calls to imports.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions