Skip to content

Commit

Permalink
add context wrappedTargetCode
Browse files Browse the repository at this point in the history
  • Loading branch information
dengsgo committed Jan 6, 2024
1 parent f160e39 commit 7526cc1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions decor/wrapped_code.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package decor

func wrappedTargetCode( /* in1, in2, ... */) /* (out1, out2, ...) */ {
varDecorContext := Context{
Kind: KFunc, // KFunc / KMethod
Receiver: nil, // wrapped method receiver
TargetName: "", // wrapped function/method name
TargetIn: []any{ /*in1, in2, ....*/ },
TargetOut: []any{ /*out1, out2, ....*/ },
}
varDecorContext.Func = func() {
/* varDecorContext.TargetOut[0], varDecorContext.TargetOut[1], ... = */ func( /* in1, in2, ... */) /* (out1, out2, ...) */ {

// Here is code for the original target.

}( /* varDecorContext.TargetIn[0], varDecorContext.TargetIn[1], ... */)
}

/* decoratorFunc(varDecorContext, ...#{key: value}) */ // execute the decorator function

return /* varDecorContext.TargetOut[0], varDecorContext.TargetOut[1], ... */
}

0 comments on commit 7526cc1

Please sign in to comment.