Function
methodCode(_:initialIndentation:record:allowConstructor:functionPrefix:avoiding:publicDesignation:convertName:ptr:)
Swift code for methods (with a given indentation)
func methodCode(_ indentation: String, initialIndentation: String? = nil, record: GIR.Record? = nil, allowConstructor: Bool = true, functionPrefix: String = "", avoiding existingNames: Set<String> = [], publicDesignation: String = "public ", convertName: @escaping (String) -> String = { $0.snakeCase2camelCase }, ptr ptrName: String = "ptr") -> (GIR.Method) -> String
Return Value
The Swift code for the method.
Discussion
This function generates Swift code for a method, including the function declaration, the invocation of the underlying C function, and the return statement.
-
indentation: The indentation (string of spaces) to use for the code.
-
initialIndentation: The indentation (string of spaces) to use for the first line of the code.
-
record: The record (class) to which the method belongs (if any).
-
allowConstructor: Whether to allow the method to be a constructor (should be
falsefor instance methods and protocol extensions). -
functionPrefix: The prefix to use for the function name (e.g. “new” for constructors).
-
existingNames: A set of names that are already used (to avoid name clashes).
-
publicDesignation: The designation to use for the method (e.g. “public “, or “” for public protocol extensions).
-
convertName: A function to convert the name of the method to a Swift name).
-
ptrName: The name of the pointer to the underlying C record.