Skip to content

Commit

Permalink
- Add external field to skip signature decoration (#40)
Browse files Browse the repository at this point in the history
* - Add external field to skip signature decoration
  • Loading branch information
tikimcfee authored and johnno1962 committed Apr 23, 2022
1 parent 6e4fc0f commit 37652bb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion SwiftTrace/SwiftArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2020 John Holdsworth. All rights reserved.
//
// Repo: https://github.com/johnno1962/SwiftTrace
// $Id: //depot/SwiftTrace/SwiftTrace/SwiftArgs.swift#193 $
// $Id: //depot/SwiftTrace/SwiftTrace/SwiftArgs.swift#194 $
//
// Decorate trace with argument/return values
// ==========================================
Expand Down Expand Up @@ -94,6 +94,12 @@ public func returner<Type>(value: Type, out: inout Any?) {
}

extension SwiftTrace {

/**
'false' skips any decoration steps when visiting Swift code
'true' decorates normally
*/
static public var swiftDecorateArgs = (onEntry: true, onExit: true)

/**
Enable auto decoration of unknown types
Expand Down Expand Up @@ -297,6 +303,8 @@ extension SwiftTrace {
substitute argument values into signature on method entry
*/
open override func entryDecorate(stack: inout EntryStack) -> String? {
guard SwiftTrace.swiftDecorateArgs.onEntry else { return signature }

let invocation = self.invocation()!
return objcMethod != nil ?
objcDecorate(signature: nil, invocation: invocation) :
Expand All @@ -308,6 +316,8 @@ extension SwiftTrace {
Determine return value on method exit
*/
open override func exitDecorate(stack: inout ExitStack) -> String? {
guard SwiftTrace.swiftDecorateArgs.onExit else { return signature }

let invocation = self.invocation()!
return objcMethod != nil ?
objcDecorate(signature: invocation.decorated ?? signature,
Expand Down

0 comments on commit 37652bb

Please sign in to comment.