-
Notifications
You must be signed in to change notification settings - Fork 12
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
Create anchors for pointer-based arguments to initializers #103
Conversation
e53c45f
to
6eae29b
Compare
6eae29b
to
d3bcd0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this!
let returnValueHandlingPrefix = ''; | ||
let returnValueHandlingSuffix = ''; | ||
if (swiftMethodName === 'init') { | ||
anchoringCommand = anchoringCommand.replaceAll('returnValue.addAnchor(', 'self.addAnchor(') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just define two separate commands instead of reusing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could, but I do like that this doesn't mess with the indentation.
@@ -807,6 +815,10 @@ export abstract class BaseTypeGenerator<Type extends RustType> { | |||
} | |||
`; | |||
|
|||
if(memoryContext && memoryContext.isConstructor && (argument.type instanceof RustStruct || argument.type instanceof RustTaggedValueEnum || argument.type instanceof RustResult)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a brief comment here explaining what anchoring is and why we it is required in these cases in particular?
@@ -1284,6 +1296,11 @@ export interface PreparedArgument { | |||
* memory deallocation or, ironically, retention beyond the call site | |||
*/ | |||
deferredCleanup: string | |||
|
|||
/** | |||
* If true (only applicable in constructors), add a `self.addAnchor` call after super.init() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC there are however other cases were the anchors are added, not only upon init
?
@@ -301,9 +302,13 @@ public class HumanObjectPeerTestInstance { | |||
// channel manager constructor is mandatory | |||
|
|||
let graph = NetworkGraph(network: .Regtest, logger: self.logger) | |||
var scorerGraph = graph | |||
if(master.configuration.ephemeralNetworkGraphForScorer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could add some space after if
and drop the parentheses.
@@ -465,6 +465,9 @@ class LDKSwiftTests: XCTestCase { | |||
|
|||
config.useRouter = (i & (1 << 2)) != 0 | |||
print("useRouter: \(config.useRouter)") | |||
|
|||
config.ephemeralNetworkGraphForScorer = (i & (1 << 3)) != 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: May want to add a comment on how these magic shiftings work.
@@ -465,6 +465,9 @@ class LDKSwiftTests: XCTestCase { | |||
|
|||
config.useRouter = (i & (1 << 2)) != 0 | |||
print("useRouter: \(config.useRouter)") | |||
|
|||
config.ephemeralNetworkGraphForScorer = (i & (1 << 3)) != 0 | |||
print("ephemeralNetworkGraphForScorer: \(config.ephemeralNetworkGraphForScorer)") | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can we drop the commented-out code here and above while we're here?
Fixes #102.